diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-02-27 10:51:33 +0000 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-02-27 10:51:33 +0000 |
commit | 254c3db4a39aa35274fd7cd4ec2cccde5b92d71b (patch) | |
tree | 01c1b5ad71794c02b03d9c45f2c4b5043bc03163 /src/sdlgraphics.h | |
parent | 81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08 (diff) | |
download | mana-254c3db4a39aa35274fd7cd4ec2cccde5b92d71b.tar.gz mana-254c3db4a39aa35274fd7cd4ec2cccde5b92d71b.tar.bz2 mana-254c3db4a39aa35274fd7cd4ec2cccde5b92d71b.tar.xz mana-254c3db4a39aa35274fd7cd4ec2cccde5b92d71b.zip |
Added VSync and windowed fullscreen options
The configuration and setup UI were adjusted to the new options.
This also fixes issues in applying new video settings.
Default resolution was changed from 800x600 to 1280x720. VSync is
enabled by default while FPS limit was disabled.
Display aspect ratio for the resolution options.
I had to work around some macOS issues:
* Don't change window size when it appears to be "maximized", since it
just changes the rendering area while leaving the window maximized.
* Unset fullscreen display mode temporarily to allow changing resolutions,
otherwise the rendering area no longer matches the screen and mouse
input is also off.
* Removed SDL_WINDOW_ALLOW_HIGHDPI for now because it causes issues on
macOS, since we're not actually handling the scaling factor.
A Video class and an SDLGraphics subclass were split off from Graphics.
This setup has Less duplication and leaves the OpenGLGraphics and
SDLGraphics better separated.
Fixes #57
Fixes #58
Diffstat (limited to 'src/sdlgraphics.h')
-rw-r--r-- | src/sdlgraphics.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/sdlgraphics.h b/src/sdlgraphics.h new file mode 100644 index 00000000..6685fc83 --- /dev/null +++ b/src/sdlgraphics.h @@ -0,0 +1,73 @@ +/* + * The Mana Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2012 The Mana Developers + * + * This file is part of The Mana Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef SDLGRAPHICS_H +#define SDLGRAPHICS_H + +#include "graphics.h" + +class SDLGraphics final : public Graphics +{ +public: + SDLGraphics(SDL_Window *window, SDL_Renderer *renderer); + ~SDLGraphics() override; + + void setVSync(bool sync) override; + + void videoResized(int w, int h) override; + + bool drawRescaledImage(Image *image, + int srcX, int srcY, + int dstX, int dstY, + int width, int height, + int desiredWidth, int desiredHeight, + bool useColor) override; + + void drawRescaledImagePattern(Image *image, + int x, int y, + int w, int h, + int scaledWidth, + int scaledHeight) override; + + void updateScreen() override; + + SDL_Surface *getScreenshot() override; + + bool pushClipArea(gcn::Rectangle area) override; + + void popClipArea() override; + + void drawPoint(int x, int y) override; + + void drawLine(int x1, int y1, int x2, int y2) override; + + void drawRectangle(const gcn::Rectangle &rectangle) override; + + void fillRectangle(const gcn::Rectangle &rectangle) override; + +private: + void updateSDLClipRect(); + + SDL_Window *mWindow = nullptr; + SDL_Renderer *mRenderer = nullptr; +}; + +#endif // SDLGRAPHICS_H |