History

Make text overlays apply alpha to text as well as background

David Rowe committed 12 years ago

Commit 8ac3aba1 parent d9141b45 files · +12 −9Browse files

Showing the changes to interface/src/ui/TextRenderer.cpp (1 of 5 files). Show all

Unified · Split

interface/src/ui/TextRenderer.cpp+7−5
@@ -69,14 +69,16 @@ int TextRenderer::calculateHeight(const char* str) { · 68 unmodified lines
6969 return maxHeight;
7070 }
7171
72−int TextRenderer::draw(int x, int y, const char* str) {
72+int TextRenderer::draw(int x, int y, const char* str, float alpha) {
7373 // Grab the current color
7474 float currentColor[4];
7575 glGetFloatv(GL_CURRENT_COLOR, currentColor);
76− int compactColor = ((int( currentColor[0] * 255.f) & 0xFF)) |
77− ((int( currentColor[1] * 255.f) & 0xFF) << 8) |
78− ((int( currentColor[2] * 255.f) & 0xFF) << 16) |
79− ((int( currentColor[3] * 255.f) & 0xFF) << 24);
76+ alpha = std::max(0.f, std::min(alpha, 1.f));
77+ currentColor[3] *= alpha;
78+ int compactColor = ((int(currentColor[0] * 255.f) & 0xFF)) |
79+ ((int(currentColor[1] * 255.f) & 0xFF) << 8) |
80+ ((int(currentColor[2] * 255.f) & 0xFF) << 16) |
81+ ((int(currentColor[3] * 255.f) & 0xFF) << 24);
8082
8183 // TODO: Remove that code once we test for performance improvments
8284 //glEnable(GL_TEXTURE_2D);