aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llcubemap.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llcubemap.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llcubemap.cpp40
1 files changed, 38 insertions, 2 deletions
diff --git a/linden/indra/newview/llcubemap.cpp b/linden/indra/newview/llcubemap.cpp
index c8e0d50..baa33ac 100644
--- a/linden/indra/newview/llcubemap.cpp
+++ b/linden/indra/newview/llcubemap.cpp
@@ -57,6 +57,7 @@ const BOOL use_cube_mipmaps = FALSE; //current build works best without cube mi
57 57
58LLCubeMap::LLCubeMap() 58LLCubeMap::LLCubeMap()
59 : mTextureStage(0), 59 : mTextureStage(0),
60 mTextureCoordStage(0),
60 mMatrixStage(0) 61 mMatrixStage(0)
61{ 62{
62} 63}
@@ -184,6 +185,7 @@ void LLCubeMap::bind()
184 ) 185 )
185 { 186 {
186 // We assume that if they have cube mapping, they have multitexturing. 187 // We assume that if they have cube mapping, they have multitexturing.
188 glActiveTextureARB(GL_TEXTURE0_ARB + mTextureStage);
187 glEnable(GL_TEXTURE_CUBE_MAP_ARB); 189 glEnable(GL_TEXTURE_CUBE_MAP_ARB);
188 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mImages[0]->getTexName()); 190 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mImages[0]->getTexName());
189 191
@@ -198,6 +200,12 @@ void LLCubeMap::bind()
198 200
199void LLCubeMap::enable(S32 stage) 201void LLCubeMap::enable(S32 stage)
200{ 202{
203 enableTexture(stage);
204 enableTextureCoords(stage);
205}
206
207void LLCubeMap::enableTexture(S32 stage)
208{
201 mTextureStage = stage; 209 mTextureStage = stage;
202 if (gGLManager.mHasCubeMap && 210 if (gGLManager.mHasCubeMap &&
203 stage >= 0 211 stage >= 0
@@ -207,6 +215,16 @@ void LLCubeMap::enable(S32 stage)
207 glActiveTextureARB(GL_TEXTURE0_ARB + stage); // NOTE: leaves texture stage set 215 glActiveTextureARB(GL_TEXTURE0_ARB + stage); // NOTE: leaves texture stage set
208 216
209 glEnable(GL_TEXTURE_CUBE_MAP_ARB); 217 glEnable(GL_TEXTURE_CUBE_MAP_ARB);
218 }
219}
220
221void LLCubeMap::enableTextureCoords(S32 stage)
222{
223 mTextureCoordStage = stage;
224 if (gGLManager.mHasCubeMap && stage >= 0)
225 {
226 glActiveTextureARB(GL_TEXTURE0_ARB + stage); // NOTE: leaves texture stage set
227
210 glEnable(GL_TEXTURE_GEN_R); 228 glEnable(GL_TEXTURE_GEN_R);
211 glEnable(GL_TEXTURE_GEN_S); 229 glEnable(GL_TEXTURE_GEN_S);
212 glEnable(GL_TEXTURE_GEN_T); 230 glEnable(GL_TEXTURE_GEN_T);
@@ -214,10 +232,18 @@ void LLCubeMap::enable(S32 stage)
214 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP); 232 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
215 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP); 233 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
216 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP); 234 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
235
236 glActiveTextureARB(GL_TEXTURE0_ARB);
217 } 237 }
218} 238}
219 239
220void LLCubeMap::disable() 240void LLCubeMap::disable(void)
241{
242 disableTexture();
243 disableTextureCoords();
244}
245
246void LLCubeMap::disableTexture(void)
221{ 247{
222 if (gGLManager.mHasCubeMap && mTextureStage >= 0 248 if (gGLManager.mHasCubeMap && mTextureStage >= 0
223 //&& gFeatureManagerp->isFeatureAvailable("RenderCubeMap") 249 //&& gFeatureManagerp->isFeatureAvailable("RenderCubeMap")
@@ -225,10 +251,18 @@ void LLCubeMap::disable()
225 { 251 {
226 glActiveTextureARB(GL_TEXTURE0_ARB + mTextureStage); 252 glActiveTextureARB(GL_TEXTURE0_ARB + mTextureStage);
227 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0); 253 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0);
254 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
255 }
256}
257
258void LLCubeMap::disableTextureCoords(void)
259{
260 if (gGLManager.mHasCubeMap && mTextureCoordStage >= 0)
261 {
262 glActiveTextureARB(GL_TEXTURE0_ARB + mTextureCoordStage);
228 glDisable(GL_TEXTURE_GEN_S); 263 glDisable(GL_TEXTURE_GEN_S);
229 glDisable(GL_TEXTURE_GEN_T); 264 glDisable(GL_TEXTURE_GEN_T);
230 glDisable(GL_TEXTURE_GEN_R); 265 glDisable(GL_TEXTURE_GEN_R);
231 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
232 } 266 }
233} 267}
234 268
@@ -250,6 +284,7 @@ void LLCubeMap::setMatrix(S32 stage)
250 glPushMatrix(); 284 glPushMatrix();
251 glLoadMatrixf((F32 *)trans.mMatrix); 285 glLoadMatrixf((F32 *)trans.mMatrix);
252 glMatrixMode(GL_MODELVIEW); 286 glMatrixMode(GL_MODELVIEW);
287 glActiveTextureARB(GL_TEXTURE0_ARB);
253} 288}
254 289
255void LLCubeMap::restoreMatrix() 290void LLCubeMap::restoreMatrix()
@@ -258,6 +293,7 @@ void LLCubeMap::restoreMatrix()
258 glMatrixMode(GL_TEXTURE); 293 glMatrixMode(GL_TEXTURE);
259 glPopMatrix(); 294 glPopMatrix();
260 glMatrixMode(GL_MODELVIEW); 295 glMatrixMode(GL_MODELVIEW);
296 glActiveTextureARB(GL_TEXTURE0_ARB);
261} 297}
262 298
263LLVector3 LLCubeMap::map(U8 side, U16 v_val, U16 h_val) const 299LLVector3 LLCubeMap::map(U8 side, U16 v_val, U16 h_val) const