Fixed alpha surfaces in Alien Blaster
This commit is contained in:
@@ -28,7 +28,8 @@ static inline SdlCompat_AcceleratedSurface * SdlCompat_CreateAcceleratedSurface(
|
||||
|
||||
// Allocate accelerated surface even if that means loss of color quality
|
||||
Uint32 format;
|
||||
|
||||
|
||||
/*
|
||||
if( surface->flags & SDL_SRCALPHA )
|
||||
{
|
||||
format = SDL_PIXELFORMAT_RGBA4444;
|
||||
@@ -59,17 +60,33 @@ static inline SdlCompat_AcceleratedSurface * SdlCompat_CreateAcceleratedSurface(
|
||||
format = SDL_PIXELFORMAT_RGB565;
|
||||
ret->t = SDL_CreateTextureFromSurface(format, surface);
|
||||
}
|
||||
*/
|
||||
|
||||
format = SDL_PIXELFORMAT_RGB565;
|
||||
|
||||
if( surface->flags & SDL_SRCCOLORKEY )
|
||||
format = SDL_PIXELFORMAT_RGBA5551;
|
||||
ret->t = SDL_CreateTextureFromSurface(format, surface);
|
||||
|
||||
ret->w = surface->w;
|
||||
ret->h = surface->h;
|
||||
ret->format = new SDL_PixelFormat();
|
||||
*(ret->format) = *(surface->format);
|
||||
|
||||
if( ! ret->t )
|
||||
{
|
||||
SDL_SetError("SdlCompat_CreateAcceleratedSurface: Cannot allocate HW texture, W %d H %d format %x surface->flags %x", ret->w, ret->h, format, surface->flags );
|
||||
return ret;
|
||||
}
|
||||
|
||||
if( surface->flags & SDL_SRCALPHA )
|
||||
{
|
||||
SDL_SetTextureBlendMode( ret->t, SDL_BLENDMODE_BLEND );
|
||||
Uint8 alpha = 128;
|
||||
if( SDL_GetSurfaceAlphaMod( surface, &alpha ) < 0 )
|
||||
alpha = 128;
|
||||
SDL_SetTextureAlphaMod( ret->t, alpha );
|
||||
}
|
||||
|
||||
ret->format = new SDL_PixelFormat();
|
||||
*(ret->format) = *(surface->format);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@ using namespace std;
|
||||
|
||||
Explosion::Explosion(string fn, const Vector2D &position,
|
||||
const Vector2D &velocity, const ExplosionTypes &explosionType) {
|
||||
sprite = surfaceDB.loadSurface(fn);
|
||||
sprite = surfaceDB.loadSurface(fn, true);
|
||||
|
||||
nrAnimStages = sprite->w / sprite->h;
|
||||
expired = false;
|
||||
|
||||
@@ -368,8 +368,8 @@ void initAllSurfaces() {
|
||||
surfaceDB.loadSurface("./images/heavyFighterDeflector.bmp", true);
|
||||
//surfaceDB.loadSurface("./images/font-20red");
|
||||
//surfaceDB.loadSurface("./images/font-20blue");
|
||||
surfaceDB.loadSurface("./images/explosion.bmp");
|
||||
surfaceDB.loadSurface("./images/explosionEnemy.bmp");
|
||||
surfaceDB.loadSurface("./images/explosion.bmp", true);
|
||||
surfaceDB.loadSurface("./images/explosionEnemy.bmp", true);
|
||||
surfaceDB.loadSurface("./images/bannerExcellent.bmp", true);
|
||||
surfaceDB.loadSurface("./images/bannerYouRule.bmp", true);
|
||||
surfaceDB.loadSurface("./images/bannerHeiho.bmp", true);
|
||||
|
||||
@@ -93,14 +93,7 @@ SdlCompat_AcceleratedSurface *SurfaceDB::loadSurface( string fn, bool alpha ) {
|
||||
}
|
||||
|
||||
if ( alpha ) {
|
||||
hwSurface = SDL_DisplayFormatAlpha(newSurface);
|
||||
if( hwSurface ) {
|
||||
SDL_FreeSurface(newSurface);
|
||||
newSurface = hwSurface;
|
||||
}
|
||||
SDL_SetAlpha( newSurface, SDL_SRCALPHA, 128 );
|
||||
SDL_SetColorKey( newSurface, SDL_SRCCOLORKEY,
|
||||
SDL_MapRGB(newSurface->format, transR, transG, transB) );
|
||||
}
|
||||
|
||||
surfaceDB[ fn ] = SdlCompat_CreateAcceleratedSurface( newSurface );
|
||||
|
||||
Reference in New Issue
Block a user