From 89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:44:50 -0500 Subject: Second Life viewer sources 1.14.0.0 --- linden/indra/newview/lldrawpoolsimple.cpp | 234 ++++++++---------------------- 1 file changed, 62 insertions(+), 172 deletions(-) (limited to 'linden/indra/newview/lldrawpoolsimple.cpp') diff --git a/linden/indra/newview/lldrawpoolsimple.cpp b/linden/indra/newview/lldrawpoolsimple.cpp index 031c170..ec8929e 100644 --- a/linden/indra/newview/lldrawpoolsimple.cpp +++ b/linden/indra/newview/lldrawpoolsimple.cpp @@ -30,55 +30,45 @@ #include "lldrawpoolsimple.h" #include "llagent.h" -#include "llagparray.h" #include "lldrawable.h" #include "llface.h" #include "llsky.h" #include "pipeline.h" -S32 LLDrawPoolSimple::sDiffTex = 0; - -LLDrawPoolSimple::LLDrawPoolSimple(LLViewerImage *texturep) : - LLDrawPool(POOL_SIMPLE, - DATA_SIMPLE_IL_MASK | DATA_COLORS_MASK, - DATA_SIMPLE_NIL_MASK), // ady temp - mTexturep(texturep) +class LLRenderPassGlow : public LLRenderPass { -} +public: + LLRenderPassGlow(): LLRenderPass(LLRenderPass::PASS_GLOW) { } + + enum + { + VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX | + LLVertexBuffer::MAP_TEXCOORD + }; -LLDrawPool *LLDrawPoolSimple::instancePool() -{ - return new LLDrawPoolSimple(mTexturep); -} + virtual U32 getVertexDataMask() { return VERTEX_DATA_MASK; } -BOOL LLDrawPoolSimple::match(LLFace* last_face, LLFace* facep) -{ - if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_CHAIN_FACES) && - !last_face->isState(LLFace::LIGHT | LLFace::FULLBRIGHT) && - !facep->isState(LLFace::LIGHT | LLFace::FULLBRIGHT) && - facep->getIndicesStart() == last_face->getIndicesStart()+last_face->getIndicesCount() && - facep->getRenderColor() == last_face->getRenderColor()) + virtual void prerender() { } + + void render(S32 pass = 0) { - if (facep->isState(LLFace::GLOBAL)) - { - if (last_face->isState(LLFace::GLOBAL)) - { - return TRUE; - } - } - else - { - if (!last_face->isState(LLFace::GLOBAL)) - { - if (last_face->getRenderMatrix() == facep->getRenderMatrix()) - { - return TRUE; - } - } - } + LLGLEnable blend(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + renderTexture(LLRenderPass::PASS_GLOW, getVertexDataMask()); + renderActive(LLRenderPass::PASS_GLOW, getVertexDataMask()); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } - - return FALSE; + + void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture = TRUE) + { + glColor4ubv(params.mGlowColor.mV); + LLRenderPass::pushBatch(params, mask, texture); + } +}; + +LLDrawPoolSimple::LLDrawPoolSimple() : + LLRenderPass(POOL_SIMPLE) +{ } void LLDrawPoolSimple::prerender() @@ -91,156 +81,56 @@ void LLDrawPoolSimple::beginRenderPass(S32 pass) glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); - if (gPipeline.getLightingDetail() >= 2) - { - glEnableClientState(GL_COLOR_ARRAY); - } - - if (mVertexShaderLevel > 0) - { - S32 scatterTex = gPipeline.mObjectSimpleProgram.enableTexture(LLPipeline::GLSL_SCATTER_MAP); - LLViewerImage::bindTexture(gSky.mVOSkyp->getScatterMap(), scatterTex); - sDiffTex = gPipeline.mObjectSimpleProgram.enableTexture(LLPipeline::GLSL_DIFFUSE_MAP); - } + glEnableClientState(GL_COLOR_ARRAY); } - void LLDrawPoolSimple::render(S32 pass) { - LLFastTimer t(LLFastTimer::FTM_RENDER_SIMPLE); - if (mDrawFace.empty()) - { - return; - } - - bindGLVertexPointer(); - bindGLTexCoordPointer(); - bindGLNormalPointer(); - if (gPipeline.getLightingDetail() >= 2) + LLGLDisable blend(GL_BLEND); + LLGLDisable alpha_test(GL_ALPHA_TEST); + { - bindGLColorPointer(); + LLFastTimer t(LLFastTimer::FTM_RENDER_SIMPLE); + gPipeline.enableLightsDynamic(1.f); + renderTexture(LLRenderPass::PASS_SIMPLE, getVertexDataMask()); + renderActive(LLRenderPass::PASS_SIMPLE, getVertexDataMask()); } - LLViewerImage* tex = getTexture(); - LLGLState alpha_test(GL_ALPHA_TEST, FALSE); - LLGLState blend(GL_BLEND, FALSE); - - if (tex) { - LLViewerImage::bindTexture(tex,sDiffTex); - if (tex->getPrimaryFormat() == GL_ALPHA) - { - // Enable Invisibility Hack - alpha_test.enable(); - blend.enable(); - } + LLFastTimer t(LLFastTimer::FTM_RENDER_GRASS); + LLGLEnable blend(GL_BLEND); + LLGLEnable alpha_test(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, 0.5f); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + //render grass + LLRenderPass::renderTexture(LLRenderPass::PASS_GRASS, getVertexDataMask()); + glAlphaFunc(GL_GREATER, 0.01f); } - else + { - LLImageGL::unbindTexture(sDiffTex, GL_TEXTURE_2D); + LLFastTimer t(LLFastTimer::FTM_RENDER_FULLBRIGHT); + U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD | LLVertexBuffer::MAP_COLOR; + gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); + glDisableClientState(GL_NORMAL_ARRAY); + renderTexture(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask); + renderActive(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask); } - drawLoop(); -} - -void LLDrawPoolSimple::endRenderPass(S32 pass) -{ - if (mVertexShaderLevel > 0) - { - gPipeline.mObjectSimpleProgram.disableTexture(LLPipeline::GLSL_SCATTER_MAP); - gPipeline.mObjectSimpleProgram.disableTexture(LLPipeline::GLSL_DIFFUSE_MAP); - glActiveTextureARB(GL_TEXTURE0_ARB); - glEnable(GL_TEXTURE_2D); - } - - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - if (gPipeline.getLightingDetail() >= 2) { + LLFastTimer t(LLFastTimer::FTM_RENDER_GLOW); glDisableClientState(GL_COLOR_ARRAY); + LLRenderPassGlow glow; + glow.render(); } -} - -void LLDrawPoolSimple::renderForSelect() -{ - if (mDrawFace.empty() || !mMemory.count()) - { - return; - } - - glEnableClientState ( GL_VERTEX_ARRAY ); - - bindGLVertexPointer(); - - for (std::vector::iterator iter = mDrawFace.begin(); - iter != mDrawFace.end(); iter++) - { - LLFace *facep = *iter; - LLDrawable *drawable = facep->getDrawable(); - if (drawable && !drawable->isDead() && (facep->getViewerObject()->mGLName)) - { - facep->renderForSelect(); - } - } -} - -void LLDrawPoolSimple::renderFaceSelected(LLFace *facep, - LLImageGL *image, - const LLColor4 &color, - const S32 index_offset, const S32 index_count) -{ - facep->renderSelected(image, color, index_offset, index_count); -} - - -void LLDrawPoolSimple::dirtyTexture(const LLViewerImage *texturep) -{ - if (mTexturep == texturep) { - for (std::vector::iterator iter = mReferences.begin(); - iter != mReferences.end(); iter++) - { - LLFace *facep = *iter; - gPipeline.markTextured(facep->getDrawable()); - } + LLFastTimer t(LLFastTimer::FTM_RENDER_INVISIBLE); + U32 invisi_mask = LLVertexBuffer::MAP_VERTEX; + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + renderInvisible(invisi_mask); + renderActive(LLRenderPass::PASS_INVISIBLE, invisi_mask); + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); } } -LLViewerImage *LLDrawPoolSimple::getTexture() -{ - return mTexturep; -} - -LLViewerImage *LLDrawPoolSimple::getDebugTexture() -{ - return mTexturep; -} - -LLColor3 LLDrawPoolSimple::getDebugColor() const -{ - return LLColor3(1.f, 1.f, 1.f); -} - -S32 LLDrawPoolSimple::getMaterialAttribIndex() -{ - return gPipeline.mObjectSimpleProgram.mAttribute[LLPipeline::GLSL_MATERIAL_COLOR]; -} - -// virtual -void LLDrawPoolSimple::enableShade() -{ - glDisableClientState(GL_COLOR_ARRAY); -} - -// virtual -void LLDrawPoolSimple::disableShade() -{ - glEnableClientState(GL_COLOR_ARRAY); -} - -// virtual -void LLDrawPoolSimple::setShade(F32 shade) -{ - glColor4f(0,0,0,shade); -} -- cgit v1.1