]> git.mxchange.org Git - quix0rs-blobwars.git/commitdiff
Fix color key and alpha blending.
authorGuus Sliepen <Guus.Sliepen@astro.su.se>
Tue, 1 Oct 2013 12:26:27 +0000 (14:26 +0200)
committerGuus Sliepen <Guus.Sliepen@astro.su.se>
Tue, 1 Oct 2013 12:26:27 +0000 (14:26 +0200)
src/CGraphics.cpp
src/CGraphics.h
src/cutscene.cpp
src/galdov.cpp
src/game.cpp
src/map.cpp
src/mapData.cpp
src/mission.cpp
src/title.cpp

index 93c2de8706ac4fd37c6ad92b724ae0d9c27036d3..f6e2292351dbc6d17a5e6ab62f8b1988a5235cac 100644 (file)
@@ -20,6 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "headers.h"
 
+void SDL_SetAlpha(SDL_Surface *surface, uint8_t value) {
+       SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND);
+       SDL_SetSurfaceAlphaMod(surface, value);
+}
+
 Graphics::Graphics()
 {
        for (int i = 0 ; i < MAX_TILES ; i++)
@@ -154,7 +159,7 @@ Sprite *Graphics::getSpriteHead()
 
 void Graphics::setTransparent(SDL_Surface *sprite)
 {
-       SDL_SetColorKey(sprite, SDL_RLEACCEL, SDL_MapRGB(sprite->format, 0, 0, 0));
+       SDL_SetColorKey(sprite, SDL_TRUE, SDL_MapRGB(sprite->format, 0, 0, 0));
 }
 
 bool Graphics::canShowMedalMessage() const
@@ -370,7 +375,7 @@ SDL_Surface *Graphics::loadImage(const char *filename, bool srcalpha)
        }
 
        if(srcalpha)
-               SDL_SetSurfaceAlphaMod(newImage, 255);
+               SDL_SetAlpha(newImage, 255);
        else
                setTransparent(newImage);
 
@@ -457,7 +462,7 @@ SDL_Surface *Graphics::quickSprite(const char *name, SDL_Surface *image)
 
 void Graphics::fade(int amount)
 {
-       SDL_SetSurfaceAlphaMod(fadeBlack, amount);
+       SDL_SetAlpha(fadeBlack, amount);
        blit(fadeBlack, 0, 0, screen, false);
 }
 
@@ -467,7 +472,7 @@ void Graphics::fadeToBlack()
 
        while (start < 50)
        {
-               SDL_SetSurfaceAlphaMod(fadeBlack, start);
+               SDL_SetAlpha(fadeBlack, start);
                blit(fadeBlack, 0, 0, screen, false);
                delay(60);
                start++;
@@ -519,7 +524,7 @@ void Graphics::loadMapTiles(const char *baseDir)
                        {
                                if ((i < MAP_EXITSIGN) || (i >= MAP_WATERANIM))
                                {
-                                       SDL_SetSurfaceAlphaMod(tile[i], 130);
+                                       SDL_SetAlpha(tile[i], 130);
                                }
                        }
                        else
@@ -1077,7 +1082,7 @@ SDL_Surface *Graphics::alphaRect(int width, int height, Uint8 red, Uint8 green,
 
        SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, red, green, blue));
 
-       SDL_SetSurfaceAlphaMod(surface, 130);
+       SDL_SetAlpha(surface, 130);
 
        return surface;
 }
@@ -1088,7 +1093,7 @@ void Graphics::colorize(SDL_Surface *image, int red, int green, int blue)
 
        blit(alpha, 0, 0, image, false);
 
-       SDL_SetColorKey(image, SDL_RLEACCEL, SDL_MapRGB(image->format, red / 2, green / 2, blue / 2));
+       SDL_SetColorKey(image, SDL_TRUE, SDL_MapRGB(image->format, red / 2, green / 2, blue / 2));
 }
 
 void Graphics::lock(SDL_Surface *surface)
index 2070ce55783ffbf81b214e03e252254bc76c9201..1f544cf38a79111d83c1fc12b07b12d9dfed47f6 100644 (file)
@@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 */
 
