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

Thread: Using alpha values

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2003
    Posts
    4

    Using alpha values

    How can I create a polygon that is semi transparent? I know that you can use glColor4f and that the last parameter is the alpha value with 1.0 being totally "solid." I have tried using this function but it isn't working. What else to I need to include to get the alpha values to work properly? Thanks!

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,797

    Re: Using alpha values

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    Deiussum
    Software Engineer and OpenGL enthusiast

  3. #3
    Junior Member Regular Contributor
    Join Date
    Dec 2000
    Location
    USA
    Posts
    223

    Re: Using alpha values

    You can also put alpha channel in your texture then use DECAL env. mode. The texture color will get multiplied with texture alpha.

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2003
    Posts
    4

    Re: Using alpha values

    That helped, but now if I put in a value of say 0.3 for alpha, I have a flashing polygon instead of just a polygon that is 0.3 transparent. How do you get the flashing to stop?

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,797

    Re: Using alpha values

    You may be seeing z-buffer fighting. What do you use for your near and far clip planes? If the difference is too big, your z-buffer might not be able to differentiate between 2 polygons that are close to each other.
    Deiussum
    Software Engineer and OpenGL enthusiast

  6. #6
    Intern Contributor
    Join Date
    Apr 2003
    Posts
    61

    Re: Using alpha values

    Quick question does z-fighting occur gluOrtho2D projections?

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,797

    Re: Using alpha values

    Yes, it can. If for instance the difference between your near and far clip plane is 1,000,000,000 and you only have a z-buffer with 16-bits of precision, you are going to see a lot of z-fighting because a 16-bit number can only store 65,536 different values.
    Deiussum
    Software Engineer and OpenGL enthusiast

Posting Permissions

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