aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/pipeline.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:50 -0500
committerJacek Antonelli2008-08-15 23:45:50 -0500
commit2a4dea528f670b9bb1f77ef27a8a1dd16603d114 (patch)
tree95c68e362703c9099d571ecbdc6142b1cda1e005 /linden/indra/newview/pipeline.cpp
parentSecond Life viewer sources 1.20.6 (diff)
downloadmeta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.zip
meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.gz
meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.bz2
meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.xz
Second Life viewer sources 1.20.7
Diffstat (limited to 'linden/indra/newview/pipeline.cpp')
-rw-r--r--linden/indra/newview/pipeline.cpp185
1 files changed, 65 insertions, 120 deletions
diff --git a/linden/indra/newview/pipeline.cpp b/linden/indra/newview/pipeline.cpp
index 5ec3310..20fd5a7 100644
--- a/linden/indra/newview/pipeline.cpp
+++ b/linden/indra/newview/pipeline.cpp
@@ -50,7 +50,7 @@
50#include "v3color.h" 50#include "v3color.h"
51#include "llui.h" 51#include "llui.h"
52#include "llglheaders.h" 52#include "llglheaders.h"
53#include "llglimmediate.h" 53#include "llrender.h"
54 54
55// newview includes 55// newview includes
56#include "llagent.h" 56#include "llagent.h"
@@ -125,6 +125,7 @@ extern S32 gBoxFrame;
125extern BOOL gRenderLightGlows; 125extern BOOL gRenderLightGlows;
126extern BOOL gHideSelectedObjects; 126extern BOOL gHideSelectedObjects;
127extern BOOL gDisplaySwapBuffers; 127extern BOOL gDisplaySwapBuffers;
128extern BOOL gDebugGL;
128 129
129// hack counter for rendering a fixed number of frames after toggling 130// hack counter for rendering a fixed number of frames after toggling
130// fullscreen to work around DEV-5361 131// fullscreen to work around DEV-5361
@@ -134,6 +135,7 @@ BOOL gAvatarBacklight = FALSE;
134 135
135BOOL gRenderForSelect = FALSE; 136BOOL gRenderForSelect = FALSE;
136 137
138BOOL gDebugPipeline = FALSE;
137LLPipeline gPipeline; 139LLPipeline gPipeline;
138const LLMatrix4* gGLLastMatrix = NULL; 140const LLMatrix4* gGLLastMatrix = NULL;
139 141
@@ -504,11 +506,7 @@ void LLPipeline::createGLBuffers()
504 res = 128; 506 res = 128;
505 mCubeBuffer = new LLCubeMap(); 507 mCubeBuffer = new LLCubeMap();
506 mCubeBuffer->initGL(); 508 mCubeBuffer->initGL();
507 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mCubeBuffer->getGLName()); 509 mCubeBuffer->setReflection();
508 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
509 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
510 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
511 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
512 510
513 for (U32 i = 0; i < 6; i++) 511 for (U32 i = 0; i < 6; i++)
514 { 512 {
@@ -1178,7 +1176,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
1178 LLGLDisable test(GL_ALPHA_TEST); 1176 LLGLDisable test(GL_ALPHA_TEST);
1179 LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); 1177 LLViewerImage::unbindTexture(0, GL_TEXTURE_2D);
1180 1178
1181 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 1179 gGL.setColorMask(false, false);
1182 LLGLDepthTest depth(GL_TRUE, GL_FALSE); 1180 LLGLDepthTest depth(GL_TRUE, GL_FALSE);
1183 1181
1184 for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); 1182 for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin();
@@ -1236,7 +1234,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
1236 sCull->pushDrawable(gSky.mVOGroundp->mDrawable); 1234 sCull->pushDrawable(gSky.mVOGroundp->mDrawable);
1237 } 1235 }
1238 1236
1239 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); 1237 gGL.setColorMask(true, false);
1240 glPopMatrix(); 1238 glPopMatrix();
1241 1239
1242 if (to_texture) 1240 if (to_texture)
@@ -1313,11 +1311,11 @@ void LLPipeline::doOcclusion(LLCamera& camera)
1313 LLVertexBuffer::unbind(); 1311 LLVertexBuffer::unbind();
1314 if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION)) 1312 if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION))
1315 { 1313 {
1316 glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); 1314 gGL.setColorMask(true, false, false, false);
1317 } 1315 }
1318 else 1316 else
1319 { 1317 {
1320 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 1318 gGL.setColorMask(false, false);
1321 } 1319 }
1322 LLGLDisable blend(GL_BLEND); 1320 LLGLDisable blend(GL_BLEND);
1323 LLGLDisable test(GL_ALPHA_TEST); 1321 LLGLDisable test(GL_ALPHA_TEST);
@@ -1334,7 +1332,7 @@ void LLPipeline::doOcclusion(LLCamera& camera)
1334 } 1332 }
1335 } 1333 }
1336 1334
1337 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); 1335 gGL.setColorMask(true, false);
1338 glFlush(); 1336 glFlush();
1339} 1337}
1340 1338
@@ -2262,11 +2260,9 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
2262 LLVertexBuffer::unbind(); 2260 LLVertexBuffer::unbind();
2263 2261
2264 // Do verification of GL state 2262 // Do verification of GL state
2265#ifndef LL_RELEASE_FOR_DOWNLOAD
2266 LLGLState::checkStates(); 2263 LLGLState::checkStates();
2267 LLGLState::checkTextureChannels(); 2264 LLGLState::checkTextureChannels();
2268 LLGLState::checkClientArrays(); 2265 LLGLState::checkClientArrays();
2269#endif
2270 if (mRenderDebugMask & RENDER_DEBUG_VERIFY) 2266 if (mRenderDebugMask & RENDER_DEBUG_VERIFY)
2271 { 2267 {
2272 if (!verify()) 2268 if (!verify())
@@ -2384,19 +2380,18 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
2384 } 2380 }
2385 poolp->endRenderPass(i); 2381 poolp->endRenderPass(i);
2386 LLVertexBuffer::unbind(); 2382 LLVertexBuffer::unbind();
2387#ifndef LL_RELEASE_FOR_DOWNLOAD 2383 if (gDebugGL || gDebugPipeline)
2388# if LL_DEBUG_GL
2389 GLint depth;
2390 glGetIntegerv(GL_MODELVIEW_STACK_DEPTH, &depth);
2391 if (depth > 3)
2392 { 2384 {
2393 llerrs << "GL matrix stack corrupted!" << llendl; 2385 GLint depth;
2386 glGetIntegerv(GL_MODELVIEW_STACK_DEPTH, &depth);
2387 if (depth > 3)
2388 {
2389 llerrs << "GL matrix stack corrupted!" << llendl;
2390 }
2391 LLGLState::checkStates();
2392 LLGLState::checkTextureChannels();
2393 LLGLState::checkClientArrays();
2394 } 2394 }
2395 LLGLState::checkStates();
2396 LLGLState::checkTextureChannels();
2397 LLGLState::checkClientArrays();
2398# endif
2399#endif
2400 } 2395 }
2401 } 2396 }
2402 else 2397 else
@@ -2417,11 +2412,9 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
2417 } 2412 }
2418 2413
2419 LLVertexBuffer::unbind(); 2414 LLVertexBuffer::unbind();
2420#ifndef LL_RELEASE_FOR_DOWNLOAD
2421 LLGLState::checkStates(); 2415 LLGLState::checkStates();
2422 LLGLState::checkTextureChannels(); 2416 LLGLState::checkTextureChannels();
2423 LLGLState::checkClientArrays(); 2417 LLGLState::checkClientArrays();
2424#endif
2425 2418
2426 gGLLastMatrix = NULL; 2419 gGLLastMatrix = NULL;
2427 glLoadMatrixd(gGLModelView); 2420 glLoadMatrixd(gGLModelView);
@@ -2436,12 +2429,10 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
2436 2429
2437 stop_glerror(); 2430 stop_glerror();
2438 2431
2439#ifndef LL_RELEASE_FOR_DOWNLOAD 2432 LLGLState::checkStates();
2440 LLGLState::checkStates(); 2433 LLGLState::checkTextureChannels();
2441 LLGLState::checkTextureChannels(); 2434 LLGLState::checkClientArrays();
2442 LLGLState::checkClientArrays(); 2435
2443#endif
2444
2445 if (!sReflectionRender) 2436 if (!sReflectionRender)
2446 { 2437 {
2447 renderHighlights(); 2438 renderHighlights();
@@ -2475,11 +2466,9 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
2475 2466
2476 LLVertexBuffer::unbind(); 2467 LLVertexBuffer::unbind();
2477 2468
2478#ifndef LL_RELEASE_FOR_DOWNLOAD
2479 LLGLState::checkStates(); 2469 LLGLState::checkStates();
2480 LLGLState::checkTextureChannels(); 2470 LLGLState::checkTextureChannels();
2481 LLGLState::checkClientArrays(); 2471 LLGLState::checkClientArrays();
2482#endif
2483} 2472}
2484 2473
2485void LLPipeline::renderGeomDeferred() 2474void LLPipeline::renderGeomDeferred()
@@ -2514,7 +2503,7 @@ void LLPipeline::renderDebug()
2514 2503
2515 gGLLastMatrix = NULL; 2504 gGLLastMatrix = NULL;
2516 glLoadMatrixd(gGLModelView); 2505 glLoadMatrixd(gGLModelView);
2517 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); 2506 gGL.setColorMask(true, false);
2518 2507
2519 // Debug stuff. 2508 // Debug stuff.
2520 for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); 2509 for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin();
@@ -2585,7 +2574,7 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects)
2585{ 2574{
2586 assertInitialized(); 2575 assertInitialized();
2587 2576
2588 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); 2577 gGL.setColorMask(true, false);
2589 gPipeline.resetDrawOrders(); 2578 gPipeline.resetDrawOrders();
2590 2579
2591 for (std::set<LLViewerObject*>::iterator iter = objects.begin(); iter != objects.end(); ++iter) 2580 for (std::set<LLViewerObject*>::iterator iter = objects.begin(); iter != objects.end(); ++iter)
@@ -2607,12 +2596,11 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects)
2607 LLVertexBuffer::unbind(); 2596 LLVertexBuffer::unbind();
2608 2597
2609 //for each drawpool 2598 //for each drawpool
2610#ifndef LL_RELEASE_FOR_DOWNLOAD
2611 LLGLState::checkStates(); 2599 LLGLState::checkStates();
2612 LLGLState::checkTextureChannels(); 2600 LLGLState::checkTextureChannels();
2613 LLGLState::checkClientArrays(); 2601 LLGLState::checkClientArrays();
2614 U32 last_type = 0; 2602 U32 last_type = 0;
2615#endif 2603
2616 for (pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ++iter) 2604 for (pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ++iter)
2617 { 2605 {
2618 LLDrawPool *poolp = *iter; 2606 LLDrawPool *poolp = *iter;
@@ -2624,7 +2612,6 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects)
2624 gGLLastMatrix = NULL; 2612 gGLLastMatrix = NULL;
2625 glLoadMatrixd(gGLModelView); 2613 glLoadMatrixd(gGLModelView);
2626 2614
2627#ifndef LL_RELEASE_FOR_DOWNLOAD
2628 if (poolp->getType() != last_type) 2615 if (poolp->getType() != last_type)
2629 { 2616 {
2630 last_type = poolp->getType(); 2617 last_type = poolp->getType();
@@ -2632,32 +2619,21 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects)
2632 LLGLState::checkTextureChannels(); 2619 LLGLState::checkTextureChannels();
2633 LLGLState::checkClientArrays(); 2620 LLGLState::checkClientArrays();
2634 } 2621 }
2635#endif
2636 } 2622 }
2637 } 2623 }
2638 2624
2639 LLGLEnable alpha_test(GL_ALPHA_TEST); 2625 LLGLEnable alpha_test(GL_ALPHA_TEST);
2640 if (gPickTransparent) 2626 if (gPickTransparent)
2641 { 2627 {
2642 glAlphaFunc(GL_GEQUAL, 0.0f); 2628 gGL.setAlphaRejectSettings(LLRender::CF_GREATER_EQUAL, 0.f);
2643 } 2629 }
2644 else 2630 else
2645 { 2631 {
2646 glAlphaFunc(GL_GREATER, 0.2f); 2632 gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.2f);
2647 } 2633 }
2648 2634
2649 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); 2635 gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_VERT_COLOR);
2650 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE); 2636 gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_ALPHA, LLTexUnit::TBS_VERT_ALPHA);
2651 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE);
2652
2653 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PRIMARY_COLOR);
2654 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
2655
2656 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE);
2657 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
2658
2659 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, GL_PRIMARY_COLOR_ARB);
2660 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, GL_SRC_ALPHA);
2661 2637
2662 U32 prim_mask = LLVertexBuffer::MAP_VERTEX | 2638 U32 prim_mask = LLVertexBuffer::MAP_VERTEX |
2663 LLVertexBuffer::MAP_TEXCOORD; 2639 LLVertexBuffer::MAP_TEXCOORD;
@@ -2758,12 +2734,11 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects)
2758 glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); 2734 glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]);
2759 } 2735 }
2760 2736
2761 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 2737 gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
2762 2738
2763 LLVertexBuffer::unbind(); 2739 LLVertexBuffer::unbind();
2764 LLVertexBuffer::unbind();
2765 2740
2766 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 2741 gGL.setColorMask(true, true);
2767} 2742}
2768 2743
2769void LLPipeline::renderFaceForUVSelect(LLFace* facep) 2744void LLPipeline::renderFaceForUVSelect(LLFace* facep)
@@ -4118,11 +4093,9 @@ void apply_cube_face_rotation(U32 face)
4118} 4093}
4119void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam) 4094void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam)
4120{ 4095{
4121#ifndef LL_RELEASE_FOR_DOWNLOAD
4122 LLGLState::checkStates(); 4096 LLGLState::checkStates();
4123 LLGLState::checkTextureChannels(); 4097 LLGLState::checkTextureChannels();
4124 LLGLState::checkClientArrays(); 4098 LLGLState::checkClientArrays();
4125#endif
4126 4099
4127 assertInitialized(); 4100 assertInitialized();
4128 4101
@@ -4140,10 +4113,7 @@ void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam)
4140 glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_TEXTURE_WIDTH, &width); 4113 glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_TEXTURE_WIDTH, &width);
4141 if (width != res) 4114 if (width != res)
4142 { 4115 {
4143 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 4116 cube_map->setReflection();
4144 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
4145 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
4146 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
4147 4117
4148 for (U32 i = 0; i < 6; i++) 4118 for (U32 i = 0; i < 6; i++)
4149 { 4119 {
@@ -4224,9 +4194,9 @@ void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam)
4224 gPipeline.stateSort(cube_cam, result); 4194 gPipeline.stateSort(cube_cam, result);
4225 4195
4226 glClearColor(0,0,0,0); 4196 glClearColor(0,0,0,0);
4227 glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); 4197 gGL.setColorMask(true, true);
4228 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); 4198 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
4229 glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_FALSE); 4199 gGL.setColorMask(true, false);
4230 stop_glerror(); 4200 stop_glerror();
4231 gPipeline.renderGeom(cube_cam); 4201 gPipeline.renderGeom(cube_cam);
4232 } 4202 }
@@ -4254,12 +4224,9 @@ void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam)
4254 LLPipeline::sSkipUpdate = FALSE; 4224 LLPipeline::sSkipUpdate = FALSE;
4255 LLPipeline::sReflectionRender = FALSE; 4225 LLPipeline::sReflectionRender = FALSE;
4256 4226
4257#ifndef LL_RELEASE_FOR_DOWNLOAD
4258 LLGLState::checkStates(); 4227 LLGLState::checkStates();
4259 LLGLState::checkTextureChannels(); 4228 LLGLState::checkTextureChannels();
4260 LLGLState::checkClientArrays(); 4229 LLGLState::checkClientArrays();
4261#endif
4262
4263} 4230}
4264 4231
4265//send cube map vertices and texture coordinates 4232//send cube map vertices and texture coordinates
@@ -4336,18 +4303,16 @@ void validate_framebuffer_object()
4336 4303
4337void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out) 4304void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out)
4338{ 4305{
4339#ifndef LL_RELEASE_FOR_DOWNLOAD
4340 LLGLState::checkStates(); 4306 LLGLState::checkStates();
4341 LLGLState::checkTextureChannels(); 4307 LLGLState::checkTextureChannels();
4342 LLGLState::checkClientArrays(); 4308 LLGLState::checkClientArrays();
4343#endif
4344 4309
4345 assertInitialized(); 4310 assertInitialized();
4346 4311
4347 U32 res = (U32) gSavedSettings.getS32("RenderReflectionRes"); 4312 U32 res = (U32) gSavedSettings.getS32("RenderReflectionRes");
4348 enableLightsFullbright(LLColor4::white); 4313 enableLightsFullbright(LLColor4::white);
4349 LLGLDepthTest depth(GL_FALSE); 4314 LLGLDepthTest depth(GL_FALSE);
4350 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 4315 gGL.setColorMask(true, true);
4351 glMatrixMode(GL_PROJECTION); 4316 glMatrixMode(GL_PROJECTION);
4352 glPushMatrix(); 4317 glPushMatrix();
4353 glLoadIdentity(); 4318 glLoadIdentity();
@@ -4361,10 +4326,7 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out)
4361 glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_TEXTURE_WIDTH, &width); 4326 glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_TEXTURE_WIDTH, &width);
4362 if (width != res) 4327 if (width != res)
4363 { 4328 {
4364 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 4329 cube_out->setReflection();
4365 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
4366 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
4367 glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
4368 4330
4369 for (U32 i = 0; i < 6; i++) 4331 for (U32 i = 0; i < 6; i++)
4370 { 4332 {
@@ -4391,7 +4353,7 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out)
4391 4353
4392 stop_glerror(); 4354 stop_glerror();
4393 glViewport(0,0,res, res); 4355 glViewport(0,0,res, res);
4394 gGL.blendFunc(GL_ONE, GL_ONE); 4356 gGL.setSceneBlendType(LLRender::BT_ADD);
4395 cube_in->enableTexture(0); 4357 cube_in->enableTexture(0);
4396 //3-axis blur 4358 //3-axis blur
4397 for (U32 j = 0; j < 3; j++) 4359 for (U32 j = 0; j < 3; j++)
@@ -4421,7 +4383,7 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out)
4421 gl_cube_face[i], 4383 gl_cube_face[i],
4422 j < 2 ? mBlurCubeTexture[j] : cube_out->getGLName(), 0); 4384 j < 2 ? mBlurCubeTexture[j] : cube_out->getGLName(), 0);
4423 validate_framebuffer_object(); 4385 validate_framebuffer_object();
4424 glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); 4386 gGL.setColorMask(true, true);
4425 glClear(GL_COLOR_BUFFER_BIT); 4387 glClear(GL_COLOR_BUFFER_BIT);
4426 glLoadIdentity(); 4388 glLoadIdentity();
4427 apply_cube_face_rotation(i); 4389 apply_cube_face_rotation(i);
@@ -4441,7 +4403,7 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out)
4441 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0); 4403 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0);
4442 4404
4443 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 4405 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
4444 glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_FALSE); 4406 gGL.setColorMask(true, false);
4445 glMatrixMode(GL_PROJECTION); 4407 glMatrixMode(GL_PROJECTION);
4446 glPopMatrix(); 4408 glPopMatrix();
4447 glMatrixMode(GL_MODELVIEW); 4409 glMatrixMode(GL_MODELVIEW);
@@ -4449,13 +4411,11 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out)
4449 4411
4450 cube_in->disableTexture(); 4412 cube_in->disableTexture();
4451 gViewerWindow->setupViewport(); 4413 gViewerWindow->setupViewport();
4452 gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 4414 gGL.setSceneBlendType(LLRender::BT_ALPHA);
4453 4415
4454#ifndef LL_RELEASE_FOR_DOWNLOAD
4455 LLGLState::checkStates(); 4416 LLGLState::checkStates();
4456 LLGLState::checkTextureChannels(); 4417 LLGLState::checkTextureChannels();
4457 LLGLState::checkClientArrays(); 4418 LLGLState::checkClientArrays();
4458#endif
4459} 4419}
4460 4420
4461void LLPipeline::bindScreenToTexture() 4421void LLPipeline::bindScreenToTexture()
@@ -4471,10 +4431,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
4471 return; 4431 return;
4472 } 4432 }
4473 4433
4474#ifndef LL_RELEASE_FOR_DOWNLOAD
4475 LLGLState::checkStates(); 4434 LLGLState::checkStates();
4476 LLGLState::checkTextureChannels(); 4435 LLGLState::checkTextureChannels();
4477#endif
4478 4436
4479 assertInitialized(); 4437 assertInitialized();
4480 4438
@@ -4494,7 +4452,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
4494 tc2 /= (F32) res_mod; 4452 tc2 /= (F32) res_mod;
4495 } 4453 }
4496 4454
4497 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 4455 gGL.setColorMask(true, true);
4498 4456
4499 LLFastTimer ftm(LLFastTimer::FTM_RENDER_BLOOM); 4457 LLFastTimer ftm(LLFastTimer::FTM_RENDER_BLOOM);
4500 gGL.color4f(1,1,1,1); 4458 gGL.color4f(1,1,1,1);
@@ -4513,7 +4471,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
4513 4471
4514 LLGLDisable test(GL_ALPHA_TEST); 4472 LLGLDisable test(GL_ALPHA_TEST);
4515 4473
4516 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 4474 gGL.setColorMask(true, true);
4517 glClearColor(0,0,0,0); 4475 glClearColor(0,0,0,0);
4518 4476
4519 if (for_snapshot) 4477 if (for_snapshot)
@@ -4525,7 +4483,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
4525 //glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); 4483 //glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
4526 //LLGLDisable blend(GL_BLEND); 4484 //LLGLDisable blend(GL_BLEND);
4527 LLGLEnable blend(GL_BLEND); 4485 LLGLEnable blend(GL_BLEND);
4528 gGL.blendFunc(GL_ONE, GL_ONE); 4486 gGL.setSceneBlendType(LLRender::BT_ADD);
4529 tc2.setVec(1,1); 4487 tc2.setVec(1,1);
4530 gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); 4488 gGL.begin(LLVertexBuffer::TRIANGLE_STRIP);
4531 gGL.color4f(1,1,1,1); 4489 gGL.color4f(1,1,1,1);
@@ -4543,7 +4501,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
4543 gGL.end(); 4501 gGL.end();
4544 4502
4545 gGL.flush(); 4503 gGL.flush();
4546 gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 4504 gGL.setSceneBlendType(LLRender::BT_ALPHA);
4547 } 4505 }
4548 4506
4549 gGL.flush(); 4507 gGL.flush();
@@ -4575,8 +4533,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
4575 gGlowExtractProgram.uniform1f("warmthAmount", warmthAmount); 4533 gGlowExtractProgram.uniform1f("warmthAmount", warmthAmount);
4576 LLGLEnable blend_on(GL_BLEND); 4534 LLGLEnable blend_on(GL_BLEND);
4577 LLGLEnable test(GL_ALPHA_TEST); 4535 LLGLEnable test(GL_ALPHA_TEST);
4578 glAlphaFunc(GL_GREATER, 0.f); 4536 gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
4579 gGL.blendFunc(GL_SRC_ALPHA, GL_ONE); 4537 gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA);
4580 LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); 4538 LLViewerImage::unbindTexture(0, GL_TEXTURE_2D);
4581 4539
4582 glDisable(GL_TEXTURE_2D); 4540 glDisable(GL_TEXTURE_2D);
@@ -4785,26 +4743,17 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
4785 4743
4786 LLGLDisable blend(GL_BLEND); 4744 LLGLDisable blend(GL_BLEND);
4787 4745
4788
4789 //tex unit 0 4746 //tex unit 0
4790 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); 4747 gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_COLOR);
4791 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
4792 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
4793 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
4794 4748
4795 mGlow[1].bindTexture(); 4749 mGlow[1].bindTexture();
4796 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 4750 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
4797 glTexCoordPointer(2, GL_FLOAT, 0, uv0); 4751 glTexCoordPointer(2, GL_FLOAT, 0, uv0);
4798 glActiveTextureARB(GL_TEXTURE1_ARB); 4752 gGL.getTexUnit(1)->activate();
4799 glEnable(GL_TEXTURE_RECTANGLE_ARB); 4753 glEnable(GL_TEXTURE_RECTANGLE_ARB);
4800 4754
4801 //tex unit 1 4755 //tex unit 1
4802 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); 4756 gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_ADD, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR);
4803 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD);
4804 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
4805 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
4806 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE);
4807 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
4808 4757
4809 glClientActiveTextureARB(GL_TEXTURE1_ARB); 4758 glClientActiveTextureARB(GL_TEXTURE1_ARB);
4810 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 4759 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -4819,23 +4768,23 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
4819 4768
4820 glDisable(GL_TEXTURE_RECTANGLE_ARB); 4769 glDisable(GL_TEXTURE_RECTANGLE_ARB);
4821 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 4770 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
4822 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 4771 gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT);
4823 glClientActiveTextureARB(GL_TEXTURE0_ARB); 4772 glClientActiveTextureARB(GL_TEXTURE0_ARB);
4824 glActiveTextureARB(GL_TEXTURE0_ARB); 4773 gGL.getTexUnit(0)->activate();
4825 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 4774 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
4826 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 4775 gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
4827 } 4776 }
4828 4777
4829 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 4778 gGL.setSceneBlendType(LLRender::BT_ALPHA);
4830 glMatrixMode(GL_PROJECTION); 4779 glMatrixMode(GL_PROJECTION);
4831 glPopMatrix(); 4780 glPopMatrix();
4832 glMatrixMode(GL_MODELVIEW); 4781 glMatrixMode(GL_MODELVIEW);
4833 glPopMatrix(); 4782 glPopMatrix();
4834 4783
4835#ifndef LL_RELEASE_FOR_DOWNLOAD 4784 LLVertexBuffer::unbind();
4785
4836 LLGLState::checkStates(); 4786 LLGLState::checkStates();
4837 LLGLState::checkTextureChannels(); 4787 LLGLState::checkTextureChannels();
4838#endif
4839 4788
4840} 4789}
4841 4790
@@ -4867,11 +4816,9 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
4867 { 4816 {
4868 LLVertexBuffer::unbind(); 4817 LLVertexBuffer::unbind();
4869 4818
4870#ifndef LL_RELEASE_FOR_DOWNLOAD
4871 LLGLState::checkStates(); 4819 LLGLState::checkStates();
4872 LLGLState::checkTextureChannels(); 4820 LLGLState::checkTextureChannels();
4873 LLGLState::checkClientArrays(); 4821 LLGLState::checkClientArrays();
4874#endif
4875 4822
4876 LLCamera camera = camera_in; 4823 LLCamera camera = camera_in;
4877 camera.setFar(camera.getFar()*0.87654321f); 4824 camera.setFar(camera.getFar()*0.87654321f);
@@ -4916,11 +4863,11 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
4916 { //generate planar reflection map 4863 { //generate planar reflection map
4917 LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); 4864 LLViewerImage::unbindTexture(0, GL_TEXTURE_2D);
4918 glClearColor(0,0,0,0); 4865 glClearColor(0,0,0,0);
4919 glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); 4866 gGL.setColorMask(true, true);
4920 mWaterRef.bindTarget(); 4867 mWaterRef.bindTarget();
4921 mWaterRef.getViewport(gGLViewport); 4868 mWaterRef.getViewport(gGLViewport);
4922 mWaterRef.clear(); 4869 mWaterRef.clear();
4923 glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_FALSE); 4870 gGL.setColorMask(true, false);
4924 4871
4925 stop_glerror(); 4872 stop_glerror();
4926 4873
@@ -5022,11 +4969,11 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
5022 LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); 4969 LLViewerImage::unbindTexture(0, GL_TEXTURE_2D);
5023 LLColor4& col = LLDrawPoolWater::sWaterFogColor; 4970 LLColor4& col = LLDrawPoolWater::sWaterFogColor;
5024 glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); 4971 glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f);
5025 glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); 4972 gGL.setColorMask(true, true);
5026 mWaterDis.bindTarget(); 4973 mWaterDis.bindTarget();
5027 mWaterDis.getViewport(gGLViewport); 4974 mWaterDis.getViewport(gGLViewport);
5028 mWaterDis.clear(); 4975 mWaterDis.clear();
5029 glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_FALSE); 4976 gGL.setColorMask(true, false);
5030 4977
5031 if (!LLPipeline::sUnderWaterRender || LLDrawPoolWater::sNeedsReflectionUpdate) 4978 if (!LLPipeline::sUnderWaterRender || LLDrawPoolWater::sNeedsReflectionUpdate)
5032 { 4979 {
@@ -5060,11 +5007,9 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
5060 LLViewerCamera::getInstance()->setUserClipPlane(LLPlane(-pnorm, -pd)); 5007 LLViewerCamera::getInstance()->setUserClipPlane(LLPlane(-pnorm, -pd));
5061 LLPipeline::sUseOcclusion = occlusion; 5008 LLPipeline::sUseOcclusion = occlusion;
5062 5009
5063#ifndef LL_RELEASE_FOR_DOWNLOAD
5064 LLGLState::checkStates(); 5010 LLGLState::checkStates();
5065 LLGLState::checkTextureChannels(); 5011 LLGLState::checkTextureChannels();
5066 LLGLState::checkClientArrays(); 5012 LLGLState::checkClientArrays();
5067#endif
5068 } 5013 }
5069} 5014}
5070 5015
@@ -5203,7 +5148,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
5203 glh_set_current_modelview(mat); 5148 glh_set_current_modelview(mat);
5204 5149
5205 glClearColor(0.0f,0.0f,0.0f,0.0f); 5150 glClearColor(0.0f,0.0f,0.0f,0.0f);
5206 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 5151 gGL.setColorMask(true, true);
5207 glStencilMask(0xFFFFFFFF); 5152 glStencilMask(0xFFFFFFFF);
5208 glClearStencil(0); 5153 glClearStencil(0);
5209 5154
@@ -5250,14 +5195,14 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
5250 5195
5251 if (muted) 5196 if (muted)
5252 { 5197 {
5253 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 5198 gGL.setColorMask(true, true);
5254 } 5199 }
5255 else 5200 else
5256 { 5201 {
5257 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); 5202 gGL.setColorMask(false, true);
5258 } 5203 }
5259 5204
5260 gGL.blendFunc(GL_ONE, GL_ONE); 5205 gGL.setSceneBlendType(LLRender::BT_ADD);
5261 LLImageGL::unbindTexture(0, GL_TEXTURE_2D); 5206 LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
5262 5207
5263 LLGLDepthTest depth(GL_FALSE, GL_FALSE); 5208 LLGLDepthTest depth(GL_FALSE, GL_FALSE);
@@ -5273,7 +5218,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
5273 gGL.flush(); 5218 gGL.flush();
5274 5219
5275 5220
5276 gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 5221 gGL.setSceneBlendType(LLRender::BT_ALPHA);
5277 } 5222 }
5278 5223
5279 5224