This repository has been archived on 2022-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
Xash3DArchive/engine/client/cl_scrn.c

643 lines
16 KiB
C
Raw Normal View History

2011-05-09 22:00:00 +02:00
/*
cl_scrn.c - refresh screen
Copyright (C) 2007 Uncle Mike
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 3 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.
*/
2007-06-21 22:00:00 +02:00
2008-06-09 22:00:00 +02:00
#include "common.h"
2007-06-21 22:00:00 +02:00
#include "client.h"
2011-04-06 22:00:00 +02:00
#include "gl_local.h"
2011-04-08 22:00:00 +02:00
#include "vgui_draw.h"
2010-09-10 22:00:00 +02:00
#include "qfont.h"
2007-06-21 22:00:00 +02:00
2010-10-22 22:00:00 +02:00
convar_t *scr_centertime;
convar_t *scr_loading;
convar_t *scr_download;
convar_t *scr_width;
convar_t *scr_height;
2011-04-10 22:00:00 +02:00
convar_t *scr_viewsize;
2010-10-22 22:00:00 +02:00
convar_t *cl_testlights;
convar_t *cl_allow_levelshots;
convar_t *cl_levelshot_name;
convar_t *cl_envshot_size;
2010-10-31 22:00:00 +01:00
convar_t *scr_dark;
2007-11-06 22:00:00 +01:00
2011-09-19 22:00:00 +02:00
typedef struct
{
int x1, y1, x2, y2;
} dirty_t;
static dirty_t scr_dirty, scr_old_dirty[2];
2011-04-09 22:00:00 +02:00
static qboolean scr_init = false;
2007-11-04 22:00:00 +01:00
2008-12-26 22:00:00 +01:00
/*
==============
SCR_DrawFPS
==============
*/
void SCR_DrawFPS( void )
{
float calc;
2010-07-20 22:00:00 +02:00
rgba_t color;
2008-12-26 22:00:00 +01:00
static double nexttime = 0, lasttime = 0;
static double framerate = 0;
static int framecount = 0;
double newtime;
char fpsstring[32];
2011-07-07 22:00:00 +02:00
int offset;
2008-12-26 22:00:00 +01:00
if( cls.state != ca_active ) return;
2011-02-27 22:00:00 +01:00
if( !cl_showfps->integer || cl.background ) return;
2011-09-19 22:00:00 +02:00
switch( cls.scrshot_action )
{
case scrshot_normal:
case scrshot_snapshot:
case scrshot_inactive:
break;
default: return;
}
2008-12-26 22:00:00 +01:00
newtime = Sys_DoubleTime();
2009-09-17 22:00:00 +02:00
if( newtime >= nexttime )
2008-12-26 22:00:00 +01:00
{
framerate = framecount / (newtime - lasttime);
lasttime = newtime;
2010-07-23 22:00:00 +02:00
nexttime = max( nexttime + 1, lasttime - 1 );
2008-12-26 22:00:00 +01:00
framecount = 0;
}
2010-07-20 22:00:00 +02:00
2008-12-26 22:00:00 +01:00
framecount++;
calc = framerate;
2010-07-20 22:00:00 +02:00
if( calc < 1.0f )
2008-12-26 22:00:00 +01:00
{
2011-03-09 22:00:00 +01:00
Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i spf", (int)(1.0f / calc + 0.5));
2010-07-20 22:00:00 +02:00
MakeRGBA( color, 255, 0, 0, 255 );
2008-12-26 22:00:00 +01:00
}
else
{
2011-03-09 22:00:00 +01:00
Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i fps", (int)(calc + 0.5));
2010-07-20 22:00:00 +02:00
MakeRGBA( color, 255, 255, 255, 255 );
2008-12-26 22:00:00 +01:00
}
2011-07-07 22:00:00 +02:00
Con_DrawStringLen( fpsstring, &offset, NULL );
Con_DrawString( scr_width->integer - offset - 2, 4, fpsstring, color );
2008-12-26 22:00:00 +01:00
}
2011-04-09 22:00:00 +02:00
/*
==============
SCR_NetSpeeds
same as r_speeds but for network channel
==============
*/
2010-07-26 22:00:00 +02:00
void SCR_NetSpeeds( void )
{
static char msg[MAX_SYSPATH];
int x, y, height;
char *p, *start, *end;
2011-04-08 22:00:00 +02:00
float time = cl.mtime[0];
2010-07-26 22:00:00 +02:00
rgba_t color;
if( !net_speeds->integer ) return;
if( cls.state != ca_active ) return;
switch( net_speeds->integer )
{
case 1:
if( cls.netchan.compress )
{
2011-03-09 22:00:00 +01:00
Q_snprintf( msg, sizeof( msg ), "Game Time: %02d:%02d\nTotal received from server:\n Huffman %s\nUncompressed %s\n",
(int)(time / 60.0f ), (int)fmod( time, 60.0f ), Q_memprint( cls.netchan.total_received ), Q_memprint( cls.netchan.total_received_uncompressed ));
2010-07-26 22:00:00 +02:00
}
else
{
2011-03-09 22:00:00 +01:00
Q_snprintf( msg, sizeof( msg ), "Game Time: %02d:%02d\nTotal received from server:\nUncompressed %s\n",
(int)(time / 60.0f ), (int)fmod( time, 60.0f ), Q_memprint( cls.netchan.total_received_uncompressed ));
2010-07-26 22:00:00 +02:00
}
break;
case 2:
if( cls.netchan.compress )
{
2011-03-09 22:00:00 +01:00
Q_snprintf( msg, sizeof( msg ), "Game Time: %02d:%02d\nTotal sended to server:\nHuffman %s\nUncompressed %s\n",
(int)(time / 60.0f ), (int)fmod( time, 60.0f ), Q_memprint( cls.netchan.total_sended ), Q_memprint( cls.netchan.total_sended_uncompressed ));
2010-07-26 22:00:00 +02:00
}
else
{
2011-03-09 22:00:00 +01:00
Q_snprintf( msg, sizeof( msg ), "Game Time: %02d:%02d\nTotal sended to server:\nUncompressed %s\n",
(int)(time / 60.0f ), (int)fmod( time, 60.0f ), Q_memprint( cls.netchan.total_sended_uncompressed ));
2010-07-26 22:00:00 +02:00
}
break;
default: return;
}
x = scr_width->integer - 320;
y = 256;
Con_DrawStringLen( NULL, NULL, &height );
MakeRGBA( color, 255, 255, 255, 255 );
p = start = msg;
2011-04-09 22:00:00 +02:00
2010-07-26 22:00:00 +02:00
do
{
2011-03-09 22:00:00 +01:00
end = Q_strchr( p, '\n' );
2010-07-26 22:00:00 +02:00
if( end ) msg[end-start] = '\0';
Con_DrawString( x, y, p, color );
y += height;
if( end ) p = end + 1;
else break;
} while( 1 );
}
2009-09-01 22:00:00 +02:00
/*
================
SCR_RSpeeds
================
*/
void SCR_RSpeeds( void )
{
char msg[MAX_SYSPATH];
2010-12-02 22:00:00 +01:00
if( R_SpeedsMessage( msg, sizeof( msg )))
2009-09-01 22:00:00 +02:00
{
int x, y, height;
char *p, *start, *end;
2009-09-10 22:00:00 +02:00
rgba_t color;
2009-09-01 22:00:00 +02:00
2013-12-19 21:00:00 +01:00
x = scr_width->integer - 340;
2009-09-01 22:00:00 +02:00
y = 64;
2010-07-20 22:00:00 +02:00
Con_DrawStringLen( NULL, NULL, &height );
2009-09-10 22:00:00 +02:00
MakeRGBA( color, 255, 255, 255, 255 );
2009-09-01 22:00:00 +02:00
p = start = msg;
do
{
2011-03-09 22:00:00 +01:00
end = Q_strchr( p, '\n' );
2009-09-01 22:00:00 +02:00
if( end ) msg[end-start] = '\0';
2010-07-20 22:00:00 +02:00
Con_DrawString( x, y, p, color );
2009-09-01 22:00:00 +02:00
y += height;
if( end ) p = end + 1;
else break;
} while( 1 );
}
}
2009-10-18 22:00:00 +02:00
void SCR_MakeLevelShot( void )
{
if( cls.scrshot_request != scrshot_plaque )
return;
// make levelshot at nextframe()
2010-12-09 22:00:00 +01:00
Cbuf_AddText( "levelshot\n" );
2009-10-18 22:00:00 +02:00
}
2009-09-23 22:00:00 +02:00
void SCR_MakeScreenShot( void )
{
2010-10-26 22:00:00 +02:00
qboolean iRet = false;
2010-03-26 22:00:00 +01:00
2009-09-23 22:00:00 +02:00
switch( cls.scrshot_action )
{
2011-03-31 22:00:00 +02:00
case scrshot_normal:
iRet = VID_ScreenShot( cls.shotname, VID_SCREENSHOT );
break;
2011-09-03 22:00:00 +02:00
case scrshot_snapshot:
iRet = VID_ScreenShot( cls.shotname, VID_SNAPSHOT );
break;
2009-09-23 22:00:00 +02:00
case scrshot_plaque:
2010-12-02 22:00:00 +01:00
iRet = VID_ScreenShot( cls.shotname, VID_LEVELSHOT );
2009-09-23 22:00:00 +02:00
break;
case scrshot_savegame:
2010-01-07 22:00:00 +01:00
case scrshot_demoshot:
2010-12-02 22:00:00 +01:00
iRet = VID_ScreenShot( cls.shotname, VID_MINISHOT );
2010-03-26 22:00:00 +01:00
break;
case scrshot_envshot:
2010-12-02 22:00:00 +01:00
iRet = VID_CubemapShot( cls.shotname, cl_envshot_size->integer, cls.envshot_vieworg, false );
2009-09-23 22:00:00 +02:00
break;
2010-03-26 22:00:00 +01:00
case scrshot_skyshot:
2010-12-02 22:00:00 +01:00
iRet = VID_CubemapShot( cls.shotname, cl_envshot_size->integer, cls.envshot_vieworg, true );
2010-03-26 22:00:00 +01:00
break;
2011-08-21 22:00:00 +02:00
case scrshot_mapshot:
iRet = VID_ScreenShot( cls.shotname, VID_MAPSHOT );
break;
case scrshot_inactive:
return;
2009-09-23 22:00:00 +02:00
}
2010-03-26 22:00:00 +01:00
// report
2011-09-03 22:00:00 +02:00
if( iRet )
{
// snapshots don't writes message about image
if( cls.scrshot_action != scrshot_snapshot )
2012-08-03 22:00:00 +02:00
MsgDev( D_AICONSOLE, "Write %s\n", cls.shotname );
2011-09-03 22:00:00 +02:00
}
2010-03-26 22:00:00 +01:00
else MsgDev( D_ERROR, "Unable to write %s\n", cls.shotname );
cls.envshot_vieworg = NULL;
2009-09-23 22:00:00 +02:00
cls.scrshot_action = scrshot_inactive;
cls.shotname[0] = '\0';
}
2009-10-18 22:00:00 +02:00
void SCR_DrawPlaque( void )
{
2011-02-11 22:00:00 +01:00
int levelshot;
2009-10-18 22:00:00 +02:00
2011-02-27 22:00:00 +01:00
if(( cl_allow_levelshots->integer && !cls.changelevel ) || Cvar_VariableInteger( "sv_background" ))
2010-07-17 22:00:00 +02:00
{
2012-11-20 21:00:00 +01:00
levelshot = GL_LoadTexture( cl_levelshot_name->string, NULL, 0, TF_IMAGE, NULL );
2010-12-02 22:00:00 +01:00
GL_SetRenderMode( kRenderNormal );
R_DrawStretchPic( 0, 0, scr_width->integer, scr_height->integer, 0, 0, 1, 1, levelshot );
2010-08-22 22:00:00 +02:00
CL_DrawHUD( CL_LOADING );
2010-07-17 22:00:00 +02:00
}
2009-10-18 22:00:00 +02:00
}
2010-12-09 22:00:00 +01:00
/*
================
SCR_BeginLoadingPlaque
================
*/
2011-04-05 22:00:00 +02:00
void SCR_BeginLoadingPlaque( qboolean is_background )
2010-12-09 22:00:00 +01:00
{
S_StopAllSounds();
2011-04-09 22:00:00 +02:00
cl.audio_prepped = false; // don't play ambients
2010-12-09 22:00:00 +01:00
if( cls.disable_screen ) return; // already set
if( cls.state == ca_disconnected ) return; // if at console, don't bring up the plaque
if( cls.key_dest == key_console ) return;
cls.draw_changelevel = true;
SCR_UpdateScreen();
cls.disable_screen = host.realtime;
cls.disable_servercount = cl.servercount;
2011-04-09 22:00:00 +02:00
cl.background = is_background; // set right state before svc_serverdata is came
2010-12-09 22:00:00 +01:00
}
/*
================
SCR_EndLoadingPlaque
================
*/
void SCR_EndLoadingPlaque( void )
{
cls.disable_screen = 0;
Con_ClearNotify();
}
2011-09-19 22:00:00 +02:00
/*
=================
SCR_AddDirtyPoint
=================
*/
void SCR_AddDirtyPoint( int x, int y )
{
2012-12-23 21:00:00 +01:00
if( x < scr_dirty.x1 ) scr_dirty.x1 = x;
if( x > scr_dirty.x2 ) scr_dirty.x2 = x;
if( y < scr_dirty.y1 ) scr_dirty.y1 = y;
if( y > scr_dirty.y2 ) scr_dirty.y2 = y;
2011-09-19 22:00:00 +02:00
}
/*
================
SCR_DirtyScreen
================
*/
void SCR_DirtyScreen( void )
{
SCR_AddDirtyPoint( 0, 0 );
SCR_AddDirtyPoint( scr_width->integer - 1, scr_height->integer - 1 );
}
/*
================
SCR_TileClear
================
*/
void SCR_TileClear( void )
{
int i, top, bottom, left, right;
dirty_t clear;
if( scr_viewsize->integer >= 120 )
return; // full screen rendering
// erase rect will be the union of the past three frames
// so tripple buffering works properly
clear = scr_dirty;
2012-11-18 21:00:00 +01:00
2011-09-19 22:00:00 +02:00
for( i = 0; i < 2; i++ )
{
if( scr_old_dirty[i].x1 < clear.x1 )
clear.x1 = scr_old_dirty[i].x1;
if( scr_old_dirty[i].x2 > clear.x2 )
clear.x2 = scr_old_dirty[i].x2;
if( scr_old_dirty[i].y1 < clear.y1 )
clear.y1 = scr_old_dirty[i].y1;
if( scr_old_dirty[i].y2 > clear.y2 )
clear.y2 = scr_old_dirty[i].y2;
}
scr_old_dirty[1] = scr_old_dirty[0];
scr_old_dirty[0] = scr_dirty;
scr_dirty.x1 = 9999;
scr_dirty.x2 = -9999;
scr_dirty.y1 = 9999;
scr_dirty.y2 = -9999;
if( clear.y2 <= clear.y1 )
return; // nothing disturbed
top = cl.refdef.viewport[1];
bottom = top + cl.refdef.viewport[3] - 1;
left = cl.refdef.viewport[0];
right = left + cl.refdef.viewport[2] - 1;
if( clear.y1 < top )
{
// clear above view screen
i = clear.y2 < top-1 ? clear.y2 : top - 1;
R_DrawTileClear( clear.x1, clear.y1, clear.x2 - clear.x1 + 1, i - clear.y1 + 1 );
clear.y1 = top;
}
if( clear.y2 > bottom )
{
// clear below view screen
i = clear.y1 > bottom + 1 ? clear.y1 : bottom + 1;
R_DrawTileClear( clear.x1, i, clear.x2 - clear.x1 + 1, clear.y2 - i + 1 );
clear.y2 = bottom;
}
if( clear.x1 < left )
{
// clear left of view screen
i = clear.x2 < left - 1 ? clear.x2 : left - 1;
R_DrawTileClear( clear.x1, clear.y1, i - clear.x1 + 1, clear.y2 - clear.y1 + 1 );
clear.x1 = left;
}
if( clear.x2 > right )
{
// clear left of view screen
i = clear.x1 > right + 1 ? clear.x1 : right + 1;
R_DrawTileClear( i, clear.y1, clear.x2 - i + 1, clear.y2 - clear.y1 + 1 );
clear.x2 = right;
}
}
2007-06-21 22:00:00 +02:00
/*
==================
2007-11-06 22:00:00 +01:00
SCR_UpdateScreen
2007-06-21 22:00:00 +02:00
2007-11-06 22:00:00 +01:00
This is called every frame, and can also be called explicitly to flush
text to the screen.
2007-06-21 22:00:00 +02:00
==================
*/
2007-11-06 22:00:00 +01:00
void SCR_UpdateScreen( void )
2007-06-21 22:00:00 +02:00
{
2011-04-09 22:00:00 +02:00
if( !V_PreRender( )) return;
switch( cls.state )
2007-06-21 22:00:00 +02:00
{
2011-04-09 22:00:00 +02:00
case ca_disconnected:
break;
case ca_connecting:
case ca_connected:
SCR_DrawPlaque();
break;
case ca_active:
V_RenderView();
break;
case ca_cinematic:
SCR_DrawCinematic();
break;
default:
Host_Error( "SCR_UpdateScreen: bad cls.state\n" );
break;
}
V_PostRender();
2007-11-05 22:00:00 +01:00
}
2007-06-21 22:00:00 +02:00
2012-12-23 21:00:00 +01:00
void SCR_LoadCreditsFont( void )
2010-07-08 22:00:00 +02:00
{
2011-04-09 22:00:00 +02:00
int fontWidth;
2011-09-28 22:00:00 +02:00
if( cls.creditsFont.valid ) return; // already loaded
2011-04-09 22:00:00 +02:00
2012-11-20 21:00:00 +01:00
cls.creditsFont.hFontTexture = GL_LoadTexture( "gfx.wad/creditsfont.fnt", NULL, 0, TF_IMAGE, NULL );
2011-04-09 22:00:00 +02:00
R_GetTextureParms( &fontWidth, NULL, cls.creditsFont.hFontTexture );
2011-09-28 22:00:00 +02:00
// setup creditsfont
if( FS_FileExists( "gfx/creditsfont.fnt", false ))
2011-04-09 22:00:00 +02:00
{
2011-09-28 22:00:00 +02:00
byte *buffer;
size_t length;
qfont_t *src;
2011-04-09 22:00:00 +02:00
2011-09-28 22:00:00 +02:00
// half-life font with variable chars witdh
buffer = FS_LoadFile( "gfx/creditsfont.fnt", &length, false );
if( buffer && length >= sizeof( qfont_t ))
2010-07-08 22:00:00 +02:00
{
2011-09-28 22:00:00 +02:00
int i;
src = (qfont_t *)buffer;
cls.creditsFont.charHeight = clgame.scrInfo.iCharHeight = src->rowheight;
// build rectangles
for( i = 0; i < 256; i++ )
{
cls.creditsFont.fontRc[i].left = (word)src->fontinfo[i].startoffset % fontWidth;
cls.creditsFont.fontRc[i].right = cls.creditsFont.fontRc[i].left + src->fontinfo[i].charwidth;
cls.creditsFont.fontRc[i].top = (word)src->fontinfo[i].startoffset / fontWidth;
cls.creditsFont.fontRc[i].bottom = cls.creditsFont.fontRc[i].top + src->rowheight;
cls.creditsFont.charWidths[i] = clgame.scrInfo.charWidths[i] = src->fontinfo[i].charwidth;
}
cls.creditsFont.valid = true;
2010-07-08 22:00:00 +02:00
}
2011-09-28 22:00:00 +02:00
if( buffer ) Mem_Free( buffer );
2010-07-08 22:00:00 +02:00
}
}
2012-12-23 21:00:00 +01:00
void SCR_InstallParticlePalette( void )
2010-07-13 22:00:00 +02:00
{
rgbdata_t *pic;
int i;
2011-04-18 22:00:00 +02:00
// first check 'palette.lmp' then 'palette.pal'
pic = FS_LoadImage( "gfx/palette.lmp", NULL, 0 );
if( !pic ) pic = FS_LoadImage( "gfx/palette.pal", NULL, 0 );
2011-04-09 22:00:00 +02:00
2010-07-13 22:00:00 +02:00
// NOTE: imagelib required this fakebuffer for loading internal palette
2011-04-09 22:00:00 +02:00
if( !pic ) pic = FS_LoadImage( "#valve.pal", ((byte *)&i), 768 );
2010-07-13 22:00:00 +02:00
if( pic )
{
for( i = 0; i < 256; i++ )
{
clgame.palette[i][0] = pic->palette[i*4+0];
clgame.palette[i][1] = pic->palette[i*4+1];
clgame.palette[i][2] = pic->palette[i*4+2];
}
FS_FreeImage( pic );
}
else
{
for( i = 0; i < 256; i++ )
{
clgame.palette[i][0] = i;
clgame.palette[i][1] = i;
clgame.palette[i][2] = i;
}
MsgDev( D_WARN, "CL_InstallParticlePalette: failed. Force to grayscale\n" );
}
}
2012-12-23 21:00:00 +01:00
void SCR_RegisterTextures( void )
2008-11-15 22:00:00 +01:00
{
2012-11-20 21:00:00 +01:00
cls.fillImage = GL_LoadTexture( "*white", NULL, 0, TF_IMAGE, NULL ); // used for FillRGBA
cls.particleImage = GL_LoadTexture( "*particle", NULL, 0, TF_IMAGE, NULL );
2010-11-22 22:00:00 +01:00
// register gfx.wad images
2012-11-20 21:00:00 +01:00
cls.pauseIcon = GL_LoadTexture( "gfx.wad/paused.lmp", NULL, 0, TF_IMAGE, NULL );
2011-09-03 22:00:00 +02:00
if( cl_allow_levelshots->integer )
2012-11-20 21:00:00 +01:00
cls.loadingBar = GL_LoadTexture( "gfx.wad/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE, NULL );
else cls.loadingBar = GL_LoadTexture( "gfx.wad/lambda.lmp", NULL, 0, TF_IMAGE, NULL );
cls.tileImage = GL_LoadTexture( "gfx.wad/backtile.lmp", NULL, 0, TF_UNCOMPRESSED|TF_NOPICMIP|TF_NOMIPMAP, NULL );
2011-10-01 22:00:00 +02:00
cls.hChromeSprite = pfnSPR_Load( "sprites/shellchrome.spr" );
2011-03-15 22:00:00 +01:00
}
2010-11-22 22:00:00 +01:00
2011-09-19 22:00:00 +02:00
/*
=================
SCR_SizeUp_f
Keybinding command
=================
*/
void SCR_SizeUp_f( void )
{
Cvar_SetFloat( "viewsize", min( scr_viewsize->value + 10, 120 ));
}
/*
=================
SCR_SizeDown_f
Keybinding command
=================
*/
void SCR_SizeDown_f( void )
{
Cvar_SetFloat( "viewsize", max( scr_viewsize->value - 10, 30 ));
}
2010-11-22 22:00:00 +01:00
/*
==================
SCR_VidInit
==================
*/
void SCR_VidInit( void )
{
2011-03-10 22:00:00 +01:00
Q_memset( &clgame.ds, 0, sizeof( clgame.ds )); // reset a draw state
Q_memset( &menu.ds, 0, sizeof( menu.ds )); // reset a draw state
Q_memset( &clgame.centerPrint, 0, sizeof( clgame.centerPrint ));
2009-12-05 22:00:00 +01:00
2010-07-20 22:00:00 +02:00
// update screen sizes for menu
2010-11-15 22:00:00 +01:00
menu.globals->scrWidth = scr_width->integer;
menu.globals->scrHeight = scr_height->integer;
2008-12-28 22:00:00 +01:00
2010-12-27 22:00:00 +01:00
SCR_RebuildGammaTable();
2010-11-16 22:00:00 +01:00
VGui_Startup ();
2010-12-21 22:00:00 +01:00
clgame.load_sequence++; // now all hud sprites are invalid
2008-12-28 22:00:00 +01:00
// vid_state has changed
2010-11-15 22:00:00 +01:00
if( menu.hInstance ) menu.dllFuncs.pfnVidInit();
2010-12-21 22:00:00 +01:00
if( clgame.hInstance ) clgame.dllFuncs.pfnVidInit();
2010-07-19 22:00:00 +02:00
// restart console size
Con_VidInit ();
2008-11-15 22:00:00 +01:00
}
2007-11-05 22:00:00 +01:00
/*
==================
2007-11-06 22:00:00 +01:00
SCR_Init
2007-11-05 22:00:00 +01:00
==================
*/
2008-11-15 22:00:00 +01:00
void SCR_Init( void )
2007-11-05 22:00:00 +01:00
{
2009-10-02 22:00:00 +02:00
if( scr_init ) return;
2011-02-25 22:00:00 +01:00
MsgDev( D_NOTE, "SCR_Init()\n" );
2009-09-19 22:00:00 +02:00
scr_centertime = Cvar_Get( "scr_centertime", "2.5", 0, "centerprint hold time" );
2010-12-09 22:00:00 +01:00
cl_levelshot_name = Cvar_Get( "cl_levelshot_name", "*black", 0, "contains path to current levelshot" );
2010-07-17 22:00:00 +02:00
cl_allow_levelshots = Cvar_Get( "allow_levelshots", "0", CVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" );
2010-07-20 22:00:00 +02:00
scr_loading = Cvar_Get( "scr_loading", "0", 0, "loading bar progress" );
scr_download = Cvar_Get( "scr_download", "0", 0, "downloading bar progress" );
cl_testlights = Cvar_Get( "cl_testlights", "0", 0, "test dynamic lights" );
2008-11-09 22:00:00 +01:00
cl_envshot_size = Cvar_Get( "cl_envshot_size", "256", CVAR_ARCHIVE, "envshot size of cube side" );
2010-10-31 22:00:00 +01:00
scr_dark = Cvar_Get( "v_dark", "0", 0, "starts level from dark screen" );
2011-04-10 22:00:00 +02:00
scr_viewsize = Cvar_Get( "viewsize", "120", CVAR_ARCHIVE, "screen size" );
2008-11-15 22:00:00 +01:00
2007-11-06 22:00:00 +01:00
// register our commands
2008-01-20 22:00:00 +01:00
Cmd_AddCommand( "timerefresh", SCR_TimeRefresh_f, "turn quickly and print rendering statistcs" );
Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" );
2008-08-04 22:00:00 +02:00
Cmd_AddCommand( "viewpos", SCR_Viewpos_f, "prints current player origin" );
2011-09-19 22:00:00 +02:00
Cmd_AddCommand( "sizeup", SCR_SizeUp_f, "screen size up to 10 points" );
Cmd_AddCommand( "sizedown", SCR_SizeDown_f, "screen size down to 10 points" );
2008-11-09 22:00:00 +01:00
2011-03-20 22:00:00 +01:00
if( host.state != HOST_RESTART && !UI_LoadProgs( ))
2010-07-21 22:00:00 +02:00
{
2011-07-07 22:00:00 +02:00
Msg( "^1Error: ^7can't initialize menu.dll\n" ); // there is non fatal for us
2010-07-21 22:00:00 +02:00
if( !host.developer ) host.developer = 1; // we need console, because menu is missing
}
2010-07-18 22:00:00 +02:00
2011-09-28 22:00:00 +02:00
SCR_LoadCreditsFont ();
SCR_InstallParticlePalette ();
2012-12-23 21:00:00 +01:00
SCR_RegisterTextures ();
2010-10-01 22:00:00 +02:00
SCR_InitCinematic();
2010-11-22 22:00:00 +01:00
SCR_VidInit();
2010-07-08 22:00:00 +02:00
2010-12-21 22:00:00 +01:00
if( host.state != HOST_RESTART )
{
2011-03-08 22:00:00 +01:00
if( host.developer && Sys_CheckParm( "-toconsole" ))
2010-12-21 22:00:00 +01:00
Cbuf_AddText( "toggleconsole\n" );
else UI_SetActiveMenu( true );
}
2009-10-02 22:00:00 +02:00
scr_init = true;
2008-08-04 22:00:00 +02:00
}
void SCR_Shutdown( void )
{
2009-10-02 22:00:00 +02:00
if( !scr_init ) return;
2011-02-25 22:00:00 +01:00
MsgDev( D_NOTE, "SCR_Shutdown()\n" );
2009-10-02 22:00:00 +02:00
Cmd_RemoveCommand( "timerefresh" );
Cmd_RemoveCommand( "skyname" );
Cmd_RemoveCommand( "viewpos" );
2010-07-18 22:00:00 +02:00
UI_SetActiveMenu( false );
2010-12-21 22:00:00 +01:00
if( host.state != HOST_RESTART )
UI_UnloadProgs();
2009-10-02 22:00:00 +02:00
scr_init = false;
2007-11-06 22:00:00 +01:00
}