mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
Refactor Screen.cpp
to use named constants
No more hardcoded 320s and 240s here.
This commit is contained in:
parent
6fffa5c11d
commit
726b149fbb
1 changed files with 15 additions and 14 deletions
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#include "Constants.h"
|
||||||
#include "FileSystemUtils.h"
|
#include "FileSystemUtils.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "GraphicsUtil.h"
|
#include "GraphicsUtil.h"
|
||||||
|
@ -10,8 +11,8 @@
|
||||||
|
|
||||||
void ScreenSettings_default(struct ScreenSettings* _this)
|
void ScreenSettings_default(struct ScreenSettings* _this)
|
||||||
{
|
{
|
||||||
_this->windowWidth = 320;
|
_this->windowWidth = SCREEN_WIDTH_PIXELS;
|
||||||
_this->windowHeight = 240;
|
_this->windowHeight = SCREEN_HEIGHT_PIXELS;
|
||||||
_this->fullscreen = false;
|
_this->fullscreen = false;
|
||||||
_this->useVsync = true; // Now that uncapped is the default...
|
_this->useVsync = true; // Now that uncapped is the default...
|
||||||
_this->scalingMode = SCALING_INTEGER;
|
_this->scalingMode = SCALING_INTEGER;
|
||||||
|
@ -57,8 +58,8 @@ void Screen::init(const struct ScreenSettings* settings)
|
||||||
// FIXME: This surface should be the actual backbuffer! -flibit
|
// FIXME: This surface should be the actual backbuffer! -flibit
|
||||||
m_screen = SDL_CreateRGBSurface(
|
m_screen = SDL_CreateRGBSurface(
|
||||||
0,
|
0,
|
||||||
320,
|
SCREEN_WIDTH_PIXELS,
|
||||||
240,
|
SCREEN_HEIGHT_PIXELS,
|
||||||
32,
|
32,
|
||||||
0x00FF0000,
|
0x00FF0000,
|
||||||
0x0000FF00,
|
0x0000FF00,
|
||||||
|
@ -69,8 +70,8 @@ void Screen::init(const struct ScreenSettings* settings)
|
||||||
m_renderer,
|
m_renderer,
|
||||||
SDL_PIXELFORMAT_ARGB8888,
|
SDL_PIXELFORMAT_ARGB8888,
|
||||||
SDL_TEXTUREACCESS_STREAMING,
|
SDL_TEXTUREACCESS_STREAMING,
|
||||||
320,
|
SCREEN_WIDTH_PIXELS,
|
||||||
240
|
SCREEN_HEIGHT_PIXELS
|
||||||
);
|
);
|
||||||
|
|
||||||
badSignalEffect = settings->badSignal;
|
badSignalEffect = settings->badSignal;
|
||||||
|
@ -131,8 +132,8 @@ void Screen::LoadIcon(void)
|
||||||
|
|
||||||
void Screen::ResizeScreen(int x, int y)
|
void Screen::ResizeScreen(int x, int y)
|
||||||
{
|
{
|
||||||
static int resX = 320;
|
static int resX = SCREEN_WIDTH_PIXELS;
|
||||||
static int resY = 240;
|
static int resY = SCREEN_HEIGHT_PIXELS;
|
||||||
if (x != -1 && y != -1)
|
if (x != -1 && y != -1)
|
||||||
{
|
{
|
||||||
// This is a user resize!
|
// This is a user resize!
|
||||||
|
@ -182,7 +183,7 @@ void Screen::ResizeScreen(int x, int y)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SDL_RenderSetLogicalSize(m_renderer, 320, 240);
|
SDL_RenderSetLogicalSize(m_renderer, SCREEN_WIDTH_PIXELS, SCREEN_HEIGHT_PIXELS);
|
||||||
int result = SDL_RenderSetIntegerScale(m_renderer, (SDL_bool) (scalingMode == SCALING_INTEGER));
|
int result = SDL_RenderSetIntegerScale(m_renderer, (SDL_bool) (scalingMode == SCALING_INTEGER));
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
|
@ -206,14 +207,14 @@ void Screen::ResizeToNearestMultiple(void)
|
||||||
{
|
{
|
||||||
// Width is bigger, so it's limited by height
|
// Width is bigger, so it's limited by height
|
||||||
usethisdimension = h;
|
usethisdimension = h;
|
||||||
usethisratio = 240;
|
usethisratio = SCREEN_HEIGHT_PIXELS;
|
||||||
using_width = false;
|
using_width = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Height is bigger, so it's limited by width. Or we're exactly 4:3 already
|
// Height is bigger, so it's limited by width. Or we're exactly 4:3 already
|
||||||
usethisdimension = w;
|
usethisdimension = w;
|
||||||
usethisratio = 320;
|
usethisratio = SCREEN_WIDTH_PIXELS;
|
||||||
using_width = true;
|
using_width = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +237,7 @@ void Screen::ResizeToNearestMultiple(void)
|
||||||
if (final_dimension == 0)
|
if (final_dimension == 0)
|
||||||
{
|
{
|
||||||
// We're way too small!
|
// We're way too small!
|
||||||
ResizeScreen(320, 240);
|
ResizeScreen(SCREEN_WIDTH_PIXELS, SCREEN_HEIGHT_PIXELS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,8 +349,8 @@ void Screen::toggleLinearFilter(void)
|
||||||
m_renderer,
|
m_renderer,
|
||||||
SDL_PIXELFORMAT_ARGB8888,
|
SDL_PIXELFORMAT_ARGB8888,
|
||||||
SDL_TEXTUREACCESS_STREAMING,
|
SDL_TEXTUREACCESS_STREAMING,
|
||||||
320,
|
SCREEN_WIDTH_PIXELS,
|
||||||
240
|
SCREEN_HEIGHT_PIXELS
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue