Mercurial > repos > blastem
comparison render_sdl.c @ 2388:a8c069d847a0
Fix issue that would break debug windows when config update causes window to be recreated
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 22 Nov 2023 23:07:30 -0800 |
parents | ff2f18dac84b |
children | 9264c847ceb7 |
comparison
equal
deleted
inserted
replaced
2387:ff2f18dac84b | 2388:a8c069d847a0 |
---|---|
474 static void render_alloc_surfaces() | 474 static void render_alloc_surfaces() |
475 { | 475 { |
476 if (texture_init) { | 476 if (texture_init) { |
477 return; | 477 return; |
478 } | 478 } |
479 sdl_textures= calloc(sizeof(SDL_Texture *), 3); | 479 if (!sdl_textures) { |
480 num_textures = 3; | 480 sdl_textures= calloc(sizeof(SDL_Texture *), 3); |
481 num_textures = 3; | |
482 } | |
481 texture_init = 1; | 483 texture_init = 1; |
482 #ifndef DISABLE_OPENGL | 484 #ifndef DISABLE_OPENGL |
483 if (render_gl) { | 485 if (render_gl) { |
484 gl_setup(); | 486 gl_setup(); |
485 } else { | 487 } else { |
1271 } | 1273 } |
1272 static int in_toggle; | 1274 static int in_toggle; |
1273 | 1275 |
1274 void render_config_updated(void) | 1276 void render_config_updated(void) |
1275 { | 1277 { |
1276 free_surfaces(); | 1278 int n = num_textures < FRAMEBUFFER_USER_START ? num_textures : FRAMEBUFFER_USER_START; |
1279 for (int i = 0; i < n; i++) | |
1280 { | |
1281 if (sdl_textures[i]) { | |
1282 SDL_DestroyTexture(sdl_textures[i]); | |
1283 sdl_textures[i] = NULL; | |
1284 } | |
1285 } | |
1286 texture_init = 0; | |
1277 #ifndef DISABLE_OPENGL | 1287 #ifndef DISABLE_OPENGL |
1278 if (render_gl) { | 1288 if (render_gl) { |
1279 if (on_context_destroyed) { | 1289 if (on_context_destroyed) { |
1280 on_context_destroyed(); | 1290 on_context_destroyed(); |
1281 } | 1291 } |