sw and gl rmisc are now client clean. the graphing functions ahve been pulled

out into r_graph.c (Time and Z graph), cl_ngraph.c (Net graph), and
{gl,sw}_graph.c (R_LineGraph). gl_ngraph.c is gone. Unfortunatly, something
is rather wrong with NetGraph in gl (probably R_LineGraph).
This commit is contained in:
Bill Currie 2001-05-22 06:00:38 +00:00
parent f732cd7932
commit 4a80639556
29 changed files with 812 additions and 718 deletions

View file

@ -189,6 +189,7 @@ extern qboolean r_force_fullscreen;
extern qboolean r_paused;
extern entity_t *r_view_model;
extern entity_t *r_player_entity;
extern int r_lineadj;
void *D_SurfaceCacheAddress (void);
int D_SurfaceCacheForRes (int width, int height);
@ -207,4 +208,6 @@ dlight_t *R_AllocDlight (int key);
void R_DecayLights (double frametime);
void R_ClearDlights (void);
void R_LineGraph (int x, int y, int *h_vals, int count);
#endif // __render_h

View file

@ -85,11 +85,13 @@ extern int glx, gly, glwidth, glheight;
#define BACKFACE_EPSILON 0.01
#define NUM_GRAPH_TEXTURES 8
extern qboolean envmap;
extern int currenttexture;
extern int cnttextures[2];
extern int particletexture;
extern int netgraphtexture;
extern int graph_texture[NUM_GRAPH_TEXTURES];
extern int netgraphtexture; // netgraph texture
extern int skytexturenum; // index in cl.loadmodel, not gl texture object
@ -234,4 +236,6 @@ void AddLightBlend (float, float, float, float);
extern int c_brush_polys, c_alias_polys;
extern float r_world_matrix[16];
int R_InitGraphTextures (int base);
#endif // __glquake_h

View file

@ -325,6 +325,7 @@ struct dlight_s;
void R_StoreEfrags (efrag_t **ppefrag);
void R_TimeRefresh_f (void);
void R_TimeGraph (void);
void R_ZGraph (void);
void R_PrintAliasStats (void);
void R_PrintTimes (void);
void R_PrintDSpeeds (void);

View file

@ -74,7 +74,7 @@ client_LIB_DEPS= libqfnet.a $(qf_client_LIBS)
client_SOURCES= cl_cam.c cl_cmd.c cl_demo.c cl_input.c cl_main.c cl_parse.c \
cl_tent.c \
console.c keys.c sbar.c r_cvar.c r_efrag.c r_ent.c r_main.c \
console.c keys.c sbar.c r_cvar.c r_efrag.c r_ent.c r_graph.c r_main.c \
r_part.c r_view.c nonintel.c locs.c pcx.c tga.c
server_SOURCES= host.c host_cmd.c pr_cmds.c sv_cvar.c sv_main.c \
@ -88,7 +88,8 @@ combined_SOURCES= $(common_SOURCES) $(client_SOURCES) $(server_SOURCES) \
# ... Common stuff
soft_SOURCES= d_edge.c d_fill.c d_init.c d_modech.c d_part.c d_polyse.c \
d_scan.c d_sky.c d_sprite.c d_surf.c d_vars.c d_zpoint.c \
draw.c screen.c sw_raclip.c sw_ralias.c sw_rbsp.c sw_rdraw.c \
draw.c screen.c sw_graph.c sw_raclip.c sw_ralias.c sw_rbsp.c \
sw_rdraw.c \
sw_redge.c sw_rlight.c sw_rmain.c sw_rmisc.c sw_rpart.c \
sw_rsky.c sw_rsprite.c sw_rsurf.c sw_skin.c sw_view.c \
$(soft_ASM)
@ -122,7 +123,7 @@ nq_x11_DEPENDENCIES=../../libs/models/libQFmodels_sw.la ../../libs/video/targets
# OpenGL-using targets
# ... Common stuff
ogl_SOURCES= noisetextures.c gl_textures.c gl_draw.c gl_dyn_fires.c \
gl_dyn_part.c gl_dyn_textures.c gl_ngraph.c gl_rlight.c \
gl_dyn_part.c gl_dyn_textures.c gl_graph.c gl_rlight.c \
gl_rmain.c gl_rmisc.c gl_rsurf.c gl_screen.c gl_skin.c \
gl_sky.c gl_sky_clip.c gl_view.c gl_warp.c

145
nq/source/gl_graph.c Normal file
View file

