Screenshots in LWJGL?

I’ve got a question here, but it’s specifically about saving as a TGA. I pretty much want to convert frames from a 3D model into sprites of the model doing various things. I’ve got the models all loaded in and taking a sceenshot works, but I don’t know how to turn everything that is not the model into part of the alpha channel for the TGA, thereby making it transparent. Anyone know how? I was thinking of changing the background to some obscure color and searching for any pixels matching that color, but I don’t want to do anything like that because there is the off chance I will need the color I used.

for 3d models you can usually do this with a 3d modeling program i’ve seen in programs such as 3ds max you can render the image to a bitmap or tga if you wish with alpha for the background! you can also just take a screenshot and edit in say the GIMP, where you can just fill paint the background into alpha and save as tga.

This is true, I could use a program, but I wanted to make my own that would save me a lot of time over doing it manually. Pretty much it just loads in the first frame of an animation, let’s you choose as many camera angles as you like, and then saves each animation from each of those camera angles, thereby creating sprites. This way after some experimentation I could simply drag the 3D model into the application and have every single type of sprite I need automatically generated.

If you are going to take the shot in away from anything else you could use the ZBuffer to decide what should be alpha and what should show.

If you choose an 8-bit alpha channel for your OpenGL context using the PixelFormat class and set the background color to one with zero alpha using glClearColor, then if you read back the frame buffer in GL_ABGR_EXT format into a Targa file with alpha then the unrendered background pixels will automatically be transparent in the resulting .tga. For a concrete example, look in the JOGL source code for Screenshot.java, in particular writeToTargaFile(File file, int width, int height, boolean alpha).