diff options
author | Sven Gothel <[email protected]> | 2014-05-21 08:53:54 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-05-21 08:53:54 +0200 |
commit | f9a00b91dcd146c72a50237b62270f33bd0da98e (patch) | |
tree | f4387da868608cea5066ce3a8cb9039a16b529de /src/jogl/classes | |
parent | 0ffba122ea5c4b8cc247234ca9f48ccfcce833cd (diff) |
Bug 742 HiDPI: [Core API Change] Distinguish window-units and pixel-units; Add HiDPI for AWT GLCanvas w/ OSX CALayer
Core API Change:
To support HiDPI thoroughly in JOGL (NativeWindow, JOGL, NEWT)
we need to separate window- and pixel units.
NativeWindow and NativeSurface now have distinguished
access methods for window units and pixel units.
NativeWindow: Using window units
- getWindowWidth() * NEW Method *
- getWindowHeight() * NEW Method *
- getX(), getY(), ...
NativeSurface: Using pixel units
- getWidth() -> getSurfaceWidth() * RENAMED *
- getHeight() -> getSurfaceHeight() * RENAMED *
GLDrawable: Using pixel units
- getWidth() -> getSurfaceWidth() * RENAMED, aligned w/ NativeSurface *
- getHeight() -> getSurfaceHeight() * RENAMED, aligned w/ NativeSurface *
Above changes also removes API collision w/ other windowing TK,
e.g. AWT's getWidth()/getHeight() in GLCanvas
and the same method names in GLDrawable before this change.
+++
Now preliminary 'working':
- AWT GLCanvas
- AWT GLJPanel
Tested manually on OSX w/ and w/o HiDPI Retina:
java com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT -manual -noanim -time 1000000
java com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT -manual -noanim -time 1000000
+++
TODO:
- NEWT
- Change Window.setSize(..) to use pixel units ?
- OSX HiDPI support
- Testing ..
- API refinement
Diffstat (limited to 'src/jogl/classes')
27 files changed, 211 insertions, 171 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java b/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java index 1b4187668..299e51532 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java +++ b/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java @@ -408,7 +408,7 @@ public class GLEventListenerState { public static GLRunnable setViewport = new GLRunnable() { @Override public boolean run(GLAutoDrawable drawable) { - drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); + drawable.getGL().glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); return true; } }; @@ -428,7 +428,7 @@ public class GLEventListenerState { } @Override public boolean run(GLAutoDrawable drawable) { - listener.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); + listener.reshape(drawable, 0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); return true; } } diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index cd5aa338d..1c6dced6a 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -455,12 +455,12 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS public final void destroy(ProxySurface s) { /* nop */ } @Override - public final int getWidth(ProxySurface s) { + public final int getPixelWidth(ProxySurface s) { return clientArea.width; } @Override - public final int getHeight(ProxySurface s) { + public final int getPixelHeight(ProxySurface s) { return clientArea.height; } @@ -689,12 +689,12 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS } @Override - public int getWidth() { + public int getSurfaceWidth() { return clientArea.width; } @Override - public int getHeight() { + public int getSurfaceHeight() { return clientArea.height; } @@ -984,15 +984,15 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS @Override public String toString() { final GLDrawable _drawable = drawable; - final int dw = (null!=_drawable) ? _drawable.getWidth() : -1; - final int dh = (null!=_drawable) ? _drawable.getHeight() : -1; + final int dw = (null!=_drawable) ? _drawable.getSurfaceWidth() : -1; + final int dh = (null!=_drawable) ? _drawable.getSurfaceHeight() : -1; return "SWT-GLCanvas[Realized "+isRealized()+ ",\n\t"+((null!=_drawable)?_drawable.getClass().getName():"null-drawable")+ ",\n\tFactory "+getFactory()+ ",\n\thandle "+toHexString(getHandle())+ ",\n\tDrawable size "+dw+"x"+dh+ - ",\n\tSWT size "+getWidth()+"x"+getHeight()+"]"; + ",\n\tSWT size "+getSurfaceWidth()+"x"+getSurfaceHeight()+"]"; } public static void main(final String[] args) { diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java index 25a012bb9..2b4795aaa 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java @@ -154,13 +154,13 @@ public class GLReadBufferUtil { public boolean readPixels(GL gl, int inX, int inY, int inWidth, int inHeight, boolean mustFlipVertically) { final GLDrawable drawable = gl.getContext().getGLReadDrawable(); final int width, height; - if( 0 >= inWidth || drawable.getWidth() < inWidth ) { - width = drawable.getWidth(); + if( 0 >= inWidth || drawable.getSurfaceWidth() < inWidth ) { + width = drawable.getSurfaceWidth(); } else { width = inWidth; } - if( 0 >= inHeight || drawable.getHeight() < inHeight ) { - height = drawable.getHeight(); + if( 0 >= inHeight || drawable.getSurfaceHeight() < inHeight ) { + height = drawable.getSurfaceHeight(); } else { height= inHeight; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java index 9490e041b..3c5d6be2d 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java @@ -87,13 +87,13 @@ public class AWTGLReadBufferUtil extends GLReadBufferUtil { public BufferedImage readPixelsToBufferedImage(GL gl, int inX, int inY, int inWidth, int inHeight, boolean awtOrientation) { final GLDrawable drawable = gl.getContext().getGLReadDrawable(); final int width, height; - if( 0 >= inWidth || drawable.getWidth() < inWidth ) { - width = drawable.getWidth(); + if( 0 >= inWidth || drawable.getSurfaceWidth() < inWidth ) { + width = drawable.getSurfaceWidth(); } else { width = inWidth; } - if( 0 >= inHeight || drawable.getHeight() < inHeight ) { - height = drawable.getHeight(); + if( 0 >= inHeight || drawable.getSurfaceHeight() < inHeight ) { + height = drawable.getSurfaceHeight(); } else { height= inHeight; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java b/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java index 931f59869..1ad7b9987 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java @@ -119,7 +119,7 @@ public class Overlay { */ public void drawAll() throws GLException { beginRendering(); - draw(0, 0, drawable.getWidth(), drawable.getHeight()); + draw(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); endRendering(); } @@ -130,7 +130,7 @@ public class Overlay { @throws GLException If an OpenGL context is not current when this method is called */ public void beginRendering() throws GLException { - renderer.beginOrthoRendering(drawable.getWidth(), drawable.getHeight()); + renderer.beginOrthoRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); } /** Ends the OpenGL rendering process for the overlay. This is @@ -198,13 +198,13 @@ public class Overlay { private void validateRenderer() { if (renderer == null) { - renderer = new TextureRenderer(drawable.getWidth(), - drawable.getHeight(), + renderer = new TextureRenderer(drawable.getSurfaceWidth(), + drawable.getSurfaceHeight(), true); contentsLost = true; - } else if (renderer.getWidth() != drawable.getWidth() || - renderer.getHeight() != drawable.getHeight()) { - renderer.setSize(drawable.getWidth(), drawable.getHeight()); + } else if (renderer.getWidth() != drawable.getSurfaceWidth() || + renderer.getHeight() != drawable.getSurfaceHeight()) { + renderer.setSize(drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); contentsLost = true; } else { contentsLost = false; diff --git a/src/jogl/classes/javax/media/opengl/GLDrawable.java b/src/jogl/classes/javax/media/opengl/GLDrawable.java index 3c354a240..e93d1c3ad 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawable.java @@ -140,11 +140,17 @@ public interface GLDrawable { */ public boolean isRealized(); - /** Returns the current width of this GLDrawable. */ - public int getWidth(); + /** + * Returns the width of this {@link GLDrawable}'s {@link #getNativeSurface() surface} client area in pixel units. + * @see NativeSurface#getSurfaceWidth() + */ + public int getSurfaceWidth(); - /** Returns the current height of this GLDrawable. */ - public int getHeight(); + /** + * Returns the height of this {@link GLDrawable}'s {@link #getNativeSurface() surface} client area in pixel units. + * @see NativeSurface#getSurfaceHeight() + */ + public int getSurfaceHeight(); /** * Returns <code>true</code> if the drawable is rendered in diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 09589080f..c5ce32827 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -101,6 +101,7 @@ import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.util.GLDrawableUtil; import com.jogamp.opengl.util.TileRenderer; +import jogamp.nativewindow.jawt.JAWTUtil; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableHelper; @@ -167,6 +168,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private volatile JAWTWindow jawtWindow; // the JAWTWindow presentation of this AWT Canvas, bound to the 'drawable' lifecycle private volatile GLContextImpl context; // volatile: avoid locking for read-only access private volatile boolean sendReshape = false; // volatile: maybe written by EDT w/o locking + private volatile int pixelScale; // copy of the cstr args, mainly for recreation private final GLCapabilitiesImmutable capsReqUser; @@ -307,6 +309,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing this.addHierarchyListener(hierarchyListener); this.isShowing = isShowing(); + this.pixelScale = 1; } @Override @@ -378,7 +381,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing * otherwise it is from an ancestor component that this Canvas is being * added to, and we go into this block. */ - GraphicsConfiguration chosen = awtConfig.getAWTGraphicsConfiguration(); + GraphicsConfiguration chosen = null != awtConfig ? awtConfig.getAWTGraphicsConfiguration() : null; if (gc != null && chosen != null && !chosen.equals(gc)) { /* @@ -487,7 +490,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing try { final GLDrawable _drawable = drawable; if( null == _drawable || realized == _drawable.isRealized() || - realized && ( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) ) { + realized && ( 0 >= _drawable.getSurfaceWidth() || 0 >= _drawable.getSurfaceHeight() ) ) { return; } _drawable.setRealized(realized); @@ -665,6 +668,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing try { drawable = (GLDrawableImpl) GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow); createContextImpl(drawable); + pixelScale = jawtWindow.getPixelScale(); } finally { jawtWindow.unlockSurface(); } @@ -696,7 +700,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing boolean res = _drawable.isRealized(); if( !res ) { // re-try drawable creation - if( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) { + if( 0 >= _drawable.getSurfaceWidth() || 0 >= _drawable.getSurfaceHeight() ) { return false; // early out! } setRealized(true); @@ -760,10 +764,17 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing synchronized (getTreeLock()) { // super.reshape(..) claims tree lock, so we do extend it's lock over reshape super.reshape(x, y, width, height); + final int scale = getPixelScale(); + final int scaledWidth = scale * width; + final int scaledHeight = scale * height; + if(DEBUG) { final NativeSurface ns = getNativeSurface(); final long nsH = null != ns ? ns.getSurfaceHandle() : 0; - System.err.println("GLCanvas.sizeChanged: ("+getThreadName()+"): "+width+"x"+height+" - surfaceHandle 0x"+Long.toHexString(nsH)); + System.err.println(getThreadName()+": GLCanvas.reshape.0 "+this.getName()+" resize"+(printActive?"WithinPrint":"")+ + " [ this "+getWidth()+"x"+getHeight()+", pixelScale "+scale+ + "] -> "+(printActive?"[skipped] ":"") + width+"x"+height+" * "+scale+" -> "+scaledWidth+"x"+scaledHeight+ + " - surfaceHandle 0x"+Long.toHexString(nsH)); // Thread.dumpStack(); } if( validateGLDrawable() && !printActive ) { @@ -772,7 +783,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final RecursiveLock _lock = lock; _lock.lock(); try { - final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, context, width, height); + final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, context, scaledWidth, scaledHeight); if(_drawable != _drawableNew) { // write back drawable = _drawableNew; @@ -835,15 +846,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final int printNumSamples = printAWTTiles.getNumSamples(caps); GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); - final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || - printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); + final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getSurfaceWidth() || + printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getSurfaceHeight(); final boolean reqNewGLADOnscrn = caps.isOnscreen(); // It is desired to use a new offscreen GLAD, however Bug 830 forbids this for AA onscreen context. // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX final boolean reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ); if( DEBUG ) { System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ - ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ + ", drawableSize "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+ ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); @@ -863,13 +874,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing printDrawable = printGLAD.getDelegatedDrawable(); } printAWTTiles.setGLOrientation(printGLAD.isGLOriented(), printGLAD.isGLOriented()); - printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); + printAWTTiles.renderer.setTileSize(printDrawable.getSurfaceWidth(), printDrawable.getSurfaceHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); if( DEBUG ) { System.err.println("AWT print.setup "+printAWTTiles); System.err.println("AWT print.setup AA "+printNumSamples+", "+caps); - System.err.println("AWT print.setup printGLAD: "+printGLAD.getWidth()+"x"+printGLAD.getHeight()+", "+printGLAD); - System.err.println("AWT print.setup printDraw: "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+", "+printDrawable); + System.err.println("AWT print.setup printGLAD: "+printGLAD.getSurfaceWidth()+"x"+printGLAD.getSurfaceHeight()+", "+printGLAD); + System.err.println("AWT print.setup printDraw: "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+", "+printDrawable); } } }; @@ -1122,6 +1133,16 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } @Override + public int getSurfaceWidth() { + return getWidth() * getPixelScale(); + } + + @Override + public int getSurfaceHeight() { + return getHeight() * getPixelScale(); + } + + @Override public boolean isGLOriented() { final GLDrawable _drawable = drawable; return null != _drawable ? _drawable.isGLOriented() : true; @@ -1148,23 +1169,25 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public String toString() { final GLDrawable _drawable = drawable; - final int dw = (null!=_drawable) ? _drawable.getWidth() : -1; - final int dh = (null!=_drawable) ? _drawable.getHeight() : -1; + final int dw = (null!=_drawable) ? _drawable.getSurfaceWidth() : -1; + final int dh = (null!=_drawable) ? _drawable.getSurfaceHeight() : -1; return "AWT-GLCanvas[Realized "+isRealized()+ ",\n\t"+((null!=_drawable)?_drawable.getClass().getName():"null-drawable")+ ",\n\tFactory "+getFactory()+ ",\n\thandle 0x"+Long.toHexString(getHandle())+ - ",\n\tDrawable size "+dw+"x"+dh+ - ",\n\tAWT pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ + ",\n\tDrawable size "+dw+"x"+dh+" surface["+getSurfaceWidth()+"x"+getSurfaceHeight()+"]"+ + ",\n\tAWT[pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ ",\n\tvisible "+isVisible()+", displayable "+isDisplayable()+", showing "+isShowing+ - ",\n\t"+awtConfig+"]"; + ",\n\t"+awtConfig+"]]"; } //---------------------------------------------------------------------- // Internals only below this point // + private final int getPixelScale() { return pixelScale; } + private final Runnable destroyOnEDTAction = new Runnable() { @Override public void run() { @@ -1247,6 +1270,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } jawtWindow=null; } + pixelScale = 1; if(null != awtConfig) { final AbstractGraphicsConfiguration aconfig = awtConfig.getNativeGraphicsConfiguration(); @@ -1278,11 +1302,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void run() { if (sendReshape) { if(DEBUG) { - System.err.println(getThreadName()+": Reshape: "+getWidth()+"x"+getHeight()); + System.err.println(getThreadName()+": Reshape: "+getSurfaceWidth()+"x"+getSurfaceHeight()); } // Note: we ignore the given x and y within the parent component // since we are drawing directly into this heavyweight component. - helper.reshape(GLCanvas.this, 0, 0, getWidth(), getHeight()); + helper.reshape(GLCanvas.this, 0, 0, getSurfaceWidth(), getSurfaceHeight()); sendReshape = false; } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 8bcf97ba1..65b61d3aa 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -175,8 +175,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private static final boolean USE_GLSL_TEXTURE_RASTERIZER; private static final boolean SKIP_VERTICAL_FLIP_DEFAULT; - private static final boolean SKIP_HIDPI; - /** Indicates whether the Java 2D OpenGL pipeline is requested by user. */ private static final boolean java2dOGLEnabledByProp; @@ -192,7 +190,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing DEBUG_VIEWPORT = Debug.isPropertyDefined("jogl.debug.GLJPanel.Viewport", true); USE_GLSL_TEXTURE_RASTERIZER = !Debug.isPropertyDefined("jogl.gljpanel.noglsl", true); SKIP_VERTICAL_FLIP_DEFAULT = Debug.isPropertyDefined("jogl.gljpanel.noverticalflip", true); - SKIP_HIDPI = Debug.isPropertyDefined("jogl.gljpanel.nohidpi", true); boolean enabled = Debug.getBooleanProperty("sun.java2d.opengl", false); java2dOGLEnabledByProp = enabled && !Debug.isPropertyDefined("jogl.gljpanel.noogl", true); @@ -247,15 +244,15 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private boolean handleReshape = false; private boolean sendReshape = true; + private volatile int pixelScale; + // For handling reshape events lazily: reshapeWidth -> panelWidth -> backend.width private int reshapeWidth; private int reshapeHeight; - private int reshapeScale; // Width of the actual GLJPanel: reshapeWidth -> panelWidth -> backend.width private int panelWidth = 0; private int panelHeight = 0; - private int panelScale = 0; // These are always set to (0, 0) except when the Java2D / OpenGL // pipeline is active @@ -371,6 +368,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing this.setFocusable(true); // allow keyboard input! this.addHierarchyListener(hierarchyListener); this.isShowing = isShowing(); + this.pixelScale = 1; } /** @@ -485,6 +483,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing animator.resume(); } } + pixelScale = 1; if(DEBUG) { System.err.println(getThreadName()+": GLJPanel.dispose() - stop"); @@ -563,8 +562,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing public void addNotify() { super.addNotify(); awtWindowClosingProtocol.addClosingListener(); + { + final int s = JAWTUtil.getPixelScale(this); + pixelScale = 0 < s ? s : 1; + } if (DEBUG) { - System.err.println(getThreadName()+": GLJPanel.addNotify()"); + System.err.println(getThreadName()+": GLJPanel.addNotify()"); } } @@ -607,7 +610,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if( !printActive ) { reshapeWidth = scaledWidth; reshapeHeight = scaledHeight; - reshapeScale = scale; handleReshape = true; } } @@ -657,12 +659,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing final int printNumSamples = printAWTTiles.getNumSamples(caps); GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); - final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || - printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); + final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getSurfaceWidth() || + printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getSurfaceHeight(); final boolean reqNewGLAD = reqNewGLADSamples || reqNewGLADSize ; if( DEBUG ) { System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ - ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ + ", drawableSize "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+ ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); @@ -680,13 +682,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing printDrawable = printGLAD.getDelegatedDrawable(); } printAWTTiles.setGLOrientation( !GLJPanel.this.skipGLOrientationVerticalFlip && printGLAD.isGLOriented(), printGLAD.isGLOriented() ); - printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); + printAWTTiles.renderer.setTileSize(printDrawable.getSurfaceWidth(), printDrawable.getSurfaceHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); if( DEBUG ) { System.err.println("AWT print.setup "+printAWTTiles); System.err.println("AWT print.setup AA "+printNumSamples+", "+caps); - System.err.println("AWT print.setup printGLAD: "+printGLAD.getWidth()+"x"+printGLAD.getHeight()+", "+printGLAD); - System.err.println("AWT print.setup printDraw: "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+", "+printDrawable); + System.err.println("AWT print.setup printGLAD: "+printGLAD.getSurfaceWidth()+"x"+printGLAD.getSurfaceHeight()+", "+printGLAD); + System.err.println("AWT print.setup printDraw: "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+", "+printDrawable); } } }; @@ -727,16 +729,15 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing final int scaledAWTHeight= scale * awtHeight; final GLDrawable drawable = GLJPanel.this.getDelegatedDrawable(); if( scaledAWTWidth != panelWidth || scaledAWTHeight != panelHeight || - drawable.getWidth() != panelWidth || drawable.getHeight() != panelHeight ) { + drawable.getSurfaceWidth() != panelWidth || drawable.getSurfaceHeight() != panelHeight ) { // -> !( awtSize == panelSize == drawableSize ) if ( DEBUG ) { - System.err.println(getThreadName()+": GLJPanel.releasePrintOnEDT.0: resizeWithinPrint panel " +panelWidth+"x"+panelHeight + " @ scale "+panelScale+ - ", draw "+drawable.getWidth()+"x"+drawable.getHeight()+ + System.err.println(getThreadName()+": GLJPanel.releasePrintOnEDT.0: resizeWithinPrint panel " +panelWidth+"x"+panelHeight + " @ scale "+getPixelScale()+ + ", draw "+drawable.getSurfaceWidth()+"x"+drawable.getSurfaceHeight()+ " -> " + awtWidth+"x"+awtHeight+" * "+scale+" -> "+scaledAWTWidth+"x"+scaledAWTHeight); } reshapeWidth = scaledAWTWidth; reshapeHeight = scaledAWTHeight; - reshapeScale = scale; sendReshape = handleReshape(); // reshapeSize -> panelSize, backend reshape w/ GL reshape } else { sendReshape = true; // only GL reshape @@ -1017,6 +1018,16 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return oglPipelineUsable(); } + @Override + public int getSurfaceWidth() { + return getWidth() * getPixelScale(); + } + + @Override + public int getSurfaceHeight() { + return getHeight() * getPixelScale(); + } + /** * {@inheritDoc} * <p> @@ -1142,15 +1153,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if (DEBUG) { System.err.println(getThreadName()+": GLJPanel.createAndInitializeBackend: " + - panelWidth+"x"+panelHeight+" @ scale "+panelScale + " -> " + - reshapeWidth+"x"+reshapeHeight+" @ scale "+reshapeScale); + panelWidth+"x"+panelHeight+" @ scale "+getPixelScale() + " -> " + + reshapeWidth+"x"+reshapeHeight+" @ scale "+getPixelScale()); } // Pull down reshapeWidth and reshapeHeight into panelWidth and // panelHeight eagerly in order to complete initialization, and // force a reshape later panelWidth = reshapeWidth; panelHeight = reshapeHeight; - panelScale = reshapeScale; } if ( null == backend ) { @@ -1172,14 +1182,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } } - protected final int getPixelScale() { - if( SKIP_HIDPI ) { - return 1; - } else { - final int s = JAWTUtil.getPixelScale(this); - return 0 < s ? s : 1; - } - } + private final int getPixelScale() { return pixelScale; } @Override public WindowClosingMode getDefaultCloseOperation() { @@ -1194,12 +1197,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private boolean handleReshape() { if (DEBUG) { System.err.println(getThreadName()+": GLJPanel.handleReshape: "+ - panelWidth+"x"+panelHeight+" @ scale "+panelScale + " -> " + - reshapeWidth+"x"+reshapeHeight+" @ scale "+reshapeScale); + panelWidth+"x"+panelHeight+" @ scale "+getPixelScale() + " -> " + + reshapeWidth+"x"+reshapeHeight+" @ scale "+getPixelScale()); } panelWidth = reshapeWidth; panelHeight = reshapeHeight; - panelScale = reshapeScale; return backend.handleReshape(); } @@ -1234,7 +1236,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } if (sendReshape) { if (DEBUG) { - System.err.println(getThreadName()+": GLJPanel.display: reshape(" + viewportX + "," + viewportY + " " + panelWidth + "x" + panelHeight + " @ scale "+panelScale+")"); + System.err.println(getThreadName()+": GLJPanel.display: reshape(" + viewportX + "," + viewportY + " " + panelWidth + "x" + panelHeight + " @ scale "+getPixelScale()+")"); } helper.reshape(GLJPanel.this, viewportX, viewportY, panelWidth, panelHeight); sendReshape = false; @@ -1433,7 +1435,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private final boolean useSingletonBuffer; private AWTGLPixelBuffer pixelBuffer; private BufferedImage alignedImage; - private int alignedImageScale; // One of these is used to store the read back pixels before storing // in the BufferedImage @@ -1515,12 +1516,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing fboDrawable.setTextureUnit( GLJPanel.this.requestedTextureUnit ); try { fboFlipped = new FBObject(); - fboFlipped.reset(gl, fboDrawable.getWidth(), fboDrawable.getHeight(), 0, false); + fboFlipped.reset(gl, fboDrawable.getSurfaceWidth(), fboDrawable.getSurfaceHeight(), 0, false); fboFlipped.attachTexture2D(gl, 0, chosenCaps.getAlphaBits()>0); // fboFlipped.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24); glslTextureRaster = new GLSLTextureRaster(fboDrawable.getTextureUnit(), true); glslTextureRaster.init(gl.getGL2ES2()); - glslTextureRaster.reshape(gl.getGL2ES2(), 0, 0, fboDrawable.getWidth(), fboDrawable.getHeight()); + glslTextureRaster.reshape(gl.getGL2ES2(), 0, 0, fboDrawable.getSurfaceWidth(), fboDrawable.getSurfaceHeight()); } catch (Exception ex) { ex.printStackTrace(); if(null != glslTextureRaster) { @@ -1674,19 +1675,18 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" pixelBufferProvider isSingletonBufferProvider "+useSingletonBuffer+", 0x"+Integer.toHexString(pixelBufferProvider.hashCode())+", "+pixelBufferProvider.getClass().getSimpleName()); System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" pixelBuffer 0x"+Integer.toHexString(pixelBuffer.hashCode())+", "+pixelBuffer+", alignment "+alignment); System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" flippedVertical "+flipVertical+", glslTextureRaster "+(null!=glslTextureRaster)); - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" panelSize "+panelWidth+"x"+panelHeight+" @ scale "+panelScale); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" panelSize "+panelWidth+"x"+panelHeight+" @ scale "+getPixelScale()); } } - if( offscreenDrawable.getWidth() != panelWidth || offscreenDrawable.getHeight() != panelHeight ) { - throw new InternalError("OffscreenDrawable panelSize mismatch (reshape missed): panelSize "+panelWidth+"x"+panelHeight+" != drawable "+offscreenDrawable.getWidth()+"x"+offscreenDrawable.getHeight()+", on thread "+getThreadName()); + if( offscreenDrawable.getSurfaceWidth() != panelWidth || offscreenDrawable.getSurfaceHeight() != panelHeight ) { + throw new InternalError("OffscreenDrawable panelSize mismatch (reshape missed): panelSize "+panelWidth+"x"+panelHeight+" != drawable "+offscreenDrawable.getSurfaceWidth()+"x"+offscreenDrawable.getSurfaceHeight()+", on thread "+getThreadName()); } if( null == alignedImage || panelWidth != alignedImage.getWidth() || panelHeight != alignedImage.getHeight() || !pixelBuffer.isDataBufferSource(alignedImage) ) { alignedImage = pixelBuffer.getAlignedImage(panelWidth, panelHeight); - alignedImageScale = panelScale; if(DEBUG) { - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" new alignedImage "+alignedImage.getWidth()+"x"+alignedImage.getHeight()+" @ scale "+alignedImageScale+", "+alignedImage+", pixelBuffer "+pixelBuffer.width+"x"+pixelBuffer.height+", "+pixelBuffer); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" new alignedImage "+alignedImage.getWidth()+"x"+alignedImage.getHeight()+" @ scale "+getPixelScale()+", "+alignedImage+", pixelBuffer "+pixelBuffer.width+"x"+pixelBuffer.height+", "+pixelBuffer); } } final IntBuffer readBackInts; @@ -1737,14 +1737,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing final int[] usrViewport = new int[] { 0, 0, 0, 0 }; gl.glGetIntegerv(GL.GL_VIEWPORT, usrViewport, 0); viewportChange = 0 != usrViewport[0] || 0 != usrViewport[1] || - offscreenDrawable.getWidth() != usrViewport[2] || offscreenDrawable.getHeight() != usrViewport[3]; + offscreenDrawable.getSurfaceWidth() != usrViewport[2] || offscreenDrawable.getSurfaceHeight() != usrViewport[3]; if( DEBUG_VIEWPORT ) { System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL: "+GLJPanel.this.getName()+" Viewport: change "+viewportChange+ ", "+usrViewport[0]+"/"+usrViewport[1]+" "+usrViewport[2]+"x"+usrViewport[3]+ - " -> 0/0 "+offscreenDrawable.getWidth()+"x"+offscreenDrawable.getHeight()); + " -> 0/0 "+offscreenDrawable.getSurfaceWidth()+"x"+offscreenDrawable.getSurfaceHeight()); } if( viewportChange ) { - gl.glViewport(0, 0, offscreenDrawable.getWidth(), offscreenDrawable.getHeight()); + gl.glViewport(0, 0, offscreenDrawable.getSurfaceWidth(), offscreenDrawable.getSurfaceHeight()); } // perform vert-flipping via OpenGL/FBO @@ -1813,7 +1813,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.doPaintComponent.drawImage: - frameCount "+frameCount); } // Draw resulting image in one shot - g.drawImage(alignedImage, 0, 0, alignedImage.getWidth()/alignedImageScale, alignedImage.getHeight()/alignedImageScale, null); // Null ImageObserver since image data is ready. + g.drawImage(alignedImage, 0, 0, alignedImage.getWidth()/getPixelScale(), alignedImage.getHeight()/getPixelScale(), null); // Null ImageObserver since image data is ready. } frameCount++; } @@ -1835,17 +1835,17 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } } if (DEBUG) { - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.handleReshape: " +panelWidth+"x"+panelHeight + " @ scale "+panelScale + " -> " + _drawable.getWidth()+"x"+_drawable.getHeight()); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.handleReshape: " +panelWidth+"x"+panelHeight + " @ scale "+getPixelScale() + " -> " + _drawable.getSurfaceWidth()+"x"+_drawable.getSurfaceHeight()); } - panelWidth = _drawable.getWidth(); - panelHeight = _drawable.getHeight(); + panelWidth = _drawable.getSurfaceWidth(); + panelHeight = _drawable.getSurfaceHeight(); if( null != glslTextureRaster ) { if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) { try { final GL gl = offscreenContext.getGL(); - fboFlipped.reset(gl, _drawable.getWidth(), _drawable.getHeight(), 0, false); - glslTextureRaster.reshape(gl.getGL2ES2(), 0, 0, _drawable.getWidth(), _drawable.getHeight()); + fboFlipped.reset(gl, _drawable.getSurfaceWidth(), _drawable.getSurfaceHeight(), 0, false); + glslTextureRaster.reshape(gl.getGL2ES2(), 0, 0, _drawable.getSurfaceWidth(), _drawable.getSurfaceHeight()); } finally { offscreenContext.release(); } diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index 7cd685d5a..de7653570 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -393,7 +393,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe public final void run() { // Lock: Locked Surface/Window by display _and_ MakeCurrent/Release if (sendReshape) { - helper.reshape(GLAutoDrawableBase.this, 0, 0, getWidth(), getHeight()); + helper.reshape(GLAutoDrawableBase.this, 0, 0, getSurfaceWidth(), getSurfaceHeight()); sendReshape = false; } helper.display(GLAutoDrawableBase.this); @@ -412,7 +412,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe if( null == context ) { boolean contextCreated = false; final GLDrawableImpl _drawable = drawable; - if ( null != _drawable && _drawable.isRealized() && 0<_drawable.getWidth()*_drawable.getHeight() ) { + if ( null != _drawable && _drawable.isRealized() && 0<_drawable.getSurfaceWidth()*_drawable.getSurfaceHeight() ) { final GLContext[] shareWith = { null }; if( !helper.isSharedGLContextPending(shareWith) ) { if( !restoreGLEventListenerState() ) { @@ -669,7 +669,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe _lock.lock(); try { final GLDrawable _drawable = drawable; - if( null == _drawable || realized && ( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) ) { + if( null == _drawable || realized && ( 0 >= _drawable.getSurfaceWidth() || 0 >= _drawable.getSurfaceHeight() ) ) { return; } _drawable.setRealized(realized); @@ -688,15 +688,15 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe } @Override - public int getWidth() { + public int getSurfaceWidth() { final GLDrawable _drawable = drawable; - return null != _drawable ? _drawable.getWidth() : 0; + return null != _drawable ? _drawable.getSurfaceWidth() : 0; } @Override - public int getHeight() { + public int getSurfaceHeight() { final GLDrawable _drawable = drawable; - return null != _drawable ? _drawable.getHeight() : 0; + return null != _drawable ? _drawable.getSurfaceHeight() : 0; } @Override diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index d2f69029e..c815556ff 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -634,7 +634,7 @@ public abstract class GLContextImpl extends GLContext { private final int makeCurrentWithinLock(int surfaceLockRes) throws GLException { if (!isCreated()) { - if( 0 >= drawable.getWidth() || 0 >= drawable.getHeight() ) { + if( 0 >= drawable.getSurfaceWidth() || 0 >= drawable.getSurfaceHeight() ) { if ( DEBUG_TRACE_SWITCH ) { System.err.println(getThreadName() + ": Create GL context REJECTED (zero surface size) obj " + toHexString(hashCode()) + ", surf "+toHexString(drawable.getHandle())+" for " + getClass().getName()); System.err.println(drawable.toString()); diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index c914b5e10..2dbd6dee3 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -417,9 +417,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * @param deviceReq which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be <code>null</code> for the platform's default device. * @param requestedCaps * @param chooser the custom chooser, may be null for default - * @param width the initial width as returned by {@link NativeSurface#getWidth()}, not the actual dummy surface width. + * @param width the initial width as returned by {@link NativeSurface#getSurfaceWidth()}, not the actual dummy surface width. * The latter is platform specific and small - * @param height the initial height as returned by {@link NativeSurface#getHeight()}, not the actual dummy surface height, + * @param height the initial height as returned by {@link NativeSurface#getSurfaceHeight()}, not the actual dummy surface height, * The latter is platform specific and small * * @return the created {@link ProxySurface} instance w/o defined surface handle but platform specific {@link UpstreamSurfaceHook}. @@ -446,9 +446,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * @param chosenCaps * @param requestedCaps * @param chooser the custom chooser, may be null for default - * @param width the initial width as returned by {@link NativeSurface#getWidth()}, not the actual dummy surface width. + * @param width the initial width as returned by {@link NativeSurface#getSurfaceWidth()}, not the actual dummy surface width. * The latter is platform specific and small - * @param height the initial height as returned by {@link NativeSurface#getHeight()}, not the actual dummy surface height, + * @param height the initial height as returned by {@link NativeSurface#getSurfaceHeight()}, not the actual dummy surface height, * The latter is platform specific and small * @return the created {@link ProxySurface} instance w/o defined surface handle but platform specific {@link UpstreamSurfaceHook}. */ diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 0e135d5e0..6116a2886 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -362,7 +362,7 @@ public class GLDrawableHelper { final ProxySurface ps = (ProxySurface) ns; final UpstreamSurfaceHook ush = ps.getUpstreamSurfaceHook(); if(ush instanceof UpstreamSurfaceHook.MutableSize) { - ((UpstreamSurfaceHook.MutableSize)ush).setSize(newWidth, newHeight); + ((UpstreamSurfaceHook.MutableSize)ush).setPixelSize(newWidth, newHeight); } else if(DEBUG) { // we have to assume UpstreamSurfaceHook contains the new size already, hence size check @ bottom System.err.println("GLDrawableHelper.resizeOffscreenDrawable: Drawable's offscreen ProxySurface n.a. UpstreamSurfaceHook.MutableSize, but "+ush.getClass().getName()+": "+ush); } @@ -379,7 +379,7 @@ public class GLDrawableHelper { } finally { ns.unlockSurface(); } - if( validateSize && ( drawable.getWidth() != newWidth || drawable.getHeight() != newHeight ) ) { + if( validateSize && ( drawable.getSurfaceWidth() != newWidth || drawable.getSurfaceHeight() != newHeight ) ) { throw new InternalError("Incomplete resize operation: expected "+newWidth+"x"+newHeight+", has: "+drawable); } return drawable; @@ -616,7 +616,7 @@ public class GLDrawableHelper { private final void init(GLEventListener l, GLAutoDrawable drawable, boolean sendReshape, boolean setViewport) { l.init(drawable); if(sendReshape) { - reshape(l, drawable, 0, 0, drawable.getWidth(), drawable.getHeight(), setViewport, false /* checkInit */); + reshape(l, drawable, 0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), setViewport, false /* checkInit */); } } @@ -640,7 +640,7 @@ public class GLDrawableHelper { } } else { // Expose same GL initialization if not using GLEventListener - drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); + drawable.getGL().glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); } } } diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java index d11274560..2070c2f4e 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java @@ -275,13 +275,13 @@ public abstract class GLDrawableImpl implements GLDrawable { } @Override - public int getWidth() { - return surface.getWidth(); + public int getSurfaceWidth() { + return surface.getSurfaceWidth(); } @Override - public int getHeight() { - return surface.getHeight(); + public int getSurfaceHeight() { + return surface.getSurfaceHeight(); } @Override diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java index 5ab2fdf00..0e9d3c1bb 100644 --- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -139,7 +139,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { for(int i=0; i<fbosN; i++) { fbos[i] = new FBObject(); - fbos[i].reset(gl, getWidth(), getHeight(), samples, false); + fbos[i].reset(gl, getSurfaceWidth(), getSurfaceHeight(), samples, false); if(fbos[i].getNumSamples() != samples) { throw new InternalError("Sample number mismatch: "+samples+", fbos["+i+"] "+fbos[i]); } @@ -211,7 +211,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { // resetQuirk fallback fbos[idx].destroy(gl); fbos[idx] = new FBObject(); - fbos[idx].reset(gl, getWidth(), getHeight(), samples, false); + fbos[idx].reset(gl, getSurfaceWidth(), getSurfaceHeight(), samples, false); if(fbos[idx].getNumSamples() != samples) { throw new InternalError("Sample number mismatch: "+samples+", fbos["+idx+"] "+fbos[idx]); } @@ -262,8 +262,8 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { if(DEBUG) { System.err.println("GLFBODrawableImpl.reset(): simple reconfig: "+samples+" -> "+newSamples+"/"+maxSamples); } - final int nWidth = getWidth(); - final int nHeight = getHeight(); + final int nWidth = getSurfaceWidth(); + final int nHeight = getSurfaceHeight(); samples = newSamples; pendingFBOReset = ( 1 < fbos.length ) ? fboIFront : -1; // pending-front reset only w/ double buffering (or zero samples) final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities(); @@ -396,7 +396,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { // Safely reset the previous front FBO - after completing propagating swap if(0 <= pendingFBOReset) { final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities(); - reset(glc.getGL(), pendingFBOReset, getWidth(), getHeight(), samples, caps.getAlphaBits(), caps.getStencilBits()); + reset(glc.getGL(), pendingFBOReset, getSurfaceWidth(), getSurfaceHeight(), samples, caps.getAlphaBits(), caps.getStencilBits()); pendingFBOReset = -1; } } @@ -578,7 +578,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { final ProxySurface ps = (ProxySurface) getNativeSurface(); final UpstreamSurfaceHook ush = ps.getUpstreamSurfaceHook(); if(ush instanceof UpstreamSurfaceHook.MutableSize) { - ((UpstreamSurfaceHook.MutableSize)ush).setSize(newWidth, newHeight); + ((UpstreamSurfaceHook.MutableSize)ush).setPixelSize(newWidth, newHeight); } else { throw new InternalError("GLFBODrawableImpl.ResizableImpl's ProxySurface doesn't hold a UpstreamSurfaceHookMutableSize but "+ush.getClass().getName()+", "+ps+", ush"); } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java index f184edae3..76c6e5beb 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java @@ -66,7 +66,7 @@ public abstract class EGLDrawable extends GLDrawableImpl { final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) eglws.getGraphicsConfiguration(); final NativeSurface upstreamSurface = eglws.getUpstreamSurface(); - long eglSurface = createSurface(eglConfig, eglws.getWidth(), eglws.getHeight(), upstreamSurface.getSurfaceHandle()); + long eglSurface = createSurface(eglConfig, eglws.getSurfaceWidth(), eglws.getSurfaceHeight(), upstreamSurface.getSurfaceHandle()); int eglError0; if (EGL.EGL_NO_SURFACE == eglSurface) { @@ -80,7 +80,7 @@ public abstract class EGLDrawable extends GLDrawableImpl { if(DEBUG) { System.err.println(getThreadName() + ": Info: Creation of window surface w/ surface handle failed: "+eglConfig+", error "+toHexString(eglError0)+", retry w/ windowHandle"); } - eglSurface = createSurface(eglConfig, eglws.getWidth(), eglws.getHeight(), nw.getWindowHandle()); + eglSurface = createSurface(eglConfig, eglws.getSurfaceWidth(), eglws.getSurfaceHeight(), nw.getWindowHandle()); if (EGL.EGL_NO_SURFACE == eglSurface) { eglError0 = EGL.eglGetError(); } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java b/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java index 818f32607..6deaa26c7 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java @@ -10,10 +10,10 @@ import com.jogamp.nativewindow.egl.EGLGraphicsDevice; /** Uses a PBuffer offscreen surface */ public class EGLDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { /** - * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * @param width the initial width as returned by {@link NativeSurface#getSurfaceWidth()} via {@link UpstreamSurfaceHook#getPixelWidth(ProxySurface)}, * not the actual dummy surface width. * The latter is platform specific and small - * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * @param height the initial height as returned by {@link NativeSurface#getSurfaceHeight()} via {@link UpstreamSurfaceHook#getPixelHeight(ProxySurface)}, * not the actual dummy surface height, * The latter is platform specific and small */ diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java index 5b911576e..8cc4580a7 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java @@ -45,9 +45,9 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { static String getThreadName() { return Thread.currentThread().getName(); } @Override - public final void setSize(int width, int height) { + public final void setPixelSize(int width, int height) { if(null != upstreamSurfaceHookMutableSize) { - upstreamSurfaceHookMutableSize.setSize(width, height); + upstreamSurfaceHookMutableSize.setPixelSize(width, height); } } @@ -199,19 +199,19 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { } @Override - public final int getWidth(ProxySurface s) { - return upstreamSurface.getWidth(); + public final int getPixelWidth(ProxySurface s) { + return upstreamSurface.getSurfaceWidth(); } @Override - public final int getHeight(ProxySurface s) { - return upstreamSurface.getHeight(); + public final int getPixelHeight(ProxySurface s) { + return upstreamSurface.getSurfaceHeight(); } @Override public String toString() { final String us_s = null != upstreamSurface ? ( upstreamSurface.getClass().getName() + ": 0x" + Long.toHexString(upstreamSurface.getSurfaceHandle()) ) : "nil"; - return "EGLUpstreamSurfaceHook[ "+ upstreamSurface.getWidth() + "x" + upstreamSurface.getHeight() + ", " + us_s+ "]"; + return "EGLUpstreamSurfaceHook[ "+ upstreamSurface.getSurfaceWidth() + "x" + upstreamSurface.getSurfaceHeight() + ", " + us_s+ "]"; } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 259c70641..d3cfffdea 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -364,8 +364,8 @@ public class MacOSXCGLContext extends GLContextImpl protected void drawableUpdatedNotify() throws GLException { if( drawable.getChosenGLCapabilities().isOnscreen() ) { final long _updateHandle = getUpdateHandle(); - final int w = drawable.getWidth(); - final int h = drawable.getHeight(); + final int w = drawable.getSurfaceWidth(); + final int h = drawable.getSurfaceHeight(); final boolean updateContext = ( 0!=_updateHandle && CGL.updateContextNeedsUpdate(_updateHandle) ) || w != lastWidth || h != lastHeight; if(updateContext) { @@ -681,14 +681,17 @@ public class MacOSXCGLContext extends GLContextImpl final long pbuffer; final int texID; final boolean isOpaque; - final int width; - final int height; + final int texWidth; + final int texHeight; + final int winWidth; + final int winHeight; /** Synchronized by instance's monitor */ long nsOpenGLLayer; /** Synchronized by instance's monitor */ boolean valid; - AttachGLLayerCmd(OffscreenLayerSurface ols, long ctx, int shaderProgram, long pfmt, long pbuffer, int texID, boolean isOpaque, int width, int height) { + AttachGLLayerCmd(OffscreenLayerSurface ols, long ctx, int shaderProgram, long pfmt, long pbuffer, int texID, + boolean isOpaque, int texWidth, int texHeight, int winWidth, int winHeight) { this.ols = ols; this.ctx = ctx; this.shaderProgram = shaderProgram; @@ -696,14 +699,16 @@ public class MacOSXCGLContext extends GLContextImpl this.pbuffer = pbuffer; this.texID = texID; this.isOpaque = isOpaque; - this.width = width; - this.height = height; + this.texWidth = texWidth; + this.texHeight = texHeight; + this.winWidth = winWidth; + this.winHeight = winHeight; this.valid = false; this.nsOpenGLLayer = 0; } public final String contentToString() { - return "valid "+valid+", size "+width+"x"+height+", ctx "+toHexString(ctx)+", opaque "+isOpaque+", texID "+texID+", pbuffer "+toHexString(pbuffer)+", nsOpenGLLayer "+toHexString(nsOpenGLLayer); + return "valid "+valid+", size tex["+texWidth+"x"+texHeight+"], win["+winWidth+"x"+winHeight+"], ctx "+toHexString(ctx)+", opaque "+isOpaque+", texID "+texID+", pbuffer "+toHexString(pbuffer)+", nsOpenGLLayer "+toHexString(nsOpenGLLayer); } @Override @@ -722,7 +727,8 @@ public class MacOSXCGLContext extends GLContextImpl try { if( MacOSXCGLContext.this.lock.tryLock( maxwait ) ) { try { - nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, shaderProgram, pfmt, pbuffer, texID, isOpaque, width, height); + nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, shaderProgram, pfmt, pbuffer, texID, isOpaque, + texWidth, texHeight, winWidth, winHeight); ols.attachSurfaceLayer(nsOpenGLLayer); final int currentInterval = MacOSXCGLContext.this.getSwapInterval(); final int interval = 0 <= currentInterval ? currentInterval : 1; @@ -838,8 +844,8 @@ public class MacOSXCGLContext extends GLContextImpl } else { throw new GLException("BackingLayerHost w/ unknown handle (!FBO, !PBuffer): "+drawable); } - lastWidth = drawable.getWidth(); - lastHeight = drawable.getHeight(); + lastWidth = drawable.getSurfaceWidth(); + lastHeight = drawable.getSurfaceHeight(); if(0>=lastWidth || 0>=lastHeight || !drawable.isRealized()) { throw new GLException("Drawable not realized yet or invalid texture size, texSize "+lastWidth+"x"+lastHeight+", "+drawable); } @@ -853,16 +859,21 @@ public class MacOSXCGLContext extends GLContextImpl } // All CALayer lifecycle ops are deferred on main-thread + final int[] winSize; + { + final int[] pixelSize = { lastWidth, lastHeight }; + winSize = drawable.getNativeSurface().getWindowUnitXY(pixelSize, pixelSize); + } attachGLLayerCmd = new AttachGLLayerCmd( backingLayerHost, ctx, gl3ShaderProgramName, pixelFormat, pbufferHandle, texID, - chosenCaps.isBackgroundOpaque(), lastWidth, lastHeight ); + chosenCaps.isBackgroundOpaque(), lastWidth, lastHeight, winSize[0], winSize[1] ); if(DEBUG) { System.err.println("MaxOSXCGLContext.NSOpenGLImpl.associateDrawable(true): "+attachGLLayerCmd); } OSXUtil.RunOnMainThread(false, attachGLLayerCmd); } else { // -> null == backingLayerHost - lastWidth = drawable.getWidth(); - lastHeight = drawable.getHeight(); + lastWidth = drawable.getSurfaceWidth(); + lastHeight = drawable.getSurfaceHeight(); boolean[] isPBuffer = { false }; boolean[] isFBO = { false }; CGL.setContextView(contextHandle, getNSViewHandle(isPBuffer, isFBO)); @@ -913,11 +924,11 @@ public class MacOSXCGLContext extends GLContextImpl /** Returns true if size has been updated, otherwise false (same size). */ private final boolean validateDrawableSizeConfig(long ctx) { - final int width = drawable.getWidth(); - final int height = drawable.getHeight(); + final int width = drawable.getSurfaceWidth(); + final int height = drawable.getSurfaceHeight(); if( lastWidth != width || lastHeight != height ) { - lastWidth = drawable.getWidth(); - lastHeight = drawable.getHeight(); + lastWidth = drawable.getSurfaceWidth(); + lastHeight = drawable.getSurfaceHeight(); if(DEBUG) { System.err.println("NS.validateDrawableConfig size changed"); } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java index ebb0fc6d1..150feac55 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java @@ -145,12 +145,12 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { } @Override - public int getWidth() { + public int getSurfaceWidth() { throw new GLException("Should not call this"); } @Override - public int getHeight() { + public int getSurfaceHeight() { throw new GLException("Should not call this"); } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java index f6e8b8fa3..eba97a9ca 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -135,18 +135,18 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { pBufferTexTarget = GL.GL_TEXTURE_2D; if ( null!=sr && sr.isNPOTTextureAvailable() ) { - pBufferTexWidth = getWidth(); - pBufferTexHeight = getHeight(); + pBufferTexWidth = getSurfaceWidth(); + pBufferTexHeight = getSurfaceHeight(); } else { - pBufferTexWidth = GLBuffers.getNextPowerOf2(getWidth()); - pBufferTexHeight = GLBuffers.getNextPowerOf2(getHeight()); + pBufferTexWidth = GLBuffers.getNextPowerOf2(getSurfaceWidth()); + pBufferTexHeight = GLBuffers.getNextPowerOf2(getSurfaceHeight()); } final int internalFormat = GL.GL_RGBA; - final long pBuffer = impl.create(pBufferTexTarget, internalFormat, getWidth(), getHeight()); + final long pBuffer = impl.create(pBufferTexTarget, internalFormat, getSurfaceWidth(), getSurfaceHeight()); if(DEBUG) { System.err.println("MacOSXPbufferCGLDrawable tex: target "+toHexString(pBufferTexTarget)+ - ", pbufferSize "+getWidth()+"x"+getHeight()+ + ", pbufferSize "+getSurfaceWidth()+"x"+getSurfaceHeight()+ ", texSize "+pBufferTexWidth+"x"+pBufferTexHeight+ ", internal-fmt "+toHexString(internalFormat)); System.err.println("MacOSXPbufferCGLDrawable pBuffer: "+toHexString(pBuffer)); diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java index f658a3598..1ad3fed8d 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java @@ -111,8 +111,8 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable { } final WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration(); final GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable)config.getChosenCapabilities(); - final int width = getWidth(); - final int height = getHeight(); + final int width = getSurfaceWidth(); + final int height = getSurfaceHeight(); // // 1. Create DIB Section diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java index c46b3c9dd..2047a91b5 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java @@ -129,12 +129,12 @@ public class WindowsExternalWGLContext extends WindowsWGLContext { } @Override - public int getWidth() { + public int getSurfaceWidth() { throw new GLException("Should not call this"); } @Override - public int getHeight() { + public int getSurfaceHeight() { throw new GLException("Should not call this"); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java index f8c237c9e..11e0202fd 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java @@ -51,7 +51,6 @@ import javax.media.opengl.GLProfile; import jogamp.nativewindow.WrappedSurface; import jogamp.nativewindow.windows.GDI; -import jogamp.nativewindow.windows.GDIUtil; public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { @@ -86,12 +85,12 @@ public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { } @Override - public int getWidth() { + public int getSurfaceWidth() { throw new GLException("Should not call this"); } @Override - public int getHeight() { + public int getSurfaceHeight() { throw new GLException("Should not call this"); } } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java index 2e60c682b..e0bf1f50b 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -181,7 +181,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { iattributes.put(niattribs++, 0); - tmpBuffer = wglExt.wglCreatePbufferARB(sharedHdc, format, getWidth(), getHeight(), iattributes); + tmpBuffer = wglExt.wglCreatePbufferARB(sharedHdc, format, getSurfaceWidth(), getSurfaceHeight(), iattributes); if (tmpBuffer != 0) { // Done break; diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java index ff9363ca0..45c666230 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java @@ -141,12 +141,12 @@ public class X11ExternalGLXContext extends X11GLXContext { } @Override - public int getWidth() { + public int getSurfaceWidth() { throw new GLException("Should not call this"); } @Override - public int getHeight() { + public int getSurfaceHeight() { throw new GLException("Should not call this"); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java index 0e771fd0f..ae2982269 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java @@ -105,9 +105,9 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { IntBuffer iattributes = Buffers.newDirectIntBuffer(7); iattributes.put(niattribs++, GLX.GLX_PBUFFER_WIDTH); - iattributes.put(niattribs++, ms.getWidth()); + iattributes.put(niattribs++, ms.getSurfaceWidth()); iattributes.put(niattribs++, GLX.GLX_PBUFFER_HEIGHT); - iattributes.put(niattribs++, ms.getHeight()); + iattributes.put(niattribs++, ms.getSurfaceHeight()); iattributes.put(niattribs++, GLX.GLX_LARGEST_PBUFFER); // exact iattributes.put(niattribs++, 0); iattributes.put(niattribs++, 0); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java index c1388db8a..42d76097c 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java @@ -83,7 +83,7 @@ public class X11PixmapGLXDrawable extends X11GLXDrawable { int screen = aScreen.getIndex(); pixmap = X11Lib.XCreatePixmap(dpy, X11Lib.RootWindow(dpy, screen), - surface.getWidth(), surface.getHeight(), bitsPerPixel); + surface.getSurfaceWidth(), surface.getSurfaceHeight(), bitsPerPixel); if (pixmap == 0) { throw new GLException("XCreatePixmap failed"); } |