gl_screen.c
字号:
int x, y;
char st[80];
if (!cl_showfps->value)
return;
t = Sys_FloatTime ();
if ((t - lastframetime) >= 1.0) {
lastfps = fps_count;
fps_count = 0;
lastframetime = t;
}
sprintf(st, "%3d FPS", lastfps);
x = vid.width - strlen(st) * 16 - 16;
y = 0 ; //vid.height - (sb_lines * (vid.height/240) )- 16;
// Draw_TileClear(x, y, strlen(st)*16, 16);
Draw_String(x, y, st);
}
// 2001-11-31 FPS display by QuakeForge/Muff end
/*
==============
DrawPause
==============
*/
void SCR_DrawPause (void)
{
qpic_t *pic;
if (!scr_showpause->value) // turn off for screenshots
return;
if (!cl.paused)
return;
pic = Draw_CachePic ("gfx/pause.lmp");
Draw_Pic ( (vid.width - pic->width)/2,
(vid.height - 48 - pic->height)/2, pic);
}
/*
==============
SCR_DrawLoading
==============
*/
void SCR_DrawLoading (void)
{
qpic_t *pic;
if (!scr_drawloading)
return;
pic = Draw_CachePic ("gfx/loading.lmp");
Draw_Pic ( (vid.width - pic->width)/2,
(vid.height - 48 - pic->height)/2, pic);
}
//=============================================================================
/*
==================
SCR_SetUpToDrawConsole
==================
*/
void SCR_SetUpToDrawConsole (void)
{
Con_CheckResize ();
if (scr_drawloading)
return; // never a console with loading plaque
// decide on the height of the console
con_forcedup = !cl.worldmodel || cls.signon != SIGNONS;
if (con_forcedup)
{
scr_conlines = vid.height; // full screen
scr_con_current = scr_conlines;
}
else if (key_dest == key_console)
// 2000-01-12 Variable console height by Fett/Maddes start
{
// scr_conlines = vid.height/2; // half screen
scr_conlines = vid.height*scr_conheight->value; // in-game console
if (scr_conlines < (3*8+8+8)) // always leave three lines visible (plus command line and border)
{
scr_conlines = (3*8+8+8);
}
if (scr_conlines >= vid.height)
{
scr_conlines = vid.height - 1; // maximum is full screen
}
}
// 2000-01-12 Variable console height by Fett/Maddes end
else
scr_conlines = 0; // none visible
if (scr_conlines < scr_con_current)
{
// 2001-10-20 TIMESCALE extension by Tomaz/Maddes start
// scr_con_current -= scr_conspeed->value*host_frametime;
scr_con_current -= scr_conspeed->value*host_cpu_frametime;
// 2001-10-20 TIMESCALE extension by Tomaz/Maddes end
if (scr_conlines > scr_con_current)
scr_con_current = scr_conlines;
}
else if (scr_conlines > scr_con_current)
{
// 2001-10-20 TIMESCALE extension by Tomaz/Maddes start
// scr_con_current += scr_conspeed->value*host_frametime;
scr_con_current += scr_conspeed->value*host_cpu_frametime;
// 2001-10-20 TIMESCALE extension by Tomaz/Maddes end
if (scr_conlines < scr_con_current)
scr_con_current = scr_conlines;
}
if (clearconsole++ < vid.numpages)
{
Sbar_Changed ();
}
else if (clearnotify++ < vid.numpages)
{
}
else
con_notifylines = 0;
}
/*
==================
SCR_DrawConsole
==================
*/
void SCR_DrawConsole (void)
{
if (scr_con_current)
{
scr_copyeverything = 1;
Con_DrawConsole (scr_con_current, true);
clearconsole = 0;
}
else
{
if (key_dest == key_game || key_dest == key_message)
Con_DrawNotify (); // only draw notify in game
}
}
/*
==============================================================================
SCREEN SHOTS
==============================================================================
*/
typedef struct _TargaHeader {
unsigned char id_length, colormap_type, image_type;
unsigned short colormap_index, colormap_length;
unsigned char colormap_size;
unsigned short x_origin, y_origin, width, height;
unsigned char pixel_size, attributes;
} TargaHeader;
/*
==================
SCR_ScreenShot_f
==================
*/
void SCR_ScreenShot_f (void)
{
byte *buffer;
char pcxname[80];
char checkname[MAX_OSPATH];
int i, c, temp;
//
// find a file name to save it to
//
strcpy(pcxname,"quake00.tga");
for (i=0 ; i<=99 ; i++)
{
pcxname[5] = i/10 + '0';
pcxname[6] = i%10 + '0';
sprintf (checkname, "%s/%s", com_gamedir, pcxname);
if (Sys_FileTime(checkname) == -1)
break; // file doesn't exist
}
if (i==100)
{
Con_Printf ("SCR_ScreenShot_f: Couldn't create a PCX file\n");
return;
}
buffer = malloc(glwidth*glheight*3 + 18);
memset (buffer, 0, 18);
buffer[2] = 2; // uncompressed type
buffer[12] = glwidth&255;
buffer[13] = glwidth>>8;
buffer[14] = glheight&255;
buffer[15] = glheight>>8;
buffer[16] = 24; // pixel size
glReadPixels (glx, gly, glwidth, glheight, GL_RGB, GL_UNSIGNED_BYTE, buffer+18 );
// swap rgb to bgr
c = 18+glwidth*glheight*3;
for (i=18 ; i<c ; i+=3)
{
temp = buffer[i];
buffer[i] = buffer[i+2];
buffer[i+2] = temp;
}
COM_WriteFile (pcxname, buffer, glwidth*glheight*3 + 18 );
free (buffer);
Con_Printf ("Wrote %s\n", pcxname);
}
//=============================================================================
/*
===============
SCR_BeginLoadingPlaque
================
*/
void SCR_BeginLoadingPlaque (void)
{
S_StopAllSounds (true);
if (cls.state != ca_connected)
return;
if (cls.signon != SIGNONS)
return;
// redraw with no console and the loading plaque
Con_ClearNotify ();
scr_centertime_off = 0;
scr_con_current = 0;
scr_drawloading = true;
scr_fullupdate = 0;
Sbar_Changed ();
SCR_UpdateScreen ();
scr_drawloading = false;
scr_disabled_for_loading = true;
scr_disabled_time = realtime;
scr_fullupdate = 0;
}
/*
===============
SCR_EndLoadingPlaque
================
*/
void SCR_EndLoadingPlaque (void)
{
scr_disabled_for_loading = false;
scr_fullupdate = 0;
Con_ClearNotify ();
}
//=============================================================================
char *scr_notifystring;
qboolean scr_drawdialog;
void SCR_DrawNotifyString (void)
{
char *start;
int l;
int j;
int x, y;
start = scr_notifystring;
y = vid.height*0.35;
do
{
// scan the width of the line
for (l=0 ; l<40 ; l++)
if (start[l] == '\n' || !start[l])
break;
x = (vid.width - l*8)/2;
for (j=0 ; j<l ; j++, x+=8)
Draw_Character (x, y, start[j]);
y += 8;
while (*start && *start != '\n')
start++;
if (!*start)
break;
start++; // skip the \n
} while (1);
}
/*
==================
SCR_ModalMessage
Displays a text string in the center of the screen and waits for a Y or N
keypress.
==================
*/
int SCR_ModalMessage (char *text)
{
if (cls.state == ca_dedicated)
return true;
scr_notifystring = text;
// draw a fresh screen
scr_fullupdate = 0;
scr_drawdialog = true;
SCR_UpdateScreen ();
scr_drawdialog = false;
S_ClearBuffer (); // so dma doesn't loop current sound
do
{
key_count = -1; // wait for a key down and up
Sys_SendKeyEvents ();
} while (key_lastpress != 'y' && key_lastpress != 'n' && key_lastpress != K_ESCAPE);
scr_fullupdate = 0;
SCR_UpdateScreen ();
return key_lastpress == 'y';
}
//=============================================================================
/*
===============
SCR_BringDownConsole
Brings the console down and fades the palettes back to normal
================
*/
void SCR_BringDownConsole (void)
{
int i;
scr_centertime_off = 0;
for (i=0 ; i<20 && scr_conlines != scr_con_current ; i++)
SCR_UpdateScreen ();
cl.cshifts[0].percent = 0; // no area contents palette on next frame
VID_SetPalette (host_basepal);
}
void SCR_TileClear (void)
{
if (r_refdef.vrect.x > 0) {
// left
Draw_TileClear (0, 0, r_refdef.vrect.x, vid.height - sb_lines);
// right
Draw_TileClear (r_refdef.vrect.x + r_refdef.vrect.width, 0,
vid.width - r_refdef.vrect.x + r_refdef.vrect.width,
vid.height - sb_lines);
}
if (r_refdef.vrect.y > 0) {
// top
Draw_TileClear (r_refdef.vrect.x, 0,
r_refdef.vrect.x + r_refdef.vrect.width,
r_refdef.vrect.y);
// bottom
Draw_TileClear (r_refdef.vrect.x,
r_refdef.vrect.y + r_refdef.vrect.height,
r_refdef.vrect.width,
vid.height - sb_lines -
(r_refdef.vrect.height + r_refdef.vrect.y));
}
}
/*
==================
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 SCR_UpdateScreen (void)
{
// static float oldscr_viewsize; // 2001-12-10 Reduced compiler warnings by Jeff Ford
vrect_t vrect;
if (block_drawing)
return;
vid.numpages = 2 + gl_triplebuffer->value;
scr_copytop = 0;
scr_copyeverything = 0;
if (scr_disabled_for_loading)
{
if (realtime - scr_disabled_time > 60)
{
scr_disabled_for_loading = false;
Con_Printf ("load failed.\n");
}
else
return;
}
if (!scr_initialized || !con_initialized)
return; // not initialized yet
GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
//
// determine size of refresh window
//
if (oldfov != scr_fov->value)
{
oldfov = scr_fov->value;
vid.recalc_refdef = true;
}
if (oldscreensize != scr_viewsize->value)
{
oldscreensize = scr_viewsize->value;
vid.recalc_refdef = true;
}
if (vid.recalc_refdef)
SCR_CalcRefdef ();
//
// do 3D refresh drawing, and then update the screen
//
SCR_SetUpToDrawConsole ();
V_RenderView ();
GL_Set2D ();
//
// draw any areas not covered by the refresh
//
SCR_TileClear ();
if (scr_drawdialog)
{
Sbar_Draw ();
Draw_FadeScreen ();
SCR_DrawNotifyString ();
scr_copyeverything = true;
}
else if (scr_drawloading)
{
SCR_DrawLoading ();
Sbar_Draw ();
}
else if (cl.intermission == 1 && key_dest == key_game)
{
Sbar_IntermissionOverlay ();
}
else if (cl.intermission == 2 && key_dest == key_game)
{
Sbar_FinaleOverlay ();
SCR_CheckDrawCenterString ();
}
else
{
if (crosshair->value)
Draw_Character (scr_vrect.x + scr_vrect.width/2, scr_vrect.y + scr_vrect.height/2, '+');
SCR_DrawRam ();
SCR_DrawNet ();
SCR_DrawTurtle ();
SCR_DrawFPS (); // 2001-11-31 FPS display by QuakeForge/Muff
SCR_DrawPause ();
SCR_CheckDrawCenterString ();
Sbar_Draw ();
SCR_DrawConsole ();
M_Draw ();
}
V_UpdatePalette ();
GL_EndRendering ();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -