Skip to content
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

Canvas width and height is not reported correctly for OpenGL Viewport #53

Open
pengiie opened this issue Oct 18, 2021 · 4 comments
Open
Labels

Comments

@pengiie
Copy link

pengiie commented Oct 18, 2021

On Windows when I create an OpenGL Canvas. If Windows Display Scaling is not 100%, if you set glViewport to the canvas's width and height, it will be incorrect.
Screenshot_3

I set the clear color to red to make it easier to see, this is when the scaling is set to 125% and the viewport is the reported canvas width and height.
Screenshot_1

@httpdigest
Copy link
Member

Thanks for reporting. Can reproduce.
According to https://kynosarges.org/GuiDpiScaling.html a fix is to do the following:

java.awt.geom.AffineTransform t = canvas.getGraphicsConfiguration().getDefaultTransform();
float sx = (float) t.getScaleX(), sy = (float) t.getScaleY();
int viewportWidth = (int) (getWidth() * sx);
int viewportHeight = (int) (getHeight() * sy);

The default transform of the graphics configuration of the canvas will provide the scale factor.
We could add a corresponding e.g. getFramebufferWidth/Height() to the GLCanvas which does this.

@httpdigest httpdigest added the bug label Oct 18, 2021
httpdigest added a commit that referenced this issue Oct 18, 2021
to handle desktop/graphics configuration scaling.
@eduramiba
Copy link

This bug happens with the latest snapshot, should it still happen?

Only on windows, in the same machine but linux works fine.

Thanks!!
Eduardo

@eduramiba
Copy link

Sorry I was still using getWidth instead of getFramebufferWidth, it works perfect, thanks!

@hageldave
Copy link
Contributor

hageldave commented Apr 7, 2022

This is not yet deployed to maven, the latest build on maven central is from January 2021. Is it possible to do a deployment with these changes included?

edit:
oh, it is deployed as snapshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants