diff options
author | Jacek Antonelli | 2008-12-01 17:39:58 -0600 |
---|---|---|
committer | Jacek Antonelli | 2008-12-01 17:40:06 -0600 |
commit | 7abecb48babe6a6f09bf6692ba55076546cfced9 (patch) | |
tree | 8d18a88513fb97adf32c10aae78f4be1984942db /linden/indra/newview/pipeline.cpp | |
parent | Second Life viewer sources 1.21.6 (diff) | |
download | meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.zip meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.tar.gz meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.tar.bz2 meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.tar.xz |
Second Life viewer sources 1.22.0-RC
Diffstat (limited to 'linden/indra/newview/pipeline.cpp')
-rw-r--r-- | linden/indra/newview/pipeline.cpp | 187 |
1 files changed, 128 insertions, 59 deletions
diff --git a/linden/indra/newview/pipeline.cpp b/linden/indra/newview/pipeline.cpp index f232fdf..81f1a90 100644 --- a/linden/indra/newview/pipeline.cpp +++ b/linden/indra/newview/pipeline.cpp | |||
@@ -330,8 +330,15 @@ void LLPipeline::init() | |||
330 | mRenderDebugFeatureMask = 0xffffffff; // All debugging features on | 330 | mRenderDebugFeatureMask = 0xffffffff; // All debugging features on |
331 | mRenderDebugMask = 0; // All debug starts off | 331 | mRenderDebugMask = 0; // All debug starts off |
332 | 332 | ||
333 | // Don't turn on ground when this is set | ||
334 | // Mac Books with intel 950s need this | ||
335 | if(!gSavedSettings.getBOOL("RenderGround")) | ||
336 | { | ||
337 | toggleRenderType(RENDER_TYPE_GROUND); | ||
338 | } | ||
339 | |||
333 | mOldRenderDebugMask = mRenderDebugMask; | 340 | mOldRenderDebugMask = mRenderDebugMask; |
334 | 341 | ||
335 | mBackfaceCull = TRUE; | 342 | mBackfaceCull = TRUE; |
336 | 343 | ||
337 | stop_glerror(); | 344 | stop_glerror(); |
@@ -454,7 +461,7 @@ void LLPipeline::resizeScreenTexture() | |||
454 | } | 461 | } |
455 | 462 | ||
456 | mScreen.release(); | 463 | mScreen.release(); |
457 | mScreen.allocate(resX, resY, GL_RGBA, TRUE, GL_TEXTURE_RECTANGLE_ARB); | 464 | mScreen.allocate(resX, resY, GL_RGBA, TRUE, LLTexUnit::TT_RECT_TEXTURE); |
458 | 465 | ||
459 | llinfos << "RESIZED SCREEN TEXTURE: " << resX << "x" << resY << llendl; | 466 | llinfos << "RESIZED SCREEN TEXTURE: " << resX << "x" << resY << llendl; |
460 | } | 467 | } |
@@ -556,7 +563,7 @@ void LLPipeline::createGLBuffers() | |||
556 | 563 | ||
557 | for (U32 j = 0; j < 3; j++) | 564 | for (U32 j = 0; j < 3; j++) |
558 | { | 565 | { |
559 | glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mBlurCubeTexture[j]); | 566 | gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_CUBE_MAP, mBlurCubeTexture[j]); |
560 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 567 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
561 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 568 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
562 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 569 | glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
@@ -583,10 +590,11 @@ void LLPipeline::createGLBuffers() | |||
583 | mGlow[i].allocate(512,glow_res,GL_RGBA,FALSE); | 590 | mGlow[i].allocate(512,glow_res,GL_RGBA,FALSE); |
584 | } | 591 | } |
585 | 592 | ||
593 | |||
586 | GLuint resX = gViewerWindow->getWindowDisplayWidth(); | 594 | GLuint resX = gViewerWindow->getWindowDisplayWidth(); |
587 | GLuint resY = gViewerWindow->getWindowDisplayHeight(); | 595 | GLuint resY = gViewerWindow->getWindowDisplayHeight(); |
588 | 596 | ||
589 | mScreen.allocate(resX, resY, GL_RGBA, TRUE, GL_TEXTURE_RECTANGLE_ARB); | 597 | mScreen.allocate(resX, resY, GL_RGBA, TRUE, LLTexUnit::TT_RECT_TEXTURE); |
590 | } | 598 | } |
591 | } | 599 | } |
592 | 600 | ||
@@ -1212,7 +1220,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl | |||
1212 | LLVertexBuffer::unbind(); | 1220 | LLVertexBuffer::unbind(); |
1213 | LLGLDisable blend(GL_BLEND); | 1221 | LLGLDisable blend(GL_BLEND); |
1214 | LLGLDisable test(GL_ALPHA_TEST); | 1222 | LLGLDisable test(GL_ALPHA_TEST); |
1215 | LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); | 1223 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
1216 | 1224 | ||
1217 | gGL.setColorMask(false, false); | 1225 | gGL.setColorMask(false, false); |
1218 | LLGLDepthTest depth(GL_TRUE, GL_FALSE); | 1226 | LLGLDepthTest depth(GL_TRUE, GL_FALSE); |
@@ -1357,7 +1365,7 @@ void LLPipeline::doOcclusion(LLCamera& camera) | |||
1357 | } | 1365 | } |
1358 | LLGLDisable blend(GL_BLEND); | 1366 | LLGLDisable blend(GL_BLEND); |
1359 | LLGLDisable test(GL_ALPHA_TEST); | 1367 | LLGLDisable test(GL_ALPHA_TEST); |
1360 | LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); | 1368 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
1361 | LLGLDepthTest depth(GL_TRUE, GL_FALSE); | 1369 | LLGLDepthTest depth(GL_TRUE, GL_FALSE); |
1362 | 1370 | ||
1363 | if (LLPipeline::sUseOcclusion > 1) | 1371 | if (LLPipeline::sUseOcclusion > 1) |
@@ -2368,7 +2376,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) | |||
2368 | sUnderWaterRender = FALSE; | 2376 | sUnderWaterRender = FALSE; |
2369 | } | 2377 | } |
2370 | 2378 | ||
2371 | LLViewerImage::sDefaultImagep->bind(0); | 2379 | gGL.getTexUnit(0)->bind(LLViewerImage::sDefaultImagep); |
2372 | LLViewerImage::sDefaultImagep->setClamp(FALSE, FALSE); | 2380 | LLViewerImage::sDefaultImagep->setClamp(FALSE, FALSE); |
2373 | 2381 | ||
2374 | ////////////////////////////////////////////// | 2382 | ////////////////////////////////////////////// |
@@ -2604,11 +2612,11 @@ void LLPipeline::renderDebug() | |||
2604 | // Debug composition layers | 2612 | // Debug composition layers |
2605 | F32 x, y; | 2613 | F32 x, y; |
2606 | 2614 | ||
2607 | LLGLSNoTexture gls_no_texture; | 2615 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
2608 | 2616 | ||
2609 | if (gAgent.getRegion()) | 2617 | if (gAgent.getRegion()) |
2610 | { | 2618 | { |
2611 | gGL.begin(LLVertexBuffer::POINTS); | 2619 | gGL.begin(LLRender::POINTS); |
2612 | // Draw the composition layer for the region that I'm in. | 2620 | // Draw the composition layer for the region that I'm in. |
2613 | for (x = 0; x <= 260; x++) | 2621 | for (x = 0; x <= 260; x++) |
2614 | { | 2622 | { |
@@ -2654,6 +2662,7 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects, BOOL render | |||
2654 | 2662 | ||
2655 | LLGLSDefault gls_default; | 2663 | LLGLSDefault gls_default; |
2656 | LLGLSObjectSelect gls_object_select; | 2664 | LLGLSObjectSelect gls_object_select; |
2665 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); | ||
2657 | LLGLDepthTest gls_depth(GL_TRUE,GL_TRUE); | 2666 | LLGLDepthTest gls_depth(GL_TRUE,GL_TRUE); |
2658 | disableLights(); | 2667 | disableLights(); |
2659 | 2668 | ||
@@ -2665,6 +2674,18 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects, BOOL render | |||
2665 | LLGLState::checkClientArrays(); | 2674 | LLGLState::checkClientArrays(); |
2666 | U32 last_type = 0; | 2675 | U32 last_type = 0; |
2667 | 2676 | ||
2677 | // If we don't do this, we crash something on changing graphics settings | ||
2678 | // from Medium -> Low, because we unload all the shaders and the | ||
2679 | // draw pools aren't aware. I don't know if this has to be a separate | ||
2680 | // loop before actual rendering. JC | ||
2681 | for (pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ++iter) | ||
2682 | { | ||
2683 | LLDrawPool *poolp = *iter; | ||
2684 | if (poolp->isFacePool() && hasRenderType(poolp->getType())) | ||
2685 | { | ||
2686 | poolp->prerender(); | ||
2687 | } | ||
2688 | } | ||
2668 | for (pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ++iter) | 2689 | for (pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ++iter) |
2669 | { | 2690 | { |
2670 | LLDrawPool *poolp = *iter; | 2691 | LLDrawPool *poolp = *iter; |
@@ -3089,7 +3110,7 @@ void LLPipeline::setupAvatarLights(BOOL for_edit) | |||
3089 | camera_rot.invert(); | 3110 | camera_rot.invert(); |
3090 | LLVector4 light_pos = light_pos_cam * camera_rot; | 3111 | LLVector4 light_pos = light_pos_cam * camera_rot; |
3091 | 3112 | ||
3092 | light_pos.normVec(); | 3113 | light_pos.normalize(); |
3093 | 3114 | ||
3094 | mHWLightColors[1] = diffuse; | 3115 | mHWLightColors[1] = diffuse; |
3095 | glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse.mV); | 3116 | glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse.mV); |
@@ -3107,7 +3128,7 @@ void LLPipeline::setupAvatarLights(BOOL for_edit) | |||
3107 | LLVector3 opposite_pos = -1.f * mSunDir; | 3128 | LLVector3 opposite_pos = -1.f * mSunDir; |
3108 | LLVector3 orthog_light_pos = mSunDir % LLVector3::z_axis; | 3129 | LLVector3 orthog_light_pos = mSunDir % LLVector3::z_axis; |
3109 | LLVector4 backlight_pos = LLVector4(lerp(opposite_pos, orthog_light_pos, 0.3f), 0.0f); | 3130 | LLVector4 backlight_pos = LLVector4(lerp(opposite_pos, orthog_light_pos, 0.3f), 0.0f); |
3110 | backlight_pos.normVec(); | 3131 | backlight_pos.normalize(); |
3111 | 3132 | ||
3112 | LLColor4 light_diffuse = mSunDiffuse; | 3133 | LLColor4 light_diffuse = mSunDiffuse; |
3113 | LLColor4 backlight_diffuse(1.f - light_diffuse.mV[VRED], 1.f - light_diffuse.mV[VGREEN], 1.f - light_diffuse.mV[VBLUE], 1.f); | 3134 | LLColor4 backlight_diffuse(1.f - light_diffuse.mV[VRED], 1.f - light_diffuse.mV[VGREEN], 1.f - light_diffuse.mV[VBLUE], 1.f); |
@@ -3446,7 +3467,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) | |||
3446 | atten = x / (light_radius); // % of brightness at radius | 3467 | atten = x / (light_radius); // % of brightness at radius |
3447 | quad = 0.0f; | 3468 | quad = 0.0f; |
3448 | } | 3469 | } |
3449 | //mHWLightColors[cur_light] = light_color; | 3470 | mHWLightColors[2] = light_color; |
3450 | S32 gllight = GL_LIGHT2; | 3471 | S32 gllight = GL_LIGHT2; |
3451 | glLightfv(gllight, GL_POSITION, light_pos_gl.mV); | 3472 | glLightfv(gllight, GL_POSITION, light_pos_gl.mV); |
3452 | glLightfv(gllight, GL_DIFFUSE, light_color.mV); | 3473 | glLightfv(gllight, GL_DIFFUSE, light_color.mV); |
@@ -3987,6 +4008,7 @@ BOOL LLPipeline::getRenderHighlights(void*) | |||
3987 | } | 4008 | } |
3988 | 4009 | ||
3989 | LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start, const LLVector3& end, | 4010 | LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start, const LLVector3& end, |
4011 | BOOL pick_transparent, | ||
3990 | S32* face_hit, | 4012 | S32* face_hit, |
3991 | LLVector3* intersection, // return the intersection point | 4013 | LLVector3* intersection, // return the intersection point |
3992 | LLVector2* tex_coord, // return the texture coordinates of the intersection point | 4014 | LLVector2* tex_coord, // return the texture coordinates of the intersection point |
@@ -3996,6 +4018,10 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start, | |||
3996 | { | 4018 | { |
3997 | LLDrawable* drawable = NULL; | 4019 | LLDrawable* drawable = NULL; |
3998 | 4020 | ||
4021 | LLVector3 local_end = end; | ||
4022 | |||
4023 | LLVector3 position; | ||
4024 | |||
3999 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); | 4025 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); |
4000 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | 4026 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) |
4001 | { | 4027 | { |
@@ -4003,24 +4029,49 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start, | |||
4003 | 4029 | ||
4004 | for (U32 j = 0; j < LLViewerRegion::NUM_PARTITIONS; j++) | 4030 | for (U32 j = 0; j < LLViewerRegion::NUM_PARTITIONS; j++) |
4005 | { | 4031 | { |
4006 | if ((j == LLViewerRegion::PARTITION_VOLUME) || (j == LLViewerRegion::PARTITION_BRIDGE)) // only check these partitions for now | 4032 | if ((j == LLViewerRegion::PARTITION_VOLUME) || |
4033 | (j == LLViewerRegion::PARTITION_BRIDGE) || | ||
4034 | (j == LLViewerRegion::PARTITION_TERRAIN) || | ||
4035 | (j == LLViewerRegion::PARTITION_TREE) || | ||
4036 | (j == LLViewerRegion::PARTITION_GRASS)) // only check these partitions for now | ||
4007 | { | 4037 | { |
4008 | LLSpatialPartition* part = region->getSpatialPartition(j); | 4038 | LLSpatialPartition* part = region->getSpatialPartition(j); |
4009 | if (part) | 4039 | if (part && hasRenderType(part->mDrawableType)) |
4010 | { | 4040 | { |
4011 | LLDrawable* hit = part->lineSegmentIntersect(start, end, face_hit, intersection, tex_coord, normal, bi_normal); | 4041 | LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, face_hit, &position, tex_coord, normal, bi_normal); |
4012 | if (hit) | 4042 | if (hit) |
4013 | { | 4043 | { |
4014 | drawable = hit; | 4044 | drawable = hit; |
4045 | local_end = position; | ||
4015 | } | 4046 | } |
4016 | } | 4047 | } |
4017 | } | 4048 | } |
4018 | } | 4049 | } |
4019 | } | 4050 | } |
4051 | |||
4052 | //check all avatar nametags (silly, isn't it?) | ||
4053 | for (std::vector< LLCharacter* >::iterator iter = LLCharacter::sInstances.begin(); | ||
4054 | iter != LLCharacter::sInstances.end(); | ||
4055 | ++iter) | ||
4056 | { | ||
4057 | LLVOAvatar* av = (LLVOAvatar*) *iter; | ||
4058 | if (av->mNameText.notNull() && av->mNameText->lineSegmentIntersect(start, local_end, position)) | ||
4059 | { | ||
4060 | drawable = av->mDrawable; | ||
4061 | local_end = position; | ||
4062 | } | ||
4063 | } | ||
4064 | |||
4065 | if (intersection) | ||
4066 | { | ||
4067 | *intersection = position; | ||
4068 | } | ||
4069 | |||
4020 | return drawable ? drawable->getVObj().get() : NULL; | 4070 | return drawable ? drawable->getVObj().get() : NULL; |
4021 | } | 4071 | } |
4022 | 4072 | ||
4023 | LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector3& start, const LLVector3& end, | 4073 | LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector3& start, const LLVector3& end, |
4074 | BOOL pick_transparent, | ||
4024 | S32* face_hit, | 4075 | S32* face_hit, |
4025 | LLVector3* intersection, // return the intersection point | 4076 | LLVector3* intersection, // return the intersection point |
4026 | LLVector2* tex_coord, // return the texture coordinates of the intersection point | 4077 | LLVector2* tex_coord, // return the texture coordinates of the intersection point |
@@ -4035,15 +4086,27 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector3& start, co | |||
4035 | { | 4086 | { |
4036 | LLViewerRegion* region = *iter; | 4087 | LLViewerRegion* region = *iter; |
4037 | 4088 | ||
4089 | BOOL toggle = FALSE; | ||
4090 | if (!hasRenderType(LLPipeline::RENDER_TYPE_HUD)) | ||
4091 | { | ||
4092 | toggleRenderType(LLPipeline::RENDER_TYPE_HUD); | ||
4093 | toggle = TRUE; | ||
4094 | } | ||
4095 | |||
4038 | LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_HUD); | 4096 | LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_HUD); |
4039 | if (part) | 4097 | if (part) |
4040 | { | 4098 | { |
4041 | LLDrawable* hit = part->lineSegmentIntersect(start, end, face_hit, intersection, tex_coord, normal, bi_normal); | 4099 | LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, face_hit, intersection, tex_coord, normal, bi_normal); |
4042 | if (hit) | 4100 | if (hit) |
4043 | { | 4101 | { |
4044 | drawable = hit; | 4102 | drawable = hit; |
4045 | } | 4103 | } |
4046 | } | 4104 | } |
4105 | |||
4106 | if (toggle) | ||
4107 | { | ||
4108 | toggleRenderType(LLPipeline::RENDER_TYPE_HUD); | ||
4109 | } | ||
4047 | } | 4110 | } |
4048 | return drawable ? drawable->getVObj().get() : NULL; | 4111 | return drawable ? drawable->getVObj().get() : NULL; |
4049 | } | 4112 | } |
@@ -4197,7 +4260,8 @@ void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam) | |||
4197 | 4260 | ||
4198 | LLPipeline::sReflectionRender = TRUE; | 4261 | LLPipeline::sReflectionRender = TRUE; |
4199 | 4262 | ||
4200 | cube_map->bind(); | 4263 | gGL.getTexUnit(cube_map->getStage())->bind(cube_map); |
4264 | gGL.getTexUnit(0)->activate(); | ||
4201 | GLint width; | 4265 | GLint width; |
4202 | glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_TEXTURE_WIDTH, &width); | 4266 | glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_TEXTURE_WIDTH, &width); |
4203 | if (width != res) | 4267 | if (width != res) |
@@ -4209,8 +4273,10 @@ void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam) | |||
4209 | glTexImage2D(gl_cube_face[i], 0, GL_RGBA, res, res, 0, GL_RGBA, GL_FLOAT, NULL); | 4273 | glTexImage2D(gl_cube_face[i], 0, GL_RGBA, res, res, 0, GL_RGBA, GL_FLOAT, NULL); |
4210 | } | 4274 | } |
4211 | } | 4275 | } |
4212 | glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0); | 4276 | gGL.getTexUnit(cube_map->getStage())->unbind(LLTexUnit::TT_CUBE_MAP); |
4213 | cube_map->disable(); | 4277 | gGL.getTexUnit(cube_map->getStage())->disable(); |
4278 | gGL.getTexUnit(0)->activate(); | ||
4279 | gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); | ||
4214 | 4280 | ||
4215 | BOOL toggle_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI); | 4281 | BOOL toggle_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI); |
4216 | if (toggle_ui) | 4282 | if (toggle_ui) |
@@ -4254,7 +4320,7 @@ void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam) | |||
4254 | gPipeline.calcNearbyLights(cube_cam); | 4320 | gPipeline.calcNearbyLights(cube_cam); |
4255 | 4321 | ||
4256 | stop_glerror(); | 4322 | stop_glerror(); |
4257 | LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); | 4323 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
4258 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mCubeFrameBuffer); | 4324 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mCubeFrameBuffer); |
4259 | glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, | 4325 | glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, |
4260 | GL_RENDERBUFFER_EXT, mCubeDepth); | 4326 | GL_RENDERBUFFER_EXT, mCubeDepth); |
@@ -4410,7 +4476,8 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out) | |||
4410 | glPushMatrix(); | 4476 | glPushMatrix(); |
4411 | 4477 | ||
4412 | cube_out->enableTexture(0); | 4478 | cube_out->enableTexture(0); |
4413 | cube_out->bind(); | 4479 | gGL.getTexUnit(cube_out->getStage())->bind(cube_out); |
4480 | gGL.getTexUnit(0)->activate(); | ||
4414 | GLint width; | 4481 | GLint width; |
4415 | glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_TEXTURE_WIDTH, &width); | 4482 | glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_TEXTURE_WIDTH, &width); |
4416 | if (width != res) | 4483 | if (width != res) |
@@ -4422,8 +4489,8 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out) | |||
4422 | glTexImage2D(gl_cube_face[i], 0, GL_RGBA, res, res, 0, GL_RGBA, GL_FLOAT, NULL); | 4489 | glTexImage2D(gl_cube_face[i], 0, GL_RGBA, res, res, 0, GL_RGBA, GL_FLOAT, NULL); |
4423 | } | 4490 | } |
4424 | } | 4491 | } |
4425 | glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0); | 4492 | gGL.getTexUnit(cube_out->getStage())->unbind(LLTexUnit::TT_CUBE_MAP); |
4426 | 4493 | gGL.getTexUnit(0)->activate(); | |
4427 | glViewport(0, 0, res, res); | 4494 | glViewport(0, 0, res, res); |
4428 | LLGLEnable blend(GL_BLEND); | 4495 | LLGLEnable blend(GL_BLEND); |
4429 | 4496 | ||
@@ -4451,16 +4518,17 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out) | |||
4451 | 4518 | ||
4452 | if (j == 0) | 4519 | if (j == 0) |
4453 | { | 4520 | { |
4454 | cube_in->bind(); | 4521 | gGL.getTexUnit(cube_in->getStage())->bind(cube_in); |
4455 | } | 4522 | } |
4456 | else | 4523 | else |
4457 | { | 4524 | { |
4458 | glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mBlurCubeTexture[j-1]); | 4525 | gGL.getTexUnit(cube_in->getStage())->bindManual(LLTexUnit::TT_CUBE_MAP, mBlurCubeTexture[j-1]); |
4459 | } | 4526 | } |
4527 | gGL.getTexUnit(0)->activate(); | ||
4460 | 4528 | ||
4461 | stop_glerror(); | 4529 | stop_glerror(); |
4462 | 4530 | ||
4463 | LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); | 4531 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
4464 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mBlurCubeBuffer[j]); | 4532 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mBlurCubeBuffer[j]); |
4465 | stop_glerror(); | 4533 | stop_glerror(); |
4466 | 4534 | ||
@@ -4489,7 +4557,7 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out) | |||
4489 | 4557 | ||
4490 | stop_glerror(); | 4558 | stop_glerror(); |
4491 | 4559 | ||
4492 | glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0); | 4560 | gGL.getTexUnit(cube_in->getStage())->unbind(LLTexUnit::TT_CUBE_MAP); |
4493 | 4561 | ||
4494 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); | 4562 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); |
4495 | gGL.setColorMask(true, false); | 4563 | gGL.setColorMask(true, false); |
@@ -4498,7 +4566,8 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out) | |||
4498 | glMatrixMode(GL_MODELVIEW); | 4566 | glMatrixMode(GL_MODELVIEW); |
4499 | glPopMatrix(); | 4567 | glPopMatrix(); |
4500 | 4568 | ||
4501 | cube_in->disableTexture(); | 4569 | gGL.getTexUnit(cube_in->getStage())->disable(); |
4570 | gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); | ||
4502 | gViewerWindow->setupViewport(); | 4571 | gViewerWindow->setupViewport(); |
4503 | gGL.setSceneBlendType(LLRender::BT_ALPHA); | 4572 | gGL.setSceneBlendType(LLRender::BT_ALPHA); |
4504 | 4573 | ||
@@ -4566,7 +4635,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot) | |||
4566 | 4635 | ||
4567 | if (for_snapshot) | 4636 | if (for_snapshot) |
4568 | { | 4637 | { |
4569 | mGlow[1].bindTexture(); | 4638 | gGL.getTexUnit(0)->bind(&mGlow[1]); |
4570 | { | 4639 | { |
4571 | //LLGLEnable stencil(GL_STENCIL_TEST); | 4640 | //LLGLEnable stencil(GL_STENCIL_TEST); |
4572 | //glStencilFunc(GL_NOTEQUAL, 255, 0xFFFFFFFF); | 4641 | //glStencilFunc(GL_NOTEQUAL, 255, 0xFFFFFFFF); |
@@ -4575,7 +4644,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot) | |||
4575 | LLGLEnable blend(GL_BLEND); | 4644 | LLGLEnable blend(GL_BLEND); |
4576 | gGL.setSceneBlendType(LLRender::BT_ADD); | 4645 | gGL.setSceneBlendType(LLRender::BT_ADD); |
4577 | tc2.setVec(1,1); | 4646 | tc2.setVec(1,1); |
4578 | gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); | 4647 | gGL.begin(LLRender::TRIANGLE_STRIP); |
4579 | gGL.color4f(1,1,1,1); | 4648 | gGL.color4f(1,1,1,1); |
4580 | gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); | 4649 | gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); |
4581 | gGL.vertex2f(-1,-1); | 4650 | gGL.vertex2f(-1,-1); |
@@ -4625,15 +4694,15 @@ void LLPipeline::renderBloom(BOOL for_snapshot) | |||
4625 | LLGLEnable test(GL_ALPHA_TEST); | 4694 | LLGLEnable test(GL_ALPHA_TEST); |
4626 | gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); | 4695 | gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); |
4627 | gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); | 4696 | gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); |
4628 | LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); | ||
4629 | 4697 | ||
4630 | glDisable(GL_TEXTURE_2D); | 4698 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
4631 | glEnable(GL_TEXTURE_RECTANGLE_ARB); | 4699 | gGL.getTexUnit(0)->disable(); |
4632 | mScreen.bindTexture(); | 4700 | gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); |
4701 | gGL.getTexUnit(0)->bind(&mScreen); | ||
4633 | 4702 | ||
4634 | gGL.color4f(1,1,1,1); | 4703 | gGL.color4f(1,1,1,1); |
4635 | gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); | 4704 | gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); |
4636 | gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); | 4705 | gGL.begin(LLRender::TRIANGLE_STRIP); |
4637 | gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); | 4706 | gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); |
4638 | gGL.vertex2f(-1,-1); | 4707 | gGL.vertex2f(-1,-1); |
4639 | 4708 | ||
@@ -4647,8 +4716,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot) | |||
4647 | gGL.vertex2f(1,1); | 4716 | gGL.vertex2f(1,1); |
4648 | gGL.end(); | 4717 | gGL.end(); |
4649 | 4718 | ||
4650 | glEnable(GL_TEXTURE_2D); | 4719 | gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); |
4651 | glDisable(GL_TEXTURE_RECTANGLE_ARB); | ||
4652 | 4720 | ||
4653 | mGlow[2].flush(); | 4721 | mGlow[2].flush(); |
4654 | } | 4722 | } |
@@ -4678,7 +4746,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot) | |||
4678 | 4746 | ||
4679 | for (S32 i = 0; i < kernel; i++) | 4747 | for (S32 i = 0; i < kernel; i++) |
4680 | { | 4748 | { |
4681 | LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); | 4749 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
4682 | { | 4750 | { |
4683 | LLFastTimer ftm(LLFastTimer::FTM_RENDER_BLOOM_FBO); | 4751 | LLFastTimer ftm(LLFastTimer::FTM_RENDER_BLOOM_FBO); |
4684 | mGlow[i%2].bindTarget(); | 4752 | mGlow[i%2].bindTarget(); |
@@ -4687,11 +4755,11 @@ void LLPipeline::renderBloom(BOOL for_snapshot) | |||
4687 | 4755 | ||
4688 | if (i == 0) | 4756 | if (i == 0) |
4689 | { | 4757 | { |
4690 | mGlow[2].bindTexture(); | 4758 | gGL.getTexUnit(0)->bind(&mGlow[2]); |
4691 | } | 4759 | } |
4692 | else | 4760 | else |
4693 | { | 4761 | { |
4694 | mGlow[(i-1)%2].bindTexture(); | 4762 | gGL.getTexUnit(0)->bind(&mGlow[(i-1)%2]); |
4695 | } | 4763 | } |
4696 | 4764 | ||
4697 | if (i%2 == 0) | 4765 | if (i%2 == 0) |
@@ -4703,7 +4771,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot) | |||
4703 | gGlowProgram.uniform2f("glowDelta", 0, delta); | 4771 | gGlowProgram.uniform2f("glowDelta", 0, delta); |
4704 | } | 4772 | } |
4705 | 4773 | ||
4706 | gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); | 4774 | gGL.begin(LLRender::TRIANGLE_STRIP); |
4707 | gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); | 4775 | gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); |
4708 | gGL.vertex2f(-1,-1); | 4776 | gGL.vertex2f(-1,-1); |
4709 | 4777 | ||
@@ -4768,8 +4836,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot) | |||
4768 | LLGLEnable blend(GL_BLEND); | 4836 | LLGLEnable blend(GL_BLEND); |
4769 | gGL.blendFunc(GL_ONE, GL_ONE); | 4837 | gGL.blendFunc(GL_ONE, GL_ONE); |
4770 | 4838 | ||
4771 | glDisable(GL_TEXTURE_2D); | 4839 | gGL.getTexUnit(0)->disable(); |
4772 | glEnable(GL_TEXTURE_RECTANGLE_ARB); | 4840 | gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); |
4773 | mScreen.bindTexture(); | 4841 | mScreen.bindTexture(); |
4774 | 4842 | ||
4775 | gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); | 4843 | gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); |
@@ -4789,8 +4857,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot) | |||
4789 | 4857 | ||
4790 | gGL.flush(); | 4858 | gGL.flush(); |
4791 | 4859 | ||
4792 | glEnable(GL_TEXTURE_2D); | 4860 | gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); |
4793 | glDisable(GL_TEXTURE_RECTANGLE_ARB); | ||
4794 | 4861 | ||
4795 | gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 4862 | gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
4796 | }*/ | 4863 | }*/ |
@@ -4835,12 +4902,12 @@ void LLPipeline::renderBloom(BOOL for_snapshot) | |||
4835 | 4902 | ||
4836 | //tex unit 0 | 4903 | //tex unit 0 |
4837 | gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_COLOR); | 4904 | gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_COLOR); |
4838 | 4905 | ||
4839 | mGlow[1].bindTexture(); | 4906 | gGL.getTexUnit(0)->bind(&mGlow[1]); |
4840 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 4907 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
4841 | glTexCoordPointer(2, GL_FLOAT, 0, uv0); | 4908 | glTexCoordPointer(2, GL_FLOAT, 0, uv0); |
4842 | gGL.getTexUnit(1)->activate(); | 4909 | gGL.getTexUnit(1)->activate(); |
4843 | glEnable(GL_TEXTURE_RECTANGLE_ARB); | 4910 | gGL.getTexUnit(1)->enable(LLTexUnit::TT_RECT_TEXTURE); |
4844 | 4911 | ||
4845 | //tex unit 1 | 4912 | //tex unit 1 |
4846 | gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_ADD, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR); | 4913 | gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_ADD, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR); |
@@ -4851,14 +4918,16 @@ void LLPipeline::renderBloom(BOOL for_snapshot) | |||
4851 | 4918 | ||
4852 | glVertexPointer(2, GL_FLOAT, 0, v); | 4919 | glVertexPointer(2, GL_FLOAT, 0, v); |
4853 | 4920 | ||
4854 | mScreen.bindTexture(); | 4921 | gGL.getTexUnit(1)->bind(&mScreen); |
4922 | gGL.getTexUnit(1)->activate(); | ||
4855 | 4923 | ||
4856 | LLGLEnable multisample(GL_MULTISAMPLE_ARB); | 4924 | LLGLEnable multisample(GL_MULTISAMPLE_ARB); |
4857 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); | 4925 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
4858 | 4926 | ||
4859 | glDisable(GL_TEXTURE_RECTANGLE_ARB); | 4927 | gGL.getTexUnit(1)->disable(); |
4860 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | 4928 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
4861 | gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT); | 4929 | gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT); |
4930 | |||
4862 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | 4931 | glClientActiveTextureARB(GL_TEXTURE0_ARB); |
4863 | gGL.getTexUnit(0)->activate(); | 4932 | gGL.getTexUnit(0)->activate(); |
4864 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | 4933 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
@@ -4936,7 +5005,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) | |||
4936 | 5005 | ||
4937 | if (!LLViewerCamera::getInstance()->cameraUnderWater()) | 5006 | if (!LLViewerCamera::getInstance()->cameraUnderWater()) |
4938 | { //generate planar reflection map | 5007 | { //generate planar reflection map |
4939 | LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); | 5008 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
4940 | glClearColor(0,0,0,0); | 5009 | glClearColor(0,0,0,0); |
4941 | gGL.setColorMask(true, true); | 5010 | gGL.setColorMask(true, true); |
4942 | mWaterRef.bindTarget(); | 5011 | mWaterRef.bindTarget(); |
@@ -5041,7 +5110,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) | |||
5041 | } | 5110 | } |
5042 | LLViewerCamera::updateFrustumPlanes(camera); | 5111 | LLViewerCamera::updateFrustumPlanes(camera); |
5043 | 5112 | ||
5044 | LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); | 5113 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
5045 | LLColor4& col = LLDrawPoolWater::sWaterFogColor; | 5114 | LLColor4& col = LLDrawPoolWater::sWaterFogColor; |
5046 | glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); | 5115 | glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); |
5047 | gGL.setColorMask(true, true); | 5116 | gGL.setColorMask(true, true); |
@@ -5173,11 +5242,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) | |||
5173 | 5242 | ||
5174 | LLVector3 left = camera.getLeftAxis(); | 5243 | LLVector3 left = camera.getLeftAxis(); |
5175 | left *= left; | 5244 | left *= left; |
5176 | left.normVec(); | 5245 | left.normalize(); |
5177 | 5246 | ||
5178 | LLVector3 up = camera.getUpAxis(); | 5247 | LLVector3 up = camera.getUpAxis(); |
5179 | up *= up; | 5248 | up *= up; |
5180 | up.normVec(); | 5249 | up.normalize(); |
5181 | 5250 | ||
5182 | tdim.mV[0] = fabsf(half_height * left); | 5251 | tdim.mV[0] = fabsf(half_height * left); |
5183 | tdim.mV[1] = fabsf(half_height * up); | 5252 | tdim.mV[1] = fabsf(half_height * up); |
@@ -5218,10 +5287,10 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) | |||
5218 | resY != avatar->mImpostor.getHeight()) | 5287 | resY != avatar->mImpostor.getHeight()) |
5219 | { | 5288 | { |
5220 | avatar->mImpostor.allocate(resX,resY,GL_RGBA,TRUE); | 5289 | avatar->mImpostor.allocate(resX,resY,GL_RGBA,TRUE); |
5221 | avatar->mImpostor.bindTexture(); | 5290 | gGL.getTexUnit(0)->bind(&avatar->mImpostor); |
5222 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 5291 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
5223 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 5292 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
5224 | LLImageGL::unbindTexture(0, GL_TEXTURE_2D); | 5293 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
5225 | } | 5294 | } |
5226 | 5295 | ||
5227 | { | 5296 | { |
@@ -5258,13 +5327,13 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) | |||
5258 | } | 5327 | } |
5259 | 5328 | ||
5260 | gGL.setSceneBlendType(LLRender::BT_ADD); | 5329 | gGL.setSceneBlendType(LLRender::BT_ADD); |
5261 | LLImageGL::unbindTexture(0, GL_TEXTURE_2D); | 5330 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
5262 | 5331 | ||
5263 | LLGLDepthTest depth(GL_FALSE, GL_FALSE); | 5332 | LLGLDepthTest depth(GL_FALSE, GL_FALSE); |
5264 | 5333 | ||
5265 | gGL.color4f(1,1,1,1); | 5334 | gGL.color4f(1,1,1,1); |
5266 | gGL.color4ub(64,64,64,255); | 5335 | gGL.color4ub(64,64,64,255); |
5267 | gGL.begin(LLVertexBuffer::QUADS); | 5336 | gGL.begin(LLRender::QUADS); |
5268 | gGL.vertex3fv((pos+left-up).mV); | 5337 | gGL.vertex3fv((pos+left-up).mV); |
5269 | gGL.vertex3fv((pos-left-up).mV); | 5338 | gGL.vertex3fv((pos-left-up).mV); |
5270 | gGL.vertex3fv((pos-left+up).mV); | 5339 | gGL.vertex3fv((pos-left+up).mV); |