Any way I can improve on this?

BlitzMax Forums/BlitzMax Programming/Any way I can improve on this?

Pete Rigz(Posted 2008) [#1]
A few months back I posted about trying to save an image with alpha for a particle editor I've been creating. I thought I'd cracked it but it wasn't actually any good because it didn't work with images (I only tested with drawoval and setalpha). Anyway since then I've been busy redoing the interface in wxWidgets and now I'm back trying to figure this problem out. I'm very nearly there but it's still not quite perfect.

I'm using Klepto's render to texture code and have included 2 new blendmodes that use glBlendFuncSeparateEXT which separates how the colour and alpha is added to the buffer (this won't work on older cards but not really bothered about that at the moment). But also what I have to do is restore the colour values on the texture back to what they would have been before any blending took place. I think this is where inaccuracies are creeping in as I have to divide each colour by the alpha value.

Please someone tell me I'm missing something blindingly obvious that makes all this easy :)

here's my test code:



If you run it the image on the left is how it should look, the image on the right is the image that was rendered to and grabbed.

Thanks for any help!