aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/build-jogl.xml1
-rw-r--r--make/config/jogl/cgl-macosx.cfg1
-rwxr-xr-xmake/scripts/tests.sh6
-rw-r--r--make/stub_includes/opengl/macosx-window-system.h7
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java56
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java79
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java13
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java11
-rw-r--r--src/jogl/native/macosx/MacOSXWindowSystemInterface-nsview.m140
-rw-r--r--src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m151
-rw-r--r--src/jogl/native/macosx/MacOSXWindowSystemInterface.h20
-rw-r--r--src/jogl/native/macosx/MacOSXWindowSystemInterface.m180
-rw-r--r--src/nativewindow/native/macosx/OSXmisc.m8
14 files changed, 454 insertions, 227 deletions
diff --git a/make/build-jogl.xml b/make/build-jogl.xml
index 58e018024..fc6786e21 100644
--- a/make/build-jogl.xml
+++ b/make/build-jogl.xml
@@ -1278,6 +1278,7 @@
<include name="${rootrel.src.c}/GLDebugMessageHandler.c"/>
<include name="${rootrel.src.c}/macosx/MacOSXCustomCGLCode.c" if="isOSX"/>
<include name="${rootrel.src.c}/macosx/MacOSXWindowSystemInterface.m" if="isOSX"/>
+ <include name="${rootrel.src.c}/macosx/MacOSXWindowSystemInterface-pbuffer.m" if="isOSX"/>
<include name="${rootrel.src.c}/macosx/ContextUpdater.m" if="isOSX"/>
<include name="${rootrel.src.c}/GLXGetProcAddressARB.c" if="isX11"/>
<!-- FIXME: the Mixer should be moved to another library -->
diff --git a/make/config/jogl/cgl-macosx.cfg b/make/config/jogl/cgl-macosx.cfg
index 6be8abe76..7d17c4aff 100644
--- a/make/config/jogl/cgl-macosx.cfg
+++ b/make/config/jogl/cgl-macosx.cfg
@@ -23,6 +23,7 @@ Opaque long CGLPixelFormatObj
Opaque long NSOpenGLPixelFormat *
Opaque long NSOpenGLContext *
Opaque long NSView *
+Opaque long NSOpenGLView *
Opaque long NSOpenGLPixelBuffer *
Opaque long NSOpenGLLayer *
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index cbea43cc9..d171e87eb 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -49,7 +49,7 @@ function jrun() {
shift
#D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true"
- D_ARGS="-Dnativewindow.debug=all"
+ D_ARGS="-Dnativewindow.debug=all -Djogl.debug.GLContext -Djogl.debug.GLDrawable"
#D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all"
#D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache"
#D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable"
@@ -202,7 +202,7 @@ function testswt() {
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing
#testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464
-#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $*
+testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.texture.TestTexture01AWT
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461OffscreenSupersamplingSwingAWT
@@ -229,7 +229,7 @@ function testswt() {
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $*
-testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $*
+#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $*
#testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT
#testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleAWT $*
diff --git a/make/stub_includes/opengl/macosx-window-system.h b/make/stub_includes/opengl/macosx-window-system.h
index fe0c0b1bc..959b44d8d 100644
--- a/make/stub_includes/opengl/macosx-window-system.h
+++ b/make/stub_includes/opengl/macosx-window-system.h
@@ -9,8 +9,8 @@
#include <AppKit/NSView.h>
#include <AppKit/NSOpenGL.h>
+#include <AppKit/NSOpenGLView.h>
#include <AppKit/NSOpenGLLayer.h>
-// #include <AppKit/NSOpenGLView.h>
#include <OpenGL/CGLDevice.h>
#include <OpenGL/OpenGL.h>
@@ -50,9 +50,10 @@ void updateContextUnregister(void* updater);
NSOpenGLPixelBuffer* createPBuffer(int renderTarget, int internalFormat, int width, int height);
Bool destroyPBuffer(NSOpenGLPixelBuffer* pBuffer);
void setContextPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer);
-void setContextTextureImageToPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer, int colorBuffer);
+void setContextTextureImageToPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer, GLenum colorBuffer);
-NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSView* view, Bool opaque);
+// NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSView* view, Bool opaque);
+NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* pbuffer, Bool opaque, int width, int height);
void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* glLayer);
void releaseNSOpenGLLayer(NSOpenGLLayer *glLayer);
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index 2efdf958d..b942fb904 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -47,6 +47,7 @@ import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.DefaultGraphicsConfiguration;
import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.SurfaceUpdatedListener;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLException;
@@ -79,7 +80,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
boolean makeCurrent(long ctx);
boolean release(long ctx);
boolean setSwapInterval(int interval);
- boolean swapBuffers(boolean isOnscreen);
+ boolean swapBuffers();
}
/* package */ static final boolean isTigerOrLater;
@@ -271,9 +272,8 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
protected void swapBuffers() {
- DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)config.getChosenCapabilities();
- if(!impl.swapBuffers(caps.isOnscreen())) {
+ // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers()
+ if(!impl.swapBuffers()) {
throw new GLException("Error swapping buffers: "+this);
}
}
@@ -417,16 +417,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl
final NativeSurface surface = drawable.getNativeSurface();
final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) surface.getGraphicsConfiguration().getNativeGraphicsConfiguration();
final boolean isBackingLayerView = LayeredSurfaceType.None != drawable.getLayeredSurfaceType();
- /**
- final GLCapabilitiesImmutable chosenCaps;
- {
- final GLCapabilitiesImmutable _chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
- if(isBackingLayerView) {
- chosenCaps = GLGraphicsConfigurationUtil.fixSingleBufferGLCapabilities(_chosenCaps);
- } else {
- chosenCaps = _chosenCaps;
- }
- } */
final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(chosenCaps, ctp, major, minor);
if (pixelFormat == 0) {
@@ -483,11 +473,21 @@ public abstract class MacOSXCGLContext extends GLContextImpl
final MacOSXJAWTWindow lsh = MacOSXCGLDrawableFactory.getLayeredSurfaceHost(surface);
nsOpenGLLayerPFmt = pixelFormat;
pixelFormat = 0;
- nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, drawable.getNSViewHandle(), fixedCaps.isBackgroundOpaque());
+ // final long nsView = drawable.getNSViewHandle();
+ // nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, nsView, fixedCaps.isBackgroundOpaque());
+ nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, drawable.getHandle(), fixedCaps.isBackgroundOpaque(),
+ drawable.getWidth(), drawable.getHeight());
if (DEBUG) {
System.err.println("NS create nsOpenGLLayer "+toHexString(nsOpenGLLayer));
}
lsh.attachSurfaceLayer(nsOpenGLLayer);
+ lsh.addSurfaceUpdatedListener(new SurfaceUpdatedListener() {
+ public void surfaceUpdated(Object updater, NativeSurface ns, long when) {
+ if(0 != nsOpenGLLayer) {
+ CGL.setNSOpenGLLayerNeedsDisplay(nsOpenGLLayer);
+ }
+ }
+ });
}
} finally {
if(0!=pixelFormat) {
@@ -530,23 +530,8 @@ public abstract class MacOSXCGLContext extends GLContextImpl
CGL.setSwapInterval(contextHandle, interval);
return true;
}
- public boolean swapBuffers(boolean isOnscreen) {
- /*
- boolean res = true;
- if(isOnscreen) {
- res = CGL.flushBuffer(contextHandle);
- }
- if(res && 0 != nsOpenGLLayer) {
- CGL.setNSOpenGLLayerNeedsDisplay(nsOpenGLLayer);
- }
- return res; */
-
- if(0 != nsOpenGLLayer) {
- CGL.setNSOpenGLLayerNeedsDisplay(nsOpenGLLayer);
- } else if(isOnscreen) {
- return CGL.flushBuffer(contextHandle);
- }
- return true;
+ public boolean swapBuffers() {
+ return CGL.flushBuffer(contextHandle);
}
}
@@ -614,11 +599,8 @@ public abstract class MacOSXCGLContext extends GLContextImpl
CGL.CGLSetParameter(contextHandle, CGL.kCGLCPSwapInterval, lval, 0);
return true;
}
- public boolean swapBuffers(boolean isOnscreen) {
- if(isOnscreen) {
- return CGL.kCGLNoError == CGL.CGLFlushDrawable(contextHandle);
- }
- return true;
+ public boolean swapBuffers() {
+ return CGL.kCGLNoError == CGL.CGLFlushDrawable(contextHandle);
}
}
}
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java
index 6ac0af6e8..a97f3b1b2 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java
@@ -40,12 +40,16 @@
package jogamp.opengl.macosx.cgl;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
import javax.media.nativewindow.NativeSurface;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLException;
import jogamp.nativewindow.jawt.macosx.MacOSXJAWTWindow;
-import jogamp.nativewindow.macosx.OSXUtil;
import jogamp.opengl.GLDrawableImpl;
import jogamp.opengl.GLDynamicLookupHelper;
@@ -99,13 +103,15 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
}
}
+ private List<WeakReference<MacOSXCGLContext>> createdContexts = new ArrayList<WeakReference<MacOSXCGLContext>>();
+
private boolean haveSetOpenGLMode = false;
private GLBackendType openGLMode = GLBackendType.NSOPENGL;
protected LayeredSurfaceType layeredSurfaceType = LayeredSurfaceType.None;
public MacOSXCGLDrawable(GLDrawableFactory factory, NativeSurface comp, boolean realized) {
super(factory, comp, realized);
- initOpenGLImpl(getOpenGLMode());
+ initOpenGLImpl(getOpenGLMode());
}
public final LayeredSurfaceType getLayeredSurfaceType() { return layeredSurfaceType; }
@@ -117,6 +123,7 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
return GLBackendType.NSOPENGL == openGLMode ? getHandle() : null;
}
+ /**
@Override
protected void destroyHandle() {
if(layeredSurfaceType == LayeredSurfaceType.Direct) {
@@ -126,10 +133,12 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
System.err.println("destroyHandle: layerType " + layeredSurfaceType + ", backingLayer "+toHexString(lsh.getSurfaceHandle()) + " -> 0");
}
OSXUtil.DestroyNSView(lsh.getSurfaceHandle());
+ // CGL.releaseNSOpenGLView(lsh.getSurfaceHandle());
lsh.setSurfaceHandle(0);
} else if (DEBUG) {
System.err.println("destroyHandle: layerType " + layeredSurfaceType);
}
+ super.destroyHandle();
}
@Override
@@ -139,14 +148,16 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
if(lsh == surface) {
// direct surface host, eg. AWT GLCanvas
layeredSurfaceType = LayeredSurfaceType.Direct;
- final long oldNSBackingView = lsh.getSurfaceHandle();
- if(0 != oldNSBackingView) {
- OSXUtil.DestroyNSView(oldNSBackingView);
+ final long oldNSView = lsh.getSurfaceHandle();
+ if(0 != oldNSView) {
+ OSXUtil.DestroyNSView(oldNSView);
+ // CGL.releaseNSOpenGLView(oldNSView);
}
- final long newNSBackingView = OSXUtil.CreateNSView(0, 0, getWidth(), getHeight());
- lsh.setSurfaceHandle(newNSBackingView);
+ final long nsView = OSXUtil.CreateNSView(0, 0, getWidth(), getHeight());
+ // final long nsView = CGL.createNSOpenGLView(0, 0, getWidth(), getHeight());
+ lsh.setSurfaceHandle(nsView);
if (DEBUG) {
- System.err.println("updateHandle: layerType " + layeredSurfaceType + ", backingLayer "+toHexString(newNSBackingView) + " -> "+toHexString(oldNSBackingView));
+ System.err.println("updateHandle: layerType " + layeredSurfaceType + ", backingLayer "+toHexString(oldNSView) + " -> "+toHexString(nsView));
}
} else {
// parent surface host, eg. via native parenting w/ NewtCanvasAWT
@@ -161,8 +172,58 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
System.err.println("updateHandle: layerType " + layeredSurfaceType);
}
}
- }
+ super.updateHandle();
+ } */
+ @Override
+ protected void updateHandle() {
+ final MacOSXJAWTWindow lsh = MacOSXCGLDrawableFactory.getLayeredSurfaceHost(surface);
+ if (null != lsh) {
+ if(lsh == surface) {
+ // direct surface host, eg. AWT GLCanvas
+ layeredSurfaceType = LayeredSurfaceType.Direct;
+ if (DEBUG) {
+ System.err.println("updateHandle: layerType " + layeredSurfaceType + ", backingLayer "+toHexString(lsh.getSurfaceHandle()));
+ }
+ } else {
+ // parent surface host, eg. via native parenting w/ NewtCanvasAWT
+ layeredSurfaceType = LayeredSurfaceType.Parented;
+ if (DEBUG) {
+ System.err.println("updateHandle: layerType " + layeredSurfaceType + ", backingLayer "+toHexString(getHandle()));
+ }
+ }
+ } else {
+ layeredSurfaceType = LayeredSurfaceType.None;
+ if (DEBUG) {
+ System.err.println("updateHandle: layerType " + layeredSurfaceType);
+ }
+ }
+ super.updateHandle();
+ }
+
+ protected void registerContext(MacOSXCGLContext ctx) {
+ // NOTE: we need to keep track of the created contexts in order to
+ // implement swapBuffers() because of how Mac OS X implements its
+ // OpenGL window interface
+ synchronized (createdContexts) {
+ createdContexts.add(new WeakReference<MacOSXCGLContext>(ctx));
+ }
+ }
+ protected final void swapBuffersImpl() {
+ // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers()
+ synchronized (createdContexts) {
+ for (Iterator<WeakReference<MacOSXCGLContext>> iter = createdContexts.iterator(); iter.hasNext(); ) {
+ WeakReference<MacOSXCGLContext> ref = iter.next();
+ MacOSXCGLContext ctx = ref.get();
+ if (ctx != null) {
+ ctx.swapBuffers();
+ } else {
+ iter.remove();
+ }
+ }
+ }
+ }
+
public GLDynamicLookupHelper getGLDynamicLookupHelper() {
return getFactoryImpl().getGLDynamicLookupHelper(0);
}
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
index cbdff144f..18401a025 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -248,8 +248,12 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
final MacOSXJAWTWindow lsh = MacOSXCGLDrawableFactory.getLayeredSurfaceHost(target);
if(null != lsh) {
// layered surface -> PBuffer
- final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities((GLCapabilitiesImmutable) config.getChosenCapabilities());
+ final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ final GLCapabilities chosenCaps = (GLCapabilities) config.getChosenCapabilities().cloneMutable();
+ // chosenCaps.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN
+ chosenCaps.setOnscreen(false);
+ chosenCaps.setPBuffer(true);
+ // chosenCaps.setPbufferRenderToTextureRectangle(true);
config.setChosenCapabilities(chosenCaps);
return new MacOSXPbufferCGLDrawable(this, target, false);
}
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
index 865238f06..741bb19c5 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
@@ -83,6 +83,8 @@ public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration
static final int[] cglInternalAttributeToken = new int[] {
CGL.kCGLPFAOpenGLProfile,
CGL.kCGLPFAColorFloat,
+ CGL.NSOpenGLPFANoRecovery,
+ CGL.NSOpenGLPFAAccelerated,
CGL.NSOpenGLPFAPixelBuffer,
CGL.NSOpenGLPFADoubleBuffer,
CGL.NSOpenGLPFAStereo,
@@ -114,6 +116,13 @@ public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration
ivalues[idx] = caps.getPbufferFloatingPointBuffers() ? 1 : 0;
break;
+ case CGL.NSOpenGLPFANoRecovery:
+ ivalues[idx] = caps.getHardwareAccelerated() ? 1 : 0; // FIXME: Jau ??
+ break;
+ case CGL.NSOpenGLPFAAccelerated:
+ ivalues[idx] = caps.getHardwareAccelerated() ? 1 : 0; // FIXME: Jau ??
+ break;
+
case CGL.NSOpenGLPFAPixelBuffer:
ivalues[idx] = caps.isPBuffer() ? 1 : 0;
break;
@@ -285,6 +294,10 @@ public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration
caps.setPbufferFloatingPointBuffers(ivalues[i] != 0);
break;
+ case CGL.NSOpenGLPFAAccelerated:
+ caps.setHardwareAccelerated(ivalues[i] != 0);
+ break;
+
case CGL.NSOpenGLPFAPixelBuffer:
caps.setPBuffer(ivalues[i] != 0);
break;
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java
index 525134f1e..5f511c505 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java
@@ -136,13 +136,16 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities();
GLProfile glProfile = capabilities.getGLProfile();
+ final int w, h;
int renderTarget;
if (glProfile.isGL2GL3() && capabilities.getPbufferRenderToTextureRectangle()) {
+ w = getWidth();
+ h = getHeight();
renderTarget = GL2.GL_TEXTURE_RECTANGLE;
} else {
- int w = getNextPowerOf2(getWidth());
- int h = getNextPowerOf2(getHeight());
- ((SurfaceChangeable)ns).setSize(w, h);
+ w = getNextPowerOf2(getWidth());
+ h = getNextPowerOf2(getHeight());
+ // FIXME - JAU: ((SurfaceChangeable)ns).setSize(w, h); // can't do that, removed orig size
renderTarget = GL.GL_TEXTURE_2D;
}
@@ -168,7 +171,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
}
}
- pBuffer = impl.create(renderTarget, internalFormat, getWidth(), getHeight());
+ pBuffer = impl.create(renderTarget, internalFormat, w, h);
if (pBuffer == 0) {
throw new GLException("pbuffer creation error: CGL.createPBuffer() failed");
}
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-nsview.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-nsview.m
new file mode 100644
index 000000000..7233f40ce
--- /dev/null
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-nsview.m
@@ -0,0 +1,140 @@
+
+@interface MyNSOpenGLLayer: NSOpenGLLayer
+{
+@protected
+ NSOpenGLContext* ctxShared;
+ NSView* view;
+ NSOpenGLPixelFormat* fmt;
+@public
+ volatile BOOL shallDraw;
+}
+
+- (id) initWithContext: (NSOpenGLContext*) ctx
+ pixelFormat: (NSOpenGLPixelFormat*) pfmt
+ view: (NSView*) v
+ opaque: (Bool) opaque;
+
+@end
+
+@implementation MyNSOpenGLLayer
+
+- (id) initWithContext: (NSOpenGLContext*) _ctx
+ pixelFormat: (NSOpenGLPixelFormat*) _fmt
+ view: (NSView*) _view
+ opaque: (Bool) opaque
+{
+ self = [super init];
+ ctxShared = _ctx;
+ [ctxShared retain];
+
+ fmt = _fmt;
+ [fmt retain];
+
+ view = _view;
+ [view retain];
+ [self setView: view];
+ [view setLayer: self];
+ [view setWantsLayer: YES];
+
+ [self setAsynchronous: NO];
+ // [self setAsynchronous: YES]; // FIXME: JAU
+ [self setNeedsDisplayOnBoundsChange: NO];
+ [self setOpaque: opaque ? YES : NO];
+ shallDraw = NO;
+ textureID = 0;
+ DBG_PRINT("MyNSOpenGLLayer::init %p, ctx %p, pfmt %p, view %p, opaque %d\n", self, ctx, fmt, view, opaque);
+ return self;
+}
+
+- (void)dealloc
+{
+ [fmt release];
+ [ctxShared release];
+ [view release];
+ DBG_PRINT("MyNSOpenGLLayer::dealloc %p\n", self);
+ [super dealloc];
+}
+
+- (void) setOpenGLContext: (NSOpenGLContext*) _ctx
+{
+ DBG_PRINT("MyNSOpenGLLayer::setOpenGLContext: %p %p -> %p\n", self, [self openGLContext], _ctx);
+ [super setOpenGLContext: _ctx];
+}
+
+- (void) setOpenGLPixelFormat: (NSOpenGLPixelFormat*) _fmt
+{
+ DBG_PRINT("MyNSOpenGLLayer::setOpenGLPixelFormat %p %p -> %p\n", self, fmt, _fmt);
+ [super setOpenGLPixelFormat: fmt];
+}
+
+- (NSOpenGLPixelFormat *) openGLPixelFormat
+{
+ return fmt;
+}
+
+- (void) setView: (NSView*) v
+{
+ DBG_PRINT("MyNSOpenGLLayer::setView %p %p -> %p (ignored/propagated)\n", self, view, v);
+ [super setView: view]; // propagate
+}
+
+- (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask
+{
+ DBG_PRINT("MyNSOpenGLLayer::openGLPixelFormatForDisplayMask %p %d -> %p\n", self, mask, fmt);
+ return fmt;
+}
+
+- (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat
+{
+ NSOpenGLContext* ctx = NULL;
+ if(NULL == ctx) {
+ int viewNotReady[] = { 0 };
+ ctx = createContext(ctxShared, view, true, fmt, [self isOpaque], viewNotReady);
+ }
+ DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat %p, fmt %p/%p, view %p, shared %p -> %p\n",
+ self, fmt, pixelFormat, view, ctxShared, ctx);
+ return ctx;
+}
+
+- (BOOL)canDrawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat
+ forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
+{
+ DBG_PRINT("MyNSOpenGLLayer::canDrawInOpenGLContext %p: %d\n", self, self->shallDraw);
+ return self->shallDraw;
+}
+
+- (void)drawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat
+ forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
+{
+ self->shallDraw = NO;
+
+ DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p, ctx %p, pfmt %p\n", self, context, pixelFormat);
+
+ [super drawInOpenGLContext: context pixelFormat: pixelFormat forLayerTime: timeInterval displayTime: timeStamp];
+}
+
+@end
+
+NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSView* view, Bool opaque) {
+ return [[MyNSOpenGLLayer alloc] initWithContext:ctx pixelFormat: fmt view: view opaque: opaque];
+}
+
+void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* layer) {
+ MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer;
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ l->shallDraw = YES;
+ [l performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:YES];
+ // NSView* view = [l view];
+ // [view setNeedsDisplay: YES]; // FIXME: JAU
+ // [view performSelectorOnMainThread:@selector(setNeedsDisplay:) withObject:YES waitUntilDone:YES];
+ // [view performSelectorOnMainThread:@selector(display) withObject:nil waitUntilDone:YES];
+ DBG_PRINT("MyNSOpenGLLayer::setNSOpenGLLayerNeedsDisplay %p\n", l);
+ [pool release];
+}
+
+void releaseNSOpenGLLayer(NSOpenGLLayer* l) {
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ [l release];
+ [pool release];
+}
+
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m
new file mode 100644
index 000000000..16e5829ba
--- /dev/null
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m
@@ -0,0 +1,151 @@
+#import "MacOSXWindowSystemInterface.h"
+
+@interface MyNSOpenGLLayer: NSOpenGLLayer
+{
+@protected
+ NSOpenGLPixelBuffer* pbuffer;
+ int width;
+ int height;
+ GLuint textureID;
+@public
+ volatile BOOL shallDraw;
+}
+
+- (id) initWithContext: (NSOpenGLContext*) ctx
+ pixelFormat: (NSOpenGLPixelFormat*) pfmt
+ pbuffer: (NSOpenGLPixelBuffer*) p
+ opaque: (Bool) opaque
+ width: (int) width
+ height: (int) height;
+
+@end
+
+@implementation MyNSOpenGLLayer
+
+- (id) initWithContext: (NSOpenGLContext*) _ctx
+ pixelFormat: (NSOpenGLPixelFormat*) _fmt
+ pbuffer: (NSOpenGLPixelBuffer*) p
+ opaque: (Bool) opaque
+ width: (int) _width
+ height: (int) _height;
+{
+ self = [super init];
+ pbuffer = p;
+ [pbuffer retain];
+
+ [self setAsynchronous: NO];
+ // [self setAsynchronous: YES]; // FIXME: JAU
+ [self setNeedsDisplayOnBoundsChange: NO];
+ [self setOpaque: opaque ? YES : NO];
+ width = _width;
+ height = _height;
+ textureID = 0;
+ shallDraw = NO;
+ DBG_PRINT("MyNSOpenGLLayer::init %p, ctx %p, pfmt %p, pbuffer %p, opaque %d, %dx%d -> %dx%d\n",
+ self, _ctx, _fmt, pbuffer, opaque, width, height, [pbuffer pixelsWide], [pbuffer pixelsHigh]);
+ return self;
+}
+
+- (void)dealloc
+{
+ [pbuffer release];
+ DBG_PRINT("MyNSOpenGLLayer::dealloc %p\n", self);
+ [super dealloc];
+}
+
+- (BOOL)canDrawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat
+ forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
+{
+ DBG_PRINT("MyNSOpenGLLayer::canDrawInOpenGLContext %p: %d\n", self, self->shallDraw);
+ return self->shallDraw;
+}
+
+- (void)drawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat
+ forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
+{
+ self->shallDraw = NO;
+
+ [context makeCurrentContext];
+
+ GLenum textureTarget = [pbuffer textureTarget];
+ GLsizei pwidth = [pbuffer pixelsWide];
+ GLsizei pheight = [pbuffer pixelsHigh];
+ GLfloat tWidth = textureTarget == GL_TEXTURE_2D ? (GLfloat)width/(GLfloat)pwidth : pwidth;
+ GLfloat tHeight = textureTarget == GL_TEXTURE_2D ? (GLfloat)height/(GLfloat)pheight : pheight;
+
+ DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p, ctx %p, pfmt %p %dx%d -> %fx%f 0x%X\n",
+ self, context, pixelFormat, width, height, tWidth, tHeight, textureTarget);
+
+ if(0 == textureID) {
+ glGenTextures(1, &textureID);
+ }
+ glBindTexture(textureTarget, textureID);
+
+ [context setTextureImageToPixelBuffer: pbuffer colorBuffer: GL_FRONT];
+
+ glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ glEnable(textureTarget);
+
+ static GLfloat verts[] = {
+ -1.0, -1.0,
+ -1.0, 1.0,
+ 1.0, 1.0,
+ 1.0, -1.0
+ };
+
+ GLfloat tex[] = {
+ 0.0, 0.0,
+ 0.0, tHeight,
+ tWidth, tHeight,
+ tWidth, 0.0
+ };
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glVertexPointer(2, GL_FLOAT, 0, verts);
+ glTexCoordPointer(2, GL_FLOAT, 0, tex);
+
+ glDrawArrays(GL_QUADS, 0, 4);
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+
+ glDisable(textureTarget);
+
+ [super drawInOpenGLContext: context pixelFormat: pixelFormat forLayerTime: timeInterval displayTime: timeStamp];
+}
+
+@end
+
+NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, Bool opaque, int width, int height) {
+ return [[MyNSOpenGLLayer alloc] initWithContext:ctx pixelFormat: fmt pbuffer: p opaque: opaque width: width height: height];
+}
+
+void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* layer) {
+ MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer;
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ l->shallDraw = YES;
+ if ( [NSThread isMainThread] == YES ) {
+ [l setNeedsDisplay];
+ } else {
+ // [l performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:YES];
+ [l performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO];
+ }
+ // NSView* view = [l view];
+ // [view setNeedsDisplay: YES]; // FIXME: JAU
+ // [view performSelectorOnMainThread:@selector(setNeedsDisplay:) withObject:YES waitUntilDone:YES];
+ // [view performSelectorOnMainThread:@selector(display) withObject:nil waitUntilDone:YES];
+ DBG_PRINT("MyNSOpenGLLayer::setNSOpenGLLayerNeedsDisplay %p\n", l);
+ [pool release];
+}
+
+void releaseNSOpenGLLayer(NSOpenGLLayer* l) {
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ [l release];
+ [pool release];
+}
+
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.h b/src/jogl/native/macosx/MacOSXWindowSystemInterface.h
new file mode 100644
index 000000000..763930e37
--- /dev/null
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.h
@@ -0,0 +1,20 @@
+#import <Cocoa/Cocoa.h>
+#import <OpenGL/gl.h>
+#import <OpenGL/CGLTypes.h>
+#import <jni.h>
+
+#define VERBOSE_ON 1
+
+#ifdef VERBOSE_ON
+ // #define DBG_PRINT(...) NSLog(@ ## __VA_ARGS__)
+ #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
+#else
+ #define DBG_PRINT(...)
+#endif
+
+#ifndef CGL_VERSION_1_3
+ #warning this SDK doesn't support OpenGL profile
+#endif
+
+#import "macosx-window-system.h"
+
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
index 7c10545f3..af269a4b5 100644
--- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
@@ -14,28 +14,10 @@
#endif
*/
-#import <Cocoa/Cocoa.h>
-#import <OpenGL/gl.h>
-#import <OpenGL/CGLTypes.h>
-#import <jni.h>
-
-#define VERBOSE_ON 1
-
-#ifdef VERBOSE_ON
- // #define DBG_PRINT(...) NSLog(@ ## __VA_ARGS__)
- #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
-#else
- #define DBG_PRINT(...)
-#endif
-
-#ifndef CGL_VERSION_1_3
- #warning this SDK doesn't support OpenGL profile
-#endif
+#import "MacOSXWindowSystemInterface.h"
#import "ContextUpdater.h"
-#import "macosx-window-system.h"
-
// see MacOSXPbufferGLContext.java createPbuffer
#define USE_GL_TEXTURE_RECTANGLE_EXT
@@ -399,6 +381,18 @@ NSOpenGLPixelFormat* createPixelFormat(int* iattrs, int niattrs, int* ivalues) {
for (i = 0; i < niattrs && iattrs[i]>0; i++) {
int attr = iattrs[i];
switch (attr) {
+ case NSOpenGLPFANoRecovery:
+ if (ivalues[i] != 0) {
+ attribs[idx++] = NSOpenGLPFANoRecovery;
+ }
+ break;
+
+ case NSOpenGLPFAAccelerated:
+ if (ivalues[i] != 0) {
+ attribs[idx++] = NSOpenGLPFAAccelerated;
+ }
+ break;
+
case NSOpenGLPFAPixelBuffer:
if (ivalues[i] != 0) {
attribs[idx++] = NSOpenGLPFAPixelBuffer;
@@ -678,153 +672,9 @@ void setContextPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer) {
[pool release];
}
-void setContextTextureImageToPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer, int colorBuffer) {
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- [ctx setTextureImageToPixelBuffer: pBuffer
- colorBuffer: (unsigned long) colorBuffer];
- [pool release];
-}
-
-@interface MyNSOpenGLLayer: NSOpenGLLayer
-{
-@protected
- NSOpenGLContext* ctx;
- NSView* nsView;
- NSOpenGLPixelFormat* fmt;
-@public
- volatile BOOL shallDraw;
-}
-
-- (id) initWithContext: (NSOpenGLContext*) ctx
- pixelFormat: (NSOpenGLPixelFormat*) pfmt
- view: (NSView*) v
- opaque: (Bool) opaque;
-
-@end
-
-@implementation MyNSOpenGLLayer
-
-- (id) initWithContext: (NSOpenGLContext*) _ctx
- pixelFormat: (NSOpenGLPixelFormat*) pfmt
- view: (NSView*) view
- opaque: (Bool) opaque
-{
- self = [super init];
- self->ctx = _ctx;
- if(NULL != ctx) {
- [ctx retain];
- }
- fmt = pfmt;
- if(NULL != fmt) {
- [fmt retain];
- }
- if(NULL != view) {
- [view retain];
- [self setView: view];
- [view setWantsLayer: YES];
- }
- [self setAsynchronous: NO];
- [self setNeedsDisplayOnBoundsChange: NO];
- [self setOpaque: opaque ? YES : NO];
- self->shallDraw=NO;
- DBG_PRINT("MyNSOpenGLLayer::init %p, ctx %p, pfmt %p, view %p, opaque %d\n", self, ctx, fmt, nsView, opaque);
- return self;
-}
-
-- (void)dealloc
-{
- if(NULL != ctx) {
- [ctx release];
- }
- if(NULL != fmt) {
- [fmt release];
- }
- if(NULL != nsView) {
- [nsView release];
- }
- DBG_PRINT("MyNSOpenGLLayer::dealloc %p\n", self);
- [super dealloc];
-}
-
-- (void) setOpenGLContext: (NSOpenGLContext*) _ctx
-{
- DBG_PRINT("MyNSOpenGLLayer::setOpenGLContext: %p %p -> %p (ignored)\n", self, ctx, _ctx);
-}
-
-- (NSOpenGLContext *) openGLContext
-{
- return ctx;
-}
-
-- (void) setOpenGLPixelFormat: (NSOpenGLPixelFormat*) pfmt
-{
- DBG_PRINT("MyNSOpenGLLayer::setOpenGLPixelFormat %p %p\n", self, pfmt);
-}
-
-- (NSOpenGLPixelFormat *) openGLPixelFormat
-{
- return fmt;
-}
-
-- (void) setView: (NSView*) v
-{
- DBG_PRINT("MyNSOpenGLLayer::setView %p %p\n", self, v);
- nsView = v;
- [super setView: nsView]; // propagate
-}
-
-- (NSView *) view
-{
- return nsView;
-}
-
-- (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask
-{
- DBG_PRINT("MyNSOpenGLLayer::openGLPixelFormatForDisplayMask %p %d\n", self, mask);
- return fmt;
-}
-
-- (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat
-{
- DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat %p %p\n", self, pixelFormat);
- return ctx;
-}
-
-- (BOOL)canDrawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat
- forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
-{
- DBG_PRINT("MyNSOpenGLLayer::canDrawInOpenGLContext %p: %d\n", self, self->shallDraw);
- return self->shallDraw;
-}
-
-- (void)drawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat
- forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
-{
- self->shallDraw = NO;
- DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p, ctx %p, pfmt %p\n", self, context, pixelFormat);
- [super drawInOpenGLContext: context pixelFormat: pixelFormat forLayerTime: timeInterval displayTime: timeStamp];
-}
-
-@end
-
-NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSView* view, Bool opaque) {
- return [[MyNSOpenGLLayer alloc] initWithContext:ctx pixelFormat: fmt view: view opaque: opaque];
-}
-
-void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* glLayer) {
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) glLayer;
- l->shallDraw = YES;
- // [l setNeedsDisplay];
- [l performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:YES];
- DBG_PRINT("MyNSOpenGLLayer::setNSOpenGLLayerNeedsDisplay %p\n", l);
- [pool release];
-}
-
-void releaseNSOpenGLLayer(NSOpenGLLayer* glLayer) {
+void setContextTextureImageToPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer, GLenum colorBuffer) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) glLayer;
- [l release];
+ [ctx setTextureImageToPixelBuffer: pBuffer colorBuffer: colorBuffer];
[pool release];
}
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
index 221eec393..55ec83279 100644
--- a/src/nativewindow/native/macosx/OSXmisc.m
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -177,7 +177,7 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyNSView0
JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AttachJAWTSurfaceLayer0
(JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer)
{
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ JNF_COCOA_ENTER(env);
JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer);
if (NULL == dsi) {
NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer");
@@ -186,10 +186,10 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AttachJAWTSur
CALayer* layer = (CALayer*) (intptr_t) caLayer;
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)dsi->platformInfo;
- // FIXME: JAU: surfaceLayers.layer = [layer autorelease];
- surfaceLayers.layer = layer;
+ surfaceLayers.layer = [layer autorelease];
+ // surfaceLayers.layer = layer; // FIXME: JAU
}];
- [pool release];
+ JNF_COCOA_EXIT(env);
return JNI_TRUE;
}