From 068da0b5655fc3c735cd8019ab3b6bb0defec4c0 Mon Sep 17 00:00:00 2001
From: Steven Bennetts <steve@lindenlab.com>
Date: Tue, 6 May 2008 18:09:03 +0000
Subject: [PATCH] merge release-QAR-511 Viewer 1.20 RC 5 merge
 Branch_1-20-Viewer -r 85828 : 86279 -> release

---
 doc/contributions.txt                   |  2 +
 indra/llcommon/llversionviewer.h        |  2 +-
 indra/llrender/llrendertarget.cpp       | 10 ++++
 indra/llrender/llrendertarget.h         |  3 ++
 indra/llrender/llvertexbuffer.cpp       | 16 +++++++
 indra/llui/llfloater.cpp                |  2 +
 indra/llui/lltabcontainer.cpp           |  2 +-
 indra/newview/app_settings/settings.xml |  8 ++--
 indra/newview/gpu_table.txt             |  1 +
 indra/newview/lldrawpoolalpha.cpp       |  4 --
 indra/newview/llface.cpp                |  3 +-
 indra/newview/llfloateranimpreview.cpp  | 64 ++++++++++++++++++-------
 indra/newview/llfloateranimpreview.h    |  3 ++
 indra/newview/llfloatertools.cpp        |  2 +-
 indra/newview/llselectmgr.cpp           |  1 +
 indra/newview/llspatialpartition.cpp    |  2 +-
 indra/newview/llviewerdisplay.cpp       |  6 +--
 indra/newview/llviewerobject.cpp        |  9 +++-
 indra/newview/llviewerwindow.cpp        | 61 +++++++++++------------
 indra/newview/llvoicevisualizer.cpp     |  3 +-
 indra/newview/pipeline.cpp              | 14 +++---
 21 files changed, 145 insertions(+), 73 deletions(-)

diff --git a/doc/contributions.txt b/doc/contributions.txt
index fa470cccae9..b5ca98dc311 100644
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -48,6 +48,8 @@ Alissa Sabre
         VWR-6385
         VWR-5929
         VWR-6430
+        VWR-1843
+        VWR-6668
 Angus Boyd
 	VWR-592
 Argent Stonecutter
diff --git a/indra/llcommon/llversionviewer.h b/indra/llcommon/llversionviewer.h
index dbf1d3154b1..9b4d4ff0a2c 100644
--- a/indra/llcommon/llversionviewer.h
+++ b/indra/llcommon/llversionviewer.h
@@ -34,7 +34,7 @@
 
 const S32 LL_VERSION_MAJOR = 1;
 const S32 LL_VERSION_MINOR = 20;
-const S32 LL_VERSION_PATCH = 4;
+const S32 LL_VERSION_PATCH = 5;
 const S32 LL_VERSION_BUILD = 0;
 
 const char * const LL_CHANNEL = "Second Life Release";
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index cbadb029ac7..4efe078ad7a 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -33,6 +33,7 @@
 
 #include "llrendertarget.h"
 #include "llglimmediate.h"
+#include "llgl.h"
 
 
 BOOL LLRenderTarget::sUseFBO = FALSE;
@@ -150,6 +151,15 @@ void LLRenderTarget::bindTarget()
 	glViewport(0, 0, mResX, mResY);
 }
 
+// static
+void LLRenderTarget::unbindTarget()
+{
+	if (gGLManager.mHasFramebufferObject)
+	{
+		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+	}
+}
+
 void LLRenderTarget::clear()
 {
 	U32 mask = GL_COLOR_BUFFER_BIT;
diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h
index 27c40fcfcf3..df886409704 100644
--- a/indra/llrender/llrendertarget.h
+++ b/indra/llrender/llrendertarget.h
@@ -83,6 +83,9 @@ class LLRenderTarget
 	//bind target for rendering
 	//applies appropriate viewport
 	void bindTarget();
+
+	//unbind target for rendering
+	static void unbindTarget();
 	
 	//clear render targer, clears depth buffer if present,
 	//uses scissor rect if in copy-to-texture mode
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index b646a02cae4..99fd2b33d4b 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -491,6 +491,7 @@ void LLVertexBuffer::destroyGLBuffer()
 	}
 	
 	mGLBuffer = 0;
+	unbind();
 }
 
 void LLVertexBuffer::destroyGLIndices()
@@ -517,6 +518,7 @@ void LLVertexBuffer::destroyGLIndices()
 	}
 
 	mGLIndices = 0;
+	unbind();
 }
 
 void LLVertexBuffer::updateNumVerts(S32 nverts)
@@ -737,8 +739,11 @@ U8* LLVertexBuffer::mapBuffer(S32 access)
 	{
 		setBuffer(0);
 		mLocked = TRUE;
+		stop_glerror();
 		mMappedData = (U8*) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
+		stop_glerror();
 		mMappedIndexData = (U8*) glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
+		stop_glerror();
 		/*if (sMapped)
 		{
 			llerrs << "Mapped two VBOs at the same time!" << llendl;
@@ -767,8 +772,11 @@ void LLVertexBuffer::unmapBuffer()
 	{
 		if (useVBOs() && mLocked)
 		{
+			stop_glerror();
 			glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
+			stop_glerror();
 			glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB);
+			stop_glerror();
 
 			/*if (!sMapped)
 			{
@@ -907,7 +915,9 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 			{
 				llerrs << "VBO bound while another VBO mapped!" << llendl;
 			}*/
+			stop_glerror();
 			glBindBufferARB(GL_ARRAY_BUFFER_ARB, mGLBuffer);
+			stop_glerror();
 			sBindCount++;
 			sVBOActive = TRUE;
 			setup = TRUE; // ... or the bound buffer changed
@@ -918,7 +928,9 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 			{
 				llerrs << "VBO bound while another VBO mapped!" << llendl;
 			}*/
+			stop_glerror();
 			glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mGLIndices);
+			stop_glerror();
 			sBindCount++;
 			sIBOActive = TRUE;
 		}
