FreeImage and loading textures with Alpha, NOt rendering correctly with OpenGL [SOLVED]

Started by
1 comment, last by harshman_chris 11 years, 1 month ago

Alright so I am working on implementing loading 2D textures using FreeImage, these textures have transparency, originally I was just taking these textures and converting them to 24 bits per pixel, but now I am expanding it to 32 bits.

My Code is here:

http://pastebin.com/F3ydkjPy

This is the Texture I am using, it has transparency

[attachment=14258:waterdroplets.png]

Here is what it looks like when loaded with the code I have linked above.

[attachment=14257:ColourIssue.png]

If I load this texture as 24 bits, it just loads the texture find with the right colour, but the transparent area's are all black.

I am at a lost to this issue right now, as the loading code should work as I really didn't create anything new, just using what other people used, written out myself.

Advertisement

Your loading code looks correct enough (you might want to revisit how you're handling sampler objects, but that's for another topic).

Are you calling glEnable (GL_BLEND) anywhere, and are you setting glBlendFunc? It's not enough to just load a texture with alpha, you need these too.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Your loading code looks correct enough (you might want to revisit how you're handling sampler objects, but that's for another topic).

Are you calling glEnable (GL_BLEND) anywhere, and are you setting glBlendFunc? It's not enough to just load a texture with alpha, you need these too.

Yes I am, but given that the colour of the texture is off (GL_BLEND wont do this), it has to be something within the texture loading code as far as I can see.

Edit:

So after playing around a bit, I at least found some of the issue, rather than swapping bytes in the image, I just tell the image that it is GL_BGRA and that solves the colour issue, but the background is still visible. in addition to blending all my particles are deferred to draw after all other 3 components. In the shader, adjusting the alpha does work, the particles do fade out over there life time.

Edit:

So I resolved the issue not, I added a discard to the fragment shader and now it works.

This topic is closed to new replies.

Advertisement