summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolterrain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lldrawpoolterrain.cpp')
-rw-r--r--indra/newview/lldrawpoolterrain.cpp98
1 files changed, 36 insertions, 62 deletions
diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp
index 3e6ae7bf85..8c5c2e177a 100644
--- a/indra/newview/lldrawpoolterrain.cpp
+++ b/indra/newview/lldrawpoolterrain.cpp
@@ -13,7 +13,6 @@
#include "llfasttimer.h"
#include "llagent.h"
-#include "llagparray.h"
#include "llviewercontrol.h"
#include "lldrawable.h"
#include "llface.h"
@@ -37,7 +36,7 @@ S32 LLDrawPoolTerrain::sDetailMode = 1;
F32 LLDrawPoolTerrain::sDetailScale = DETAIL_SCALE;
LLDrawPoolTerrain::LLDrawPoolTerrain(LLViewerImage *texturep) :
- LLDrawPool(POOL_TERRAIN, DATA_SIMPLE_IL_MASK | DATA_COLORS_MASK | DATA_TEX_COORDS1_MASK, DATA_SIMPLE_NIL_MASK),
+ LLFacePool(POOL_TERRAIN),
mTexturep(texturep)
{
// Hack!
@@ -75,6 +74,13 @@ void LLDrawPoolTerrain::prerender()
#if 0 // 1.9.2
mVertexShaderLevel = gPipeline.getVertexShaderLevel(LLPipeline::SHADER_ENVIRONMENT);
#endif
+ sDetailMode = gSavedSettings.getS32("RenderTerrainDetail");
+}
+
+//static
+S32 LLDrawPoolTerrain::getDetailMode()
+{
+ return sDetailMode;
}
void LLDrawPoolTerrain::render(S32 pass)
@@ -86,6 +92,15 @@ void LLDrawPoolTerrain::render(S32 pass)
return;
}
+ // Hack! Get the region that this draw pool is rendering from!
+ LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion();
+ LLVLComposition *compp = regionp->getComposition();
+ for (S32 i = 0; i < 4; i++)
+ {
+ compp->mDetailTextures[i]->setBoostLevel(LLViewerImage::BOOST_TERRAIN);
+ compp->mDetailTextures[i]->addTextureStats(1024.f*1024.f); // assume large pixel area
+ }
+
if (!gGLManager.mHasMultitexture)
{
// No mulititexture, render simple land.
@@ -152,25 +167,16 @@ void LLDrawPoolTerrain::renderFull4TUShader()
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
- bindGLVertexPointer();
- bindGLNormalPointer();
if (gPipeline.getLightingDetail() >= 2)
{
glEnableClientState(GL_COLOR_ARRAY);
- bindGLColorPointer();
}
-
+
glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
// Hack! Get the region that this draw pool is rendering from!
LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion();
LLVLComposition *compp = regionp->getComposition();
- for (S32 i = 0; i < 4; i++)
- {
- compp->mDetailTextures[i]->setBoostLevel(LLViewerImage::BOOST_TERRAIN);
- compp->mDetailTextures[i]->addTextureStats(1024.f*1024.f); // assume large pixel area
- }
-
LLViewerImage *detail_texture0p = compp->mDetailTextures[0];
LLViewerImage *detail_texture1p = compp->mDetailTextures[1];
LLViewerImage *detail_texture2p = compp->mDetailTextures[2];
@@ -200,8 +206,7 @@ void LLDrawPoolTerrain::renderFull4TUShader()
S32 detailTex0 = gPipeline.mTerrainProgram.enableTexture(LLPipeline::GLSL_TERRAIN_DETAIL0);
S32 detailTex1 = gPipeline.mTerrainProgram.enableTexture(LLPipeline::GLSL_TERRAIN_DETAIL1);
S32 rampTex = gPipeline.mTerrainProgram.enableTexture(LLPipeline::GLSL_TERRAIN_ALPHARAMP);
- S32 scatterTex = gPipeline.mTerrainProgram.enableTexture(LLPipeline::GLSL_SCATTER_MAP);
-
+
LLViewerImage::bindTexture(detail_texture0p,detailTex0);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
@@ -222,7 +227,6 @@ void LLDrawPoolTerrain::renderFull4TUShader()
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- bindGLTexCoordPointer(1);
//
// Stage 2: Interpolate detail1 with existing based on ramp
@@ -239,9 +243,6 @@ void LLDrawPoolTerrain::renderFull4TUShader()
glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0.mV);
glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1.mV);
- // Stage 4: Haze
- LLViewerImage::bindTexture(gSky.mVOSkyp->getScatterMap(), scatterTex);
-
//
// Stage 3: Modulate with primary color for lighting
//
@@ -278,7 +279,6 @@ void LLDrawPoolTerrain::renderFull4TUShader()
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glActiveTextureARB(GL_TEXTURE1_ARB);
- bindGLTexCoordPointer(1);
// Set the texture matrix
glMatrixMode(GL_TEXTURE);
@@ -310,7 +310,6 @@ void LLDrawPoolTerrain::renderFull4TUShader()
glClientActiveTextureARB(GL_TEXTURE3_ARB);
glActiveTextureARB(GL_TEXTURE3_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- bindGLTexCoordPointer(1);
// Set the texture matrix
glMatrixMode(GL_TEXTURE);
@@ -323,7 +322,6 @@ void LLDrawPoolTerrain::renderFull4TUShader()
}
// Disable multitexture
- gPipeline.mTerrainProgram.disableTexture(LLPipeline::GLSL_SCATTER_MAP);
gPipeline.mTerrainProgram.disableTexture(LLPipeline::GLSL_TERRAIN_ALPHARAMP);
gPipeline.mTerrainProgram.disableTexture(LLPipeline::GLSL_TERRAIN_DETAIL0);
gPipeline.mTerrainProgram.disableTexture(LLPipeline::GLSL_TERRAIN_DETAIL1);
@@ -377,18 +375,9 @@ void LLDrawPoolTerrain::renderFull4TU()
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
- bindGLVertexPointer();
- bindGLNormalPointer();
-
// Hack! Get the region that this draw pool is rendering from!
LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion();
LLVLComposition *compp = regionp->getComposition();
- for (S32 i = 0; i < 4; i++)
- {
- compp->mDetailTextures[i]->setBoostLevel(LLViewerImage::BOOST_TERRAIN);
- compp->mDetailTextures[i]->addTextureStats(1024.f*1024.f); // assume large pixel area
- }
-
LLViewerImage *detail_texture0p = compp->mDetailTextures[0];
LLViewerImage *detail_texture1p = compp->mDetailTextures[1];
LLViewerImage *detail_texture2p = compp->mDetailTextures[2];
@@ -411,6 +400,7 @@ void LLDrawPoolTerrain::renderFull4TU()
//
// Stage 0: detail texture 0
//
+ glActiveTextureARB(GL_TEXTURE0_ARB);
LLViewerImage::bindTexture(detail_texture0p,0);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
@@ -432,12 +422,12 @@ void LLDrawPoolTerrain::renderFull4TU()
//
// Stage 1: Generate alpha ramp for detail0/detail1 transition
//
+ glActiveTextureARB(GL_TEXTURE1_ARB);
LLViewerImage::bindTexture(m2DAlphaRampImagep,1);
glEnable(GL_TEXTURE_2D); // Texture unit 1
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- bindGLTexCoordPointer(1);
// Care about alpha only
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
@@ -452,6 +442,7 @@ void LLDrawPoolTerrain::renderFull4TU()
//
// Stage 2: Interpolate detail1 with existing based on ramp
//
+ glActiveTextureARB(GL_TEXTURE2_ARB);
LLViewerImage::bindTexture(detail_texture1p,2);
glEnable(GL_TEXTURE_2D); // Texture unit 2
glClientActiveTextureARB(GL_TEXTURE2_ARB);
@@ -477,6 +468,7 @@ void LLDrawPoolTerrain::renderFull4TU()
//
// Stage 3: Modulate with primary (vertex) color for lighting
//
+ glActiveTextureARB(GL_TEXTURE3_ARB);
LLViewerImage::bindTexture(detail_texture1p,3); // bind any texture
glEnable(GL_TEXTURE_2D); // Texture unit 3
glClientActiveTextureARB(GL_TEXTURE3_ARB);
@@ -498,6 +490,7 @@ void LLDrawPoolTerrain::renderFull4TU()
// Stage 0: Write detail3 into base
//
+ glActiveTextureARB(GL_TEXTURE0_ARB);
LLViewerImage::bindTexture(detail_texture3p,0);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
@@ -519,14 +512,13 @@ void LLDrawPoolTerrain::renderFull4TU()
//
// Stage 1: Generate alpha ramp for detail2/detail3 transition
//
+ glActiveTextureARB(GL_TEXTURE1_ARB);
LLViewerImage::bindTexture(m2DAlphaRampImagep,1);
glEnable(GL_TEXTURE_2D); // Texture unit 1
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- bindGLTexCoordPointer(1);
-
// Set the texture matrix
glMatrixMode(GL_TEXTURE);
@@ -547,6 +539,7 @@ void LLDrawPoolTerrain::renderFull4TU()
//
// Stage 2: Interpolate detail2 with existing based on ramp
//
+ glActiveTextureARB(GL_TEXTURE2_ARB);
LLViewerImage::bindTexture(detail_texture2p,2);
glEnable(GL_TEXTURE_2D); // Texture unit 2
glClientActiveTextureARB(GL_TEXTURE2_ARB);
@@ -573,19 +566,19 @@ void LLDrawPoolTerrain::renderFull4TU()
//
// Stage 3: Generate alpha ramp for detail1/detail2 transition
//
+ glActiveTextureARB(GL_TEXTURE3_ARB);
LLViewerImage::bindTexture(m2DAlphaRampImagep,3);
glEnable(GL_TEXTURE_2D); // Texture unit 3
glClientActiveTextureARB(GL_TEXTURE3_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- bindGLTexCoordPointer(1);
// Set the texture matrix
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(-1.f, 0.f, 0.f);
-
+
// Set alpha texture and do lighting modulation
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
@@ -656,18 +649,9 @@ void LLDrawPoolTerrain::renderFull2TU()
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
- bindGLVertexPointer();
- bindGLNormalPointer();
-
// Hack! Get the region that this draw pool is rendering from!
LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion();
LLVLComposition *compp = regionp->getComposition();
- for (S32 i = 0; i < 4; i++)
- {
- compp->mDetailTextures[i]->setBoostLevel(LLViewerImage::BOOST_TERRAIN);
- compp->mDetailTextures[i]->addTextureStats(1024.f*1024.f); // assume large pixel area
- }
-
LLViewerImage *detail_texture0p = compp->mDetailTextures[0];
LLViewerImage *detail_texture1p = compp->mDetailTextures[1];
LLViewerImage *detail_texture2p = compp->mDetailTextures[2];
@@ -724,7 +708,6 @@ void LLDrawPoolTerrain::renderFull2TU()
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- bindGLTexCoordPointer(1);
// Care about alpha only
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
@@ -781,7 +764,6 @@ void LLDrawPoolTerrain::renderFull2TU()
glTranslatef(-1.f, 0.f, 0.f);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- bindGLTexCoordPointer(1);
// Care about alpha only
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
@@ -839,7 +821,6 @@ void LLDrawPoolTerrain::renderFull2TU()
glTranslatef(-2.f, 0.f, 0.f);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- bindGLTexCoordPointer(1);
// Care about alpha only
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
@@ -919,9 +900,6 @@ void LLDrawPoolTerrain::renderSimple()
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
- bindGLVertexPointer();
- bindGLNormalPointer();
-
LLVector4 tp0, tp1;
//----------------------------------------------------------------------------
@@ -999,9 +977,6 @@ void LLDrawPoolTerrain::renderOwnership()
glEnableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
- bindGLVertexPointer();
- bindGLTexCoordPointer(0);
-
LLViewerImage::bindTexture(texturep);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
@@ -1017,12 +992,12 @@ void LLDrawPoolTerrain::renderOwnership()
const F32 TEXTURE_FUDGE = 257.f / 256.f;
glScalef( TEXTURE_FUDGE, TEXTURE_FUDGE, 1.f );
- const U32* index_array = getRawIndices();
for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
iter != mDrawFace.end(); iter++)
{
LLFace *facep = *iter;
- facep->renderIndexed(index_array);
+ facep->renderIndexed(LLVertexBuffer::MAP_VERTEX |
+ LLVertexBuffer::MAP_TEXCOORD);
}
glMatrixMode(GL_TEXTURE);
@@ -1036,14 +1011,13 @@ void LLDrawPoolTerrain::renderOwnership()
void LLDrawPoolTerrain::renderForSelect()
{
- if (mDrawFace.empty() || !mMemory.count())
+ if (mDrawFace.empty())
{
return;
}
- glEnableClientState ( GL_VERTEX_ARRAY );
-
- bindGLVertexPointer();
+
+ LLImageGL::unbindTexture(0);
for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
iter != mDrawFace.end(); iter++)
@@ -1051,14 +1025,14 @@ void LLDrawPoolTerrain::renderForSelect()
LLFace *facep = *iter;
if (!facep->getDrawable()->isDead() && (facep->getDrawable()->getVObj()->mGLName))
{
- facep->renderForSelect();
+ facep->renderForSelect(LLVertexBuffer::MAP_VERTEX);
}
}
}
-void LLDrawPoolTerrain::dirtyTexture(const LLViewerImage *texturep)
+void LLDrawPoolTerrain::dirtyTextures(const std::set<LLViewerImage*>& textures)
{
- if (mTexturep == texturep)
+ if (textures.find(mTexturep) != textures.end())
{
for (std::vector<LLFace*>::iterator iter = mReferences.begin();
iter != mReferences.end(); iter++)