@@ -927,11 +939,15 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
 		{
 			if (mGLBuffer)
 			{
+				stop_glerror();
 				glBufferDataARB(GL_ARRAY_BUFFER_ARB, getSize(), NULL, mUsage);
+				stop_glerror();
 			}
 			if (mGLIndices)
 			{
+				stop_glerror();
 				glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, getIndicesSize(), NULL, mUsage);
+				stop_glerror();
 			}
 
 			mEmpty = TRUE;
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index f80028656e0..b5958455463 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -2571,6 +2571,8 @@ void LLMultiFloater::addFloater(LLFloater* floaterp, BOOL select_added_floater,
 	floaterp->setCanResize(FALSE);
 	floaterp->setCanDrag(FALSE);
 	floaterp->storeRectControl();
+	// avoid double rendering of floater background (makes it more opaque)
+	floaterp->setBackgroundVisible(FALSE);
 
 	if (mAutoResize)
 	{
diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp
index a1844d34f99..2d1228b084e 100644
--- a/indra/llui/lltabcontainer.cpp
+++ b/indra/llui/lltabcontainer.cpp
@@ -716,7 +716,6 @@ void LLTabContainer::addTabPanel(LLPanel* child,
 	child->setFollowsAll();
 	child->translate( tab_panel_rect.mLeft - child->getRect().mLeft, tab_panel_rect.mBottom - child->getRect().mBottom);
 	child->reshape( tab_panel_rect.getWidth(), tab_panel_rect.getHeight(), TRUE );
-	child->setBackgroundVisible( FALSE );  // No need to overdraw
 	// add this child later
 
 	child->setVisible( FALSE );  // Will be made visible when selected
@@ -1795,3 +1794,4 @@ void LLTabContainer::commitHoveredButton(S32 x, S32 y)
 	}
 }
 
+
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index e954d973105..f1e4b39d7df 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -2855,7 +2855,7 @@
         <key>Type</key>
             <string>Boolean</string>
         <key>Value</key>
-            <string>0</string>
+            <integer>0</integer>
         </map>
     <key>JoystickFlycamEnabled</key>
         <map>
@@ -6089,9 +6089,9 @@
             <string>Color4</string>
         <key>Value</key>
             <array>
-                <real>0.819999992847442626953125</real>
-                <real>0.819999992847442626953125</real>
-                <real>0.9900000095367431640625</real>
+                <real>0.8235294117</real>
+                <real>0.2745098039</real>
+                <real>0.2745098039</real>
                 <real>1</real>
             </array>
         </map>
diff --git a/indra/newview/gpu_table.txt b/indra/newview/gpu_table.txt
index 842e1afaadc..f0b0f0c514b 100644
--- a/indra/newview/gpu_table.txt
+++ b/indra/newview/gpu_table.txt
@@ -195,6 +195,7 @@ NVIDIA GeForce Go 6				.*GeForce Go 6.*					1		1
 NVIDIA GeForce PCX				.*GeForce PCX.*						0		1
 NVIDIA Generic					.*NVIDIA.*Unknown.*					0		0
 NVIDIA NV43						.*NVIDIA.*NV43.*					1		1
+NVIDIA MCP78					.*NVIDIA.*MCP78.*					1		1
 NVIDIA Quadro2					.*Quadro2.*							0		1
 NVIDIA Quadro4					.*Quadro4.*							0		1
 NVIDIA Quadro DCC				.*Quadro DCC.*						0		1
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 795f6bc3965..09901984c4f 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -149,10 +149,6 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
 
 void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask)
 {
-#if !LL_RELEASE_FOR_DOWNLOAD
-	LLGLState::checkClientArrays(mask);
-#endif
-
 	for (LLCullResult::sg_list_t::iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i)
 	{
 		LLSpatialGroup* group = *i;
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 5a683c4c2e5..3ced3541d21 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -411,7 +411,8 @@ void LLFace::renderForSelect(U32 data_mask)
 
 void LLFace::renderSelected(LLImageGL *imagep, const LLColor4& color)
 {
-	if(mDrawablep.isNull() || mVertexBuffer.isNull())
+	if(mDrawablep.isNull() || mVertexBuffer.isNull() || mDrawablep->getSpatialGroup() == NULL ||
+		mDrawablep->getSpatialGroup()->isState(LLSpatialGroup::GEOM_DIRTY))
 	{
 		return;
 	}
diff --git a/indra/newview/llfloateranimpreview.cpp b/indra/newview/llfloateranimpreview.cpp
index aba92791e05..c2495e4037f 100644
--- a/indra/newview/llfloateranimpreview.cpp
+++ b/indra/newview/llfloateranimpreview.cpp
@@ -113,6 +113,34 @@ LLFloaterAnimPreview::LLFloaterAnimPreview(const char* filename) :
 	mIDList["Worry"] = ANIM_AGENT_EXPRESS_WORRY;
 }
 
+//-----------------------------------------------------------------------------
+// setAnimCallbacks()
+//-----------------------------------------------------------------------------
+void LLFloaterAnimPreview::setAnimCallbacks()
+{
+	childSetCommitCallback("playback_slider", onSliderMove, this);
+	
+	childSetCommitCallback("preview_base_anim", onCommitBaseAnim, this);
+	childSetValue("preview_base_anim", "Standing");
+
+	childSetCommitCallback("priority", onCommitPriority, this);
+	childSetCommitCallback("loop_check", onCommitLoop, this);
+	childSetCommitCallback("loop_in_point", onCommitLoopIn, this);
+	childSetValidate("loop_in_point", validateLoopIn);
+	childSetCommitCallback("loop_out_point", onCommitLoopOut, this);
+	childSetValidate("loop_out_point", validateLoopOut);
+
+	childSetCommitCallback("hand_pose_combo", onCommitHandPose, this);
+	
+	childSetCommitCallback("emote_combo", onCommitEmote, this);
+	childSetValue("emote_combo", "[None]");
+
+	childSetCommitCallback("ease_in_time", onCommitEaseIn, this);
+	childSetValidate("ease_in_time", validateEaseIn);
+	childSetCommitCallback("ease_out_time", onCommitEaseOut, this);
+	childSetValidate("ease_out_time", validateEaseOut);
+}
+
 //-----------------------------------------------------------------------------
 // postBuild()
 //-----------------------------------------------------------------------------
@@ -172,29 +200,29 @@ BOOL LLFloaterAnimPreview::postBuild()
 	mStopButton->setScaleImage(TRUE);
 
 	r.set(r.mRight + PREVIEW_HPAD, y, getRect().getWidth() - PREVIEW_HPAD, y - BTN_HEIGHT);
-	childSetCommitCallback("playback_slider", onSliderMove, this);
+	//childSetCommitCallback("playback_slider", onSliderMove, this);
 
 	childHide("bad_animation_text");
 
-	childSetCommitCallback("preview_base_anim", onCommitBaseAnim, this);
-	childSetValue("preview_base_anim", "Standing");
+	//childSetCommitCallback("preview_base_anim", onCommitBaseAnim, this);
+	//childSetValue("preview_base_anim", "Standing");
 
-	childSetCommitCallback("priority", onCommitPriority, this);
-	childSetCommitCallback("loop_check", onCommitLoop, this);
-	childSetCommitCallback("loop_in_point", onCommitLoopIn, this);
-	childSetValidate("loop_in_point", validateLoopIn);
-	childSetCommitCallback("loop_out_point", onCommitLoopOut, this);
-	childSetValidate("loop_out_point", validateLoopOut);
+	//childSetCommitCallback("priority", onCommitPriority, this);
+	//childSetCommitCallback("loop_check", onCommitLoop, this);
+	//childSetCommitCallback("loop_in_point", onCommitLoopIn, this);
+	//childSetValidate("loop_in_point", validateLoopIn);
+	//childSetCommitCallback("loop_out_point", onCommitLoopOut, this);
+	//childSetValidate("loop_out_point", validateLoopOut);
 
-	childSetCommitCallback("hand_pose_combo", onCommitHandPose, this);
+	//childSetCommitCallback("hand_pose_combo", onCommitHandPose, this);
 	
-	childSetCommitCallback("emote_combo", onCommitEmote, this);
-	childSetValue("emote_combo", "[None]");
+	//childSetCommitCallback("emote_combo", onCommitEmote, this);
+	//childSetValue("emote_combo", "[None]");
 
-	childSetCommitCallback("ease_in_time", onCommitEaseIn, this);
-	childSetValidate("ease_in_time", validateEaseIn);
-	childSetCommitCallback("ease_out_time", onCommitEaseOut, this);
-	childSetValidate("ease_out_time", validateEaseOut);
+	//childSetCommitCallback("ease_in_time", onCommitEaseIn, this);
+	//childSetValidate("ease_in_time", validateEaseIn);
+	//childSetCommitCallback("ease_out_time", onCommitEaseOut, this);
+	//childSetValidate("ease_out_time", validateEaseOut);
 
 	if (!stricmp(strrchr(mFilename.c_str(), '.'), ".bvh"))
 	{
@@ -254,6 +282,8 @@ BOOL LLFloaterAnimPreview::postBuild()
 
 		if (success)
 		{
+			setAnimCallbacks() ;
+			
 			const LLBBoxLocal &pelvis_bbox = motionp->getPelvisBBox();
 
 			LLVector3 temp = pelvis_bbox.getCenter();
@@ -314,7 +344,7 @@ BOOL LLFloaterAnimPreview::postBuild()
 			}
 		}
 
-		setEnabled(FALSE);
+		//setEnabled(FALSE);
 		mMotionID.setNull();
 		mAnimPreview = NULL;
 	}
diff --git a/indra/newview/llfloateranimpreview.h b/indra/newview/llfloateranimpreview.h
index e2383c57e82..cbfba0c43ec 100644
--- a/indra/newview/llfloateranimpreview.h
+++ b/indra/newview/llfloateranimpreview.h
@@ -106,6 +106,9 @@ class LLFloaterAnimPreview : public LLFloaterNameDesc
 									   LLAssetType::EType type,
 									   void* user_data,
 									   S32 status, LLExtStat ext_status);
