diff --git a/src/drawing/engines/opengl/OpenGLDrawingEngine.cpp b/src/drawing/engines/opengl/OpenGLDrawingEngine.cpp index 6b538cbaf4..f3a329ba9e 100644 --- a/src/drawing/engines/opengl/OpenGLDrawingEngine.cpp +++ b/src/drawing/engines/opengl/OpenGLDrawingEngine.cpp @@ -605,10 +605,12 @@ void OpenGLDrawingContext::DrawSprite(uint32 image, sint32 x, sint32 y, uint32 t GLuint texture = _textureCache->GetOrLoadImageTexture(image); + uint8 zoomLevel = (1 << _dpi->zoom_level); + sint32 drawOffsetX = g1Element->x_offset; sint32 drawOffsetY = g1Element->y_offset; - sint32 drawWidth = (uint16)g1Element->width >> _dpi->zoom_level; - sint32 drawHeight = (uint16)g1Element->height >> _dpi->zoom_level; + sint32 drawWidth = g1Element->width; + sint32 drawHeight = g1Element->height; sint32 left = x + drawOffsetX; sint32 top = y + drawOffsetY; @@ -624,10 +626,20 @@ void OpenGLDrawingContext::DrawSprite(uint32 image, sint32 x, sint32 y, uint32 t std::swap(top, bottom); } - left += _offsetX; - top += _offsetY; - right += _offsetX; - bottom += _offsetY; + left -= _dpi->x; + top -= _dpi->y; + right -= _dpi->x; + bottom -= _dpi->y; + + left /= zoomLevel; + top /= zoomLevel; + right /= zoomLevel; + bottom /= zoomLevel; + + left += _clipLeft; + top += _clipTop; + right += _clipLeft; + bottom += _clipTop; _drawImageShader->Use(); _drawImageShader->SetClip(_clipLeft, _clipTop, _clipRight, _clipBottom); @@ -643,6 +655,8 @@ void OpenGLDrawingContext::DrawSpriteRawMasked(sint32 x, sint32 y, uint32 maskIm GLuint textureMask = _textureCache->GetOrLoadImageTexture(maskImage); GLuint textureColour = _textureCache->GetOrLoadImageTexture(colourImage); + uint8 zoomLevel = (1 << _dpi->zoom_level); + sint32 drawOffsetX = g1ElementMask->x_offset; sint32 drawOffsetY = g1ElementMask->y_offset; sint32 drawWidth = Math::Min(g1ElementMask->width, g1ElementColour->width); @@ -662,10 +676,20 @@ void OpenGLDrawingContext::DrawSpriteRawMasked(sint32 x, sint32 y, uint32 maskIm std::swap(top, bottom); } - left += _offsetX; - top += _offsetY; - right += _offsetX; - bottom += _offsetY; + left -= _dpi->x; + top -= _dpi->y; + right -= _dpi->x; + bottom -= _dpi->y; + + left /= zoomLevel; + top /= zoomLevel; + right /= zoomLevel; + bottom /= zoomLevel; + + left += _clipLeft; + top += _clipTop; + right += _clipLeft; + bottom += _clipTop; _drawImageMaskedShader->Use(); _drawImageMaskedShader->SetClip(_clipLeft, _clipTop, _clipRight, _clipBottom);