mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-09 01:01:07 +00:00
fix screenshots when width isn't a multiple of 4. explained by Sander van Dijk.
also check that malloc() didn't fail. git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@909 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
5e6683608d
commit
1dc482677d
1 changed files with 10 additions and 2 deletions
|
@ -118,6 +118,7 @@ float scr_disabled_time;
|
|||
|
||||
int scr_tileclear_updates = 0; //johnfitz
|
||||
|
||||
static GLint gl_pack_alignment = 4;
|
||||
void SCR_ScreenShot_f (void);
|
||||
|
||||
/*
|
||||
|
@ -425,6 +426,7 @@ void SCR_Init (void)
|
|||
|
||||
SCR_LoadPics (); //johnfitz
|
||||
|
||||
glGetIntegerv (GL_PACK_ALIGNMENT, &gl_pack_alignment);
|
||||
scr_initialized = true;
|
||||
}
|
||||
|
||||
|
@ -778,11 +780,17 @@ void SCR_ScreenShot_f (void)
|
|||
{
|
||||
Con_Printf ("SCR_ScreenShot_f: Couldn't find an unused filename\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//get data
|
||||
buffer = (byte *) malloc(glwidth*glheight*3);
|
||||
if (!(buffer = (byte *) malloc(glwidth*glheight*3)))
|
||||
{
|
||||
Con_Printf ("SCR_ScreenShot_f: Couldn't allocate memory\n");
|
||||
return;
|
||||
}
|
||||
glPixelStorei (GL_PACK_ALIGNMENT, 1);/* for widths that aren't a multiple of 4 */
|
||||
glReadPixels (glx, gly, glwidth, glheight, GL_RGB, GL_UNSIGNED_BYTE, buffer);
|
||||
glPixelStorei (GL_PACK_ALIGNMENT, gl_pack_alignment);
|
||||
|
||||
// now write the file
|
||||
if (Image_WriteTGA (tganame, buffer, glwidth, glheight, 24, false))
|
||||
|
|
Loading…
Reference in a new issue