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: Transparency

  1. #1
    Intern Newbie
    Join Date
    May 2001
    Location
    Montreal, Canada
    Posts
    32

    Transparency

    Hi

    I was wondering how can I use transparency with OpenGL. Because I am fairly new to OpenGL and want to make a 2d tile based game. So the maps used will be multilayered and the 2nd layer, 3rd layer and so on should not show the black ( or any other color around them. for example suppose its a tree and the background is euh.. background is Pink. So all the pixel that are pink shouldn't be seen. it should use the color already present at that location ) I used to use Allegro but now i am using OpenGL; I am not sure if blending will do the trick...

    [This message has been edited by Akash (edited 08-08-2001).]

  2. #2
    Intern Newbie
    Join Date
    May 2001
    Location
    Montreal, Canada
    Posts
    32

    Re: Transparency

    I forgot to mention that I draw a texture mapped quad for the tiles.

  3. #3
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,609

    Re: Transparency

    what u need to do is add an alpha channel to your texture either in a painting program eg gimp or alternatively when u laod the image for each pixel check to see if the colour of it is black if so make the alpha of that pixel 0 else make it 1 then use
    glEnable( GL_ALPHA_TEST )
    glAlphaFunc( GL_NOTEQUAL, 0 );

  4. #4
    Junior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    Aurora, Illinois, USA
    Posts
    217

    Re: Transparency

    hey akash...

    zed is right... to clarify he means something like this as his second solution:

    Code :
    for (0 to numpixels)
    {
      if (pixe.color==pink)
        pixel.alpha=0;
      else 
        pixel.alpha=1;
    }
    you'll need to do some setting up before you can use blending in OpenGL.

    Good luck yaar.

    If you have any questions e-mail me at ngill@imsa.edu

    [This message has been edited by ngill (edited 08-10-2001).]
    Navreet Gill [img]/forum/images/%%GRAEMLIN_URL%%/smile.gif[/img]

  5. #5
    Intern Newbie
    Join Date
    May 2001
    Location
    Montreal, Canada
    Posts
    32

    Re: Transparency

    Thx a lot guys; i think i know what your trying to say. I will try if not i'll post another msg... laterz

Posting Permissions

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