2001-08-25 02:47:11 +00:00
|
|
|
/*
|
|
|
|
screen.c
|
|
|
|
|
|
|
|
master for refresh, status bar, console, chat, notify, etc
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2012-02-22 07:32:34 +00:00
|
|
|
#define NH_DEFINE
|
|
|
|
#include "namehack.h"
|
|
|
|
|
2001-08-25 02:47:11 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/draw.h"
|
2003-05-23 17:17:01 +00:00
|
|
|
#include "QF/dstring.h"
|
2003-09-04 18:59:39 +00:00
|
|
|
#include "QF/image.h"
|
2001-08-25 02:47:11 +00:00
|
|
|
#include "QF/pcx.h"
|
2002-08-27 07:16:28 +00:00
|
|
|
#include "QF/quakefs.h"
|
2001-08-29 02:16:17 +00:00
|
|
|
#include "QF/render.h"
|
|
|
|
#include "QF/screen.h"
|
2001-08-25 02:47:11 +00:00
|
|
|
#include "QF/sys.h"
|
2003-05-23 17:17:01 +00:00
|
|
|
#include "QF/va.h"
|
2021-07-10 09:04:34 +00:00
|
|
|
#include "QF/ui/view.h"
|
2001-08-25 02:47:11 +00:00
|
|
|
|
|
|
|
#include "compat.h"
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "r_internal.h"
|
2012-02-17 07:13:56 +00:00
|
|
|
#include "vid_internal.h"
|
2019-07-08 16:00:47 +00:00
|
|
|
#include "vid_sw.h"
|
2001-08-25 02:47:11 +00:00
|
|
|
|
2002-12-11 16:45:40 +00:00
|
|
|
/* SCREEN SHOTS */
|
2001-08-25 02:47:11 +00:00
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
tex_t *
|
2012-02-22 07:32:34 +00:00
|
|
|
sw32_SCR_CaptureBGR (void)
|
2012-01-05 10:19:37 +00:00
|
|
|
{
|
|
|
|
int count, x, y;
|
|
|
|
tex_t *tex;
|
|
|
|
const byte *src;
|
|
|
|
byte *dst;
|
|
|
|
|
|
|
|
count = vid.width * vid.height;
|
2021-01-24 15:54:41 +00:00
|
|
|
tex = malloc (sizeof (tex_t) + count * 3);
|
|
|
|
tex->data = (byte *) (tex + 1);
|
2012-01-05 10:19:37 +00:00
|
|
|
SYS_CHECKMEM (tex);
|
|
|
|
tex->width = vid.width;
|
|
|
|
tex->height = vid.height;
|
|
|
|
tex->format = tex_rgb;
|
|
|
|
tex->palette = 0;
|
2012-02-22 07:32:34 +00:00
|
|
|
sw32_D_EnableBackBufferAccess ();
|
2012-01-05 10:19:37 +00:00
|
|
|
src = vid.buffer;
|
|
|
|
for (y = 0; y < tex->height; y++) {
|
|
|
|
dst = tex->data + (tex->height - 1 - y) * tex->width * 3;
|
|
|
|
for (x = 0; x < tex->width; x++) {
|
|
|
|
*dst++ = vid.basepal[*src * 3 + 2]; // blue
|
|
|
|
*dst++ = vid.basepal[*src * 3 + 1]; // green
|
|
|
|
*dst++ = vid.basepal[*src * 3 + 0]; // red
|
|
|
|
src++;
|
|
|
|
}
|
|
|
|
}
|
2012-02-22 07:32:34 +00:00
|
|
|
sw32_D_DisableBackBufferAccess ();
|
2012-01-05 10:19:37 +00:00
|
|
|
return tex;
|
|
|
|
}
|
|
|
|
|
2018-10-09 03:35:01 +00:00
|
|
|
__attribute__((const)) tex_t *
|
2013-01-24 02:25:30 +00:00
|
|
|
sw32_SCR_ScreenShot (unsigned width, unsigned height)
|
2001-08-25 03:24:44 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-08-25 02:47:11 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
sw32_SCR_ScreenShot_f (void)
|
2001-08-25 02:47:11 +00:00
|
|
|
{
|
2003-05-23 17:17:01 +00:00
|
|
|
dstring_t *pcxname = dstring_new ();
|
2003-05-23 17:39:33 +00:00
|
|
|
pcx_t *pcx = 0;
|
2001-08-29 02:16:17 +00:00
|
|
|
int pcx_len;
|
2001-08-25 02:47:11 +00:00
|
|
|
|
2012-01-05 10:19:37 +00:00
|
|
|
// find a file name to save it to
|
2021-01-31 07:01:20 +00:00
|
|
|
if (!QFS_NextFilename (pcxname, va (0, "%s/qf",
|
|
|
|
qfs_gamedir->dir.shots), ".pcx")) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("SCR_ScreenShot_f: Couldn't create a PCX");
|
2003-05-23 17:17:01 +00:00
|
|
|
} else {
|
|
|
|
// enable direct drawing of console to back buffer
|
2012-02-22 07:32:34 +00:00
|
|
|
sw32_D_EnableBackBufferAccess ();
|
2003-05-23 17:17:01 +00:00
|
|
|
|
|
|
|
// save the pcx file
|
2021-07-10 15:09:41 +00:00
|
|
|
switch(sw32_ctx->pixbytes) {
|
2003-05-23 17:17:01 +00:00
|
|
|
case 1:
|
|
|
|
pcx = EncodePCX (vid.buffer, vid.width, vid.height, vid.rowbytes,
|
|
|
|
vid.basepal, false, &pcx_len);
|
|
|
|
break;
|
|
|
|
case 2:
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf("SCR_ScreenShot_f: FIXME - add 16bit support\n");
|
2003-05-23 17:17:01 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf("SCR_ScreenShot_f: FIXME - add 32bit support\n");
|
2003-05-23 17:17:01 +00:00
|
|
|
break;
|
|
|
|
default:
|
2021-07-10 15:09:41 +00:00
|
|
|
Sys_Error("SCR_ScreenShot_f: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
2003-05-23 17:17:01 +00:00
|
|
|
}
|
2001-08-25 02:47:11 +00:00
|
|
|
|
2003-05-23 17:17:01 +00:00
|
|
|
// for adapters that can't stay mapped in for linear writes all the time
|
2012-02-22 07:32:34 +00:00
|
|
|
sw32_D_DisableBackBufferAccess ();
|
2001-08-25 02:47:11 +00:00
|
|
|
|
2003-05-23 17:39:33 +00:00
|
|
|
if (pcx) {
|
|
|
|
QFS_WriteFile (pcxname->str, pcx, pcx_len);
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("Wrote %s/%s\n", qfs_userpath, pcxname->str);
|
2003-05-23 17:39:33 +00:00
|
|
|
}
|
2003-05-23 17:17:01 +00:00
|
|
|
}
|
|
|
|
dstring_delete (pcxname);
|
2001-08-25 02:47:11 +00:00
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2021-12-02 09:30:57 +00:00
|
|
|
sw32_R_RenderFrame (SCR_Func *scr_funcs)
|
2001-08-25 02:47:11 +00:00
|
|
|
{
|
2001-08-29 02:16:17 +00:00
|
|
|
vrect_t vrect;
|
2001-08-25 02:47:11 +00:00
|
|
|
|
|
|
|
// do 3D refresh drawing, and then update the screen
|
2012-02-22 07:32:34 +00:00
|
|
|
sw32_D_EnableBackBufferAccess (); // of all overlay stuff if drawing
|
2001-08-25 02:47:11 +00:00
|
|
|
// directly
|
2001-08-29 02:16:17 +00:00
|
|
|
|
2013-01-13 07:46:41 +00:00
|
|
|
if (vr_data.scr_fullupdate++ < vid.numpages) { // clear the entire screen
|
|
|
|
vr_data.scr_copyeverything = 1;
|
2012-02-22 07:32:34 +00:00
|
|
|
sw32_Draw_TileClear (0, 0, vid.width, vid.height);
|
2001-08-25 02:47:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pconupdate = NULL;
|
|
|
|
|
|
|
|
SCR_SetUpToDrawConsole ();
|
|
|
|
|
2012-02-22 07:32:34 +00:00
|
|
|
sw32_D_DisableBackBufferAccess (); // for adapters that can't stay mapped
|
2001-08-25 02:47:11 +00:00
|
|
|
// in for linear writes all the time
|
|
|
|
VID_LockBuffer ();
|
2021-12-02 09:30:57 +00:00
|
|
|
sw32_R_RenderView ();
|
2001-08-25 02:47:11 +00:00
|
|
|
VID_UnlockBuffer ();
|
|
|
|
|
2012-02-22 07:32:34 +00:00
|
|
|
sw32_D_EnableBackBufferAccess (); // of all overlay stuff if drawing
|
2001-08-25 02:47:11 +00:00
|
|
|
// directly
|
2001-08-29 02:16:17 +00:00
|
|
|
|
2021-07-10 09:04:34 +00:00
|
|
|
view_draw (vr_data.scr_view);
|
2004-03-01 23:47:39 +00:00
|
|
|
while (*scr_funcs) {
|
|
|
|
(*scr_funcs)();
|
|
|
|
scr_funcs++;
|
2001-08-25 02:47:11 +00:00
|
|
|
}
|
|
|
|
|
2012-02-22 07:32:34 +00:00
|
|
|
sw32_D_DisableBackBufferAccess (); // for adapters that can't stay mapped
|
2001-08-25 02:47:11 +00:00
|
|
|
// in for linear writes all the time
|
|
|
|
if (pconupdate) {
|
2012-02-22 07:32:34 +00:00
|
|
|
sw32_D_UpdateRects (pconupdate);
|
2001-08-25 02:47:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// update one of three areas
|
2013-01-13 07:46:41 +00:00
|
|
|
if (vr_data.scr_copyeverything) {
|
2001-08-25 02:47:11 +00:00
|
|
|
vrect.x = 0;
|
|
|
|
vrect.y = 0;
|
|
|
|
vrect.width = vid.width;
|
|
|
|
vrect.height = vid.height;
|
2012-01-06 00:52:14 +00:00
|
|
|
vrect.next = 0;
|
2001-08-25 02:47:11 +00:00
|
|
|
} else if (scr_copytop) {
|
|
|
|
vrect.x = 0;
|
|
|
|
vrect.y = 0;
|
|
|
|
vrect.width = vid.width;
|
2012-02-14 08:28:09 +00:00
|
|
|
vrect.height = vid.height - vr_data.lineadj;
|
2012-01-06 00:52:14 +00:00
|
|
|
vrect.next = 0;
|
2001-08-25 02:47:11 +00:00
|
|
|
} else {
|
2021-07-10 09:04:34 +00:00
|
|
|
vrect.x = vr_data.scr_view->xpos;
|
|
|
|
vrect.y = vr_data.scr_view->ypos;
|
|
|
|
vrect.width = vr_data.scr_view->xlen;
|
|
|
|
vrect.height = vr_data.scr_view->ylen;
|
2012-01-06 00:52:14 +00:00
|
|
|
vrect.next = 0;
|
2001-08-25 02:47:11 +00:00
|
|
|
}
|
2021-07-10 15:09:41 +00:00
|
|
|
sw32_ctx->update (sw32_ctx, &vrect);
|
2001-08-25 02:47:11 +00:00
|
|
|
}
|