| Summary: | No window on SDL_CreateWindow | ||
|---|---|---|---|
| Product: | SDL | Reporter: | mydevlists |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | CC: | amaranth72 |
| Version: | 2.0.4 | ||
| Hardware: | x86 | ||
| OS: | Mac OS X 10.8 | ||
You need to either call SDL_PollEvent or SDL_PumpEvents regularly (typically you'd call SDL_PollEvent in a while-loop every frame). Alex is right, if you're creating windows on the various platforms you also need to handle window management events otherwise the OS won't be able to complete the operations. |
OS X 10.11.3 SDL2 2.0.4 --- The following code paints a yellow rect, but I do not get a window. --- Removing the surface code, does not create an empty window either. #include <stdio.h> #include <SDL2/SDL.h> const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; int main ( int argc, char** argv ) { SDL_Window * window = NULL; SDL_Surface * surface = NULL; // initialize SDL video if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { printf( "Unable to init SDL: %s\n", SDL_GetError() ); return 1; } // make sure SDL cleans up before exit atexit(SDL_Quit); window = SDL_CreateWindow("Hi world!", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_RESIZABLE); if (window == NULL) { printf("Window not created: %s\n",SDL_GetError()); } else { surface = SDL_GetWindowSurface(window); SDL_FillRect(surface,NULL,SDL_MapRGBA(surface->format,255,255,0,255)); SDL_UpdateWindowSurface(window); SDL_Delay(5000); } SDL_DestroyWindow(window); SDL_Quit(); // all is well ;) printf("Exited cleanly\n"); return 0; }