summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewerwindow.cpp')
-rw-r--r--indra/newview/llviewerwindow.cpp90
1 files changed, 48 insertions, 42 deletions
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 8f675e66e7..8f79253cf3 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -43,7 +43,7 @@
#include "llviewquery.h"
#include "llxmltree.h"
//#include "llviewercamera.h"
-#include "llglimmediate.h"
+#include "llrender.h"
#include "llvoiceclient.h" // for push-to-talk button handling
@@ -182,6 +182,7 @@
#include "llviewerdisplay.h"
#include "llspatialpartition.h"
#include "llviewerjoystick.h"
+#include "llviewernetwork.h"
#if LL_WINDOWS
#include "llwindebug.h"
@@ -191,12 +192,12 @@
//
// Globals
//
-void render_ui_and_swap_if_needed();
void render_ui_and_swap();
LLBottomPanel* gBottomPanel = NULL;
extern BOOL gDebugClicks;
extern BOOL gDisplaySwapBuffers;
+extern BOOL gDepthDirty;
extern BOOL gResizeScreenTexture;
extern S32 gJamesInt;
@@ -1638,7 +1639,7 @@ LLViewerWindow::LLViewerWindow(
void LLViewerWindow::initGLDefaults()
{
- gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ 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 };
@@ -1656,7 +1657,7 @@ void LLViewerWindow::initGLDefaults()
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
glCullFace(GL_BACK);
@@ -2198,7 +2199,7 @@ void LLViewerWindow::setNormalControlsVisible( BOOL visible )
// ...and set the menu color appropriately.
setMenuBackgroundColor(gAgent.getGodLevel() > GOD_NOT,
- LLAppViewer::instance()->isInProductionGrid());
+ LLViewerLogin::getInstance()->isInProductionGrid());
}
if ( gStatusBar )
@@ -2213,15 +2214,15 @@ void LLViewerWindow::setMenuBackgroundColor(bool god_mode, bool dev_grid)
LLString::format_map_t args;
LLColor4 new_bg_color;
- if(god_mode && LLAppViewer::instance()->isInProductionGrid())
+ if(god_mode && LLViewerLogin::getInstance()->isInProductionGrid())
{
new_bg_color = gColors.getColor( "MenuBarGodBgColor" );
}
- else if(god_mode && !LLAppViewer::instance()->isInProductionGrid())
+ else if(god_mode && !LLViewerLogin::getInstance()->isInProductionGrid())
{
new_bg_color = gColors.getColor( "MenuNonProductionGodBgColor" );
}
- else if(!god_mode && !LLAppViewer::instance()->isInProductionGrid())
+ else if(!god_mode && !LLViewerLogin::getInstance()->isInProductionGrid())
{
new_bg_color = gColors.getColor( "MenuNonProductionBgColor" );
}
@@ -3386,9 +3387,8 @@ void LLViewerWindow::hitObjectOrLandGlobalAsync(S32 x, S32 y_from_bot, MASK mask
return;
}
- render_ui_and_swap_if_needed();
glClear(GL_DEPTH_BUFFER_BIT);
- gDisplaySwapBuffers = FALSE;
+ gDepthDirty = TRUE;
S32 scaled_x = llround((F32)x * mDisplayScale.mV[VX]);
S32 scaled_y = llround((F32)y_from_bot * mDisplayScale.mV[VY]);
@@ -3538,7 +3538,7 @@ void LLViewerWindow::hitUIElementAsync(S32 x, S32 y_from_bot, MASK mask, void (*
const LLVector2& display_scale = getDisplayScale();
glScalef(display_scale.mV[VX], display_scale.mV[VY], 1.f);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
// make viewport big enough to handle antialiased frame buffers
glViewport(x - (PICK_HALF_WIDTH + 2), y_from_bot - (PICK_HALF_WIDTH + 2), PICK_DIAMETER + 4, PICK_DIAMETER + 4);
@@ -4281,7 +4281,8 @@ BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 p
LLRect window_rect = mWindowRect;
mWindowRect.set(0, h, w, 0);
- gDisplaySwapBuffers = FALSE;
+ gDisplaySwapBuffers = FALSE;
+ gDepthDirty = TRUE;
glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
setup3DRender();
@@ -4349,6 +4350,7 @@ BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 p
setup3DRender();
setupViewport();
gDisplaySwapBuffers = FALSE;
+ gDepthDirty = TRUE;
// POST SNAPSHOT
if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
@@ -4388,7 +4390,6 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
}
// PRE SNAPSHOT
- render_ui_and_swap_if_needed();
gDisplaySwapBuffers = FALSE;
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
@@ -4419,6 +4420,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
LLRect window_rect = mWindowRect;
BOOL use_fbo = FALSE;
+ LLRenderTarget target;
F32 scale_factor = 1.0f ;
if(!keep_window_aspect) //image cropping
{
@@ -4427,37 +4429,39 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
snapshot_height = (S32)(ratio * image_height) ;
scale_factor = llmax(1.0f, 1.0f / ratio) ;
}
-
- LLRenderTarget target;
- if (gGLManager.mHasFramebufferObject &&
- (image_width > window_width ||
- image_height > window_height) &&
- !show_ui &&
- keep_window_aspect)
- {
- GLint max_size = 0;
- glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &max_size);
-
- if (image_width <= max_size && image_height <= max_size)
- {
- use_fbo = TRUE;
-
- snapshot_width = image_width;
- snapshot_height = image_height;
- target.allocate(snapshot_width, snapshot_height, GL_RGBA, TRUE, GL_TEXTURE_RECTANGLE_ARB, TRUE);
- window_width = snapshot_width;
- window_height = snapshot_height;
- scale_factor = 1.f;
- mWindowRect.set(0, 0, snapshot_width, snapshot_height);
- target.bindTarget();
- }
- else //tiling
+ else //the scene(window) proportion needs to be maintained.
+ {
+ if(image_width > window_width || image_height > window_height) //need to enlarge the scene
{
- F32 ratio = llmin( (F32)window_width / image_width , (F32)window_height / image_height) ;
- snapshot_width = (S32)(ratio * image_width) ;
- snapshot_height = (S32)(ratio * image_height) ;
- scale_factor = llmax(1.0f, 1.0f / ratio) ;
+ if (gGLManager.mHasFramebufferObject && !show_ui)
+ {
+ GLint max_size = 0;
+ glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &max_size);
+
+ if (image_width <= max_size && image_height <= max_size) //re-project the scene
+ {
+ use_fbo = TRUE;
+
+ snapshot_width = image_width;
+ snapshot_height = image_height;
+ target.allocate(snapshot_width, snapshot_height, GL_RGBA, TRUE, GL_TEXTURE_RECTANGLE_ARB, TRUE);
+ window_width = snapshot_width;
+ window_height = snapshot_height;
+ scale_factor = 1.f;
+ mWindowRect.set(0, 0, snapshot_width, snapshot_height);
+ target.bindTarget();
+ }
+ }
+
+ if(!use_fbo) //no re-projection, so tiling the scene
+ {
+ F32 ratio = llmin( (F32)window_width / image_width , (F32)window_height / image_height) ;
+ snapshot_width = (S32)(ratio * image_width) ;
+ snapshot_height = (S32)(ratio * image_height) ;
+ scale_factor = llmax(1.0f, 1.0f / ratio) ;
+ }
}
+ //else: keep the current scene scale, re-scale it if necessary after reading out.
}
S32 buffer_x_offset = llfloor(((window_width - snapshot_width) * scale_factor) / 2.f);
@@ -4502,6 +4506,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
for (int subimage_x = 0; subimage_x < scale_factor; ++subimage_x)
{
gDisplaySwapBuffers = FALSE;
+ gDepthDirty = TRUE;
if (type == SNAPSHOT_TYPE_OBJECT_ID)
{
glClearColor(0.f, 0.f, 0.f, 0.f);
@@ -4585,6 +4590,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
gDisplaySwapBuffers = FALSE;
+ gDepthDirty = TRUE;
// POST SNAPSHOT
if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))