mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-16 09:01:04 +00:00
R_Screenshot(): Write "yq2" image ID
because we can. This should hopefully work around problems in old versions of gdk-pixbuf that mistook TGAs without image ID as microsoft .ICO
This commit is contained in:
parent
d60dfa63bc
commit
6983d5dc3c
1 changed files with 12 additions and 4 deletions
|
@ -121,7 +121,9 @@ R_ScreenShot(void)
|
|||
return;
|
||||
}
|
||||
|
||||
c = 18 + vid.width * vid.height * 3;
|
||||
static const int headerLength = 18+4;
|
||||
|
||||
c = headerLength + vid.width * vid.height * 3;
|
||||
|
||||
buffer = malloc(c);
|
||||
if (!buffer)
|
||||
|
@ -130,20 +132,26 @@ R_ScreenShot(void)
|
|||
return;
|
||||
}
|
||||
|
||||
memset(buffer, 0, 18);
|
||||
memset(buffer, 0, headerLength);
|
||||
buffer[0] = 4; // image ID: "yq2\0"
|
||||
buffer[2] = 2; /* uncompressed type */
|
||||
buffer[12] = vid.width & 255;
|
||||
buffer[13] = vid.width >> 8;
|
||||
buffer[14] = vid.height & 255;
|
||||
buffer[15] = vid.height >> 8;
|
||||
buffer[16] = 24; /* pixel size */
|
||||
buffer[17] = 0; // image descriptor
|
||||
buffer[18] = 'y'; // following: the 4 image ID fields
|
||||
buffer[19] = 'q';
|
||||
buffer[20] = '2';
|
||||
buffer[21] = '\0';
|
||||
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
glReadPixels(0, 0, vid.width, vid.height, GL_RGB,
|
||||
GL_UNSIGNED_BYTE, buffer + 18);
|
||||
GL_UNSIGNED_BYTE, buffer + headerLength);
|
||||
|
||||
/* swap rgb to bgr */
|
||||
for (i = 18; i < c; i += 3)
|
||||
for (i = headerLength; i < c; i += 3)
|
||||
{
|
||||
temp = buffer[i];
|
||||
buffer[i] = buffer[i + 2];
|
||||
|
|
Loading…
Reference in a new issue