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 5 of 5

Thread: Enabling blending clips texture ?

  1. #1

    Enabling blending clips texture ?

    I use the following to render a texture font to an fbo(which I later render to another fbo):

    Code :
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    ..
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(0f, width, height,0f, -1f, 1f);
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();
    glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);	
     
    glClear(GL_COLOR_BUFFER_BIT);  // (0f,0f,0f,0f)
     
    glDisable(GL_BLEND);
    glWrite(0f, i*16f, line);
    glEnable(GL_BLEND);
     
    glViewport( 0, 0, vPort[2], vPort[3]);
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
     
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    ..

    With the above code all the letters miss the right 4 pixels. The letters appear in full when gldisable is commented out. Why is this? (the letters are on the same pixels both ways)
    Thanks.

  2. #2

    Re: Enabling blending clips texture ?

    glWrite just needs an x, y and a line (char[]) and works like a charm everywhere except on that fbo when blending is disabled.

    glWrite is alike nehe's texture font write function.

    What could disabling blending do to make part of the letters(textures) not show up?

  3. #3

    Re: Enabling blending clips texture ?

    Why the 4 pixels still showed up is still a mystery to me, but here the solution:

    In stead of glDisable(GL_BLEND), using glBlendFunc(GL_ONE,GL_ONE) worked like a charm

    What does disabling blending exactly do? does set rendering to ignore the alpha channel?

  4. #4
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,370

    Re: Enabling blending clips texture ?

    When you disable blending, newly computed fragments color will replace the last fragments color stored in the framebuffer. When you enable blending, incoming fragments color can be blended with the fragment color that are already in the framebuffer using the operation set with glBlendFunc.

    Using GL_ONE as source and destination will add the incoming fragment color to the one already stored in the framebuffer. You may quickly obtain saturated renderings.

    If you use glBlendFunc(GL_ONE,GL_ZERO) it would behave as if blending is disabled.

  5. #5

    Re: Enabling blending clips texture ?

    Ok, this is how I thought it would work.
    Is there anything special in this regard when rendering to fbo-binded textures to other fbo's?

    glBlendFunc(GL_ONE,GL_ZERO);
    fbo.bind(); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    writeText("text");
    fbo.unbind();

    = clipped letters, (GL_ONE, GL_ONE) works correct...
    I must be doing something really stupid

Posting Permissions

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