LWJGL Forum

Programming => OpenGL => Topic started by: bisquit on May 24, 2007, 02:37:48

Title: tga loading
Post by: bisquit on May 24, 2007, 02:37:48
hi! i'm trying to imitate lesson32 from nehe.gamedev.org and i noticed that they're using tga files... how can i use tga files without the black background showing? and how can i create my own tga files?

not really familiar with it.

i tried copying 'loadTextures(string path)' from the lesson, but it just gave me an error on Display.update(). which i don't get at all.

thanks for your helP!
Title: Re: tga loading
Post by: bobjob on May 24, 2007, 08:53:01
assuming that the file loads.

if its only a problem with transperancy

add this in ur code: when setting up openGL

GL11.glAlphaFunc(GL11.GL_GREATER,0.1f);
GL11.glEnable(GL11.GL_ALPHA_TEST);
Title: Re: tga loading
Post by: bisquit on May 25, 2007, 22:33:12
thanks! now it works for .tga files..

but now, how can i make my own tga files? i've tried making it in photoshop with a transparent background.. but the background becomes white when i load it...
Title: Re: tga loading
Post by: bobjob on May 26, 2007, 06:49:42
im not sure about photoshop.
I use Gimp its free :)

make a new transperant layer then delete the background, so that the transperant layer is the background.
then place your image on top.
Title: Re: tga loading
Post by: oNyx on May 27, 2007, 05:00:38
If you have a bunch of PNGs it's easier to convert em via imagemagick like:

mogrify -format tga *.png

If you want to create a 32bit tga in photoshop, you'll need to add an alpha channel in the channels tab (with that new channel button). If you want to use the existing alpha from the RGB stuff (well... photoshop is a bit weird in that regard) you can do it like:
-ctrl+click on the layer
-go to the channels tab
-hit new channel
-select white
-alt+backspace

And then you got some sparkling new alpha channel, which matches your usual alpha stuff.