PDA

View Full Version : blending for a transparent window, but text refuses to be bright



147-2
10-29-2002, 10:38 AM
I am creating a windowing system for my game which I want to be transparent, sorta like a "pane of smoked glass" effect. When I draw text to it, I want that text to be bright green, but I cant seem to get it to depart from being muddy looking. I have tried a handful of different blending functions, but none of them make my green look bright. Since this is a space game, non bright text in a window will wash out with the background. I have tried a lot, even not blending the text, and it still appears muddy. I have lighting disabled, so I imagine lighting will not affect the text.

Any ideas as to how I can make bright text?

yakuza
10-29-2002, 06:26 PM
Well, since you don't mention the blending functions you've tried, I'll just tell you what I do to draw text.

I draw the text last, in Ortho mode.
Disable lighting
disable depth test
enable blending (GL_SRC_ALPHA, GL_ONE)

Hope that helps, otherwise post a screenshot or give us some more info.

147-2
10-29-2002, 07:05 PM
Well, here's the code I have been using....


void Window::Render()
{

if(isactive())
SetColor(.035, .25, .1250); // a tingier green than before...
else
SetColor(0.075, .125, .1250); // light blue, with a tinge of green.

glTranslated(0.0, 0.0, 0.001);
glRectf(xpos, ypos, xpos+width, ypos+height);
glTranslated(0.0, 0.0, -0.001);

for(int x(0); x < components.size(); x++)
components[x]->Render();
};

void FPSwindow::Render()
{
Window::Render();

float fps = 1000.0/clock->GetElapsed();
// glColor4d(0.85, 1.0, 0.85, 1.0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glColor3d(1.0, 1.0, 1.0);
font->glDrawText(xpos + 5, ypos - 5, "FPS: %f\n", fps);
};

void WindowManager::Render()
{
glDisable(GL_LIGHTING);

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0f, size, size * height/width, 0.0f, 1.0f, -1.0f);

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
for(int x(0); x < components.size(); x++)
components[x]->Render();
glDisable(GL_BLEND);

glMatrixMode(GL_PROJECTION);
glPopMatrix();

glMatrixMode(GL_MODELVIEW);
glPopMatrix();

glColor4d(1.0, 1.0, 1.0, 1.0);
glEnable(GL_LIGHTING);
};

That (now) shows the text somewhat brighter and the same color as the background. It isnt turning out as a bright green at all. I have tried many blending modes, and I have also tried pulling the text out of the blending functions altogether, but nothing seems to work correctly. Something else odd, I was having trouble getting text to display on the screen, but when I instantiated a second set of fonts, the first worked just fine. Whenever I remove the second font, the first stops showing up on the screen. Im blindly guessing these two problems are interrelated. Im gonna print out my code tomorrow, and go thru it with a fine toothed comb... maybe something'll turn up.

[This message has been edited by 147-2 (edited 10-29-2002).]

147-2
11-03-2002, 09:04 AM
figured it out... I didnt disable texturing before rendering my windows. Doh!