@ -0,0 +1,145 @@
/*
gl_ngraph.c
(description)
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
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include "QF/cvar.h"
#include "QF/draw.h"
#include "QF/sys.h"
#include "glquake.h"
#include "r_cvar.h"
extern byte *draw_chars; // 8*8 graphic characters
extern qboolean lighthalf;
extern cvar_t *r_netgraph;
extern cvar_t *r_netgraph_alpha;
extern cvar_t *r_netgraph_box;
static int graph_index;
static int graph_size[NUM_GRAPH_TEXTURES];
static int graph_width[NUM_GRAPH_TEXTURES];
static byte *graph_texels[NUM_GRAPH_TEXTURES];
int graph_texture[NUM_GRAPH_TEXTURES];
int
R_InitGraphTextures (int base)
{
int i;
for (i = 0; i < NUM_GRAPH_TEXTURES; i++)
graph_texture[i] = base++;
return base;
}
void
R_LineGraph (int x, int y, int *h_vals, int count)
{
int i, j;
int h;
int s;
byte color;
int size;
byte *dest;
if (!count)
return;
s = r_graphheight->int_val;
size = 2 * count;
if (size > graph_size[graph_index]) {
graph_size[graph_index] = size;
graph_texels[graph_index] = realloc (graph_texels[graph_index], size);
}
graph_width[graph_index] = count;
if (!graph_texels[graph_index])
Sys_Error ("R_LineGraph: failed to allocate texture buffer\n");
i = 0;
while (count--) {
dest = graph_texels[graph_index] + i++;
h = *h_vals++;
if (h == 10000)
color = 0x6f; // yellow
else if (h == 9999)
color = 0x4f; // red
else if (h == 9998)
color = 0xd0; // blue
else
color = 0xfe; // white
if (h > s)
h = s;
for (j = 0; j < h; j++, dest += graph_width[graph_index])
dest[0] = color;
for (; j < s; j++, dest += graph_width[graph_index])
dest[0] = 0xff;
}
glBindTexture (GL_TEXTURE_2D, graph_texture[graph_index]);
glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format,
graph_width[graph_index], s, 0, GL_RGBA,
GL_UNSIGNED_BYTE, graph_texels[graph_index]);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBegin (GL_QUADS);
glTexCoord2f (0, 0);
glVertex2f (x, y);
glTexCoord2f (1, 0);
glVertex2f (x + graph_width[graph_index], y);
glTexCoord2f (1, 1);
glVertex2f (x + graph_width[graph_index], y - s);
glTexCoord2f (0, 1);
glVertex2f (x, y - s);
glEnd ();
glColor3ubv (lighthalf_v);
graph_index = (graph_index + 1) % NUM_GRAPH_TEXTURES;
}

View file

@ -1,186 +0,0 @@
/*
gl_ngraph.c
(description)
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
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdio.h>
#include "QF/compat.h"
#include "QF/cvar.h"
#include "QF/draw.h"
#include "QF/vid.h"
#include "client.h"
#include "glquake.h"
#include "sbar.h"
extern byte *draw_chars; // 8*8 graphic characters
extern qboolean lighthalf;
extern cvar_t *r_netgraph;
extern cvar_t *r_netgraph_alpha;
extern cvar_t *r_netgraph_box;
int netgraphtexture; // netgraph texture
#define NET_GRAPHHEIGHT 32
//XXXstatic byte ngraph_texels[NET_GRAPHHEIGHT][NET_TIMINGS];
void
R_LineGraph (int x, int h)
{
#if 0
int i;
int s;
int color;
s = NET_GRAPHHEIGHT;
if (h == 10000)
color = 0x6f; // yellow
else if (h == 9999)
color = 0x4f; // red
else if (h == 9998)
color = 0xd0; // blue
else
color = 0xfe; // white
if (h > s)
h = s;
for (i = 0; i < h; i++)
if (i & 1)
ngraph_texels[NET_GRAPHHEIGHT - i - 1][x] = 0xff;
else
ngraph_texels[NET_GRAPHHEIGHT - i - 1][x] = (byte) color;
for (; i < s; i++)
ngraph_texels[NET_GRAPHHEIGHT - i - 1][x] = (byte) 0xff;
#endif
}
void
Draw_CharToNetGraph (int x, int y, int num)
{
#if 0
int row, col;
byte *source;
int drawline;
int nx;
row = num >> 4;
col = num & 15;
source = draw_chars + (row << 10) + (col << 3);
for (drawline = 8; drawline; drawline--, y++) {
for (nx = 0; nx < 8; nx++)
if (source[nx] != 255)
ngraph_texels[y][nx + x] = 0x60 + source[nx];
source += 128;
}
#endif
}
void
R_NetGraph (void)
{
#if 0
int a, x, i, y;
int lost;
char st[80];
unsigned int ngraph_pixels[NET_GRAPHHEIGHT][NET_TIMINGS];
x = 0;
lost = CL_CalcNet ();
for (a = 0; a < NET_TIMINGS; a++) {
i = (cls.netchan.outgoing_sequence - a) & NET_TIMINGSMASK;
R_LineGraph (NET_TIMINGS - 1 - a, packet_latency[i]);
}
// now load the netgraph texture into gl and draw it
for (y = 0; y < NET_GRAPHHEIGHT; y++)
for (x = 0; x < NET_TIMINGS; x++)
ngraph_pixels[y][x] = d_8to24table[ngraph_texels[y][x]];
x = cl_hudswap->int_val ? vid.width - (NET_TIMINGS + 16): 0 ;
y = vid.height - sb_lines - 24 - NET_GRAPHHEIGHT - 1;
if (r_netgraph_alpha->value < 0.995) // roundoff
glColor4f (1, 1, 1, r_netgraph_alpha->value);
if (r_netgraph_box->int_val)
Draw_TextBox (x, y, NET_TIMINGS / 8, NET_GRAPHHEIGHT / 8 + 1);
y += 8;
snprintf (st, sizeof (st), "%3i%% packet loss", lost);
if (cl_hudswap->int_val) {
Draw_String8 (vid.width - ((strlen (st) * 8) + 8), y, st);
} else {
Draw_String8 (8, y, st);
}
x = cl_hudswap->int_val ? vid.width - (NET_TIMINGS + 8) : 8;
y += 8;
glBindTexture (GL_TEXTURE_2D, netgraphtexture);
glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format,
NET_TIMINGS, NET_GRAPHHEIGHT, 0, GL_RGBA,
GL_UNSIGNED_BYTE, ngraph_pixels);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBegin (GL_QUADS);
glTexCoord2f (0, 0);
glVertex2f (x, y);
glTexCoord2f (1, 0);
glVertex2f (x + NET_TIMINGS, y);
glTexCoord2f (1, 1);
glVertex2f (x + NET_TIMINGS, y + NET_GRAPHHEIGHT);
glTexCoord2f (0, 1);
glVertex2f (x, y + NET_GRAPHHEIGHT);
glEnd ();
glColor3ubv (lighthalf_v);
#endif
}

View file

@ -1053,6 +1053,9 @@ R_Clear (void)
void
R_RenderScene (void)
{
if (r_timegraph->int_val || r_speeds->int_val || r_dspeeds->int_val)
r_time1 = Sys_DoubleTime ();
R_SetupFrame ();
R_SetFrustum ();
@ -1070,6 +1073,12 @@ R_RenderScene (void)
R_DrawEntitiesOnList ();
R_RenderDlights ();
if (r_timegraph->int_val)
R_TimeGraph ();
if (r_zgraph->int_val)
R_ZGraph ();
}

View file

@ -41,16 +41,16 @@
#include "QF/cmd.h"
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/quakefs.h"
#include "QF/render.h"
#include "QF/skin.h"
#include "QF/sys.h"
#include "QF/vid.h"
#include "QF/varrays.h"
#include "client.h"
#include "glquake.h"
#include "r_dynamic.h"
#include "r_local.h"
#include "QF/render.h"
varray_t2f_c4f_v3f_t varray[MAX_VARRAY_VERTS];
@ -155,8 +155,7 @@ R_Init (void)
GDT_Init ();
netgraphtexture = texture_extension_number;
texture_extension_number++;
texture_extension_number = R_InitGraphTextures (texture_extension_number);
texture_extension_number = Skin_Init_Textures (texture_extension_number);

View file

@ -941,8 +941,8 @@ SCR_UpdateScreen (double realtime)
// draw any areas not covered by the refresh
SCR_TileClear ();
if (r_netgraph->int_val)
R_NetGraph ();
//if (r_netgraph->int_val)
// CL_NetGraph ();
if (cl.intermission == 1 && key_dest == key_game) {
Sbar_IntermissionOverlay ();

110
nq/source/r_graph.c Normal file
View file

@ -0,0 +1,110 @@
/*
r_graph.c
rednerer diagnostic graphs
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
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/draw.h"
#include "QF/render.h"
#include "QF/sys.h"
#include "r_local.h"
#include "sbar.h"
#define MAX_TIMINGS 100
extern float mouse_x, mouse_y;
int graphval;
/*
R_TimeGraph
Performance monitoring tool
*/
void
R_TimeGraph (void)
{
static int timex;
int a;
int l;
float r_time2;
static int r_timings[MAX_TIMINGS];
int x;
r_time2 = Sys_DoubleTime ();
a = (r_time2 - r_time1) / 0.01;
// a = fabs(mouse_y * 0.05);
// a = (int)((r_refdef.vieworg[2] + 1024)/1)%(int)r_graphheight->value;
// a = (int)((pmove.velocity[2] + 500)/10);
// a = fabs(velocity[0])/20;
// a = ((int)fabs(origin[0])/8)%20;
// a = (cl.idealpitch + 30)/5;
// a = (int)(cl.simangles[YAW] * 64/360) & 63;
a = graphval;
r_timings[timex] = a;
a = timex;
l = MAX_TIMINGS;
if (l > r_refdef.vrect.width)
l = r_refdef.vrect.width;
x = r_refdef.vrect.width - l;
a = timex - l;
if (a < 0) {
R_LineGraph (x, r_refdef.vrect.height - 2, &r_timings[a + MAX_TIMINGS], -a);
x -= a;
l += a;
a = 0;
}
R_LineGraph (x, r_refdef.vrect.height - 2, &r_timings[a], l);
timex = (timex + 1) % MAX_TIMINGS;
}
void
R_ZGraph (void)
{
int a, x, w, i;
static int height[256];
if (r_refdef.vrect.width <= 256)
w = r_refdef.vrect.width;
else
w = 256;
height[r_framecount & 255] = ((int) r_origin[2]) & 31;
x = 0;
for (a = 0; a < w; a++) {
i = (r_framecount - a) & 255;
}
R_LineGraph (x, r_refdef.vrect.height - 2, height, w);
}

