summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-10-05 15:26:28 -0700
committerSven Gothel <[email protected]>2009-10-05 15:26:28 -0700
commit62fb860ffc454fc00ed73f9b6da54bba34a6d64f (patch)
treecd753aa602beeb429902f1c2b8096e13861fdbb6 /src
parent906e3698f1493daab5cf196b893e65b11b2f0d12 (diff)
Fix On-/Offscreen and PBuffer.
Demos are working again: demos.jrefract.JRefract - X11, Win32, OSX -Dsun.java2d.opengl=true demos.jrefract.JRefract - X11, Win32 demos.readbuffer.Main [-GL2,-GL2ES1] -test 0 demos.es1.RedSquare - X11, Win32, OSX, EGL demos.readbuffer.Main [-GL2,-GL2ES1] -test [12] demos.es1.RedSquare - X11, Win32 - OSX not, because of the missing feature of attaching a read surface. - EGL not, because the emulation I used didn't support attaching a read surface. Emulation bug .. probably .. MacOSXWindowSystemInterface.m createContext(): - Verify if passed surface handle _is_ a view, now it could be a pbuffer etc .. handle as well. Cleanup GLDrawableImpl.setRealized(boolean realized) - Calls setRealizedImpl() (implementation) now, and only if new stated differs .. - setRealizedImpl() fixed for: MacOSXPbufferCGLDrawable: recreate/destroy WindowsOffscreenWGLDrawable: recreate/destroy WindowsPbufferWGLDrawable: no-recreate/destroy X11OffscreenGLXDrawable: recreate/destroy X11PbufferGLXDrawable: recreate/destroy WindowsWGLContext: - wglMakeContextCurrent(): uses isFunctionAvailable .. - create(): Uses WGL.MakeCurrent() and releases the created context, due to unavailable MakeContextCurrent extensions before updating the procaddress tables.
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java9
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java11
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java15
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java10
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java8
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java8
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java21
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java9
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java25
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java9
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java10
-rw-r--r--src/jogl/native/macosx/MacOSXWindowSystemInterface.m7
-rw-r--r--src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java5
17 files changed, 120 insertions, 43 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
index aa775c3ae..ceef07727 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
@@ -173,6 +173,15 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
super();
}
+ protected void maybeDoSingleThreadedWorkaround(Runnable action) {
+ if (Threading.isSingleThreaded() &&
+ !Threading.isOpenGLThread()) {
+ Threading.invokeOnOpenGLThread(action);
+ } else {
+ action.run();
+ }
+ }
+
/**
* Returns the sole GLDrawableFactoryImpl instance.
*
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
index 865abe09f..befee170f 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
@@ -112,8 +112,17 @@ public abstract class GLDrawableImpl implements GLDrawable {
}
public void setRealized(boolean realized) {
- this.realized = realized;
+ if ( this.realized != realized ) {
+ if(DEBUG) {
+ System.err.println("setRealized: "+getClass().getName()+" "+this.realized+" -> "+realized);
+ }
+ this.realized = realized;
+ setRealizedImpl();
+ } else if(DEBUG) {
+ System.err.println("setRealized: "+getClass().getName()+" "+this.realized+" == "+realized);
+ }
}
+ protected abstract void setRealizedImpl();
public boolean getRealized() {
return realized;
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
index f109c9497..dd801e4e2 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
@@ -97,9 +97,7 @@ public abstract class EGLDrawable extends GLDrawableImpl {
}
}
- public void setRealized(boolean realized) {
- super.setRealized(realized);
-
+ protected void setRealizedImpl() {
if (realized) {
if ( NativeWindow.LOCK_SURFACE_NOT_READY == lockSurface() ) {
throw new GLException("Couldn't lock surface");
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
index 662c2ba78..b417668da 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
@@ -82,9 +82,7 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
super(factory, comp, realized);
}
- public void setRealized(boolean realized) {
- super.setRealized(realized);
-
+ protected void setRealizedImpl() {
if(realized) {
if( NativeWindow.LOCK_SURFACE_NOT_READY == lockSurface() ) {
throw new GLException("Couldn't lock surface");
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
index f8c15b7f2..be18ee2da 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -77,7 +77,20 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements D
return true;
}
- protected GLDrawableImpl createGLPbufferDrawableImpl(NativeWindow target) {
+ protected GLDrawableImpl createGLPbufferDrawableImpl(final NativeWindow target) {
+ /**
+ * FIXME: Think about this ..
+ * should not be necessary ? ..
+ final List returnList = new ArrayList();
+ final GLDrawableFactory factory = this;
+ Runnable r = new Runnable() {
+ public void run() {
+ returnList.add(new MacOSXPbufferCGLDrawable(factory, target));
+ }
+ };
+ maybeDoSingleThreadedWorkaround(r);
+ return (GLDrawableImpl) returnList.get(0);
+ */
return new MacOSXPbufferCGLDrawable(this, target);
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
index c90e5d6bd..f57952b7c 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
@@ -71,14 +71,24 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
}
}
+ protected void setRealizedImpl() {
+ if(realized) {
+ createPbuffer();
+ } else {
+ destroy();
+ }
+ }
+
public GLContext createContext(GLContext shareWith) {
return new MacOSXPbufferCGLContext(this, shareWith);
}
public void destroy() {
if (this.pBuffer != 0) {
+ NativeWindow nw = getNativeWindow();
impl.destroy(pBuffer);
this.pBuffer = 0;
+ ((SurfaceChangeable)nw).setSurfaceHandle(0);
if (DEBUG) {
System.err.println("Destroyed pbuffer: " + pBuffer);
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
index 35fbcc6f5..f254748d1 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
@@ -53,6 +53,14 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
create();
}
+ protected void setRealizedImpl() {
+ if(realized) {
+ create();
+ } else {
+ destroy();
+ }
+ }
+
public GLContext createContext(GLContext shareWith) {
return new WindowsOffscreenWGLContext(this, shareWith);
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
index 798eafad3..2bc6660fb 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -67,6 +67,14 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
}
}
+ protected void setRealizedImpl() {
+ if(realized) {
+ throw new GLException("Recreation via setRealized not supported.");
+ } else {
+ destroy();
+ }
+ }
+
public GLContext createContext(GLContext shareWith) {
return new WindowsPbufferWGLContext(this, shareWith);
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
index b07cd6046..418336e3f 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -95,9 +95,12 @@ public class WindowsWGLContext extends GLContextImpl {
public boolean wglMakeContextCurrent(long hDrawDC, long hReadDC, long hglrc) {
WGLExt wglExt = getWGLExt();
if (!wglMakeContextCurrentInitialized) {
- wglMakeContextCurrentARBAvailable = (WGL.wglGetProcAddress("wglMakeContextCurrentARB") != 0);
- wglMakeContextCurrentEXTAvailable = (WGL.wglGetProcAddress("wglMakeContextCurrentEXT") != 0);
+ wglMakeContextCurrentARBAvailable = isFunctionAvailable("wglMakeContextCurrentARB");
+ wglMakeContextCurrentEXTAvailable = isFunctionAvailable("wglMakeContextCurrentEXT");
wglMakeContextCurrentInitialized = true;
+ if(DEBUG) {
+ System.err.println("WindowsWGLContext.wglMakeContextCurrent: ARB "+wglMakeContextCurrentARBAvailable+", EXT "+wglMakeContextCurrentEXTAvailable);
+ }
}
if(wglMakeContextCurrentARBAvailable) {
return wglExt.wglMakeContextCurrentARB(hDrawDC, hReadDC, hglrc);
@@ -163,7 +166,7 @@ public class WindowsWGLContext extends GLContextImpl {
if (temp_hglrc == 0) {
throw new GLException("Unable to create temp OpenGL context for device context " + toHexString(drawable.getNativeWindow().getSurfaceHandle()));
} else {
- if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), temp_hglrc)) {
+ if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), temp_hglrc)) {
throw new GLException("Error making temp context current: 0x" + Integer.toHexString(WGL.GetLastError()));
}
setGLFunctionAvailability(true);
@@ -171,7 +174,7 @@ public class WindowsWGLContext extends GLContextImpl {
if( !isFunctionAvailable("wglCreateContextAttribsARB") ||
!isExtensionAvailable("WGL_ARB_create_context") ) {
if(glCaps.getGLProfile().isGL3()) {
- wglMakeContextCurrent(0, 0, 0);
+ WGL.wglMakeCurrent(0, 0);
WGL.wglDeleteContext(temp_hglrc);
throw new GLException("Unable to create OpenGL >= 3.1 context (no WGL_ARB_create_context)");
}
@@ -230,25 +233,26 @@ public class WindowsWGLContext extends GLContextImpl {
if(0==hglrc) {
if(glCaps.getGLProfile().isGL3()) {
- wglMakeContextCurrent(0, 0, 0);
+ WGL.wglMakeCurrent(0, 0);
WGL.wglDeleteContext(temp_hglrc);
throw new GLException("Unable to create OpenGL >= 3.1 context (have WGL_ARB_create_context)");
}
// continue with temp context for GL < 3.0
hglrc = temp_hglrc;
- if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), hglrc)) {
+ if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), hglrc)) {
throw new GLException("Error making old context current: 0x" + Integer.toHexString(WGL.GetLastError()));
}
+ updateGLProcAddressTable();
if(DEBUG) {
System.err.println("WindowsWGLContext.create done (old ctx < 3.0 - no 3.0) 0x"+Long.toHexString(hglrc));
}
} else {
hglrc2 = 0; // mark as shared ..
- wglMakeContextCurrent(0, 0, 0);
+ WGL.wglMakeCurrent(0, 0);
WGL.wglDeleteContext(temp_hglrc);
- if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), hglrc)) {
+ if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), hglrc)) {
throw new GLException("Error making new context current: 0x" + Integer.toHexString(WGL.GetLastError()));
}
updateGLProcAddressTable();
@@ -266,6 +270,7 @@ public class WindowsWGLContext extends GLContextImpl {
}
}
GLContextShareSet.contextCreated(this);
+ WGL.wglMakeCurrent(0, 0); // release immediatly to gain from ARB/EXT wglMakeContextCurrent(draw, read, ctx)!
if (DEBUG) {
System.err.println(getThreadName() + ": !!! Created OpenGL context " + toHexString(hglrc) + " for " + this + ", device context " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) + ", sharing with " + toHexString(hglrc2));
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java
index 01e259665..91604d18e 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java
@@ -60,9 +60,7 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
super(factory, comp, realized);
}
- public void setRealized(boolean realized) {
- super.setRealized(realized);
-
+ protected void setRealizedImpl() {
if(!realized) {
return; // nothing todo ..
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
index af65861b9..e37179191 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -222,15 +222,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
return detail;
}
- private void maybeDoSingleThreadedWorkaround(Runnable action) {
- if (Threading.isSingleThreaded() &&
- !Threading.isOpenGLThread()) {
- Threading.invokeOnOpenGLThread(action);
- } else {
- action.run();
- }
- }
-
public boolean canCreateContextOnJava2DSurface() {
return false;
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java
index 1abc36c58..c2a1987cc 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java
@@ -54,9 +54,7 @@ public abstract class X11GLXDrawable extends GLDrawableImpl {
return (X11GLXDrawableFactory) getFactoryImpl() ;
}
- public void setRealized(boolean realized) {
- super.setRealized(realized);
-
+ protected void setRealizedImpl() {
if(!realized) {
return; // nothing to do
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index f6c911c63..ebf650ae4 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -110,10 +110,24 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
return canCreateGLPbuffer;
}
- protected GLDrawableImpl createGLPbufferDrawableImpl(NativeWindow target) {
+ protected GLDrawableImpl createGLPbufferDrawableImpl(final NativeWindow target) {
+ /**
+ * FIXME: Think about this ..
+ * should not be necessary ? ..
+ final List returnList = new ArrayList();
+ final GLDrawableFactory factory = this;
+ Runnable r = new Runnable() {
+ public void run() {
+ returnList.add(new X11PbufferGLXDrawable(factory, target));
+ }
+ };
+ maybeDoSingleThreadedWorkaround(r);
+ return (GLDrawableImpl) returnList.get(0);
+ */
return new X11PbufferGLXDrawable(this, target);
}
+
protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
AbstractGraphicsScreen screen = X11GraphicsScreen.createDefault();
NullWindow nw = new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, screen));
@@ -147,15 +161,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
return res;
}
- private void maybeDoSingleThreadedWorkaround(Runnable action) {
- if (Threading.isSingleThreaded() &&
- !Threading.isOpenGLThread()) {
- Threading.invokeOnOpenGLThread(action);
- } else {
- action.run();
- }
- }
-
public boolean canCreateContextOnJava2DSurface() {
return false;
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
index 98eca44d9..c8b8851f8 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
@@ -52,6 +52,14 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
create();
}
+ protected void setRealizedImpl() {
+ if(realized) {
+ create();
+ } else {
+ destroy();
+ }
+ }
+
public GLContext createContext(GLContext shareWith) {
return new X11OffscreenGLXContext(this, shareWith);
}
@@ -123,6 +131,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
drawable = 0;
pixmap = 0;
display = 0;
+ ((SurfaceChangeable)nw).setSurfaceHandle(0);
} finally {
getFactoryImpl().unlockToolkit();
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
index ddb96ae6b..e87ef54ac 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
@@ -63,6 +63,14 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
}
}
+ protected void setRealizedImpl() {
+ if(realized) {
+ createPbuffer();
+ } else {
+ destroy();
+ }
+ }
+
public GLContext createContext(GLContext shareWith) {
return new X11PbufferGLXContext(this, shareWith);
}
@@ -74,7 +82,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
if (nw.getSurfaceHandle() != 0) {
GLX.glXDestroyPbuffer(nw.getDisplayHandle(), nw.getSurfaceHandle());
}
- nw.invalidate();
+ ((SurfaceChangeable)nw).setSurfaceHandle(0);
} finally {
getFactoryImpl().unlockToolkit();
}
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
index 5405ad4ee..cbfea6d71 100644
--- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
@@ -476,7 +476,12 @@ void* createContext(void* shareContext,
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- NSView *nsView = (NSView*)view;
+ NSView *nsView = NULL;
+ NSObject *nsObj = (NSObject*) view;
+
+ if( nsObj != NULL && [nsObj isKindOfClass:[NSView class]] ) {
+ nsView = (NSView*)nsObj;
+ }
if (nsView != NULL)
{
diff --git a/src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java b/src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java
index c8e3c7c9e..b5efc03e8 100644
--- a/src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java
@@ -66,6 +66,11 @@ public class OffscreenWindow extends Window implements SurfaceChangeable {
// nop
}
+ public void invalidate() {
+ super.invalidate();
+ disposeSurfaceHandle();
+ }
+
public void disposeSurfaceHandle() {
surfaceHandle = 0;
}