Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/ps/VideoMode.cpp
Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | m_CursorSurface = SDL_CreateRGBSurfaceFrom(imageBGRA, | ||||
static_cast<int>(t.m_Width), static_cast<int>(t.m_Height), 32, | static_cast<int>(t.m_Width), static_cast<int>(t.m_Height), 32, | ||||
static_cast<int>(t.m_Width * 4), | static_cast<int>(t.m_Width * 4), | ||||
0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); | 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); | ||||
if (!m_CursorSurface) | if (!m_CursorSurface) | ||||
{ | { | ||||
LOGERROR("Can't create surface for cursor: %s", SDL_GetError()); | LOGERROR("Can't create surface for cursor: %s", SDL_GetError()); | ||||
return; | return; | ||||
} | } | ||||
const float scale = g_GuiScale; | const float scale = g_VideoMode.GetScale(); | ||||
if (scale != 1.0) | if (scale != 1.0) | ||||
{ | { | ||||
SDL_Surface* scaledSurface = SDL_CreateRGBSurface(0, | SDL_Surface* scaledSurface = SDL_CreateRGBSurface(0, | ||||
m_CursorSurface->w * scale, | m_CursorSurface->w * scale, | ||||
m_CursorSurface->h * scale, 32, | m_CursorSurface->h * scale, 32, | ||||
0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); | 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); | ||||
if (!scaledSurface) | if (!scaledSurface) | ||||
{ | { | ||||
Show All 28 Lines | |||||
CVideoMode::~CVideoMode() = default; | CVideoMode::~CVideoMode() = default; | ||||
void CVideoMode::ReadConfig() | void CVideoMode::ReadConfig() | ||||
{ | { | ||||
bool windowed = !m_ConfigFullscreen; | bool windowed = !m_ConfigFullscreen; | ||||
CFG_GET_VAL("windowed", windowed); | CFG_GET_VAL("windowed", windowed); | ||||
m_ConfigFullscreen = !windowed; | m_ConfigFullscreen = !windowed; | ||||
CFG_GET_VAL("gui.scale", m_Scale); | |||||
CFG_GET_VAL("xres", m_ConfigW); | CFG_GET_VAL("xres", m_ConfigW); | ||||
CFG_GET_VAL("yres", m_ConfigH); | CFG_GET_VAL("yres", m_ConfigH); | ||||
CFG_GET_VAL("bpp", m_ConfigBPP); | CFG_GET_VAL("bpp", m_ConfigBPP); | ||||
CFG_GET_VAL("display", m_ConfigDisplay); | CFG_GET_VAL("display", m_ConfigDisplay); | ||||
CFG_GET_VAL("hidpi", m_ConfigEnableHiDPI); | CFG_GET_VAL("hidpi", m_ConfigEnableHiDPI); | ||||
CFG_GET_VAL("vsync", m_ConfigVSync); | CFG_GET_VAL("vsync", m_ConfigVSync); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | bool CVideoMode::ResizeWindow(int w, int h) | ||||
m_WindowedW = w; | m_WindowedW = w; | ||||
m_WindowedH = h; | m_WindowedH = h; | ||||
UpdateRenderer(w, h); | UpdateRenderer(w, h); | ||||
return true; | return true; | ||||
} | } | ||||
void CVideoMode::Rescale(float scale) | |||||
{ | |||||
ENSURE(m_IsInitialised); | |||||
m_Scale = scale; | |||||
UpdateRenderer(m_CurrentW, m_CurrentH); | |||||
} | |||||
float CVideoMode::GetScale() const | |||||
{ | |||||
return m_Scale; | |||||
} | |||||
bool CVideoMode::SetFullscreen(bool fullscreen) | bool CVideoMode::SetFullscreen(bool fullscreen) | ||||
{ | { | ||||
// This might get called before initialisation by psDisplayError; | // This might get called before initialisation by psDisplayError; | ||||
// if so then silently fail | // if so then silently fail | ||||
if (!m_IsInitialised) | if (!m_IsInitialised) | ||||
return false; | return false; | ||||
// Check whether this is actually a change | // Check whether this is actually a change | ||||
▲ Show 20 Lines • Show All 208 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator