diff options
Diffstat (limited to 'indra/newview/llviewerwindow.cpp')
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 113 |
1 files changed, 61 insertions, 52 deletions
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 98ae746ca7..28642fbc3c 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -534,7 +534,7 @@ public: } - addText(xpos, ypos, llformat("%d MB Vertex Data", LLVertexBuffer::sAllocatedBytes/(1024*1024))); + addText(xpos, ypos, llformat("%d MB Vertex Data (%d MB Pooled)", LLVertexBuffer::sAllocatedBytes/(1024*1024), LLVBOPool::sBytesPooled/(1024*1024))); ypos += y_inc; addText(xpos, ypos, llformat("%d Vertex Buffers", LLVertexBuffer::sGLCount)); @@ -1580,6 +1580,12 @@ LLViewerWindow::LLViewerWindow( ignore_pixel_depth, gSavedSettings.getBOOL("RenderDeferred") ? 0 : gSavedSettings.getU32("RenderFSAASamples")); //don't use window level anti-aliasing if FBOs are enabled + if (!LLViewerShaderMgr::sInitialized) + { //immediately initialize shaders + LLViewerShaderMgr::sInitialized = TRUE; + LLViewerShaderMgr::instance()->setShaders(); + } + if (NULL == mWindow) { LLSplashScreen::update(LLTrans::getString("StartupRequireDriverUpdate")); @@ -1716,32 +1722,30 @@ LLViewerWindow::LLViewerWindow( void LLViewerWindow::initGLDefaults() { gGL.setSceneBlendType(LLRender::BT_ALPHA); - glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); - F32 ambient[4] = {0.f,0.f,0.f,0.f }; - F32 diffuse[4] = {1.f,1.f,1.f,1.f }; - glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,ambient); - glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,diffuse); - - glPixelStorei(GL_PACK_ALIGNMENT,1); - glPixelStorei(GL_UNPACK_ALIGNMENT,1); + if (!LLGLSLShader::sNoFixedFunction) + { //initialize fixed function state + glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,LLColor4::black.mV); + glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,LLColor4::white.mV); - // lights for objects - glShadeModel( GL_SMOOTH ); + // lights for objects + glShadeModel( GL_SMOOTH ); - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient); - - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + } + + glPixelStorei(GL_PACK_ALIGNMENT,1); + glPixelStorei(GL_UNPACK_ALIGNMENT,1); + gGL.setAmbientLightColor(LLColor4::black); + glCullFace(GL_BACK); // RN: Need this for translation and stretch manip. - gCone.prerender(); gBox.prerender(); - gSphere.prerender(); - gCylinder.prerender(); } struct MainPanel : public LLPanel @@ -2253,6 +2257,10 @@ void LLViewerWindow::drawDebugText() gGL.color4f(1,1,1,1); gGL.pushMatrix(); gGL.pushUIMatrix(); + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } { // scale view by UI global scale factor and aspect ratio correction factor gGL.scaleUI(mDisplayScale.mV[VX], mDisplayScale.mV[VY], 1.f); @@ -2262,6 +2270,10 @@ void LLViewerWindow::drawDebugText() gGL.popMatrix(); gGL.flush(); + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.unbind(); + } } void LLViewerWindow::draw() @@ -2276,9 +2288,9 @@ void LLViewerWindow::draw() LLUI::setLineWidth(1.f); // Reset any left-over transforms - glMatrixMode(GL_MODELVIEW); + gGL.matrixMode(LLRender::MM_MODELVIEW); - glLoadIdentity(); + gGL.loadIdentity(); //S32 screen_x, screen_y; @@ -2293,7 +2305,7 @@ void LLViewerWindow::draw() // draw timecode block std::string text; - glLoadIdentity(); + gGL.loadIdentity(); microsecondsToTimecodeString(gFrameTime,text); const LLFontGL* font = LLFontGL::getFontSansSerif(); @@ -2329,10 +2341,10 @@ void LLViewerWindow::draw() int pos_y = sub_region / llceil(zoom_factor); int pos_x = sub_region - (pos_y*llceil(zoom_factor)); // offset for this tile - glTranslatef((F32)getWindowWidthScaled() * -(F32)pos_x, + gGL.translatef((F32)getWindowWidthScaled() * -(F32)pos_x, (F32)getWindowHeightScaled() * -(F32)pos_y, 0.f); - glScalef(zoom_factor, zoom_factor, 1.f); + gGL.scalef(zoom_factor, zoom_factor, 1.f); LLUI::sGLScaleFactor *= zoom_factor; } @@ -2361,7 +2373,7 @@ void LLViewerWindow::draw() S32 screen_x, screen_y; top_ctrl->localPointToScreen(0, 0, &screen_x, &screen_y); - glMatrixMode(GL_MODELVIEW); + gGL.matrixMode(LLRender::MM_MODELVIEW); LLUI::pushMatrix(); LLUI::translate( (F32) screen_x, (F32) screen_y, 0.f); top_ctrl->draw(); @@ -3425,17 +3437,17 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, LLBBox hud_bbox = gAgentAvatarp->getHUDBBox(); // set up transform to encompass bounding box of HUD - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); F32 depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f); - glOrtho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, depth); + gGL.ortho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, depth); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - glLoadMatrixf(OGL_TO_CFR_ROTATION); // Load Cory's favorite reference frame - glTranslatef(-hud_bbox.getCenterLocal().mV[VX] + (depth *0.5f), 0.f, 0.f); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.loadMatrix(OGL_TO_CFR_ROTATION); // Load Cory's favorite reference frame + gGL.translatef(-hud_bbox.getCenterLocal().mV[VX] + (depth *0.5f), 0.f, 0.f); } // Render light for editing @@ -3445,12 +3457,12 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, LLGLEnable gls_blend(GL_BLEND); LLGLEnable gls_cull(GL_CULL_FACE); LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); if (selection->getSelectType() == SELECT_TYPE_HUD) { F32 zoom = gAgentCamera.mHUDCurZoom; - glScalef(zoom, zoom, zoom); + gGL.scalef(zoom, zoom, zoom); } struct f : public LLSelectedObjectFunctor @@ -3461,33 +3473,33 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, if (drawable && drawable->isLight()) { LLVOVolume* vovolume = drawable->getVOVolume(); - glPushMatrix(); + gGL.pushMatrix(); LLVector3 center = drawable->getPositionAgent(); - glTranslatef(center[0], center[1], center[2]); + gGL.translatef(center[0], center[1], center[2]); F32 scale = vovolume->getLightRadius(); - glScalef(scale, scale, scale); + gGL.scalef(scale, scale, scale); LLColor4 color(vovolume->getLightColor(), .5f); - glColor4fv(color.mV); + gGL.color4fv(color.mV); - F32 pixel_area = 100000.f; + //F32 pixel_area = 100000.f; // Render Outside - gSphere.render(pixel_area); + gSphere.render(); // Render Inside glCullFace(GL_FRONT); - gSphere.render(pixel_area); + gSphere.render(); glCullFace(GL_BACK); - glPopMatrix(); + gGL.popMatrix(); } return true; } } func; LLSelectMgr::getInstance()->getSelection()->applyToObjects(&func); - glPopMatrix(); + gGL.popMatrix(); } // NOTE: The average position for the axis arrows of the selected objects should @@ -3550,11 +3562,11 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, } if (selection->getSelectType() == SELECT_TYPE_HUD && selection->getObjectCount()) { - glMatrixMode(GL_PROJECTION); - glPopMatrix(); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); stop_glerror(); } } @@ -4668,10 +4680,7 @@ void LLViewerWindow::stopGL(BOOL save_state) gPipeline.destroyGL(); } - gCone.cleanupGL(); gBox.cleanupGL(); - gSphere.cleanupGL(); - gCylinder.cleanupGL(); if(gPostProcess) { |