2020-01-01 21:29:24 +01:00
|
|
|
#ifndef SCREEN_H
|
|
|
|
#define SCREEN_H
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
|
2020-11-13 01:29:11 +01:00
|
|
|
#include "ScreenSettings.h"
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
class Screen
|
|
|
|
{
|
|
|
|
public:
|
2021-12-25 09:18:51 +01:00
|
|
|
void init(const struct ScreenSettings* settings);
|
2021-09-07 03:56:39 +02:00
|
|
|
void destroy(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2021-12-25 09:18:51 +01:00
|
|
|
void GetSettings(struct ScreenSettings* settings);
|
2020-12-22 01:34:16 +01:00
|
|
|
|
2021-09-07 03:56:39 +02:00
|
|
|
void LoadIcon(void);
|
2020-11-01 04:25:27 +01:00
|
|
|
|
2021-09-07 03:56:39 +02:00
|
|
|
void ResizeScreen(int x, int y);
|
|
|
|
void ResizeToNearestMultiple(void);
|
|
|
|
void GetWindowSize(int* x, int* y);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
Always update scaling before rendering
This fixes the following bug that only occurs on Wayland: If the game is
configured to be fullscreened and in stretch mode, on startup, it won't
be in stretch mode. It will appear to be in letterbox mode, but the game
still thinks it's in stretch mode.
This is because during the ResizeScreen() call on startup, for whatever
reason, the window size will be reported to be the default size (640 by
480) instead of the screen resolution of the monitor, as one would
expect from being in fullscreen. It seems like when the game queries the
window size, the window isn't actually in fullscreen at that time, even
though this is after fullscreen has been set to true.
To fix this, I decided to always update the logical size before
SDL_RenderPresent() is called. To make this neater, I put the scaling
code in its own function named UpdateScaling().
This bug has existed since 2.3 and does not occur on X11. I tested this
on GNOME Wayland, and for testing it on X11, I used Openbox in a Xephyr
session while running VVVVVV with SDL_VIDEODRIVER=x11.
2023-03-21 04:31:31 +01:00
|
|
|
void UpdateScaling(void);
|
2023-03-18 23:24:14 +01:00
|
|
|
void RenderPresent(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2021-09-07 03:56:39 +02:00
|
|
|
void toggleFullScreen(void);
|
2021-12-23 04:54:59 +01:00
|
|
|
void toggleScalingMode(void);
|
2021-09-07 03:56:39 +02:00
|
|
|
void toggleLinearFilter(void);
|
2021-09-15 05:23:22 +02:00
|
|
|
void toggleVSync(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2023-01-07 19:28:07 +01:00
|
|
|
void recacheTextures(void);
|
|
|
|
|
2021-12-26 07:55:55 +01:00
|
|
|
bool isForcedFullscreen(void);
|
|
|
|
|
2021-09-07 03:56:39 +02:00
|
|
|
bool isWindowed;
|
|
|
|
bool isFiltered;
|
|
|
|
bool badSignalEffect;
|
2021-12-23 04:54:59 +01:00
|
|
|
int scalingMode;
|
2021-09-07 03:56:39 +02:00
|
|
|
bool vsync;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2021-09-07 03:56:39 +02:00
|
|
|
SDL_Window *m_window;
|
|
|
|
SDL_Renderer *m_renderer;
|
2020-01-01 21:29:24 +01:00
|
|
|
};
|
|
|
|
|
Extern `gameScreen`, remove `screenbuffer`
I know earlier I removed the gameScreen extern in favor of using
screenbuffer, but that was only to be consistent. After further
consideration, I have found that it's actually really stupid.
There's no reason to be accessing it through screenbuffer, and it's
probably an artifact of 2.0-2.2 passing stack-allocated otherwise-global
classes everywhere through function arguments. Also, it leads to stupid
bugs where screenbuffer could potentially be NULL, which has already
resulted in various annoying crashes in the past. Although those could
be fixed by simply initializing screenbuffer at the very top of main(),
but, why not just scrap the whole thing anyway?
So that's what I'm doing.
As a nice side effect, I've removed the transitive include of Screen.h
from Graphics.h. This could've been done already since it only includes
it for the pointer anyway, but it's still good to do it now.
2021-12-25 08:56:47 +01:00
|
|
|
#ifndef GAMESCREEN_DEFINITION
|
|
|
|
extern Screen gameScreen;
|
|
|
|
#endif
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
#endif /* SCREEN_H */
|