Results 1 to 7 of 7

Thread: glFont / glBlendFunc help needed

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    5

    glFont / glBlendFunc help needed

    Hi, just got a problem with glFont.

    In my game i use glFont to display my text, but i originally had a problem that surrounding each letter was a black box. I used glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) to solve this.

    However this only works properly when i want to display my text in front of a 3D object. If i display the text in-front of my in-game interfaces (drawn in 2D ortho mode) the black boxes are removed, however so are sections of the interface where the black boxes would have been.

    i.e. it produces 'holes' in the interface and lets you see the through to the rest of the game world, where ideally i want my interface with the text on top.

    Thanks

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: glFont / glBlendFunc help needed

    Try to glDisable( GL_DEPTH_TEST ); when drawing your ingame interface. Don't forget to enable it back afterwards.

  3. #3
    Member Newbie
    Join Date
    Jun 2009
    Posts
    47

    Re: glFont / glBlendFunc help needed

    I have the exact same problem from using the code from
    http://nehe.gamedev.net/data/lessons....asp?lesson=17

    I guess there's no other solution than to calculate which one that is closer to the viewer the object or the text.

  4. #4
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    5

    Re: glFont / glBlendFunc help needed

    haha works perfectly now, thanks alot

  5. #5
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    5

    Re: glFont / glBlendFunc help needed

    Hi ColacX, the method that i've used is as follows:

    My basic game loop is:

    Draw my 3d game world in projection mode,
    Change to 2d - orthographic mode,
    then set:

    glClearColor(0.0,0.0,0.0,1.0);
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glDisable(GL_DEPTH_TEST);

    Draw my in-game interfaces,

    Draw my in-game text using the glFont method.

    Hope this helps.

  6. #6
    Member Newbie
    Join Date
    Jun 2009
    Posts
    47

    Re: glFont / glBlendFunc help needed

    What did you do with with your ingame 3D text?

    I dont have a 2D interface in mine i just want the 3D text to display properly.

    with depthtest enabled the text flickers
    with depthtest disabled the text gets drawn infront of other objects. i see no way to solve this unless i calculate which object is closest to me.

  7. #7
    Member Newbie
    Join Date
    Jun 2009
    Posts
    47

    Re: glFont / glBlendFunc help needed

    hmm an alpha textured font could work.

Similar Threads

  1. A glfont that is not Windows dependent
    By paradoxresolved in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 10-02-2011, 10:23 PM
  2. glBlendFunc help please....
    By Al Grant in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-17-2006, 10:29 PM
  3. glBlendFunc
    By HairyFotr in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 11-22-2003, 12:30 AM
  4. glfont
    By shalinigilra in forum OpenGL: Linux
    Replies: 1
    Last Post: 09-04-2001, 12:05 AM
  5. glBlendFunc?
    By Kondrat in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-28-2000, 04:26 AM

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