1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00
VVVVVV/desktop_version/src/Screen.h

52 lines
963 B
C
Raw Normal View History

2020-01-01 21:29:24 +01:00
#ifndef SCREEN_H
#define SCREEN_H
#include <SDL.h>
#include "ScreenSettings.h"
2020-01-01 21:29:24 +01:00
class Screen
{
public:
void init(const struct ScreenSettings* settings);
void destroy(void);
2020-01-01 21:29:24 +01:00
void GetSettings(struct ScreenSettings* settings);
void LoadIcon(void);
void ResizeScreen(int x, int y);
void ResizeToNearestMultiple(void);
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-21 04:59:37 +01:00
void GetScreenSize(int* x, int* y);
2020-01-01 21:29:24 +01:00
void UpdateScaling(void);
void RenderPresent(void);
2020-01-01 21:29:24 +01:00
void toggleFullScreen(void);
void toggleScalingMode(void);
void toggleLinearFilter(void);
void toggleVSync(void);
2020-01-01 21:29:24 +01:00
void recacheTextures(void);
bool isForcedFullscreen(void);
int windowDisplay;
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-21 04:59:37 +01:00
int windowWidth;
int windowHeight;
bool isWindowed;
bool isFiltered;
bool badSignalEffect;
int scalingMode;
bool vsync;
2020-01-01 21:29:24 +01:00
SDL_Window *m_window;
SDL_Renderer *m_renderer;
2020-01-01 21:29:24 +01:00
};
#ifndef GAMESCREEN_DEFINITION
extern Screen gameScreen;
#endif
2020-01-01 21:29:24 +01:00
#endif /* SCREEN_H */