Results 1 to 4 of 4

Thread: blending for a transparent window, but text refuses to be bright

  1. #1
    Senior Member Regular Contributor
    Join Date
    Oct 2002
    Location
    San Diego, CA, USA
    Posts
    209

    blending for a transparent window, but text refuses to be bright

    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?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Fort Collins, Colorado
    Posts
    446

    Re: blending for a transparent window, but text refuses to be bright

    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.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Oct 2002
    Location
    San Diego, CA, USA
    Posts
    209

    Re: blending for a transparent window, but text refuses to be bright

    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).]

  4. #4
    Senior Member Regular Contributor
    Join Date
    Oct 2002
    Location
    San Diego, CA, USA
    Posts
    209

    Re: blending for a transparent window, but text refuses to be bright

    figured it out... I didnt disable texturing before rendering my windows. Doh!

Similar Threads

  1. Transparent 3d Text mapped onto a polygon
    By bigefrom84 in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 11-12-2013, 12:41 PM
  2. Transparent objects - Blending
    By Puma1140 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-23-2003, 09:29 AM
  3. Semi-transparent blending?
    By von in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-29-2003, 06:45 PM
  4. overlay a semi-transparent window on an OpenGL window
    By Coconut in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 02-17-2002, 07:01 AM
  5. Blending Opaque and transparent objects
    By dhiraj in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 08-30-2000, 12:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean