-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[core] HighDPI not considered while using RenderTexture #1086
Comments
I love the idea of exposing the DPI to the user. I ran into this issue, and am working off a fork that exposes this info via float GetWindowDPI(void). I found it necessary for recreating the render texture when the window is moved to a new monitor with a different DPI or when the window is resized. |
Just for reference, glfwGetMonitorContentScale() is the related function. |
Hmmm. I was going to try and do this, but I'm getting an error. Here is what I have done to try and expose the dpi. core.c
And here is the error I get when calling the function from my code.
Any ideas? @jozanza would you mind sharing your implementation in your fork? |
Success! Sorry I figured it out. I was passing the window handle. The glfwGetMonitorContentScale() actually was expecting a monitor pointer. Heres my final code which is working:
|
I think it is better:
|
@raysan5 thanks for this! Ive been toying around with both Raylib and SDL2. What I'm trying to accomplish is actually handled in one line in SDL2. SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h) Im not sure how it would translate to Raylib, but below you can see description of the function which explains what Id like to do.
|
@ismyhc it seems similar to example |
Hey @raysan5. I had an issue that may be related. First I turned off the following in libs/raylib/src/core.c: With this removed, I get the following behaviour:
b) Buttons still work as though the screen is full size. c) Moving the window sets everything back right again! I fixed this issue by messing with glfw: In libs/raylib/src/external/glfw/src/cocoa_window.m
|
@TakUnderhand Thanks for reporting! I'm afraid behaviour could be dependant of macOS version as well as retina display... but, in any case, your solution points to GLFW library, maybe that issue could also be asked on their repo to make it available for all the users. Also, note that current GLFW version used in raylib is about 4 month old, maybe something changed on GLFW side on that time. |
Thanks :) |
@TakUnderhand Thank you very much for your time an effort! This issue has been open for some time, it would be great to find a proper fix! :) |
Not sure how helpful this is, but I wrote a hack to allow me to drag a window between monitors that "mostly" works: https://gist.github.com/mattj1/606a94527badb6ffa7d22245c9b745b1 (I'm on a Mac, btw) Note: GLFW is required, and you have to specify your viewport size to rlViewport. |
hi @mattj1! Thank you very much for the git! I'm reviewing it! |
Cheers, this helped me a lot. Thanks! |
i use another approach, i send this flag directly, i will send code in my fork soon |
this is because of call SetViewport with incorrect screen widths and heights, on HiDPI systems, render width is often not equals to screen width, so GetWindowScaleDPI willl return {2.0f, 2.0f} not {1.0f, 1.0f} |
I am seeing something like this too, but on Linux on a hidpi screen |
Finally I opt for the option of letting the user manage the |
This issue is directly related to #837.
When creating a RenderTexture on a HighDPI application:
GetScreenWidth()
andGetScreenHeight()
actually return the original screen size requested by the user, despite that everything drawn is scaled to match HighDPI. So, we end up with a RenderTexture smaller than the actual render size.One possible solution would be to consider the
scaleFactor
directly onGetScreenWidth()
andGetScreenHeight()
but if those calls are used in game logic for some maths it will lend to logic errors, because scaling is done automatically only on drawing.Another solution would be directly exposing the
HighDPI scaleFactor
and let the user manage everything.Feedback is welcome!
The text was updated successfully, but these errors were encountered: