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

HiDPI not supported - Win10 + GLCanvas + JDK11 + JOGL2.4 #8

Open
jzy3d opened this issue Nov 9, 2021 · 3 comments
Open

HiDPI not supported - Win10 + GLCanvas + JDK11 + JOGL2.4 #8

jzy3d opened this issue Nov 9, 2021 · 3 comments
Labels
bug Something isn't working Windows

Comments

@jzy3d
Copy link
Owner

jzy3d commented Nov 9, 2021

GL viewport do not occupy the whole panel in this configuration. Similar to a known bug with 2.3.2.

Another JOGL user reported a similar problem with Newt and suggested a workaround with a sample code.

@jzy3d jzy3d added the bug Something isn't working label Nov 9, 2021
@jzy3d jzy3d added the Windows label Dec 8, 2021
@doquang
Copy link

doquang commented Feb 15, 2022

@jzy3d - Do you have any workaround solution for AWT?
I saw a post about it, https://forum.jogamp.org/canvas-not-filling-frame-td4040092.html#a4040138

  • I tested the workaround of farrellf on Nov 09, 2019; 3:59am, but this do not scaling-up the surface. It just make the window fit to the canvas. It also requires GL2(), that somehow do not support on my MacBook.
  • See the post of Karl-Heinz Mali on Dec 29, 2019; 7:59pm, it show the missing of GLCanvas, but it requires to recompile JOGAMP.

@jzy3d
Copy link
Owner Author

jzy3d commented Feb 15, 2022

Hi @doquang , I am currently working on it but at Jzy3D level, not solving the underlying JOGL bug on Win10. The fix I am evaluating is more or less what is discussed by Farelff, with an ability to avoid stretching if HiDPI is actually supported.

I am a bit surprised by the fix suggested by Karl-Heinz, that may mean there is a mess between current and requested pixel ratio, the former being overrided by the maximum pixel ratio. Doing this properly would require to better undestand the whole pixel ratio management. But it's a very interesting direction thanks, for pointing this.

@jzy3d
Copy link
Owner Author

jzy3d commented Mar 16, 2022

Another workaround suggested by @doquang

setLayout(new BorderLayout() {
          @Override
          public void layoutContainer(Container target) {
              synchronized (target.getTreeLock()) {
                  Insets insets = target.getInsets();
                  int top = insets.top;
                  int bottom = target.getHeight() - insets.bottom;
                  int left = insets.left;
                  int right = target.getWidth() - insets.right;

                  Graphics graphics = getGraphics();
                  AffineTransform transform = ((Graphics2D) graphics).getTransform();
                  double scaleX = transform.getScaleX();
                  double scaleY = transform.getScaleY();

                  int width = right - left;
                  int height = bottom - top;
                  width *= scaleX;
                  height *= scaleY;

                  renWin.setBounds(left, top, width, height);
              }
          }
      });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Windows
Projects
None yet
Development

No branches or pull requests

2 participants