-
-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add px_per_unit to GLMakie #2529
Conversation
Compile Times benchmarkNote, that these numbers may fluctuate on the CI servers, so take them with a grain of salt. All benchmark results are based on the mean time and negative percent mean faster than the base branch. Note, that GLMakie + WGLMakie run on an emulated GPU, so the runtime benchmark is much slower. Results are from running: using_time = @ctime using Backend
# Compile time
create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @ctime Makie.colorbuffer(display(fig))
# Runtime
create_time = @benchmark fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @benchmark Makie.colorbuffer(display(fig))
|
Nice! Thank you :) it currently fails during loading though, same error as in CI |
Ok so this doesn't quite solve the problem, yet, as the size of the elements is still too small, although I can now render it at higher quality. Here's an example with In the end, I need the same apparent scaling on a normal dpi monitor with 800x600 pixels, where text is 16px high, just with twice the pixels. |
Should the window just be double the size?l |
Right now it is such that when a retina factor is detected, the window size is reduced by the same factor. For example, 800x600 figure gets a 400x300 size window, backed by a 800x600 pixel buffer. What I really need is a 800x600 window with a 1600x1200 buffer, but with the same "real estate" for the figure as in a non-retina window, just sharper. |
end | ||
return | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the reduction in window size was happening here...
Looking at GLFW docs, there seems to be a retina window hint which we don't have in GLFW.jl
GLFW_COCOA_RETINA_FRAMEBUFFER
specifies whether to use full resolution framebuffers on Retina displays. Possible values areGLFW_TRUE
andGLFW_FALSE
. This is ignored on other platforms.
https://www.glfw.org/docs/latest/window_guide.html
and there is also a compile flag
GLFW_USE_RETINA
determines whether windows will use the full resolution of Retina displays.
https://www.glfw.org/docs/3.1/compile.html
Maybe we also need some changes in GLFW?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think retina is already used correctly, you specify a window size of 400x300 and you get a frame buffer size of 800x600. It's just that the size of everything should be doubled in pixels so that it looks normal.
You can use the retina flag to disable that behavior, then you'd get a pixelated window though, I think.
fb = screen.framebuffer | ||
w, h = size(fb) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also a window hint
GLFW_SCALE_TO_MONITOR
specified whether the window content area should be resized based on the monitor content scale of any monitor it is placed on. This includes the initial placement when the window is created. Possible values are GLFW_TRUE and GLFW_FALSE.
which we do have available. You could try adding it here
Makie.jl/GLMakie/src/screen.jl
Lines 200 to 213 in 2fcee32
windowhints = [ | |
(GLFW.SAMPLES, 0), | |
(GLFW.DEPTH_BITS, 0), | |
# SETTING THE ALPHA BIT IS REALLY IMPORTANT ON OSX, SINCE IT WILL JUST KEEP SHOWING A BLACK SCREEN | |
# WITHOUT ANY ERROR -.- | |
(GLFW.ALPHA_BITS, 8), | |
(GLFW.RED_BITS, 8), | |
(GLFW.GREEN_BITS, 8), | |
(GLFW.BLUE_BITS, 8), | |
(GLFW.STENCIL_BITS, 0), | |
(GLFW.AUX_BUFFERS, 0), | |
] |
If this changes the size of the final framebuffer you will probably need to adjust this to something like 2 .* size(screen)
. (I'm guessing GLFW.GetFramebufferSize(screen.glscreen)
will return the correct size, but it would be better to avoid calling that all the time. If we don't need px_per_unit
we can probably just revert to the old code.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a second monitor to test with, but it sounds reasonable that pixel density should be automatic and depend on the current monitor. Unless you want to override it, or render out hi res pngs.
I found some code that looks like it solves the same problem: https://web.eecs.umich.edu/~sugih/courses/eecs487/glut-howto/glfw/sample.cpp This does the "scaling" that I was talking about if I understand correctly, with the /* Called when framebuffer is resized, e.g., when window is resized
* OR when the same size buffer is moved across Retina and non-Retina displays
* when running Mac OS X.
* NOT called automatically when window is first created.
* Called by GLFW BEFORE reshape().
*/
void
fbreshape(GLFWwindow *wd, int w, int h)
{
/* save new framebuffer dimensions */
fbwidth = w;
fbheight = h;
/* do an orthographic parallel projection with the view volume
set to first quadrant, fixed to the initial window dimension */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, (float)fbwidth, 0.0, (float)fbheight, -1.f, 1.f);
/* Tell OpenGL to use the whole window for drawing.
Note that we don't resize the view volume, so
the viewport will show the whole view volume
shrunk/stretched to fit the current view port. */
glViewport(0, 0, (GLsizei) fbwidth, (GLsizei) fbheight);
init_data();
return;
} |
Closed in favor of #2544 |
Description
This is a prototype for #2522 though I don't have a mac to test anything with. Feel free to mess around with this @jkrumbiegel
The pr adds
px_per_unit
to the GLMakie screen config, which acts as a multiplier between the window size and the framebuffer size. So with this you can have 2x2 pixels per window resolution pixel by doingTODO:
Type of change
Checklist