aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-05-21 08:53:54 +0200
committerSven Gothel <[email protected]>2014-05-21 08:53:54 +0200
commitf9a00b91dcd146c72a50237b62270f33bd0da98e (patch)
treef4387da868608cea5066ce3a8cb9039a16b529de /src/jogl/classes/jogamp
parent0ffba122ea5c4b8cc247234ca9f48ccfcce833cd (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/jogamp')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java14
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableHelper.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableImpl.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java12
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java14
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java47
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java12
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java5
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java2
19 files changed, 86 insertions, 76 deletions
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");
}