2004-08-22 22:29:09 +00:00
|
|
|
/*
|
|
|
|
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 the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
// screen.c -- master for refresh, status bar, console, chat, notify, etc
|
|
|
|
|
|
|
|
#include "quakedef.h"
|
2004-12-15 19:53:30 +00:00
|
|
|
#ifdef RGLQUAKE
|
2004-08-22 22:29:09 +00:00
|
|
|
#include "glquake.h"
|
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
void GLSCR_UpdateScreen (void);
|
2006-02-11 14:51:36 +00:00
|
|
|
void GLDraw_TextureMode_Changed (void);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern qboolean scr_drawdialog;
|
|
|
|
|
|
|
|
extern cvar_t gl_triplebuffer;
|
|
|
|
extern cvar_t scr_fov;
|
|
|
|
|
|
|
|
extern qboolean scr_initialized;
|
|
|
|
extern float oldsbar;
|
|
|
|
extern qboolean scr_drawloading;
|
|
|
|
|
|
|
|
extern float oldfov;
|
|
|
|
|
|
|
|
|
|
|
|
extern int scr_chatmode;
|
|
|
|
extern cvar_t scr_chatmodecvar;
|
|
|
|
|
|
|
|
|
2004-12-15 19:53:30 +00:00
|
|
|
|
|
|
|
void RSpeedShow(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
static int samplerspeeds[RSPEED_MAX];
|
|
|
|
static int samplerquant[RQUANT_MAX];
|
|
|
|
char *RSpNames[RSPEED_MAX];
|
|
|
|
char *RQntNames[RQUANT_MAX];
|
|
|
|
char *s;
|
|
|
|
static int framecount;
|
|
|
|
|
|
|
|
if (!r_speeds.value)
|
|
|
|
return;
|
|
|
|
|
|
|
|
memset(RSpNames, 0, sizeof(RSpNames));
|
|
|
|
RSpNames[RSPEED_TOTALREFRESH] = "Total refresh";
|
2005-04-16 16:21:27 +00:00
|
|
|
RSpNames[RSPEED_PROTOCOL] = "Protocol";
|
|
|
|
RSpNames[RSPEED_LINKENTITIES] = "Entity setup";
|
2004-12-15 19:53:30 +00:00
|
|
|
RSpNames[RSPEED_WORLDNODE] = "World walking";
|
|
|
|
RSpNames[RSPEED_WORLD] = "World rendering";
|
|
|
|
RSpNames[RSPEED_DYNAMIC] = "Lightmap updates";
|
|
|
|
RSpNames[RSPEED_PARTICLES] = "Particle physics and sorting";
|
|
|
|
RSpNames[RSPEED_PARTICLESDRAW] = "Particle drawing";
|
|
|
|
RSpNames[RSPEED_2D] = "2d elements";
|
|
|
|
RSpNames[RSPEED_SERVER] = "Server";
|
|
|
|
|
2005-04-16 16:21:27 +00:00
|
|
|
RSpNames[RSPEED_DRAWENTITIES] = "Entity rendering";
|
|
|
|
|
2004-12-15 19:53:30 +00:00
|
|
|
RSpNames[RSPEED_PALETTEFLASHES] = "Palette flashes";
|
|
|
|
RSpNames[RSPEED_STENCILSHADOWS] = "Stencil Shadows";
|
|
|
|
|
|
|
|
RSpNames[RSPEED_FULLBRIGHTS] = "World fullbrights";
|
|
|
|
|
|
|
|
RSpNames[RSPEED_FINISH] = "Waiting for card to catch up";
|
|
|
|
|
|
|
|
RQntNames[RQUANT_MSECS] = "Microseconds";
|
|
|
|
RQntNames[RQUANT_EPOLYS] = "Entity Polys";
|
|
|
|
RQntNames[RQUANT_WPOLYS] = "World Polys";
|
|
|
|
RQntNames[RQUANT_SHADOWFACES] = "Shadow Faces";
|
|
|
|
RQntNames[RQUANT_SHADOWEDGES] = "Shadow edges";
|
|
|
|
RQntNames[RQUANT_LITFACES] = "Lit faces";
|
|
|
|
|
|
|
|
for (i = 0; i < RSPEED_MAX; i++)
|
|
|
|
{
|
2005-01-13 15:20:33 +00:00
|
|
|
s = va("%i %-30s", samplerspeeds[i], RSpNames[i]);
|
2004-12-15 19:53:30 +00:00
|
|
|
Draw_String(vid.width-strlen(s)*8, i*8, s);
|
|
|
|
}
|
|
|
|
for (i = 0; i < RQUANT_MAX; i++)
|
|
|
|
{
|
2005-01-13 15:20:33 +00:00
|
|
|
s = va("%i %-30s", samplerquant[i], RQntNames[i]);
|
2004-12-15 19:53:30 +00:00
|
|
|
Draw_String(vid.width-strlen(s)*8, (i+RSPEED_MAX)*8, s);
|
|
|
|
}
|
2005-05-13 10:42:48 +00:00
|
|
|
s = va("%f %-30s", 100000000.0f/samplerspeeds[RSPEED_TOTALREFRESH], "Framerate");
|
|
|
|
Draw_String(vid.width-strlen(s)*8, (i+RSPEED_MAX)*8, s);
|
2004-12-15 19:53:30 +00:00
|
|
|
|
|
|
|
if (framecount++>=100)
|
|
|
|
{
|
|
|
|
for (i = 0; i < RSPEED_MAX; i++)
|
|
|
|
{
|
|
|
|
samplerspeeds[i] = rspeeds[i];
|
|
|
|
rspeeds[i] = 0;
|
|
|
|
}
|
|
|
|
for (i = 0; i < RQUANT_MAX; i++)
|
|
|
|
{
|
|
|
|
samplerquant[i] = rquant[i];
|
|
|
|
rquant[i] = 0;
|
|
|
|
}
|
|
|
|
framecount=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
/*
|
|
|
|
==================
|
|
|
|
SCR_UpdateScreen
|
|
|
|
|
|
|
|
This is called every frame, and can also be called explicitly to flush
|
|
|
|
text to the screen.
|
|
|
|
|
|
|
|
WARNING: be very careful calling this from elsewhere, because the refresh
|
|
|
|
needs almost the entire 256k of stack space!
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
|
|
|
|
void GLSCR_UpdateScreen (void)
|
|
|
|
{
|
2005-11-30 01:20:53 +00:00
|
|
|
extern cvar_t vid_conwidth, vid_conheight, gl_texturemode;
|
2004-08-22 22:29:09 +00:00
|
|
|
int uimenu;
|
|
|
|
#ifdef TEXTEDITOR
|
2005-01-24 23:47:32 +00:00
|
|
|
extern qboolean editormodal;
|
2004-08-22 22:29:09 +00:00
|
|
|
#endif
|
2004-12-24 08:45:56 +00:00
|
|
|
qboolean nohud;
|
2004-12-15 19:53:30 +00:00
|
|
|
RSpeedMark();
|
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
if (block_drawing)
|
2004-12-15 19:53:30 +00:00
|
|
|
{
|
|
|
|
RSpeedEnd(RSPEED_TOTALREFRESH);
|
2004-08-22 22:29:09 +00:00
|
|
|
return;
|
2004-12-15 19:53:30 +00:00
|
|
|
}
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2005-01-26 18:56:49 +00:00
|
|
|
if (vid_conwidth.modified || vid_conheight.modified)
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
2005-01-26 18:56:49 +00:00
|
|
|
//let let the user be too crazy
|
|
|
|
if (vid_conwidth.value > 2048) //anything higher is unreadable.
|
|
|
|
Cvar_Set(&vid_conwidth, "2048");
|
2005-02-06 02:47:36 +00:00
|
|
|
if (vid_conwidth.value < 240) //lower would be wrong
|
2005-01-26 18:56:49 +00:00
|
|
|
Cvar_Set(&vid_conwidth, "320");
|
|
|
|
if (vid_conheight.value > 1536) //anything higher is unreadable.
|
|
|
|
Cvar_Set(&vid_conheight, "1536");
|
2005-02-06 02:47:36 +00:00
|
|
|
if (vid_conheight.value < 240) //lower would be wrong
|
|
|
|
Cvar_Set(&vid_conheight, "200");
|
2005-01-26 18:56:49 +00:00
|
|
|
|
|
|
|
vid_conwidth.modified = false;
|
|
|
|
vid_conheight.modified = false;
|
|
|
|
|
|
|
|
// vid.width = vid.conwidth = (glwidth - 320) * gl_2dscale.value + 320;
|
|
|
|
// vid.height = vid.conheight = (glheight - 240) * gl_2dscale.value + 240;
|
|
|
|
|
|
|
|
vid.width = vid.conwidth = vid_conwidth.value;
|
|
|
|
vid.height = vid.conheight = vid_conheight.value;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
vid.recalc_refdef = true;
|
|
|
|
Con_CheckResize();
|
2004-10-10 06:32:29 +00:00
|
|
|
|
2004-10-26 23:06:29 +00:00
|
|
|
#ifdef PLUGINS
|
2004-10-10 06:32:29 +00:00
|
|
|
Plug_ResChanged();
|
2004-10-26 23:06:29 +00:00
|
|
|
#endif
|
2004-10-10 06:32:29 +00:00
|
|
|
GL_Set2D();
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vid.numpages = 2 + gl_triplebuffer.value;
|
|
|
|
|
|
|
|
scr_copytop = 0;
|
|
|
|
scr_copyeverything = 0;
|
|
|
|
|
|
|
|
if (scr_disabled_for_loading)
|
|
|
|
{
|
2005-02-12 18:56:04 +00:00
|
|
|
extern float scr_disabled_time;
|
|
|
|
if (Sys_DoubleTime() - scr_disabled_time > 60 || key_dest != key_game)
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
|
|
|
scr_disabled_for_loading = false;
|
|
|
|
}
|
|
|
|
else
|
2005-02-12 18:56:04 +00:00
|
|
|
{
|
2004-08-22 22:29:09 +00:00
|
|
|
GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
|
|
|
|
SCR_DrawLoading ();
|
|
|
|
GL_EndRendering ();
|
2004-11-18 17:55:04 +00:00
|
|
|
GL_DoSwap();
|
2004-12-15 19:53:30 +00:00
|
|
|
RSpeedEnd(RSPEED_TOTALREFRESH);
|
2004-08-22 22:29:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!scr_initialized || !con_initialized)
|
2004-12-15 19:53:30 +00:00
|
|
|
{
|
|
|
|
RSpeedEnd(RSPEED_TOTALREFRESH);
|
2004-08-22 22:29:09 +00:00
|
|
|
return; // not initialized yet
|
2004-12-15 19:53:30 +00:00
|
|
|
}
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2005-09-09 23:40:55 +00:00
|
|
|
#ifdef VM_UI
|
2004-08-22 22:29:09 +00:00
|
|
|
uimenu = UI_MenuState();
|
2005-09-09 23:40:55 +00:00
|
|
|
#else
|
|
|
|
uimenu = 0;
|
|
|
|
#endif
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (oldsbar != cl_sbar.value) {
|
|
|
|
oldsbar = cl_sbar.value;
|
|
|
|
vid.recalc_refdef = true;
|
|
|
|
}
|
2005-11-30 01:20:53 +00:00
|
|
|
if (gl_texturemode.modified)
|
|
|
|
GLDraw_TextureMode_Changed();
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
|
|
|
|
|
|
|
|
#ifdef TEXTEDITOR
|
|
|
|
if (editormodal)
|
|
|
|
{
|
|
|
|
Editor_Draw();
|
|
|
|
GLV_UpdatePalette ();
|
|
|
|
#if defined(_WIN32) && defined(RGLQUAKE)
|
|
|
|
Media_RecordFrame();
|
|
|
|
#endif
|
|
|
|
GLR_BrightenScreen();
|
2005-08-03 23:14:59 +00:00
|
|
|
|
|
|
|
if (key_dest == key_console)
|
|
|
|
Con_DrawConsole(vid_conheight.value/2, false);
|
2004-08-22 22:29:09 +00:00
|
|
|
GL_EndRendering ();
|
2004-11-18 17:55:04 +00:00
|
|
|
GL_DoSwap();
|
2004-12-15 19:53:30 +00:00
|
|
|
RSpeedEnd(RSPEED_TOTALREFRESH);
|
2004-08-22 22:29:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (Media_ShowFilm())
|
|
|
|
{
|
|
|
|
M_Draw(0);
|
|
|
|
GLV_UpdatePalette ();
|
|
|
|
#if defined(_WIN32) && defined(RGLQUAKE)
|
|
|
|
Media_RecordFrame();
|
|
|
|
#endif
|
|
|
|
GLR_BrightenScreen();
|
|
|
|
GL_EndRendering ();
|
2004-11-18 17:55:04 +00:00
|
|
|
GL_DoSwap();
|
2004-12-15 19:53:30 +00:00
|
|
|
RSpeedEnd(RSPEED_TOTALREFRESH);
|
2004-08-22 22:29:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// determine size of refresh window
|
|
|
|
//
|
|
|
|
if (oldfov != scr_fov.value)
|
|
|
|
{
|
|
|
|
oldfov = scr_fov.value;
|
|
|
|
vid.recalc_refdef = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vid.recalc_refdef || scr_viewsize.modified)
|
|
|
|
SCR_CalcRefdef ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// do 3D refresh drawing, and then update the screen
|
|
|
|
//
|
|
|
|
SCR_SetUpToDrawConsole ();
|
2004-12-24 08:45:56 +00:00
|
|
|
|
|
|
|
nohud = false;
|
2005-09-08 22:52:46 +00:00
|
|
|
|
2004-12-24 08:45:56 +00:00
|
|
|
#ifdef VM_CG
|
|
|
|
if (CG_Refresh())
|
|
|
|
nohud = true;
|
|
|
|
else
|
2005-01-07 03:07:50 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CSQC_DAT
|
2006-01-04 00:44:34 +00:00
|
|
|
if (cls.state == ca_active && CSQC_DrawView())
|
2005-01-07 03:07:50 +00:00
|
|
|
nohud = true;
|
|
|
|
else
|
2004-12-24 08:45:56 +00:00
|
|
|
#endif
|
2006-01-28 19:04:13 +00:00
|
|
|
if (r_worldentity.model && uimenu != 1)
|
2005-05-13 10:42:48 +00:00
|
|
|
{
|
2004-08-22 22:29:09 +00:00
|
|
|
V_RenderView ();
|
2006-02-11 14:51:36 +00:00
|
|
|
// Q1BSP_TestClipDecal();
|
2005-05-13 10:42:48 +00:00
|
|
|
}
|
2004-11-18 17:55:04 +00:00
|
|
|
else
|
|
|
|
GL_DoSwap();
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
GL_Set2D ();
|
|
|
|
|
2004-10-13 07:24:59 +00:00
|
|
|
GLR_BrightenScreen();
|
|
|
|
|
2005-02-06 13:54:36 +00:00
|
|
|
if (!nohud)
|
|
|
|
SCR_TileClear ();
|
|
|
|
|
2004-12-24 08:45:56 +00:00
|
|
|
SCR_DrawTwoDimensional(uimenu, nohud);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
GLV_UpdatePalette ();
|
|
|
|
#if defined(_WIN32) && defined(RGLQUAKE)
|
|
|
|
Media_RecordFrame();
|
|
|
|
#endif
|
2004-12-15 19:53:30 +00:00
|
|
|
|
|
|
|
RSpeedEnd(RSPEED_TOTALREFRESH);
|
|
|
|
RSpeedShow();
|
|
|
|
|
2004-11-18 17:55:04 +00:00
|
|
|
GL_EndRendering ();
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char *GLVID_GetRGBInfo(int prepadbytes, int *truewidth, int *trueheight)
|
|
|
|
{ //returns a BZ_Malloced array
|
2004-11-29 01:21:00 +00:00
|
|
|
extern qboolean gammaworks;
|
|
|
|
int i, c;
|
2004-08-22 22:29:09 +00:00
|
|
|
qbyte *ret = BZ_Malloc(prepadbytes + glwidth*glheight*3);
|
|
|
|
|
2005-01-07 03:07:50 +00:00
|
|
|
qglReadPixels (glx, gly, glwidth, glheight, GL_RGB, GL_UNSIGNED_BYTE, ret + prepadbytes);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
*truewidth = glwidth;
|
|
|
|
*trueheight = glheight;
|
2004-11-29 01:21:00 +00:00
|
|
|
|
|
|
|
if (gammaworks)
|
|
|
|
{
|
|
|
|
c = prepadbytes+glwidth*glheight*3;
|
|
|
|
for (i=prepadbytes ; i<c ; i+=3)
|
|
|
|
{
|
|
|
|
extern qbyte gammatable[256];
|
|
|
|
ret[i+0] = gammatable[ret[i+0]];
|
|
|
|
ret[i+1] = gammatable[ret[i+1]];
|
|
|
|
ret[i+2] = gammatable[ret[i+2]];
|
|
|
|
}
|
|
|
|
}
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2004-12-15 19:53:30 +00:00
|
|
|
#endif
|