summaryrefslogtreecommitdiff
path: root/src/graphics.h
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-05 10:21:43 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-22 20:26:26 +0100
commita06db62288bc3fdbf3f25bcfa046c20510036665 (patch)
tree5ad510ebc223364f8d8f59f84d5bb8081a2822b1 /src/graphics.h
parent944b99f3a2e87a080666174dc1e2e2b543519904 (diff)
downloadmana-a06db62288bc3fdbf3f25bcfa046c20510036665.tar.gz
mana-a06db62288bc3fdbf3f25bcfa046c20510036665.tar.bz2
mana-a06db62288bc3fdbf3f25bcfa046c20510036665.tar.xz
mana-a06db62288bc3fdbf3f25bcfa046c20510036665.zip
Added support for scaling the output
* Added "Scale" user option, which can either by "Auto" or an explicit scaling factor. Its maximum value depends on the current resolution. The "Auto" factor is based on keeping the logical resolution on at least 800x600, wheres the maximum scale is based on keeping the logical resolution on at least 640x480. * Enabled support for High DPI. This means the rendering target can now have a different resolution than the window size, which can happen on macOS, Windows and Wayland. The resulting scale is multiplied by the above user-controlled scale. Currently, this looks ugly for non-integer scales, which are not used on macOS and can only be configured on some Wayland compositors. Has not been tested on Windows. * Simplified OpenGL initialization (moved out of _beginDraw). * Made sure _beginDraw/_endDraw sets a clip area also for SDLGraphics.
Diffstat (limited to 'src/graphics.h')
-rw-r--r--src/graphics.h23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/graphics.h b/src/graphics.h
index 956e729d..91bb01cf 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -80,7 +80,10 @@ class Graphics : public gcn::Graphics
*/
virtual void setVSync(bool sync) = 0;
- virtual void videoResized(int w, int h);
+ /**
+ * Called when the window size or scale has changed.
+ */
+ virtual void updateSize(int width, int height, float scale);
using gcn::Graphics::drawImage;
@@ -161,14 +164,24 @@ class Graphics : public gcn::Graphics
virtual void updateScreen() = 0;
/**
- * Returns the width of the screen.
+ * Returns the logical width of the screen.
+ */
+ int getWidth() const { return mWidth; }
+
+ /**
+ * Returns the logical height of the screen.
*/
- int getWidth() const;
+ int getHeight() const { return mHeight; }
/**
- * Returns the height of the screen.
+ * Converts a window coordinate to a logical coordinate. Used for
+ * converting mouse coordinates.
*/
- int getHeight() const;
+ virtual void windowToLogical(int windowX, int windowY,
+ float &logicalX, float &logicalY) const = 0;
+
+ void _beginDraw() override;
+ void _endDraw() override;
/**
* Takes a screenshot and returns it as SDL surface.