OPENGL: Fix cursor regression when defaultFormat doesn't have an alpha channel.

This commit is contained in:
Johannes Schickel 2014-02-11 12:19:30 +01:00
parent 16898486fa
commit abcadb5d87
2 changed files with 10 additions and 6 deletions

View file

@ -572,7 +572,7 @@ void OpenGLGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int
} else { } else {
textureFormat = _defaultFormatAlpha; textureFormat = _defaultFormatAlpha;
} }
_cursor = createTexture(textureFormat); _cursor = createTexture(textureFormat, true);
assert(_cursor); assert(_cursor);
_cursor->enableLinearFiltering(_currentState.graphicsMode == GFX_LINEAR); _cursor->enableLinearFiltering(_currentState.graphicsMode == GFX_LINEAR);
} }
@ -911,14 +911,15 @@ void OpenGLGraphicsManager::adjustMousePosition(int16 &x, int16 &y) {
} }
} }
Texture *OpenGLGraphicsManager::createTexture(const Graphics::PixelFormat &format) { Texture *OpenGLGraphicsManager::createTexture(const Graphics::PixelFormat &format, bool wantAlpha) {
GLenum glIntFormat, glFormat, glType; GLenum glIntFormat, glFormat, glType;
if (format.bytesPerPixel == 1) { if (format.bytesPerPixel == 1) {
const bool supported = getGLPixelFormat(_defaultFormat, glIntFormat, glFormat, glType); const Graphics::PixelFormat &virtFormat = wantAlpha ? _defaultFormatAlpha : _defaultFormat;
const bool supported = getGLPixelFormat(virtFormat, glIntFormat, glFormat, glType);
if (!supported) { if (!supported) {
return nullptr; return nullptr;
} else { } else {
return new TextureCLUT8(glIntFormat, glFormat, glType, _defaultFormat); return new TextureCLUT8(glIntFormat, glFormat, glType, virtFormat);
} }
} else { } else {
const bool supported = getGLPixelFormat(format, glIntFormat, glFormat, glType); const bool supported = getGLPixelFormat(format, glIntFormat, glFormat, glType);

View file

@ -174,10 +174,13 @@ private:
/** /**
* Create a texture with the specified pixel format. * Create a texture with the specified pixel format.
* *
* @param format The pixel format the Texture object should accept as input. * @param format The pixel format the Texture object should accept as
* input.
* @param wantAlpha For CLUT8 textures this marks whether an alpha
* channel should be used.
* @return A pointer to the texture or nullptr on failure. * @return A pointer to the texture or nullptr on failure.
*/ */
Texture *createTexture(const Graphics::PixelFormat &format); Texture *createTexture(const Graphics::PixelFormat &format, bool wantAlpha = false);
// //
// Transaction support // Transaction support