Annotation of /linden_release/linden/indra/llrender/llglstates.h
Parent Directory
|
Revision Log
Revision 57 - (view) (download)
| 1 : | mjm | 57 | /** |
| 2 : | * @file llglstates.h | ||
| 3 : | * @brief LLGL states definitions | ||
| 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 : | //THIS HEADER SHOULD ONLY BE INCLUDED FROM llgl.h | ||
| 33 : | #ifndef LL_LLGLSTATES_H | ||
| 34 : | #define LL_LLGLSTATES_H | ||
| 35 : | |||
| 36 : | #include "llimagegl.h" | ||
| 37 : | |||
| 38 : | //---------------------------------------------------------------------------- | ||
| 39 : | |||
| 40 : | class LLGLDepthTest | ||
| 41 : | { | ||
| 42 : | // Enabled by default | ||
| 43 : | public: | ||
| 44 : | LLGLDepthTest(GLboolean depth_enabled, GLboolean write_enabled = GL_TRUE, GLenum depth_func = GL_LEQUAL); | ||
| 45 : | |||
| 46 : | ~LLGLDepthTest(); | ||
| 47 : | |||
| 48 : | GLboolean mPrevDepthEnabled; | ||
| 49 : | GLenum mPrevDepthFunc; | ||
| 50 : | GLboolean mPrevWriteEnabled; | ||
| 51 : | private: | ||
| 52 : | static GLboolean sDepthEnabled; // defaults to GL_FALSE | ||
| 53 : | static GLenum sDepthFunc; // defaults to GL_LESS | ||
| 54 : | static GLboolean sWriteEnabled; // defaults to GL_TRUE | ||
| 55 : | }; | ||
| 56 : | |||
| 57 : | //---------------------------------------------------------------------------- | ||
| 58 : | |||
| 59 : | class LLGLSDefault | ||
| 60 : | { | ||
| 61 : | protected: | ||
| 62 : | LLGLEnable mColorMaterial; | ||
| 63 : | LLGLDisable mAlphaTest, mBlend, mCullFace, mDither, mFog, | ||
| 64 : | mLineSmooth, mLineStipple, mNormalize, mPolygonSmooth, | ||
| 65 : | mTextureGenQ, mTextureGenR, mTextureGenS, mTextureGenT, | ||
| 66 : | mGLMultisample; | ||
| 67 : | public: | ||
| 68 : | LLGLSDefault() | ||
| 69 : | : | ||
| 70 : | // Enable | ||
| 71 : | mColorMaterial(GL_COLOR_MATERIAL), | ||
| 72 : | // Disable | ||
| 73 : | mAlphaTest(GL_ALPHA_TEST), | ||
| 74 : | mBlend(GL_BLEND), | ||
| 75 : | mCullFace(GL_CULL_FACE), | ||
| 76 : | mDither(GL_DITHER), | ||
| 77 : | mFog(GL_FOG), | ||
| 78 : | mLineSmooth(GL_LINE_SMOOTH), | ||
| 79 : | mLineStipple(GL_LINE_STIPPLE), | ||
| 80 : | mNormalize(GL_NORMALIZE), | ||
| 81 : | mPolygonSmooth(GL_POLYGON_SMOOTH), | ||
| 82 : | mTextureGenQ(GL_TEXTURE_GEN_Q), | ||
| 83 : | mTextureGenR(GL_TEXTURE_GEN_R), | ||
| 84 : | mTextureGenS(GL_TEXTURE_GEN_S), | ||
| 85 : | mTextureGenT(GL_TEXTURE_GEN_T), | ||
| 86 : | mGLMultisample(GL_MULTISAMPLE_ARB) | ||
| 87 : | { } | ||
| 88 : | }; | ||
| 89 : | |||
| 90 : | class LLGLSNoTexture | ||
| 91 : | { | ||
| 92 : | public: | ||
| 93 : | LLGLSNoTexture() | ||
| 94 : | { LLImageGL::unbindTexture(0); } | ||
| 95 : | }; | ||
| 96 : | |||
| 97 : | class LLGLSObjectSelect | ||
| 98 : | { | ||
| 99 : | protected: | ||
| 100 : | LLGLDisable mBlend, mFog, mAlphaTest; | ||
| 101 : | LLGLEnable mCullFace; | ||
| 102 : | public: | ||
| 103 : | LLGLSObjectSelect() | ||
| 104 : | : mBlend(GL_BLEND), mFog(GL_FOG), | ||
| 105 : | mAlphaTest(GL_ALPHA_TEST), | ||
| 106 : | mCullFace(GL_CULL_FACE) | ||
| 107 : | { LLImageGL::unbindTexture(0); } | ||
| 108 : | }; | ||
| 109 : | |||
| 110 : | class LLGLSObjectSelectAlpha | ||
| 111 : | { | ||
| 112 : | protected: | ||
| 113 : | LLGLEnable mAlphaTest; | ||
| 114 : | public: | ||
| 115 : | LLGLSObjectSelectAlpha() | ||
| 116 : | : mAlphaTest(GL_ALPHA_TEST) | ||
| 117 : | {} | ||
| 118 : | }; | ||
| 119 : | |||
| 120 : | //---------------------------------------------------------------------------- | ||
| 121 : | |||
| 122 : | class LLGLSUIDefault | ||
| 123 : | { | ||
| 124 : | protected: | ||
| 125 : | LLGLEnable mBlend, mAlphaTest; | ||
| 126 : | LLGLDisable mCullFace; | ||
| 127 : | LLGLDepthTest mDepthTest; | ||
| 128 : | public: | ||
| 129 : | LLGLSUIDefault() | ||
| 130 : | : mBlend(GL_BLEND), mAlphaTest(GL_ALPHA_TEST), | ||
| 131 : | mCullFace(GL_CULL_FACE), | ||
| 132 : | mDepthTest(GL_FALSE, GL_TRUE, GL_LEQUAL) | ||
| 133 : | {} | ||
| 134 : | }; | ||
| 135 : | |||
| 136 : | class LLGLSNoAlphaTest // : public LLGLSUIDefault | ||
| 137 : | { | ||
| 138 : | protected: | ||
| 139 : | LLGLDisable mAlphaTest; | ||
| 140 : | public: | ||
| 141 : | LLGLSNoAlphaTest() | ||
| 142 : | : mAlphaTest(GL_ALPHA_TEST) | ||
| 143 : | {} | ||
| 144 : | }; | ||
| 145 : | |||
| 146 : | class LLGLSNoTextureNoAlphaTest // : public LLGLSUIDefault | ||
| 147 : | { | ||
| 148 : | protected: | ||
| 149 : | LLGLDisable mAlphaTest; | ||
| 150 : | public: | ||
| 151 : | LLGLSNoTextureNoAlphaTest() | ||
| 152 : | : mAlphaTest(GL_ALPHA_TEST) | ||
| 153 : | |||
| 154 : | { LLImageGL::unbindTexture(0); } | ||
| 155 : | }; | ||
| 156 : | |||
| 157 : | //---------------------------------------------------------------------------- | ||
| 158 : | |||
| 159 : | class LLGLSFog | ||
| 160 : | { | ||
| 161 : | protected: | ||
| 162 : | LLGLEnable mFog; | ||
| 163 : | public: | ||
| 164 : | LLGLSFog() | ||
| 165 : | : mFog(GL_FOG) | ||
| 166 : | {} | ||
| 167 : | }; | ||
| 168 : | |||
| 169 : | class LLGLSNoFog | ||
| 170 : | { | ||
| 171 : | protected: | ||
| 172 : | LLGLDisable mFog; | ||
| 173 : | public: | ||
| 174 : | LLGLSNoFog() | ||
| 175 : | : mFog(GL_FOG) | ||
| 176 : | {} | ||
| 177 : | }; | ||
| 178 : | |||
| 179 : | //---------------------------------------------------------------------------- | ||
| 180 : | |||
| 181 : | class LLGLSPipeline | ||
| 182 : | { | ||
| 183 : | protected: | ||
| 184 : | LLGLEnable mCullFace; | ||
| 185 : | LLGLDepthTest mDepthTest; | ||
| 186 : | public: | ||
| 187 : | LLGLSPipeline() | ||
| 188 : | : mCullFace(GL_CULL_FACE), | ||
| 189 : | mDepthTest(GL_TRUE, GL_TRUE, GL_LEQUAL) | ||
| 190 : | { } | ||
| 191 : | }; | ||
| 192 : | |||
| 193 : | class LLGLSPipelineAlpha // : public LLGLSPipeline | ||
| 194 : | { | ||
| 195 : | protected: | ||
| 196 : | LLGLEnable mBlend, mAlphaTest; | ||
| 197 : | public: | ||
| 198 : | LLGLSPipelineAlpha() | ||
| 199 : | : mBlend(GL_BLEND), | ||
| 200 : | mAlphaTest(GL_ALPHA_TEST) | ||
| 201 : | { } | ||
| 202 : | }; | ||
| 203 : | |||
| 204 : | class LLGLSPipelineEmbossBump | ||
| 205 : | { | ||
| 206 : | protected: | ||
| 207 : | LLGLDisable mFog; | ||
| 208 : | public: | ||
| 209 : | LLGLSPipelineEmbossBump() | ||
| 210 : | : mFog(GL_FOG) | ||
| 211 : | { } | ||
| 212 : | }; | ||
| 213 : | |||
| 214 : | class LLGLSPipelineSelection | ||
| 215 : | { | ||
| 216 : | protected: | ||
| 217 : | LLGLDisable mCullFace; | ||
| 218 : | public: | ||
| 219 : | LLGLSPipelineSelection() | ||
| 220 : | : mCullFace(GL_CULL_FACE) | ||
| 221 : | {} | ||
| 222 : | }; | ||
| 223 : | |||
| 224 : | class LLGLSPipelineAvatar | ||
| 225 : | { | ||
| 226 : | protected: | ||
| 227 : | LLGLEnable mNormalize; | ||
| 228 : | public: | ||
| 229 : | LLGLSPipelineAvatar() | ||
| 230 : | : mNormalize(GL_NORMALIZE) | ||
| 231 : | {} | ||
| 232 : | }; | ||
| 233 : | |||
| 234 : | class LLGLSPipelineSkyBox | ||
| 235 : | { | ||
| 236 : | protected: | ||
| 237 : | LLGLDisable mAlphaTest, mCullFace, mFog; | ||
| 238 : | public: | ||
| 239 : | LLGLSPipelineSkyBox() | ||
| 240 : | : mAlphaTest(GL_ALPHA_TEST), mCullFace(GL_CULL_FACE), mFog(GL_FOG) | ||
| 241 : | { } | ||
| 242 : | }; | ||
| 243 : | |||
| 244 : | class LLGLSTracker | ||
| 245 : | { | ||
| 246 : | protected: | ||
| 247 : | LLGLEnable mCullFace, mBlend, mAlphaTest; | ||
| 248 : | public: | ||
| 249 : | LLGLSTracker() : | ||
| 250 : | mCullFace(GL_CULL_FACE), | ||
| 251 : | mBlend(GL_BLEND), | ||
| 252 : | mAlphaTest(GL_ALPHA_TEST) | ||
| 253 : | |||
| 254 : | { LLImageGL::unbindTexture(0); } | ||
| 255 : | }; | ||
| 256 : | |||
| 257 : | //---------------------------------------------------------------------------- | ||
| 258 : | |||
| 259 : | class LLGLSSpecular | ||
| 260 : | { | ||
| 261 : | public: | ||
| 262 : | LLGLSSpecular(const LLColor4& color, F32 shininess) | ||
| 263 : | { | ||
| 264 : | if (shininess > 0.0f) | ||
| 265 : | { | ||
| 266 : | glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color.mV); | ||
| 267 : | S32 shiny = (S32)(shininess*128.f); | ||
| 268 : | shiny = llclamp(shiny,0,128); | ||
| 269 : | glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, shiny); | ||
| 270 : | } | ||
| 271 : | } | ||
| 272 : | ~LLGLSSpecular() | ||
| 273 : | { | ||
| 274 : | glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, LLColor4(0.f,0.f,0.f,0.f).mV); | ||
| 275 : | glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 0); | ||
| 276 : | } | ||
| 277 : | }; | ||
| 278 : | |||
| 279 : | //---------------------------------------------------------------------------- | ||
| 280 : | |||
| 281 : | |||
| 282 : | class LLGLSBlendFunc : public LLGLSPipeline { | ||
| 283 : | protected: | ||
| 284 : | GLint mSavedSrc, mSavedDst; | ||
| 285 : | LLGLEnable mBlend; | ||
| 286 : | |||
| 287 : | public: | ||
| 288 : | LLGLSBlendFunc(GLenum srcFunc, GLenum dstFunc) : | ||
| 289 : | mBlend(GL_BLEND) | ||
| 290 : | { | ||
| 291 : | glGetIntegerv(GL_BLEND_SRC, &mSavedSrc); | ||
| 292 : | glGetIntegerv(GL_BLEND_DST, &mSavedDst); | ||
| 293 : | glBlendFunc(srcFunc, dstFunc); | ||
| 294 : | } | ||
| 295 : | |||
| 296 : | ~LLGLSBlendFunc(void) { | ||
| 297 : | glBlendFunc(mSavedSrc, mSavedDst); | ||
| 298 : | } | ||
| 299 : | }; | ||
| 300 : | |||
| 301 : | |||
| 302 : | #endif |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