+private:
+	void setAnimCallbacks() ;
+	
 protected:
 	void			draw();
 	void			resetMotion();
diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp
index 55be7a199c1..b8f7e3ed0ab 100644
--- a/indra/newview/llfloatertools.cpp
+++ b/indra/newview/llfloatertools.cpp
@@ -776,7 +776,7 @@ void LLFloaterTools::onClose(bool app_quitting)
 	setVisible(FALSE);
 	mTab->setVisible(FALSE);
 
-	LLViewerJoystick::getInstance()->moveAvatar(true);
+	LLViewerJoystick::getInstance()->moveAvatar(false);
 
     // Different from handle_reset_view in that it doesn't actually 
 	//   move the camera if EditCameraMovement is not set.
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index abda5067e59..5eacb25ded7 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -158,6 +158,7 @@ static LLPointer<LLObjectSelection> sNullSelection;
 void LLSelectMgr::cleanupGlobals()
 {
 	sNullSelection = NULL;
+	LLSelectMgr::getInstance()->clearSelections();
 }
 
 LLObjectSelection *get_null_object_selection()
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 59fa2c4bcc8..b7cdf04de79 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -2421,7 +2421,7 @@ class LLOctreeRenderNonOccluded : public LLOctreeTraveler<LLDrawable>
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) branch->getListener(0);
 
