Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Skwint

Pages: [1]
1
Graphics / Re: sfml2.0-rc pushStates/poStates crash (with Horde3d)
« on: June 01, 2013, 12:59:21 am »
I have exactly the same issue - after calling h3dInit all SFML sprites become single colour blocks.  However, I also then crash shortly afterwards.  :-\

I think taking a working 3D engine and implementing 2D yourself is probably easier than taking the 2D SFML and trying to make a 3D engine play nicely with it.  Infact, the only reason I'm attempting this atall is that I have a lot of work complete using SFML and SFGUI which I don't want to redo.

2
That's reassuring.  Thanks.

Since I found this thread, instead of finding github, I'll stick this here for any that want it:
void Image::convertToPremultipliedAlpha()
{
        if (!m_pixels.empty())
        {
                Uint8* source = &m_pixels[0];
                for (unsigned int y = 0; y < m_size.y; ++y)
                {
                        for (unsigned int x = 0; x < m_size.x; ++x)
                        {
                                Uint32 alpha = *(source + 3);
                                *(source    ) = Uint8((Uint32(*(source    )) * alpha) / 255);
                                *(source + 1) = Uint8((Uint32(*(source + 1)) * alpha) / 255);
                                *(source + 2) = Uint8((Uint32(*(source + 2)) * alpha) / 255);
                                source += 4;
                        }
                }
        }
}
 
optimizations exist for this I'm sure, but this works, and I don't have a profiler to hand.

3
*Bump*
+1 vote in favour of this feature request.

To quote TomF "What we think of as conventional alpha-blending is basically wrong"
It's been obviously wrong since atleast 1984.  It was wrong before then, but it would be understandable if people didn't realise it :P

So just so you know, I'm another guy off to implement premultiplied himself because I need something that works  :-\



Pages: [1]