+void SDL_SetAlpha(SDL_Surface *surface, uint8_t value);
+
 class Graphics {
 
        private:
index 75baa4de8a0e32d14a97eb4cfaa693b31ce1b27c..4e37d9b5dac9dab6eb80ffcee170ac1cc3a6f1de 100644 (file)
@@ -135,7 +135,7 @@ void showScene(bool allowSkip)
        
        float panelAlpha = 0;
        
-       SDL_SetSurfaceAlphaMod(panel, 0);
+       SDL_SetAlpha(panel, 0);
        
        engine.clearInput();
        engine.flushInput();
@@ -164,10 +164,10 @@ void showScene(bool allowSkip)
                if (panelAlpha < 256)
                {
                        panelAlpha += (1 * engine.getTimeDifference());
-                       SDL_SetSurfaceAlphaMod(panel, panelAlpha);
+                       SDL_SetAlpha(panel, panelAlpha);
                        if (image != NULL)
                        {
-                               SDL_SetSurfaceAlphaMod(image, panelAlpha);
+                               SDL_SetAlpha(image, panelAlpha);
                                graphics.blit(image, 0, 0, graphics.screen, false);
                        }
                        graphics.blit(panel, 0, 390, graphics.screen, false);
index 22f936ea552c7e39fc655d6c9b2cf95702a77d0d..583091601fc4c2f071fc085fc4dd71e66f55e041 100644 (file)
@@ -474,8 +474,8 @@ void galdovInit()
        
        Math::addBit(&map.boss[0]->flags, ENT_AIMS);
        
-       SDL_SetSurfaceAlphaMod(graphics.getSprite("GaldovInvsLeft", true)->image[0], 100);
-       SDL_SetSurfaceAlphaMod(graphics.getSprite("GaldovInvsRight", true)->image[0], 100);
+       SDL_SetAlpha(graphics.getSprite("GaldovInvsLeft", true)->image[0], 100);
+       SDL_SetAlpha(graphics.getSprite("GaldovInvsRight", true)->image[0], 100);
        
        for (int i = 1 ; i < 10 ; i++)
        {
index 6f5a97008906cfc7631258f9633777dedf643a46..6ecbfa44017514d63611d7c1d9be08410bbff7fc 100644 (file)
@@ -381,7 +381,7 @@ void showMissionInformation()
 
        SDL_Surface *panel = graphics.createSurface(400, 300);
        SDL_Surface *panelBack = graphics.alphaRect(400, 300, 0x00, 0x00, 0x00);
-       SDL_SetColorKey(panel, SDL_RLEACCEL, SDL_MapRGB(panel->format, 0, 0, 0));
+       SDL_SetColorKey(panel, SDL_TRUE, SDL_MapRGB(panel->format, 0, 0, 0));
 
        graphics.drawRect(1, 1, 398, 298, graphics.black, graphics.white, panelBack);
 
index 07eb4aabb94e8cd40615c5b63ce42c42f5f50e3c..378c888751bd1c12e76f40fa85225a4f69ce77e6 100644 (file)
@@ -293,7 +293,7 @@ void showMap(int centerX, int centerY)
        
        SDL_Surface *panel = graphics.createSurface(320, 240);
        SDL_Surface *background = graphics.loadImage("gfx/main/mapBackground.png");
-       SDL_SetSurfaceAlphaMod(background, 130);
+       SDL_SetAlpha(background, 130);
        
        graphics.blit(background, 0, 0, panel, false);
        
index a617a02063ace920182c03f029da118a351c3136..fb64299faa196780e0db14a2d8fce0cc72af34af 100644 (file)
@@ -284,7 +284,7 @@ void getMapTokens()
                                                
                                        debug(("Setting Alpha for Tile %d\n", param[0]));
 
-                                       SDL_SetSurfaceAlphaMod(graphics.tile[param[0]], 130);
+                                       SDL_SetAlpha(graphics.tile[param[0]], 130);
 
                                        while (true)
                                        {
index 983b47bd4ca17db41134d128cca7a55b22c1e3a5..6321a554d8cccf060528223b59002578245dfc15 100644 (file)
@@ -162,7 +162,7 @@ void showMissionClear()
        graphics.loadBackground("gfx/main/areaClearBackGround.jpg");
 
        SDL_Surface *panel = graphics.alphaRect(550, 420, 0x00, 0x00, 0x00);
-       SDL_SetSurfaceAlphaMod(panel, 180);
+       SDL_SetAlpha(panel, 180);
        graphics.drawRect(1, 1, panel->w - 2, panel->h - 2 , graphics.black, graphics.white, panel);
 
        graphics.blit(panel, (640 - panel->w) / 2, (480 - panel->h) / 2, graphics.background, false);
index 7b5e05028726094f4963c5a03223bb0d11af9f56..91439557c5b960a05cab011e4de6fbdbb7694a1d 100644 (file)
@@ -197,12 +197,12 @@ int title()
        snprintf(v, sizeof v, _("Version %s"), STRINGIFY_VALUE(VERSION));
        SDL_Surface *version = graphics.quickSprite("Version", graphics.getString(v, true));
 
-       SDL_SetSurfaceAlphaMod(title, 0);
+       SDL_SetAlpha(title, 0);
 
        audio.loadMusic("music/title");
 
        graphics.loadBackground("gfx/main/CircuitBoard.jpg");
-       SDL_SetSurfaceAlphaMod(graphics.background, 0);
+       SDL_SetAlpha(graphics.background, 0);
 
        int startNewGame, options, quit, help, easy, normal, hard, extreme, back, practice;
        int load, cont, save[5], slot[6];
@@ -268,8 +268,8 @@ int title()
                                engine.clearInput();
                                backAlpha = 255;
                                titleAlpha = 255;
-                               SDL_SetSurfaceAlphaMod(graphics.background, backAlpha);
-                               SDL_SetSurfaceAlphaMod(title, titleAlpha);
+                               SDL_SetAlpha(graphics.background, backAlpha);
+                               SDL_SetAlpha(title, titleAlpha);
                        }
                }
 
@@ -278,7 +278,7 @@ int title()
                        if (backAlpha < 255)
                        {
                                backAlpha++;
-                               SDL_SetSurfaceAlphaMod(graphics.background, backAlpha);
+                               SDL_SetAlpha(graphics.background, backAlpha);
                        }
                }
 
@@ -287,7 +287,7 @@ int title()
                        if (titleAlpha < 255)
                        {
                                titleAlpha++;
-                               SDL_SetSurfaceAlphaMod(title, titleAlpha);
+                               SDL_SetAlpha(title, titleAlpha);
                        }
                        else
                        {