aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llwindow/llglstates.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llwindow/llglstates.h')
-rw-r--r--linden/indra/llwindow/llglstates.h125
1 files changed, 41 insertions, 84 deletions
diff --git a/linden/indra/llwindow/llglstates.h b/linden/indra/llwindow/llglstates.h
index 5052c8d..7d65952 100644
--- a/linden/indra/llwindow/llglstates.h
+++ b/linden/indra/llwindow/llglstates.h
@@ -33,17 +33,7 @@
33#ifndef LL_LLGLSTATES_H 33#ifndef LL_LLGLSTATES_H
34#define LL_LLGLSTATES_H 34#define LL_LLGLSTATES_H
35 35
36#ifdef WIN32 36#include "llimagegl.h"
37# define WIN32_LEAN_AND_MEAN
38# include <winsock2.h>
39# include <windows.h>
40#endif
41
42#if LL_DARWIN
43#include <AGL/gl.h>
44#else
45#include "llglheaders.h"
46#endif
47 37
48//---------------------------------------------------------------------------- 38//----------------------------------------------------------------------------
49 39
@@ -51,45 +41,10 @@ class LLGLDepthTest
51{ 41{
52 // Enabled by default 42 // Enabled by default
53public: 43public:
54 LLGLDepthTest(GLboolean depth_enabled, GLboolean write_enabled = GL_TRUE, GLenum depth_func = GL_LEQUAL) 44 LLGLDepthTest(GLboolean depth_enabled, GLboolean write_enabled = GL_TRUE, GLenum depth_func = GL_LEQUAL);
55 : mPrevDepthEnabled(sDepthEnabled), mPrevDepthFunc(sDepthFunc), mPrevWriteEnabled(sWriteEnabled) 45
56 { 46 ~LLGLDepthTest();
57 if (depth_enabled != sDepthEnabled) 47
58 {
59 if (depth_enabled) glEnable(GL_DEPTH_TEST);
60 else glDisable(GL_DEPTH_TEST);
61 sDepthEnabled = depth_enabled;
62 }
63 if (depth_func != sDepthFunc)
64 {
65 glDepthFunc(depth_func);
66 sDepthFunc = depth_func;
67 }
68 if (write_enabled != sWriteEnabled)
69 {
70 glDepthMask(write_enabled);
71 sWriteEnabled = write_enabled;
72 }
73 }
74 ~LLGLDepthTest()
75 {
76 if (sDepthEnabled != mPrevDepthEnabled )
77 {
78 if (mPrevDepthEnabled) glEnable(GL_DEPTH_TEST);
79 else glDisable(GL_DEPTH_TEST);
80 sDepthEnabled = mPrevDepthEnabled;
81 }
82 if (sDepthFunc != mPrevDepthFunc)
83 {
84 glDepthFunc(mPrevDepthFunc);
85 sDepthFunc = mPrevDepthFunc;
86 }
87 if (sWriteEnabled != mPrevWriteEnabled )
88 {
89 glDepthMask(mPrevWriteEnabled);
90 sWriteEnabled = mPrevWriteEnabled;
91 }
92 }
93 GLboolean mPrevDepthEnabled; 48 GLboolean mPrevDepthEnabled;
94 GLenum mPrevDepthFunc; 49 GLenum mPrevDepthFunc;
95 GLboolean mPrevWriteEnabled; 50 GLboolean mPrevWriteEnabled;
@@ -104,7 +59,7 @@ private:
104class LLGLSDefault 59class LLGLSDefault
105{ 60{
106protected: 61protected:
107 LLGLEnable mTexture2D, mColorMaterial; 62 LLGLEnable mColorMaterial;
108 LLGLDisable mAlphaTest, mBlend, mCullFace, mDither, mFog, 63 LLGLDisable mAlphaTest, mBlend, mCullFace, mDither, mFog,
109 mLineSmooth, mLineStipple, mNormalize, mPolygonSmooth, 64 mLineSmooth, mLineStipple, mNormalize, mPolygonSmooth,
110 mTextureGenQ, mTextureGenR, mTextureGenS, mTextureGenT; 65 mTextureGenQ, mTextureGenR, mTextureGenS, mTextureGenT;
@@ -112,7 +67,6 @@ public:
112 LLGLSDefault() 67 LLGLSDefault()
113 : 68 :
114 // Enable 69 // Enable
115 mTexture2D(GL_TEXTURE_2D),
116 mColorMaterial(GL_COLOR_MATERIAL), 70 mColorMaterial(GL_COLOR_MATERIAL),
117 // Disable 71 // Disable
118 mAlphaTest(GL_ALPHA_TEST), 72 mAlphaTest(GL_ALPHA_TEST),
@@ -131,47 +85,33 @@ public:
131 { } 85 { }
132}; 86};
133 87
134class LLGLSTexture
135{
136protected:
137 LLGLEnable mTexture2D;
138public:
139 LLGLSTexture()
140 : mTexture2D(GL_TEXTURE_2D)
141 {}
142};
143
144
145class LLGLSNoTexture 88class LLGLSNoTexture
146{ 89{
147protected:
148 LLGLDisable mTexture2D;
149public: 90public:
150 LLGLSNoTexture() 91 LLGLSNoTexture()
151 : mTexture2D(GL_TEXTURE_2D) 92 { LLImageGL::unbindTexture(0); }
152 {}
153}; 93};
154 94
155class LLGLSObjectSelect // : public LLGLSDefault 95class LLGLSObjectSelect
156{ 96{
157protected: 97protected:
158 LLGLDisable mBlend, mFog, mTexture2D, mAlphaTest; 98 LLGLDisable mBlend, mFog, mAlphaTest;
159 LLGLEnable mCullFace; 99 LLGLEnable mCullFace;
160public: 100public:
161 LLGLSObjectSelect() 101 LLGLSObjectSelect()
162 : mBlend(GL_BLEND), mFog(GL_FOG), mTexture2D(GL_TEXTURE_2D), 102 : mBlend(GL_BLEND), mFog(GL_FOG),
163 mAlphaTest(GL_ALPHA_TEST), 103 mAlphaTest(GL_ALPHA_TEST),
164 mCullFace(GL_CULL_FACE) 104 mCullFace(GL_CULL_FACE)
165 {} 105 { LLImageGL::unbindTexture(0); }
166}; 106};
167 107
168class LLGLSObjectSelectAlpha // : public LLGLSObjectSelect 108class LLGLSObjectSelectAlpha
169{ 109{
170protected: 110protected:
171 LLGLEnable mTexture2D, mAlphaTest; 111 LLGLEnable mAlphaTest;
172public: 112public:
173 LLGLSObjectSelectAlpha() 113 LLGLSObjectSelectAlpha()
174 : mTexture2D(GL_TEXTURE_2D), mAlphaTest(GL_ALPHA_TEST) 114 : mAlphaTest(GL_ALPHA_TEST)
175 {} 115 {}
176}; 116};
177 117
@@ -180,13 +120,12 @@ public:
180class LLGLSUIDefault // : public LLGLSDefault 120class LLGLSUIDefault // : public LLGLSDefault
181{ 121{
182protected: 122protected:
183 LLGLEnable mBlend, mAlphaTest, mTexture2D; 123 LLGLEnable mBlend, mAlphaTest;
184 LLGLDisable mCullFace; 124 LLGLDisable mCullFace;
185 LLGLDepthTest mDepthTest; 125 LLGLDepthTest mDepthTest;
186public: 126public:
187 LLGLSUIDefault() 127 LLGLSUIDefault()
188 : mBlend(GL_BLEND), mAlphaTest(GL_ALPHA_TEST), 128 : mBlend(GL_BLEND), mAlphaTest(GL_ALPHA_TEST),
189 mTexture2D(GL_TEXTURE_2D),
190 mCullFace(GL_CULL_FACE), 129 mCullFace(GL_CULL_FACE),
191 mDepthTest(GL_FALSE, GL_TRUE, GL_LEQUAL) 130 mDepthTest(GL_FALSE, GL_TRUE, GL_LEQUAL)
192 {} 131 {}
@@ -206,12 +145,11 @@ class LLGLSNoTextureNoAlphaTest // : public LLGLSUIDefault
206{ 145{
207protected: 146protected:
208 LLGLDisable mAlphaTest; 147 LLGLDisable mAlphaTest;
209 LLGLDisable mTexture2D;
210public: 148public:
211 LLGLSNoTextureNoAlphaTest() 149 LLGLSNoTextureNoAlphaTest()
212 : mAlphaTest(GL_ALPHA_TEST), 150 : mAlphaTest(GL_ALPHA_TEST)
213 mTexture2D(GL_TEXTURE_2D) 151
214 {} 152 { LLImageGL::unbindTexture(0); }
215}; 153};
216 154
217//---------------------------------------------------------------------------- 155//----------------------------------------------------------------------------
@@ -305,14 +243,13 @@ class LLGLSTracker // : public LLGLSDefault
305{ 243{
306protected: 244protected:
307 LLGLEnable mCullFace, mBlend, mAlphaTest; 245 LLGLEnable mCullFace, mBlend, mAlphaTest;
308 LLGLDisable mTexture2D;
309public: 246public:
310 LLGLSTracker() : 247 LLGLSTracker() :
311 mCullFace(GL_CULL_FACE), 248 mCullFace(GL_CULL_FACE),
312 mBlend(GL_BLEND), 249 mBlend(GL_BLEND),
313 mAlphaTest(GL_ALPHA_TEST), 250 mAlphaTest(GL_ALPHA_TEST)
314 mTexture2D(GL_TEXTURE_2D) 251
315 {} 252 { LLImageGL::unbindTexture(0); }
316}; 253};
317 254
318//---------------------------------------------------------------------------- 255//----------------------------------------------------------------------------
@@ -340,4 +277,24 @@ public:
340//---------------------------------------------------------------------------- 277//----------------------------------------------------------------------------
341 278
342 279
280class LLGLSBlendFunc : public LLGLSPipeline {
281protected:
282 GLint mSavedSrc, mSavedDst;
283 LLGLEnable mBlend;
284
285public:
286 LLGLSBlendFunc(GLenum srcFunc, GLenum dstFunc) :
287 mBlend(GL_BLEND)
288 {
289 glGetIntegerv(GL_BLEND_SRC, &mSavedSrc);
290 glGetIntegerv(GL_BLEND_DST, &mSavedDst);
291 glBlendFunc(srcFunc, dstFunc);
292 }
293
294 ~LLGLSBlendFunc(void) {
295 glBlendFunc(mSavedSrc, mSavedDst);
296 }
297};
298
299
343#endif 300#endif