mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
Add a fix to the window resolution for Retina displays
Add a new setting to the ConfigurationManager that can specify whether to scale the onscreen text by window size or resolution
This commit is contained in:
@@ -97,6 +97,9 @@ public:
|
||||
/// The key that stores the time (in seconds) that the application will wait before
|
||||
/// shutting down after the shutdown call is made
|
||||
static const std::string KeyShutdownCountdown;
|
||||
/// The key that stores whether the onscreen text should be scaled to the window size
|
||||
/// or the window resolution
|
||||
static const std::string KeyOnScreenTextScaling;
|
||||
/// The key that stores whether the master node should perform rendering just function
|
||||
/// as a pure manager
|
||||
static const std::string KeyDisableMasterRendering;
|
||||
|
||||
@@ -190,6 +190,9 @@ public:
|
||||
|
||||
void sortScreenspaceRenderables();
|
||||
|
||||
glm::ivec2 renderingResolution() const;
|
||||
glm::ivec2 fontResolution() const;
|
||||
|
||||
// This is temporary until a proper screenspace solution is found ---abock
|
||||
struct OnScreenInformation{
|
||||
glm::vec2 _position;
|
||||
|
||||
@@ -72,6 +72,8 @@ const string ConfigurationManager::KeyDisableMasterRendering = "DisableRendering
|
||||
const string ConfigurationManager::KeyDownloadRequestURL = "DownloadRequestURL";
|
||||
const string ConfigurationManager::KeyRenderingMethod = "RenderingMethod";
|
||||
|
||||
const string ConfigurationManager::KeyOnScreenTextScaling = "OnScreenTextScaling";
|
||||
|
||||
const string ConfigurationManager::KeyHttpProxy = "HttpProxy";
|
||||
const string ConfigurationManager::PartHttpProxyAddress = "Address";
|
||||
const string ConfigurationManager::PartHttpProxyPort = "Port";
|
||||
|
||||
@@ -295,6 +295,18 @@ Documentation ConfigurationManager::Documentation() {
|
||||
"shutdown is aborted.",
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
ConfigurationManager::KeyOnScreenTextScaling,
|
||||
new StringInListVerifier({
|
||||
// Values from RenderEngine:updateRenderer
|
||||
"window", "framebuffer"
|
||||
}),
|
||||
"The method for scaling the onscreen text in the window. As the resolution "
|
||||
"of the rendering can be different from the size of the window, the onscreen "
|
||||
"text can either be scaled according to the window size (\"window\"), or the "
|
||||
"rendering resolution (\"framebuffer\"). This value defaults to \"window\".",
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
ConfigurationManager::KeyDownloadRequestURL,
|
||||
new OrVerifier(
|
||||
|
||||
@@ -744,7 +744,7 @@ void OpenSpaceEngine::loadFonts() {
|
||||
LERROR("Error initializing default font renderer");
|
||||
|
||||
ghoul::fontrendering::FontRenderer::defaultRenderer().setFramebufferSize(
|
||||
glm::vec2(_windowWrapper->currentWindowSize())
|
||||
_renderEngine->fontResolution()
|
||||
);
|
||||
|
||||
}
|
||||
@@ -898,6 +898,9 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
glm::ivec2 windowSize = _windowWrapper->currentWindowSize();
|
||||
uint32_t mouseButtons = _windowWrapper->mouseButtons(2);
|
||||
|
||||
LINFO("Size" + std::to_string(windowSize));
|
||||
LINFO("Res " + std::to_string(_windowWrapper->currentWindowResolution()));
|
||||
|
||||
//glm::vec2 windowBufferCorrectionFactor = glm::vec2(
|
||||
// static_cast<float>(drawBufferResolution.x) / static_cast<float>(windowSize.x),
|
||||
// static_cast<float>(drawBufferResolution.y) / static_cast<float>(windowSize.y)
|
||||
|
||||
@@ -90,12 +90,20 @@ uint32_t SGCTWindowWrapper::mouseButtons(int maxNumber) const {
|
||||
}
|
||||
|
||||
glm::ivec2 SGCTWindowWrapper::currentWindowSize() const {
|
||||
//return glm::ivec2(sgct::Engine::instance()->getCurrentWindowPtr()->getXResolution(),
|
||||
// sgct::Engine::instance()->getCurrentWindowPtr()->getYResolution());
|
||||
|
||||
return glm::ivec2(sgct::Engine::instance()->getCurrentWindowPtr()->getXResolution(),
|
||||
sgct::Engine::instance()->getCurrentWindowPtr()->getYResolution());
|
||||
}
|
||||
|
||||
glm::ivec2 SGCTWindowWrapper::currentWindowResolution() const {
|
||||
int x,y;
|
||||
//int width, height;
|
||||
//auto window = sgct::Engine::instance()->getCurrentWindowPtr()->getWindowHandle();
|
||||
//glfwGetFramebufferSize(window, &width, &height);
|
||||
//return glm::ivec2(width, height);
|
||||
|
||||
int x, y;
|
||||
sgct::Engine::instance()->getCurrentWindowPtr()->getFinalFBODimensions(x, y);
|
||||
return glm::ivec2(x, y);
|
||||
}
|
||||
|
||||
@@ -315,7 +315,8 @@ void LuaConsole::charCallback(unsigned int codepoint, KeyModifier modifier) {
|
||||
void LuaConsole::render() {
|
||||
const float font_size = 10.0f;
|
||||
|
||||
int ySize = OsEng.windowWrapper().currentWindowSize().y;
|
||||
int ySize = OsEng.renderEngine().fontResolution().y;
|
||||
//int ySize = OsEng.windowWrapper().currentWindowSize().y;
|
||||
//int ySize = OsEng.windowWrapper().viewportPixelCoordinates().w;
|
||||
|
||||
float startY = static_cast<float>(ySize) - 2.0f * font_size;
|
||||
|
||||
@@ -370,11 +370,10 @@ void RenderEngine::updateRenderer() {
|
||||
bool windowResized = OsEng.windowWrapper().windowHasResized();
|
||||
|
||||
if (windowResized) {
|
||||
glm::ivec2 res = OsEng.windowWrapper().currentWindowSize();
|
||||
//glm::ivec2 res = OsEng.windowWrapper().currentDrawBufferResolution();
|
||||
_renderer->setResolution(res);
|
||||
_renderer->setResolution(renderingResolution());
|
||||
|
||||
ghoul::fontrendering::FontRenderer::defaultRenderer().setFramebufferSize(
|
||||
glm::vec2(res)
|
||||
fontResolution()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -387,6 +386,31 @@ void RenderEngine::updateScreenSpaceRenderables() {
|
||||
}
|
||||
}
|
||||
|
||||
glm::ivec2 RenderEngine::renderingResolution() const {
|
||||
if (OsEng.windowWrapper().isRegularRendering()) {
|
||||
return OsEng.windowWrapper().currentWindowResolution();
|
||||
}
|
||||
else {
|
||||
return OsEng.windowWrapper().currentDrawBufferResolution();
|
||||
}
|
||||
}
|
||||
|
||||
glm::ivec2 RenderEngine::fontResolution() const {
|
||||
std::string value;
|
||||
bool hasValue = OsEng.configurationManager().getValue(
|
||||
ConfigurationManager::KeyOnScreenTextScaling,
|
||||
value
|
||||
);
|
||||
if (hasValue && value == "framebuffer") {
|
||||
return OsEng.windowWrapper().currentWindowResolution();
|
||||
}
|
||||
else {
|
||||
// The default is to use the window size
|
||||
return OsEng.windowWrapper().currentWindowSize();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RenderEngine::updateFade() {
|
||||
//temporary fade funtionality
|
||||
float fadedIn = 1.0;
|
||||
@@ -686,14 +710,12 @@ void RenderEngine::postRaycast(ghoul::opengl::ProgramObject& programObject) {
|
||||
* Set renderer
|
||||
*/
|
||||
void RenderEngine::setRenderer(std::unique_ptr<Renderer> renderer) {
|
||||
glm::ivec2 res = OsEng.windowWrapper().currentDrawBufferResolution();
|
||||
|
||||
if (_renderer) {
|
||||
_renderer->deinitialize();
|
||||
}
|
||||
|
||||
_renderer = std::move(renderer);
|
||||
_renderer->setResolution(res);
|
||||
_renderer->setResolution(renderingResolution());
|
||||
_renderer->setNAaSamples(_nAaSamples);
|
||||
_renderer->initialize();
|
||||
_renderer->setCamera(_mainCamera);
|
||||
@@ -1279,7 +1301,8 @@ void RenderEngine::renderInformation() {
|
||||
if (_fontDate) {
|
||||
glm::vec2 penPosition = glm::vec2(
|
||||
10.f,
|
||||
OsEng.windowWrapper().viewportPixelCoordinates().w
|
||||
fontResolution().y
|
||||
//OsEng.windowWrapper().viewportPixelCoordinates().w
|
||||
);
|
||||
penPosition.y -= _fontDate->height();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user