View file

@ -11,6 +11,8 @@ dlight_t r_dlights[MAX_DLIGHTS];
entity_t *r_view_model;
entity_t *r_player_entity;
lightstyle_t r_lightstyle[MAX_LIGHTSTYLES];
int r_lineadj;
float r_time1;
dlight_t *

View file

@ -717,6 +717,7 @@ SCR_DrawStringToSnap (const char *s, byte * buf, int x, int y, int width)
}
}
void
SCR_RSShot_f (void)
{
@ -802,7 +803,7 @@ SCR_RSShot_f (void)
st[sizeof (st) - 1] = 0;
SCR_DrawStringToSnap (st, newbuf, w - strlen (st) * 8, 10, w);
strncpy (st, name->string, sizeof (st));
strncpy (st, cl_name->string, sizeof (st));
st[sizeof (st) - 1] = 0;
SCR_DrawStringToSnap (st, newbuf, w - strlen (st) * 8, 20, w);
@ -821,6 +822,7 @@ SCR_RSShot_f (void)
#endif
}
//=============================================================================
@ -965,6 +967,10 @@ SCR_UpdateScreen (double realtime)
SCR_DrawRam ();
SCR_DrawNet ();
//if (r_netgraph->int_val)
// CL_NetGraph ();
SCR_DrawFPS ();
SCR_DrawTime ();
SCR_DrawTurtle ();

77
nq/source/sw_graph.c Normal file
View file

@ -0,0 +1,77 @@
/*
r_misc.c
(description)
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
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/draw.h"
#include "QF/render.h"
#include "r_local.h"
#include "r_cvar.h"
/*
R_LineGraph
Only called by R_DisplayTime
*/
void
R_LineGraph (int x, int y, int *h_vals, int count)
{
int i;
byte *dest;
int s;
int color;
int h;
// FIXME: should be disabled on no-buffer adapters, or should be in the driver
s = r_graphheight->int_val;
while (count--) {
dest = vid.buffer + vid.rowbytes * y + x++;
h = *h_vals++;
if (h == 10000)
color = 0x6f; // yellow
else if (h == 9999)
color = 0x4f; // red
else if (h == 9998)
color = 0xd0; // blue
else
color = 0xff; // pink
if (h > s)
h = s;
for (i = 0; i < h; i++, dest -= vid.rowbytes) {
dest[0] = color;
}
}
}

View file

@ -56,7 +56,6 @@
void *colormap;
vec3_t viewlightvec;
alight_t r_viewlighting = { 128, 192, viewlightvec };
float r_time1;
int r_numallocatededges;
qboolean r_drawpolys;
qboolean r_drawculledpolys;
@ -137,7 +136,6 @@ void R_MarkLeaves (void);
extern cvar_t *scr_fov;
void R_NetGraph (void);
void R_ZGraph (void);
@ -909,9 +907,6 @@ R_RenderView_ (void)
if (r_timegraph->int_val)
R_TimeGraph ();
if (r_netgraph->int_val)
R_NetGraph ();
if (r_zgraph->int_val)
R_ZGraph ();

View file

@ -34,14 +34,12 @@
#include "QF/console.h"
#include "QF/cmd.h"
#include "QF/draw.h"
#include "QF/render.h"
#include "QF/sys.h"
#include "host.h"
#include "r_local.h"
#include "QF/render.h"
#include "sbar.h"
#include "server.h"
#include "view.h"
void
R_CheckVariables (void)
@ -119,161 +117,6 @@ R_LoadSky_f (void)
}
/*
R_LineGraph
Only called by R_DisplayTime
*/
void
R_LineGraph (int x, int y, int h)
{
int i;
byte *dest;
int s;
int color;
// FIXME: should be disabled on no-buffer adapters, or should be in the driver
// x += r_refdef.vrect.x;
// y += r_refdef.vrect.y;
dest = vid.buffer + vid.rowbytes * y + x;
s = r_graphheight->int_val;
if (h == 10000)
color = 0x6f; // yellow
else if (h == 9999)
color = 0x4f; // red
else if (h == 9998)
color = 0xd0; // blue
else
color = 0xff; // pink
if (h > s)
h = s;
for (i = 0; i < h; i++, dest -= vid.rowbytes) {
dest[0] = color;
// *(dest-vid.rowbytes) = 0x30;
}
#if 0
for (; i < s; i++, dest -= vid.rowbytes * 2) {
dest[0] = 0x30;
*(dest - vid.rowbytes) = 0x30;
}
#endif
}
#define MAX_TIMINGS 100
extern float mouse_x, mouse_y;
int graphval;
/*
R_TimeGraph
Performance monitoring tool
*/
void
R_TimeGraph (void)
{
static int timex;
int a;
float r_time2;
static byte r_timings[MAX_TIMINGS];
int x;
r_time2 = Sys_DoubleTime ();
a = (r_time2 - r_time1) / 0.01;
// a = fabs(mouse_y * 0.05);
// a = (int)((r_refdef.vieworg[2] + 1024)/1)%(int)r_graphheight->value;
// a = (int)((pmove.velocity[2] + 500)/10);
// a = fabs(velocity[0])/20;
// a = ((int)fabs(origin[0])/8)%20;
// a = (cl.idealpitch + 30)/5;
// a = (int)(cl.simangles[YAW] * 64/360) & 63;
a = graphval;
r_timings[timex] = a;
a = timex;
if (r_refdef.vrect.width <= MAX_TIMINGS)
x = r_refdef.vrect.width - 1;
else
x = r_refdef.vrect.width - (r_refdef.vrect.width - MAX_TIMINGS) / 2;
do {
R_LineGraph (x, r_refdef.vrect.height - 2, r_timings[a]);
if (x == 0)
break; // screen too small to hold entire thing
x--;
a--;
if (a == -1)
a = MAX_TIMINGS - 1;
} while (a != timex);
timex = (timex + 1) % MAX_TIMINGS;
}
void
R_NetGraph (void)
{
#if 0
int a, x, y, h, i;
int lost;
char st[80];
x = cl_hudswap->int_val ? vid.width - (NET_TIMINGS + 16): 0;
y = vid.height - sb_lines - 24 - r_graphheight->int_val - 1;
h = r_graphheight->int_val % 8;
Draw_TextBox (x, y, NET_TIMINGS / 8, r_graphheight->int_val / 8 + 1);
lost = CL_CalcNet ();
x = cl_hudswap->int_val ? vid.width - (NET_TIMINGS + 8) : 8;
y = vid.height - sb_lines - 9;
y -= h;
for (a = 0; a < NET_TIMINGS; a++) {
i = (cls.netchan.outgoing_sequence - a) & NET_TIMINGSMASK;
R_LineGraph (x + NET_TIMINGS - 1 - a, y, packet_latency[i]);
}
y -= vid.height - sb_lines - 24 - r_graphheight->int_val + 7;
snprintf (st, sizeof (st), "%3i%% packet loss", lost);
if (cl_hudswap->int_val) {
Draw_String8 (vid.width - ((strlen (st) * 8) + 8), y, st);
} else {
Draw_String8 (8, y, st);
}
#endif
}
void
R_ZGraph (void)
{
int a, x, w, i;
static int height[256];
if (r_refdef.vrect.width <= 256)
w = r_refdef.vrect.width;
else
w = 256;
height[r_framecount & 255] = ((int) r_origin[2]) & 31;
x = 0;
for (a = 0; a < w; a++) {
i = (r_framecount - a) & 255;
R_LineGraph (x + w - 1 - a, r_refdef.vrect.height - 2, height[i]);
}
}
void
R_PrintTimes (void)
{
@ -484,7 +327,7 @@ R_SetupFrame (void)
vrect.width = vid.width;
vrect.height = vid.height;
R_ViewChanged (&vrect, cl_sbar->int_val ? sb_lines : 0, vid.aspect);
R_ViewChanged (&vrect, r_lineadj, vid.aspect);
} else {
w = vid.width;
h = vid.height;
@ -505,7 +348,7 @@ R_SetupFrame (void)
vrect.height = (int) h;
R_ViewChanged (&vrect,
(int) ((float) (cl_sbar->int_val ? sb_lines : 0) *
(int) ((float) r_lineadj *
(h / (float) vid.height)),
vid.aspect * (h / w) * ((float) vid.width /
(float) vid.height));
@ -516,7 +359,7 @@ R_SetupFrame (void)
vrect.width = vid.width;
vrect.height = vid.height;
R_ViewChanged (&vrect, cl_sbar->int_val ? sb_lines : 0, vid.aspect);
R_ViewChanged (&vrect, r_lineadj, vid.aspect);
}
r_viewchanged = false;

View file

@ -318,4 +318,6 @@ extern double realtime;
void Cvar_Info (struct cvar_s *var);
void CL_NetGraph (void);
#endif // _CLIENT_H

View file

@ -95,10 +95,10 @@ client_LIB_DEPS= libqfnet.a $(qf_client_LIBS)
# libQFjs is seperate because it needs to be linked after when building statically
client_SOURCES= cl_cam.c cl_cmd.c cl_cvar.c cl_demo.c cl_ents.c cl_input.c \
cl_main.c cl_misc.c cl_parse.c cl_pred.c cl_skin.c cl_slist.c \
cl_tent.c \
cl_main.c cl_misc.c cl_ngraph.c cl_parse.c cl_pred.c cl_skin.c \
cl_slist.c cl_tent.c \
console.c keys.c locs.c nonintel.c pcx.c r_cvar.c r_efrag.c \
r_ent.c r_main.c r_view.c sbar.c skin.c teamplay.c tga.c \
r_ent.c r_graph.c r_main.c r_view.c sbar.c skin.c teamplay.c tga.c \
wad.c cl_math.S $(syscl_SRC)
# Software-rendering clients
@ -107,7 +107,7 @@ client_SOURCES= cl_cam.c cl_cmd.c cl_cvar.c cl_demo.c cl_ents.c cl_input.c \
soft_SOURCES= d_edge.c d_fill.c d_init.c d_modech.c \
d_part.c d_polyse.c d_scan.c d_sky.c d_sprite.c d_surf.c \
d_vars.c d_zpoint.c draw.c sw_raclip.c sw_ralias.c sw_rbsp.c \
d_vars.c d_zpoint.c draw.c sw_graph.c sw_raclip.c sw_ralias.c sw_rbsp.c \
sw_rdraw.c sw_redge.c sw_rlight.c sw_rmain.c sw_rmisc.c \
sw_rpart.c sw_rsky.c sw_rsprite.c sw_rsurf.c sw_skin.c \
sw_view.c screen.c \
@ -146,7 +146,7 @@ qw_client_x11_DEPENDENCIES=../../libs/models/libQFmodels_sw.la ../../libs/video/
#
# ... Common stuff
ogl_SOURCES= noisetextures.c gl_textures.c gl_draw.c gl_dyn_fires.c \
gl_dyn_part.c gl_dyn_textures.c gl_ngraph.c gl_rlight.c \
gl_dyn_part.c gl_dyn_textures.c gl_graph.c gl_rlight.c \
gl_rmain.c gl_rmisc.c gl_rsurf.c gl_screen.c gl_skin.c \
gl_sky.c gl_sky_clip.c gl_view.c gl_warp.c

78
qw/source/cl_ngraph.c Normal file
View file

@ -0,0 +1,78 @@
/*
cl_ngraph.c
client network diagnostic graph
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
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/draw.h"
#include "QF/render.h"
#include "cl_parse.h"
#include "client.h"
#include "sbar.h"
void
CL_NetGraph (void)
{
int a, l, x, y, h, i;
int lost;
char st[80];
x = cl_hudswap->int_val ? vid.width - (NET_TIMINGS + 16): 0;
y = vid.height - sb_lines - 24 - r_graphheight->int_val - 1;
h = r_graphheight->int_val % 8;
Draw_TextBox (x, y, NET_TIMINGS / 8, r_graphheight->int_val / 8 + 1);
lost = CL_CalcNet ();
x = cl_hudswap->int_val ? vid.width - (NET_TIMINGS + 8) : 8;
y = vid.height - sb_lines - 9;
l = NET_TIMINGS;
if (l > r_refdef.vrect.width - 8)
l = r_refdef.vrect.width - 8;
i = (cls.netchan.outgoing_sequence - a) & NET_TIMINGSMASK;
a = i - l;
if (a < 0) {
R_LineGraph (x, y, &packet_latency[a + NET_TIMINGS], -a);
x -= a;
l += a;
a = 0;
}
R_LineGraph (x, y, &packet_latency[a], l);
y = vid.height - sb_lines - 24 - r_graphheight->int_val + 7;
snprintf (st, sizeof (st), "%3i%% packet loss", lost);
if (cl_hudswap->int_val) {
Draw_String8 (vid.width - ((strlen (st) * 8) + 8), y, st);
} else {
Draw_String8 (8, y, st);
}
}

145
qw/source/gl_graph.c Normal file
View file

@ -0,0 +1,145 @@
/*
gl_ngraph.c
(description)
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
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include "QF/cvar.h"
#include "QF/draw.h"
#include "QF/sys.h"
#include "glquake.h"
#include "r_cvar.h"
extern byte *draw_chars; // 8*8 graphic characters
extern qboolean lighthalf;
extern cvar_t *r_netgraph;
extern cvar_t *r_netgraph_alpha;
extern cvar_t *r_netgraph_box;
static int graph_index;
static int graph_size[NUM_GRAPH_TEXTURES];
static int graph_width[NUM_GRAPH_TEXTURES];
static byte *graph_texels[NUM_GRAPH_TEXTURES];
int graph_texture[NUM_GRAPH_TEXTURES];
int
R_InitGraphTextures (int base)
{
int i;
for (i = 0; i < NUM_GRAPH_TEXTURES; i++)
graph_texture[i] = base++;
return base;
}
void
R_LineGraph (int x, int y, int *h_vals, int count)
{
int i, j;
int h;
int s;
byte color;
int size;
byte *dest;
if (!count)
return;
s = r_graphheight->int_val;
size = 2 * count;
if (size > graph_size[graph_index]) {
graph_size[graph_index] = size;
graph_texels[graph_index] = realloc (graph_texels[graph_index], size);
}
graph_width[graph_index] = count;
if (!graph_texels[graph_index])
Sys_Error ("R_LineGraph: failed to allocate texture buffer\n");
i = 0;
while (count--) {
dest = graph_texels[graph_index] + i++;
h = *h_vals++;
if (h == 10000)
color = 0x6f; // yellow
else if (h == 9999)
color = 0x4f; // red
else if (h == 9998)
color = 0xd0; // blue
else
color = 0xfe; // white
if (h > s)
h = s;
for (j = 0; j < h; j++, dest += graph_width[graph_index])
dest[0] = color;
for (; j < s; j++, dest += graph_width[graph_index])
dest[0] = 0xff;
}
glBindTexture (GL_TEXTURE_2D, graph_texture[graph_index]);
glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format,
graph_width[graph_index], s, 0, GL_RGBA,
GL_UNSIGNED_BYTE, graph_texels[graph_index]);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBegin (GL_QUADS);
glTexCoord2f (0, 0);
glVertex2f (x, y);
glTexCoord2f (1, 0);
glVertex2f (x + graph_width[graph_index], y);
glTexCoord2f (1, 1);
glVertex2f (x + graph_width[graph_index], y - s);
glTexCoord2f (0, 1);
glVertex2f (x, y - s);
glEnd ();
glColor3ubv (lighthalf_v);
graph_index = (graph_index + 1) % NUM_GRAPH_TEXTURES;
}

View file

@ -1,181 +0,0 @@
/*
gl_ngraph.c
(description)
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
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdio.h>
#include "QF/compat.h"
#include "QF/cvar.h"
#include "QF/draw.h"
#include "QF/vid.h"
#include "cl_parse.h"
#include "client.h"
#include "glquake.h"
#include "sbar.h"
extern byte *draw_chars; // 8*8 graphic characters
extern qboolean lighthalf;
extern cvar_t *r_netgraph;
extern cvar_t *r_netgraph_alpha;
extern cvar_t *r_netgraph_box;
int netgraphtexture; // netgraph texture
#define NET_GRAPHHEIGHT 32
static byte ngraph_texels[NET_GRAPHHEIGHT][NET_TIMINGS];
void
R_LineGraph (int x, int h)
{
int i;
int s;
int color;
s = NET_GRAPHHEIGHT;
if (h == 10000)
color = 0x6f; // yellow
else if (h == 9999)
color = 0x4f; // red
else if (h == 9998)
color = 0xd0; // blue
else
color = 0xfe; // white
if (h > s)
h = s;
for (i = 0; i < h; i++)
if (i & 1)
ngraph_texels[NET_GRAPHHEIGHT - i - 1][x] = 0xff;
else
ngraph_texels[NET_GRAPHHEIGHT - i - 1][x] = (byte) color;
for (; i < s; i++)
ngraph_texels[NET_GRAPHHEIGHT - i - 1][x] = (byte) 0xff;
}
void
Draw_CharToNetGraph (int x, int y, int num)
{
int row, col;
byte *source;
int drawline;
int nx;
row = num >> 4;
col = num & 15;
source = draw_chars + (row << 10) + (col << 3);
for (drawline = 8; drawline; drawline--, y++) {
for (nx = 0; nx < 8; nx++)
if (source[nx] != 255)
ngraph_texels[y][nx + x] = 0x60 + source[nx];
source += 128;
}
}
void
R_NetGraph (void)
{
int a, x, i, y;
int lost;
char st[80];
unsigned int ngraph_pixels[NET_GRAPHHEIGHT][NET_TIMINGS];
x = 0;
lost = CL_CalcNet ();
for (a = 0; a < NET_TIMINGS; a++) {
i = (cls.netchan.outgoing_sequence - a) & NET_TIMINGSMASK;
R_LineGraph (NET_TIMINGS - 1 - a, packet_latency[i]);
}
// now load the netgraph texture into gl and draw it
for (y = 0; y < NET_GRAPHHEIGHT; y++)
for (x = 0; x < NET_TIMINGS; x++)
ngraph_pixels[y][x] = d_8to24table[ngraph_texels[y][x]];
x = cl_hudswap->int_val ? vid.width - (NET_TIMINGS + 16): 0 ;
y = vid.height - sb_lines - 24 - NET_GRAPHHEIGHT - 1;
if (r_netgraph_alpha->value < 0.995) // roundoff
glColor4f (1, 1, 1, r_netgraph_alpha->value);
if (r_netgraph_box->int_val)
Draw_TextBox (x, y, NET_TIMINGS / 8, NET_GRAPHHEIGHT / 8 + 1);
y += 8;
snprintf (st, sizeof (st), "%3i%% packet loss", lost);
if (cl_hudswap->int_val) {
Draw_String8 (vid.width - ((strlen (st) * 8) + 8), y, st);
} else {
Draw_String8 (8, y, st);
}
x = cl_hudswap->int_val ? vid.width - (NET_TIMINGS + 8) : 8;
y += 8;
glBindTexture (GL_TEXTURE_2D, netgraphtexture);
glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format,
NET_TIMINGS, NET_GRAPHHEIGHT, 0, GL_RGBA,
GL_UNSIGNED_BYTE, ngraph_pixels);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBegin (GL_QUADS);
glTexCoord2f (0, 0);
glVertex2f (x, y);
glTexCoord2f (1, 0);
glVertex2f (x + NET_TIMINGS, y);
glTexCoord2f (1, 1);
glVertex2f (x + NET_TIMINGS, y + NET_GRAPHHEIGHT);
glTexCoord2f (0, 1);
glVertex2f (x, y + NET_GRAPHHEIGHT);
glEnd ();
glColor3ubv (lighthalf_v);
}

View file

@ -1053,6 +1053,9 @@ R_Clear (void)
void
R_RenderScene (void)
{
if (r_timegraph->int_val || r_speeds->int_val || r_dspeeds->int_val)
r_time1 = Sys_DoubleTime ();
R_SetupFrame ();
R_SetFrustum ();
@ -1070,6 +1073,12 @@ R_RenderScene (void)
R_DrawEntitiesOnList ();
R_RenderDlights ();
if (r_timegraph->int_val)
R_TimeGraph ();
if (r_zgraph->int_val)
R_ZGraph ();
}

View file

@ -41,16 +41,16 @@
#include "QF/cmd.h"
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/quakefs.h"
#include "QF/render.h"
#include "QF/skin.h"
#include "QF/sys.h"
#include "QF/vid.h"
#include "QF/varrays.h"
#include "client.h"
#include "glquake.h"
#include "r_dynamic.h"
#include "r_local.h"
#include "QF/render.h"
varray_t2f_c4f_v3f_t varray[MAX_VARRAY_VERTS];
@ -155,8 +155,7 @@ R_Init (void)
GDT_Init ();
netgraphtexture = texture_extension_number;
texture_extension_number++;
texture_extension_number = R_InitGraphTextures (texture_extension_number);
texture_extension_number = Skin_Init_Textures (texture_extension_number);

View file

@ -940,7 +940,7 @@ SCR_UpdateScreen (double realtime)
SCR_TileClear ();
if (r_netgraph->int_val)
R_NetGraph ();
CL_NetGraph ();
if (cl.intermission == 1 && key_dest == key_game) {
Sbar_IntermissionOverlay ();

110
qw/source/r_graph.c Normal file
View file

@ -0,0 +1,110 @@
/*
r_graph.c
rednerer diagnostic graphs
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
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/draw.h"
#include "QF/render.h"
#include "QF/sys.h"
#include "r_local.h"
#include "sbar.h"
#define MAX_TIMINGS 100
extern float mouse_x, mouse_y;
int graphval;
/*
R_TimeGraph
Performance monitoring tool
*/
void
R_TimeGraph (void)
{
static int timex;
int a;
int l;
float r_time2;
static int r_timings[MAX_TIMINGS];
int x;
r_time2 = Sys_DoubleTime ();
a = (r_time2 - r_time1) / 0.01;
// a = fabs(mouse_y * 0.05);
// a = (int)((r_refdef.vieworg[2] + 1024)/1)%(int)r_graphheight->value;
// a = (int)((pmove.velocity[2] + 500)/10);
// a = fabs(velocity[0])/20;
// a = ((int)fabs(origin[0])/8)%20;
// a = (cl.idealpitch + 30)/5;
// a = (int)(cl.simangles[YAW] * 64/360) & 63;
a = graphval;
r_timings[timex] = a;
a = timex;
l = MAX_TIMINGS;
if (l > r_refdef.vrect.width)
l = r_refdef.vrect.width;
x = r_refdef.vrect.width - l;
a = timex - l;
if (a < 0) {
R_LineGraph (x, r_refdef.vrect.height - 2, &r_timings[a + MAX_TIMINGS], -a);
x -= a;
l += a;
a = 0;
}
R_LineGraph (x, r_refdef.vrect.height - 2, &r_timings[a], l);
timex = (timex + 1) % MAX_TIMINGS;
}
void
R_ZGraph (void)
{
int a, x, w, i;
static int height[256];
if (r_refdef.vrect.width <= 256)
w = r_refdef.vrect.width;
else
w = 256;
height[r_framecount & 255] = ((int) r_origin[2]) & 31;
x = 0;
for (a = 0; a < w; a++) {
i = (r_framecount - a) & 255;
}
R_LineGraph (x, r_refdef.vrect.height - 2, height, w);
}

View file

@ -11,6 +11,8 @@ dlight_t r_dlights[MAX_DLIGHTS];
entity_t *r_view_model;
entity_t *r_player_entity;
lightstyle_t r_lightstyle[MAX_LIGHTSTYLES];
int r_lineadj;
float r_time1;
dlight_t *

View file

@ -965,6 +965,10 @@ SCR_UpdateScreen (double realtime)
SCR_DrawRam ();
SCR_DrawNet ();
if (r_netgraph->int_val)
CL_NetGraph ();
SCR_DrawFPS ();
SCR_DrawTime ();
SCR_DrawTurtle ();

77
qw/source/sw_graph.c Normal file
View file

@ -0,0 +1,77 @@
/*
r_misc.c
(description)
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
$Id$
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/draw.h"
#include "QF/render.h"
#include "r_local.h"
#include "r_cvar.h"
/*
R_LineGraph
Only called by R_DisplayTime
*/
void
R_LineGraph (int x, int y, int *h_vals, int count)
{
int i;
byte *dest;
int s;
int color;
int h;
// FIXME: should be disabled on no-buffer adapters, or should be in the driver
s = r_graphheight->int_val;
while (count--) {
dest = vid.buffer + vid.rowbytes * y + x++;
h = *h_vals++;
if (h == 10000)
color = 0x6f; // yellow
else if (h == 9999)
color = 0x4f; // red
else if (h == 9998)
color = 0xd0; // blue
else
color = 0xff; // pink
if (h > s)
h = s;
for (i = 0; i < h; i++, dest -= vid.rowbytes) {
dest[0] = color;
}
}
}

View file

@ -56,7 +56,6 @@
void *colormap;
vec3_t viewlightvec;
alight_t r_viewlighting = { 128, 192, viewlightvec };
float r_time1;
int r_numallocatededges;
qboolean r_drawpolys;
qboolean r_drawculledpolys;
@ -137,7 +136,6 @@ void R_MarkLeaves (void);
extern cvar_t *scr_fov;
void R_NetGraph (void);
void R_ZGraph (void);
@ -909,9 +907,6 @@ R_RenderView_ (void)
if (r_timegraph->int_val)
R_TimeGraph ();
if (r_netgraph->int_val)
R_NetGraph ();
if (r_zgraph->int_val)
R_ZGraph ();

View file

@ -34,13 +34,11 @@
#include "QF/console.h"
#include "QF/cmd.h"
#include "QF/draw.h"
#include "QF/render.h"
#include "QF/sys.h"
#include "cl_parse.h"
#include "client.h"
#include "host.h"
#include "r_local.h"
#include "QF/render.h"
#include "sbar.h"
void
@ -119,159 +117,6 @@ R_LoadSky_f (void)
}
/*
R_LineGraph
Only called by R_DisplayTime
*/
void
R_LineGraph (int x, int y, int h)
{
int i;
byte *dest;
int s;
int color;
// FIXME: should be disabled on no-buffer adapters, or should be in the driver
// x += r_refdef.vrect.x;
// y += r_refdef.vrect.y;
dest = vid.buffer + vid.rowbytes * y + x;
s = r_graphheight->int_val;
if (h == 10000)
color = 0x6f; // yellow
else if (h == 9999)
color = 0x4f; // red
else if (h == 9998)
color = 0xd0; // blue
else
color = 0xff; // pink
if (h > s)
h = s;
for (i = 0; i < h; i++, dest -= vid.rowbytes) {
dest[0] = color;
// *(dest-vid.rowbytes) = 0x30;
}
#if 0
for (; i < s; i++, dest -= vid.rowbytes * 2) {
dest[0] = 0x30;
*(dest - vid.rowbytes) = 0x30;
}
#endif
}
#define MAX_TIMINGS 100
extern float mouse_x, mouse_y;
int graphval;
/*
R_TimeGraph
Performance monitoring tool
*/
void
R_TimeGraph (void)
{
static int timex;
int a;
float r_time2;
static byte r_timings[MAX_TIMINGS];
int x;
r_time2 = Sys_DoubleTime ();
a = (r_time2 - r_time1) / 0.01;
// a = fabs(mouse_y * 0.05);
// a = (int)((r_refdef.vieworg[2] + 1024)/1)%(int)r_graphheight->value;
// a = (int)((pmove.velocity[2] + 500)/10);
// a = fabs(velocity[0])/20;
// a = ((int)fabs(origin[0])/8)%20;
// a = (cl.idealpitch + 30)/5;
// a = (int)(cl.simangles[YAW] * 64/360) & 63;
a = graphval;
r_timings[timex] = a;
a = timex;
if (r_refdef.vrect.width <= MAX_TIMINGS)
x = r_refdef.vrect.width - 1;
else
x = r_refdef.vrect.width - (r_refdef.vrect.width - MAX_TIMINGS) / 2;
do {
R_LineGraph (x, r_refdef.vrect.height - 2, r_timings[a]);
if (x == 0)
break; // screen too small to hold entire thing
x--;
a--;
if (a == -1)
a = MAX_TIMINGS - 1;
} while (a != timex);
timex = (timex + 1) % MAX_TIMINGS;
}
void
R_NetGraph (void)
{
int a, x, y, h, i;
int lost;
char st[80];
x = cl_hudswap->int_val ? vid.width - (NET_TIMINGS + 16): 0;
y = vid.height - sb_lines - 24 - r_graphheight->int_val - 1;
h = r_graphheight->int_val % 8;
Draw_TextBox (x, y, NET_TIMINGS / 8, r_graphheight->int_val / 8 + 1);
lost = CL_CalcNet ();
x = cl_hudswap->int_val ? vid.width - (NET_TIMINGS + 8) : 8;
y = vid.height - sb_lines - 9;
y -= h;
for (a = 0; a < NET_TIMINGS; a++) {
i = (cls.netchan.outgoing_sequence - a) & NET_TIMINGSMASK;
R_LineGraph (x + NET_TIMINGS - 1 - a, y, packet_latency[i]);
}
y -= vid.height - sb_lines - 24 - r_graphheight->int_val + 7;
snprintf (st, sizeof (st), "%3i%% packet loss", lost);
if (cl_hudswap->int_val) {
Draw_String8 (vid.width - ((strlen (st) * 8) + 8), y, st);
} else {
Draw_String8 (8, y, st);
}
}
void
R_ZGraph (void)
{
int a, x, w, i;
static int height[256];
if (r_refdef.vrect.width <= 256)
w = r_refdef.vrect.width;
else
w = 256;
height[r_framecount & 255] = ((int) r_origin[2]) & 31;
x = 0;
for (a = 0; a < w; a++) {
i = (r_framecount - a) & 255;
R_LineGraph (x + w - 1 - a, r_refdef.vrect.height - 2, height[i]);
}
}
void
R_PrintTimes (void)
{
@ -482,7 +327,7 @@ R_SetupFrame (void)
vrect.width = vid.width;
vrect.height = vid.height;
R_ViewChanged (&vrect, cl_sbar->int_val ? sb_lines : 0, vid.aspect);
R_ViewChanged (&vrect, r_lineadj, vid.aspect);
} else {
w = vid.width;
h = vid.height;
@ -503,7 +348,7 @@ R_SetupFrame (void)
vrect.height = (int) h;
R_ViewChanged (&vrect,
(int) ((float) (cl_sbar->int_val ? sb_lines : 0) *
(int) ((float) r_lineadj *
(h / (float) vid.height)),
vid.aspect * (h / w) * ((float) vid.width /
(float) vid.height));
@ -514,7 +359,7 @@ R_SetupFrame (void)
vrect.width = vid.width;
vrect.height = vid.height;
R_ViewChanged (&vrect, cl_sbar->int_val ? sb_lines : 0, vid.aspect);
R_ViewChanged (&vrect, r_lineadj, vid.aspect);
}
r_viewchanged = false;