Results 1 to 7 of 7

Thread: transparency

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2001
    Posts
    17

    transparency

    I've only messed with OpenGL a little. I use it with C++ and Glut. Forgive me if this seems too novice. How do I make a polygon transparent? Yes, it has to do with the alpha values, but how do I use it?

    Lets say I have a simple triangle in front of a quad. I use float values for the color. What do I do to see the quad through the triangle? What do I need to enable? I'm trying to keep this case very simple so as to keep the answer simple.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: transparency

    Use this color function before the object.

    glColor4f(r, g, b, a)

    alpha channel set's transparency

    t = 0.0 to 1.0.
    1.0 = non-transparent
    0.5 = 50% transparent
    0.0 = transparent

    Originally posted by drummerboy_2002:
    I've only messed with OpenGL a little. I use it with C++ and Glut. Forgive me if this seems too novice. How do I make a polygon transparent? Yes, it has to do with the alpha values, but how do I use it?

    Lets say I have a simple triangle in front of a quad. I use float values for the color. What do I do to see the quad through the triangle? What do I need to enable? I'm trying to keep this case very simple so as to keep the answer simple.

  3. #3
    Senior Member Regular Contributor
    Join Date
    May 2000
    Location
    Oxford, England
    Posts
    472

    Re: transparency

    Originally posted by nexusone:
    Use this color function before the object.

    glColor4f(r, g, b, a)

    alpha channel set's transparency

    t = 0.0 to 1.0.
    1.0 = non-transparent
    0.5 = 50% transparent
    0.0 = transparent

    Although you might want to enable alpha blending for that to work.....

    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);

  4. #4
    Senior Member Regular Contributor
    Join Date
    Feb 2002
    Posts
    374

    Re: transparency

    And you have to draw your promitives in back to front order.

  5. #5
    Junior Member Newbie
    Join Date
    Oct 2001
    Posts
    17

    Re: transparency

    Cool, thanks guys.

  6. #6
    Guest

    Re: transparency

    how to draw a polygon??

  7. #7
    Senior Member Regular Contributor
    Join Date
    Feb 2002
    Posts
    374

    Re: transparency

    Originally posted by sim3:
    how to draw a polygon??
    Choosing GL_POLYGON as primitive.
    And then the standard: glBegin/glEnd, DL, VA, CVA, VAR, VAO (just what you want and what is supported by your hardware)

Similar Threads

  1. NSOpenGLView visual transparency vs. mouse transparency
    By hidefromkgb in forum OpenGL: macOS
    Replies: 1
    Last Post: 05-12-2015, 01:05 PM
  2. transparency!
    By thasadams in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 05-27-2003, 05:54 AM
  3. Transparency
    By in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 07-29-2002, 06:12 AM
  4. OpenGL window transparency and texture transparency
    By ramalhais in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-15-2002, 09:37 AM
  5. Transparency
    By in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 07-05-2001, 06:03 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