-		if (mCamera && !mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1]))
+		if (group->isState(LLSpatialGroup::GEOM_DIRTY) || (mCamera && !mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1])))
 		{
 			return;
 		}
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 583139298ff..152c614c084 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -545,8 +545,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 
 		BOOL to_texture = !for_snapshot &&
 						gPipeline.canUseVertexShaders() &&
-						LLPipeline::sRenderGlow &&
-						gGLManager.mHasFramebufferObject;
+						LLPipeline::sRenderGlow;
 
 		// now do the swap buffer (just before rendering to framebuffer)
 		{ //swap and flush state from previous frame
@@ -893,8 +892,7 @@ void render_ui_and_swap()
 	
 	{
 		BOOL to_texture = gPipeline.canUseVertexShaders() &&
-							LLPipeline::sRenderGlow &&
-							gGLManager.mHasFramebufferObject;
+							LLPipeline::sRenderGlow;
 
 		if (to_texture)
 		{
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 227a0d9ebef..af662d92aa6 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -1861,9 +1861,14 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 	if (new_rot != mLastRot
 		|| new_angv != old_angv)
 	{
-		mLastRot = new_rot;
+		if (new_rot != mLastRot)
+		{
+			mLastRot = new_rot;
+			setRotation(new_rot);
+		}
+		
 		setChanged(ROTATED | SILHOUETTE);
-		setRotation(new_rot);
+		
 		resetRot();
 	}
 
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index b3f8c6d5ebd..e403df7f450 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1684,7 +1684,7 @@ void LLViewerWindow::initBase()
 	F32 gamma = gSavedSettings.getF32("RenderGamma");
 	if (gamma != 0.0f)
 	{
-		gViewerWindow->getWindow()->setGamma(gamma);
+		getWindow()->setGamma(gamma);
 	}
 
 	// Create global views
@@ -1953,7 +1953,7 @@ void LLViewerWindow::initWorldUI()
 
 		// Status bar
 		S32 menu_bar_height = gMenuBarView->getRect().getHeight();
-		LLRect root_rect = gViewerWindow->getRootView()->getRect();
+		LLRect root_rect = getRootView()->getRect();
 		LLRect status_rect(0, root_rect.getHeight(), root_rect.getWidth(), root_rect.getHeight() - menu_bar_height);
 		gStatusBar = new LLStatusBar("status", status_rect);
 		gStatusBar->setFollows(FOLLOWS_LEFT | FOLLOWS_RIGHT | FOLLOWS_TOP);
@@ -1965,10 +1965,10 @@ void LLViewerWindow::initWorldUI()
 
 		LLFloaterChatterBox::createInstance(LLSD());
 
-		gViewerWindow->getRootView()->addChild(gStatusBar);
+		getRootView()->addChild(gStatusBar);
 
 		// menu holder appears on top to get first pass at all mouse events
-		gViewerWindow->getRootView()->sendChildToFront(gMenuHolder);
+		getRootView()->sendChildToFront(gMenuHolder);
 	}
 }
 
@@ -2313,8 +2313,8 @@ 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)gViewerWindow->getWindowWidth() * -(F32)pos_x, 
-						(F32)gViewerWindow->getWindowHeight() * -(F32)pos_y, 
+			glTranslatef((F32)getWindowWidth() * -(F32)pos_x, 
+						(F32)getWindowHeight() * -(F32)pos_y, 
 						0.f);
 			glScalef(zoom_factor, zoom_factor, 1.f);
 			LLUI::sGLScaleFactor *= zoom_factor;
@@ -2379,8 +2379,8 @@ void LLViewerWindow::draw()
 			const S32 DIST_FROM_TOP = 20;
 			LLFontGL::sSansSerifBig->renderUTF8(
 				mOverlayTitle, 0,
-				llround( gViewerWindow->getWindowWidth() * 0.5f),
-				gViewerWindow->getWindowHeight() - DIST_FROM_TOP,
+				llround( getWindowWidth() * 0.5f),
+				getWindowHeight() - DIST_FROM_TOP,
 				LLColor4(1, 1, 1, 0.4f),
 				LLFontGL::HCENTER, LLFontGL::TOP);
 		}
