Skip to content

Commit

Permalink
fix crashes when changing resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiangreffrath committed Sep 24, 2024
1 parent 81483b1 commit 35367e2
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1906,19 +1906,23 @@ void I_ReInitGraphics (int reinit)

#ifndef CRISPY_TRUECOLOR
SDL_FreeSurface(screenbuffer);
screenbuffer = SDL_CreateRGBSurface(0,
SCREENWIDTH, SCREENHEIGHT, 8,
0, 0, 0, 0);
#endif
screenbuffer = SDL_CreateRGBSurface(
0, SCREENWIDTH, SCREENHEIGHT, 8,
0, 0, 0, 0);

// pixels and pitch will be filled with the texture's values
// in I_FinishUpdate()
SDL_FreeSurface(argbbuffer);
argbbuffer = SDL_CreateRGBSurfaceWithFormat(0,
SCREENWIDTH, SCREENHEIGHT, 32,
SDL_PIXELFORMAT_ARGB8888);
#ifndef CRISPY_TRUECOLOR
argbbuffer = SDL_CreateRGBSurfaceWithFormatFrom(
NULL, SCREENWIDTH, SCREENHEIGHT, 0, 0, SDL_PIXELFORMAT_ARGB8888);

// [crispy] re-set the framebuffer pointer
I_VideoBuffer = screenbuffer->pixels;
#else
SDL_FreeSurface(argbbuffer);
argbbuffer = SDL_CreateRGBSurfaceWithFormat(
0, SCREENWIDTH, SCREENHEIGHT, 32, SDL_PIXELFORMAT_ARGB8888);

I_VideoBuffer = argbbuffer->pixels;
#endif
V_RestoreBuffer();
Expand Down

0 comments on commit 35367e2

Please sign in to comment.