-
Notifications
You must be signed in to change notification settings - Fork 462
Description
Hi,
First of all, thanks for all the work on magnum and related projects, hugely useful!
I am in the process of packaging magnum in nixpkgs. Getting it to build and run, including the plugins was not an issue. However I'm running into issues regarding HiDPI scaling in glfw 3.4.0. Considering #243 this seems to be quite a sticky point (no surpises there ^^).
If I link the TriangleExample, against glfw 3.4.0, with Plateform::GlfwApplication, I get a very low resolution window, scaled up multiple times bigger than expected:
Whereas running the same code against the Plateform::Sdl2Application, I get the expected behaviour:
Tested with
add_executable(TriangleExample TriangleExample.cpp)
target_link_libraries(TriangleExample PRIVATE
Magnum::Sdl2Application
# Magnum::GlfwApplication
Magnum::GL
Magnum::Magnum
Magnum::Primitives
Magnum::Shaders
)#include <Magnum/GL/Buffer.h>
#include <Magnum/GL/DefaultFramebuffer.h>
#include <Magnum/GL/Mesh.h>
#include <Magnum/Math/Color.h>
#include <Magnum/Platform/GlfwApplication.h> // or #include <Magnum/Platform/Sdl2Application.h>
#include <Magnum/Shaders/VertexColorGL.h>
#include <iostream>
namespace Magnum { namespace Examples {
class TriangleExample: public Platform::Application {
public:
explicit TriangleExample(const Arguments& arguments);
private:
void drawEvent() override;
void viewportEvent(ViewportEvent & event) override
{
GL::defaultFramebuffer.setViewport({{}, event.framebufferSize()});
std::cout << "windowSize: " << event.windowSize().x() << "x" << event.windowSize().y()
<< ", framebufferSize: " << event.framebufferSize().x() << "x" << event.framebufferSize().y()
<< ", dpiScaling: " << event.dpiScaling().x() << "x" << event.dpiScaling().y() << std::endl;
}
GL::Mesh _mesh;
Shaders::VertexColorGL2D _shader;
};
TriangleExample::TriangleExample(const Arguments& arguments):
Platform::Application{arguments, Configuration{}
.setTitle("Magnum Triangle Example")
.addWindowFlags(Configuration::WindowFlag::Resizable)
}
{
using namespace Math::Literals;
struct TriangleVertex {
Vector2 position;
Color3 color;
};
const TriangleVertex vertices[]{
{{-0.5f, -0.5f}, 0xff0000_rgbf}, /* Left vertex, red color */
{{ 0.5f, -0.5f}, 0x00ff00_rgbf}, /* Right vertex, green color */
{{ 0.0f, 0.5f}, 0x0000ff_rgbf} /* Top vertex, blue color */
};
_mesh.setCount(Containers::arraySize(vertices))
.addVertexBuffer(GL::Buffer{vertices}, 0,
Shaders::VertexColorGL2D::Position{},
Shaders::VertexColorGL2D::Color3{});
}
void TriangleExample::drawEvent() {
GL::defaultFramebuffer.clear(GL::FramebufferClear::Color);
_shader.draw(_mesh);
swapBuffers();
}
}}
MAGNUM_APPLICATION_MAIN(Magnum::Examples::TriangleExample)dpiScalingis reported as1x1in theSDL2case, versus2.97x3in theglfw 3.4case.- I am running on
NixOS 25.11withWayland + Niri compositor.
More visual example from our standalone robot visualizer mc_rtc-magnum built with magnum + imgui:
vs expected:
Both are running on NixOS 25.11, however the difference here is that:
- First screenshot is built from an in-tree version of magnum/glfw, with a much older glfw version from 4 years ago (
~3.3.6): see https://github.com/mc-rtc/mc_rtc-magnum/tree/main/ext for all exact versions used - Second screenshot is built against a standalone version of magnum built against glfw 3.4.0 (as packaged in nixpkgs) (cf PR Modularize - allow system dependencies mc-rtc/mc_rtc-magnum#4)
- same user code otherwise.
Are you aware of similar issues with glfw 3.4.0? What steps can I take to debug this further?
Metadata
Metadata
Assignees
Labels
Projects
Status