YATQ - Yet Another Texture Question

I am having the same problem that dsellars had on antoher thread. I have png’s that have black background. I have set black as my clear color and the backgrounds are completely gone (what I want) but the image is transparent.

I am using the testure loader form LWJGL examples with the following line:

BufferedImage tex = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_4BYTE_ABGR);

Anything other that that type_4byte_abgr or type_3byte_bgr will cause the following line to error out with a clas cast exception at the following line:

byte data[] = (byte[]) tex.getRaster().getDataElements(0, 0, tex.getWidth(), tex.getHeight(), null);

my code for transparency is as follows and i have tried with with and without the commented code:

            if(isTransparent()) {
                  GL11.glEnable(GL11.GL_BLEND);                                // Set up blending for transparency
                  //GL11.glDisable(GL11.GL_DEPTH_TEST); 
              GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE);  // Blending Function For Translucency Based On Source Alpha Value
              //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
            }

regardless of changes, to have solid images, I must have solid backgrounds.
where is my clubieness at its highest?
M

EDIT: one note…if I use Fireworks and use a transparent canvas and use GL11.GL_ONE_MINUS_SRC_ALPHA it does what it should, but is this best practice?

I got my stuff working in the end (I think as I’ve not got back to it to play with properly).

I used a modified version of the DevIL code in nehe lesson06 to load the image. (modified to load the alpa chanel)

I used the values that Cas suggested and it worked. The only thing i can think of is that when I created my png’s I created then with a transparent background.

I would have thought that having a black background on the texture will mean it gets drawn.

hth,

Dan.

Thanks. I am in the middle of converting all the canvas backgrounds to transparent. :wink:

Did you try it with just one sprite to see if it worked first? ;D

Dan.

Canvases to transparent does the trick…seeems good enough for now. :wink:

Now back to picking!