@@ -3534,8 +3534,8 @@ void LLViewerWindow::hitUIElementAsync(S32 x, S32 y_from_bot, MASK mask, void (*
 	// build orthogonal transform and picking viewport
 	// Perform pick on a PICK_DIAMETER x PICK_DIAMETER pixel region around cursor point.
 	// Don't limit the select distance for this pick.
-	gViewerWindow->setup2DRender();
-	const LLVector2& display_scale = gViewerWindow->getDisplayScale();
+	setup2DRender();
+	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);
@@ -3549,7 +3549,7 @@ void LLViewerWindow::hitUIElementAsync(S32 x, S32 y_from_bot, MASK mask, void (*
 
 	// Draw the objects so the user can select them.
 	// The starting ID is 1, since land is zero.
-	//gViewerWindow->drawForSelect();
+	//drawForSelect();
 
 	stop_glerror();
 
@@ -3579,8 +3579,8 @@ void LLViewerWindow::performPick()
 	
 	// find pick region that is fully onscreen
 	LLCoordGL scaled_pick_point = mPickPoint;
-	scaled_pick_point.mX = llclamp(llround((F32)mPickPoint.mX * mDisplayScale.mV[VX]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayWidth() - PICK_HALF_WIDTH);
-	scaled_pick_point.mY = llclamp(llround((F32)mPickPoint.mY * mDisplayScale.mV[VY]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayHeight() - PICK_HALF_WIDTH);
+	scaled_pick_point.mX = llclamp(llround((F32)mPickPoint.mX * mDisplayScale.mV[VX]), PICK_HALF_WIDTH, getWindowDisplayWidth() - PICK_HALF_WIDTH);
+	scaled_pick_point.mY = llclamp(llround((F32)mPickPoint.mY * mDisplayScale.mV[VY]), PICK_HALF_WIDTH, getWindowDisplayHeight() - PICK_HALF_WIDTH);
 
 	glReadPixels(scaled_pick_point.mX - PICK_HALF_WIDTH, scaled_pick_point.mY - PICK_HALF_WIDTH, PICK_DIAMETER, PICK_DIAMETER, GL_RGBA, GL_UNSIGNED_BYTE, mPickBuffer);
 
@@ -4152,7 +4152,7 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageRaw *raw, const LLString& extensio
 		filepath += extension;
 
 		struct stat stat_info;
-		err = gViewerWindow->mWindow->stat( filepath.c_str(), &stat_info );
+		err = mWindow->stat( filepath.c_str(), &stat_info );
 		i++;
 	}
 	while( -1 != err );  // search until the file is not found (i.e., stat() gives an error).
@@ -4177,6 +4177,7 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageRaw *raw, const LLString& extensio
 static S32 BORDERHEIGHT = 0;
 static S32 BORDERWIDTH = 0;
 
+// static
 void LLViewerWindow::movieSize(S32 new_width, S32 new_height)
 {
 	LLCoordScreen size;
@@ -4657,7 +4658,7 @@ void LLViewerWindow::drawMouselookInstructions()
 	LLRect instructions_rect;
 	instructions_rect.setLeftTopAndSize( 
 		INSTRUCTIONS_PAD,
-		gViewerWindow->getWindowHeight() - INSTRUCTIONS_PAD,
+		getWindowHeight() - INSTRUCTIONS_PAD,
 		font->getWidth( instructions ) + 2 * INSTRUCTIONS_PAD,
 		llround(font->getLineHeight() + 2 * INSTRUCTIONS_PAD));
 
@@ -4980,11 +4981,11 @@ void LLViewerWindow::getTargetWindow(BOOL& fullscreen, S32& width, S32& height)
 {
 	fullscreen = mWantFullscreen;
 	
-	if (gViewerWindow->mWindow
-	&&  gViewerWindow->mWindow->getFullscreen() == mWantFullscreen)
+	if (mWindow
+	&&  mWindow->getFullscreen() == mWantFullscreen)
 	{
-		width = gViewerWindow->getWindowDisplayWidth();
-		height = gViewerWindow->getWindowDisplayHeight();
+		width = getWindowDisplayWidth();
+		height = getWindowDisplayHeight();
 	}
 	else if (mWantFullscreen)
 	{
@@ -5001,14 +5002,14 @@ void LLViewerWindow::getTargetWindow(BOOL& fullscreen, S32& width, S32& height)
 
 BOOL LLViewerWindow::checkSettings()
 {
-	BOOL is_fullscreen = gViewerWindow->mWindow->getFullscreen();
+	BOOL is_fullscreen = mWindow->getFullscreen();
 	if (is_fullscreen && !mWantFullscreen)
 	{
-		gViewerWindow->changeDisplaySettings(FALSE, 
-											 LLCoordScreen(gSavedSettings.getS32("WindowWidth"),
-														   gSavedSettings.getS32("WindowHeight")),
-											 TRUE,
-											 mShowFullscreenProgress);
+		changeDisplaySettings(FALSE, 
+							  LLCoordScreen(gSavedSettings.getS32("WindowWidth"),
+											gSavedSettings.getS32("WindowHeight")),
+							  TRUE,
+							  mShowFullscreenProgress);
 		return TRUE;
 	}
 	else if (!is_fullscreen && mWantFullscreen)
@@ -5022,11 +5023,11 @@ BOOL LLViewerWindow::checkSettings()
 		LLGLState::checkStates();
 		LLGLState::checkTextureChannels();
 #endif
-		gViewerWindow->changeDisplaySettings(TRUE, 
-											 LLCoordScreen(gSavedSettings.getS32("FullScreenWidth"),
-														   gSavedSettings.getS32("FullScreenHeight")),
-											 gSavedSettings.getBOOL("DisableVerticalSync"),
-											 mShowFullscreenProgress);
+		changeDisplaySettings(TRUE, 
+							  LLCoordScreen(gSavedSettings.getS32("FullScreenWidth"),
+											gSavedSettings.getS32("FullScreenHeight")),
+							  gSavedSettings.getBOOL("DisableVerticalSync"),
+							  mShowFullscreenProgress);
 
 #ifndef LL_RELEASE_FOR_DOWNLOAD
 		LLGLState::checkStates();
diff --git a/indra/newview/llvoicevisualizer.cpp b/indra/newview/llvoicevisualizer.cpp
index 38d435ff74e..87f0ffdbee9 100644
--- a/indra/newview/llvoicevisualizer.cpp
+++ b/indra/newview/llvoicevisualizer.cpp
@@ -369,7 +369,8 @@ void LLVoiceVisualizer::render()
 		//---------------------------------------------------------------
 		// some gl state
 		//---------------------------------------------------------------
-		LLGLEnable blend( GL_BLEND );
+		LLGLSPipelineAlpha alpha_blend;
+		LLGLDepthTest depth(GL_TRUE, GL_FALSE);
 		
 		//-------------------------------------------------------------
 		// create coordinates of the geometry for the dot
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 69f2a4c4b7a..4f71e33af55 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1162,8 +1162,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
 						!hasRenderType(LLPipeline::RENDER_TYPE_HUD) && 
 						!sReflectionRender &&
 						gPipeline.canUseVertexShaders() &&
-						sRenderGlow &&
-						gGLManager.mHasFramebufferObject;
+						sRenderGlow;
 
 	if (to_texture)
 	{
@@ -1243,7 +1242,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
 	if (to_texture)
 	{
 		mScreen.flush();
-		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+		LLRenderTarget::unbindTarget();
 	}
 	else if (LLPipeline::sUseOcclusion > 1)
 	{
@@ -2258,6 +2257,8 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
 
 	glEnableClientState(GL_VERTEX_ARRAY);
 
+	LLVertexBuffer::unbind();
+
 	// Do verification of GL state
 #ifndef LL_RELEASE_FOR_DOWNLOAD
 	LLGLState::checkStates();
@@ -4462,8 +4463,7 @@ void LLPipeline::bindScreenToTexture()
 void LLPipeline::renderBloom(BOOL for_snapshot)
 {
 	if (!(gPipeline.canUseVertexShaders() &&
-		sRenderGlow &&
-		gGLManager.mHasFramebufferObject))
+		sRenderGlow))
 	{
 		return;
 	}
@@ -4862,6 +4862,8 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 {
 	if (LLPipeline::sWaterReflections && assertInitialized() && LLDrawPoolWater::sNeedsReflectionUpdate)
 	{
+		LLVertexBuffer::unbind();
+
 #ifndef LL_RELEASE_FOR_DOWNLOAD
 		LLGLState::checkStates();
 		LLGLState::checkTextureChannels();
@@ -5039,7 +5041,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 		}
 		last_update = LLDrawPoolWater::sNeedsReflectionUpdate && LLDrawPoolWater::sNeedsDistortionUpdate;
 
-		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+		LLRenderTarget::unbindTarget();
 		LLPipeline::sReflectionRender = FALSE;
 
 		if (!LLRenderTarget::sUseFBO)
-- 
GitLab