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
69 return maxHeight;69 return maxHeight;
70}70}
71 71
72int TextRenderer::draw(int x, int y, const char* str) {72int TextRenderer::draw(int x, int y, const char* str, float alpha) {
73 // Grab the current color73 // Grab the current color
74 float currentColor[4];74 float currentColor[4];
75 glGetFloatv(GL_CURRENT_COLOR, currentColor);75 glGetFloatv(GL_CURRENT_COLOR, currentColor);
76 int compactColor = ((int( currentColor[0] * 255.f) & 0xFF)) |76 alpha = std::max(0.f, std::min(alpha, 1.f));
77 ((int( currentColor[1] * 255.f) & 0xFF) << 8) |77 currentColor[3] *= alpha;
78 ((int( currentColor[2] * 255.f) & 0xFF) << 16) |78 int compactColor = ((int(currentColor[0] * 255.f) & 0xFF)) |
79 ((int( currentColor[3] * 255.f) & 0xFF) << 24);79 ((int(currentColor[1] * 255.f) & 0xFF) << 8) |
80 ((int(currentColor[2] * 255.f) & 0xFF) << 16) |
81 ((int(currentColor[3] * 255.f) & 0xFF) << 24);
80 82
81// TODO: Remove that code once we test for performance improvments83// TODO: Remove that code once we test for performance improvments
82 //glEnable(GL_TEXTURE_2D);84 //glEnable(GL_TEXTURE_2D);