Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Sprites and transparency in OpenGL...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Terran Marine   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 July 2001 - 12:43 AM

Hi, Can anyone explain to me how to go about billboarding in OpenGL? The openGL User''s Guide says to use AlphaFunc(), but my images are 24-bits and don''t contain any alpha values. Thanks in advance.

Sponsor:

#2 mittens   Moderators   -  Reputation: 1315

Like
Likes
Like

Posted 29 July 2001 - 04:16 AM

change the blending function to glBlendFunc(GL_SRC_ALPHA, GL_ONE); and enable blending when
you draw the sprite... Of course, it makes the sprite more transparent all over which is rather annoying
I figured this out the hard way the other day... Alpha channels are a really nice thing to have in
your sprites.

------------------------------
Trent (ShiningKnight)
E-mail me
OpenGL Game Programming Tutorials

#3 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 29 July 2001 - 10:27 AM

alphafunc has nothing to do with billboarding. billboard is when u make a polygon face the screen, i believe theres a recent thread in nehe that has a bt of info about possible methods

#4 Terran Marine   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 July 2001 - 05:07 PM

Thanks for the info.
What texture format would you recommend? I need one that contains an alpha channel.

#5 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 29 July 2001 - 05:28 PM

tga is easy to load
png is difficult to load (use a library) but handles all formats and does good lossless compression

#6 merlin9x9   Members   -  Reputation: 174

Like
Likes
Like

Posted 29 July 2001 - 05:35 PM

It depends. If you have multiple levels of transparency in that alpha channel, you''ll need GL_RGBA (or something specific like GL_RGBA8). You might also be able to get away with a format like GL_RGB5_A1 (if you do this, chances are that the display adapter will store that texture in its native format, which would probably be GL_RGBA8) So, again, it depends on the image.

If you want to use the standard sort of sprites where a certain color value represents transparency, you can create the alpha channel at runtime. In the function you use to load images into a buffer (right before using that buffer to make a texture), analyze the RGB value to determine if it is. If so, make the alpha value 0, otherwise, make it 255 (assuming that you''re using an 8-bit byte per component). Then make the texture as in the paragraph above.

To make the alpha channel useful, you have to enable blending and use some blending such as glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) (that''s how I''ve always done it, though GL_SRC_ALPHA, GL_ONE might work as well).

So, then you have to draw the billboard. Since it needs to face the camera always, you just use the camera''s angle to determine the angle necessary to make the billboard parallel to it. Then just draw the billboard using the sprite texture and blending mode.

#7 Terran Marine   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 July 2001 - 06:57 PM

I think I''ll go with TGA. Thanks for the help.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS