aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llmaniptranslate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llmaniptranslate.cpp')
-rw-r--r--linden/indra/newview/llmaniptranslate.cpp82
1 files changed, 55 insertions, 27 deletions
diff --git a/linden/indra/newview/llmaniptranslate.cpp b/linden/indra/newview/llmaniptranslate.cpp
index 2278453..fd02be6 100644
--- a/linden/indra/newview/llmaniptranslate.cpp
+++ b/linden/indra/newview/llmaniptranslate.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2002&license=viewergpl$ 5 * $LicenseInfo:firstyear=2002&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2002-2008, Linden Research, Inc. 7 * Copyright (c) 2002-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -77,7 +77,7 @@ const F32 PLANE_TICK_SIZE = 0.4f;
77const F32 MANIPULATOR_SCALE_HALF_LIFE = 0.07f; 77const F32 MANIPULATOR_SCALE_HALF_LIFE = 0.07f;
78const F32 SNAP_ARROW_SCALE = 0.7f; 78const F32 SNAP_ARROW_SCALE = 0.7f;
79 79
80static GLuint sGridTex = 0; 80static LLPointer<LLImageGL> sGridTex = NULL ;
81 81
82const LLManip::EManipPart MANIPULATOR_IDS[9] = 82const LLManip::EManipPart MANIPULATOR_IDS[9] =
83{ 83{
@@ -119,22 +119,50 @@ LLManipTranslate::LLManipTranslate( LLToolComposite* composite )
119 mPlaneScales(1.f, 1.f, 1.f), 119 mPlaneScales(1.f, 1.f, 1.f),
120 mPlaneManipPositions(1.f, 1.f, 1.f, 1.f) 120 mPlaneManipPositions(1.f, 1.f, 1.f, 1.f)
121{ 121{
122 if (sGridTex == 0) 122 if (sGridTex.isNull())
123 { 123 {
124 restoreGL(); 124 restoreGL();
125 } 125 }
126} 126}
127 127
128//static 128//static
129U32 LLManipTranslate::getGridTexName()
130{
131 if(sGridTex.isNull())
132 {
133 restoreGL() ;
134 }
135
136 return sGridTex.isNull() ? 0 : sGridTex->getTexName() ;
137}
138
139//static
140void LLManipTranslate::destroyGL()
141{
142 if (sGridTex)
143 {
144 sGridTex = NULL ;
145 }
146}
147
148//static
129void LLManipTranslate::restoreGL() 149void LLManipTranslate::restoreGL()
130{ 150{
131 //generate grid texture 151 //generate grid texture
132 U32 rez = 512; 152 U32 rez = 512;
133 U32 mip = 0; 153 U32 mip = 0;
134 154
135 GLuint* d = new GLuint[rez*rez]; 155 destroyGL() ;
136 glGenTextures(1, &sGridTex); 156 sGridTex = new LLImageGL() ;
137 glBindTexture(GL_TEXTURE_2D, sGridTex); 157 if(!sGridTex->createGLTexture())
158 {
159 sGridTex = NULL ;
160 return ;
161 }
162
163 GLuint* d = new GLuint[rez*rez];
164
165 gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, sGridTex->getTexName());
138 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 166 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
139 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 167 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
140 168
@@ -1052,7 +1080,7 @@ void LLManipTranslate::renderSnapGuides()
1052 F32 max_subdivisions = sGridMaxSubdivisionLevel;//(F32)gSavedSettings.getS32("GridSubdivision"); 1080 F32 max_subdivisions = sGridMaxSubdivisionLevel;//(F32)gSavedSettings.getS32("GridSubdivision");
1053 F32 line_alpha = gSavedSettings.getF32("GridOpacity"); 1081 F32 line_alpha = gSavedSettings.getF32("GridOpacity");
1054 1082
1055 LLGLSNoTexture gls_no_texture; 1083 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
1056 LLGLDepthTest gls_depth(GL_TRUE); 1084 LLGLDepthTest gls_depth(GL_TRUE);
1057 LLGLDisable gls_cull(GL_CULL_FACE); 1085 LLGLDisable gls_cull(GL_CULL_FACE);
1058 LLVector3 translate_axis; 1086 LLVector3 translate_axis;
@@ -1223,7 +1251,7 @@ void LLManipTranslate::renderSnapGuides()
1223 { 1251 {
1224 LLColor4 line_color = setupSnapGuideRenderPass(pass); 1252 LLColor4 line_color = setupSnapGuideRenderPass(pass);
1225 1253
1226 gGL.begin(LLVertexBuffer::LINES); 1254 gGL.begin(LLRender::LINES);
1227 { 1255 {
1228 LLVector3 line_start = selection_center + (mSnapOffsetMeters * mSnapOffsetAxis) + (translate_axis * (guide_size_meters * 0.5f + offset_nearest_grid_unit)); 1256 LLVector3 line_start = selection_center + (mSnapOffsetMeters * mSnapOffsetAxis) + (translate_axis * (guide_size_meters * 0.5f + offset_nearest_grid_unit));
1229 LLVector3 line_end = selection_center + (mSnapOffsetMeters * mSnapOffsetAxis) - (translate_axis * (guide_size_meters * 0.5f + offset_nearest_grid_unit)); 1257 LLVector3 line_end = selection_center + (mSnapOffsetMeters * mSnapOffsetAxis) - (translate_axis * (guide_size_meters * 0.5f + offset_nearest_grid_unit));
@@ -1299,7 +1327,7 @@ void LLManipTranslate::renderSnapGuides()
1299 LLVector3 line_start = selection_center - mSnapOffsetAxis * mSnapOffsetMeters; 1327 LLVector3 line_start = selection_center - mSnapOffsetAxis * mSnapOffsetMeters;
1300 LLVector3 line_end = selection_center + mSnapOffsetAxis * mSnapOffsetMeters; 1328 LLVector3 line_end = selection_center + mSnapOffsetAxis * mSnapOffsetMeters;
1301 1329
1302 gGL.begin(LLVertexBuffer::LINES); 1330 gGL.begin(LLRender::LINES);
1303 { 1331 {
1304 gGL.color4f(line_color.mV[VX], line_color.mV[VY], line_color.mV[VZ], line_color.mV[VW]); 1332 gGL.color4f(line_color.mV[VX], line_color.mV[VY], line_color.mV[VZ], line_color.mV[VW]);
1305 1333
@@ -1309,7 +1337,7 @@ void LLManipTranslate::renderSnapGuides()
1309 gGL.end(); 1337 gGL.end();
1310 1338
1311 // draw snap guide arrow 1339 // draw snap guide arrow
1312 gGL.begin(LLVertexBuffer::TRIANGLES); 1340 gGL.begin(LLRender::TRIANGLES);
1313 { 1341 {
1314 gGL.color4f(line_color.mV[VX], line_color.mV[VY], line_color.mV[VZ], line_color.mV[VW]); 1342 gGL.color4f(line_color.mV[VX], line_color.mV[VY], line_color.mV[VZ], line_color.mV[VW]);
1315 1343
@@ -1463,7 +1491,7 @@ void LLManipTranslate::renderSnapGuides()
1463 break; 1491 break;
1464 } 1492 }
1465 1493
1466 LLImageGL::unbindTexture(0); 1494 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
1467 highlightIntersection(normal, selection_center, grid_rotation, inner_color); 1495 highlightIntersection(normal, selection_center, grid_rotation, inner_color);
1468 1496
1469 gGL.pushMatrix(); 1497 gGL.pushMatrix();
@@ -1503,7 +1531,7 @@ void LLManipTranslate::renderSnapGuides()
1503 LLGLDisable stencil(GL_STENCIL_TEST); 1531 LLGLDisable stencil(GL_STENCIL_TEST);
1504 { 1532 {
1505 LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GREATER); 1533 LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GREATER);
1506 glBindTexture(GL_TEXTURE_2D, sGridTex); 1534 gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, getGridTexName());
1507 gGL.flush(); 1535 gGL.flush();
1508 gGL.blendFunc(LLRender::BF_ZERO, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); 1536 gGL.blendFunc(LLRender::BF_ZERO, LLRender::BF_ONE_MINUS_SOURCE_ALPHA);
1509 renderGrid(u,v,tiles,0.9f, 0.9f, 0.9f,a*0.15f); 1537 renderGrid(u,v,tiles,0.9f, 0.9f, 0.9f,a*0.15f);
@@ -1514,11 +1542,11 @@ void LLManipTranslate::renderSnapGuides()
1514 { 1542 {
1515 LLGLDisable alpha_test(GL_ALPHA_TEST); 1543 LLGLDisable alpha_test(GL_ALPHA_TEST);
1516 //draw black overlay 1544 //draw black overlay
1517 LLImageGL::unbindTexture(0); 1545 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
1518 renderGrid(u,v,tiles,0.0f, 0.0f, 0.0f,a*0.16f); 1546 renderGrid(u,v,tiles,0.0f, 0.0f, 0.0f,a*0.16f);
1519 1547
1520 //draw grid top 1548 //draw grid top
1521 glBindTexture(GL_TEXTURE_2D, sGridTex); 1549 gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, getGridTexName());
1522 renderGrid(u,v,tiles,1,1,1,a); 1550 renderGrid(u,v,tiles,1,1,1,a);
1523 1551
1524 gGL.popMatrix(); 1552 gGL.popMatrix();
@@ -1564,7 +1592,7 @@ void LLManipTranslate::renderGrid(F32 x, F32 y, F32 size, F32 r, F32 g, F32 b, F
1564 1592
1565 for (F32 xx = -size-d; xx < size+d; xx += d) 1593 for (F32 xx = -size-d; xx < size+d; xx += d)
1566 { 1594 {
1567 gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); 1595 gGL.begin(LLRender::TRIANGLE_STRIP);
1568 for (F32 yy = -size-d; yy < size+d; yy += d) 1596 for (F32 yy = -size-d; yy < size+d; yy += d)
1569 { 1597 {
1570 float dx, dy, da; 1598 float dx, dy, da;
@@ -1620,7 +1648,7 @@ void LLManipTranslate::highlightIntersection(LLVector3 normal,
1620 LLGLDepthTest depth (GL_TRUE, GL_FALSE, GL_ALWAYS); 1648 LLGLDepthTest depth (GL_TRUE, GL_FALSE, GL_ALWAYS);
1621 glStencilFunc(GL_ALWAYS, 0, stencil_mask); 1649 glStencilFunc(GL_ALWAYS, 0, stencil_mask);
1622 gGL.setColorMask(false, false); 1650 gGL.setColorMask(false, false);
1623 LLImageGL::unbindTexture(0); 1651 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
1624 glColor4f(1,1,1,1); 1652 glColor4f(1,1,1,1);
1625 1653
1626 //setup clip plane 1654 //setup clip plane
@@ -1686,7 +1714,7 @@ void LLManipTranslate::highlightIntersection(LLVector3 normal,
1686 1714
1687 //draw volume/plane intersections 1715 //draw volume/plane intersections
1688 { 1716 {
1689 LLImageGL::unbindTexture(0); 1717 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
1690 LLGLDepthTest depth(GL_FALSE); 1718 LLGLDepthTest depth(GL_FALSE);
1691 LLGLEnable stencil(GL_STENCIL_TEST); 1719 LLGLEnable stencil(GL_STENCIL_TEST);
1692 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); 1720 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
@@ -1834,7 +1862,7 @@ void LLManipTranslate::renderTranslationHandles()
1834 relative_camera_dir.normVec(); 1862 relative_camera_dir.normVec();
1835 1863
1836 { 1864 {
1837 LLGLSNoTexture gls_ui_no_texture; 1865 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
1838 LLGLDisable cull_face(GL_CULL_FACE); 1866 LLGLDisable cull_face(GL_CULL_FACE);
1839 1867
1840 LLColor4 color1; 1868 LLColor4 color1;
@@ -1877,7 +1905,7 @@ void LLManipTranslate::renderTranslationHandles()
1877 color1.setVec(0.f, 1.f, 0.f, 0.6f); 1905 color1.setVec(0.f, 1.f, 0.f, 0.6f);
1878 color2.setVec(0.f, 0.f, 1.f, 0.6f); 1906 color2.setVec(0.f, 0.f, 1.f, 0.6f);
1879 } 1907 }
1880 gGL.begin(LLVertexBuffer::TRIANGLES); 1908 gGL.begin(LLRender::TRIANGLES);
1881 { 1909 {
1882 gGL.color4fv(color1.mV); 1910 gGL.color4fv(color1.mV);
1883 gGL.vertex3f(0.f, mPlaneManipOffsetMeters * (-PLANE_TICK_SIZE * 0.25f), mPlaneManipOffsetMeters * (-PLANE_TICK_SIZE * 0.25f)); 1911 gGL.vertex3f(0.f, mPlaneManipOffsetMeters * (-PLANE_TICK_SIZE * 0.25f), mPlaneManipOffsetMeters * (-PLANE_TICK_SIZE * 0.25f));
@@ -1892,7 +1920,7 @@ void LLManipTranslate::renderTranslationHandles()
1892 gGL.end(); 1920 gGL.end();
1893 1921
1894 LLUI::setLineWidth(3.0f); 1922 LLUI::setLineWidth(3.0f);
1895 gGL.begin(LLVertexBuffer::LINES); 1923 gGL.begin(LLRender::LINES);
1896 { 1924 {
1897 gGL.color4f(0.f, 0.f, 0.f, 0.3f); 1925 gGL.color4f(0.f, 0.f, 0.f, 0.3f);
1898 gGL.vertex3f(0.f, mPlaneManipOffsetMeters * -PLANE_TICK_SIZE * 0.25f, mPlaneManipOffsetMeters * -PLANE_TICK_SIZE * 0.25f); 1926 gGL.vertex3f(0.f, mPlaneManipOffsetMeters * -PLANE_TICK_SIZE * 0.25f, mPlaneManipOffsetMeters * -PLANE_TICK_SIZE * 0.25f);
@@ -1932,7 +1960,7 @@ void LLManipTranslate::renderTranslationHandles()
1932 color2.setVec(1.f, 0.f, 0.f, 0.6f); 1960 color2.setVec(1.f, 0.f, 0.f, 0.6f);
1933 } 1961 }
1934 1962
1935 gGL.begin(LLVertexBuffer::TRIANGLES); 1963 gGL.begin(LLRender::TRIANGLES);
1936 { 1964 {
1937 gGL.color4fv(color1.mV); 1965 gGL.color4fv(color1.mV);
1938 gGL.vertex3f(mPlaneManipOffsetMeters * (PLANE_TICK_SIZE * 0.25f), 0.f, mPlaneManipOffsetMeters * (PLANE_TICK_SIZE * 0.25f)); 1966 gGL.vertex3f(mPlaneManipOffsetMeters * (PLANE_TICK_SIZE * 0.25f), 0.f, mPlaneManipOffsetMeters * (PLANE_TICK_SIZE * 0.25f));
@@ -1947,7 +1975,7 @@ void LLManipTranslate::renderTranslationHandles()
1947 gGL.end(); 1975 gGL.end();
1948 1976
1949 LLUI::setLineWidth(3.0f); 1977 LLUI::setLineWidth(3.0f);
1950 gGL.begin(LLVertexBuffer::LINES); 1978 gGL.begin(LLRender::LINES);
1951 { 1979 {
1952 gGL.color4f(0.f, 0.f, 0.f, 0.3f); 1980 gGL.color4f(0.f, 0.f, 0.f, 0.3f);
1953 gGL.vertex3f(mPlaneManipOffsetMeters * -PLANE_TICK_SIZE * 0.25f, 0.f, mPlaneManipOffsetMeters * -PLANE_TICK_SIZE * 0.25f); 1981 gGL.vertex3f(mPlaneManipOffsetMeters * -PLANE_TICK_SIZE * 0.25f, 0.f, mPlaneManipOffsetMeters * -PLANE_TICK_SIZE * 0.25f);
@@ -2011,7 +2039,7 @@ void LLManipTranslate::renderTranslationHandles()
2011 color2.setVec(0.f, 0.8f, 0.f, 0.6f); 2039 color2.setVec(0.f, 0.8f, 0.f, 0.6f);
2012 } 2040 }
2013 2041
2014 gGL.begin(LLVertexBuffer::TRIANGLES); 2042 gGL.begin(LLRender::TRIANGLES);
2015 { 2043 {
2016 gGL.color4fv(color1.mV); 2044 gGL.color4fv(color1.mV);
2017 gGL.vertex3fv(v0.mV); 2045 gGL.vertex3fv(v0.mV);
@@ -2026,7 +2054,7 @@ void LLManipTranslate::renderTranslationHandles()
2026 gGL.end(); 2054 gGL.end();
2027 2055
2028 LLUI::setLineWidth(3.0f); 2056 LLUI::setLineWidth(3.0f);
2029 gGL.begin(LLVertexBuffer::LINES); 2057 gGL.begin(LLRender::LINES);
2030 { 2058 {
2031 gGL.color4f(0.f, 0.f, 0.f, 0.3f); 2059 gGL.color4f(0.f, 0.f, 0.f, 0.3f);
2032 LLVector3 v12 = (v1 + v2) * .5f; 2060 LLVector3 v12 = (v1 + v2) * .5f;
@@ -2052,7 +2080,7 @@ void LLManipTranslate::renderTranslationHandles()
2052 } 2080 }
2053 } 2081 }
2054 { 2082 {
2055 LLGLSNoTexture gls_ui_no_texture; 2083 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
2056 2084
2057 // Since we draw handles with depth testing off, we need to draw them in the 2085 // Since we draw handles with depth testing off, we need to draw them in the
2058 // proper depth order. 2086 // proper depth order.
@@ -2126,7 +2154,7 @@ void LLManipTranslate::renderTranslationHandles()
2126 2154
2127void LLManipTranslate::renderArrow(S32 which_arrow, S32 selected_arrow, F32 box_size, F32 arrow_size, F32 handle_size, BOOL reverse_direction) 2155void LLManipTranslate::renderArrow(S32 which_arrow, S32 selected_arrow, F32 box_size, F32 arrow_size, F32 handle_size, BOOL reverse_direction)
2128{ 2156{
2129 LLGLSNoTexture gls_ui_no_texture; 2157 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
2130 LLGLEnable gls_blend(GL_BLEND); 2158 LLGLEnable gls_blend(GL_BLEND);
2131 LLGLEnable gls_color_material(GL_COLOR_MATERIAL); 2159 LLGLEnable gls_color_material(GL_COLOR_MATERIAL);
2132 2160
@@ -2160,7 +2188,7 @@ void LLManipTranslate::renderArrow(S32 which_arrow, S32 selected_arrow, F32 box_
2160 2188
2161 { 2189 {
2162 LLUI::setLineWidth(2.0f); 2190 LLUI::setLineWidth(2.0f);
2163 gGL.begin(LLVertexBuffer::LINES); 2191 gGL.begin(LLRender::LINES);
2164 vec.mV[index] = box_size; 2192 vec.mV[index] = box_size;
2165 gGL.vertex3f(vec.mV[0], vec.mV[1], vec.mV[2]); 2193 gGL.vertex3f(vec.mV[0], vec.mV[1], vec.mV[2]);
2166 2194