1 /*
2 r_graph.c
3
4 rednerer diagnostic graphs
5
6 Copyright (C) 1996-1997 Id Software, Inc.
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17 See the GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to:
21
22 Free Software Foundation, Inc.
23 59 Temple Place - Suite 330
24 Boston, MA 02111-1307, USA
25
26 */
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include "QF/draw.h"
32 #include "QF/render.h"
33 #include "QF/plugin.h"
34 #include "QF/sys.h"
35
36 #include "r_internal.h"
37
38
39 #define MAX_TIMINGS 100
40 int graphval;
41
42
43 /*
44 R_TimeGraph
45
46 Performance monitoring tool
47 */
48 void
R_TimeGraph(void)49 R_TimeGraph (void)
50 {
51 static int timex;
52 int a;
53 int l;
54 //XXX float r_time2;
55 static int r_timings[MAX_TIMINGS];
56 int x;
57
58 //XXX r_time2 = Sys_DoubleTime ();
59
60 a = graphval;
61
62 r_timings[timex] = a;
63
64 l = MAX_TIMINGS;
65 if (l > r_refdef.vrect.width)
66 l = r_refdef.vrect.width;
67 x = r_refdef.vrect.width - l;
68 a = timex - l;
69 if (a < 0) {
70 vr_funcs->R_LineGraph (x, r_refdef.vrect.height - 2,
71 &r_timings[a + MAX_TIMINGS], -a);
72 x -= a;
73 l += a;
74 a = 0;
75 }
76 vr_funcs->R_LineGraph (x, r_refdef.vrect.height - 2, &r_timings[a], l);
77
78 timex = (timex + 1) % MAX_TIMINGS;
79 }
80
81 void
R_ZGraph(void)82 R_ZGraph (void)
83 {
84 int x, w;
85 static int height[256];
86
87 if (r_refdef.vrect.width <= 256)
88 w = r_refdef.vrect.width;
89 else
90 w = 256;
91
92 height[r_framecount & 255] = ((int) r_origin[2]) & 31;
93
94 x = 0;
95 vr_funcs->R_LineGraph (x, r_refdef.vrect.height - 2, height, w);
96 }
97