sdl-2

SDL2 on Raspberry Pi without X?

大憨熊 提交于 2020-01-13 19:52:05
问题 I'm hoping to develop some code that uses SDL2 to display graphics on the 7" RPi touchscreen, but I'd rather not install a full desktop OS. I've got Raspbian Buster Lite installed. Some simple test code gets an error when I try to run it: user@rpi4:~/01_hello_SDL $ ./hw Window could not be created! SDL_Error: Could not initialize EGL user@rpi4:~/01_hello_SDL $ sudo ./hw error: XDG_RUNTIME_DIR not set in the environment. Window could not be created! SDL_Error: Could not initialize EGL I'm

SDL2 - Check if OpenGL context is created

♀尐吖头ヾ 提交于 2020-01-13 09:32:49
问题 I am creating an application using SDL2 & OpenGL, and it worked fine on 3 different computers. But on another computer (an updated arch linux), it doesn't, and it crashes with this error: OpenGL context already created So my question is: How do I check if the OpenGL context has already been created? And then, if it is already created, how do I get a handle for it? If I can't do this, how do I bypass this issue? 回答1: SDL2 does not in fact create an OpenGL context without you asking to make one

SDL2 - Check if OpenGL context is created

安稳与你 提交于 2020-01-13 09:32:11
问题 I am creating an application using SDL2 & OpenGL, and it worked fine on 3 different computers. But on another computer (an updated arch linux), it doesn't, and it crashes with this error: OpenGL context already created So my question is: How do I check if the OpenGL context has already been created? And then, if it is already created, how do I get a handle for it? If I can't do this, how do I bypass this issue? 回答1: SDL2 does not in fact create an OpenGL context without you asking to make one

SDL2 - Check if OpenGL context is created

会有一股神秘感。 提交于 2020-01-13 09:32:00
问题 I am creating an application using SDL2 & OpenGL, and it worked fine on 3 different computers. But on another computer (an updated arch linux), it doesn't, and it crashes with this error: OpenGL context already created So my question is: How do I check if the OpenGL context has already been created? And then, if it is already created, how do I get a handle for it? If I can't do this, how do I bypass this issue? 回答1: SDL2 does not in fact create an OpenGL context without you asking to make one

SDL2 How to position a window on a second monitor?

爷,独闯天下 提交于 2020-01-12 08:22:09
问题 I am using SDL_SetWindowPosition to position my window. Can I use this function to position my window on another monitor? UPDATE Using SDL_GetDisplayBounds will not return the correct monitor positions when the text size is changed in Windows 10. Any ideas how to fix this? 回答1: SDL2 uses a global screen space coordinate system. Each display device has its own bounds inside this coordinate space. The following example places a window on a second display device: // enumerate displays int

Android Studio, NDK - Cannot Run Application

强颜欢笑 提交于 2020-01-07 04:44:13
问题 I have managed to (finally) build a test SDL2 app with Android Studio & NDK using the Gradle experimental plugin. When I try to run the project, it won't run. I get the following error: :app:compileDebugSources :app:transformClassesAndResourcesWithExtractJarsForDebug UP-TO-DATE :app:transformClassesWithDexForDebug UP-TO-DATE :app:processDebugJavaRes UP-TO-DATE :app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE :app:validateDebugSigning :app:packageDebug FAILED FAILURE: Build failed

Conway's Game of Life: cell changes being calculated incorrectly after changing neighbour count function

南笙酒味 提交于 2020-01-06 15:32:34
问题 Wondering if someone could help me work out this little issue. I've written a function to count the living neighbours of a cell in Conway's Game of Life: int countLivingNeighbours(int a[][GRID_WIDTH], int x, int y){ int count = 0, cx, cy; for(cy = y - 1; cy <= y + 1; cy++){ for(cx = x - 1; cx <= x + 1; cx++){ if(a[cy][cx] == ALIVE){ count++; } } } // subtract 1 so it's not counting it's own cell count--; return count; } It takes a 2-dimensional array of all cells as an argument, along with

Font rendering (Freetype) with openGL ES 2.0 combined with other line drawing functions does not work

左心房为你撑大大i 提交于 2020-01-06 06:25:27
问题 This thread is related to https: //stackoverflow.com/questions/50955558/render-fonts-with-sdl2-opengl-es-2-0-glsl-1-0-freetype I have a problem combining font rendering and using this function as follows: // Create VBO (Vertex Buffer Object) based on the vertices provided, render the vertices on the // background buffer and eventually swap buffers to update the display. // Return index of VBO buffer GLuint drawVertices(SDL_Window *window, Vertex *vertices, GLsizei numVertices, int mode){ //

The application was unable to start correctly (0xc000007b) error when working with SDL2 C++

情到浓时终转凉″ 提交于 2020-01-05 06:04:24
问题 Ok so here's the problem. Recently I got interested in C++ game programming and I was working with SDL2 libraries. Everything worked fine up until I wanted to load SDL2 Image libraries. The first problem I encountered was that the first setup I was working with x64 libraries but there were some issues with running the code so I changed it to x86. I changed the Linker -> Additional Library Directories from x64 to x86, Platform from x64 to All platforms as well as Executable Directories and

SDL2 & SMPEG2 - Empty sound buffer trying to read a MP3

天涯浪子 提交于 2020-01-04 07:27:10
问题 I'm trying to load a MP3 in a buffer using the SMPEG2 library, which comes with the SDL2. Every SMPEG function calls returns without error, but when I'm done, the sound buffer is full of zeros. Here's the code : bool LoadMP3(char* filename) { bool success = false; const Uint32 Mp3ChunkLen = 4096; SMPEG* mp3; SMPEG_Info infoMP3; Uint8 * ChunkBuffer; Uint32 MP3Length = 0; // Allocate a chunk buffer ChunkBuffer = (Uint8*)malloc(Mp3ChunkLen); SDL_RWops *mp3File = SDL_RWFromFile(filename, "rb");