mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
remove glColor calls related to text rendering
This commit is contained in:
parent
7d9de6d0eb
commit
2f4e98082b
10 changed files with 24 additions and 46 deletions
|
@ -107,12 +107,12 @@ void drawText(int x, int y, float scale, float radians, int mono,
|
|||
glPushMatrix();
|
||||
glTranslatef(static_cast<float>(x), static_cast<float>(y), 0.0f);
|
||||
|
||||
// TODO: add support for color to rendering text
|
||||
glColor3fv(color);
|
||||
|
||||
glRotated(double(radians * DEGREES_PER_RADIAN), 0.0, 0.0, 1.0);
|
||||
glScalef(scale / 0.1f, scale / 0.1f, 1.0f);
|
||||
textRenderer(mono)->draw(0, 0, string);
|
||||
|
||||
glm::vec4 colorV4 = {color[0], color[1], color[3], 1.0f };
|
||||
textRenderer(mono)->draw(0, 0, string, colorV4);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,8 +57,6 @@ void AudioIOStatsRenderer::render(const float* color, int width, int height) {
|
|||
int h = statsHeight;
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(x, y, w, h, backgroundColor);
|
||||
|
||||
glColor4f(1, 1, 1, 1); // TODO: change text rendering to use collor as parameter
|
||||
|
||||
int horizontalOffset = x + 5;
|
||||
int verticalOffset = y;
|
||||
|
||||
|
|
|
@ -703,12 +703,12 @@ void Avatar::renderDisplayName() {
|
|||
DependencyManager::get<GeometryCache>()->renderBevelCornersRect(left, bottom, right - left, top - bottom, 3,
|
||||
glm::vec4(0.2f, 0.2f, 0.2f, _displayNameAlpha * DISPLAYNAME_BACKGROUND_ALPHA / DISPLAYNAME_ALPHA));
|
||||
|
||||
glColor4f(0.93f, 0.93f, 0.93f, _displayNameAlpha); // TODO: change text rendering to use collor as parameter
|
||||
glm::vec4 color(0.93f, 0.93f, 0.93f, _displayNameAlpha);
|
||||
QByteArray ba = _displayName.toLocal8Bit();
|
||||
const char* text = ba.data();
|
||||
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
textRenderer(DISPLAYNAME)->draw(text_x, text_y, text);
|
||||
textRenderer(DISPLAYNAME)->draw(text_x, text_y, text, color);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
|
|
|
@ -86,15 +86,6 @@ void BandwidthMeter::Stream::updateValue(double amount) {
|
|||
glm::clamp(dt / _msToAverage, 0.0, 1.0));
|
||||
}
|
||||
|
||||
void BandwidthMeter::setColorRGBA(unsigned c) {
|
||||
|
||||
// TODO: add support for color to rendering text, since that's why this method is used
|
||||
glColor4ub(GLubyte( c >> 24),
|
||||
GLubyte((c >> 16) & 0xff),
|
||||
GLubyte((c >> 8) & 0xff),
|
||||
GLubyte( c & 0xff));
|
||||
}
|
||||
|
||||
glm::vec4 BandwidthMeter::getColorRGBA(unsigned c) {
|
||||
|
||||
float r = (c >> 24) / 255.0f;
|
||||
|
@ -165,10 +156,10 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) {
|
|||
glTranslatef((float)barX, (float)y, 0.0f);
|
||||
|
||||
// Render captions
|
||||
setColorRGBA(COLOR_TEXT);
|
||||
_textRenderer->draw(barWidth + SPACING_LEFT_CAPTION_UNIT, textYcenteredLine, CAPTION_UNIT);
|
||||
_textRenderer->draw(-labelWidthIn - SPACING_RIGHT_CAPTION_IN_OUT, textYupperLine, CAPTION_IN);
|
||||
_textRenderer->draw(-labelWidthOut - SPACING_RIGHT_CAPTION_IN_OUT, textYlowerLine, CAPTION_OUT);
|
||||
glm::vec4 textColor = getColorRGBA(COLOR_TEXT);
|
||||
_textRenderer->draw(barWidth + SPACING_LEFT_CAPTION_UNIT, textYcenteredLine, CAPTION_UNIT, textColor);
|
||||
_textRenderer->draw(-labelWidthIn - SPACING_RIGHT_CAPTION_IN_OUT, textYupperLine, CAPTION_IN, textColor);
|
||||
_textRenderer->draw(-labelWidthOut - SPACING_RIGHT_CAPTION_IN_OUT, textYlowerLine, CAPTION_OUT, textColor);
|
||||
|
||||
// Render vertical lines for the frame
|
||||
renderVerticalLine(0, 0, h, COLOR_FRAME);
|
||||
|
@ -226,15 +217,14 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) {
|
|||
|
||||
// Render numbers
|
||||
char fmtBuf[8];
|
||||
setColorRGBA(COLOR_TEXT);
|
||||
sprintf(fmtBuf, "%0.1f", totalIn);
|
||||
_textRenderer->draw(glm::max(xIn - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE,
|
||||
PADDING_HORIZ_VALUE),
|
||||
textYupperLine, fmtBuf);
|
||||
textYupperLine, fmtBuf, textColor);
|
||||
sprintf(fmtBuf, "%0.1f", totalOut);
|
||||
_textRenderer->draw(glm::max(xOut - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE,
|
||||
PADDING_HORIZ_VALUE),
|
||||
textYlowerLine, fmtBuf);
|
||||
textYlowerLine, fmtBuf, textColor);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
|
|
|
@ -69,7 +69,6 @@ public:
|
|||
ChannelInfo const& channelInfo(ChannelIndex i) const { return _channels[i]; }
|
||||
|
||||
private:
|
||||
static void setColorRGBA(unsigned c);
|
||||
static glm::vec4 getColorRGBA(unsigned c);
|
||||
static void renderBox(int x, int y, int w, int h, unsigned c);
|
||||
static void renderVerticalLine(int x, int y, int h, unsigned c);
|
||||
|
|
|
@ -124,13 +124,11 @@ void Text3DOverlay::render(RenderArgs* args) {
|
|||
enableClipPlane(GL_CLIP_PLANE2, 0.0f, -1.0f, 0.0f, clipMinimum.y + clipDimensions.y);
|
||||
enableClipPlane(GL_CLIP_PLANE3, 0.0f, 1.0f, 0.0f, -clipMinimum.y);
|
||||
|
||||
// TODO: add support for color to rendering text
|
||||
glColor3f(_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR);
|
||||
float alpha = getAlpha();
|
||||
glm::vec4 textColor = {_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR, getAlpha() };
|
||||
QStringList lines = _text.split("\n");
|
||||
int lineOffset = maxHeight;
|
||||
foreach(QString thisLine, lines) {
|
||||
textRenderer->draw(0, lineOffset, qPrintable(thisLine), alpha);
|
||||
textRenderer->draw(0, lineOffset, qPrintable(thisLine), textColor);
|
||||
lineOffset += maxHeight;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,16 +90,15 @@ void TextOverlay::render(RenderArgs* args) {
|
|||
int x = _bounds.left() + _leftMargin + leftAdjust;
|
||||
int y = _bounds.top() + _topMargin + topAdjust;
|
||||
|
||||
// TODO: add support for color to rendering text
|
||||
glColor3f(_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR);
|
||||
float alpha = getAlpha();
|
||||
glm::vec4 textColor = {_color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR, alpha };
|
||||
QStringList lines = _text.split("\n");
|
||||
int lineOffset = 0;
|
||||
foreach(QString thisLine, lines) {
|
||||
if (lineOffset == 0) {
|
||||
lineOffset = textRenderer->calculateHeight(qPrintable(thisLine));
|
||||
}
|
||||
lineOffset += textRenderer->draw(x, y + lineOffset, qPrintable(thisLine), alpha);
|
||||
lineOffset += textRenderer->draw(x, y + lineOffset, qPrintable(thisLine), textColor);
|
||||
|
||||
const int lineGap = 2;
|
||||
lineOffset += lineGap;
|
||||
|
|
|
@ -78,13 +78,11 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
|
|||
enableClipPlane(GL_CLIP_PLANE3, 0.0f, 1.0f, 0.0f, -clipMinimum.y);
|
||||
|
||||
xColor textColor = getTextColorX();
|
||||
// TODO: add support for color to rendering text
|
||||
glColor3f(textColor.red / MAX_COLOR, textColor.green / MAX_COLOR, textColor.blue / MAX_COLOR);
|
||||
glm::vec4 textColorV4(textColor.red / MAX_COLOR, textColor.green / MAX_COLOR, textColor.blue / MAX_COLOR, 1.0f);
|
||||
QStringList lines = _text.split("\n");
|
||||
int lineOffset = maxHeight;
|
||||
float textAlpha = 1.0f; // getTextAlpha()
|
||||
foreach(QString thisLine, lines) {
|
||||
textRenderer->draw(0, lineOffset, qPrintable(thisLine), textAlpha);
|
||||
textRenderer->draw(0, lineOffset, qPrintable(thisLine), textColorV4);
|
||||
lineOffset += maxHeight;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,16 +70,11 @@ int TextRenderer::calculateHeight(const char* str) {
|
|||
return maxHeight;
|
||||
}
|
||||
|
||||
int TextRenderer::draw(int x, int y, const char* str, float alpha) {
|
||||
// Grab the current color
|
||||
float currentColor[4];
|
||||
glGetFloatv(GL_CURRENT_COLOR, currentColor);
|
||||
alpha = std::max(0.0f, std::min(alpha, 1.0f));
|
||||
currentColor[3] *= alpha;
|
||||
int compactColor = ((int(currentColor[0] * 255.0f) & 0xFF)) |
|
||||
((int(currentColor[1] * 255.0f) & 0xFF) << 8) |
|
||||
((int(currentColor[2] * 255.0f) & 0xFF) << 16) |
|
||||
((int(currentColor[3] * 255.0f) & 0xFF) << 24);
|
||||
int TextRenderer::draw(int x, int y, const char* str, const glm::vec4& color) {
|
||||
int compactColor = ((int(color.x * 255.0f) & 0xFF)) |
|
||||
((int(color.y * 255.0f) & 0xFF) << 8) |
|
||||
((int(color.z * 255.0f) & 0xFF) << 16) |
|
||||
((int(color.w * 255.0f) & 0xFF) << 24);
|
||||
|
||||
int maxHeight = 0;
|
||||
for (const char* ch = str; *ch != 0; ch++) {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define hifi_TextRenderer_h
|
||||
|
||||
#include <gpu/GPUConfig.h>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <QColor>
|
||||
#include <QFont>
|
||||
|
@ -70,7 +71,7 @@ public:
|
|||
int calculateHeight(const char* str);
|
||||
|
||||
// also returns the height of the tallest character
|
||||
int draw(int x, int y, const char* str, float alpha = 1.0f);
|
||||
int draw(int x, int y, const char* str, const glm::vec4& color);
|
||||
|
||||
int computeWidth(char ch);
|
||||
int computeWidth(const char* str);
|
||||
|
|
Loading…
Reference in a new issue