core: check for sdl initialization errors
This commit is contained in:
parent
c62cf5ce8c
commit
83f368cdbe
|
@ -91,7 +91,10 @@ int main(int argc, char **argv) {
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) != 0) {
|
||||||
|
fprintf(stderr, "Error initializing sdl: %s", SDL_GetError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
SDL_EnableScreenSaver();
|
SDL_EnableScreenSaver();
|
||||||
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
||||||
atexit(SDL_Quit);
|
atexit(SDL_Quit);
|
||||||
|
@ -122,6 +125,10 @@ int main(int argc, char **argv) {
|
||||||
"", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, dm.w * 0.8, dm.h * 0.8,
|
"", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, dm.w * 0.8, dm.h * 0.8,
|
||||||
SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN);
|
SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN);
|
||||||
init_window_icon();
|
init_window_icon();
|
||||||
|
if (!window) {
|
||||||
|
fprintf(stderr, "Error creating lite-xl window: %s", SDL_GetError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
ren_init(window);
|
ren_init(window);
|
||||||
|
|
||||||
lua_State *L;
|
lua_State *L;
|
||||||
|
|
|
@ -35,6 +35,10 @@ void renwin_init_surface(UNUSED RenWindow *ren) {
|
||||||
int w, h;
|
int w, h;
|
||||||
SDL_GL_GetDrawableSize(ren->window, &w, &h);
|
SDL_GL_GetDrawableSize(ren->window, &w, &h);
|
||||||
ren->surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, SDL_PIXELFORMAT_BGRA32);
|
ren->surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, SDL_PIXELFORMAT_BGRA32);
|
||||||
|
if (!ren->surface) {
|
||||||
|
fprintf(stderr, "Error creating surface: %s", SDL_GetError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
setup_renderer(ren, w, h);
|
setup_renderer(ren, w, h);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -68,7 +72,12 @@ SDL_Surface *renwin_get_surface(RenWindow *ren) {
|
||||||
#ifdef LITE_USE_SDL_RENDERER
|
#ifdef LITE_USE_SDL_RENDERER
|
||||||
return ren->surface;
|
return ren->surface;
|
||||||
#else
|
#else
|
||||||
return SDL_GetWindowSurface(ren->window);
|
SDL_Surface *surface = SDL_GetWindowSurface(ren->window);
|
||||||
|
if (!surface) {
|
||||||
|
fprintf(stderr, "Error getting window surface: %s", SDL_GetError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
return surface;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue