aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llwindow/llgl.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llwindow/llgl.h')
-rw-r--r--linden/indra/llwindow/llgl.h377
1 files changed, 0 insertions, 377 deletions
diff --git a/linden/indra/llwindow/llgl.h b/linden/indra/llwindow/llgl.h
deleted file mode 100644
index 2618dca..0000000
--- a/linden/indra/llwindow/llgl.h
+++ /dev/null
@@ -1,377 +0,0 @@
1/**
2 * @file llgl.h
3 * @brief LLGL definition
4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LL_LLGL_H
33#define LL_LLGL_H
34
35// This file contains various stuff for handling gl extensions and other gl related stuff.
36
37#include <string>
38#include <map>
39
40#include "llerror.h"
41#include "v4color.h"
42#include "llstring.h"
43#include "stdtypes.h"
44#include "v4math.h"
45#include "llplane.h"
46#include "llgltypes.h"
47
48#include "llglheaders.h"
49#include "glh/glh_linear.h"
50
51extern BOOL gDebugGL;
52
53#define LL_GL_ERRS LL_ERRS("RenderState")
54
55class LLSD;
56
57// Manage GL extensions...
58class LLGLManager
59{
60public:
61 LLGLManager();
62
63 bool initGL();
64 void shutdownGL();
65
66 void initWGL(); // Initializes stupid WGL extensions
67
68 LLString getRawGLString(); // For sending to simulator
69
70 BOOL mInited;
71 BOOL mIsDisabled;
72
73 // Extensions used by everyone
74 BOOL mHasMultitexture;
75 S32 mNumTextureUnits;
76 BOOL mHasMipMapGeneration;
77 BOOL mHasPalettedTextures;
78 BOOL mHasCompressedTextures;
79 BOOL mHasFramebufferObject;
80
81 // ARB Extensions
82 BOOL mHasVertexBufferObject;
83 BOOL mHasPBuffer;
84 BOOL mHasShaderObjects;
85 BOOL mHasVertexShader;
86 BOOL mHasFragmentShader;
87 BOOL mHasOcclusionQuery;
88 BOOL mHasPointParameters;
89
90 // Other extensions.
91 BOOL mHasAnisotropic;
92 BOOL mHasARBEnvCombine;
93 BOOL mHasCubeMap;
94
95 // Vendor-specific extensions
96 BOOL mIsATI;
97 BOOL mIsNVIDIA;
98 BOOL mIsIntel;
99 BOOL mIsGF2or4MX;
100 BOOL mIsGF3;
101 BOOL mIsGFFX;
102 BOOL mATIOffsetVerticalLines;
103
104 // Whether this version of GL is good enough for SL to use
105 BOOL mHasRequirements;
106
107 // Misc extensions
108 BOOL mHasSeparateSpecularColor;
109
110 S32 mDriverVersionMajor;
111 S32 mDriverVersionMinor;
112 S32 mDriverVersionRelease;
113 F32 mGLVersion; // e.g = 1.4
114 LLString mDriverVersionVendorString;
115
116 S32 mVRAM; // VRAM in MB
117 S32 mGLMaxVertexRange;
118 S32 mGLMaxIndexRange;
119
120 void getPixelFormat(); // Get the best pixel format
121
122 LLString getGLInfoString();
123 void printGLInfoString();
124 void getGLInfo(LLSD& info);
125
126 // In ALL CAPS
127 LLString mGLVendor;
128 LLString mGLVendorShort;
129
130 // In ALL CAPS
131 LLString mGLRenderer;
132
133private:
134 void initExtensions();
135 void initGLStates();
136 void initGLImages();
137};
138
139extern LLGLManager gGLManager;
140
141class LLQuaternion;
142class LLMatrix4;
143
144void rotate_quat(LLQuaternion& rotation);
145
146void flush_glerror(); // Flush GL errors when we know we're handling them correctly.
147
148void assert_glerror();
149
150void clear_glerror();
151
152//#if LL_DEBUG
153# define stop_glerror() assert_glerror()
154# define llglassertok() assert_glerror()
155//#else
156//# define stop_glerror()
157//# define llglassertok()
158//#endif
159
160#define llglassertok_always() assert_glerror()
161
162////////////////////////
163//
164// Note: U32's are GLEnum's...
165//
166
167// This is a class for GL state management
168
169/*
170 GL STATE MANAGEMENT DESCRIPTION
171
172 LLGLState and its two subclasses, LLGLEnable and LLGLDisable, manage the current
173 enable/disable states of the GL to prevent redundant setting of state within a
174 render path or the accidental corruption of what state the next path expects.
175
176 Essentially, wherever you would call glEnable set a state and then
177 subsequently reset it by calling glDisable (or vice versa), make an instance of
178 LLGLEnable with the state you want to set, and assume it will be restored to its
179 original state when that instance of LLGLEnable is destroyed. It is good practice
180 to exploit stack frame controls for optimal setting/unsetting and readability of
181 code. In llglstates.h, there are a collection of helper classes that define groups
182 of enables/disables that can cause multiple states to be set with the creation of
183 one instance.
184
185 Sample usage:
186
187 //disable lighting for rendering hud objects
188 //INCORRECT USAGE
189 LLGLEnable lighting(GL_LIGHTING);
190 renderHUD();
191 LLGLDisable lighting(GL_LIGHTING);
192
193 //CORRECT USAGE
194 {
195 LLGLEnable lighting(GL_LIGHTING);
196 renderHUD();
197 }
198
199 If a state is to be set on a conditional, the following mechanism
200 is useful:
201
202 {
203 LLGLEnable lighting(light_hud ? GL_LIGHTING : 0);
204 renderHUD();
205 }
206
207 A LLGLState initialized with a parameter of 0 does nothing.
208
209 LLGLState works by maintaining a map of the current GL states, and ignoring redundant
210 enables/disables. If a redundant call is attempted, it becomes a noop, otherwise,
211 it is set in the constructor and reset in the destructor.
212
213 For debugging GL state corruption, running with debug enabled will trigger asserts
214 if the existing GL state does not match the expected GL state.
215
216*/
217class LLGLState
218{
219public:
220 static void initClass();
221 static void restoreGL();
222
223 static void resetTextureStates();
224 static void dumpStates();
225 static void checkStates();
226 static void checkTextureChannels();
227 static void checkClientArrays(U32 data_mask = 0x0001);
228
229protected:
230 static std::map<LLGLenum, LLGLboolean> sStateMap;
231
232public:
233 enum { CURRENT_STATE = -2 };
234 LLGLState(LLGLenum state, S32 enabled = CURRENT_STATE);
235 ~LLGLState();
236 void setEnabled(S32 enabled);
237 void enable() { setEnabled(TRUE); }
238 void disable() { setEnabled(FALSE); }
239protected:
240 LLGLenum mState;
241 BOOL mWasEnabled;
242 BOOL mIsEnabled;
243};
244
245// New LLGLState class wrappers that don't depend on actual GL flags.
246class LLGLEnableBlending : public LLGLState
247{
248public:
249 LLGLEnableBlending(bool enable);
250};
251
252class LLGLEnableAlphaReject : public LLGLState
253{
254public:
255 LLGLEnableAlphaReject(bool enable);
256};
257
258/// TODO: Being deprecated.
259class LLGLEnable : public LLGLState
260{
261public:
262 LLGLEnable(LLGLenum state) : LLGLState(state, TRUE) {}
263};
264
265/// TODO: Being deprecated.
266class LLGLDisable : public LLGLState
267{
268public:
269 LLGLDisable(LLGLenum state) : LLGLState(state, FALSE) {}
270};
271
272/*
273 Store and modify projection matrix to create an oblique
274 projection that clips to the specified plane. Oblique
275 projections alter values in the depth buffer, so this
276 class should not be used mid-renderpass.
277
278 Restores projection matrix on destruction.
279 GL_MODELVIEW_MATRIX is active whenever program execution
280 leaves this class.
281 Does not stack.
282 Caches inverse of projection matrix used in gGLObliqueProjectionInverse
283*/
284class LLGLUserClipPlane
285{
286public:
287
288 LLGLUserClipPlane(const LLPlane& plane, const glh::matrix4f& modelview, const glh::matrix4f& projection);
289 ~LLGLUserClipPlane();
290
291 void setPlane(F32 a, F32 b, F32 c, F32 d);
292
293private:
294 glh::matrix4f mProjection;
295 glh::matrix4f mModelview;
296};
297
298/*
299 Modify and load projection matrix to push depth values to far clip plane.
300
301 Restores projection matrix on destruction.
302 GL_MODELVIEW_MATRIX is active whenever program execution
303 leaves this class.
304 Does not stack.
305*/
306class LLGLClampToFarClip
307{
308public:
309 LLGLClampToFarClip(glh::matrix4f projection);
310 ~LLGLClampToFarClip();
311};
312
313/*
314 Generic pooling scheme for things which use GL names (used for occlusion queries and vertex buffer objects).
315 Prevents thrashing of GL name caches by avoiding calls to glGenFoo and glDeleteFoo.
316*/
317class LLGLNamePool
318{
319public:
320 typedef struct
321 {
322 GLuint name;
323 BOOL used;
324 } NameEntry;
325
326 struct CompareUsed
327 {
328 bool operator()(const NameEntry& lhs, const NameEntry& rhs)
329 {
330 return lhs.used < rhs.used; //FALSE entries first
331 }
332 };
333
334 typedef std::vector<NameEntry> name_list_t;
335 name_list_t mNameList;
336
337 LLGLNamePool();
338 virtual ~LLGLNamePool();
339
340 void upkeep();
341 void cleanup();
342
343 GLuint allocate();
344 void release(GLuint name);
345
346 static void registerPool(LLGLNamePool* pool);
347 static void upkeepPools();
348 static void cleanupPools();
349
350protected:
351 typedef std::vector<LLGLNamePool*> pool_list_t;
352 static pool_list_t sInstances;
353
354 virtual GLuint allocateName() = 0;
355 virtual void releaseName(GLuint name) = 0;
356};
357
358extern LLMatrix4 gGLObliqueProjectionInverse;
359
360#include "llglstates.h"
361
362void init_glstates();
363void enable_vertex_weighting(const S32 index);
364void disable_vertex_weighting(const S32 index);
365void enable_binormals(const S32 index);
366void disable_binormals(const S32 index);
367void enable_cloth_weights(const S32 index);
368void disable_cloth_weights(const S32 index);
369void set_vertex_weights(const S32 index, const U32 stride, const F32 *weights);
370void set_vertex_clothing_weights(const S32 index, const U32 stride, const LLVector4 *weights);
371void set_binormals(const S32 index, const U32 stride, const LLVector3 *binormals);
372void set_palette(U8* palette_data);
373void parse_gl_version( S32* major, S32* minor, S32* release, LLString* vendor_specific );
374
375extern BOOL gClothRipple;
376extern BOOL gNoRender;
377#endif // LL_LLGL_H