Changeset View
Changeset View
Standalone View
Standalone View
source/ps/ScreenSize.cpp
- This file was added.
/* Copyright (C) 2019 Wildfire Games. | |||||
* This file is part of 0 A.D. | |||||
* | |||||
* 0 A.D. is free software: you can redistribute it and/or modify | |||||
* it under the terms of the GNU General Public License as published by | |||||
* the Free Software Foundation, either version 2 of the License, or | |||||
* (at your option) any later version. | |||||
* | |||||
* 0 A.D. is distributed in the hope that it will be useful, | |||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
* GNU General Public License for more details. | |||||
* | |||||
* You should have received a copy of the GNU General Public License | |||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | |||||
*/ | |||||
#include "precompiled.h" | |||||
#include "ScreenSize.h" | |||||
#include "renderer/Renderer.h" | |||||
CScreenSize g_ScreenSize; | |||||
void CScreenSize::SetSize(int width, int height) | |||||
{ | |||||
m_LogicalWidth = width; | |||||
m_LogicalHeight = height; | |||||
} | |||||
void CScreenSize::SetGuiScale(float scale) | |||||
{ | |||||
m_GuiScale = scale; | |||||
}; | |||||
void CScreenSize::SetDPIScale(float scale) | |||||
{ | |||||
m_DPIScale = scale; | |||||
}; | |||||
void CScreenSize::SetRendererScale(float scale) | |||||
{ | |||||
m_RendererScale = scale; | |||||
}; | |||||
int CScreenSize::LogicalWidth() | |||||
{ | |||||
return m_LogicalWidth; | |||||
}; | |||||
int CScreenSize::LogicalHeight() | |||||
{ | |||||
return m_LogicalHeight; | |||||
}; | |||||
float CScreenSize::ScreenScale() | |||||
{ | |||||
return m_DPIScale; | |||||
}; | |||||
int CScreenSize::ScreenWidth() | |||||
{ | |||||
return m_LogicalWidth * m_DPIScale; | |||||
}; | |||||
int CScreenSize::ScreenHeight() | |||||
{ | |||||
return m_LogicalHeight * m_DPIScale; | |||||
}; | |||||
float CScreenSize::GuiScale() | |||||
{ | |||||
// The GUI is scaled up automatically on high-DPI screens | |||||
return m_GuiScale * m_DPIScale; | |||||
}; | |||||
int CScreenSize::GuiWidth() | |||||
{ | |||||
return ScreenWidth() / GuiScale(); | |||||
}; | |||||
int CScreenSize::GuiHeight() | |||||
{ | |||||
return ScreenHeight() / GuiScale(); | |||||
}; | |||||
float CScreenSize::RendererScale() | |||||
{ | |||||
// We only support scaling the renderer if we print to framebuffers, i.e. use the post-processor. | |||||
return g_Renderer.m_Options.m_Postproc ? m_RendererScale : 1.0f / m_DPIScale; | |||||
}; | |||||
int CScreenSize::RendererWidth() | |||||
{ | |||||
return LogicalWidth() / RendererScale(); | |||||
}; | |||||
int CScreenSize::RendererHeight() | |||||
{ | |||||
return LogicalHeight() / RendererScale(); | |||||
}; |
Wildfire Games · Phabricator