Skip to content

Commit

Permalink
Fix screenshots becoming corrupted in rare instances (hopefully)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradharding committed Nov 26, 2023
1 parent 88f59e7 commit 7555076
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ int windowheight;
int windowx;
int windowy;

uint32_t rmask;
uint32_t gmask;
uint32_t bmask;
uint32_t amask;
int bpp = 0;

static int displaywidth;
static int displayheight;
static int displaycenterx;
Expand Down Expand Up @@ -1230,11 +1236,6 @@ static void SetVideoMode(const bool createwindow, const bool output)
int windowflags = (SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL);
int width, height;
uint32_t pixelformat;
uint32_t rmask;
uint32_t gmask;
uint32_t bmask;
uint32_t amask;
int bpp = 0;
SDL_RendererInfo rendererinfo;
const char *displayname = SDL_GetDisplayName((displayindex = vid_display - 1));
bool instead = false;
Expand Down
6 changes: 6 additions & 0 deletions src/i_video.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ extern int windowwidth;
extern int windowborderwidth;
extern int windowborderheight;

extern uint32_t rmask;
extern uint32_t gmask;
extern uint32_t bmask;
extern uint32_t amask;
extern int bpp;

extern bool usinggamecontroller;
extern bool usingmouse;
extern bool windowfocused;
Expand Down
3 changes: 2 additions & 1 deletion src/v_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,8 @@ static bool V_SavePNG(SDL_Renderer *sdlrenderer, const char *path)

if (!SDL_GetRendererOutputSize(sdlrenderer, &width, &height))
{
SDL_Surface *screenshot = SDL_CreateRGBSurface(0, (vid_widescreen ? width : height * 4 / 3), height, 32, 0, 0, 0, 0);
SDL_Surface *screenshot = SDL_CreateRGBSurface(0, (vid_widescreen ? width : height * 4 / 3), height,
bpp, rmask, gmask, bmask, amask);

if (screenshot)
{
Expand Down

0 comments on commit 7555076

Please sign in to comment.