Results 1 to 4 of 4

Thread: Is this a blending problem?

  1. #1
    Guest

    Is this a blending problem?

    I have an texture and i want to write some
    text on it.But i cant set the text color.

    For example:

    if i have a blue texture and i try to write
    red text on it.But the color seems pink.Is this a blending problem ?

    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); /* X1

    glColor4ub(255,0,0,255);
    Font->Print(10,200,"PROBLEM");

    /*****************************************/

    glColor3f(1,1,1);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE);/* X2 I think this is the problem

    /* This is a blue texture
    glBindTexture(GL_TEXTURE_2D, gl->textures[1].texID);

    glBegin(GL_QUADS);
    glTexCoord2f(0, 0); glVertex3f(10, 200, 1.0f);
    glTexCoord2f(1, 0); glVertex3f(266,200, 1.0f);
    glTexCoord2f(1, 1); glVertex3f(266,232, 1.0f);
    glTexCoord2f(0, 1); glVertex3f(10,232, 1.0f);

    glEnd();

    İf so what is the suitable X2 function?
    Thanks...

  2. #2
    Junior Member Newbie
    Join Date
    Jul 2003
    Location
    Townsville, QLD, Australia
    Posts
    23

    Re: Is this a blending problem?

    make sure GL_TEXTURE_2D is enabled
    sounds silly i know, but i wasted about an hour debuging my code once after i ported existing font code over to a new program, and all it was, was the way i enabled GL_TEXTURE_2D was different in the 2 programs.

    If thats not your problem, try find a tutorial on using display lists to display fonts, i use display lists, and they make things a lot simpler.

    check http://nehe.gamedev.net/ or http://www.gametutorials.com/ their tutorials are very very helpful when starting out with opengl.

    good luck
    --Tristan

  3. #3
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,102

    Re: Is this a blending problem?

    I don't know what Font->Print does, but if you are blending a blue texture and red text together, it is logical that you get pink.

    If you want non-transparent red text, you have to render the backgroud first and then render the text with blend function GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA (or with alpha test).

  4. #4
    Guest

    Re: Is this a blending problem?

    When i render background first, my text disapper; but when i render text first then
    background texture, my text color seems pink.
    And i tried many variates of blend function
    but i didnt find the correct one.

    My last render code seems like this and my text invisible ;

    glEnable(GL_TEXTURE_2D);

    glColor3f(1,1,1);

    glBlendFunc(GL_ONE,GL_ONE);

    glBindTexture(GL_TEXTURE_2D, gl->textures[1].texID);

    glBegin(GL_QUADS);

    glTexCoord2f(0, 0); glVertex3f(10, 200, 1.0f);
    glTexCoord2f(1, 0); glVertex3f(266,200, 1.0f);
    glTexCoord2f(1, 1); glVertex3f(266,232, 1.0f);
    glTexCoord2f(0, 1); glVertex3f(10,232, 1.0f);

    glEnd();

    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glColor4ub(204,204,204,255);
    gl->p->Print(10,200," Problem ");


    glDisable(GL_TEXTURE_2D);


    So what is the solution?

Similar Threads

  1. Blending problem
    By imported_JoshKlint in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 07-06-2009, 09:39 AM
  2. Problem with blending
    By Ralph in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-04-2008, 03:22 AM
  3. blending problem
    By 0stress in forum OpenGL ES
    Replies: 3
    Last Post: 09-21-2006, 03:36 PM
  4. I problem with blending HELP ME PLEASE!
    By Dol AI with 3D Bone system in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 10-14-2004, 07:40 AM
  5. Blending problem
    By Imotiep in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-19-2001, 01:53 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