/* 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 #include #include #include "bothdefs.h" // needed by: common.h, net.h, client.h #include "bspfile.h" // needed by: glquake.h #include "vid.h" #include "sys.h" #include "zone.h" // needed by: client.h, gl_model.h #include "mathlib.h" // needed by: protocol.h, render.h, client.h, // modelgen.h, glmodel.h #include "wad.h" #include "draw.h" #include "cvar.h" #include "menu.h" #include "net.h" // needed by: client.h #include "protocol.h" // needed by: client.h #include "cmd.h" #include "sbar.h" #include "render.h" // needed by: client.h, gl_model.h, glquake.h #include "client.h" // need cls in this file #include "model.h" // needed by: glquake.h #include "console.h" #include "glquake.h" extern byte *draw_chars; // 8*8 graphic characters int netgraphtexture; // netgraph texture #define NET_GRAPHHEIGHT 32 static byte ngraph_texels[NET_GRAPHHEIGHT][NET_TIMINGS]; static 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>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; } } /* ============== R_NetGraph ============== */ void R_NetGraph (void) { int a, x, i, y; int lost; char st[80]; unsigned ngraph_pixels[NET_GRAPHHEIGHT][NET_TIMINGS]; x = 0; lost = CL_CalcNet(); for (a=0 ; a>1); y = vid.height - sb_lines - 24 - NET_GRAPHHEIGHT - 1; M_DrawTextBox (x, y, NET_TIMINGS/8, NET_GRAPHHEIGHT/8 + 1); y += 8; sprintf(st, "%3i%% packet loss", lost); Draw_String(8, y, st); y += 8; GL_Bind(netgraphtexture); glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format, NET_TIMINGS, NET_GRAPHHEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, ngraph_pixels); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); x = 8; glColor3f (0.5, 0.5, 0.5); 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 (); }