aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/opengl
diff options
context:
space:
mode:
authorAlejandro Marzini2010-07-26 04:17:37 +0000
committerAlejandro Marzini2010-07-26 04:17:37 +0000
commit19ce960868956352139a0b43c7e43a63c5924525 (patch)
tree39ac374931c0903bf0a47d28176c47079d11110a /backends/graphics/opengl
parentc5037d7c6c42b6682523f0cde7af69178250fcfa (diff)
downloadscummvm-rg350-19ce960868956352139a0b43c7e43a63c5924525.tar.gz
scummvm-rg350-19ce960868956352139a0b43c7e43a63c5924525.tar.bz2
scummvm-rg350-19ce960868956352139a0b43c7e43a63c5924525.zip
OPENGL: Add cursor scaling.
svn-id: r51291
Diffstat (limited to 'backends/graphics/opengl')
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp42
-rw-r--r--backends/graphics/opengl/opengl-graphics.h18
2 files changed, 46 insertions, 14 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 78d70bff66..f9b39ee524 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -554,8 +554,11 @@ void OpenGLGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int
assert(keycolor <= 255);
#endif
+ // Allocate space for cursor data
+ if (_cursorData.w != w || _cursorData.h != h)
+ _cursorData.create(w, h, _cursorFormat.bytesPerPixel);
+
// Save cursor data
- _cursorData.create(w, h, _cursorFormat.bytesPerPixel);
memcpy(_cursorData.pixels, buf, h * _cursorData.pitch);
// Set cursor info
@@ -566,6 +569,8 @@ void OpenGLGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int
_cursorKeyColor = keycolor;
_cursorTargetScale = cursorTargetScale;
_cursorNeedsRedraw = true;
+
+ refreshCursorScale();
}
void OpenGLGraphicsManager::setCursorPalette(const byte *colors, uint start, uint num) {
@@ -719,6 +724,29 @@ void OpenGLGraphicsManager::refreshCursor() {
}
}
+void OpenGLGraphicsManager::refreshCursorScale() {
+ float scaleFactorX = (float)_videoMode.hardwareWidth / _videoMode.screenWidth;
+ float scaleFactorY = (float)_videoMode.hardwareHeight / _videoMode.screenHeight;
+ float scaleFactor = scaleFactorX < scaleFactorY ? scaleFactorX : scaleFactorY;
+
+ if (_cursorTargetScale >= scaleFactor && _videoMode.scaleFactor >= scaleFactor) {
+ _cursorState.rW = _cursorState.w;
+ _cursorState.rH = _cursorState.h;
+ _cursorState.rHotX = _cursorState.hotX;
+ _cursorState.rHotY = _cursorState.hotY;
+ } else {
+ _cursorState.rW = _cursorState.w * scaleFactor;
+ _cursorState.rH = _cursorState.h * scaleFactor;
+ _cursorState.rHotX = _cursorState.hotX * scaleFactor;
+ _cursorState.rHotY = _cursorState.hotY * scaleFactor;
+ }
+
+ _cursorState.vW = _cursorState.w * scaleFactor;
+ _cursorState.vH = _cursorState.h * scaleFactor;
+ _cursorState.vHotX = _cursorState.hotX * scaleFactor;
+ _cursorState.vHotY = _cursorState.hotY * scaleFactor;
+}
+
void OpenGLGraphicsManager::getGLPixelFormat(Graphics::PixelFormat pixelFormat, byte &bpp, GLenum &glFormat, GLenum &gltype) {
if (pixelFormat == Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)) { // RGBA8888
bpp = 4;
@@ -764,7 +792,6 @@ void OpenGLGraphicsManager::internUpdateScreen() {
// Draw the overlay
if (_overlayVisible) {
-
// Refresh texture if dirty
if (_overlayNeedsRedraw || !_overlayDirtyRect.isEmpty())
refreshOverlay();
@@ -774,13 +801,16 @@ void OpenGLGraphicsManager::internUpdateScreen() {
// Draw the cursor
if (_cursorVisible) {
-
// Refresh texture if dirty
if (_cursorNeedsRedraw)
refreshCursor();
- _cursorTexture->drawTexture(_cursorState.x - _cursorState.hotX,
- _cursorState.y - _cursorState.hotY, _cursorState.w, _cursorState.h);
+ if (_overlayVisible)
+ _cursorTexture->drawTexture(_cursorState.x - _cursorState.rHotX,
+ _cursorState.y - _cursorState.rHotY, _cursorState.rW, _cursorState.rH);
+ else
+ _cursorTexture->drawTexture(_cursorState.x - _cursorState.vHotX,
+ _cursorState.y - _cursorState.vHotY, _cursorState.vW, _cursorState.vH);
}
}
@@ -886,6 +916,8 @@ bool OpenGLGraphicsManager::loadGFXMode() {
loadTextures();
+ refreshCursorScale();
+
internUpdateScreen();
return true;
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index a372cb9d0d..61ae67ffaa 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -205,20 +205,19 @@ protected:
int16 w, h;
int16 hotX, hotY;
- // The size and hotspot of the pre-scaled cursor image, in real
+ // The size and hotspot of the scaled cursor, in real
// coordinates.
- //int16 rW, rH;
- //int16 rHotX, rHotY;
+ int16 rW, rH;
+ int16 rHotX, rHotY;
- // The size and hotspot of the pre-scaled cursor image, in game
+ // The size and hotspot of the scaled cursor, in game
// coordinates.
- //int16 vW, vH;
- //int16 vHotX, vHotY;
+ int16 vW, vH;
+ int16 vHotX, vHotY;
- MousePos() : x(0), y(0), w(0), h(0), hotX(0), hotY(0)/*,
+ MousePos() : x(0), y(0), w(0), h(0), hotX(0), hotY(0),
rW(0), rH(0), rHotX(0), rHotY(0), vW(0), vH(0),
- vHotX(0), vHotY(0)*/
- { }
+ vHotX(0), vHotY(0) {}
};
GLTexture* _cursorTexture;
@@ -235,6 +234,7 @@ protected:
bool _cursorNeedsRedraw;
virtual void refreshCursor();
+ virtual void refreshCursorScale();
virtual void adjustMouseEvent(const Common::Event &event);
virtual void setMousePos(int x, int y);