aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:54 -0500
committerJacek Antonelli2008-08-15 23:44:54 -0500
commitb2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch)
tree3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/llrender
parentSecond Life viewer sources 1.14.0.1 (diff)
downloadmeta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz
Second Life viewer sources 1.15.0.2
Diffstat (limited to 'linden/indra/llrender')
-rw-r--r--linden/indra/llrender/files.lst1
-rw-r--r--linden/indra/llrender/llfont.cpp6
-rw-r--r--linden/indra/llrender/llfont.h1
-rw-r--r--linden/indra/llrender/llfontgl.cpp194
-rw-r--r--linden/indra/llrender/llfontgl.h4
-rw-r--r--linden/indra/llrender/llgldbg.cpp3
-rw-r--r--linden/indra/llrender/llgldbg.h1
-rw-r--r--linden/indra/llrender/llimagegl.cpp12
-rw-r--r--linden/indra/llrender/llimagegl.h4
-rw-r--r--linden/indra/llrender/llrender.vcproj6
-rw-r--r--linden/indra/llrender/llrender_vc8.vcproj8
-rw-r--r--linden/indra/llrender/llvertexprogramgl.cpp1
-rw-r--r--linden/indra/llrender/llvertexprogramgl.h1
-rw-r--r--linden/indra/llrender/text_out.cpp115
-rw-r--r--linden/indra/llrender/text_out.h40
15 files changed, 138 insertions, 259 deletions
diff --git a/linden/indra/llrender/files.lst b/linden/indra/llrender/files.lst
index a813342..a4d541e 100644
--- a/linden/indra/llrender/files.lst
+++ b/linden/indra/llrender/files.lst
@@ -3,4 +3,3 @@ llrender/llfontgl.cpp
3llrender/llgldbg.cpp 3llrender/llgldbg.cpp
4llrender/llimagegl.cpp 4llrender/llimagegl.cpp
5llrender/llvertexbuffer.cpp 5llrender/llvertexbuffer.cpp
6llrender/text_out.cpp
diff --git a/linden/indra/llrender/llfont.cpp b/linden/indra/llrender/llfont.cpp
index c64744e..ed787e0 100644
--- a/linden/indra/llrender/llfont.cpp
+++ b/linden/indra/llrender/llfont.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -135,6 +136,7 @@ LLFont::LLFont(LLImageRaw *imagep)
135 mNumComponents = 0; 136 mNumComponents = 0;
136 mFallbackFontp = NULL; 137 mFallbackFontp = NULL;
137 mIsFallback = FALSE; 138 mIsFallback = FALSE;
139 mFTFace = NULL;
138} 140}
139 141
140 142
@@ -143,7 +145,8 @@ LLFont::~LLFont()
143 mRawImagep = NULL; // dereferences or deletes image 145 mRawImagep = NULL; // dereferences or deletes image
144 146
145 // Clean up freetype libs. 147 // Clean up freetype libs.
146 FT_Done_Face(mFTFace); 148 if (mFTFace)
149 FT_Done_Face(mFTFace);
147 mFTFace = NULL; 150 mFTFace = NULL;
148 151
149 // Delete glyph info 152 // Delete glyph info
@@ -200,6 +203,7 @@ BOOL LLFont::loadFace(const std::string& filename, const F32 point_size, const F
200 { 203 {
201 // Clean up freetype libs. 204 // Clean up freetype libs.
202 FT_Done_Face(mFTFace); 205 FT_Done_Face(mFTFace);
206 mFTFace = NULL;
203 return FALSE; 207 return FALSE;
204 } 208 }
205 209
diff --git a/linden/indra/llrender/llfont.h b/linden/indra/llrender/llfont.h
index a84a302..f10f7bb 100644
--- a/linden/indra/llrender/llfont.h
+++ b/linden/indra/llrender/llfont.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llrender/llfontgl.cpp b/linden/indra/llrender/llfontgl.cpp
index f72a7de..7ee89c7 100644
--- a/linden/indra/llrender/llfontgl.cpp
+++ b/linden/indra/llrender/llfontgl.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -69,6 +70,7 @@ const F32 PIXEL_BORDER_THRESHOLD = 0.0001f;
69const F32 PIXEL_CORRECTION_DISTANCE = 0.01f; 70const F32 PIXEL_CORRECTION_DISTANCE = 0.01f;
70 71
71const F32 PAD_AMT = 0.5f; 72const F32 PAD_AMT = 0.5f;
73const F32 DROP_SHADOW_STRENGTH = 0.3f;
72 74
73F32 llfont_round_x(F32 x) 75F32 llfont_round_x(F32 x)
74{ 76{
@@ -133,7 +135,8 @@ void LLFontGL::init()
133 mImageGLp = new LLImageGL(FALSE); 135 mImageGLp = new LLImageGL(FALSE);
134 //RN: use nearest mipmap filtering to obviate the need to do pixel-accurate positioning 136 //RN: use nearest mipmap filtering to obviate the need to do pixel-accurate positioning
135 mImageGLp->bind(); 137 mImageGLp->bind();
136 mImageGLp->setMipFilterNearest(TRUE, TRUE); 138 // we allow bilinear filtering to get sub-pixel positioning for drop shadows
139 //mImageGLp->setMipFilterNearest(TRUE, TRUE);
137 } 140 }
138 if (mRawImageGLp.isNull()) 141 if (mRawImageGLp.isNull())
139 { 142 {
@@ -549,28 +552,8 @@ S32 LLFontGL::render(const LLWString &wstr,
549 return 0; 552 return 0;
550 } 553 }
551 554
552 if (style & DROP_SHADOW)
553 {
554 LLColor4 shadow_color = sShadowColor;
555 shadow_color[3] = color[3];
556 render(wstr, begin_offset,
557 x + 1.f / sScaleX,
558 y - 1.f / sScaleY,
559 shadow_color,
560 halign,
561 valign,
562 style & (~DROP_SHADOW),
563 max_chars,
564 max_pixels,
565 right_x,
566 use_embedded,
567 use_ellipses);
568 }
569
570 S32 scaled_max_pixels = max_pixels == S32_MAX ? S32_MAX : llceil((F32)max_pixels * sScaleX); 555 S32 scaled_max_pixels = max_pixels == S32_MAX ? S32_MAX : llceil((F32)max_pixels * sScaleX);
571 556
572 BOOL render_bold = FALSE;
573
574 // HACK for better bolding 557 // HACK for better bolding
575 if (style & BOLD) 558 if (style & BOLD)
576 { 559 {
@@ -585,9 +568,17 @@ S32 LLFontGL::render(const LLWString &wstr,
585 max_chars, max_pixels, 568 max_chars, max_pixels,
586 right_x, use_embedded); 569 right_x, use_embedded);
587 } 570 }
588 else 571 }
572
573 F32 drop_shadow_strength = 0.f;
574 if (style & DROP_SHADOW)
575 {
576 F32 luminance;
577 color.calcHSL(NULL, NULL, &luminance);
578 drop_shadow_strength = clamp_rescale(luminance, 0.35f, 0.6f, 0.f, DROP_SHADOW_STRENGTH);
579 if (luminance < 0.35f)
589 { 580 {
590 render_bold = TRUE; 581 style = style & ~DROP_SHADOW;
591 } 582 }
592 } 583 }
593 584
@@ -631,9 +622,6 @@ S32 LLFontGL::render(const LLWString &wstr,
631 } 622 }
632 623
633 F32 cur_x, cur_y, cur_render_x, cur_render_y; 624 F32 cur_x, cur_y, cur_render_x, cur_render_y;
634 F32 slant_offset;
635
636 slant_offset = ((style & ITALIC) ? ( -mAscender * 0.25f) : 0.f);
637 625
638 // Bind the font texture 626 // Bind the font texture
639 627
@@ -696,7 +684,7 @@ S32 LLFontGL::render(const LLWString &wstr,
696 if (use_ellipses && halign == LEFT) 684 if (use_ellipses && halign == LEFT)
697 { 685 {
698 // check for too long of a string 686 // check for too long of a string
699 if (getWidthF32(wstr.c_str(), 0, max_chars) > scaled_max_pixels) 687 if (getWidthF32(wstr.c_str(), 0, max_chars) * sScaleX > scaled_max_pixels)
700 { 688 {
701 // use four dots for ellipsis width to generate padding 689 // use four dots for ellipsis width to generate padding
702 const LLWString dots(utf8str_to_wstring(LLString("...."))); 690 const LLWString dots(utf8str_to_wstring(LLString("....")));
@@ -706,7 +694,6 @@ S32 LLFontGL::render(const LLWString &wstr,
706 } 694 }
707 695
708 696
709 glBegin(GL_QUADS);
710 for (i = begin_offset; i < begin_offset + length; i++) 697 for (i = begin_offset; i < begin_offset + length; i++)
711 { 698 {
712 llwchar wch = wstr[i]; 699 llwchar wch = wstr[i];
@@ -735,36 +722,13 @@ S32 LLFontGL::render(const LLWString &wstr,
735 break; 722 break;
736 } 723 }
737 724
738 glEnd();
739
740 glColor3f(1.f, 1.f, 1.f);
741
742 ext_image->bind(); 725 ext_image->bind();
743 const F32 ext_x = cur_render_x + (EXT_X_BEARING * sScaleX); 726 const F32 ext_x = cur_render_x + (EXT_X_BEARING * sScaleX);
744 const F32 ext_y = cur_render_y + (EXT_Y_BEARING * sScaleY + mAscender - mLineHeight); 727 const F32 ext_y = cur_render_y + (EXT_Y_BEARING * sScaleY + mAscender - mLineHeight);
745 728
746 glBegin(GL_QUADS); 729 LLRectf uv_rect(0.f, 1.f, 1.f, 0.f);
747 { 730 LLRectf screen_rect(ext_x, ext_y + ext_height, ext_x + ext_width, ext_y);
748 S32 num_passes = render_bold ? 2 : 1; 731 drawGlyph(screen_rect, uv_rect, LLColor4::white, style, drop_shadow_strength);
749 for (S32 pass = 0; pass < num_passes; pass++)
750 {
751 glTexCoord2f(1.f, 1.f);
752 glVertex2f(llfont_round_x(ext_x + ext_width + (F32)(pass * BOLD_OFFSET)),
753 llfont_round_y(ext_y + ext_height));
754
755 glTexCoord2f(0.f, 1.f);
756 glVertex2f(llfont_round_x(ext_x + (F32)(pass * BOLD_OFFSET)),
757 llfont_round_y(ext_y + ext_height));
758
759 glTexCoord2f(0.f, 0.f);
760 glVertex2f(llfont_round_x(ext_x + (F32)(pass * BOLD_OFFSET)), llfont_round_y(ext_y));
761
762 glTexCoord2f(1.f, 0.f);
763 glVertex2f(llfont_round_x(ext_x + ext_width + (F32)(pass * BOLD_OFFSET)),
764 llfont_round_y(ext_y));
765 }
766 }
767 glEnd();
768 732
769 if (!label.empty()) 733 if (!label.empty())
770 { 734 {
@@ -793,15 +757,12 @@ S32 LLFontGL::render(const LLWString &wstr,
793 757
794 // Bind the font texture 758 // Bind the font texture
795 mImageGLp->bind(); 759 mImageGLp->bind();
796 glBegin(GL_QUADS);
797 } 760 }
798 else 761 else
799 { 762 {
800 if (!hasGlyph(wch)) 763 if (!hasGlyph(wch))
801 { 764 {
802 glEnd();
803 (const_cast<LLFontGL*>(this))->addChar(wch); 765 (const_cast<LLFontGL*>(this))->addChar(wch);
804 glBegin(GL_QUADS);
805 } 766 }
806 767
807 const LLFontGlyphInfo* fgi= getGlyphInfo(wch); 768 const LLFontGlyphInfo* fgi= getGlyphInfo(wch);
@@ -817,40 +778,28 @@ S32 LLFontGL::render(const LLWString &wstr,
817 778
818 // Draw the text at the appropriate location 779 // Draw the text at the appropriate location
819 //Specify vertices and texture coordinates 780 //Specify vertices and texture coordinates
820 S32 num_passes = render_bold ? 2 : 1; 781 LLRectf uv_rect((fgi->mXBitmapOffset - PAD_AMT) * inv_width,
821 for (S32 pass = 0; pass < num_passes; pass++) 782 (fgi->mYBitmapOffset + fgi->mHeight + PAD_AMT) * inv_height,
822 { 783 (fgi->mXBitmapOffset + fgi->mWidth + PAD_AMT) * inv_width,
823 glTexCoord2f((fgi->mXBitmapOffset - PAD_AMT) * inv_width, 784 (fgi->mYBitmapOffset - PAD_AMT) * inv_height);
824 (fgi->mYBitmapOffset + fgi->mHeight + PAD_AMT) * inv_height); 785 LLRectf screen_rect(cur_render_x + (F32)fgi->mXBearing - PAD_AMT,
825 glVertex2f(llfont_round_x(cur_render_x + (F32)fgi->mXBearing + (F32)(pass * BOLD_OFFSET) - PAD_AMT), 786 cur_render_y + (F32)fgi->mYBearing + PAD_AMT,
826 llfont_round_y(cur_render_y + (F32)fgi->mYBearing + PAD_AMT)); 787 cur_render_x + (F32)fgi->mXBearing + (F32)fgi->mWidth + PAD_AMT,
827 glTexCoord2f((fgi->mXBitmapOffset - PAD_AMT) * inv_width, 788 cur_render_y + (F32)fgi->mYBearing - (F32)fgi->mHeight - PAD_AMT);
828 (fgi->mYBitmapOffset - PAD_AMT) * inv_height);
829 glVertex2f(llfont_round_x(cur_render_x + (F32)fgi->mXBearing + slant_offset + (F32)(pass * BOLD_OFFSET) - PAD_AMT),
830 llfont_round_y(cur_render_y + (F32)fgi->mYBearing - (F32)fgi->mHeight - PAD_AMT));
831 glTexCoord2f((fgi->mXBitmapOffset + fgi->mWidth + PAD_AMT) * inv_width,
832 (fgi->mYBitmapOffset - PAD_AMT) * inv_height);
833 glVertex2f(llfont_round_x(cur_render_x + (F32)fgi->mXBearing + slant_offset + (F32)fgi->mWidth + (F32)(pass * BOLD_OFFSET) + PAD_AMT),
834 llfont_round_y(cur_render_y + (F32)fgi->mYBearing - (F32)fgi->mHeight - PAD_AMT));
835 glTexCoord2f((fgi->mXBitmapOffset + fgi->mWidth + PAD_AMT) * inv_width,
836 (fgi->mYBitmapOffset + fgi->mHeight + PAD_AMT) * inv_height);
837 glVertex2f(llfont_round_x(cur_render_x + (F32)fgi->mXBearing + (F32)fgi->mWidth + (F32)(pass * BOLD_OFFSET) + PAD_AMT),
838 llfont_round_y(cur_render_y + (F32)fgi->mYBearing + PAD_AMT));
839 }
840 789
841 chars_drawn++; 790 drawGlyph(screen_rect, uv_rect, color, style, drop_shadow_strength);
842 791
792 chars_drawn++;
843 cur_x += fgi->mXAdvance; 793 cur_x += fgi->mXAdvance;
844 cur_y += fgi->mYAdvance; 794 cur_y += fgi->mYAdvance;
795
845 llwchar next_char = wstr[i+1]; 796 llwchar next_char = wstr[i+1];
846 if (next_char && (next_char < LAST_CHARACTER)) 797 if (next_char && (next_char < LAST_CHARACTER))
847 { 798 {
848 // Kern this puppy. 799 // Kern this puppy.
849 if (!hasGlyph(next_char)) 800 if (!hasGlyph(next_char))
850 { 801 {
851 glEnd();
852 (const_cast<LLFontGL*>(this))->addChar(next_char); 802 (const_cast<LLFontGL*>(this))->addChar(next_char);
853 glBegin(GL_QUADS);
854 } 803 }
855 cur_x += getXKerning(wch, next_char); 804 cur_x += getXKerning(wch, next_char);
856 } 805 }
@@ -867,8 +816,6 @@ S32 LLFontGL::render(const LLWString &wstr,
867 } 816 }
868 } 817 }
869 818
870 glEnd();
871
872 if (right_x) 819 if (right_x)
873 { 820 {
874 *right_x = cur_x / sScaleX; 821 *right_x = cur_x / sScaleX;
@@ -1347,6 +1294,89 @@ void LLFontGL::removeEmbeddedChar( llwchar wc )
1347 } 1294 }
1348} 1295}
1349 1296
1297
1298void LLFontGL::renderQuad(const LLRectf& screen_rect, const LLRectf& uv_rect, F32 slant_amt) const
1299{
1300 glTexCoord2f(uv_rect.mRight, uv_rect.mTop);
1301 glVertex2f(llfont_round_x(screen_rect.mRight),
1302 llfont_round_y(screen_rect.mTop));
1303
1304 glTexCoord2f(uv_rect.mLeft, uv_rect.mTop);
1305 glVertex2f(llfont_round_x(screen_rect.mLeft),
1306 llfont_round_y(screen_rect.mTop));
1307
1308 glTexCoord2f(uv_rect.mLeft, uv_rect.mBottom);
1309 glVertex2f(llfont_round_x(screen_rect.mLeft + slant_amt),
1310 llfont_round_y(screen_rect.mBottom));
1311
1312 glTexCoord2f(uv_rect.mRight, uv_rect.mBottom);
1313 glVertex2f(llfont_round_x(screen_rect.mRight + slant_amt),
1314 llfont_round_y(screen_rect.mBottom));
1315}
1316
1317void LLFontGL::drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4& color, U8 style, F32 drop_shadow_strength) const
1318{
1319 F32 slant_offset;
1320 slant_offset = ((style & ITALIC) ? ( -mAscender * 0.2f) : 0.f);
1321
1322 glBegin(GL_QUADS);
1323 {
1324 //FIXME: bold and drop shadow are mutually exclusive only for convenience
1325 //Allow both when we need them.
1326 if (style & BOLD)
1327 {
1328 glColor4fv(color.mV);
1329 for (S32 pass = 0; pass < 2; pass++)
1330 {
1331 LLRectf screen_rect_offset = screen_rect;
1332
1333 screen_rect_offset.translate((F32)(pass * BOLD_OFFSET), 0.f);
1334 renderQuad(screen_rect_offset, uv_rect, slant_offset);
1335 }
1336 }
1337 else if (style & DROP_SHADOW)
1338 {
1339 LLColor4 shadow_color = LLFontGL::sShadowColor;
1340 shadow_color.mV[VALPHA] = color.mV[VALPHA] * drop_shadow_strength;
1341 glColor4fv(shadow_color.mV);
1342 for (S32 pass = 0; pass < 5; pass++)
1343 {
1344 LLRectf screen_rect_offset = screen_rect;
1345
1346 switch(pass)
1347 {
1348 case 0:
1349 screen_rect_offset.translate(-1.f, -1.f);
1350 break;
1351 case 1:
1352 screen_rect_offset.translate(1.f, -1.f);
1353 break;
1354 case 2:
1355 screen_rect_offset.translate(1.f, 1.f);
1356 break;
1357 case 3:
1358 screen_rect_offset.translate(-1.f, 1.f);
1359 break;
1360 case 4:
1361 screen_rect_offset.translate(0, -2.f);
1362 break;
1363 }
1364
1365 renderQuad(screen_rect_offset, uv_rect, slant_offset);
1366 }
1367 glColor4fv(color.mV);
1368 renderQuad(screen_rect, uv_rect, slant_offset);
1369 }
1370 else // normal rendering
1371 {
1372 glColor4fv(color.mV);
1373 renderQuad(screen_rect, uv_rect, slant_offset);
1374 }
1375
1376 }
1377 glEnd();
1378}
1379
1350// static 1380// static
1351LLString LLFontGL::nameFromFont(const LLFontGL* fontp) 1381LLString LLFontGL::nameFromFont(const LLFontGL* fontp)
1352{ 1382{
diff --git a/linden/indra/llrender/llfontgl.h b/linden/indra/llrender/llfontgl.h
index bcb8dfb..98a7a55 100644
--- a/linden/indra/llrender/llfontgl.h
+++ b/linden/indra/llrender/llfontgl.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2001-2007, Linden Research, Inc. 6 * Copyright (c) 2001-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -33,6 +34,7 @@
33#include "llimagegl.h" 34#include "llimagegl.h"
34#include "v2math.h" 35#include "v2math.h"
35#include "llcoord.h" 36#include "llcoord.h"
37#include "llrect.h"
36 38
37class LLColor4; 39class LLColor4;
38 40
@@ -206,6 +208,8 @@ protected:
206 const embedded_data_t* getEmbeddedCharData(const llwchar wch) const; 208 const embedded_data_t* getEmbeddedCharData(const llwchar wch) const;
207 F32 getEmbeddedCharAdvance(const embedded_data_t* ext_data) const; 209 F32 getEmbeddedCharAdvance(const embedded_data_t* ext_data) const;
208 void clearEmbeddedChars(); 210 void clearEmbeddedChars();
211 void renderQuad(const LLRectf& screen_rect, const LLRectf& uv_rect, F32 slant_amt) const;
212 void drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4& color, U8 style, F32 drop_shadow_fade) const;
209 213
210public: 214public:
211 static F32 sVertDPI; 215 static F32 sVertDPI;
diff --git a/linden/indra/llrender/llgldbg.cpp b/linden/indra/llrender/llgldbg.cpp
index ab35353..84f0082 100644
--- a/linden/indra/llrender/llgldbg.cpp
+++ b/linden/indra/llrender/llgldbg.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -100,7 +101,7 @@ char *fv3(F32 *f)
100char *fv1(F32 *f) 101char *fv1(F32 *f)
101{ 102{
102 static char str[128]; /* Flawfinder: ignore */ 103 static char str[128]; /* Flawfinder: ignore */
103 snprintf(str, sizeof(str), "%8.3f", f[0]); /* Flawfinder: ignore */ 104 snprintf(str, sizeof(str), "%8.3f", f[0]); /* Flawfinder: ignore */
104 return str; 105 return str;
105} 106}
106 107
diff --git a/linden/indra/llrender/llgldbg.h b/linden/indra/llrender/llgldbg.h
index 39be147..4483fb9 100644
--- a/linden/indra/llrender/llgldbg.h
+++ b/linden/indra/llrender/llgldbg.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llrender/llimagegl.cpp b/linden/indra/llrender/llimagegl.cpp
index 8386e95..464507e 100644
--- a/linden/indra/llrender/llimagegl.cpp
+++ b/linden/indra/llrender/llimagegl.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -176,7 +177,7 @@ void LLImageGL::destroyGL(BOOL save_state)
176 if (save_state) 177 if (save_state)
177 { 178 {
178 glimage->mSaveData = new LLImageRaw; 179 glimage->mSaveData = new LLImageRaw;
179 glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData); 180 glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData, false);
180 } 181 }
181 glimage->destroyGLTexture(); 182 glimage->destroyGLTexture();
182 stop_glerror(); 183 stop_glerror();
@@ -939,7 +940,7 @@ BOOL LLImageGL::setDiscardLevel(S32 discard_level)
939 LLPointer<LLImageRaw> imageraw = new LLImageRaw; 940 LLPointer<LLImageRaw> imageraw = new LLImageRaw;
940 while(discard_level > mCurrentDiscardLevel) 941 while(discard_level > mCurrentDiscardLevel)
941 { 942 {
942 if (readBackRaw(discard_level, imageraw)) 943 if (readBackRaw(discard_level, imageraw, false))
943 { 944 {
944 break; 945 break;
945 } 946 }
@@ -961,7 +962,7 @@ BOOL LLImageGL::setDiscardLevel(S32 discard_level)
961 } 962 }
962} 963}
963 964
964BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw) 965BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok)
965{ 966{
966 if (discard_level < 0) 967 if (discard_level < 0)
967 { 968 {
@@ -999,7 +1000,10 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw)
999 } 1000 }
1000 1001
1001 LLGLint is_compressed = 0; 1002 LLGLint is_compressed = 0;
1002 glGetTexLevelParameteriv(mTarget, is_compressed, GL_TEXTURE_COMPRESSED, (GLint*)&is_compressed); 1003 if (compressed_ok)
1004 {
1005 glGetTexLevelParameteriv(mTarget, is_compressed, GL_TEXTURE_COMPRESSED, (GLint*)&is_compressed);
1006 }
1003 if (is_compressed) 1007 if (is_compressed)
1004 { 1008 {
1005 LLGLint glbytes; 1009 LLGLint glbytes;
diff --git a/linden/indra/llrender/llimagegl.h b/linden/indra/llrender/llimagegl.h
index 20c31d1..16315ee 100644
--- a/linden/indra/llrender/llimagegl.h
+++ b/linden/indra/llrender/llimagegl.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -91,7 +92,8 @@ public:
91 BOOL setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height); 92 BOOL setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height);
92 BOOL setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_pos, S32 width, S32 height); 93 BOOL setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_pos, S32 width, S32 height);
93 BOOL setDiscardLevel(S32 discard_level); 94 BOOL setDiscardLevel(S32 discard_level);
94 BOOL readBackRaw(S32 discard_level, LLImageRaw* imageraw); // Read back a raw image for this discard level, if it exists 95 // Read back a raw image for this discard level, if it exists
96 BOOL readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok);
95 void destroyGLTexture(); 97 void destroyGLTexture();
96 98
97 void setClamp(BOOL clamps, BOOL clampt); 99 void setClamp(BOOL clamps, BOOL clampt);
diff --git a/linden/indra/llrender/llrender.vcproj b/linden/indra/llrender/llrender.vcproj
index d13384d..86ab1c8 100644
--- a/linden/indra/llrender/llrender.vcproj
+++ b/linden/indra/llrender/llrender.vcproj
@@ -168,9 +168,6 @@
168 <File 168 <File
169 RelativePath=".\llvertexbuffer.cpp"> 169 RelativePath=".\llvertexbuffer.cpp">
170 </File> 170 </File>
171 <File
172 RelativePath=".\text_out.cpp">
173 </File>
174 </Filter> 171 </Filter>
175 <Filter 172 <Filter
176 Name="Header Files" 173 Name="Header Files"
@@ -209,9 +206,6 @@
209 <File 206 <File
210 RelativePath=".\llvertexprogramgl.h"> 207 RelativePath=".\llvertexprogramgl.h">
211 </File> 208 </File>
212 <File
213 RelativePath=".\text_out.h">
214 </File>
215 </Filter> 209 </Filter>
216 <Filter 210 <Filter
217 Name="Resource Files" 211 Name="Resource Files"
diff --git a/linden/indra/llrender/llrender_vc8.vcproj b/linden/indra/llrender/llrender_vc8.vcproj
index daa2cfc..4688988 100644
--- a/linden/indra/llrender/llrender_vc8.vcproj
+++ b/linden/indra/llrender/llrender_vc8.vcproj
@@ -247,10 +247,6 @@
247 RelativePath=".\llvertexbuffer.cpp" 247 RelativePath=".\llvertexbuffer.cpp"
248 > 248 >
249 </File> 249 </File>
250 <File
251 RelativePath=".\text_out.cpp"
252 >
253 </File>
254 </Filter> 250 </Filter>
255 <Filter 251 <Filter
256 Name="Header Files" 252 Name="Header Files"
@@ -285,10 +281,6 @@
285 RelativePath=".\llvertexprogramgl.h" 281 RelativePath=".\llvertexprogramgl.h"
286 > 282 >
287 </File> 283 </File>
288 <File
289 RelativePath=".\text_out.h"
290 >
291 </File>
292 </Filter> 284 </Filter>
293 <Filter 285 <Filter
294 Name="Resource Files" 286 Name="Resource Files"
diff --git a/linden/indra/llrender/llvertexprogramgl.cpp b/linden/indra/llrender/llvertexprogramgl.cpp
index 4ccdf01..5a65a5f 100644
--- a/linden/indra/llrender/llvertexprogramgl.cpp
+++ b/linden/indra/llrender/llvertexprogramgl.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc. 5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llrender/llvertexprogramgl.h b/linden/indra/llrender/llvertexprogramgl.h
index 78cb1c9..cf6ac37 100644
--- a/linden/indra/llrender/llvertexprogramgl.h
+++ b/linden/indra/llrender/llvertexprogramgl.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc. 5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llrender/text_out.cpp b/linden/indra/llrender/text_out.cpp
deleted file mode 100644
index 572ed03..0000000
--- a/linden/indra/llrender/text_out.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
1/**
2 * @file text_out.cpp
3 * @brief Text rendering implementation
4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28/* DEPRECATED - Use LLFontGL for raw rendering, or make an LLTextBox to hold the text */
29
30#include "linden_common.h"
31
32#include "text_out.h"
33#include "llfontgl.h"
34//#include "vmath.h"
35#include "v4color.h"
36
37#define MAX_TEXT_LINE_LENGTH (256)
38#define MAX_TEXT_LINES (128)
39
40extern S32 gWindowWidth;
41extern S32 gWindowHeight;
42
43S32 gNumTextLines = 0;
44
45LLColor4 gCurrentColor;
46//U8 gCurrentBGColor[] = { 32, 32, 32 };
47
48//F32 gCurrentScale = 10.f;
49
50typedef struct s_text_line
51{
52// const LLFontGL *font;
53// U8 color[3];
54// U8 bg_color[3];
55 char line[MAX_TEXT_LINE_LENGTH]; /* Flawfinder: ignore */
56 S32 x, y;
57// ETextModifiers tm;
58// ETextColorModifiers fcm;
59// ETextColorModifiers bcm;
60} TEXT_LINE;
61
62TEXT_LINE gTextLine[MAX_TEXT_LINES];
63
64void set_text_color( const LLColor4& color )
65{
66 gCurrentColor = color;
67}
68/*
69void set_text_bg_color(S32 red, S32 green, S32 blue)
70{
71 gCurrentBGColor[0] = red;
72 gCurrentBGColor[1] = green;
73 gCurrentBGColor[2] = blue;
74}
75*/
76void reset_num_text_lines(void)
77{
78 gNumTextLines = 0;
79}
80
81void add_text(S32 x, S32 y, char *text) // , ETextModifiers tm, ETextColorModifiers fcm, ETextColorModifiers bcm)
82{
83 if (gNumTextLines > MAX_TEXT_LINES) return;
84
85 TEXT_LINE *linep = &gTextLine[gNumTextLines++];
86
87 strcpy(linep->line, text); /* Flawfinder: ignore */
88 linep->x = x;
89 linep->y = y;
90}
91
92
93// Writes text on the screen. Deprecated, don't write new code using this.
94void show_text_gl(void)
95{
96 S32 i;
97
98 TEXT_LINE *linep;
99
100 if (gNumTextLines > MAX_TEXT_LINES)
101 {
102 gNumTextLines = MAX_TEXT_LINES;
103 }
104
105 for (i = 0; i < gNumTextLines; i++)
106 {
107 linep = &gTextLine[i];
108
109 LLFontGL::sMonospace->renderUTF8(linep->line, 0, (F32)linep->x, (F32)linep->y, gCurrentColor,
110 LLFontGL::LEFT, LLFontGL::TOP,
111 LLFontGL::NORMAL, S32_MAX, S32_MAX, NULL, FALSE);
112 }
113 gNumTextLines = 0;
114}
115
diff --git a/linden/indra/llrender/text_out.h b/linden/indra/llrender/text_out.h
deleted file mode 100644
index 5080bd5..0000000
--- a/linden/indra/llrender/text_out.h
+++ /dev/null
@@ -1,40 +0,0 @@
1/**
2 * @file text_out.h
3 * @brief Text rendering implementation
4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_TEXT_OUT_H
29#define LL_TEXT_OUT_H
30
31// DEPRECATED - Use LLFontGL for raw rendering, or make an LLTextBox to hold the text
32
33class LLColor4;
34
35void set_text_color(const LLColor4& color);
36void add_text(S32 x, S32 y, char *text);
37void show_text_gl(void);
38void reset_num_text_lines(void);
39
40#endif