diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-05 10:21:43 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-22 20:26:26 +0100 |
commit | a06db62288bc3fdbf3f25bcfa046c20510036665 (patch) | |
tree | 5ad510ebc223364f8d8f59f84d5bb8081a2822b1 /src/openglgraphics.h | |
parent | 944b99f3a2e87a080666174dc1e2e2b543519904 (diff) | |
download | mana-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/openglgraphics.h')
-rw-r--r-- | src/openglgraphics.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/openglgraphics.h b/src/openglgraphics.h index 0bb07363..ab08d075 100644 --- a/src/openglgraphics.h +++ b/src/openglgraphics.h @@ -22,16 +22,23 @@ #ifndef OPENGLGRAPHICS_H #define OPENGLGRAPHICS_H +#ifdef USE_OPENGL #include "graphics.h" -#ifdef USE_OPENGL #define NO_SDL_GLEXT #include <SDL_opengl.h> +#include <memory> + +class VideoSettings; + class OpenGLGraphics final : public Graphics { public: + static std::unique_ptr<OpenGLGraphics> create(SDL_Window *window, + const VideoSettings &settings); + OpenGLGraphics(SDL_Window *window, SDL_GLContext glContext); ~OpenGLGraphics() override; @@ -48,7 +55,7 @@ class OpenGLGraphics final : public Graphics void setReduceInputLag(bool reduceInputLag); bool getReduceInputLag() const { return mReduceInputLag; } - void videoResized(int w, int h) override; + void updateSize(int windowWidth, int windowHeight, float scale) override; bool drawImage(Image *image, int srcX, int srcY, @@ -78,8 +85,8 @@ class OpenGLGraphics final : public Graphics void updateScreen() override; - void _beginDraw() override; - void _endDraw() override; + void windowToLogical(int windowX, int windowY, + float &logicalX, float &logicalY) const override; bool pushClipArea(gcn::Rectangle area) override; void popClipArea() override; @@ -118,6 +125,9 @@ class OpenGLGraphics final : public Graphics GLfloat *mFloatTexArray; GLint *mIntTexArray; GLint *mIntVertArray; + float mScale = 1.0f; + float mScaleX = 1.0f; + float mScaleY = 1.0f; bool mAlpha = false; bool mTexture = false; bool mColorAlpha = false; |