aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewerwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llviewerwindow.cpp')
-rw-r--r--linden/indra/newview/llviewerwindow.cpp431
1 files changed, 282 insertions, 149 deletions
diff --git a/linden/indra/newview/llviewerwindow.cpp b/linden/indra/newview/llviewerwindow.cpp
index b0577e6..eaaa4d2 100644
--- a/linden/indra/newview/llviewerwindow.cpp
+++ b/linden/indra/newview/llviewerwindow.cpp
@@ -42,7 +42,7 @@
42#include "llviewquery.h" 42#include "llviewquery.h"
43#include "llxmltree.h" 43#include "llxmltree.h"
44//#include "llviewercamera.h" 44//#include "llviewercamera.h"
45//#include "imdebug.h" 45#include "llglimmediate.h"
46 46
47#include "llvoiceclient.h" // for push-to-talk button handling 47#include "llvoiceclient.h" // for push-to-talk button handling
48 48
@@ -57,10 +57,8 @@
57// linden library includes 57// linden library includes
58#include "audioengine.h" // mute on minimize 58#include "audioengine.h" // mute on minimize
59#include "indra_constants.h" 59#include "indra_constants.h"
60#include "linked_lists.h"
61#include "llassetstorage.h" 60#include "llassetstorage.h"
62#include "llfontgl.h" 61#include "llfontgl.h"
63#include "llmediaengine.h" // mute on minimize
64#include "llrect.h" 62#include "llrect.h"
65#include "llsky.h" 63#include "llsky.h"
66#include "llstring.h" 64#include "llstring.h"
@@ -184,6 +182,7 @@
184#include "llappviewer.h" 182#include "llappviewer.h"
185#include "llurlsimstring.h" 183#include "llurlsimstring.h"
186#include "llviewerdisplay.h" 184#include "llviewerdisplay.h"
185#include "llspatialpartition.h"
187 186
188#if LL_WINDOWS 187#if LL_WINDOWS
189#include "llwindebug.h" 188#include "llwindebug.h"
@@ -193,11 +192,13 @@
193// 192//
194// Globals 193// Globals
195// 194//
196 195void render_ui_and_swap_if_needed();
196void render_ui_and_swap();
197LLBottomPanel* gBottomPanel = NULL; 197LLBottomPanel* gBottomPanel = NULL;
198 198
199extern BOOL gDebugClicks; 199extern BOOL gDebugClicks;
200extern BOOL gDisplaySwapBuffers; 200extern BOOL gDisplaySwapBuffers;
201extern BOOL gResizeScreenTexture;
201extern S32 gJamesInt; 202extern S32 gJamesInt;
202 203
203LLViewerWindow *gViewerWindow = NULL; 204LLViewerWindow *gViewerWindow = NULL;
@@ -532,13 +533,68 @@ public:
532 addText(xpos, ypos, llformat("%d MB Vertex Data", LLVertexBuffer::sAllocatedBytes/(1024*1024))); 533 addText(xpos, ypos, llformat("%d MB Vertex Data", LLVertexBuffer::sAllocatedBytes/(1024*1024)));
533 ypos += y_inc; 534 ypos += y_inc;
534 535
535 addText(xpos, ypos, llformat("%d Pending Lock", LLVertexBuffer::sLockedList.size())); 536 addText(xpos, ypos, llformat("%d Vertex Buffers", LLVertexBuffer::sGLCount));
536 ypos += y_inc; 537 ypos += y_inc;
537 538
538 addText(xpos, ypos, llformat("%d Vertex Buffers", LLVertexBuffer::sGLCount)); 539 addText(xpos, ypos, llformat("%d Mapped Buffers", LLVertexBuffer::sMappedCount));
540 ypos += y_inc;
541
542 addText(xpos, ypos, llformat("%d Vertex Buffer Binds", LLVertexBuffer::sBindCount));
543 ypos += y_inc;
544
545 addText(xpos, ypos, llformat("%d Vertex Buffer Sets", LLVertexBuffer::sSetCount));
546 ypos += y_inc;
547
548 addText(xpos, ypos, llformat("%d Texture Binds", LLImageGL::sBindCount));
539 ypos += y_inc; 549 ypos += y_inc;
540 }
541 550
551 addText(xpos, ypos, llformat("%d Unique Textures", LLImageGL::sUniqueCount));
552 ypos += y_inc;
553
554 addText(xpos, ypos, llformat("%d Render Calls", gPipeline.mBatchCount));
555 ypos += y_inc;
556
557 addText(xpos, ypos, llformat("%d Matrix Ops", gPipeline.mMatrixOpCount));
558 ypos += y_inc;
559
560 addText(xpos, ypos, llformat("%d Texture Matrix Ops", gPipeline.mTextureMatrixOps));
561 ypos += y_inc;
562
563 gPipeline.mTextureMatrixOps = 0;
564 gPipeline.mMatrixOpCount = 0;
565
566 if (gPipeline.mBatchCount > 0)
567 {
568 addText(xpos, ypos, llformat("Batch min/max/mean: %d/%d/%d", gPipeline.mMinBatchSize, gPipeline.mMaxBatchSize,
569 gPipeline.mMeanBatchSize));
570
571 gPipeline.mMinBatchSize = gPipeline.mMaxBatchSize;
572 gPipeline.mMaxBatchSize = 0;
573 gPipeline.mBatchCount = 0;
574 }
575 ypos += y_inc;
576
577 addText(xpos,ypos, llformat("%d/%d Nodes visible", gPipeline.mNumVisibleNodes, LLSpatialGroup::sNodeCount));
578
579 ypos += y_inc;
580
581
582 addText(xpos,ypos, llformat("%d Avatars visible", LLVOAvatar::sNumVisibleAvatars));
583
584 ypos += y_inc;
585
586 LLVertexBuffer::sBindCount = LLImageGL::sBindCount =
587 LLVertexBuffer::sSetCount = LLImageGL::sUniqueCount =
588 gPipeline.mNumVisibleNodes = 0;
589 }
590 if (gSavedSettings.getBOOL("DebugShowColor"))
591 {
592 U8 color[4];
593 LLCoordGL coord = gViewerWindow->getCurrentMouse();
594 glReadPixels(coord.mX, coord.mY, 1,1,GL_RGBA, GL_UNSIGNED_BYTE, color);
595 addText(xpos, ypos, llformat("%d %d %d %d", color[0], color[1], color[2], color[3]));
596 ypos += y_inc;
597 }
542 // only display these messages if we are actually rendering beacons at this moment 598 // only display these messages if we are actually rendering beacons at this moment
543 if (LLPipeline::getRenderBeacons(NULL) && LLPipeline::getProcessBeacons(NULL)) 599 if (LLPipeline::getRenderBeacons(NULL) && LLPipeline::getProcessBeacons(NULL))
544 { 600 {
@@ -608,6 +664,8 @@ BOOL LLViewerWindow::handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask
608 x = llround((F32)x / mDisplayScale.mV[VX]); 664 x = llround((F32)x / mDisplayScale.mV[VX]);
609 y = llround((F32)y / mDisplayScale.mV[VY]); 665 y = llround((F32)y / mDisplayScale.mV[VY]);
610 666
667 LLView::sMouseHandlerMessage = "";
668
611 if (gDebugClicks) 669 if (gDebugClicks)
612 { 670 {
613 llinfos << "ViewerWindow left mouse down at " << x << "," << y << llendl; 671 llinfos << "ViewerWindow left mouse down at " << x << "," << y << llendl;
@@ -685,7 +743,6 @@ BOOL LLViewerWindow::handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask
685 if (LLView::sDebugMouseHandling) 743 if (LLView::sDebugMouseHandling)
686 { 744 {
687 llinfos << "Left Mouse Down" << LLView::sMouseHandlerMessage << llendl; 745 llinfos << "Left Mouse Down" << LLView::sMouseHandlerMessage << llendl;
688 LLView::sMouseHandlerMessage = "";
689 } 746 }
690 return TRUE; 747 return TRUE;
691 } 748 }
@@ -721,6 +778,8 @@ BOOL LLViewerWindow::handleDoubleClick(LLWindow *window, LLCoordGL pos, MASK ma
721 x = llround((F32)x / mDisplayScale.mV[VX]); 778 x = llround((F32)x / mDisplayScale.mV[VX]);
722 y = llround((F32)y / mDisplayScale.mV[VY]); 779 y = llround((F32)y / mDisplayScale.mV[VY]);
723 780
781 LLView::sMouseHandlerMessage = "";
782
724 if (gDebugClicks) 783 if (gDebugClicks)
725 { 784 {
726 llinfos << "ViewerWindow left mouse double-click at " << x << "," << y << llendl; 785 llinfos << "ViewerWindow left mouse double-click at " << x << "," << y << llendl;
@@ -769,7 +828,6 @@ BOOL LLViewerWindow::handleDoubleClick(LLWindow *window, LLCoordGL pos, MASK ma
769 if (LLView::sDebugMouseHandling) 828 if (LLView::sDebugMouseHandling)
770 { 829 {
771 llinfos << "Left Mouse Down" << LLView::sMouseHandlerMessage << llendl; 830 llinfos << "Left Mouse Down" << LLView::sMouseHandlerMessage << llendl;
772 LLView::sMouseHandlerMessage = "";
773 } 831 }
774 return TRUE; 832 return TRUE;
775 } 833 }
@@ -803,6 +861,8 @@ BOOL LLViewerWindow::handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask)
803 x = llround((F32)x / mDisplayScale.mV[VX]); 861 x = llround((F32)x / mDisplayScale.mV[VX]);
804 y = llround((F32)y / mDisplayScale.mV[VY]); 862 y = llround((F32)y / mDisplayScale.mV[VY]);
805 863
864 LLView::sMouseHandlerMessage = "";
865
806 if (gDebugClicks) 866 if (gDebugClicks)
807 { 867 {
808 llinfos << "ViewerWindow left mouse up" << llendl; 868 llinfos << "ViewerWindow left mouse up" << llendl;
@@ -869,7 +929,6 @@ BOOL LLViewerWindow::handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask)
869 if (handled) 929 if (handled)
870 { 930 {
871 llinfos << "Left Mouse Up" << LLView::sMouseHandlerMessage << llendl; 931 llinfos << "Left Mouse Up" << LLView::sMouseHandlerMessage << llendl;
872 LLView::sMouseHandlerMessage = "";
873 } 932 }
874 else 933 else
875 { 934 {
@@ -897,6 +956,8 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK
897 x = llround((F32)x / mDisplayScale.mV[VX]); 956 x = llround((F32)x / mDisplayScale.mV[VX]);
898 y = llround((F32)y / mDisplayScale.mV[VY]); 957 y = llround((F32)y / mDisplayScale.mV[VY]);
899 958
959 LLView::sMouseHandlerMessage = "";
960
900 if (gDebugClicks) 961 if (gDebugClicks)
901 { 962 {
902 llinfos << "ViewerWindow right mouse down at " << x << "," << y << llendl; 963 llinfos << "ViewerWindow right mouse down at " << x << "," << y << llendl;
@@ -967,7 +1028,6 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK
967 if (LLView::sDebugMouseHandling) 1028 if (LLView::sDebugMouseHandling)
968 { 1029 {
969 llinfos << "Right Mouse Down" << LLView::sMouseHandlerMessage << llendl; 1030 llinfos << "Right Mouse Down" << LLView::sMouseHandlerMessage << llendl;
970 LLView::sMouseHandlerMessage = "";
971 } 1031 }
972 return TRUE; 1032 return TRUE;
973 } 1033 }
@@ -1009,6 +1069,8 @@ BOOL LLViewerWindow::handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK m
1009 x = llround((F32)x / mDisplayScale.mV[VX]); 1069 x = llround((F32)x / mDisplayScale.mV[VX]);
1010 y = llround((F32)y / mDisplayScale.mV[VY]); 1070 y = llround((F32)y / mDisplayScale.mV[VY]);
1011 1071
1072 LLView::sMouseHandlerMessage = "";
1073
1012 // Don't care about caps lock for mouse events. 1074 // Don't care about caps lock for mouse events.
1013 if (gDebugClicks) 1075 if (gDebugClicks)
1014 { 1076 {
@@ -1075,7 +1137,6 @@ BOOL LLViewerWindow::handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK m
1075 if (handled) 1137 if (handled)
1076 { 1138 {
1077 llinfos << "Right Mouse Up" << LLView::sMouseHandlerMessage << llendl; 1139 llinfos << "Right Mouse Up" << LLView::sMouseHandlerMessage << llendl;
1078 LLView::sMouseHandlerMessage = "";
1079 } 1140 }
1080 else 1141 else
1081 { 1142 {
@@ -1505,63 +1566,39 @@ LLViewerWindow::LLViewerWindow(
1505 1566
1506 LLFontManager::initClass(); 1567 LLFontManager::initClass();
1507 1568
1508 // Initialize OpenGL Renderer 1569 //
1570 // We want to set this stuff up BEFORE we initialize the pipeline, so we can turn off
1571 // stuff like AGP if we think that it'll crash the viewer.
1572 //
1573 llinfos << "Loading feature tables." << llendl;
1574
1575 gFeatureManagerp->init();
1509 1576
1510 if (!gFeatureManagerp->isFeatureAvailable("RenderVBO") || 1577 // Initialize OpenGL Renderer
1578 if (!gFeatureManagerp->isFeatureAvailable("RenderVBOEnable") ||
1511 !gGLManager.mHasVertexBufferObject) 1579 !gGLManager.mHasVertexBufferObject)
1512 { 1580 {
1513 gSavedSettings.setBOOL("RenderVBOEnable", FALSE); 1581 gSavedSettings.setBOOL("RenderVBOEnable", FALSE);
1514 } 1582 }
1515 LLVertexBuffer::initClass(gSavedSettings.getBOOL("RenderVBOEnable")); 1583 LLVertexBuffer::initClass(gSavedSettings.getBOOL("RenderVBOEnable"));
1516 1584
1517 //
1518 // We want to set this stuff up BEFORE we initialize the pipeline, so we can turn off
1519 // stuff like AGP if we think that it'll crash the viewer.
1520 //
1521 gFeatureManagerp->initGraphicsFeatureMasks();
1522 if (gFeatureManagerp->isSafe() 1585 if (gFeatureManagerp->isSafe()
1523 || (gSavedSettings.getS32("LastFeatureVersion") != gFeatureManagerp->getVersion())) 1586 || (gSavedSettings.getS32("LastFeatureVersion") != gFeatureManagerp->getVersion())
1524 { 1587 || (gSavedSettings.getBOOL("ProbeHardwareOnStartup")))
1525 gFeatureManagerp->applyRecommendedFeatures();
1526 }
1527
1528 S32 idx = gSavedSettings.getS32("GraphicsCardMemorySetting");
1529 // -1 indicates use default (max)
1530 if (idx == -1)
1531 { 1588 {
1532 idx = LLViewerImageList::getMaxVideoRamSetting(-2); // get max recommended setting 1589 gFeatureManagerp->applyRecommendedSettings();
1533 gSavedSettings.setS32("GraphicsCardMemorySetting", idx); 1590 gSavedSettings.setBOOL("ProbeHardwareOnStartup", FALSE);
1534 } 1591 }
1535 1592
1536 // If we crashed while initializng GL stuff last time, disable certain features 1593 // If we crashed while initializng GL stuff last time, disable certain features
1537 if (gSavedSettings.getBOOL("RenderInitError")) 1594 if (gSavedSettings.getBOOL("RenderInitError"))
1538 { 1595 {
1539 mInitAlert = "DisplaySettingsNoShaders"; 1596 mInitAlert = "DisplaySettingsNoShaders";
1540 gSavedSettings.setBOOL("VertexShaderEnable", FALSE); 1597 gFeatureManagerp->setGraphicsLevel(0, false);
1541 } 1598 gSavedSettings.setU32("RenderQualityPerformance", 0);
1542 1599
1543 if (!gNoRender)
1544 {
1545 //
1546 // Initialize GL stuff
1547 //
1548
1549 // Set this flag in case we crash while initializing GL
1550 gSavedSettings.setBOOL("RenderInitError", TRUE);
1551 gSavedSettings.saveToFile( gSettingsFileName, TRUE );
1552
1553 gPipeline.init();
1554 stop_glerror();
1555 initGLDefaults();
1556
1557 gSavedSettings.setBOOL("RenderInitError", FALSE);
1558 gSavedSettings.saveToFile( gSettingsFileName, TRUE );
1559 } 1600 }
1560 1601
1561 //
1562 // Done initing GL stuff.
1563 //
1564
1565 // set callbacks 1602 // set callbacks
1566 mWindow->setCallbacks(this); 1603 mWindow->setCallbacks(this);
1567 1604
@@ -1605,11 +1642,7 @@ LLViewerWindow::LLViewerWindow(
1605 1642
1606void LLViewerWindow::initGLDefaults() 1643void LLViewerWindow::initGLDefaults()
1607{ 1644{
1608 //LLGLState::reset(); 1645 gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1609 //gGLSDefault.set();
1610 //LLGLState::verify(TRUE);
1611
1612 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1613 glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); 1646 glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
1614 1647
1615 F32 ambient[4] = {0.f,0.f,0.f,0.f }; 1648 F32 ambient[4] = {0.f,0.f,0.f,0.f };
@@ -1620,10 +1653,14 @@ void LLViewerWindow::initGLDefaults()
1620 glPixelStorei(GL_PACK_ALIGNMENT,1); 1653 glPixelStorei(GL_PACK_ALIGNMENT,1);
1621 glPixelStorei(GL_UNPACK_ALIGNMENT,1); 1654 glPixelStorei(GL_UNPACK_ALIGNMENT,1);
1622 1655
1656 glEnable(GL_TEXTURE_2D);
1657
1623 // lights for objects 1658 // lights for objects
1624 glShadeModel( GL_SMOOTH ); 1659 glShadeModel( GL_SMOOTH );
1625 1660
1626 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient); 1661 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
1662
1663 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1627 1664
1628 glCullFace(GL_BACK); 1665 glCullFace(GL_BACK);
1629 1666
@@ -1632,8 +1669,6 @@ void LLViewerWindow::initGLDefaults()
1632 gBox.prerender(); 1669 gBox.prerender();
1633 gSphere.prerender(); 1670 gSphere.prerender();
1634 gCylinder.prerender(); 1671 gCylinder.prerender();
1635
1636 LLVOAvatar::initVertexPrograms();
1637} 1672}
1638 1673
1639void LLViewerWindow::initBase() 1674void LLViewerWindow::initBase()
@@ -1782,18 +1817,23 @@ void adjust_rect_bottom_center(const LLString& control, const LLRect& window)
1782 } 1817 }
1783} 1818}
1784 1819
1785 1820void adjust_rect_centered_partial_zoom(const LLString& control,
1786void update_saved_window_size(const LLString& control,S32 delta_width, S32 delta_height) 1821 const LLRect& window)
1787{ 1822{
1788 if (delta_width || delta_height ) 1823 LLRect rect = gSavedSettings.getRect(control);
1789 { 1824 // Only adjust on first use
1790 LLRect mXMLRect = gSavedSettings.getRect(control); 1825 if (rect.mLeft == 0 && rect.mBottom == 0)
1791 //hard code it all follows the right and top 1826 {
1792 mXMLRect.mRight += delta_width; 1827 S32 width = window.getWidth();
1793 mXMLRect.mTop += delta_height; 1828 S32 height = window.getHeight();
1794 mXMLRect.mLeft = llmax (0, mXMLRect.mLeft+delta_width); 1829 rect.set(0, height-STATUS_BAR_HEIGHT, width, TOOL_BAR_HEIGHT);
1795 mXMLRect.mBottom = llmax(0,mXMLRect.mBottom+delta_height); 1830 // Make floater fill 80% of window, leaving 20% padding on
1796 gSavedSettings.setRect(control,mXMLRect); 1831 // the sides.
1832 const F32 ZOOM_FRACTION = 0.8f;
1833 S32 dx = (S32)(width * (1.f - ZOOM_FRACTION));
1834 S32 dy = (S32)(height * (1.f - ZOOM_FRACTION));
1835 rect.stretch(-dx/2, -dy/2);
1836 gSavedSettings.setRect(control, rect);
1797 } 1837 }
1798} 1838}
1799 1839
@@ -1816,7 +1856,7 @@ void LLViewerWindow::adjustRectanglesForFirstUse(const LLRect& window)
1816 1856
1817 adjust_rect_top_left("FloaterGestureRect", window); 1857 adjust_rect_top_left("FloaterGestureRect", window);
1818 1858
1819 adjust_rect_top_right("FloaterMapRect", window); 1859 adjust_rect_top_right("FloaterMiniMapRect", window);
1820 1860
1821 adjust_rect_top_right("FloaterLagMeter", window); 1861 adjust_rect_top_right("FloaterLagMeter", window);
1822 1862
@@ -1885,17 +1925,8 @@ void LLViewerWindow::initWorldUI()
1885 1925
1886 LLWorldMapView::initClass(); 1926 LLWorldMapView::initClass();
1887 1927
1888 LLRect world_map_rect = gSavedSettings.getRect("FloaterWorldMapRect"); 1928 adjust_rect_centered_partial_zoom("FloaterWorldMapRect2", full_window);
1889 // if 0,0,0,0 then use fullscreen 1929
1890 if (world_map_rect.mTop == 0
1891 && world_map_rect.mLeft == 0
1892 && world_map_rect.mRight == 0
1893 && world_map_rect.mBottom == 0)
1894 {
1895 world_map_rect.set(0, height-TOOL_BAR_HEIGHT, width, STATUS_BAR_HEIGHT);
1896 world_map_rect.stretch(-4);
1897 gSavedSettings.setRect("FloaterWorldMapRect", world_map_rect);
1898 }
1899 gFloaterWorldMap = new LLFloaterWorldMap(); 1930 gFloaterWorldMap = new LLFloaterWorldMap();
1900 gFloaterWorldMap->setVisible(FALSE); 1931 gFloaterWorldMap->setVisible(FALSE);
1901 1932
@@ -2089,9 +2120,6 @@ void LLViewerWindow::reshape(S32 width, S32 height)
2089 } 2120 }
2090 } 2121 }
2091 2122
2092 // changes in window's width and hight
2093 S32 delta_width = width - mWindowRect.getWidth();
2094 S32 delta_height = height - mWindowRect.getHeight();
2095 // update our window rectangle 2123 // update our window rectangle
2096 mWindowRect.mRight = mWindowRect.mLeft + width; 2124 mWindowRect.mRight = mWindowRect.mLeft + width;
2097 mWindowRect.mTop = mWindowRect.mBottom + height; 2125 mWindowRect.mTop = mWindowRect.mBottom + height;
@@ -2142,17 +2170,12 @@ void LLViewerWindow::reshape(S32 width, S32 height)
2142 { 2170 {
2143 gSavedSettings.setS32("WindowWidth", window_size.mX); 2171 gSavedSettings.setS32("WindowWidth", window_size.mX);
2144 gSavedSettings.setS32("WindowHeight", window_size.mY); 2172 gSavedSettings.setS32("WindowHeight", window_size.mY);
2145 if (!gFloaterMap)
2146 {
2147 update_saved_window_size("FloaterWorldMapRect",delta_width, delta_height);
2148 update_saved_window_size("FloaterMapRect",delta_width, delta_height);
2149 }
2150
2151 } 2173 }
2152 } 2174 }
2153 2175
2154 gViewerStats->setStat(LLViewerStats::ST_WINDOW_WIDTH, (F64)width); 2176 gViewerStats->setStat(LLViewerStats::ST_WINDOW_WIDTH, (F64)width);
2155 gViewerStats->setStat(LLViewerStats::ST_WINDOW_HEIGHT, (F64)height); 2177 gViewerStats->setStat(LLViewerStats::ST_WINDOW_HEIGHT, (F64)height);
2178 gResizeScreenTexture = TRUE;
2156 } 2179 }
2157} 2180}
2158 2181
@@ -2218,11 +2241,20 @@ void LLViewerWindow::setMenuBackgroundColor(bool god_mode, bool dev_grid)
2218 2241
2219void LLViewerWindow::drawDebugText() 2242void LLViewerWindow::drawDebugText()
2220{ 2243{
2221 mDebugText->draw(); 2244 gGL.start();
2245 gGL.pushMatrix();
2246 {
2247 // scale view by UI global scale factor and aspect ratio correction factor
2248 glScalef(mDisplayScale.mV[VX], mDisplayScale.mV[VY], 1.f);
2249 mDebugText->draw();
2250 }
2251 gGL.popMatrix();
2252 gGL.stop();
2222} 2253}
2223 2254
2224void LLViewerWindow::draw() 2255void LLViewerWindow::draw()
2225{ 2256{
2257
2226#if LL_DEBUG 2258#if LL_DEBUG
2227 LLView::sIsDrawing = TRUE; 2259 LLView::sIsDrawing = TRUE;
2228#endif 2260#endif
@@ -2264,7 +2296,7 @@ void LLViewerWindow::draw()
2264 // Draw all nested UI views. 2296 // Draw all nested UI views.
2265 // No translation needed, this view is glued to 0,0 2297 // No translation needed, this view is glued to 0,0
2266 2298
2267 glPushMatrix(); 2299 gGL.pushMatrix();
2268 { 2300 {
2269 // scale view by UI global scale factor and aspect ratio correction factor 2301 // scale view by UI global scale factor and aspect ratio correction factor
2270 glScalef(mDisplayScale.mV[VX], mDisplayScale.mV[VY], 1.f); 2302 glScalef(mDisplayScale.mV[VX], mDisplayScale.mV[VY], 1.f);
@@ -2289,11 +2321,6 @@ void LLViewerWindow::draw()
2289 } 2321 }
2290 } 2322 }
2291 2323
2292 {
2293 LLGLSTexture gls_texture;
2294 drawDebugText();
2295 }
2296
2297 if (gToolMgr) 2324 if (gToolMgr)
2298 { 2325 {
2299 // Draw tool specific overlay on world 2326 // Draw tool specific overlay on world
@@ -2354,7 +2381,6 @@ void LLViewerWindow::draw()
2354 { 2381 {
2355 // Used for special titles such as "Second Life - Special E3 2003 Beta" 2382 // Used for special titles such as "Second Life - Special E3 2003 Beta"
2356 const S32 DIST_FROM_TOP = 20; 2383 const S32 DIST_FROM_TOP = 20;
2357 LLGLSTexture gls_texture;
2358 LLFontGL::sSansSerifBig->renderUTF8( 2384 LLFontGL::sSansSerifBig->renderUTF8(
2359 mOverlayTitle, 0, 2385 mOverlayTitle, 0,
2360 llround( gViewerWindow->getWindowWidth() * 0.5f), 2386 llround( gViewerWindow->getWindowWidth() * 0.5f),
@@ -2365,8 +2391,7 @@ void LLViewerWindow::draw()
2365 2391
2366 LLUI::sGLScaleFactor = old_scale_factor; 2392 LLUI::sGLScaleFactor = old_scale_factor;
2367 } 2393 }
2368 glPopMatrix(); 2394 gGL.popMatrix();
2369
2370 2395
2371#if LL_DEBUG 2396#if LL_DEBUG
2372 LLView::sIsDrawing = FALSE; 2397 LLView::sIsDrawing = FALSE;
@@ -2642,6 +2667,8 @@ BOOL LLViewerWindow::handleUnicodeChar(llwchar uni_char, MASK mask)
2642 2667
2643void LLViewerWindow::handleScrollWheel(S32 clicks) 2668void LLViewerWindow::handleScrollWheel(S32 clicks)
2644{ 2669{
2670 LLView::sMouseHandlerMessage = "";
2671
2645 gMouseIdleTimer.reset(); 2672 gMouseIdleTimer.reset();
2646 2673
2647 // Hide tooltips 2674 // Hide tooltips
@@ -2678,7 +2705,6 @@ void LLViewerWindow::handleScrollWheel(S32 clicks)
2678 if (LLView::sDebugMouseHandling) 2705 if (LLView::sDebugMouseHandling)
2679 { 2706 {
2680 llinfos << "Scroll Wheel" << LLView::sMouseHandlerMessage << llendl; 2707 llinfos << "Scroll Wheel" << LLView::sMouseHandlerMessage << llendl;
2681 LLView::sMouseHandlerMessage = "";
2682 } 2708 }
2683 return; 2709 return;
2684 } 2710 }
@@ -2720,6 +2746,8 @@ BOOL LLViewerWindow::handlePerFrameHover()
2720{ 2746{
2721 static std::string last_handle_msg; 2747 static std::string last_handle_msg;
2722 2748
2749 LLView::sMouseHandlerMessage = "";
2750
2723 //RN: fix for asynchronous notification of mouse leaving window not working 2751 //RN: fix for asynchronous notification of mouse leaving window not working
2724 LLCoordWindow mouse_pos; 2752 LLCoordWindow mouse_pos;
2725 mWindow->getCursorPosition(&mouse_pos); 2753 mWindow->getCursorPosition(&mouse_pos);
@@ -2777,23 +2805,23 @@ BOOL LLViewerWindow::handlePerFrameHover()
2777 { 2805 {
2778 gFocusMgr.releaseFocusIfNeeded(cur_focus); 2806 gFocusMgr.releaseFocusIfNeeded(cur_focus);
2779 2807
2780 LLView* parent = cur_focus->getParent(); 2808 LLUICtrl* parent = cur_focus->getParentUICtrl();
2781 LLView* focus_root = cur_focus->findRootMostFocusRoot(); 2809 const LLUICtrl* focus_root = cur_focus->findRootMostFocusRoot();
2782 while(parent) 2810 while(parent)
2783 { 2811 {
2784 if (parent->isCtrl() && 2812 if (parent->isCtrl() &&
2785 (((LLUICtrl*)parent)->hasTabStop() || parent == focus_root) && 2813 (parent->hasTabStop() || parent == focus_root) &&
2786 !((LLUICtrl*)parent)->getIsChrome() && 2814 !parent->getIsChrome() &&
2787 parent->isInVisibleChain() && 2815 parent->isInVisibleChain() &&
2788 parent->isInEnabledChain()) 2816 parent->isInEnabledChain())
2789 { 2817 {
2790 if (!parent->focusFirstItem()) 2818 if (!parent->focusFirstItem())
2791 { 2819 {
2792 ((LLUICtrl*)parent)->setFocus(TRUE); 2820 parent->setFocus(TRUE);
2793 } 2821 }
2794 break; 2822 break;
2795 } 2823 }
2796 parent = parent->getParent(); 2824 parent = parent->getParentUICtrl();
2797 } 2825 }
2798 } 2826 }
2799 else if (cur_focus->isFocusRoot()) 2827 else if (cur_focus->isFocusRoot())
@@ -2855,7 +2883,6 @@ BOOL LLViewerWindow::handlePerFrameHover()
2855 last_handle_msg = LLView::sMouseHandlerMessage; 2883 last_handle_msg = LLView::sMouseHandlerMessage;
2856 llinfos << "Hover" << LLView::sMouseHandlerMessage << llendl; 2884 llinfos << "Hover" << LLView::sMouseHandlerMessage << llendl;
2857 } 2885 }
2858 LLView::sMouseHandlerMessage = "";
2859 handled = TRUE; 2886 handled = TRUE;
2860 } 2887 }
2861 else if (LLView::sDebugMouseHandling) 2888 else if (LLView::sDebugMouseHandling)
@@ -3021,7 +3048,7 @@ BOOL LLViewerWindow::handlePerFrameHover()
3021 } 3048 }
3022 3049
3023 // snap floaters to top of chat bar/button strip 3050 // snap floaters to top of chat bar/button strip
3024 LLView* chatbar_and_buttons = gOverlayBar->getChildByName("chatbar_and_buttons", TRUE); 3051 LLView* chatbar_and_buttons = gOverlayBar->getChild<LLView>("chatbar_and_buttons", TRUE);
3025 // find top of chatbar and strate buttons, if either are visible 3052 // find top of chatbar and strate buttons, if either are visible
3026 if (chatbar_and_buttons && !chatbar_and_buttons->getLocalBoundingRect().isNull()) 3053 if (chatbar_and_buttons && !chatbar_and_buttons->getLocalBoundingRect().isNull())
3027 { 3054 {
@@ -3061,9 +3088,9 @@ BOOL LLViewerWindow::handlePerFrameHover()
3061 mLastMousePoint = mCurrentMousePoint; 3088 mLastMousePoint = mCurrentMousePoint;
3062 3089
3063 // last ditch force of edit menu to selection manager 3090 // last ditch force of edit menu to selection manager
3064 if (gEditMenuHandler == NULL && gSelectMgr && gSelectMgr->getSelection()->getObjectCount()) 3091 if (LLEditMenuHandler::gEditMenuHandler == NULL && gSelectMgr && gSelectMgr->getSelection()->getObjectCount())
3065 { 3092 {
3066 gEditMenuHandler = gSelectMgr; 3093 LLEditMenuHandler::gEditMenuHandler = gSelectMgr;
3067 } 3094 }
3068 3095
3069 if (gFloaterView->getCycleMode()) 3096 if (gFloaterView->getCycleMode())
@@ -3195,11 +3222,12 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls,
3195 } 3222 }
3196 3223
3197 // Render light for editing 3224 // Render light for editing
3198 if (LLSelectMgr::sRenderLightRadius) 3225 if (LLSelectMgr::sRenderLightRadius && gToolMgr->inEdit())
3199 { 3226 {
3227 LLImageGL::unbindTexture(0);
3200 LLGLEnable gls_blend(GL_BLEND); 3228 LLGLEnable gls_blend(GL_BLEND);
3201 LLGLEnable gls_cull(GL_CULL_FACE); 3229 LLGLEnable gls_cull(GL_CULL_FACE);
3202 LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE); 3230 LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
3203 glMatrixMode(GL_MODELVIEW); 3231 glMatrixMode(GL_MODELVIEW);
3204 glPushMatrix(); 3232 glPushMatrix();
3205 if (selection->getSelectType() == SELECT_TYPE_HUD) 3233 if (selection->getSelectType() == SELECT_TYPE_HUD)
@@ -3362,6 +3390,10 @@ void LLViewerWindow::hitObjectOrLandGlobalAsync(S32 x, S32 y_from_bot, MASK mask
3362 { 3390 {
3363 return; 3391 return;
3364 } 3392 }
3393
3394 render_ui_and_swap_if_needed();
3395 glClear(GL_DEPTH_BUFFER_BIT);
3396 gDisplaySwapBuffers = FALSE;
3365 3397
3366 S32 scaled_x = llround((F32)x * mDisplayScale.mV[VX]); 3398 S32 scaled_x = llround((F32)x * mDisplayScale.mV[VX]);
3367 S32 scaled_y = llround((F32)y_from_bot * mDisplayScale.mV[VY]); 3399 S32 scaled_y = llround((F32)y_from_bot * mDisplayScale.mV[VY]);
@@ -3402,6 +3434,8 @@ void LLViewerWindow::hitObjectOrLandGlobalAsync(S32 x, S32 y_from_bot, MASK mask
3402 pick_camera.setAspect(1.f); 3434 pick_camera.setAspect(1.f);
3403 3435
3404 // save our drawing state 3436 // save our drawing state
3437 // *TODO: should we be saving using the new method here using
3438 // glh_get_current_projection/glh_set_current_projection? -brad
3405 glMatrixMode(GL_MODELVIEW); 3439 glMatrixMode(GL_MODELVIEW);
3406 glPushMatrix(); 3440 glPushMatrix();
3407 glLoadIdentity(); 3441 glLoadIdentity();
@@ -3415,13 +3449,18 @@ void LLViewerWindow::hitObjectOrLandGlobalAsync(S32 x, S32 y_from_bot, MASK mask
3415 // Don't limit the select distance for this pick. 3449 // Don't limit the select distance for this pick.
3416 // make viewport big enough to handle antialiased frame buffers 3450 // make viewport big enough to handle antialiased frame buffers
3417 gCamera->setPerspective(FOR_SELECTION, scaled_x - (PICK_HALF_WIDTH + 2), scaled_y - (PICK_HALF_WIDTH + 2), PICK_DIAMETER + 4, PICK_DIAMETER + 4, FALSE); 3451 gCamera->setPerspective(FOR_SELECTION, scaled_x - (PICK_HALF_WIDTH + 2), scaled_y - (PICK_HALF_WIDTH + 2), PICK_DIAMETER + 4, PICK_DIAMETER + 4, FALSE);
3418 pick_camera.calcAgentFrustumPlanes(gCamera->mAgentFrustum);
3419 // make viewport big enough to handle antialiased frame buffers 3452 // make viewport big enough to handle antialiased frame buffers
3420 glViewport(scaled_x - (PICK_HALF_WIDTH + 2), scaled_y - (PICK_HALF_WIDTH + 2), PICK_DIAMETER + 4, PICK_DIAMETER + 4); 3453 gGLViewport[0] = scaled_x - (PICK_HALF_WIDTH + 2);
3454 gGLViewport[1] = scaled_y - (PICK_HALF_WIDTH + 2);
3455 gGLViewport[2] = PICK_DIAMETER + 4;
3456 gGLViewport[3] = PICK_DIAMETER + 4;
3457 glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]);
3458 LLViewerCamera::updateFrustumPlanes(pick_camera);
3421 stop_glerror(); 3459 stop_glerror();
3422 3460
3423 glClearColor(0.f, 0.f, 0.f, 0.f); 3461 glClearColor(0.f, 0.f, 0.f, 0.f);
3424 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 3462 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
3463 //glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
3425 3464
3426 // Draw the objects so the user can select them. 3465 // Draw the objects so the user can select them.
3427 // The starting ID is 1, since land is zero. 3466 // The starting ID is 1, since land is zero.
@@ -4279,7 +4318,7 @@ BOOL LLViewerWindow::saveSnapshot( const LLString& filepath, S32 image_width, S3
4279 llinfos << "Saving snapshot to: " << filepath << llendl; 4318 llinfos << "Saving snapshot to: " << filepath << llendl;
4280 4319
4281 LLPointer<LLImageRaw> raw = new LLImageRaw; 4320 LLPointer<LLImageRaw> raw = new LLImageRaw;
4282 BOOL success = rawSnapshot(raw, image_width, image_height, TRUE, show_ui, do_rebuild); 4321 BOOL success = rawSnapshot(raw, image_width, image_height, TRUE, FALSE, show_ui, do_rebuild);
4283 4322
4284 if (success) 4323 if (success)
4285 { 4324 {
@@ -4312,10 +4351,10 @@ void LLViewerWindow::playSnapshotAnimAndSound()
4312 4351
4313// Saves the image from the screen to the specified filename and path. 4352// Saves the image from the screen to the specified filename and path.
4314BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, 4353BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height,
4315 BOOL keep_window_aspect, BOOL show_ui, BOOL do_rebuild, ESnapshotType type) 4354 BOOL keep_window_aspect, BOOL is_texture, BOOL show_ui, BOOL do_rebuild, ESnapshotType type, S32 max_size)
4316{ 4355{
4317 F32 image_aspect_ratio = ((F32)image_width) / ((F32)image_height); 4356 //F32 image_aspect_ratio = ((F32)image_width) / ((F32)image_height);
4318 F32 window_aspect_ratio = ((F32)getWindowWidth()) / ((F32)getWindowHeight()); 4357 //F32 window_aspect_ratio = ((F32)getWindowWidth()) / ((F32)getWindowHeight());
4319 4358
4320 if ((!gWorldPointer) || 4359 if ((!gWorldPointer) ||
4321 (!raw)) 4360 (!raw))
@@ -4324,7 +4363,9 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
4324 } 4363 }
4325 4364
4326 // PRE SNAPSHOT 4365 // PRE SNAPSHOT
4327 4366 render_ui_and_swap_if_needed();
4367 gDisplaySwapBuffers = FALSE;
4368
4328 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 4369 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
4329 setCursor(UI_CURSOR_WAIT); 4370 setCursor(UI_CURSOR_WAIT);
4330 4371
@@ -4336,7 +4377,6 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
4336 LLPipeline::toggleRenderDebugFeature((void*)LLPipeline::RENDER_DEBUG_FEATURE_UI); 4377 LLPipeline::toggleRenderDebugFeature((void*)LLPipeline::RENDER_DEBUG_FEATURE_UI);
4337 } 4378 }
4338 4379
4339
4340 BOOL hide_hud = !gSavedSettings.getBOOL("RenderHUDInSnapshot") && LLPipeline::sShowHUDAttachments; 4380 BOOL hide_hud = !gSavedSettings.getBOOL("RenderHUDInSnapshot") && LLPipeline::sShowHUDAttachments;
4341 if (hide_hud) 4381 if (hide_hud)
4342 { 4382 {
@@ -4348,20 +4388,81 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
4348 // from window 4388 // from window
4349 S32 snapshot_width = mWindowRect.getWidth(); 4389 S32 snapshot_width = mWindowRect.getWidth();
4350 S32 snapshot_height = mWindowRect.getHeight(); 4390 S32 snapshot_height = mWindowRect.getHeight();
4351 if (!keep_window_aspect) 4391 F32 scale_factor = 1.0f ;
4392 if (keep_window_aspect || is_texture) //map the entire window to snapshot
4393 {
4394 }
4395 else //scale or crop
4352 { 4396 {
4353 if (image_aspect_ratio > window_aspect_ratio) 4397 if(snapshot_width > image_width) //crop
4354 { 4398 {
4355 snapshot_height = llround((F32)snapshot_width / image_aspect_ratio); 4399 snapshot_width = image_width ;
4356 } 4400 }
4357 else if (image_aspect_ratio < window_aspect_ratio) 4401 if(snapshot_height > image_height)//crop
4358 { 4402 {
4359 snapshot_width = llround((F32)snapshot_height * image_aspect_ratio); 4403 snapshot_height = image_height ;
4360 } 4404 }
4405
4406 //if (image_aspect_ratio > window_aspect_ratio)
4407 //{
4408 // snapshot_height = llround((F32)snapshot_width / image_aspect_ratio);
4409 //}
4410 //else if (image_aspect_ratio < window_aspect_ratio)
4411 //{
4412 // snapshot_width = llround((F32)snapshot_height * image_aspect_ratio);
4413 //}
4361 } 4414 }
4362 4415
4363 F32 scale_factor = llmax(1.f, (F32)image_width / snapshot_width, (F32)image_height / snapshot_height); 4416 LLRenderTarget target;
4364 raw->resize(llfloor(snapshot_width*scale_factor), llfloor(snapshot_height *scale_factor), type == SNAPSHOT_TYPE_DEPTH ? 4 : 3); 4417
4418 scale_factor = llmax(1.f, (F32)image_width / snapshot_width, (F32)image_height / snapshot_height);
4419
4420 // SNAPSHOT
4421 S32 window_width = mWindowRect.getWidth();
4422 S32 window_height = mWindowRect.getHeight();
4423
4424 LLRect window_rect = mWindowRect;
4425
4426 BOOL use_fbo = FALSE;
4427
4428 if (gGLManager.mHasFramebufferObject &&
4429 (image_width > window_width ||
4430 image_height > window_height) &&
4431 !show_ui &&
4432 keep_window_aspect)
4433 {
4434 GLint max_size = 0;
4435 glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &max_size);
4436
4437 if (image_width <= max_size && image_height <= max_size)
4438 {
4439 use_fbo = TRUE;
4440
4441 snapshot_width = image_width;
4442 snapshot_height = image_height;
4443 target.allocate(snapshot_width, snapshot_height, GL_RGBA, TRUE, GL_TEXTURE_RECTANGLE_ARB, TRUE);
4444 window_width = snapshot_width;
4445 window_height = snapshot_height;
4446 scale_factor = 1.f;
4447 mWindowRect.set(0, 0, snapshot_width, snapshot_height);
4448 target.bindTarget();
4449
4450
4451 }
4452 }
4453
4454 S32 buffer_x_offset = llfloor(((window_width - snapshot_width) * scale_factor) / 2.f);
4455 S32 buffer_y_offset = llfloor(((window_height - snapshot_height) * scale_factor) / 2.f);
4456
4457 S32 image_buffer_x = llfloor(snapshot_width*scale_factor) ;
4458 S32 image_buffer_y = llfloor(snapshot_height *scale_factor) ;
4459 if(image_buffer_x > max_size || image_buffer_y > max_size) //boundary check to avoid memory overflow
4460 {
4461 scale_factor *= llmin((F32)max_size / image_buffer_x, (F32)max_size / image_buffer_y) ;
4462 image_buffer_x = llfloor(snapshot_width*scale_factor) ;
4463 image_buffer_y = llfloor(snapshot_height *scale_factor) ;
4464 }
4465 raw->resize(image_buffer_x, image_buffer_y, type == SNAPSHOT_TYPE_DEPTH ? 4 : 3);
4365 4466
4366 BOOL high_res = scale_factor > 1.f; 4467 BOOL high_res = scale_factor > 1.f;
4367 if (high_res) 4468 if (high_res)
@@ -4372,12 +4473,6 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
4372 LLHUDText::reshape(); 4473 LLHUDText::reshape();
4373 } 4474 }
4374 4475
4375 // SNAPSHOT
4376 S32 window_width = mWindowRect.getWidth();
4377 S32 window_height = mWindowRect.getHeight();
4378 S32 buffer_x_offset = llfloor(((window_width - snapshot_width) * scale_factor) / 2.f);
4379 S32 buffer_y_offset = llfloor(((window_height - snapshot_height) * scale_factor) / 2.f);
4380
4381 S32 output_buffer_offset_y = 0; 4476 S32 output_buffer_offset_y = 0;
4382 4477
4383 F32 depth_conversion_factor_1 = (gCamera->getFar() + gCamera->getNear()) / (2.f * gCamera->getFar() * gCamera->getNear()); 4478 F32 depth_conversion_factor_1 = (gCamera->getFar() + gCamera->getNear()) / (2.f * gCamera->getFar() * gCamera->getNear());
@@ -4408,9 +4503,10 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
4408 } 4503 }
4409 else 4504 else
4410 { 4505 {
4411 display(do_rebuild, scale_factor, subimage_x+(subimage_y*llceil(scale_factor))); 4506 display(do_rebuild, scale_factor, subimage_x+(subimage_y*llceil(scale_factor)), use_fbo);
4507 render_ui_and_swap();
4412 } 4508 }
4413 glFlush(); 4509
4414 S32 subimage_x_offset = llclamp(buffer_x_offset - (subimage_x * window_width), 0, window_width); 4510 S32 subimage_x_offset = llclamp(buffer_x_offset - (subimage_x * window_width), 0, window_width);
4415 // handle fractional rows 4511 // handle fractional rows
4416 U32 read_width = llmax(0, (window_width - subimage_x_offset) - 4512 U32 read_width = llmax(0, (window_width - subimage_x_offset) -
@@ -4469,6 +4565,14 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
4469 output_buffer_offset_y += subimage_y_offset; 4565 output_buffer_offset_y += subimage_y_offset;
4470 } 4566 }
4471 4567
4568 if (use_fbo)
4569 {
4570 mWindowRect = window_rect;
4571 target.flush();
4572 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
4573 }
4574 gDisplaySwapBuffers = FALSE;
4575
4472 // POST SNAPSHOT 4576 // POST SNAPSHOT
4473 if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) 4577 if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
4474 { 4578 {
@@ -4486,14 +4590,20 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
4486 LLHUDText::reshape(); 4590 LLHUDText::reshape();
4487 } 4591 }
4488 4592
4489 gDisplaySwapBuffers = TRUE;
4490
4491 // Pre-pad image to number of pixels such that the line length is a multiple of 4 bytes (for BMP encoding) 4593 // Pre-pad image to number of pixels such that the line length is a multiple of 4 bytes (for BMP encoding)
4492 // Note: this formula depends on the number of components being 3. Not obvious, but it's correct. 4594 // Note: this formula depends on the number of components being 3. Not obvious, but it's correct.
4493 image_width += (image_width * (type == SNAPSHOT_TYPE_DEPTH ? 4 : 3)) % 4; 4595 image_width += (image_width * (type == SNAPSHOT_TYPE_DEPTH ? 4 : 3)) % 4 ;
4494 4596
4495 // Resize image 4597 // Resize image
4496 raw->scale( image_width, image_height ); 4598 if(llabs(image_width - image_buffer_x) > 4 || llabs(image_height - image_buffer_y) > 4)
4599 {
4600 raw->scale( image_width, image_height );
4601 }
4602 else if(image_width != image_buffer_x || image_height != image_buffer_y)
4603 {
4604 raw->scale( image_width, image_height, FALSE );
4605 }
4606
4497 4607
4498 setCursor(UI_CURSOR_ARROW); 4608 setCursor(UI_CURSOR_ARROW);
4499 4609
@@ -4541,7 +4651,7 @@ void LLViewerWindow::drawMouselookInstructions()
4541 4651
4542 { 4652 {
4543 LLGLSNoTexture gls_no_texture; 4653 LLGLSNoTexture gls_no_texture;
4544 glColor4f( 0.9f, 0.9f, 0.9f, 1.0f ); 4654 gGL.color4f( 0.9f, 0.9f, 0.9f, 1.0f );
4545 gl_rect_2d( instructions_rect ); 4655 gl_rect_2d( instructions_rect );
4546 } 4656 }
4547 4657
@@ -4624,12 +4734,16 @@ void LLViewerWindow::setTopCtrl(LLUICtrl* new_top)
4624 4734
4625void LLViewerWindow::setupViewport(S32 x_offset, S32 y_offset) 4735void LLViewerWindow::setupViewport(S32 x_offset, S32 y_offset)
4626{ 4736{
4627 glViewport(x_offset, y_offset, mWindowRect.getWidth(), mWindowRect.getHeight()); 4737 gGLViewport[0] = x_offset;
4738 gGLViewport[1] = y_offset;
4739 gGLViewport[2] = mWindowRect.getWidth();
4740 gGLViewport[3] = mWindowRect.getHeight();
4741 glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]);
4628} 4742}
4629 4743
4630void LLViewerWindow::setup3DRender() 4744void LLViewerWindow::setup3DRender()
4631{ 4745{
4632 gCamera->setPerspective(NOT_FOR_SELECTION, 0, 0, mWindowRect.getWidth(), mWindowRect.getHeight(), FALSE, gCamera->getNear(), MAX_FAR_PLANE); 4746 gCamera->setPerspective(NOT_FOR_SELECTION, 0, 0, mWindowRect.getWidth(), mWindowRect.getHeight(), FALSE, gCamera->getNear(), MAX_FAR_CLIP*2.f);
4633} 4747}
4634 4748
4635void LLViewerWindow::setup2DRender() 4749void LLViewerWindow::setup2DRender()
@@ -4758,7 +4872,10 @@ void LLViewerWindow::stopGL(BOOL save_state)
4758 LLDynamicTexture::destroyGL(); 4872 LLDynamicTexture::destroyGL();
4759 stop_glerror(); 4873 stop_glerror();
4760 4874
4761 gPipeline.destroyGL(); 4875 if (gPipeline.isInit())
4876 {
4877 gPipeline.destroyGL();
4878 }
4762 4879
4763 gCone.cleanupGL(); 4880 gCone.cleanupGL();
4764 gBox.cleanupGL(); 4881 gBox.cleanupGL();
@@ -4793,6 +4910,8 @@ void LLViewerWindow::restoreGL(const LLString& progress_message)
4793 LLDynamicTexture::restoreGL(); 4910 LLDynamicTexture::restoreGL();
4794 LLVOAvatar::restoreGL(); 4911 LLVOAvatar::restoreGL();
4795 4912
4913 gResizeScreenTexture = TRUE;
4914
4796 if (gFloaterCustomize && gFloaterCustomize->getVisible()) 4915 if (gFloaterCustomize && gFloaterCustomize->getVisible())
4797 { 4916 {
4798 LLVisualParamHint::requestHintUpdates(); 4917 LLVisualParamHint::requestHintUpdates();
@@ -4887,11 +5006,20 @@ BOOL LLViewerWindow::checkSettings()
4887 return FALSE; 5006 return FALSE;
4888 } 5007 }
4889 5008
5009#ifndef LL_RELEASE_FOR_DOWNLOAD
5010 LLGLState::checkStates();
5011 LLGLState::checkTextureChannels();
5012#endif
4890 gViewerWindow->changeDisplaySettings(TRUE, 5013 gViewerWindow->changeDisplaySettings(TRUE,
4891 LLCoordScreen(gSavedSettings.getS32("FullScreenWidth"), 5014 LLCoordScreen(gSavedSettings.getS32("FullScreenWidth"),
4892 gSavedSettings.getS32("FullScreenHeight")), 5015 gSavedSettings.getS32("FullScreenHeight")),
4893 gSavedSettings.getBOOL("DisableVerticalSync"), 5016 gSavedSettings.getBOOL("DisableVerticalSync"),
4894 mShowFullscreenProgress); 5017 mShowFullscreenProgress);
5018
5019#ifndef LL_RELEASE_FOR_DOWNLOAD
5020 LLGLState::checkStates();
5021 LLGLState::checkTextureChannels();
5022#endif
4895 return TRUE; 5023 return TRUE;
4896 } 5024 }
4897 return FALSE; 5025 return FALSE;
@@ -4918,6 +5046,8 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
4918 mShowFullscreenProgress = show_progress_bar; 5046 mShowFullscreenProgress = show_progress_bar;
4919 gSavedSettings.setBOOL("FullScreen", mWantFullscreen); 5047 gSavedSettings.setBOOL("FullScreen", mWantFullscreen);
4920 5048
5049 gResizeScreenTexture = TRUE;
5050
4921 BOOL old_fullscreen = mWindow->getFullscreen(); 5051 BOOL old_fullscreen = mWindow->getFullscreen();
4922 if (!old_fullscreen && fullscreen && !LLStartUp::canGoFullscreen()) 5052 if (!old_fullscreen && fullscreen && !LLStartUp::canGoFullscreen())
4923 { 5053 {
@@ -5061,6 +5191,8 @@ void LLViewerWindow::drawPickBuffer() const
5061{ 5191{
5062 if (mPickBuffer) 5192 if (mPickBuffer)
5063 { 5193 {
5194 gGL.start();
5195 gGL.pushMatrix();
5064 LLGLDisable no_blend(GL_BLEND); 5196 LLGLDisable no_blend(GL_BLEND);
5065 LLGLDisable no_alpha_test(GL_ALPHA_TEST); 5197 LLGLDisable no_alpha_test(GL_ALPHA_TEST);
5066 LLGLSNoTexture no_texture; 5198 LLGLSNoTexture no_texture;
@@ -5069,7 +5201,7 @@ void LLViewerWindow::drawPickBuffer() const
5069 ((F32)mPickPoint.mY * mDisplayScale.mV[VY] + 10.f)); 5201 ((F32)mPickPoint.mY * mDisplayScale.mV[VY] + 10.f));
5070 glDrawPixels(PICK_DIAMETER, PICK_DIAMETER, GL_RGBA, GL_UNSIGNED_BYTE, mPickBuffer); 5202 glDrawPixels(PICK_DIAMETER, PICK_DIAMETER, GL_RGBA, GL_UNSIGNED_BYTE, mPickBuffer);
5071 glPixelZoom(1.f, 1.f); 5203 glPixelZoom(1.f, 1.f);
5072 glColor4fv(LLColor4::white.mV); 5204 gGL.color4fv(LLColor4::white.mV);
5073 gl_rect_2d(llround((F32)mPickPoint.mX * mDisplayScale.mV[VX] - (F32)(PICK_HALF_WIDTH)), 5205 gl_rect_2d(llround((F32)mPickPoint.mX * mDisplayScale.mV[VX] - (F32)(PICK_HALF_WIDTH)),
5074 llround((F32)mPickPoint.mY * mDisplayScale.mV[VY] + (F32)(PICK_HALF_WIDTH)), 5206 llround((F32)mPickPoint.mY * mDisplayScale.mV[VY] + (F32)(PICK_HALF_WIDTH)),
5075 llround((F32)mPickPoint.mX * mDisplayScale.mV[VX] + (F32)(PICK_HALF_WIDTH)), 5207 llround((F32)mPickPoint.mX * mDisplayScale.mV[VX] + (F32)(PICK_HALF_WIDTH)),
@@ -5083,7 +5215,7 @@ void LLViewerWindow::drawPickBuffer() const
5083 llround((F32)mPickPoint.mY * mDisplayScale.mV[VY] - (F32)(PICK_HALF_WIDTH)), 5215 llround((F32)mPickPoint.mY * mDisplayScale.mV[VY] - (F32)(PICK_HALF_WIDTH)),
5084 llround((F32)mPickPoint.mX * mDisplayScale.mV[VX] + (F32)(PICK_DIAMETER) * 10.f + 10.f), 5216 llround((F32)mPickPoint.mX * mDisplayScale.mV[VX] + (F32)(PICK_DIAMETER) * 10.f + 10.f),
5085 llround((F32)mPickPoint.mY * mDisplayScale.mV[VY] + 10.f)); 5217 llround((F32)mPickPoint.mY * mDisplayScale.mV[VY] + 10.f));
5086 glTranslatef(10.f, 10.f, 0.f); 5218 gGL.translatef(10.f, 10.f, 0.f);
5087 gl_rect_2d(llround((F32)mPickPoint.mX * mDisplayScale.mV[VX]), 5219 gl_rect_2d(llround((F32)mPickPoint.mX * mDisplayScale.mV[VX]),
5088 llround((F32)mPickPoint.mY * mDisplayScale.mV[VY] + (F32)(PICK_DIAMETER) * 10.f), 5220 llround((F32)mPickPoint.mY * mDisplayScale.mV[VY] + (F32)(PICK_DIAMETER) * 10.f),
5089 llround((F32)mPickPoint.mX * mDisplayScale.mV[VX] + (F32)(PICK_DIAMETER) * 10.f), 5221 llround((F32)mPickPoint.mX * mDisplayScale.mV[VX] + (F32)(PICK_DIAMETER) * 10.f),
@@ -5094,7 +5226,8 @@ void LLViewerWindow::drawPickBuffer() const
5094 llround((F32)mPickPoint.mX * mDisplayScale.mV[VX] + (F32)(PICK_HALF_WIDTH + mPickOffset.mX + 1) * 10.f), 5226 llround((F32)mPickPoint.mX * mDisplayScale.mV[VX] + (F32)(PICK_HALF_WIDTH + mPickOffset.mX + 1) * 10.f),
5095 llround((F32)mPickPoint.mY * mDisplayScale.mV[VY] + (F32)(PICK_HALF_WIDTH + mPickOffset.mY) * 10.f), 5227 llround((F32)mPickPoint.mY * mDisplayScale.mV[VY] + (F32)(PICK_HALF_WIDTH + mPickOffset.mY) * 10.f),
5096 FALSE); 5228 FALSE);
5097 glPopMatrix(); 5229 gGL.popMatrix();
5230 gGL.stop();
5098 } 5231 }
5099} 5232}
5100 5233