Running the following code, I'm not able to view a window unless I set SDL_WINDOW_FULLSCREEN
in SDL_CreateWindow
. With any other settings, I can see the process running, but no window appears. I'd like to be able to create a windowed SDL_Window
. Am I missing something?
Running macOS Sierra, SDL v2.0.7
#include <SDL2/SDL.h>
int main() {
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
SDL_Log("Unable to initialize SDL: %s", SDL_GetError());
return 1;
}
SDL_Window *window = SDL_CreateWindow(
"Title",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
640,
800,
SDL_WINDOW_SHOWN
);
if (window == NULL) {
SDL_Log("Unable to create window: %s", SDL_GetError());
return 1;
}
SDL_Delay(5000);
// Cleanup.
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…