aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llgldbg.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llrender/llgldbg.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r--linden/indra/llrender/llgldbg.cpp224
1 files changed, 224 insertions, 0 deletions
diff --git a/linden/indra/llrender/llgldbg.cpp b/linden/indra/llrender/llgldbg.cpp
new file mode 100644
index 0000000..4d9f5f9
--- /dev/null
+++ b/linden/indra/llrender/llgldbg.cpp
@@ -0,0 +1,224 @@
1/**
2 * @file llgldbg.cpp
3 * @brief Definitions for OpenGL debugging support
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28// This file sets some global GL parameters, and implements some
29// useful functions for GL operations.
30
31#include "linden_common.h"
32
33#include "llgldbg.h"
34
35#include "llgl.h"
36#include "llglheaders.h"
37
38
39//------------------------------------------------------------------------
40// cmstr()
41//------------------------------------------------------------------------
42char *cmstr(int i)
43{
44 switch( i )
45 {
46 case GL_EMISSION: return "GL_EMISSION";
47 case GL_AMBIENT: return "GL_AMBIENT";
48 case GL_DIFFUSE: return "GL_DIFFUSE";
49 case GL_SPECULAR: return "GL_SPECULAR";
50 case GL_AMBIENT_AND_DIFFUSE: return "GL_AMBIENT_AND_DIFFUSE";
51 }
52 return "UNKNOWN";
53}
54
55//------------------------------------------------------------------------
56// facestr()
57//------------------------------------------------------------------------
58char *facestr(int i)
59{
60 switch( i )
61 {
62 case GL_FRONT: return "GL_FRONT";
63 case GL_BACK: return "GL_BACK";
64 case GL_FRONT_AND_BACK: return "GL_FRONT_AND_BACK";
65 }
66 return "UNKNOWN";
67}
68
69//------------------------------------------------------------------------
70// boolstr()
71//------------------------------------------------------------------------
72const char *boolstr(int b)
73{
74 return b ? "GL_TRUE" : "GL_FALSE";
75}
76
77//------------------------------------------------------------------------
78// fv4()
79//------------------------------------------------------------------------
80char *fv4(F32 *f)
81{
82 static char str[128];
83 sprintf(str, "%8.3f %8.3f %8.3f %8.3f", f[0], f[1], f[2], f[3]);
84 return str;
85}
86
87//------------------------------------------------------------------------
88// fv3()
89//------------------------------------------------------------------------
90char *fv3(F32 *f)
91{
92 static char str[128];
93 sprintf(str, "%8.3f, %8.3f, %8.3f", f[0], f[1], f[2]);
94 return str;
95}
96
97//------------------------------------------------------------------------
98// fv1()
99//------------------------------------------------------------------------
100char *fv1(F32 *f)
101{
102 static char str[128];
103 sprintf(str, "%8.3f", f[0]);
104 return str;
105}
106
107//------------------------------------------------------------------------
108// llgl_dump()
109//------------------------------------------------------------------------
110void llgl_dump()
111{
112 int i;
113 F32 fv[16];
114 GLboolean b;
115
116 llinfos << "==========================" << llendl;
117 llinfos << "OpenGL State" << llendl;
118 llinfos << "==========================" << llendl;
119
120 llinfos << "-----------------------------------" << llendl;
121 llinfos << "Current Values" << llendl;
122 llinfos << "-----------------------------------" << llendl;
123
124 glGetFloatv(GL_CURRENT_COLOR, fv);
125 llinfos << "GL_CURRENT_COLOR : " << fv4(fv) << llendl;
126
127 glGetFloatv(GL_CURRENT_NORMAL, fv);
128 llinfos << "GL_CURRENT_NORMAL : " << fv3(fv) << llendl;
129
130 llinfos << "-----------------------------------" << llendl;
131 llinfos << "Lighting" << llendl;
132 llinfos << "-----------------------------------" << llendl;
133
134 llinfos << "GL_LIGHTING : " << boolstr(glIsEnabled(GL_LIGHTING)) << llendl;
135
136 llinfos << "GL_COLOR_MATERIAL : " << boolstr(glIsEnabled(GL_COLOR_MATERIAL)) << llendl;
137
138 glGetIntegerv(GL_COLOR_MATERIAL_PARAMETER, (GLint*)&i);
139 llinfos << "GL_COLOR_MATERIAL_PARAMETER: " << cmstr(i) << llendl;
140
141 glGetIntegerv(GL_COLOR_MATERIAL_FACE, (GLint*)&i);
142 llinfos << "GL_COLOR_MATERIAL_FACE : " << facestr(i) << llendl;
143
144 fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f;
145 glGetMaterialfv(GL_FRONT, GL_AMBIENT, fv);
146 llinfos << "GL_AMBIENT material : " << fv4(fv) << llendl;
147
148 fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f;
149 glGetMaterialfv(GL_FRONT, GL_DIFFUSE, fv);
150 llinfos << "GL_DIFFUSE material : " << fv4(fv) << llendl;
151
152 fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f;
153 glGetMaterialfv(GL_FRONT, GL_SPECULAR, fv);
154 llinfos << "GL_SPECULAR material : " << fv4(fv) << llendl;
155
156 fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f;
157 glGetMaterialfv(GL_FRONT, GL_EMISSION, fv);
158 llinfos << "GL_EMISSION material : " << fv4(fv) << llendl;
159
160 fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f;
161 glGetMaterialfv(GL_FRONT, GL_SHININESS, fv);
162 llinfos << "GL_SHININESS material : " << fv1(fv) << llendl;
163
164 fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f;
165 glGetFloatv(GL_LIGHT_MODEL_AMBIENT, fv);
166 llinfos << "GL_LIGHT_MODEL_AMBIENT : " << fv4(fv) << llendl;
167
168 glGetBooleanv(GL_LIGHT_MODEL_LOCAL_VIEWER, &b);
169 llinfos << "GL_LIGHT_MODEL_LOCAL_VIEWER: " << boolstr(b) << llendl;
170
171 glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE, &b);
172 llinfos << "GL_LIGHT_MODEL_TWO_SIDE : " << boolstr(b) << llendl;
173
174 for (int l=0; l<8; l++)
175 {
176 b = glIsEnabled(GL_LIGHT0+l);
177 llinfos << "GL_LIGHT" << l << " : " << boolstr(b) << llendl;
178
179 if (!b)
180 continue;
181
182 glGetLightfv(GL_LIGHT0+l, GL_AMBIENT, fv);
183 llinfos << " GL_AMBIENT light : " << fv4(fv) << llendl;
184
185 glGetLightfv(GL_LIGHT0+l, GL_DIFFUSE, fv);
186 llinfos << " GL_DIFFUSE light : " << fv4(fv) << llendl;
187
188 glGetLightfv(GL_LIGHT0+l, GL_SPECULAR, fv);
189 llinfos << " GL_SPECULAR light : " << fv4(fv) << llendl;
190
191 glGetLightfv(GL_LIGHT0+l, GL_POSITION, fv);
192 llinfos << " GL_POSITION light : " << fv4(fv) << llendl;
193
194 glGetLightfv(GL_LIGHT0+l, GL_CONSTANT_ATTENUATION, fv);
195 llinfos << " GL_CONSTANT_ATTENUATION : " << fv1(fv) << llendl;
196
197 glGetLightfv(GL_LIGHT0+l, GL_QUADRATIC_ATTENUATION, fv);
198 llinfos << " GL_QUADRATIC_ATTENUATION : " << fv1(fv) << llendl;
199
200 glGetLightfv(GL_LIGHT0+l, GL_SPOT_DIRECTION, fv);
201 llinfos << " GL_SPOT_DIRECTION : " << fv4(fv) << llendl;
202
203 glGetLightfv(GL_LIGHT0+l, GL_SPOT_EXPONENT, fv);
204 llinfos << " GL_SPOT_EXPONENT : " << fv1(fv) << llendl;
205
206 glGetLightfv(GL_LIGHT0+l, GL_SPOT_CUTOFF, fv);
207 llinfos << " GL_SPOT_CUTOFF : " << fv1(fv) << llendl;
208 }
209
210 llinfos << "-----------------------------------" << llendl;
211 llinfos << "Pixel Operations" << llendl;
212 llinfos << "-----------------------------------" << llendl;
213
214 llinfos << "GL_ALPHA_TEST : " << boolstr(glIsEnabled(GL_ALPHA_TEST)) << llendl;
215 llinfos << "GL_DEPTH_TEST : " << boolstr(glIsEnabled(GL_DEPTH_TEST)) << llendl;
216
217 glGetBooleanv(GL_DEPTH_WRITEMASK, &b);
218 llinfos << "GL_DEPTH_WRITEMASK : " << boolstr(b) << llendl;
219
220 llinfos << "GL_BLEND : " << boolstr(glIsEnabled(GL_BLEND)) << llendl;
221 llinfos << "GL_DITHER : " << boolstr(glIsEnabled(GL_DITHER)) << llendl;
222}
223
224// End