summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerdisplay.cpp
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2007-03-02 21:25:50 +0000
committerSteven Bennetts <steve@lindenlab.com>2007-03-02 21:25:50 +0000
commit4dabd9c0472deb49573fdafef2fa413e59703f19 (patch)
tree06c680d6a2047e03838d6548bccd26c7baf9d652 /indra/newview/llviewerdisplay.cpp
parentd4462963c6ba5db2088723bbedc7b60f1184c594 (diff)
merge release@58699 beta-1-14-0@58707 -> release
Diffstat (limited to 'indra/newview/llviewerdisplay.cpp')
-rw-r--r--indra/newview/llviewerdisplay.cpp204
1 files changed, 175 insertions, 29 deletions
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 9c3643128b..837eaa90e9 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -44,6 +44,9 @@
#include "llfloatertools.h"
#include "llviewerimagelist.h"
#include "llfocusmgr.h"
+#include "llcubemap.h"
+#include "llviewerregion.h"
+#include "lldrawpoolwater.h"
extern U32 gFrameCount;
extern LLPointer<LLImageGL> gStartImageGL;
@@ -84,8 +87,12 @@ void display_startup()
return;
}
- LLDynamicTexture::updateAllInstances();
-
+ // Required for HTML update in login screen
+ static S32 frame_count = 0;
+ if (frame_count++ > 1) // make sure we have rendered a frame first
+ {
+ LLDynamicTexture::updateAllInstances();
+ }
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
LLGLSDefault gls_default;
LLGLSUIDefault gls_ui;
@@ -364,6 +371,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
//
gCamera->setZoomParameters(zoom_factor, subfield);
+ gCamera->setNear(MIN_NEAR_PLANE);
//////////////////////////
//
@@ -379,6 +387,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
else if (!gViewerWindow->isPickPending())
{
glClear( GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
+ //DEBUG TEMPORARY
+ glClear(GL_COLOR_BUFFER_BIT);
}
gViewerWindow->setupViewport();
@@ -399,7 +409,13 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
glClearColor(0.5f, 0.5f, 0.5f, 0.f);
glClear(GL_COLOR_BUFFER_BIT);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ LLPipeline::sUseOcclusion = FALSE;
}
+ else
+ {
+ LLPipeline::sUseOcclusion = gSavedSettings.getBOOL("UseOcclusion") && gGLManager.mHasOcclusionQuery;
+ }
+
stop_glerror();
///////////////////////////////////////
@@ -412,7 +428,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
glLightModelfv (GL_LIGHT_MODEL_AMBIENT,one);
stop_glerror();
- //LLGLState::verify();
+ //Increment drawable frame counter
+ LLDrawable::incrementVisible();
/////////////////////////////////////
//
@@ -422,6 +439,11 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
//
if (!gDisconnected)
{
+ if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD))
+ { //don't draw hud objects in this frame
+ gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD);
+ }
+
LLFastTimer t(LLFastTimer::FTM_WORLD_UPDATE);
stop_glerror();
display_update_camera();
@@ -437,34 +459,41 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
gPipeline.updateGeom(max_geom_update_time);
stop_glerror();
+ LLSpatialPartition* part = gPipeline.getSpatialPartition(LLPipeline::PARTITION_VOLUME);
+ part->processImagery(gCamera);
+
+ display_update_camera();
+
gFrameStats.start(LLFrameStats::UPDATE_CULL);
- gPipeline.updateCull();
+ gPipeline.updateCull(*gCamera);
stop_glerror();
- if (rebuild)
+ ///////////////////////////////////
+ //
+ // StateSort
+ //
+ // Responsible for taking visible objects, and adding them to the appropriate draw orders.
+ // In the case of alpha objects, z-sorts them first.
+ // Also creates special lists for outlines and selected face rendering.
+ //
{
LLFastTimer t(LLFastTimer::FTM_REBUILD);
-
- ///////////////////////////////////
- //
- // StateSort
- //
- // Responsible for taking visible objects, and adding them to the appropriate draw orders.
- // In the case of alpha objects, z-sorts them first.
- // Also creates special lists for outlines and selected face rendering.
- //
- gFrameStats.start(LLFrameStats::STATE_SORT);
- gPipeline.stateSort();
- stop_glerror();
- //////////////////////////////////////
- //
- // rebuildPools
- //
- //
- gFrameStats.start(LLFrameStats::REBUILD);
- gPipeline.rebuildPools();
+ gFrameStats.start(LLFrameStats::STATE_SORT);
+ gPipeline.stateSort(*gCamera);
stop_glerror();
+
+ if (rebuild)
+ {
+ //////////////////////////////////////
+ //
+ // rebuildPools
+ //
+ //
+ gFrameStats.start(LLFrameStats::REBUILD);
+ gPipeline.rebuildPools();
+ stop_glerror();
+ }
}
}
@@ -509,10 +538,65 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
&& !gRestoreGL
&& !gDisconnected)
{
- gPipeline.renderGeom();
+ gPipeline.renderGeom(*gCamera);
stop_glerror();
}
+ //render hud attachments
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ if (LLPipeline::sShowHUDAttachments && !gDisconnected && setup_hud_matrices(FALSE))
+ {
+ LLCamera hud_cam = *gCamera;
+ glClear(GL_DEPTH_BUFFER_BIT);
+ LLVector3 origin = hud_cam.getOrigin();
+ hud_cam.setOrigin(-1.f,0,0);
+ hud_cam.setAxes(LLVector3(1,0,0), LLVector3(0,1,0), LLVector3(0,0,1));
+ LLViewerCamera::updateFrustumPlanes(hud_cam, TRUE);
+ //only render hud objects
+ U32 mask = gPipeline.getRenderTypeMask();
+ gPipeline.setRenderTypeMask(0);
+ gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD);
+
+ BOOL has_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI);
+ if (has_ui)
+ {
+ gPipeline.toggleRenderDebugFeature((void*) LLPipeline::RENDER_DEBUG_FEATURE_UI);
+ }
+
+ BOOL use_occlusion = gSavedSettings.getBOOL("UseOcclusion");
+ gSavedSettings.setBOOL("UseOcclusion", FALSE);
+
+ //cull, sort, and render hud objects
+ gPipeline.updateCull(hud_cam);
+
+ gPipeline.toggleRenderType(LLDrawPool::POOL_ALPHA_POST_WATER);
+ gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_BUMP);
+ gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_SIMPLE);
+ gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_VOLUME);
+
+ {
+ LLFastTimer ftm(LLFastTimer::FTM_REBUILD);
+ gPipeline.stateSort(hud_cam);
+ }
+
+ gPipeline.renderGeom(hud_cam);
+
+ //restore type mask
+ gPipeline.setRenderTypeMask(mask);
+ if (has_ui)
+ {
+ gPipeline.toggleRenderDebugFeature((void*) LLPipeline::RENDER_DEBUG_FEATURE_UI);
+ }
+ gSavedSettings.setBOOL("UseOcclusion", use_occlusion);
+ }
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+
gFrameStats.start(LLFrameStats::RENDER_UI);
if (gHandleKeysAsync)
@@ -535,6 +619,64 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield)
}
+BOOL setup_hud_matrices(BOOL for_select)
+{
+ LLVOAvatar* my_avatarp = gAgent.getAvatarObject();
+ if (my_avatarp && my_avatarp->hasHUDAttachment())
+ {
+ if (!for_select)
+ {
+ // clamp target zoom level to reasonable values
+ my_avatarp->mHUDTargetZoom = llclamp(my_avatarp->mHUDTargetZoom, 0.1f, 1.f);
+ // smoothly interpolate current zoom level
+ my_avatarp->mHUDCurZoom = lerp(my_avatarp->mHUDCurZoom, my_avatarp->mHUDTargetZoom, LLCriticalDamp::getInterpolant(0.03f));
+ }
+
+ F32 zoom_level = my_avatarp->mHUDCurZoom;
+ // clear z buffer and set up transform for hud
+ if (!for_select)
+ {
+ glClear(GL_DEPTH_BUFFER_BIT);
+ }
+ LLBBox hud_bbox = my_avatarp->getHUDBBox();
+
+ // set up transform to encompass bounding box of HUD
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f);
+ if (for_select)
+ {
+ //RN: reset viewport to window extents so ortho screen is calculated with proper reference frame
+ gViewerWindow->setupViewport();
+ }
+ glOrtho(-0.5f * gCamera->getAspect(), 0.5f * gCamera->getAspect(), -0.5f, 0.5f, 0.f, hud_depth);
+
+ // apply camera zoom transform (for high res screenshots)
+ F32 zoom_factor = gCamera->getZoomFactor();
+ S16 sub_region = gCamera->getZoomSubRegion();
+ if (zoom_factor > 1.f)
+ {
+ float offset = zoom_factor - 1.f;
+ int pos_y = sub_region / llceil(zoom_factor);
+ int pos_x = sub_region - (pos_y*llceil(zoom_factor));
+ glTranslatef(gCamera->getAspect() * 0.5f * (offset - (F32)pos_x * 2.f), 0.5f * (offset - (F32)pos_y * 2.f), 0.f);
+ glScalef(zoom_factor, zoom_factor, 1.f);
+ }
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glLoadMatrixf(OGL_TO_CFR_ROTATION); // Load Cory's favorite reference frame
+ glTranslatef(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f);
+ glScalef(zoom_level, zoom_level, zoom_level);
+
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
void render_ui_and_swap()
{
@@ -546,7 +688,7 @@ void render_ui_and_swap()
{
LLGLSUIDefault gls_ui;
gPipeline.disableLights();
-
+ LLVertexBuffer::startRender();
if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
{
LLFastTimer t(LLFastTimer::FTM_RENDER_UI);
@@ -563,6 +705,8 @@ void render_ui_and_swap()
LLGLState::checkStates();
#endif
}
+ LLVertexBuffer::stopRender();
+ glFlush();
// now do the swap buffer
if (gDisplaySwapBuffers)
@@ -570,6 +714,11 @@ void render_ui_and_swap()
LLFastTimer t(LLFastTimer::FTM_SWAP);
gViewerWindow->mWindow->swapBuffers();
}
+
+ {
+// LLFastTimer ftm(LLFastTimer::FTM_TEMP6);
+ LLVertexBuffer::clientCopy();
+ }
}
}
@@ -585,8 +734,6 @@ void render_ui_3d()
//
// Render selections
-
- glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
@@ -643,7 +790,6 @@ void render_ui_2d()
LLFontGL::sCurOrigin.mY -= llround((F32)gViewerWindow->getWindowHeight() * (F32)pos_y / zoom_factor);
}
-
stop_glerror();
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);