Skip to content

Commit

Permalink
Create Renderer Only When It Doesn't Exist (lite-xl#1315)
Browse files Browse the repository at this point in the history
  • Loading branch information
pegvin authored Jan 11, 2023
1 parent bebef68 commit f9933ed
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/renwindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ static int query_surface_scale(RenWindow *ren) {
static void setup_renderer(RenWindow *ren, int w, int h) {
/* Note that w and h here should always be in pixels and obtained from
a call to SDL_GL_GetDrawableSize(). */
if (ren->renderer) {
if (!ren->renderer) {
ren->renderer = SDL_CreateRenderer(ren->window, -1, 0);
}
if (ren->texture) {
SDL_DestroyTexture(ren->texture);
SDL_DestroyRenderer(ren->renderer);
}
ren->renderer = SDL_CreateRenderer(ren->window, -1, 0);
ren->texture = SDL_CreateTexture(ren->renderer, SDL_PIXELFORMAT_BGRA32, SDL_TEXTUREACCESS_STREAMING, w, h);
ren->surface_scale = query_surface_scale(ren);
}
Expand Down

0 comments on commit f9933ed

Please sign in to comment.