Advertisement

TGA transparent background

Started by September 30, 2005 09:32 AM
5 comments, last by CrashStar 19 years, 2 months ago
How to do it? I managed to load TGA in my game and everything is working fine, but i cant get tga background transparent :/ Im using 32bit TGAs. Can anyone help me pls?
There could be a few reasons it isn't working, try these things:

  • Does your Targa definitely have an alpha channel?
  • Have you enabled blending with
    glEnable(GL_BLEND);
    ?
  • Have you set up a blend mode? The typical blending function is
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

  • When you load your images into OpenGL are you using RGBA and specifying four colour components in your call to glTexImage2D or gluBuild2DMipmaps? For example:
    glTexImage2D(GL_TEXTURE_2D, 0, 4, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pointer_to_data);orgluBuild2DMipmaps(GL_TEXTURE_2D, 4, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pointer_to_data);


Hope one of these fixes it, if not then post back here with some code. :)
--
Cheers,
Darren Clark
Advertisement
thx man, i forgot to setup blend mode :/

im newb in this so :) ty once more m8 :) :)
Not a problem at all. We were all newbies once and we all still make stupid mistakes. :)
--
Cheers,
Darren Clark
ok some more questions :)



how much pixels is 1.00f in opengl ?
It can be pretty much any amount, it depends on how far away from the camera you are, assuming a perspective projection that is. As an example, take your finger, let's say it's 20mm wide, now hold it as far away from your face as possible, it looks a lot smaller doesn't it? Now hold it right in front of your face, it looks a lot bigger. This is the problem, OpenGL will render your scene and it is totally dependent on where you are looking from as to how many pixels are occupied by an object.

You can use an orthographic projection to 'negate' depth but all that means is that all objects appear at the same scale regardless of depth. A common use of this is to render a 2D overlay, like a GUI or menu. Usually you would set up an orthographic screen and render to it, displacing co-ordinates by 0.375f or 0.5f (I don't remember which) to make sure you hit the centre of a pixel.
--
Cheers,
Darren Clark
Advertisement
thx m8

This topic is closed to new replies.

Advertisement