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"
|
2009-11-04 21:16:50 +00:00
|
|
|
#ifdef GLQUAKE
|
2004-08-22 22:29:09 +00:00
|
|
|
#include "glquake.h"
|
2009-11-04 21:16:50 +00:00
|
|
|
#include "shader.h"
|
2010-05-01 22:47:47 +00:00
|
|
|
#include "gl_draw.h"
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
void GLSCR_UpdateScreen (void);
|
|
|
|
|
|
|
|
|
|
|
|
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 int scr_chatmode;
|
|
|
|
extern cvar_t scr_chatmodecvar;
|
2009-03-03 01:52:30 +00:00
|
|
|
extern cvar_t vid_conautoscale;
|
2009-11-04 21:16:50 +00:00
|
|
|
extern qboolean scr_con_forcedraw;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2006-04-15 06:57:13 +00:00
|
|
|
// console size manipulation callbacks
|
|
|
|
void GLVID_Console_Resize(void)
|
|
|
|
{
|
2009-07-18 20:46:42 +00:00
|
|
|
extern cvar_t gl_font;
|
2006-04-15 06:57:13 +00:00
|
|
|
extern cvar_t vid_conwidth, vid_conheight;
|
2009-03-03 01:52:30 +00:00
|
|
|
int cwidth, cheight;
|
|
|
|
float xratio;
|
|
|
|
float yratio=0;
|
|
|
|
cwidth = vid_conwidth.value;
|
|
|
|
cheight = vid_conheight.value;
|
2006-04-15 06:57:13 +00:00
|
|
|
|
2009-03-03 01:52:30 +00:00
|
|
|
xratio = vid_conautoscale.value;
|
|
|
|
if (xratio > 0)
|
|
|
|
{
|
|
|
|
char *s = strchr(vid_conautoscale.string, ' ');
|
|
|
|
if (s)
|
|
|
|
yratio = atof(s + 1);
|
|
|
|
|
|
|
|
if (yratio <= 0)
|
|
|
|
yratio = xratio;
|
|
|
|
|
|
|
|
xratio = 1 / xratio;
|
|
|
|
yratio = 1 / yratio;
|
|
|
|
|
|
|
|
//autoscale overrides conwidth/height (without actually changing them)
|
2009-11-04 21:16:50 +00:00
|
|
|
cwidth = vid.pixelwidth;
|
|
|
|
cheight = vid.pixelheight;
|
2009-03-03 01:52:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xratio = 1;
|
|
|
|
yratio = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!cwidth)
|
2009-11-04 21:16:50 +00:00
|
|
|
cwidth = vid.pixelwidth;
|
2009-03-03 01:52:30 +00:00
|
|
|
if (!cheight)
|
2009-11-04 21:16:50 +00:00
|
|
|
cheight = vid.pixelheight;
|
2009-03-03 01:52:30 +00:00
|
|
|
|
|
|
|
cwidth*=xratio;
|
|
|
|
cheight*=yratio;
|
|
|
|
|
|
|
|
if (cwidth < 320)
|
|
|
|
cwidth = 320;
|
|
|
|
if (cheight < 200)
|
|
|
|
cheight = 200;
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
vid.width = cwidth;
|
|
|
|
vid.height = cheight;
|
2006-04-15 06:57:13 +00:00
|
|
|
|
|
|
|
vid.recalc_refdef = true;
|
|
|
|
|
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
|
|
|
if (font_tiny)
|
|
|
|
Font_Free(font_tiny);
|
|
|
|
font_tiny = NULL;
|
2009-11-04 21:16:50 +00:00
|
|
|
if (font_conchar)
|
|
|
|
Font_Free(font_conchar);
|
2010-08-17 20:40:27 +00:00
|
|
|
font_conchar = NULL;
|
|
|
|
|
|
|
|
Cvar_ForceCallback(&gl_font);
|
2009-07-05 18:45:53 +00:00
|
|
|
|
2006-04-15 06:57:13 +00:00
|
|
|
#ifdef PLUGINS
|
|
|
|
Plug_ResChanged();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-08-17 20:40:27 +00:00
|
|
|
void GL_Font_Callback(struct cvar_s *var, char *oldvalue)
|
|
|
|
{
|
|
|
|
if (font_conchar)
|
|
|
|
Font_Free(font_conchar);
|
|
|
|
font_conchar = Font_LoadFont(8*vid.pixelheight/vid.height, var->string);
|
|
|
|
if (!font_conchar && *var->string)
|
|
|
|
font_conchar = Font_LoadFont(8*vid.pixelheight/vid.height, "");
|
|
|
|
}
|
|
|
|
|
2006-04-15 06:57:13 +00:00
|
|
|
void GLVID_Conheight_Callback(struct cvar_s *var, char *oldvalue)
|
|
|
|
{
|
|
|
|
if (var->value > 1536) //anything higher is unreadable.
|
|
|
|
{
|
|
|
|
Cvar_ForceSet(var, "1536");
|
|
|
|
return;
|
|
|
|
}
|
2009-03-03 01:52:30 +00:00
|
|
|
if (var->value < 200 && var->value) //lower would be wrong
|
2006-04-15 06:57:13 +00:00
|
|
|
{
|
|
|
|
Cvar_ForceSet(var, "200");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLVID_Console_Resize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLVID_Conwidth_Callback(struct cvar_s *var, char *oldvalue)
|
|
|
|
{
|
|
|
|
//let let the user be too crazy
|
|
|
|
if (var->value > 2048) //anything higher is unreadable.
|
|
|
|
{
|
|
|
|
Cvar_ForceSet(var, "2048");
|
|
|
|
return;
|
|
|
|
}
|
2009-03-03 01:52:30 +00:00
|
|
|
if (var->value < 320 && var->value) //lower would be wrong
|
2006-04-15 06:57:13 +00:00
|
|
|
{
|
|
|
|
Cvar_ForceSet(var, "320");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLVID_Console_Resize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLVID_Conautoscale_Callback(struct cvar_s *var, char *oldvalue)
|
|
|
|
{
|
2009-03-03 01:52:30 +00:00
|
|
|
GLVID_Console_Resize();
|
2006-04-15 06:57:13 +00:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2006-04-15 06:57:13 +00:00
|
|
|
extern cvar_t vid_conheight;
|
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;
|
2009-04-06 00:34:32 +00:00
|
|
|
qboolean noworld;
|
2004-12-15 19:53:30 +00:00
|
|
|
RSpeedMark();
|
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
vid.numpages = 2 + gl_triplebuffer.value;
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
GL_BeginRendering ();
|
2006-09-17 00:59:22 +00:00
|
|
|
scr_drawloading = true;
|
2004-08-22 22:29:09 +00:00
|
|
|
SCR_DrawLoading ();
|
2006-09-17 00:59:22 +00:00
|
|
|
scr_drawloading = 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2009-11-07 13:29:15 +00:00
|
|
|
|
|
|
|
Shader_DoReload();
|
|
|
|
|
|
|
|
GL_BeginRendering ();
|
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
|
|
|
|
|
|
|
#ifdef TEXTEDITOR
|
|
|
|
if (editormodal)
|
|
|
|
{
|
|
|
|
Editor_Draw();
|
2008-06-12 23:19:47 +00:00
|
|
|
GLV_UpdatePalette (false, host_frametime);
|
2009-11-04 21:16:50 +00:00
|
|
|
#if defined(_WIN32) && defined(GLQUAKE)
|
2004-08-22 22:29:09 +00:00
|
|
|
Media_RecordFrame();
|
|
|
|
#endif
|
2010-05-01 22:47:47 +00:00
|
|
|
R2D_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);
|
2008-06-12 23:19:47 +00:00
|
|
|
GLV_UpdatePalette (false, host_frametime);
|
2009-11-04 21:16:50 +00:00
|
|
|
#if defined(_WIN32) && defined(GLQUAKE)
|
2004-08-22 22:29:09 +00:00
|
|
|
Media_RecordFrame();
|
|
|
|
#endif
|
2010-05-01 22:47:47 +00:00
|
|
|
R2D_BrightenScreen();
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// determine size of refresh window
|
|
|
|
//
|
2006-04-15 06:57:13 +00:00
|
|
|
if (vid.recalc_refdef)
|
2004-08-22 22:29:09 +00:00
|
|
|
SCR_CalcRefdef ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// do 3D refresh drawing, and then update the screen
|
|
|
|
//
|
|
|
|
SCR_SetUpToDrawConsole ();
|
2004-12-24 08:45:56 +00:00
|
|
|
|
2009-04-06 00:34:32 +00:00
|
|
|
noworld = false;
|
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
|
2009-04-06 00:34:32 +00:00
|
|
|
if (uimenu != 1)
|
2005-05-13 10:42:48 +00:00
|
|
|
{
|
2009-04-06 00:34:32 +00:00
|
|
|
if (r_worldentity.model && cls.state == ca_active)
|
|
|
|
V_RenderView ();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
noworld = true;
|
|
|
|
}
|
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 ();
|
|
|
|
|
2010-03-25 22:56:11 +00:00
|
|
|
if (!noworld)
|
|
|
|
{
|
2010-05-01 22:47:47 +00:00
|
|
|
R2D_PolyBlend ();
|
|
|
|
R2D_BrightenScreen();
|
2010-03-25 22:56:11 +00:00
|
|
|
}
|
2004-10-13 07:24:59 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
scr_con_forcedraw = false;
|
2009-04-06 00:34:32 +00:00
|
|
|
if (noworld)
|
|
|
|
{
|
|
|
|
extern char levelshotname[];
|
|
|
|
|
|
|
|
if ((key_dest == key_console || key_dest == key_game) && SCR_GetLoadingStage() == LS_NONE)
|
|
|
|
scr_con_current = vid.height;
|
|
|
|
|
|
|
|
//draw the levelshot or the conback fullscreen
|
|
|
|
if (*levelshotname)
|
|
|
|
{
|
|
|
|
if(Draw_ScalePic)
|
|
|
|
Draw_ScalePic(0, 0, vid.width, vid.height, Draw_SafeCachePic (levelshotname));
|
2009-11-04 21:16:50 +00:00
|
|
|
else if (scr_con_current != vid.height)
|
2009-04-06 00:34:32 +00:00
|
|
|
Draw_ConsoleBackground(0, vid.height, true);
|
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
else if (scr_con_current != vid.height)
|
2009-04-06 00:34:32 +00:00
|
|
|
Draw_ConsoleBackground(0, vid.height, true);
|
2009-11-04 21:16:50 +00:00
|
|
|
else
|
|
|
|
scr_con_forcedraw = true;
|
2009-04-06 00:34:32 +00:00
|
|
|
|
|
|
|
nohud = true;
|
|
|
|
}
|
|
|
|
else if (!nohud)
|
2005-02-06 13:54:36 +00:00
|
|
|
SCR_TileClear ();
|
|
|
|
|
2004-12-24 08:45:56 +00:00
|
|
|
SCR_DrawTwoDimensional(uimenu, nohud);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2008-06-12 23:19:47 +00:00
|
|
|
GLV_UpdatePalette (false, host_frametime);
|
2009-11-04 21:16:50 +00:00
|
|
|
#if defined(_WIN32) && defined(GLQUAKE)
|
2004-08-22 22:29:09 +00:00
|
|
|
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;
|
2009-11-04 21:16:50 +00:00
|
|
|
qbyte *ret = BZ_Malloc(prepadbytes + vid.pixelwidth*vid.pixelheight*3);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
qglReadPixels (0, 0, vid.pixelwidth, vid.pixelheight, GL_RGB, GL_UNSIGNED_BYTE, ret + prepadbytes);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
*truewidth = vid.pixelwidth;
|
|
|
|
*trueheight = vid.pixelheight;
|
2004-11-29 01:21:00 +00:00
|
|
|
|
|
|
|
if (gammaworks)
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
c = prepadbytes+vid.pixelwidth*vid.pixelheight*3;
|
2004-11-29 01:21:00 +00:00
|
|
|
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
|