mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
get snaps working properly
This commit is contained in:
parent
c158f0028b
commit
15655c23cd
3 changed files with 19 additions and 17 deletions
|
@ -511,22 +511,23 @@ SCR_DrawConsole (void)
|
|||
tex_t *
|
||||
SCR_ScreenShot (int width, int height)
|
||||
{
|
||||
unsigned char *src, *dest;
|
||||
unsigned char *src, *dest, *snap;
|
||||
float fracw, frach;
|
||||
int count, dex, dey, dx, dy, nx, r, g, b, x, y, w, h;
|
||||
tex_t *tex;
|
||||
|
||||
tex = Hunk_TempAlloc (field_offset (tex_t, data[vid.width *
|
||||
vid.height * 3]));
|
||||
if (!tex)
|
||||
return 0;
|
||||
snap = Hunk_TempAlloc (vid.width * vid.height * 3);
|
||||
|
||||
qfglReadPixels (glx, gly, vid.width, vid.height, GL_RGB, GL_UNSIGNED_BYTE,
|
||||
tex->data);
|
||||
qfglReadPixels (0, 0, vid.width, vid.height, GL_RGB, GL_UNSIGNED_BYTE,
|
||||
snap);
|
||||
|
||||
w = (vid.width < width) ? vid.width : width;
|
||||
h = (vid.height < height) ? vid.height : height;
|
||||
|
||||
tex = malloc (field_offset (tex_t, data[w * h]));
|
||||
if (!tex)
|
||||
return 0;
|
||||
|
||||
fracw = (float) vid.width / (float) w;
|
||||
frach = (float) vid.height / (float) h;
|
||||
|
||||
|
@ -535,7 +536,7 @@ SCR_ScreenShot (int width, int height)
|
|||
tex->palette = vid.palette;
|
||||
|
||||
for (y = 0; y < h; y++) {
|
||||
dest = tex->data + (w * 3 * y);
|
||||
dest = snap + (w * 3 * y);
|
||||
|
||||
for (x = 0; x < w; x++) {
|
||||
r = g = b = 0;
|
||||
|
@ -551,7 +552,7 @@ SCR_ScreenShot (int width, int height)
|
|||
|
||||
count = 0;
|
||||
for (; dy < dey; dy++) {
|
||||
src = tex->data + (vid.width * 3 * dy) + dx * 3;
|
||||
src = snap + (vid.width * 3 * dy) + dx * 3;
|
||||
for (nx = dx; nx < dex; nx++) {
|
||||
r += *src++;
|
||||
g += *src++;
|
||||
|
@ -570,7 +571,7 @@ SCR_ScreenShot (int width, int height)
|
|||
|
||||
// convert to eight bit
|
||||
for (y = 0; y < h; y++) {
|
||||
src = tex->data + (w * 3 * y);
|
||||
src = snap + (w * 3 * y);
|
||||
dest = tex->data + (w * y);
|
||||
|
||||
for (x = 0; x < w; x++) {
|
||||
|
|
|
@ -581,7 +581,7 @@ SCR_ScreenShot (int width, int height)
|
|||
fracw = (float) vid.width / (float) w;
|
||||
frach = (float) vid.height / (float) h;
|
||||
|
||||
tex = Hunk_TempAlloc (field_offset (tex_t, data[w * h]));
|
||||
tex = malloc (field_offset (tex_t, data[w * h]));
|
||||
if (!tex)
|
||||
return 0;
|
||||
|
||||
|
@ -590,7 +590,7 @@ SCR_ScreenShot (int width, int height)
|
|||
tex->palette = vid.palette;
|
||||
|
||||
for (y = 0; y < h; y++) {
|
||||
dest = tex->data + (w * y);
|
||||
dest = tex->data + (w * (h - y - 1));
|
||||
|
||||
for (x = 0; x < w; x++) {
|
||||
r = g = b = 0;
|
||||
|
@ -608,9 +608,9 @@ SCR_ScreenShot (int width, int height)
|
|||
for ( /* */ ; dy < dey; dy++) {
|
||||
src = vid.buffer + (vid.rowbytes * dy) + dx;
|
||||
for (nx = dx; nx < dex; nx++) {
|
||||
r += vid.palette[*src * 3];
|
||||
g += vid.palette[*src * 3 + 1];
|
||||
b += vid.palette[*src * 3 + 2];
|
||||
r += vid.basepal[*src * 3];
|
||||
g += vid.basepal[*src * 3 + 1];
|
||||
b += vid.basepal[*src * 3 + 2];
|
||||
src++;
|
||||
count++;
|
||||
}
|
||||
|
@ -714,7 +714,7 @@ SCR_DrawCharToSnap (int num, byte * dest, int width)
|
|||
else
|
||||
dest[x] = 98;
|
||||
source += 128;
|
||||
dest += width;
|
||||
dest -= width;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -171,7 +171,8 @@ CL_RSShot_f (void)
|
|||
tex->height - 21);
|
||||
|
||||
pcx = EncodePCX (tex->data, tex->width, tex->height, tex->width,
|
||||
vid.palette, true, &pcx_len);
|
||||
vid.basepal, true, &pcx_len);
|
||||
free (tex);
|
||||
}
|
||||
if (pcx) {
|
||||
CL_StartUpload ((void *)pcx, pcx_len);
|
||||
|
|
Loading…
Reference in a new issue