Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 harshman_chris   Members   -  Reputation: 184

Like
0Likes
Like

Posted 13 March 2013 - 10:52 AM

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

waterdroplets.png

 

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

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.



Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 8282

Like
0Likes
Like

Posted 13 March 2013 - 04:14 PM

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.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 harshman_chris   Members   -  Reputation: 184

Like
0Likes
Like

Posted 13 March 2013 - 04:44 PM

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.


Edited by harshman_chris, 13 March 2013 - 05:02 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS