Skip to content

Commit

Permalink
WINTERMUTE: Apply colorkey according to subengine version
Browse files Browse the repository at this point in the history
  • Loading branch information
lolbot-iichan committed Jul 3, 2021
1 parent b45d6ce commit f7d54f2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
13 changes: 11 additions & 2 deletions engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "common/algorithm.h"
#include "graphics/transform_tools.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/gfx/base_image.h"

#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
Expand Down Expand Up @@ -174,11 +175,19 @@ bool BaseSurfaceOpenGL3D::create(const Common::String &filename, bool defaultCK,

_imageData = img.getSurface()->convertTo(OpenGL::TextureGL::getRGBAPixelFormat(), img.getPalette());

if (_filename.hasSuffix(".bmp") && img.getSurface()->format.bytesPerPixel == 4) {
// 32 bpp BMPs have nothing useful in their alpha-channel -> color-key
if (BaseEngine::instance().getTargetExecutable() < WME_LITE) {
// WME 1.x always use colorkey, even for images with transparency
needsColorKey = true;
replaceAlpha = false;
} else if (BaseEngine::instance().isFoxTail()) {
// FoxTail does not use colorkey
needsColorKey = false;
} else if (_filename.hasSuffix(".bmp")) {
// generic WME Lite ignores alpha channel for BMPs
needsColorKey = true;
replaceAlpha = false;
} else if (img.getSurface()->format.aBits() == 0) {
// generic WME Lite does not use colorkey for non-BMPs with transparency
needsColorKey = true;
}

Expand Down
33 changes: 19 additions & 14 deletions engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,27 @@ bool BaseSurfaceOSystem::finishLoad() {
error("Missing palette while loading 8bit image %s", _filename.c_str());
}
_surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette());
needsColorKey = true;
} else if (image->getSurface()->format != g_system->getScreenFormat()) {
_surface = image->getSurface()->convertTo(g_system->getScreenFormat());
} else {
if (image->getSurface()->format != g_system->getScreenFormat()) {
_surface = image->getSurface()->convertTo(g_system->getScreenFormat());
} else {
_surface = new Graphics::Surface();
_surface->copyFrom(*image->getSurface());
}
_surface = new Graphics::Surface();
_surface->copyFrom(*image->getSurface());
}

if (_filename.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) {
// 32 bpp BMPs have nothing useful in their alpha-channel -> color-key
needsColorKey = true;
replaceAlpha = false;
} else if (image->getSurface()->format.aBits() == 0) {
needsColorKey = true;
}
if (BaseEngine::instance().getTargetExecutable() < WME_LITE) {
// WME 1.x always use colorkey, even for images with transparency
needsColorKey = true;
replaceAlpha = false;
} else if (BaseEngine::instance().isFoxTail()) {
// FoxTail does not use colorkey
needsColorKey = false;
} else if (_filename.hasSuffix(".bmp")) {
// generic WME Lite ignores alpha channel for BMPs
needsColorKey = true;
replaceAlpha = false;
} else if (image->getSurface()->format.aBits() == 0) {
// generic WME Lite does not use colorkey for non-BMPs with transparency
needsColorKey = true;
}

if (needsColorKey) {
Expand Down

0 comments on commit f7d54f2

Please sign in to comment.