lldrawpoolsimple.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "lldrawpoolsimple.h"
00035 
00036 #include "llviewercamera.h"
00037 #include "llagent.h"
00038 #include "lldrawable.h"
00039 #include "llface.h"
00040 #include "llsky.h"
00041 #include "pipeline.h"
00042 #include "llspatialpartition.h"
00043 #include "llglslshader.h"
00044 #include "llglimmediate.h"
00045 
00046 
00047 static LLGLSLShader* simple_shader = NULL;
00048 static LLGLSLShader* fullbright_shader = NULL;
00049 
00050 void LLDrawPoolGlow::render(S32 pass)
00051 {
00052         LLFastTimer t(LLFastTimer::FTM_RENDER_GLOW);
00053         LLGLEnable blend(GL_BLEND);
00054         LLGLDisable test(GL_ALPHA_TEST);
00055         gGL.blendFunc(GL_ONE, GL_ONE);
00056         
00057         U32 shader_level = LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_OBJECT);
00058 
00059         if (shader_level > 0 && fullbright_shader)
00060         {
00061                 fullbright_shader->bind();
00062         }
00063         else
00064         {
00065                 gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
00066         }
00067 
00068         LLGLDepthTest depth(GL_TRUE, GL_FALSE);
00069         glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
00070         renderTexture(LLRenderPass::PASS_GLOW, getVertexDataMask());
00071         
00072         glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
00073         gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00074         
00075         if (shader_level > 0 && fullbright_shader)
00076         {
00077                 fullbright_shader->unbind();
00078         }
00079 }
00080 
00081 void LLDrawPoolGlow::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
00082 {
00083         glColor4ubv(params.mGlowColor.mV);
00084         LLRenderPass::pushBatch(params, mask, texture);
00085 }
00086 
00087 
00088 LLDrawPoolSimple::LLDrawPoolSimple() :
00089         LLRenderPass(POOL_SIMPLE)
00090 {
00091 }
00092 
00093 void LLDrawPoolSimple::prerender()
00094 {
00095         mVertexShaderLevel = LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_OBJECT);
00096 }
00097 
00098 void LLDrawPoolSimple::beginRenderPass(S32 pass)
00099 {
00100         LLFastTimer t(LLFastTimer::FTM_RENDER_SIMPLE);
00101 
00102         if (LLPipeline::sUnderWaterRender)
00103         {
00104                 simple_shader = &gObjectSimpleWaterProgram;
00105                 fullbright_shader = &gObjectFullbrightWaterProgram;
00106         }
00107         else
00108         {
00109                 simple_shader = &gObjectSimpleProgram;
00110                 fullbright_shader = &gObjectFullbrightProgram;
00111         }
00112 
00113         if (mVertexShaderLevel > 0)
00114         {
00115                 simple_shader->bind();
00116                 simple_shader->uniform1f(LLShaderMgr::FULLBRIGHT, 0.f);
00117         }
00118         else 
00119         {
00120                 // don't use shaders!
00121                 if (gGLManager.mHasShaderObjects)
00122                 {
00123                         glUseProgramObjectARB(0);
00124                 }               
00125         }
00126 }
00127 
00128 void LLDrawPoolSimple::endRenderPass(S32 pass)
00129 {
00130         LLFastTimer t(LLFastTimer::FTM_RENDER_SIMPLE);
00131         LLRenderPass::endRenderPass(pass);
00132 
00133         if (mVertexShaderLevel > 0){
00134 
00135                 simple_shader->unbind();
00136         }
00137 }
00138 
00139 void LLDrawPoolSimple::render(S32 pass)
00140 {
00141         LLGLDisable blend(GL_BLEND);
00142         LLGLState alpha_test(GL_ALPHA_TEST, gPipeline.canUseWindLightShadersOnObjects());
00143         glAlphaFunc(GL_GREATER, 0.5f);
00144 
00145         { //render simple
00146                 LLFastTimer t(LLFastTimer::FTM_RENDER_SIMPLE);
00147                 gPipeline.enableLightsDynamic();
00148                 renderTexture(LLRenderPass::PASS_SIMPLE, getVertexDataMask());
00149         }
00150 
00151         {
00152                 LLFastTimer t(LLFastTimer::FTM_RENDER_GRASS);
00153                 LLGLEnable test(GL_ALPHA_TEST);
00154                 LLGLEnable blend(GL_BLEND);
00155                 gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00156                 //render grass
00157                 LLRenderPass::renderTexture(LLRenderPass::PASS_GRASS, getVertexDataMask());
00158         }                       
00159 
00160         { //render fullbright
00161                 if (mVertexShaderLevel > 0)
00162                 {
00163                         fullbright_shader->bind();
00164                         fullbright_shader->uniform1f(LLShaderMgr::FULLBRIGHT, 1.f);
00165                 }
00166                 else
00167                 {
00168                         gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
00169                 }
00170                 LLFastTimer t(LLFastTimer::FTM_RENDER_FULLBRIGHT);
00171                 U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD | LLVertexBuffer::MAP_COLOR;
00172                 renderTexture(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask);
00173         }
00174 
00175         glAlphaFunc(GL_GREATER, 0.01f);
00176 }
00177 

Generated on Fri May 16 08:33:19 2008 for SecondLife by  doxygen 1.5.5