Blending

Howzit

How do I load a texture say for example a gun, all I want is the gun and not the rest of the parts that just fill the image. I need to map the gun over the other images.

Is there a way to do this in OpenGL or do I need to do it manually?

Shot

Are you wrapping this gun image as a texture around a gun model? Or do you just want to display it as a flat image on say a single quad?

A flat image

Create an image with an alpha channel for transparency (use for example PhotoShop for this).
Be sure to load the texture with the right pixel format (GL.RGBA usually). (revert to tutorials to see how)

Then, before drawing your quad with the texture, enable blending like this:


gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE);

Something like that :slight_smile:

Erik