Hi All
we are porting an application that already works under Windows and OSX to Linux (Mint) using wxGTK under gtk3. So far everything works surprisingly well with a simple recompilation. But we have a display issue: one of our laptops has a 4K screen, so gtk sets a dispaly scaling of 2. The result is that wxGTK respects the display scaling but OpenGL (more precisely: glViewport) does not. To reproduce
1. open wxFrame with wxGLCanvas
2. set inner size to e.g. 1024px width -> results in scaled frame with 2048 display pixels canvas width
3. open glViewport with the same 1024px -> will open *real* 1024 display pixels unscaled viewport
Result is a OpenGL viewport that fills only the bottom left quarter of the wxGLCanvas.
We can fix the issue by passing the display scaling to all of the OpenGL screen-based operations (eg. glViewport, glScissor) but this is inefficient and error prone. Is there an official way to pass the display scaling to OpenGL (as it apparently happens in Windows and OSX)?
wxGTK + OpenGL + gtk3 + Display Scaling
-
- Earned some good credits
- Posts: 100
- Joined: Sat Oct 26, 2013 11:54 am
-
- Earned some good credits
- Posts: 100
- Joined: Sat Oct 26, 2013 11:54 am
Re: wxGTK + OpenGL + gtk3 + Display Scaling
Edit: i found this issue
https://trac.wxwidgets.org/ticket/17391
https://trac.wxwidgets.org/ticket/17391
-
- Earned some good credits
- Posts: 100
- Joined: Sat Oct 26, 2013 11:54 am
Re: wxGTK + OpenGL + gtk3 + Display Scaling
Interim solution: you can change the GDK scale factor by setting the
GDK_SCALE=1
factor in the environment variables. Using this solution now, since we do not know about the display scaling implications (glViewport and glScissor for sure, not sure about framebuffer objects)
GDK_SCALE=1
factor in the environment variables. Using this solution now, since we do not know about the display scaling implications (glViewport and glScissor for sure, not sure about framebuffer objects)
Re: wxGTK + OpenGL + gtk3 + Display Scaling
In that ticket #17391 you can read that OpenGL knows nothing about the scale of the display. The best way to go is also told there: use const wxSize sizeInPixels = GetClientSize() * GetContentScaleFactor();.
No need to use GDK_SCALE, which will affect also the normal GUI.
Then use that sizeInPixels in all OGL functions that require it: glViewport, FBO, glScissor, glReadPixels, etc.
No need to use GDK_SCALE, which will affect also the normal GUI.
Then use that sizeInPixels in all OGL functions that require it: glViewport, FBO, glScissor, glReadPixels, etc.
-
- Earned some good credits
- Posts: 100
- Joined: Sat Oct 26, 2013 11:54 am
Re: wxGTK + OpenGL + gtk3 + Display Scaling
unfortunately
always reports 1.0, then i replaced it with a direct call to
which seems to work. Is this a bug, shall i report it? wx version is 3.0.4, gtk runtime is 3.22., gtk compile time is 3.22.29
Code: Select all
GetContentScaleFactor();
Code: Select all
gdk_monitor_get_scale_factor( gdk_display_get_monitor (gdk_display_get_default(), 0));
Re: wxGTK + OpenGL + gtk3 + Display Scaling
Fixed two months ago.
https://github.com/wxWidgets/wxWidgets/ ... 5283137a2f
Can you test it (as the patch uses gtk_widget_get_scale_factor() instead of gdk_monitor_get_scale_factor())?
https://github.com/wxWidgets/wxWidgets/ ... 5283137a2f
Can you test it (as the patch uses gtk_widget_get_scale_factor() instead of gdk_monitor_get_scale_factor())?
-
- Earned some good credits
- Posts: 100
- Joined: Sat Oct 26, 2013 11:54 am
Re: wxGTK + OpenGL + gtk3 + Display Scaling
Code: Select all
gtk_widget_get_scale_factor( .. )