Mercurial > repos > blastem
comparison render_sdl.c @ 1820:70a1304b432b
Fix crash that occurs when changing video screen settings if the emulator window is currently fullscreen. Add a little more error handling to Open GL code
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 31 Mar 2019 14:53:29 -0700 |
parents | 73a9d06413bc |
children | 56a1171e29b9 |
comparison
equal
deleted
inserted
replaced
1819:4fb9af0c65b6 | 1820:70a1304b432b |
---|---|
529 text = alloc_concat(shader_prefix, tmp); | 529 text = alloc_concat(shader_prefix, tmp); |
530 free(tmp); | 530 free(tmp); |
531 fsize += strlen(shader_prefix); | 531 fsize += strlen(shader_prefix); |
532 } | 532 } |
533 GLuint ret = glCreateShader(shader_type); | 533 GLuint ret = glCreateShader(shader_type); |
534 if (!ret) { | |
535 warning("glCreateShader failed with error %d\n", glGetError()); | |
536 return 0; | |
537 } | |
534 glShaderSource(ret, 1, (const GLchar **)&text, (const GLint *)&fsize); | 538 glShaderSource(ret, 1, (const GLchar **)&text, (const GLint *)&fsize); |
535 free(text); | 539 free(text); |
536 glCompileShader(ret); | 540 glCompileShader(ret); |
537 GLint compile_status, loglen; | 541 GLint compile_status, loglen; |
538 glGetShaderiv(ret, GL_COMPILE_STATUS, &compile_status); | 542 glGetShaderiv(ret, GL_COMPILE_STATUS, &compile_status); |
963 break; | 967 break; |
964 case SDL_WINDOWEVENT: | 968 case SDL_WINDOWEVENT: |
965 switch (event->window.event) | 969 switch (event->window.event) |
966 { | 970 { |
967 case SDL_WINDOWEVENT_SIZE_CHANGED: | 971 case SDL_WINDOWEVENT_SIZE_CHANGED: |
972 if (!main_window) { | |
973 break; | |
974 } | |
968 main_width = event->window.data1; | 975 main_width = event->window.data1; |
969 main_height = event->window.data2; | 976 main_height = event->window.data2; |
970 update_aspect(); | 977 update_aspect(); |
971 #ifndef DISABLE_OPENGL | 978 #ifndef DISABLE_OPENGL |
972 if (render_gl) { | 979 if (render_gl) { |
982 } | 989 } |
983 } | 990 } |
984 #endif | 991 #endif |
985 break; | 992 break; |
986 case SDL_WINDOWEVENT_CLOSE: | 993 case SDL_WINDOWEVENT_CLOSE: |
987 if (SDL_GetWindowID(main_window) == event->window.windowID) { | 994 if (main_window && SDL_GetWindowID(main_window) == event->window.windowID) { |
988 exit(0); | 995 exit(0); |
989 } else { | 996 } else { |
990 for (int i = 0; i < num_textures - FRAMEBUFFER_USER_START; i++) | 997 for (int i = 0; i < num_textures - FRAMEBUFFER_USER_START; i++) |
991 { | 998 { |
992 if (SDL_GetWindowID(extra_windows[i]) == event->window.windowID) { | 999 if (SDL_GetWindowID(extra_windows[i]) == event->window.windowID) { |
1303 #ifndef DISABLE_OPENGL | 1310 #ifndef DISABLE_OPENGL |
1304 } | 1311 } |
1305 #endif | 1312 #endif |
1306 in_toggle = 1; | 1313 in_toggle = 1; |
1307 SDL_DestroyWindow(main_window); | 1314 SDL_DestroyWindow(main_window); |
1315 main_window = NULL; | |
1308 drain_events(); | 1316 drain_events(); |
1309 | 1317 |
1310 char *config_width = tern_find_path(config, "video\0width\0", TVAL_PTR).ptrval; | 1318 char *config_width = tern_find_path(config, "video\0width\0", TVAL_PTR).ptrval; |
1311 if (config_width) { | 1319 if (config_width) { |
1312 windowed_width = atoi(config_width); | 1320 windowed_width = atoi(config_width); |