lldrawpoolsimple.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "lldrawpoolsimple.h"
00035 #include "lldrawpoolbump.h"
00036 
00037 #include "llviewercamera.h"
00038 #include "llagent.h"
00039 #include "lldrawable.h"
00040 #include "llface.h"
00041 #include "llsky.h"
00042 #include "pipeline.h"
00043 #include "llglslshader.h"
00044 
00045 class LLRenderShinyGlow : public LLDrawPoolBump
00046 {
00047 public:
00048         LLRenderShinyGlow() { }
00049         
00050         void render(S32 pass = 0)
00051         {
00052                 LLCubeMap* cube_map = gSky.mVOSkyp->getCubeMap();
00053                 if( cube_map )
00054                 {
00055                         cube_map->enable(0);
00056                         cube_map->setMatrix(0);
00057                         cube_map->bind();
00058                         glEnableClientState(GL_NORMAL_ARRAY);
00059                         
00060                         glColor4f(1,1,1,1);
00061 
00062             U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL;
00063                         renderStatic(LLRenderPass::PASS_SHINY, mask);
00064                         renderActive(LLRenderPass::PASS_SHINY, mask);
00065 
00066                         glDisableClientState(GL_NORMAL_ARRAY);
00067                         cube_map->disable();
00068                         cube_map->restoreMatrix();
00069                 }
00070         }
00071 };
00072 
00073 void LLDrawPoolGlow::render(S32 pass)
00074 {
00075         LLGLEnable blend(GL_BLEND);
00076         glBlendFunc(GL_SRC_ALPHA, GL_ONE);
00077         gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
00078         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00079         //********UMICH 3D LAB********
00080         // protect the color mask change for correct anaglyph render
00081         GLboolean mask[4];
00082         glGetBooleanv(GL_COLOR_WRITEMASK,mask);
00083         glColorMask(mask[0], mask[1], mask[2], GL_FALSE);
00084         //********UMICH 3D LAB********
00085         renderTexture(LLRenderPass::PASS_GLOW, getVertexDataMask());
00086         renderActive(LLRenderPass::PASS_GLOW, getVertexDataMask());
00087 
00088         if (gSky.mVOSkyp)
00089         {
00090                 glPushMatrix();
00091                 LLVector3 origin = gCamera->getOrigin();
00092                 glTranslatef(origin.mV[0], origin.mV[1], origin.mV[2]);
00093 
00094                 LLFace* facep = gSky.mVOSkyp->mFace[LLVOSky::FACE_BLOOM];
00095 
00096                 if (facep)
00097                 {
00098                         LLGLDisable cull(GL_CULL_FACE);
00099                         facep->getTexture()->bind();
00100                         glColor4f(1,1,1,1);
00101                         facep->renderIndexed(getVertexDataMask());
00102                 }
00103 
00104                 glPopMatrix();
00105         }
00106 
00107         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
00108 
00109         if (LLPipeline::sDynamicReflections)
00110         {
00111                 LLRenderShinyGlow glow;
00112                 glow.render();
00113         }
00114 
00115         //********UMICH 3D LAB********
00116         // protect the color mask change for correct anaglyph render
00117         glGetBooleanv(GL_COLOR_WRITEMASK,mask);
00118         glColorMask(mask[0], mask[1], mask[2], GL_FALSE);
00119         //********UMICH 3D LAB********
00120         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00121         
00122 }
00123 
00124 void LLDrawPoolGlow::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
00125 {
00126         glColor4ubv(params.mGlowColor.mV);
00127         LLRenderPass::pushBatch(params, mask, texture);
00128 }
00129 
00130 
00131 LLDrawPoolSimple::LLDrawPoolSimple() :
00132         LLRenderPass(POOL_SIMPLE)
00133 {
00134 }
00135 
00136 void LLDrawPoolSimple::prerender()
00137 {
00138         mVertexShaderLevel = LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_OBJECT);
00139 }
00140 
00141 void LLDrawPoolSimple::beginRenderPass(S32 pass)
00142 {
00143         glEnableClientState(GL_VERTEX_ARRAY);
00144         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00145         glEnableClientState(GL_NORMAL_ARRAY);
00146         glEnableClientState(GL_COLOR_ARRAY);
00147 }
00148 
00149 void LLDrawPoolSimple::render(S32 pass)
00150 {
00151         LLGLDisable blend(GL_BLEND);
00152         LLGLDisable alpha_test(GL_ALPHA_TEST);
00153         
00154         {
00155                 LLFastTimer t(LLFastTimer::FTM_RENDER_SIMPLE);
00156                 gPipeline.enableLightsDynamic(1.f);
00157                 renderTexture(LLRenderPass::PASS_SIMPLE, getVertexDataMask());
00158                 renderActive(LLRenderPass::PASS_SIMPLE, getVertexDataMask());
00159         }
00160 
00161         {
00162                 LLFastTimer t(LLFastTimer::FTM_RENDER_GRASS);
00163                 LLGLEnable blend(GL_BLEND);
00164                 LLGLEnable alpha_test(GL_ALPHA_TEST);
00165                 glAlphaFunc(GL_GREATER, 0.5f);
00166                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00167                 //render grass
00168                 LLRenderPass::renderTexture(LLRenderPass::PASS_GRASS, getVertexDataMask());
00169                 glAlphaFunc(GL_GREATER, 0.01f);
00170         }
00171                 
00172         {
00173                 LLFastTimer t(LLFastTimer::FTM_RENDER_FULLBRIGHT);
00174                 U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD | LLVertexBuffer::MAP_COLOR;
00175                 gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
00176                 glDisableClientState(GL_NORMAL_ARRAY);
00177                 renderTexture(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask);
00178                 renderActive(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask);
00179         }
00180 
00181         {
00182                 LLFastTimer t(LLFastTimer::FTM_RENDER_INVISIBLE);
00183                 U32 invisi_mask = LLVertexBuffer::MAP_VERTEX;
00184                 glDisableClientState(GL_COLOR_ARRAY);
00185                 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
00186                 //********UMICH 3D LAB********
00187                 // protect the color mask change for correct anaglyph render
00188                 GLboolean mask[4];
00189                 glGetBooleanv(GL_COLOR_WRITEMASK,mask);
00190                 //********UMICH 3D LAB********
00191 
00192                 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
00193                 renderInvisible(invisi_mask);
00194                 renderActive(LLRenderPass::PASS_INVISIBLE, invisi_mask);
00195                 
00196                 //********UMICH 3D LAB********
00197                 glColorMask(mask[0], mask[1], mask[2], mask[3]);
00198                 //********UMICH 3D LAB********
00199         }
00200 }
00201 

Generated on Thu Jul 1 06:08:26 2010 for Second Life Viewer by  doxygen 1.4.7