aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llfontgl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llrender/llfontgl.cpp')
-rw-r--r--linden/indra/llrender/llfontgl.cpp73
1 files changed, 37 insertions, 36 deletions
diff --git a/linden/indra/llrender/llfontgl.cpp b/linden/indra/llrender/llfontgl.cpp
index 99f68d6..bb60b70 100644
--- a/linden/indra/llrender/llfontgl.cpp
+++ b/linden/indra/llrender/llfontgl.cpp
@@ -36,6 +36,7 @@
36#include "llfont.h" 36#include "llfont.h"
37#include "llfontgl.h" 37#include "llfontgl.h"
38#include "llgl.h" 38#include "llgl.h"
39#include "llglimmediate.h"
39#include "v4color.h" 40#include "v4color.h"
40#include "llstl.h" 41#include "llstl.h"
41 42
@@ -556,8 +557,8 @@ S32 LLFontGL::render(const LLWString &wstr,
556 BOOL use_embedded, 557 BOOL use_embedded,
557 BOOL use_ellipses) const 558 BOOL use_ellipses) const
558{ 559{
559 LLGLEnable texture_2d(GL_TEXTURE_2D); 560 LLGLEnable tex(GL_TEXTURE_2D);
560 561
561 if (wstr.empty()) 562 if (wstr.empty())
562 { 563 {
563 return 0; 564 return 0;
@@ -593,9 +594,9 @@ S32 LLFontGL::render(const LLWString &wstr,
593 } 594 }
594 } 595 }
595 596
596 glPushMatrix(); 597 gGL.pushMatrix();
597 glLoadIdentity(); 598 glLoadIdentity();
598 glTranslatef(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY), sCurOrigin.mZ); 599 gGL.translatef(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY), sCurOrigin.mZ);
599 //glScalef(sScaleX, sScaleY, 1.0f); 600 //glScalef(sScaleX, sScaleY, 1.0f);
600 601
601 // avoid half pixels 602 // avoid half pixels
@@ -604,20 +605,20 @@ S32 LLFontGL::render(const LLWString &wstr,
604 //F32 half_pixel_distance = llabs(fmodf(sCurOrigin.mX * sScaleX, 1.f) - 0.5f); 605 //F32 half_pixel_distance = llabs(fmodf(sCurOrigin.mX * sScaleX, 1.f) - 0.5f);
605 //if (half_pixel_distance < PIXEL_BORDER_THRESHOLD) 606 //if (half_pixel_distance < PIXEL_BORDER_THRESHOLD)
606 //{ 607 //{
607 glTranslatef(PIXEL_CORRECTION_DISTANCE*sScaleX, 0.f, 0.f); 608 gGL.translatef(PIXEL_CORRECTION_DISTANCE*sScaleX, 0.f, 0.f);
608 //} 609 //}
609 610
610 // this code would just snap to pixel grid, although it seems to introduce more jitter 611 // this code would just snap to pixel grid, although it seems to introduce more jitter
611 //F32 pixel_offset_x = llround(sCurOrigin.mX * sScaleX) - (sCurOrigin.mX * sScaleX); 612 //F32 pixel_offset_x = llround(sCurOrigin.mX * sScaleX) - (sCurOrigin.mX * sScaleX);
612 //F32 pixel_offset_y = llround(sCurOrigin.mY * sScaleY) - (sCurOrigin.mY * sScaleY); 613 //F32 pixel_offset_y = llround(sCurOrigin.mY * sScaleY) - (sCurOrigin.mY * sScaleY);
613 //glTranslatef(-pixel_offset_x, -pixel_offset_y, 0.f); 614 //gGL.translatef(-pixel_offset_x, -pixel_offset_y, 0.f);
614 615
615 // scale back to native pixel size 616 // scale back to native pixel size
616 //glScalef(1.f / sScaleX, 1.f / sScaleY, 1.f); 617 //glScalef(1.f / sScaleX, 1.f / sScaleY, 1.f);
617 //glScaled(1.0 / (F64) sScaleX, 1.0 / (F64) sScaleY, 1.0f); 618 //glScaled(1.0 / (F64) sScaleX, 1.0 / (F64) sScaleY, 1.0f);
618 LLFastTimer t(LLFastTimer::FTM_RENDER_FONTS); 619 LLFastTimer t(LLFastTimer::FTM_RENDER_FONTS);
619 620
620 glColor4fv( color.mV ); 621 gGL.color4fv( color.mV );
621 622
622 S32 chars_drawn = 0; 623 S32 chars_drawn = 0;
623 S32 i; 624 S32 i;
@@ -638,7 +639,7 @@ S32 LLFontGL::render(const LLWString &wstr,
638 639
639 mImageGLp->bind(0); 640 mImageGLp->bind(0);
640 641
641 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Not guaranteed to be set correctly 642 gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Not guaranteed to be set correctly
642 643
643 cur_x = ((F32)x * sScaleX); 644 cur_x = ((F32)x * sScaleX);
644 cur_y = ((F32)y * sScaleY); 645 cur_y = ((F32)y * sScaleY);
@@ -743,9 +744,9 @@ S32 LLFontGL::render(const LLWString &wstr,
743 744
744 if (!label.empty()) 745 if (!label.empty())
745 { 746 {
746 glPushMatrix(); 747 gGL.pushMatrix();
747 //glLoadIdentity(); 748 //glLoadIdentity();
748 //glTranslatef(sCurOrigin.mX, sCurOrigin.mY, 0.0f); 749 //gGL.translatef(sCurOrigin.mX, sCurOrigin.mY, 0.0f);
749 //glScalef(sScaleX, sScaleY, 1.f); 750 //glScalef(sScaleX, sScaleY, 1.f);
750 gExtCharFont->render(label, 0, 751 gExtCharFont->render(label, 0,
751 /*llfloor*/((ext_x + (F32)ext_image->getWidth() + EXT_X_BEARING) / sScaleX), 752 /*llfloor*/((ext_x + (F32)ext_image->getWidth() + EXT_X_BEARING) / sScaleX),
@@ -753,10 +754,10 @@ S32 LLFontGL::render(const LLWString &wstr,
753 color, 754 color,
754 halign, BASELINE, NORMAL, S32_MAX, S32_MAX, NULL, 755 halign, BASELINE, NORMAL, S32_MAX, S32_MAX, NULL,
755 TRUE ); 756 TRUE );
756 glPopMatrix(); 757 gGL.popMatrix();
757 } 758 }
758 759
759 glColor4fv(color.mV); 760 gGL.color4fv(color.mV);
760 761
761 chars_drawn++; 762 chars_drawn++;
762 cur_x += ext_advance; 763 cur_x += ext_advance;
@@ -836,10 +837,10 @@ S32 LLFontGL::render(const LLWString &wstr,
836 if (style & UNDERLINE) 837 if (style & UNDERLINE)
837 { 838 {
838 LLGLSNoTexture no_texture; 839 LLGLSNoTexture no_texture;
839 glBegin(GL_LINES); 840 gGL.begin(GL_LINES);
840 glVertex2f(start_x, cur_y - (mDescender)); 841 gGL.vertex2f(start_x, cur_y - (mDescender));
841 glVertex2f(cur_x, cur_y - (mDescender)); 842 gGL.vertex2f(cur_x, cur_y - (mDescender));
842 glEnd(); 843 gGL.end();
843 } 844 }
844 845
845 // *FIX: get this working in all alignment cases, etc. 846 // *FIX: get this working in all alignment cases, etc.
@@ -847,9 +848,9 @@ S32 LLFontGL::render(const LLWString &wstr,
847 { 848 {
848 // recursively render ellipses at end of string 849 // recursively render ellipses at end of string
849 // we've already reserved enough room 850 // we've already reserved enough room
850 glPushMatrix(); 851 gGL.pushMatrix();
851 //glLoadIdentity(); 852 //glLoadIdentity();
852 //glTranslatef(sCurOrigin.mX, sCurOrigin.mY, 0.0f); 853 //gGL.translatef(sCurOrigin.mX, sCurOrigin.mY, 0.0f);
853 //glScalef(sScaleX, sScaleY, 1.f); 854 //glScalef(sScaleX, sScaleY, 1.f);
854 renderUTF8("...", 855 renderUTF8("...",
855 0, 856 0,
@@ -860,10 +861,10 @@ S32 LLFontGL::render(const LLWString &wstr,
860 S32_MAX, max_pixels, 861 S32_MAX, max_pixels,
861 right_x, 862 right_x,
862 FALSE); 863 FALSE);
863 glPopMatrix(); 864 gGL.popMatrix();
864 } 865 }
865 866
866 glPopMatrix(); 867 gGL.popMatrix();
867 868
868 return chars_drawn; 869 return chars_drawn;
869} 870}
@@ -1309,20 +1310,20 @@ void LLFontGL::removeEmbeddedChar( llwchar wc )
1309 1310
1310void LLFontGL::renderQuad(const LLRectf& screen_rect, const LLRectf& uv_rect, F32 slant_amt) const 1311void LLFontGL::renderQuad(const LLRectf& screen_rect, const LLRectf& uv_rect, F32 slant_amt) const
1311{ 1312{
1312 glTexCoord2f(uv_rect.mRight, uv_rect.mTop); 1313 gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop);
1313 glVertex2f(llfont_round_x(screen_rect.mRight), 1314 gGL.vertex2f(llfont_round_x(screen_rect.mRight),
1314 llfont_round_y(screen_rect.mTop)); 1315 llfont_round_y(screen_rect.mTop));
1315 1316
1316 glTexCoord2f(uv_rect.mLeft, uv_rect.mTop); 1317 gGL.texCoord2f(uv_rect.mLeft, uv_rect.mTop);
1317 glVertex2f(llfont_round_x(screen_rect.mLeft), 1318 gGL.vertex2f(llfont_round_x(screen_rect.mLeft),
1318 llfont_round_y(screen_rect.mTop)); 1319 llfont_round_y(screen_rect.mTop));
1319 1320
1320 glTexCoord2f(uv_rect.mLeft, uv_rect.mBottom); 1321 gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom);
1321 glVertex2f(llfont_round_x(screen_rect.mLeft + slant_amt), 1322 gGL.vertex2f(llfont_round_x(screen_rect.mLeft + slant_amt),
1322 llfont_round_y(screen_rect.mBottom)); 1323 llfont_round_y(screen_rect.mBottom));
1323 1324
1324 glTexCoord2f(uv_rect.mRight, uv_rect.mBottom); 1325 gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom);
1325 glVertex2f(llfont_round_x(screen_rect.mRight + slant_amt), 1326 gGL.vertex2f(llfont_round_x(screen_rect.mRight + slant_amt),
1326 llfont_round_y(screen_rect.mBottom)); 1327 llfont_round_y(screen_rect.mBottom));
1327} 1328}
1328 1329
@@ -1331,13 +1332,13 @@ void LLFontGL::drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, con
1331 F32 slant_offset; 1332 F32 slant_offset;
1332 slant_offset = ((style & ITALIC) ? ( -mAscender * 0.2f) : 0.f); 1333 slant_offset = ((style & ITALIC) ? ( -mAscender * 0.2f) : 0.f);
1333 1334
1334 glBegin(GL_QUADS); 1335 gGL.begin(GL_QUADS);
1335 { 1336 {
1336 //FIXME: bold and drop shadow are mutually exclusive only for convenience 1337 //FIXME: bold and drop shadow are mutually exclusive only for convenience
1337 //Allow both when we need them. 1338 //Allow both when we need them.
1338 if (style & BOLD) 1339 if (style & BOLD)
1339 { 1340 {
1340 glColor4fv(color.mV); 1341 gGL.color4fv(color.mV);
1341 for (S32 pass = 0; pass < 2; pass++) 1342 for (S32 pass = 0; pass < 2; pass++)
1342 { 1343 {
1343 LLRectf screen_rect_offset = screen_rect; 1344 LLRectf screen_rect_offset = screen_rect;
@@ -1350,7 +1351,7 @@ void LLFontGL::drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, con
1350 { 1351 {
1351 LLColor4 shadow_color = LLFontGL::sShadowColor; 1352 LLColor4 shadow_color = LLFontGL::sShadowColor;
1352 shadow_color.mV[VALPHA] = color.mV[VALPHA] * drop_shadow_strength * DROP_SHADOW_SOFT_STRENGTH; 1353 shadow_color.mV[VALPHA] = color.mV[VALPHA] * drop_shadow_strength * DROP_SHADOW_SOFT_STRENGTH;
1353 glColor4fv(shadow_color.mV); 1354 gGL.color4fv(shadow_color.mV);
1354 for (S32 pass = 0; pass < 5; pass++) 1355 for (S32 pass = 0; pass < 5; pass++)
1355 { 1356 {
1356 LLRectf screen_rect_offset = screen_rect; 1357 LLRectf screen_rect_offset = screen_rect;
@@ -1376,28 +1377,28 @@ void LLFontGL::drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, con
1376 1377
1377 renderQuad(screen_rect_offset, uv_rect, slant_offset); 1378 renderQuad(screen_rect_offset, uv_rect, slant_offset);
1378 } 1379 }
1379 glColor4fv(color.mV); 1380 gGL.color4fv(color.mV);
1380 renderQuad(screen_rect, uv_rect, slant_offset); 1381 renderQuad(screen_rect, uv_rect, slant_offset);
1381 } 1382 }
1382 else if (style & DROP_SHADOW) 1383 else if (style & DROP_SHADOW)
1383 { 1384 {
1384 LLColor4 shadow_color = LLFontGL::sShadowColor; 1385 LLColor4 shadow_color = LLFontGL::sShadowColor;
1385 shadow_color.mV[VALPHA] = color.mV[VALPHA] * drop_shadow_strength; 1386 shadow_color.mV[VALPHA] = color.mV[VALPHA] * drop_shadow_strength;
1386 glColor4fv(shadow_color.mV); 1387 gGL.color4fv(shadow_color.mV);
1387 LLRectf screen_rect_shadow = screen_rect; 1388 LLRectf screen_rect_shadow = screen_rect;
1388 screen_rect_shadow.translate(1.f, -1.f); 1389 screen_rect_shadow.translate(1.f, -1.f);
1389 renderQuad(screen_rect_shadow, uv_rect, slant_offset); 1390 renderQuad(screen_rect_shadow, uv_rect, slant_offset);
1390 glColor4fv(color.mV); 1391 gGL.color4fv(color.mV);
1391 renderQuad(screen_rect, uv_rect, slant_offset); 1392 renderQuad(screen_rect, uv_rect, slant_offset);
1392 } 1393 }
1393 else // normal rendering 1394 else // normal rendering
1394 { 1395 {
1395 glColor4fv(color.mV); 1396 gGL.color4fv(color.mV);
1396 renderQuad(screen_rect, uv_rect, slant_offset); 1397 renderQuad(screen_rect, uv_rect, slant_offset);
1397 } 1398 }
1398 1399
1399 } 1400 }
1400 glEnd(); 1401 gGL.end();
1401} 1402}
1402 1403
1403// static 1404// static