Improve error handling on display initialisation
This commit is contained in:
parent
128e8c1ff8
commit
eafcdf8ec9
@ -206,5 +206,5 @@ void sdl_seticon(void);
|
||||
void play_sound(char *file);
|
||||
void start_grav_async(void);
|
||||
void stop_grav_async(void);
|
||||
void set_scale(int scale, int kiosk);
|
||||
int set_scale(int scale, int kiosk);
|
||||
#endif
|
||||
|
@ -140,7 +140,7 @@ int render_thumb(void *thumb, int size, int bzip2, pixel *vid_buf, int px, int p
|
||||
|
||||
void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry);
|
||||
|
||||
void sdl_open(void);
|
||||
int sdl_open(void);
|
||||
|
||||
#ifdef OpenGL
|
||||
void Enable2D ();
|
||||
|
@ -3824,12 +3824,12 @@ void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry)
|
||||
}
|
||||
}
|
||||
|
||||
void sdl_open(void)
|
||||
int sdl_open(void)
|
||||
{
|
||||
if (SDL_Init(SDL_INIT_VIDEO)<0)
|
||||
{
|
||||
fprintf(stderr, "Initializing SDL: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
return 0;
|
||||
}
|
||||
atexit(SDL_Quit);
|
||||
#ifdef OpenGL
|
||||
@ -3861,12 +3861,22 @@ void sdl_open(void)
|
||||
if (!sdl_scrn)
|
||||
{
|
||||
fprintf(stderr, "Creating window: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
return 0;
|
||||
}
|
||||
SDL_WM_SetCaption("The Powder Toy", "Powder Toy");
|
||||
sdl_seticon();
|
||||
SDL_EnableUNICODE(1);
|
||||
//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
#if (defined(LIN32) || defined(LIN64)) && defined(SDL_VIDEO_DRIVER_X11)
|
||||
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
|
||||
SDL_VERSION(&sdl_wminfo.version);
|
||||
SDL_GetWMInfo(&sdl_wminfo);
|
||||
sdl_wminfo.info.x11.lock_func();
|
||||
XA_CLIPBOARD = XInternAtom(sdl_wminfo.info.x11.display, "CLIPBOARD", 1);
|
||||
XA_TARGETS = XInternAtom(sdl_wminfo.info.x11.display, "TARGETS", 1);
|
||||
sdl_wminfo.info.x11.unlock_func();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef OpenGL
|
||||
|
@ -4659,7 +4659,10 @@ void simulation_ui(pixel * vid_buf)
|
||||
new_scale = (cb3.checked)?2:1;
|
||||
new_kiosk = (cb4.checked)?1:0;
|
||||
if(new_scale!=sdl_scale || new_kiosk!=kiosk_enable)
|
||||
set_scale(new_scale, new_kiosk);
|
||||
{
|
||||
if (!set_scale(new_scale, new_kiosk))
|
||||
error_ui(vid_buf, 0, "Could not change display options");
|
||||
}
|
||||
if(ngrav_enable != cb2.checked)
|
||||
{
|
||||
if(cb2.checked)
|
||||
|
15
src/main.c
15
src/main.c
@ -1231,11 +1231,18 @@ char my_uri[] = "http://" SERVER "/Update.api?Action=Download&Architecture="
|
||||
#endif
|
||||
;
|
||||
|
||||
void set_scale(int scale, int kiosk){
|
||||
int set_scale(int scale, int kiosk){
|
||||
int old_scale = sdl_scale, old_kiosk = kiosk_enable;
|
||||
sdl_scale = scale;
|
||||
kiosk_enable = kiosk;
|
||||
sdl_open();
|
||||
return;
|
||||
if (!sdl_open())
|
||||
{
|
||||
sdl_scale = old_scale;
|
||||
kiosk_enable = old_kiosk;
|
||||
sdl_open();
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void update_grav_async()
|
||||
@ -1564,7 +1571,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
stamp_init();
|
||||
|
||||
sdl_open();
|
||||
if (!sdl_open()) exit(1);
|
||||
http_init(http_proxy_string[0] ? http_proxy_string : NULL);
|
||||
|
||||
if (cpu_check())
|
||||
|
Loading…
Reference in New Issue
Block a user