summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llhudnametag.cpp23
-rw-r--r--indra/newview/llhudnametag.h3
-rw-r--r--indra/newview/llhudrender.cpp13
-rw-r--r--indra/newview/llhudrender.h2
-rw-r--r--indra/newview/llhudtext.cpp16
-rw-r--r--indra/newview/llhudtext.h2
-rw-r--r--indra/newview/llmanip.cpp10
-rw-r--r--indra/newview/llmaniprotate.cpp4
-rw-r--r--indra/newview/llmanipscale.cpp4
-rw-r--r--indra/newview/llmaniptranslate.cpp4
10 files changed, 65 insertions, 16 deletions
diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp
index 8ad07efd1f..66130a2744 100644
--- a/indra/newview/llhudnametag.cpp
+++ b/indra/newview/llhudnametag.cpp
@@ -291,6 +291,15 @@ void LLHUDNameTag::renderText()
LLVector3 render_position = mPositionAgent
+ (x_pixel_vec * screen_offset.mV[VX])
+ (y_pixel_vec * screen_offset.mV[VY]);
+ bool reset_buffers = false;
+ const F32 treshold = 0.000001f;
+ if (abs(mLastRenderPosition.mV[VX] - render_position.mV[VX]) > treshold
+ || abs(mLastRenderPosition.mV[VY] - render_position.mV[VY]) > treshold
+ || abs(mLastRenderPosition.mV[VZ] - render_position.mV[VZ]) > treshold)
+ {
+ reset_buffers = true;
+ mLastRenderPosition = render_position;
+ }
LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
LLRect screen_rect;
@@ -314,6 +323,11 @@ void LLHUDNameTag::renderText()
for(std::vector<LLHUDTextSegment>::iterator segment_iter = mLabelSegments.begin();
segment_iter != mLabelSegments.end(); ++segment_iter )
{
+ if (reset_buffers)
+ {
+ segment_iter->mFontBufferLabel.reset();
+ }
+
// Label segments use default font
const LLFontGL* fontp = (segment_iter->mStyle == LLFontGL::BOLD) ? mBoldFontp : mFontp;
y_offset -= fontp->getLineHeight();
@@ -329,7 +343,7 @@ void LLHUDNameTag::renderText()
}
LLColor4 label_color(0.f, 0.f, 0.f, alpha_factor);
- hud_render_text(segment_iter->getText(), render_position, *fontp, segment_iter->mStyle, LLFontGL::NO_SHADOW, x_offset, y_offset, label_color, false);
+ hud_render_text(segment_iter->getText(), render_position, &segment_iter->mFontBufferLabel, *fontp, segment_iter->mStyle, LLFontGL::NO_SHADOW, x_offset, y_offset, label_color, false);
}
}
@@ -351,6 +365,11 @@ void LLHUDNameTag::renderText()
for (std::vector<LLHUDTextSegment>::iterator segment_iter = mTextSegments.begin() + start_segment;
segment_iter != mTextSegments.end(); ++segment_iter )
{
+ if (reset_buffers)
+ {
+ segment_iter->mFontBufferText.reset();
+ }
+
const LLFontGL* fontp = segment_iter->mFont;
y_offset -= fontp->getLineHeight();
y_offset -= LINE_PADDING;
@@ -374,7 +393,7 @@ void LLHUDNameTag::renderText()
text_color = segment_iter->mColor;
text_color.mV[VALPHA] *= alpha_factor;
- hud_render_text(segment_iter->getText(), render_position, *fontp, style, shadow, x_offset, y_offset, text_color, false);
+ hud_render_text(segment_iter->getText(), render_position, &segment_iter->mFontBufferText, *fontp, style, shadow, x_offset, y_offset, text_color, false);
}
}
/// Reset the default color to white. The renderer expects this to be the default.
diff --git a/indra/newview/llhudnametag.h b/indra/newview/llhudnametag.h
index ee66187345..b48a606982 100644
--- a/indra/newview/llhudnametag.h
+++ b/indra/newview/llhudnametag.h
@@ -68,6 +68,8 @@ protected:
LLColor4 mColor;
LLFontGL::StyleFlags mStyle;
const LLFontGL* mFont;
+ LLFontVertexBuffer mFontBufferLabel;
+ LLFontVertexBuffer mFontBufferText;
private:
LLWString mText;
std::map<const LLFontGL*, F32> mFontWidthMap;
@@ -175,6 +177,7 @@ private:
S32 mMaxLines;
S32 mOffsetY;
F32 mRadius;
+ LLVector3 mLastRenderPosition;
std::vector<LLHUDTextSegment> mTextSegments;
std::vector<LLHUDTextSegment> mLabelSegments;
// LLFrameTimer mResizeTimer;
diff --git a/indra/newview/llhudrender.cpp b/indra/newview/llhudrender.cpp
index 373b1a087f..2255eb236f 100644
--- a/indra/newview/llhudrender.cpp
+++ b/indra/newview/llhudrender.cpp
@@ -42,6 +42,7 @@
#include <glm/gtc/type_ptr.hpp>
void hud_render_utf8text(const std::string &str, const LLVector3 &pos_agent,
+ LLFontVertexBuffer *font_buffer,
const LLFontGL &font,
const U8 style,
const LLFontGL::ShadowType shadow,
@@ -50,10 +51,11 @@ void hud_render_utf8text(const std::string &str, const LLVector3 &pos_agent,
const bool orthographic)
{
LLWString wstr(utf8str_to_wstring(str));
- hud_render_text(wstr, pos_agent, font, style, shadow, x_offset, y_offset, color, orthographic);
+ hud_render_text(wstr, pos_agent, font_buffer, font, style, shadow, x_offset, y_offset, color, orthographic);
}
void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent,
+ LLFontVertexBuffer *font_buffer,
const LLFontGL &font,
const U8 style,
const LLFontGL::ShadowType shadow,
@@ -126,7 +128,14 @@ void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent,
LLUI::translate((F32) win_coord.x*1.0f/LLFontGL::sScaleX, (F32) win_coord.y*1.0f/(LLFontGL::sScaleY), -(((F32) win_coord.z*2.f)-1.f));
F32 right_x;
- font.render(wstr, 0, 0, 1, color, LLFontGL::LEFT, LLFontGL::BASELINE, style, shadow, static_cast<S32>(wstr.length()), 1000, &right_x, /*use_ellipses*/false, /*use_color*/true);
+ if (font_buffer)
+ {
+ font_buffer->render(&font, wstr, 0, 0, 1, color, LLFontGL::LEFT, LLFontGL::BASELINE, style, shadow, static_cast<S32>(wstr.length()), 1000, &right_x, /*use_ellipses*/false, /*use_color*/true);
+ }
+ else
+ {
+ font.render(wstr, 0, 0, 1, color, LLFontGL::LEFT, LLFontGL::BASELINE, style, shadow, static_cast<S32>(wstr.length()), 1000, &right_x, /*use_ellipses*/false, /*use_color*/true);
+ }
LLUI::popMatrix();
gGL.popMatrix();
diff --git a/indra/newview/llhudrender.h b/indra/newview/llhudrender.h
index 3c71acb271..be9fc7f084 100644
--- a/indra/newview/llhudrender.h
+++ b/indra/newview/llhudrender.h
@@ -36,6 +36,7 @@ class LLFontGL;
// Utility classes for rendering HUD elements
void hud_render_text(const LLWString &wstr,
const LLVector3 &pos_agent,
+ LLFontVertexBuffer *font_buffer,
const LLFontGL &font,
const U8 style,
const LLFontGL::ShadowType,
@@ -47,6 +48,7 @@ void hud_render_text(const LLWString &wstr,
// Legacy, slower
void hud_render_utf8text(const std::string &str,
const LLVector3 &pos_agent,
+ LLFontVertexBuffer *font_buffer,
const LLFontGL &font,
const U8 style,
const LLFontGL::ShadowType,
diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp
index fd0d8b696f..818474a0cb 100644
--- a/indra/newview/llhudtext.cpp
+++ b/indra/newview/llhudtext.cpp
@@ -185,6 +185,15 @@ void LLHUDText::renderText()
LLVector3 render_position = mPositionAgent
+ (x_pixel_vec * screen_offset.mV[VX])
+ (y_pixel_vec * screen_offset.mV[VY]);
+ bool reset_buffers = false;
+ const F32 treshold = 0.000001f;
+ if (abs(mLastRenderPosition.mV[VX] - render_position.mV[VX]) > treshold
+ || abs(mLastRenderPosition.mV[VY] - render_position.mV[VY]) > treshold
+ || abs(mLastRenderPosition.mV[VZ] - render_position.mV[VZ]) > treshold)
+ {
+ reset_buffers = true;
+ mLastRenderPosition = render_position;
+ }
F32 y_offset = (F32)mOffsetY;
@@ -208,6 +217,11 @@ void LLHUDText::renderText()
for (std::vector<LLHUDTextSegment>::iterator segment_iter = mTextSegments.begin() + start_segment;
segment_iter != mTextSegments.end(); ++segment_iter )
{
+ if (reset_buffers)
+ {
+ segment_iter->mFontBufferText.reset();
+ }
+
const LLFontGL* fontp = segment_iter->mFont;
y_offset -= fontp->getLineHeight() - 1; // correction factor to match legacy font metrics
@@ -231,7 +245,7 @@ void LLHUDText::renderText()
}
text_color.mV[VALPHA] *= alpha_factor;
- hud_render_text(segment_iter->getText(), render_position, *fontp, style, shadow, x_offset, y_offset, text_color, mOnHUDAttachment);
+ hud_render_text(segment_iter->getText(), render_position, &segment_iter->mFontBufferText, *fontp, style, shadow, x_offset, y_offset, text_color, mOnHUDAttachment);
}
}
/// Reset the default color to white. The renderer expects this to be the default.
diff --git a/indra/newview/llhudtext.h b/indra/newview/llhudtext.h
index 3bc33f1478..4c850e2d91 100644
--- a/indra/newview/llhudtext.h
+++ b/indra/newview/llhudtext.h
@@ -68,6 +68,7 @@ protected:
LLFontGL::StyleFlags mStyle;
const LLFontGL* mFont;
LLFontVertexBuffer mFontBuffer;
+ LLFontVertexBuffer mFontBufferText;
private:
LLWString mText;
std::map<const LLFontGL*, F32> mFontWidthMap;
@@ -153,6 +154,7 @@ private:
const LLFontGL* mBoldFontp;
LLRectf mSoftScreenRect;
LLVector3 mPositionAgent;
+ LLVector3 mLastRenderPosition;
LLVector2 mPositionOffset;
LLVector2 mTargetPositionOffset;
F32 mMass;
diff --git a/indra/newview/llmanip.cpp b/indra/newview/llmanip.cpp
index 3fdf7bd925..8bcfaa36e8 100644
--- a/indra/newview/llmanip.cpp
+++ b/indra/newview/llmanip.cpp
@@ -519,9 +519,9 @@ void LLManip::renderTickText(const LLVector3& pos, const std::string& text, cons
LLColor4 shadow_color = LLColor4::black;
shadow_color.mV[VALPHA] = color.mV[VALPHA] * 0.5f;
gViewerWindow->setup3DViewport(1, -1);
- hud_render_utf8text(text, render_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(text), 3.f, shadow_color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD);
+ hud_render_utf8text(text, render_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(text), 3.f, shadow_color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD);
gViewerWindow->setup3DViewport();
- hud_render_utf8text(text, render_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(text), 3.f, color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD);
+ hud_render_utf8text(text, render_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(text), 3.f, color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD);
gGL.popMatrix();
}
@@ -578,12 +578,12 @@ void LLManip::renderTickValue(const LLVector3& pos, F32 value, const std::string
{
fraction_string = llformat("%c%02d%s", LLResMgr::getInstance()->getDecimalPoint(), fractional_portion, suffix.c_str());
- hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW, -1.f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection);
- hud_render_utf8text(fraction_string, render_pos, *small_fontp, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW, 1.f, 3.f, color, hud_selection);
+ hud_render_utf8text(val_string, render_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW, -1.f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection);
+ hud_render_utf8text(fraction_string, render_pos, nullptr, *small_fontp, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW, 1.f, 3.f, color, hud_selection);
}
else
{
- hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW, -0.5f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection);
+ hud_render_utf8text(val_string, render_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW, -0.5f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection);
}
}
gGL.popMatrix();
diff --git a/indra/newview/llmaniprotate.cpp b/indra/newview/llmaniprotate.cpp
index 5bdf3f81b5..0d80b8d8ba 100644
--- a/indra/newview/llmaniprotate.cpp
+++ b/indra/newview/llmaniprotate.cpp
@@ -1169,10 +1169,10 @@ void LLManipRotate::renderSnapGuides()
std::string help_text = LLTrans::getString("manip_hint1");
LLColor4 help_text_color = LLColor4::white;
help_text_color.mV[VALPHA] = clamp_rescale(mHelpTextTimer.getElapsedTimeF32(), sHelpTextVisibleTime, sHelpTextVisibleTime + sHelpTextFadeTime, line_alpha, 0.f);
- hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false);
+ hud_render_utf8text(help_text, help_text_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false);
help_text = LLTrans::getString("manip_hint2");
help_text_pos -= offset_dir * mRadiusMeters * 0.4f;
- hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false);
+ hud_render_utf8text(help_text, help_text_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false);
}
}
}
diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp
index 66420d1cad..9966a8eedb 100644
--- a/indra/newview/llmanipscale.cpp
+++ b/indra/newview/llmanipscale.cpp
@@ -1844,10 +1844,10 @@ void LLManipScale::renderSnapGuides(const LLBBox& bbox)
std::string help_text = LLTrans::getString("manip_hint1");
LLColor4 help_text_color = LLColor4::white;
help_text_color.mV[VALPHA] = clamp_rescale(mHelpTextTimer.getElapsedTimeF32(), sHelpTextVisibleTime, sHelpTextVisibleTime + sHelpTextFadeTime, grid_alpha, 0.f);
- hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false);
+ hud_render_utf8text(help_text, help_text_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false);
help_text = LLTrans::getString("manip_hint2");
help_text_pos -= LLViewerCamera::getInstance()->getUpAxis() * mSnapRegimeOffset * 0.4f;
- hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false);
+ hud_render_utf8text(help_text, help_text_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false);
}
}
}
diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp
index 0888f630e8..060fe0d600 100644
--- a/indra/newview/llmaniptranslate.cpp
+++ b/indra/newview/llmaniptranslate.cpp
@@ -1449,10 +1449,10 @@ void LLManipTranslate::renderSnapGuides()
std::string help_text = LLTrans::getString("manip_hint1");
LLColor4 help_text_color = LLColor4::white;
help_text_color.mV[VALPHA] = clamp_rescale(mHelpTextTimer.getElapsedTimeF32(), sHelpTextVisibleTime, sHelpTextVisibleTime + sHelpTextFadeTime, line_alpha, 0.f);
- hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false);
+ hud_render_utf8text(help_text, help_text_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false);
help_text = LLTrans::getString("manip_hint2");
help_text_pos -= LLViewerCamera::getInstance()->getUpAxis() * mSnapOffsetMeters * 0.2f;
- hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false);
+ hud_render_utf8text(help_text, help_text_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false);
}
}
}