Create Renderer Only When It Doesn't Exist (#1315)
This commit is contained in:
parent
c44a3cd291
commit
8c4f093c41
|
@ -17,11 +17,12 @@ static int query_surface_scale(RenWindow *ren) {
|
||||||
static void setup_renderer(RenWindow *ren, int w, int h) {
|
static void setup_renderer(RenWindow *ren, int w, int h) {
|
||||||
/* Note that w and h here should always be in pixels and obtained from
|
/* Note that w and h here should always be in pixels and obtained from
|
||||||
a call to SDL_GL_GetDrawableSize(). */
|
a call to SDL_GL_GetDrawableSize(). */
|
||||||
if (ren->renderer) {
|
if (!ren->renderer) {
|
||||||
SDL_DestroyTexture(ren->texture);
|
ren->renderer = SDL_CreateRenderer(ren->window, -1, 0);
|
||||||
SDL_DestroyRenderer(ren->renderer);
|
}
|
||||||
|
if (ren->texture) {
|
||||||
|
SDL_DestroyTexture(ren->texture);
|
||||||
}
|
}
|
||||||
ren->renderer = SDL_CreateRenderer(ren->window, -1, 0);
|
|
||||||
ren->texture = SDL_CreateTexture(ren->renderer, SDL_PIXELFORMAT_BGRA32, SDL_TEXTUREACCESS_STREAMING, w, h);
|
ren->texture = SDL_CreateTexture(ren->renderer, SDL_PIXELFORMAT_BGRA32, SDL_TEXTUREACCESS_STREAMING, w, h);
|
||||||
ren->surface_scale = query_surface_scale(ren);
|
ren->surface_scale = query_surface_scale(ren);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue