lldrawpoolstars.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "lldrawpoolstars.h"
00035 
00036 #include "llface.h"
00037 #include "llsky.h"
00038 #include "llvostars.h"
00039 #include "pipeline.h"
00040 #include "llviewercamera.h"
00041 #include "llglslshader.h"
00042 
00043 LLDrawPoolStars::LLDrawPoolStars() :
00044         LLFacePool(POOL_STARS)
00045 {
00046 }
00047 
00048 LLDrawPool *LLDrawPoolStars::instancePool()
00049 {
00050         return new LLDrawPoolStars();
00051 }
00052 
00053 void LLDrawPoolStars::prerender()
00054 {
00055         mVertexShaderLevel = LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_ENVIRONMENT);
00056 }
00057 
00058 void LLDrawPoolStars::render(S32 pass)
00059 {
00060         if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY)))
00061         {
00062                 return;
00063         }
00064         
00065         if (mDrawFace.empty())
00066         {
00067                 return;
00068         }
00069         
00070         LLGLSPipelineSkyBox gls_sky;
00071         LLGLDepthTest gls_depth(GL_FALSE, GL_FALSE);
00072         LLGLEnable blend(GL_BLEND);
00073         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00074         
00075         LLGLDisable gl_texture_2d(GL_TEXTURE_2D);
00076         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
00077         glDisableClientState(GL_NORMAL_ARRAY);
00078 
00079         gPipeline.disableLights();
00080 
00081         GLint* viewport = (GLint*) gGLViewport;
00082 
00083         if (viewport[2] > 512 && viewport[3] > 512)
00084         {
00085                 glPointSize(2.f);
00086         }
00087 
00088         LLVector3 origin = gCamera->getOrigin();
00089         glPushMatrix();
00090         glTranslatef(origin.mV[0], origin.mV[1], origin.mV[2]);
00091 
00092         glEnableClientState(GL_COLOR_ARRAY);
00093         
00094         S32 face_count = (S32)mDrawFace.size();
00095         for (S32 curr_face = 0; curr_face < face_count; curr_face++)
00096         {
00097                 LLFace* face = mDrawFace[curr_face];
00098                 if (!face->getGeomCount())
00099                 {
00100                         continue;
00101                 }
00102         
00103                 //  render the stars as a sphere centered at viewer camera 
00104                 if (face->mVertexBuffer.notNull())
00105                 {
00106                         face->mVertexBuffer->setBuffer(getVertexDataMask());
00107                         U32* indicesp = (U32*) face->mVertexBuffer->getIndicesPointer();
00108                         glDrawElements(GL_POINTS, face->getIndicesCount(), GL_UNSIGNED_INT, indicesp);
00109                         mIndicesDrawn += face->getIndicesCount();
00110                 }
00111         }
00112         glDisableClientState(GL_COLOR_ARRAY);
00113         glPointSize(1.f);
00114         glPopMatrix();
00115 }
00116 
00117 
00118 void LLDrawPoolStars::renderForSelect()
00119 {
00120 }
00121 

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