diff options
Diffstat (limited to 'linden/indra/newview/llcubemap.cpp')
-rw-r--r-- | linden/indra/newview/llcubemap.cpp | 70 |
1 files changed, 60 insertions, 10 deletions
diff --git a/linden/indra/newview/llcubemap.cpp b/linden/indra/newview/llcubemap.cpp index e11f058..31937ba 100644 --- a/linden/indra/newview/llcubemap.cpp +++ b/linden/indra/newview/llcubemap.cpp | |||
@@ -185,12 +185,19 @@ void LLCubeMap::bind() | |||
185 | ) | 185 | ) |
186 | { | 186 | { |
187 | // 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); | 188 | if (mTextureStage > 0) |
189 | { | ||
190 | glActiveTextureARB(GL_TEXTURE0_ARB + mTextureStage); | ||
191 | } | ||
189 | glEnable(GL_TEXTURE_CUBE_MAP_ARB); | 192 | glEnable(GL_TEXTURE_CUBE_MAP_ARB); |
190 | glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mImages[0]->getTexName()); | 193 | glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mImages[0]->getTexName()); |
191 | 194 | ||
192 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 195 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
193 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, (use_cube_mipmaps? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR)); | 196 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, (use_cube_mipmaps? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR)); |
197 | if (mTextureStage > 0) | ||
198 | { | ||
199 | glActiveTextureARB(GL_TEXTURE0_ARB); | ||
200 | } | ||
194 | } | 201 | } |
195 | else | 202 | else |
196 | { | 203 | { |
@@ -212,9 +219,17 @@ void LLCubeMap::enableTexture(S32 stage) | |||
212 | //&& LLFeatureManager::getInstance()->isFeatureAvailable("RenderCubeMap") | 219 | //&& LLFeatureManager::getInstance()->isFeatureAvailable("RenderCubeMap") |
213 | ) | 220 | ) |
214 | { | 221 | { |
215 | glActiveTextureARB(GL_TEXTURE0_ARB + stage); // NOTE: leaves texture stage set | 222 | if (stage > 0) |
223 | { | ||
224 | glActiveTextureARB(GL_TEXTURE0_ARB + stage); | ||
225 | } | ||
216 | 226 | ||
217 | glEnable(GL_TEXTURE_CUBE_MAP_ARB); | 227 | glEnable(GL_TEXTURE_CUBE_MAP_ARB); |
228 | |||
229 | if (stage > 0) | ||
230 | { | ||
231 | glActiveTextureARB(GL_TEXTURE0_ARB); | ||
232 | } | ||
218 | } | 233 | } |
219 | } | 234 | } |
220 | 235 | ||
@@ -223,7 +238,10 @@ void LLCubeMap::enableTextureCoords(S32 stage) | |||
223 | mTextureCoordStage = stage; | 238 | mTextureCoordStage = stage; |
224 | if (gGLManager.mHasCubeMap && stage >= 0) | 239 | if (gGLManager.mHasCubeMap && stage >= 0) |
225 | { | 240 | { |
226 | glActiveTextureARB(GL_TEXTURE0_ARB + stage); // NOTE: leaves texture stage set | 241 | if (stage > 0) |
242 | { | ||
243 | glActiveTextureARB(GL_TEXTURE0_ARB + stage); | ||
244 | } | ||
227 | 245 | ||
228 | glEnable(GL_TEXTURE_GEN_R); | 246 | glEnable(GL_TEXTURE_GEN_R); |
229 | glEnable(GL_TEXTURE_GEN_S); | 247 | glEnable(GL_TEXTURE_GEN_S); |
@@ -233,7 +251,10 @@ void LLCubeMap::enableTextureCoords(S32 stage) | |||
233 | glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP); | 251 | glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP); |
234 | glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP); | 252 | glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP); |
235 | 253 | ||
236 | glActiveTextureARB(GL_TEXTURE0_ARB); | 254 | if (stage > 0) |
255 | { | ||
256 | glActiveTextureARB(GL_TEXTURE0_ARB); | ||
257 | } | ||
237 | } | 258 | } |
238 | } | 259 | } |
239 | 260 | ||
@@ -249,9 +270,16 @@ void LLCubeMap::disableTexture(void) | |||
249 | //&& LLFeatureManager::getInstance()->isFeatureAvailable("RenderCubeMap") | 270 | //&& LLFeatureManager::getInstance()->isFeatureAvailable("RenderCubeMap") |
250 | ) | 271 | ) |
251 | { | 272 | { |
252 | glActiveTextureARB(GL_TEXTURE0_ARB + mTextureStage); | 273 | if (mTextureStage > 0) |
274 | { | ||
275 | glActiveTextureARB(GL_TEXTURE0_ARB + mTextureStage); | ||
276 | } | ||
253 | glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0); | 277 | glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0); |
254 | glDisable(GL_TEXTURE_CUBE_MAP_ARB); | 278 | glDisable(GL_TEXTURE_CUBE_MAP_ARB); |
279 | if (mTextureStage > 0) | ||
280 | { | ||
281 | glActiveTextureARB(GL_TEXTURE0_ARB); | ||
282 | } | ||
255 | } | 283 | } |
256 | } | 284 | } |
257 | 285 | ||
@@ -259,17 +287,28 @@ void LLCubeMap::disableTextureCoords(void) | |||
259 | { | 287 | { |
260 | if (gGLManager.mHasCubeMap && mTextureCoordStage >= 0) | 288 | if (gGLManager.mHasCubeMap && mTextureCoordStage >= 0) |
261 | { | 289 | { |
262 | glActiveTextureARB(GL_TEXTURE0_ARB + mTextureCoordStage); | 290 | if (mTextureCoordStage > 0) |
291 | { | ||
292 | glActiveTextureARB(GL_TEXTURE0_ARB + mTextureCoordStage); | ||
293 | } | ||
263 | glDisable(GL_TEXTURE_GEN_S); | 294 | glDisable(GL_TEXTURE_GEN_S); |
264 | glDisable(GL_TEXTURE_GEN_T); | 295 | glDisable(GL_TEXTURE_GEN_T); |
265 | glDisable(GL_TEXTURE_GEN_R); | 296 | glDisable(GL_TEXTURE_GEN_R); |
297 | if (mTextureCoordStage > 0) | ||
298 | { | ||
299 | glActiveTextureARB(GL_TEXTURE0_ARB); | ||
300 | } | ||
266 | } | 301 | } |
267 | } | 302 | } |
268 | 303 | ||
269 | void LLCubeMap::setMatrix(S32 stage) | 304 | void LLCubeMap::setMatrix(S32 stage) |
270 | { | 305 | { |
271 | mMatrixStage = stage; | 306 | mMatrixStage = stage; |
272 | glActiveTextureARB(GL_TEXTURE0_ARB+stage); | 307 | |
308 | if (stage > 0) | ||
309 | { | ||
310 | glActiveTextureARB(GL_TEXTURE0_ARB+stage); | ||
311 | } | ||
273 | 312 | ||
274 | LLVector3 x(LLVector3d(gGLModelView+0)); | 313 | LLVector3 x(LLVector3d(gGLModelView+0)); |
275 | LLVector3 y(LLVector3d(gGLModelView+4)); | 314 | LLVector3 y(LLVector3d(gGLModelView+4)); |
@@ -284,16 +323,27 @@ void LLCubeMap::setMatrix(S32 stage) | |||
284 | glPushMatrix(); | 323 | glPushMatrix(); |
285 | glLoadMatrixf((F32 *)trans.mMatrix); | 324 | glLoadMatrixf((F32 *)trans.mMatrix); |
286 | glMatrixMode(GL_MODELVIEW); | 325 | glMatrixMode(GL_MODELVIEW); |
287 | glActiveTextureARB(GL_TEXTURE0_ARB); | 326 | |
327 | if (stage > 0) | ||
328 | { | ||
329 | glActiveTextureARB(GL_TEXTURE0_ARB); | ||
330 | } | ||
288 | } | 331 | } |
289 | 332 | ||
290 | void LLCubeMap::restoreMatrix() | 333 | void LLCubeMap::restoreMatrix() |
291 | { | 334 | { |
292 | glActiveTextureARB(GL_TEXTURE0_ARB+mMatrixStage); | 335 | if (mMatrixStage > 0) |
336 | { | ||
337 | glActiveTextureARB(GL_TEXTURE0_ARB+mMatrixStage); | ||
338 | } | ||
293 | glMatrixMode(GL_TEXTURE); | 339 | glMatrixMode(GL_TEXTURE); |
294 | glPopMatrix(); | 340 | glPopMatrix(); |
295 | glMatrixMode(GL_MODELVIEW); | 341 | glMatrixMode(GL_MODELVIEW); |
296 | glActiveTextureARB(GL_TEXTURE0_ARB); | 342 | |
343 | if (mMatrixStage > 0) | ||
344 | { | ||
345 | glActiveTextureARB(GL_TEXTURE0_ARB); | ||
346 | } | ||
297 | } | 347 | } |
298 | 348 | ||
299 | LLVector3 LLCubeMap::map(U8 side, U16 v_val, U16 h_val) const | 349 | LLVector3 LLCubeMap::map(U8 side, U16 v_val, U16 h_val) const |