get snaps working properly

This commit is contained in:
Bill Currie 2002-12-10 18:24:38 +00:00
parent c158f0028b
commit 15655c23cd
3 changed files with 19 additions and 17 deletions

View file

@ -511,22 +511,23 @@ SCR_DrawConsole (void)
tex_t * tex_t *
SCR_ScreenShot (int width, int height) SCR_ScreenShot (int width, int height)
{ {
unsigned char *src, *dest; unsigned char *src, *dest, *snap;
float fracw, frach; float fracw, frach;
int count, dex, dey, dx, dy, nx, r, g, b, x, y, w, h; int count, dex, dey, dx, dy, nx, r, g, b, x, y, w, h;
tex_t *tex; tex_t *tex;
tex = Hunk_TempAlloc (field_offset (tex_t, data[vid.width * snap = Hunk_TempAlloc (vid.width * vid.height * 3);
vid.height * 3]));
if (!tex)
return 0;
qfglReadPixels (glx, gly, vid.width, vid.height, GL_RGB, GL_UNSIGNED_BYTE, qfglReadPixels (0, 0, vid.width, vid.height, GL_RGB, GL_UNSIGNED_BYTE,
tex->data); snap);
w = (vid.width < width) ? vid.width : width; w = (vid.width < width) ? vid.width : width;
h = (vid.height < height) ? vid.height : height; 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; fracw = (float) vid.width / (float) w;
frach = (float) vid.height / (float) h; frach = (float) vid.height / (float) h;
@ -535,7 +536,7 @@ SCR_ScreenShot (int width, int height)
tex->palette = vid.palette; tex->palette = vid.palette;
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
dest = tex->data + (w * 3 * y); dest = snap + (w * 3 * y);
for (x = 0; x < w; x++) { for (x = 0; x < w; x++) {
r = g = b = 0; r = g = b = 0;
@ -551,7 +552,7 @@ SCR_ScreenShot (int width, int height)
count = 0; count = 0;
for (; dy < dey; dy++) { 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++) { for (nx = dx; nx < dex; nx++) {
r += *src++; r += *src++;
g += *src++; g += *src++;
@ -570,7 +571,7 @@ SCR_ScreenShot (int width, int height)
// convert to eight bit // convert to eight bit
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
src = tex->data + (w * 3 * y); src = snap + (w * 3 * y);
dest = tex->data + (w * y); dest = tex->data + (w * y);
for (x = 0; x < w; x++) { for (x = 0; x < w; x++) {

View file

@ -581,7 +581,7 @@ SCR_ScreenShot (int width, int height)
fracw = (float) vid.width / (float) w; fracw = (float) vid.width / (float) w;
frach = (float) vid.height / (float) h; 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) if (!tex)
return 0; return 0;
@ -590,7 +590,7 @@ SCR_ScreenShot (int width, int height)
tex->palette = vid.palette; tex->palette = vid.palette;
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
dest = tex->data + (w * y); dest = tex->data + (w * (h - y - 1));
for (x = 0; x < w; x++) { for (x = 0; x < w; x++) {
r = g = b = 0; r = g = b = 0;
@ -608,9 +608,9 @@ SCR_ScreenShot (int width, int height)
for ( /* */ ; dy < dey; dy++) { for ( /* */ ; dy < dey; dy++) {
src = vid.buffer + (vid.rowbytes * dy) + dx; src = vid.buffer + (vid.rowbytes * dy) + dx;
for (nx = dx; nx < dex; nx++) { for (nx = dx; nx < dex; nx++) {
r += vid.palette[*src * 3]; r += vid.basepal[*src * 3];
g += vid.palette[*src * 3 + 1]; g += vid.basepal[*src * 3 + 1];
b += vid.palette[*src * 3 + 2]; b += vid.basepal[*src * 3 + 2];
src++; src++;
count++; count++;
} }
@ -714,7 +714,7 @@ SCR_DrawCharToSnap (int num, byte * dest, int width)
else else
dest[x] = 98; dest[x] = 98;
source += 128; source += 128;
dest += width; dest -= width;
} }
} }

View file

@ -171,7 +171,8 @@ CL_RSShot_f (void)
tex->height - 21); tex->height - 21);
pcx = EncodePCX (tex->data, tex->width, tex->height, tex->width, pcx = EncodePCX (tex->data, tex->width, tex->height, tex->width,
vid.palette, true, &pcx_len); vid.basepal, true, &pcx_len);
free (tex);
} }
if (pcx) { if (pcx) {
CL_StartUpload ((void *)pcx, pcx_len); CL_StartUpload ((void *)pcx, pcx_len);