Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: blending with fonts

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2003
    Posts
    11

    blending with fonts

    I have a environment that's drawn, i want a 50% rect partially above it and then i want text drawn above it, the thing is that i seem not to be able to get my color anymore, what glBlendFunc options should be passed and do i put the glColor before or after that call?

    /* draw polygons */
    ...
    /* draw translucent polygon */
    glColor4b(127,127,127,50);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    glBegin(GL_TRIANGLE_STRIP);
    glVertex3f(4,15,1);
    glVertex3f(4,477,1);
    glVertex3f(635,15,1);
    glVertex3f(635,477,1);
    glEnd();
    /* drawing text */
    glBlendFunc(GL_ONE,GL_ZERO);
    glDisable(GL_BLEND);
    glColor4b(-100, 127, -108, 127); /* make everything appear in Green */
    ...

    since i enabled blending, the font appears in black instead of the green color i selected
    --
    Alien is my name and head-biting is my game.

  2. #2
    Guest

    Re: blending with fonts

    if you want to alpha blend the text you need to keep blending enabled. but this wouldn't make your text black - post the text drawing code.

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2003
    Posts
    11

    Re: blending with fonts

    the text itself does not need alpha blending, i have fixed it, it appeared that if lighting was enabled when drawing the text, that it appeared black.

    the current code is now this:

    if(!gGLX->pausetext)
    {
    /* try drawing a square with transparent background */
    glEnable(GL_LIGHTING);
    glColor4b(127,127,127,63);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    glBegin(GL_TRIANGLE_STRIP);
    glVertex3f(4,15,1);
    glVertex3f(4,477,1);
    glVertex3f(635,15,1);
    glVertex3f(635,477,1);
    glEnd();
    glBlendFunc(GL_ONE,GL_ZERO);
    glDisable(GL_BLEND);
    glDisable(GL_LIGHTING);
    }
    /* drawing hud_text */
    glColor4b(-100, 127, -108, -128); /* make everything appear in Green */
    --
    Alien is my name and head-biting is my game.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •