aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llcubemap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llrender/llcubemap.cpp')
-rw-r--r--linden/indra/llrender/llcubemap.cpp56
1 files changed, 13 insertions, 43 deletions
diff --git a/linden/indra/llrender/llcubemap.cpp b/linden/indra/llrender/llcubemap.cpp
index 563d616..60215f0 100644
--- a/linden/indra/llrender/llcubemap.cpp
+++ b/linden/indra/llrender/llcubemap.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2002&license=viewergpl$ 5 * $LicenseInfo:firstyear=2002&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2002-2008, Linden Research, Inc. 7 * Copyright (c) 2002-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -92,11 +92,11 @@ void LLCubeMap::initGL()
92 for (int i = 0; i < 6; i++) 92 for (int i = 0; i < 6; i++)
93 { 93 {
94 mImages[i] = new LLImageGL(64, 64, 4, (use_cube_mipmaps? TRUE : FALSE)); 94 mImages[i] = new LLImageGL(64, 64, 4, (use_cube_mipmaps? TRUE : FALSE));
95 mImages[i]->setTarget(mTargets[i], GL_TEXTURE_CUBE_MAP_ARB); 95 mImages[i]->setTarget(mTargets[i], LLTexUnit::TT_CUBE_MAP);
96 mRawImages[i] = new LLImageRaw(64, 64, 4); 96 mRawImages[i] = new LLImageRaw(64, 64, 4);
97 mImages[i]->createGLTexture(0, mRawImages[i], texname); 97 mImages[i]->createGLTexture(0, mRawImages[i], texname);
98 98
99 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, texname); 99 gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_CUBE_MAP, texname);
100 mImages[i]->setClampCubemap (TRUE, TRUE, TRUE); 100 mImages[i]->setClampCubemap (TRUE, TRUE, TRUE);
101 stop_glerror(); 101 stop_glerror();
102 } 102 }
@@ -180,26 +180,7 @@ GLuint LLCubeMap::getGLName()
180 180
181void LLCubeMap::bind() 181void LLCubeMap::bind()
182{ 182{
183 if (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) 183 gGL.getTexUnit(mTextureStage)->bind(this);
184 {
185 // We assume that if they have cube mapping, they have multitexturing.
186 if (mTextureStage > 0)
187 {
188 gGL.getTexUnit(mTextureStage)->activate();
189 }
190 glEnable(GL_TEXTURE_CUBE_MAP_ARB);
191 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mImages[0]->getTexName());
192
193 mImages[0]->setMipFilterNearest (FALSE, FALSE);
194 if (mTextureStage > 0)
195 {
196 gGL.getTexUnit(0)->activate();
197 }
198 }
199 else
200 {
201 llwarns << "Using cube map without extension!" << llendl
202 }
203} 184}
204 185
205void LLCubeMap::enable(S32 stage) 186void LLCubeMap::enable(S32 stage)
@@ -213,17 +194,7 @@ void LLCubeMap::enableTexture(S32 stage)
213 mTextureStage = stage; 194 mTextureStage = stage;
214 if (gGLManager.mHasCubeMap && stage >= 0 && LLCubeMap::sUseCubeMaps) 195 if (gGLManager.mHasCubeMap && stage >= 0 && LLCubeMap::sUseCubeMaps)
215 { 196 {
216 if (stage > 0) 197 gGL.getTexUnit(stage)->enable(LLTexUnit::TT_CUBE_MAP);
217 {
218 gGL.getTexUnit(stage)->activate();
219 }
220
221 glEnable(GL_TEXTURE_CUBE_MAP_ARB);
222
223 if (stage > 0)
224 {
225 gGL.getTexUnit(0)->activate();
226 }
227 } 198 }
228} 199}
229 200
@@ -262,15 +233,10 @@ void LLCubeMap::disableTexture(void)
262{ 233{
263 if (gGLManager.mHasCubeMap && mTextureStage >= 0 && LLCubeMap::sUseCubeMaps) 234 if (gGLManager.mHasCubeMap && mTextureStage >= 0 && LLCubeMap::sUseCubeMaps)
264 { 235 {
265 if (mTextureStage > 0) 236 gGL.getTexUnit(mTextureStage)->disable();
237 if (mTextureStage == 0)
266 { 238 {
267 gGL.getTexUnit(mTextureStage)->activate(); 239 gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
268 }
269 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0);
270 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
271 if (mTextureStage > 0)
272 {
273 gGL.getTexUnit(0)->activate();
274 } 240 }
275 } 241 }
276} 242}
@@ -297,6 +263,8 @@ void LLCubeMap::setMatrix(S32 stage)
297{ 263{
298 mMatrixStage = stage; 264 mMatrixStage = stage;
299 265
266 if (mMatrixStage < 0) return;
267
300 if (stage > 0) 268 if (stage > 0)
301 { 269 {
302 gGL.getTexUnit(stage)->activate(); 270 gGL.getTexUnit(stage)->activate();
@@ -324,6 +292,8 @@ void LLCubeMap::setMatrix(S32 stage)
324 292
325void LLCubeMap::restoreMatrix() 293void LLCubeMap::restoreMatrix()
326{ 294{
295 if (mMatrixStage < 0) return;
296
327 if (mMatrixStage > 0) 297 if (mMatrixStage > 0)
328 { 298 {
329 gGL.getTexUnit(mMatrixStage)->activate(); 299 gGL.getTexUnit(mMatrixStage)->activate();
@@ -340,7 +310,7 @@ void LLCubeMap::restoreMatrix()
340 310
341void LLCubeMap::setReflection (void) 311void LLCubeMap::setReflection (void)
342{ 312{
343 glBindTexture (GL_TEXTURE_CUBE_MAP_ARB, getGLName()); 313 gGL.getTexUnit(mTextureStage)->bindManual(LLTexUnit::TT_CUBE_MAP, getGLName());
344 mImages[0]->setMipFilterNearest (FALSE, FALSE); 314 mImages[0]->setMipFilterNearest (FALSE, FALSE);
345 mImages[0]->setClampCubemap (TRUE, TRUE); 315 mImages[0]->setClampCubemap (TRUE, TRUE);
346} 316}