1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-26 14:38:30 +02:00
VVVVVV/desktop_version/src/Screen.h
Misa 54990638fd Persist windowed mode size through fullscreen mode
Previously, the game would not store the size of the window itself, and
would always call SDL_GetRendererOutputSize() (via
Screen::GetWindowSize()) to figure out the size of the window. The only
problem is, this would return the size of the whole monitor if the game
was in fullscreen mode. And the only place where the original windowed
mode size was stored would be in SDL itself, but that wouldn't persist
after the game was closed.

So, if you exited the game while in fullscreen mode, then your window
size would get set to the size of your monitor (1920 by 1080 in my
case). Then when you opened the game and toggled fullscreen off, it
would go back to the default window size, which is 640 by 480.

This is made worse, however, if you were in forced fullscreen mode when
you previously exited the game in windowed mode. In that case, the game
saves the size of 1920 by 1080, but doesn't save that you were in
fullscreen mode, so opening the game not in forced fullscreen mode would
result in you having a 1920 by 1080 window, but in windowed mode.
Meaning that not even fullscreening and unfullscreening would put the
game window back to normal size.

The solution, of course, is to just store the window size ourselves,
like any other screen setting, and only use GetWindowSize() if needed.
And just to make things clear, I've also renamed the GetWindowSize()
function to GetScreenSize(), because if it was named "window" it could
lead one to think that it would always return the size of the screen in
windowed mode, when in fact it returns the size of the screen whatever
mode it is in - fullscreen size if in fullscreen mode and window size if
in windowed mode.

And doing this also fixes the FIXME above Screen::isForcedFullscreen().
2023-03-20 20:59:37 -07:00

51 lines
940 B
C++

#ifndef SCREEN_H
#define SCREEN_H
#include <SDL.h>
#include "ScreenSettings.h"
class Screen
{
public:
void init(const struct ScreenSettings* settings);
void destroy(void);
void GetSettings(struct ScreenSettings* settings);
void LoadIcon(void);
void ResizeScreen(int x, int y);
void ResizeToNearestMultiple(void);
void GetScreenSize(int* x, int* y);
void UpdateScaling(void);
void RenderPresent(void);
void toggleFullScreen(void);
void toggleScalingMode(void);
void toggleLinearFilter(void);
void toggleVSync(void);
void recacheTextures(void);
bool isForcedFullscreen(void);
int windowWidth;
int windowHeight;
bool isWindowed;
bool isFiltered;
bool badSignalEffect;
int scalingMode;
bool vsync;
SDL_Window *m_window;
SDL_Renderer *m_renderer;
};
#ifndef GAMESCREEN_DEFINITION
extern Screen gameScreen;
#endif
#endif /* SCREEN_H */