summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolwater.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lldrawpoolwater.cpp')
-rw-r--r--indra/newview/lldrawpoolwater.cpp114
1 files changed, 54 insertions, 60 deletions
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 108048efbc..db5debc079 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -16,7 +16,6 @@
#include "m3math.h"
#include "llagent.h" // for gAgent for getRegion for getWaterHeight
-#include "llagparray.h"
#include "llcubemap.h"
#include "lldrawable.h"
#include "llface.h"
@@ -44,11 +43,11 @@ int nhpo2(int v)
}
static GLuint sScreenTex = 0;
+BOOL LLDrawPoolWater::sSkipScreenCopy = FALSE;
LLDrawPoolWater::LLDrawPoolWater() :
- LLDrawPool(POOL_WATER, DATA_SIMPLE_IL_MASK, DATA_SIMPLE_NIL_MASK)
+ LLFacePool(POOL_WATER)
{
- mCleanupUnused = TRUE;
mHBTex[0] = gImageList.getImage(gSunTextureID, TRUE, TRUE);
mHBTex[0]->bind();
mHBTex[0]->setClamp(TRUE, TRUE);
@@ -116,11 +115,21 @@ extern LLColor4U MAX_WATER_COLOR;
void LLDrawPoolWater::render(S32 pass)
{
LLFastTimer ftm(LLFastTimer::FTM_RENDER_WATER);
- if (mDrawFace.empty())
+ if (mDrawFace.empty() || LLDrawable::getCurrentFrame() <= 1)
{
return;
}
+ //do a quick 'n dirty depth sort
+ for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
+ iter != mDrawFace.end(); iter++)
+ {
+ LLFace* facep = *iter;
+ facep->mDistance = -facep->mCenterLocal.mV[2];
+ }
+
+ std::sort(mDrawFace.begin(), mDrawFace.end(), LLFace::CompareDistanceGreater());
+
LLGLSPipelineAlpha alphaState;
if ((mVertexShaderLevel >= SHADER_LEVEL_RIPPLE))
@@ -145,7 +154,7 @@ void LLDrawPoolWater::render(S32 pass)
return;
}
- const LLFace* refl_face = voskyp->getReflFace();
+ LLFace* refl_face = voskyp->getReflFace();
gPipeline.disableLights();
@@ -157,10 +166,6 @@ void LLDrawPoolWater::render(S32 pass)
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
- bindGLVertexPointer();
- bindGLNormalPointer();
- bindGLTexCoordPointer();
-
// Set up second pass first
glActiveTextureARB(GL_TEXTURE1_ARB);
mWaterImagep->addTextureStats(1024.f*1024.f);
@@ -227,7 +232,7 @@ void LLDrawPoolWater::render(S32 pass)
continue;
}
face->bindTexture();
- face->renderIndexed(getRawIndices());
+ face->renderIndexed();
mIndicesDrawn += face->getIndicesCount();
}
@@ -288,7 +293,7 @@ void LLDrawPoolWater::render(S32 pass)
if (face->getGeomCount() > 0)
{
- face->renderIndexed(getRawIndices());
+ face->renderIndexed();
mIndicesDrawn += face->getIndicesCount();
}
}
@@ -335,7 +340,7 @@ void LLDrawPoolWater::renderShaderSimple()
return;
}
- const LLFace* refl_face = voskyp->getReflFace();
+ LLFace* refl_face = voskyp->getReflFace();
LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
@@ -345,10 +350,6 @@ void LLDrawPoolWater::renderShaderSimple()
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
- bindGLVertexPointer();
- bindGLNormalPointer();
- bindGLTexCoordPointer();
-
// Set up second pass first
S32 bumpTex = gPipeline.mWaterProgram.enableTexture(LLPipeline::GLSL_BUMP_MAP);
mWaterImagep->addTextureStats(1024.f*1024.f);
@@ -413,9 +414,6 @@ void LLDrawPoolWater::renderShaderSimple()
glMatrixMode(GL_MODELVIEW);
}
- S32 scatterTex = gPipeline.mWaterProgram.enableTexture(LLPipeline::GLSL_SCATTER_MAP);
- LLViewerImage::bindTexture(gSky.mVOSkyp->getScatterMap(), scatterTex);
-
S32 diffTex = gPipeline.mWaterProgram.enableTexture(LLPipeline::GLSL_DIFFUSE_MAP);
gPipeline.mWaterProgram.bind();
@@ -429,7 +427,7 @@ void LLDrawPoolWater::renderShaderSimple()
continue;
}
face->bindTexture(diffTex);
- face->renderIndexed(getRawIndices());
+ face->renderIndexed();
mIndicesDrawn += face->getIndicesCount();
}
@@ -450,8 +448,7 @@ void LLDrawPoolWater::renderShaderSimple()
glDisable(GL_TEXTURE_GEN_T); //texture unit 1
gPipeline.mWaterProgram.disableTexture(LLPipeline::GLSL_DIFFUSE_MAP);
- gPipeline.mWaterProgram.disableTexture(LLPipeline::GLSL_SCATTER_MAP);
-
+
// Disable texture coordinate and color arrays
LLImageGL::unbindTexture(diffTex, GL_TEXTURE_2D);
@@ -477,7 +474,7 @@ void LLDrawPoolWater::renderShaderSimple()
glDisableClientState(GL_NORMAL_ARRAY);
}
-void LLDrawPoolWater::renderReflection(const LLFace* face)
+void LLDrawPoolWater::renderReflection(LLFace* face)
{
LLVOSky *voskyp = gSky.mVOSkyp;
@@ -505,7 +502,7 @@ void LLDrawPoolWater::renderReflection(const LLFace* face)
LLViewerImage::bindTexture(mHBTex[dr]);
LLOverrideFaceColor override(this, face->getFaceColor().mV);
- face->renderIndexed(getRawIndices());
+ face->renderIndexed();
mIndicesDrawn += face->getIndicesCount();
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -513,36 +510,44 @@ void LLDrawPoolWater::renderReflection(const LLFace* face)
void bindScreenToTexture()
{
- GLint viewport[4];
- glGetIntegerv(GL_VIEWPORT, viewport);
- GLuint resX = nhpo2(viewport[2]);
- GLuint resY = nhpo2(viewport[3]);
-
- glBindTexture(GL_TEXTURE_2D, sScreenTex);
- GLint cResX;
- GLint cResY;
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &cResX);
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &cResY);
-
- if (cResX != (GLint)resX || cResY != (GLint)resY)
+ if (LLDrawPoolWater::sSkipScreenCopy)
{
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, resX, resY, 0, GL_RGB, GL_FLOAT, NULL);
- gImageList.updateMaxResidentTexMem(-1, resX*resY*3);
+ glBindTexture(GL_TEXTURE_2D, 0);
}
+ else
+ {
- glCopyTexSubImage2D(GL_TEXTURE_2D, 0, viewport[0], viewport[1], 0, 0, viewport[2], viewport[3]);
+ GLint viewport[4];
+ glGetIntegerv(GL_VIEWPORT, viewport);
+ GLuint resX = nhpo2(viewport[2]);
+ GLuint resY = nhpo2(viewport[3]);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glBindTexture(GL_TEXTURE_2D, sScreenTex);
+ GLint cResX;
+ GLint cResY;
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &cResX);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &cResY);
+
+ if (cResX != (GLint)resX || cResY != (GLint)resY)
+ {
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, resX, resY, 0, GL_RGB, GL_FLOAT, NULL);
+ gImageList.updateMaxResidentTexMem(-1, resX*resY*3);
+ }
- float scale[2];
- scale[0] = (float) viewport[2]/resX;
- scale[1] = (float) viewport[3]/resY;
- glUniform2fvARB(gPipeline.mWaterProgram.mUniform[LLPipeline::GLSL_WATER_FBSCALE], 1, scale);
+ glCopyTexSubImage2D(GL_TEXTURE_2D, 0, viewport[0], viewport[1], 0, 0, viewport[2], viewport[3]);
- LLImageGL::sBoundTextureMemory += resX * resY * 3;
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ float scale[2];
+ scale[0] = (float) viewport[2]/resX;
+ scale[1] = (float) viewport[3]/resY;
+ glUniform2fvARB(gPipeline.mWaterProgram.mUniform[LLPipeline::GLSL_WATER_FBSCALE], 1, scale);
+
+ LLImageGL::sBoundTextureMemory += resX * resY * 3;
+ }
}
void LLDrawPoolWater::shade()
@@ -577,9 +582,6 @@ void LLDrawPoolWater::shade()
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
LLGLDisable blend(GL_BLEND);
- bindGLVertexPointer();
- bindGLNormalPointer();
- bindGLTexCoordPointer();
LLColor3 light_diffuse(0,0,0);
F32 light_exp = 0.0f;
@@ -630,9 +632,6 @@ void LLDrawPoolWater::shade()
bindScreenToTexture();
- S32 scatterTex = gPipeline.mWaterProgram.enableTexture(LLPipeline::GLSL_SCATTER_MAP);
- LLViewerImage::bindTexture(gSky.mVOSkyp->getScatterMap(), scatterTex);
-
S32 diffTex = gPipeline.mWaterProgram.enableTexture(LLPipeline::GLSL_DIFFUSE_MAP);
LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
@@ -678,7 +677,7 @@ void LLDrawPoolWater::shade()
}
face->bindTexture(diffTex);
- face->renderIndexed(getRawIndices());
+ face->renderIndexed();
mIndicesDrawn += face->getIndicesCount();
}
}
@@ -686,7 +685,6 @@ void LLDrawPoolWater::shade()
gPipeline.mWaterProgram.disableTexture(LLPipeline::GLSL_ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB);
gPipeline.mWaterProgram.disableTexture(LLPipeline::GLSL_WATER_SCREENTEX);
gPipeline.mWaterProgram.disableTexture(LLPipeline::GLSL_BUMP_MAP);
- gPipeline.mWaterProgram.disableTexture(LLPipeline::GLSL_SCATTER_MAP);
gPipeline.mWaterProgram.disableTexture(LLPipeline::GLSL_DIFFUSE_MAP);
glActiveTextureARB(GL_TEXTURE0_ARB);
@@ -695,10 +693,6 @@ void LLDrawPoolWater::shade()
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-
- /*glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);*/
}
void LLDrawPoolWater::renderForSelect()