From 5d8cf6ba42c71e37530e83bb766b60bf1388a904 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Wed, 13 Sep 2017 00:47:44 -0500 Subject: BACKENDS: Fix GraphicsManager handling of empty cursors The SDL graphics manager was just ignoring calls from CursorMan to set the cursor to a blank cursor, which meant engines that did not immediately send a cursor to CursorMan at startup would still show the launcher's cursor (usually with a broken palette). The OpenGL graphics manager would try to generate and draw an invalid cursor surface when receiving an empty cursor. --- backends/graphics/opengl/opengl-graphics.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'backends/graphics/opengl') diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index f3ea372b2a..7bac4c85cb 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -567,6 +567,18 @@ void applyColorKey(DstPixel *dst, const SrcPixel *src, uint w, uint h, uint dstP } // End of anonymous namespace void OpenGLGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) { + + _cursorKeyColor = keycolor; + _cursorHotspotX = hotspotX; + _cursorHotspotY = hotspotY; + _cursorDontScale = dontScale; + + if (!w || !h) { + delete _cursor; + _cursor = nullptr; + return; + } + Graphics::PixelFormat inputFormat; #ifdef USE_RGB_COLOR if (format) { @@ -602,11 +614,6 @@ void OpenGLGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int _cursor->enableLinearFiltering(_currentState.filtering); } - _cursorKeyColor = keycolor; - _cursorHotspotX = hotspotX; - _cursorHotspotY = hotspotY; - _cursorDontScale = dontScale; - _cursor->allocate(w, h); if (inputFormat.bytesPerPixel == 1) { // For CLUT8 cursors we can simply copy the input data into the -- cgit v1.2.3