First of all thanks for your answers. It is very nice to see there are people like you who help others!
I really think this task shouldn't belong to PocketHAL: PHAL is abstracting all the hardware for you, but there is no hardware support for alpha, so you have to implement all the things by yourself.
Yes, i fully agree with that. The features were related to PocketFrog not PocketHAL but i must confess that i made myself not clear enough. My purpose on bringing PocketHAL into discussion was because from what i read in the PocketHAL 0.8 Alpha thread it doesn't seem to be developed anymore into future. Or did i get this wrong?
The thread pocketHal 0.8 alpha has nothing to do with alpha blending.
I might get confused or write some weird stuff because of my lacks in english language but i'm not that blind to get that...
So, which alpha 'mod' are you using?
I don't use any modification, only the PocketFrog 0.8.1. release that can be downloaded at the droneship page. There i found the following method which i use for alpha blit:
- Code:
// Blit with Full Alpha Support - J Elmore
void Blit( int destX, int destY, const Surface* source, const Surface * AlphaSurf, const Rect* srcRect = 0 );
So now i tried to made my own rotated alpha blit method by trying to combine the Blit() (with alpha) and the BlitRotated() methods. This is what i came up with, but it doesn't work right now and i'm still trying to find out why.
- Code:
void Rasterizer::BlitRotated( int destX, int destY, float angle, const Surface* source, const Surface * AlphaSurf )
{
// Calculate destination rectangle
//todo: find better fit
float tw = 0.5f * source->GetWidth();
float th = 0.5f * source->GetHeight();
int diag = int(sqrtf(tw*tw+th*th) + 1.0f);
Rect destRect( destX-diag, destY-diag, destX+diag, destY+diag );
int width = destRect.GetWidth();
int height = destRect.GetHeight();
// Clipping
if (!m_clipper.IsEmpty())
{
destRect.Intersect( m_clipper );
if (destRect.IsEmpty())
return;
}
int c = int(cosf( -angle ) * 1024.0f);
int s = int(sinf( -angle ) * 1024.0f);
int w = source->GetWidth() << 9;
int h = source->GetHeight() << 9;
// Use fixed point (22.10)
unsigned T[3][2];
T[0][0] = c;
T[0][1] = -s;
T[1][0] = s;
T[1][1] = c;
T[2][0] = -c * destX - s * destY + w;
T[2][1] = s * destX - c * destY + h;
// Optimization: compensate for fixed point arithmetic in rasterization loops
T[2][0] <<= 6;
T[2][1] <<= 6;
// Drawing
int colorMask = source->GetColorMask();
Surface* pRotatedPixels = new Surface(width, height);
Surface* pRotatedAlpha = new Surface(width, height);
Rect sizeRect(0, 0, width, destRect.GetHeight());
// Rotate both surfaces
m_raster->BlitTransform( *pRotatedPixels->m_buffer, sizeRect, T, *source->m_buffer );
m_raster->BlitTransform( *pRotatedAlpha->m_buffer, sizeRect, T, *AlphaSurf->m_buffer );
Blit( destX-diag, destY-diag, pRotatedPixels, pRotatedAlpha);
delete pRotatedPixels;
delete pRotatedAlpha;
}
I tried to create two surfaces into which i BlitRotate the image and the alpha surfaces. Seems like the BlitTransform() fails but i have no idea why. Perhaps one of you has an idea?
Greetings,
Chris