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)
dpiScaling is reported as 1x1 in the SDL2 case, versus 2.97x3 in the glfw 3.4 case.
- I am running on
NixOS 25.11 with Wayland + 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:
Are you aware of similar issues with glfw 3.4.0? What steps can I take to debug this further?
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, againstglfw 3.4.0, withPlateform::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
dpiScalingis reported as1x1in theSDL2case, versus2.97x3in theglfw 3.4case.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:
~3.3.6): see https://github.com/mc-rtc/mc_rtc-magnum/tree/main/ext for all exact versions usedAre you aware of similar issues with
glfw 3.4.0? What steps can I take to debug this further?