mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-23 13:29:12 -06:00
Potential fix for High-DPI and manual framebuffer sizes by using SGCT window scaling
This commit is contained in:
@@ -49,6 +49,7 @@ public:
|
||||
glm::ivec2 currentWindowSize() const override;
|
||||
glm::ivec2 currentWindowResolution() const override;
|
||||
glm::ivec2 currentDrawBufferResolution() const override;
|
||||
glm::vec2 dpiScaling() const override;
|
||||
int currentNumberOfAaSamples() const override;
|
||||
|
||||
bool isRegularRendering() const override;
|
||||
|
||||
@@ -138,6 +138,13 @@ public:
|
||||
* \return The resolution of the currently active window in pixel coordinates
|
||||
*/
|
||||
virtual glm::ivec2 currentDrawBufferResolution() const;
|
||||
|
||||
/**
|
||||
* Returns the DPI scaling factor for the current window. This is normally 1 on all
|
||||
* regular monitors and 2 on Retina screens.
|
||||
* \return The DPI scaling factor for the current window
|
||||
*/
|
||||
virtual glm::vec2 dpiScaling() const;
|
||||
|
||||
/**
|
||||
* Returns the number of anti-aliasing samples used in the current window.
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
bool keyCallback(Key key, KeyModifier modifier, KeyAction action);
|
||||
bool charCallback(unsigned int character, KeyModifier modifier);
|
||||
|
||||
void startFrame(float deltaTime, const glm::vec2& windowSize, const glm::vec2& mousePosCorrectionFactor, const glm::vec2& mousePos, uint32_t mouseButtons);
|
||||
void startFrame(float deltaTime, const glm::vec2& windowSize, const glm::vec2& dpiScaling, const glm::vec2& mousePos, uint32_t mouseButtons);
|
||||
void endFrame();
|
||||
|
||||
void render();
|
||||
|
||||
@@ -406,13 +406,13 @@ void GUI::deinitializeGL() {
|
||||
}
|
||||
|
||||
void GUI::startFrame(float deltaTime, const glm::vec2& windowSize,
|
||||
const glm::vec2& framebufferSize,
|
||||
const glm::vec2& dpiScaling,
|
||||
const glm::vec2& mousePos,
|
||||
uint32_t mouseButtonsPressed)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.DisplaySize = ImVec2(windowSize.x, windowSize.y);
|
||||
io.DisplayFramebufferScale = ImVec2(framebufferSize.x / windowSize.x, framebufferSize.y / windowSize.y);
|
||||
io.DisplayFramebufferScale = ImVec2(dpiScaling.x, dpiScaling.y);
|
||||
io.DeltaTime = deltaTime;
|
||||
|
||||
io.MousePos = ImVec2(mousePos.x, mousePos.y);
|
||||
|
||||
@@ -898,21 +898,13 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
glm::ivec2 windowSize = _windowWrapper->currentWindowSize();
|
||||
glm::ivec2 renderingSize = _windowWrapper->currentWindowResolution();
|
||||
uint32_t mouseButtons = _windowWrapper->mouseButtons(2);
|
||||
|
||||
//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)
|
||||
//);
|
||||
|
||||
//LINFO("DrawBufferResolution: " << std::to_string(drawBufferResolution));
|
||||
//LINFO("Window Size: " << std::to_string(windowSize));
|
||||
|
||||
double dt = _windowWrapper->averageDeltaTime();
|
||||
|
||||
_gui->startFrame(
|
||||
static_cast<float>(dt),
|
||||
glm::vec2(windowSize),
|
||||
glm::vec2(renderingSize),
|
||||
_windowWrapper->dpiScaling(),
|
||||
mousePosition,
|
||||
mouseButtons
|
||||
);
|
||||
|
||||
@@ -120,6 +120,13 @@ glm::ivec2 SGCTWindowWrapper::currentDrawBufferResolution() const {
|
||||
}
|
||||
throw WindowWrapperException("No viewport available");
|
||||
}
|
||||
|
||||
glm::vec2 SGCTWindowWrapper::dpiScaling() const {
|
||||
return glm::vec2(
|
||||
sgct::Engine::instance()->getCurrentWindowPtr()->getXScale(),
|
||||
sgct::Engine::instance()->getCurrentWindowPtr()->getYScale()
|
||||
);
|
||||
}
|
||||
|
||||
int SGCTWindowWrapper::currentNumberOfAaSamples() const {
|
||||
return sgct::Engine::instance()->getCurrentWindowPtr()->getNumberOfAASamples();
|
||||
|
||||
@@ -108,6 +108,10 @@ glm::ivec2 WindowWrapper::currentWindowResolution() const {
|
||||
glm::ivec2 WindowWrapper::currentDrawBufferResolution() const {
|
||||
return currentWindowSize();
|
||||
}
|
||||
|
||||
glm::vec2 WindowWrapper::dpiScaling() const {
|
||||
return glm::vec2(1.f);
|
||||
}
|
||||
|
||||
int WindowWrapper::currentNumberOfAaSamples() const {
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user