summaryrefslogtreecommitdiff
path: root/indra/newview/pipeline.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/pipeline.cpp')
-rw-r--r--indra/newview/pipeline.cpp167
1 files changed, 112 insertions, 55 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 2bd1831946..817331b990 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -330,8 +330,15 @@ void LLPipeline::init()
mRenderDebugFeatureMask = 0xffffffff; // All debugging features on
mRenderDebugMask = 0; // All debug starts off
+ // Don't turn on ground when this is set
+ // Mac Books with intel 950s need this
+ if(!gSavedSettings.getBOOL("RenderGround"))
+ {
+ toggleRenderType(RENDER_TYPE_GROUND);
+ }
+
mOldRenderDebugMask = mRenderDebugMask;
-
+
mBackfaceCull = TRUE;
stop_glerror();
@@ -454,7 +461,7 @@ void LLPipeline::resizeScreenTexture()
}
mScreen.release();
- mScreen.allocate(resX, resY, GL_RGBA, TRUE, GL_TEXTURE_RECTANGLE_ARB);
+ mScreen.allocate(resX, resY, GL_RGBA, TRUE, LLTexUnit::TT_RECT_TEXTURE);
llinfos << "RESIZED SCREEN TEXTURE: " << resX << "x" << resY << llendl;
}
@@ -556,7 +563,7 @@ void LLPipeline::createGLBuffers()
for (U32 j = 0; j < 3; j++)
{
- glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mBlurCubeTexture[j]);
+ gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_CUBE_MAP, mBlurCubeTexture[j]);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -583,10 +590,11 @@ void LLPipeline::createGLBuffers()
mGlow[i].allocate(512,glow_res,GL_RGBA,FALSE);
}
+
GLuint resX = gViewerWindow->getWindowDisplayWidth();
GLuint resY = gViewerWindow->getWindowDisplayHeight();
-
- mScreen.allocate(resX, resY, GL_RGBA, TRUE, GL_TEXTURE_RECTANGLE_ARB);
+
+ mScreen.allocate(resX, resY, GL_RGBA, TRUE, LLTexUnit::TT_RECT_TEXTURE);
}
}
@@ -1212,7 +1220,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
LLVertexBuffer::unbind();
LLGLDisable blend(GL_BLEND);
LLGLDisable test(GL_ALPHA_TEST);
- LLViewerImage::unbindTexture(0, GL_TEXTURE_2D);
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gGL.setColorMask(false, false);
LLGLDepthTest depth(GL_TRUE, GL_FALSE);
@@ -1357,7 +1365,7 @@ void LLPipeline::doOcclusion(LLCamera& camera)
}
LLGLDisable blend(GL_BLEND);
LLGLDisable test(GL_ALPHA_TEST);
- LLViewerImage::unbindTexture(0, GL_TEXTURE_2D);
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
LLGLDepthTest depth(GL_TRUE, GL_FALSE);
if (LLPipeline::sUseOcclusion > 1)
@@ -2368,7 +2376,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
sUnderWaterRender = FALSE;
}
- LLViewerImage::sDefaultImagep->bind(0);
+ gGL.getTexUnit(0)->bind(LLViewerImage::sDefaultImagep);
LLViewerImage::sDefaultImagep->setClamp(FALSE, FALSE);
//////////////////////////////////////////////
@@ -2604,11 +2612,11 @@ void LLPipeline::renderDebug()
// Debug composition layers
F32 x, y;
- LLGLSNoTexture gls_no_texture;
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
if (gAgent.getRegion())
{
- gGL.begin(LLVertexBuffer::POINTS);
+ gGL.begin(LLRender::POINTS);
// Draw the composition layer for the region that I'm in.
for (x = 0; x <= 260; x++)
{
@@ -2654,6 +2662,7 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects, BOOL render
LLGLSDefault gls_default;
LLGLSObjectSelect gls_object_select;
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
LLGLDepthTest gls_depth(GL_TRUE,GL_TRUE);
disableLights();
@@ -3458,7 +3467,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
atten = x / (light_radius); // % of brightness at radius
quad = 0.0f;
}
- //mHWLightColors[cur_light] = light_color;
+ mHWLightColors[2] = light_color;
S32 gllight = GL_LIGHT2;
glLightfv(gllight, GL_POSITION, light_pos_gl.mV);
glLightfv(gllight, GL_DIFFUSE, light_color.mV);
@@ -3999,6 +4008,7 @@ BOOL LLPipeline::getRenderHighlights(void*)
}
LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start, const LLVector3& end,
+ BOOL pick_transparent,
S32* face_hit,
LLVector3* intersection, // return the intersection point
LLVector2* tex_coord, // return the texture coordinates of the intersection point
@@ -4008,6 +4018,10 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start,
{
LLDrawable* drawable = NULL;
+ LLVector3 local_end = end;
+
+ LLVector3 position;
+
for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin();
iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
{
@@ -4015,24 +4029,49 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start,
for (U32 j = 0; j < LLViewerRegion::NUM_PARTITIONS; j++)
{
- if ((j == LLViewerRegion::PARTITION_VOLUME) || (j == LLViewerRegion::PARTITION_BRIDGE)) // only check these partitions for now
+ if ((j == LLViewerRegion::PARTITION_VOLUME) ||
+ (j == LLViewerRegion::PARTITION_BRIDGE) ||
+ (j == LLViewerRegion::PARTITION_TERRAIN) ||
+ (j == LLViewerRegion::PARTITION_TREE) ||
+ (j == LLViewerRegion::PARTITION_GRASS)) // only check these partitions for now
{
LLSpatialPartition* part = region->getSpatialPartition(j);
- if (part)
+ if (part && hasRenderType(part->mDrawableType))
{
- LLDrawable* hit = part->lineSegmentIntersect(start, end, face_hit, intersection, tex_coord, normal, bi_normal);
+ LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, face_hit, &position, tex_coord, normal, bi_normal);
if (hit)
{
drawable = hit;
+ local_end = position;
}
}
}
}
}
+
+ //check all avatar nametags (silly, isn't it?)
+ for (std::vector< LLCharacter* >::iterator iter = LLCharacter::sInstances.begin();
+ iter != LLCharacter::sInstances.end();
+ ++iter)
+ {
+ LLVOAvatar* av = (LLVOAvatar*) *iter;
+ if (av->mNameText.notNull() && av->mNameText->lineSegmentIntersect(start, local_end, position))
+ {
+ drawable = av->mDrawable;
+ local_end = position;
+ }
+ }
+
+ if (intersection)
+ {
+ *intersection = position;
+ }
+
return drawable ? drawable->getVObj().get() : NULL;
}
LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector3& start, const LLVector3& end,
+ BOOL pick_transparent,
S32* face_hit,
LLVector3* intersection, // return the intersection point
LLVector2* tex_coord, // return the texture coordinates of the intersection point
@@ -4047,15 +4086,27 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector3& start, co
{
LLViewerRegion* region = *iter;
+ BOOL toggle = FALSE;
+ if (!hasRenderType(LLPipeline::RENDER_TYPE_HUD))
+ {
+ toggleRenderType(LLPipeline::RENDER_TYPE_HUD);
+ toggle = TRUE;
+ }
+
LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_HUD);
if (part)
{
- LLDrawable* hit = part->lineSegmentIntersect(start, end, face_hit, intersection, tex_coord, normal, bi_normal);
+ LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, face_hit, intersection, tex_coord, normal, bi_normal);
if (hit)
{
drawable = hit;
}
}
+
+ if (toggle)
+ {
+ toggleRenderType(LLPipeline::RENDER_TYPE_HUD);
+ }
}
return drawable ? drawable->getVObj().get() : NULL;
}
@@ -4209,7 +4260,8 @@ void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam)
LLPipeline::sReflectionRender = TRUE;
- cube_map->bind();
+ gGL.getTexUnit(cube_map->getStage())->bind(cube_map);
+ gGL.getTexUnit(0)->activate();
GLint width;
glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_TEXTURE_WIDTH, &width);
if (width != res)
@@ -4221,8 +4273,10 @@ void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam)
glTexImage2D(gl_cube_face[i], 0, GL_RGBA, res, res, 0, GL_RGBA, GL_FLOAT, NULL);
}
}
- glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0);
- cube_map->disable();
+ gGL.getTexUnit(cube_map->getStage())->unbind(LLTexUnit::TT_CUBE_MAP);
+ gGL.getTexUnit(cube_map->getStage())->disable();
+ gGL.getTexUnit(0)->activate();
+ gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
BOOL toggle_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI);
if (toggle_ui)
@@ -4266,7 +4320,7 @@ void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam)
gPipeline.calcNearbyLights(cube_cam);
stop_glerror();
- LLViewerImage::unbindTexture(0, GL_TEXTURE_2D);
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mCubeFrameBuffer);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, mCubeDepth);
@@ -4422,7 +4476,8 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out)
glPushMatrix();
cube_out->enableTexture(0);
- cube_out->bind();
+ gGL.getTexUnit(cube_out->getStage())->bind(cube_out);
+ gGL.getTexUnit(0)->activate();
GLint width;
glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_TEXTURE_WIDTH, &width);
if (width != res)
@@ -4434,8 +4489,8 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out)
glTexImage2D(gl_cube_face[i], 0, GL_RGBA, res, res, 0, GL_RGBA, GL_FLOAT, NULL);
}
}
- glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0);
-
+ gGL.getTexUnit(cube_out->getStage())->unbind(LLTexUnit::TT_CUBE_MAP);
+ gGL.getTexUnit(0)->activate();
glViewport(0, 0, res, res);
LLGLEnable blend(GL_BLEND);
@@ -4463,16 +4518,17 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out)
if (j == 0)
{
- cube_in->bind();
+ gGL.getTexUnit(cube_in->getStage())->bind(cube_in);
}
else
{
- glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mBlurCubeTexture[j-1]);
+ gGL.getTexUnit(cube_in->getStage())->bindManual(LLTexUnit::TT_CUBE_MAP, mBlurCubeTexture[j-1]);
}
+ gGL.getTexUnit(0)->activate();
stop_glerror();
- LLViewerImage::unbindTexture(0, GL_TEXTURE_2D);
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mBlurCubeBuffer[j]);
stop_glerror();
@@ -4501,7 +4557,7 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out)
stop_glerror();
- glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0);
+ gGL.getTexUnit(cube_in->getStage())->unbind(LLTexUnit::TT_CUBE_MAP);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
gGL.setColorMask(true, false);
@@ -4510,7 +4566,8 @@ void LLPipeline::blurReflectionMap(LLCubeMap* cube_in, LLCubeMap* cube_out)
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
- cube_in->disableTexture();
+ gGL.getTexUnit(cube_in->getStage())->disable();
+ gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
gViewerWindow->setupViewport();
gGL.setSceneBlendType(LLRender::BT_ALPHA);
@@ -4578,7 +4635,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
if (for_snapshot)
{
- mGlow[1].bindTexture();
+ gGL.getTexUnit(0)->bind(&mGlow[1]);
{
//LLGLEnable stencil(GL_STENCIL_TEST);
//glStencilFunc(GL_NOTEQUAL, 255, 0xFFFFFFFF);
@@ -4587,7 +4644,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
LLGLEnable blend(GL_BLEND);
gGL.setSceneBlendType(LLRender::BT_ADD);
tc2.setVec(1,1);
- gGL.begin(LLVertexBuffer::TRIANGLE_STRIP);
+ gGL.begin(LLRender::TRIANGLE_STRIP);
gGL.color4f(1,1,1,1);
gGL.texCoord2f(tc1.mV[0], tc1.mV[1]);
gGL.vertex2f(-1,-1);
@@ -4637,15 +4694,15 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
LLGLEnable test(GL_ALPHA_TEST);
gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA);
- LLViewerImage::unbindTexture(0, GL_TEXTURE_2D);
- glDisable(GL_TEXTURE_2D);
- glEnable(GL_TEXTURE_RECTANGLE_ARB);
- mScreen.bindTexture();
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+ gGL.getTexUnit(0)->disable();
+ gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE);
+ gGL.getTexUnit(0)->bind(&mScreen);
gGL.color4f(1,1,1,1);
gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
- gGL.begin(LLVertexBuffer::TRIANGLE_STRIP);
+ gGL.begin(LLRender::TRIANGLE_STRIP);
gGL.texCoord2f(tc1.mV[0], tc1.mV[1]);
gGL.vertex2f(-1,-1);
@@ -4659,8 +4716,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
gGL.vertex2f(1,1);
gGL.end();
- glEnable(GL_TEXTURE_2D);
- glDisable(GL_TEXTURE_RECTANGLE_ARB);
+ gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
mGlow[2].flush();
}
@@ -4690,7 +4746,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
for (S32 i = 0; i < kernel; i++)
{
- LLViewerImage::unbindTexture(0, GL_TEXTURE_2D);
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
{
LLFastTimer ftm(LLFastTimer::FTM_RENDER_BLOOM_FBO);
mGlow[i%2].bindTarget();
@@ -4699,11 +4755,11 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
if (i == 0)
{
- mGlow[2].bindTexture();
+ gGL.getTexUnit(0)->bind(&mGlow[2]);
}
else
{
- mGlow[(i-1)%2].bindTexture();
+ gGL.getTexUnit(0)->bind(&mGlow[(i-1)%2]);
}
if (i%2 == 0)
@@ -4715,7 +4771,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
gGlowProgram.uniform2f("glowDelta", 0, delta);
}
- gGL.begin(LLVertexBuffer::TRIANGLE_STRIP);
+ gGL.begin(LLRender::TRIANGLE_STRIP);
gGL.texCoord2f(tc1.mV[0], tc1.mV[1]);
gGL.vertex2f(-1,-1);
@@ -4780,8 +4836,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
LLGLEnable blend(GL_BLEND);
gGL.blendFunc(GL_ONE, GL_ONE);
- glDisable(GL_TEXTURE_2D);
- glEnable(GL_TEXTURE_RECTANGLE_ARB);
+ gGL.getTexUnit(0)->disable();
+ gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE);
mScreen.bindTexture();
gGL.begin(LLVertexBuffer::TRIANGLE_STRIP);
@@ -4801,8 +4857,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
gGL.flush();
- glEnable(GL_TEXTURE_2D);
- glDisable(GL_TEXTURE_RECTANGLE_ARB);
+ gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}*/
@@ -4847,12 +4902,12 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
//tex unit 0
gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_COLOR);
-
- mGlow[1].bindTexture();
+
+ gGL.getTexUnit(0)->bind(&mGlow[1]);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, uv0);
gGL.getTexUnit(1)->activate();
- glEnable(GL_TEXTURE_RECTANGLE_ARB);
+ gGL.getTexUnit(1)->enable(LLTexUnit::TT_RECT_TEXTURE);
//tex unit 1
gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_ADD, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR);
@@ -4863,14 +4918,16 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
glVertexPointer(2, GL_FLOAT, 0, v);
- mScreen.bindTexture();
+ gGL.getTexUnit(1)->bind(&mScreen);
+ gGL.getTexUnit(1)->activate();
LLGLEnable multisample(GL_MULTISAMPLE_ARB);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- glDisable(GL_TEXTURE_RECTANGLE_ARB);
+ gGL.getTexUnit(1)->disable();
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT);
+
glClientActiveTextureARB(GL_TEXTURE0_ARB);
gGL.getTexUnit(0)->activate();
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -4948,7 +5005,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
if (!LLViewerCamera::getInstance()->cameraUnderWater())
{ //generate planar reflection map
- LLViewerImage::unbindTexture(0, GL_TEXTURE_2D);
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
glClearColor(0,0,0,0);
gGL.setColorMask(true, true);
mWaterRef.bindTarget();
@@ -5053,7 +5110,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
}
LLViewerCamera::updateFrustumPlanes(camera);
- LLViewerImage::unbindTexture(0, GL_TEXTURE_2D);
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
LLColor4& col = LLDrawPoolWater::sWaterFogColor;
glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f);
gGL.setColorMask(true, true);
@@ -5230,10 +5287,10 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
resY != avatar->mImpostor.getHeight())
{
avatar->mImpostor.allocate(resX,resY,GL_RGBA,TRUE);
- avatar->mImpostor.bindTexture();
+ gGL.getTexUnit(0)->bind(&avatar->mImpostor);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
}
{
@@ -5270,13 +5327,13 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
}
gGL.setSceneBlendType(LLRender::BT_ADD);
- LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
LLGLDepthTest depth(GL_FALSE, GL_FALSE);
gGL.color4f(1,1,1,1);
gGL.color4ub(64,64,64,255);
- gGL.begin(LLVertexBuffer::QUADS);
+ gGL.begin(LLRender::QUADS);
gGL.vertex3fv((pos+left-up).mV);
gGL.vertex3fv((pos-left-up).mV);
gGL.vertex3fv((pos-left+up).mV);