aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-10-13 13:47:30 +0200
committerSven Gothel <[email protected]>2011-10-13 13:47:30 +0200
commit3fd89ccc138eddb915372cff4843f69f764048a7 (patch)
treee56ee402ffbec00220e4bead29b39a73b467f48e /src
parent5d33b0a3ef993ff2d257c90abc3d84bc93269cd0 (diff)
MacOSX: Always release ctx on main thread (offscreen was frozen as well); Cleanup Warnings and OSX ContextUpdater
-
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java12
-rw-r--r--src/jogl/native/macosx/ContextUpdater.h8
-rw-r--r--src/jogl/native/macosx/ContextUpdater.m40
10 files changed, 33 insertions, 69 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 5bf0b53a2..acdde4e2c 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -273,11 +273,11 @@ public abstract class GLContextImpl extends GLContext {
throw new GLException("Surface not ready to lock: "+drawable);
}
try {
- destroyImpl();
if (DEBUG) {
System.err.println("GLContextImpl.destroy: " + toHexString(contextHandle) +
", isShared "+GLContextShareSet.isShared(this));
}
+ destroyImpl();
contextHandle = 0;
glDebugHandler = null;
// this maybe impl. in a platform specific way to release remaining shared ctx.
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index b35e38d02..383594d87 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -205,16 +205,9 @@ public abstract class MacOSXCGLContext extends GLContextImpl
if (CGL.kCGLNoError != CGL.CGLDestroyContext(contextHandle)) {
throw new GLException("Unable to delete OpenGL Context (CGL)");
}
- if (DEBUG) {
- System.err.println("!!! Destroyed OpenGL Context (CGL) " + toHexString(contextHandle));
- }
} else {
- final boolean isSharedContext = GLContextShareSet.isShared(this);
- if (!CGL.deleteContext(contextHandle, isSharedContext)) {
- throw new GLException("Unable to delete OpenGL Context (NS) "+toHexString(contextHandle)+", isShared "+isSharedContext);
- }
- if (DEBUG) {
- System.err.println("!!! Destroyed OpenGL Context (NS.s0) " + toHexString(contextHandle)+", isShared "+isSharedContext);
+ if (!CGL.deleteContext(contextHandle, true)) {
+ throw new GLException("Unable to delete OpenGL Context (NS) "+toHexString(contextHandle));
}
}
}
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java
index efc70e3dd..267578680 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java
@@ -343,9 +343,6 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
if (CGL.CGLDestroyContext(ctx) != CGL.kCGLNoError) {
throw new GLException("Unable to delete OpenGL context (cgl)");
}
- if (DEBUG) {
- System.err.println("!!! Destroyed OpenGL context (cgl)" + contextHandle);
- }
}
public boolean makeCurrent(long ctx) {
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java
index ec9ff8dd2..2554b5f67 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java
@@ -49,8 +49,8 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
private static final boolean DEBUG = Debug.debug("MacOSXPbufferCGLDrawable");
// State for render-to-texture and render-to-texture-rectangle support
- private int textureTarget; // e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_NV
- private int texture; // actual texture object
+ // private int textureTarget; // e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_NV
+ // private int texture; // actual texture object
// NSOpenGLPbuffer (for normal mode)
// CGLPbufferObj (for CGL_MODE situation, i.e., when Java2D/JOGL bridge is active)
@@ -91,9 +91,6 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
impl.destroy(pBuffer);
this.pBuffer = 0;
((SurfaceChangeable)ns).setSurfaceHandle(0);
- if (DEBUG) {
- System.err.println("Destroyed pbuffer: " + pBuffer);
- }
}
}
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
index 8f64e0a28..5e661b321 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
@@ -45,7 +45,6 @@ import java.awt.Graphics;
import javax.media.opengl.*;
import jogamp.opengl.*;
import jogamp.opengl.awt.*;
-import jogamp.opengl.macosx.cgl.*;
/** MacOSXCGLContext implementation supporting the Java2D/JOGL bridge
* on Mac OS X. The external GLDrawable mechanism does not work on Mac
@@ -119,9 +118,6 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL
protected void destroyImpl() throws GLException {
Java2D.destroyOGLContext(contextHandle);
- if (DEBUG) {
- System.err.println("!!! Destroyed OpenGL context " + contextHandle);
- }
}
public void setOpenGLMode(int mode) {
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java
index 4df3b7e34..b2c95de39 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java
@@ -93,7 +93,7 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
capabilities.getGreenBits() +
capabilities.getBlueBits() +
capabilities.getAlphaBits());
- header.setBiSize(header.size());
+ header.setBiSize(BITMAPINFOHEADER.size());
header.setBiWidth(width);
// NOTE: negating the height causes the DIB to be in top-down row
// order rather than bottom-up; ends up being correct during pixel
@@ -118,7 +118,7 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
System.err.println("WindowsBitmapWGLDrawable: " + width+"x"+height +
", bpp " + bitsPerPixel +
", bytes " + byteNum +
- ", header sz " + header.size() +
+ ", header sz " + BITMAPINFOHEADER.size() +
", DIB ptr num " + pb.capacity()+
", "+capabilities+
", werr "+werr);
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java
index 83354a7fb..7be2c1ac7 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -46,10 +46,12 @@ import javax.media.opengl.GL;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLException;
-import javax.media.opengl.GLPbuffer;
+// import javax.media.opengl.GLPbuffer;
import javax.media.opengl.GLProfile;
import jogamp.nativewindow.windows.GDI;
+import jogamp.opengl.GLDrawableImpl;
+
import javax.media.opengl.GLCapabilitiesImmutable;
public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
@@ -152,11 +154,12 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
boolean rtt = chosenCaps.getPbufferRenderToTexture();
boolean rect = chosenCaps.getPbufferRenderToTextureRectangle();
boolean useFloat = chosenCaps.getPbufferFloatingPointBuffers();
- boolean ati = false;
+ // boolean ati = false;
+ /**
if (useFloat) {
ati = (floatMode == GLPbuffer.ATI_FLOAT);
- }
+ } */
int[] pformats = new int[WindowsWGLGraphicsConfiguration.MAX_PFORMATS];
int nformats;
@@ -243,7 +246,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
{
WGLGLCapabilities newCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, parentHdc, pfdid, glProfile, false, true);
if(null == newCaps) {
- throw new GLException("pbuffer creation error: unable to re-query chosen PFD ID: " + pfdid + ", hdc " + this.toHexString(tmpHdc));
+ throw new GLException("pbuffer creation error: unable to re-query chosen PFD ID: " + pfdid + ", hdc " + GLDrawableImpl.toHexString(tmpHdc));
}
if(newCaps.isOnscreen() || !newCaps.isPBuffer()) {
throw new GLException("Error: Selected Onscreen Caps for PBuffer: "+newCaps);
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
index 26ad41fc7..935650137 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
@@ -449,17 +449,7 @@ public abstract class X11GLXContext extends GLContextImpl {
}
protected void destroyImpl() throws GLException {
- long display = drawable.getNativeSurface().getDisplayHandle();
- if (DEBUG) {
- System.err.println("glXDestroyContext(dpy " +
- toHexString(display)+
- ", ctx " +
- toHexString(contextHandle) + ")");
- }
- GLX.glXDestroyContext(display, contextHandle);
- if (DEBUG) {
- System.err.println("!!! Destroyed OpenGL context " + contextHandle);
- }
+ GLX.glXDestroyContext(drawable.getNativeSurface().getDisplayHandle(), contextHandle);
}
protected void copyImpl(GLContext source, int mask) throws GLException {
diff --git a/src/jogl/native/macosx/ContextUpdater.h b/src/jogl/native/macosx/ContextUpdater.h
index 2483ec403..3cf7315af 100644
--- a/src/jogl/native/macosx/ContextUpdater.h
+++ b/src/jogl/native/macosx/ContextUpdater.h
@@ -31,10 +31,10 @@ This notification is sent whenever an NSView that has an attached NSSurface chan
BOOL viewUpdated;
}
-+ (void) lock;
-+ (void) lockInFunction:(char *)func atLine:(int)line;
-+ (void) unlock;
-+ (void) unlockInFunction:(char *)func atLine:(int)line;
+- (void) lock;
+- (void) lockInFunction:(char *)func atLine:(int)line;
+- (void) unlock;
+- (void) unlockInFunction:(char *)func atLine:(int)line;
- (id) initWithContext:(NSOpenGLContext *)context view: (NSView *)nsView;
diff --git a/src/jogl/native/macosx/ContextUpdater.m b/src/jogl/native/macosx/ContextUpdater.m
index 64d5ef1f9..21f98ad5e 100644
--- a/src/jogl/native/macosx/ContextUpdater.m
+++ b/src/jogl/native/macosx/ContextUpdater.m
@@ -13,43 +13,31 @@ static void printLockDebugInfo(char *message, char *func, int line)
fflush(NULL);
}
-+ (void) lock
+- (void) lock
{
- if (ctx != NULL)
- {
- pthread_mutex_lock(&resourceLock);
- }
+ pthread_mutex_lock(&resourceLock);
}
-+ (void) lockInFunction:(char *)func atLine:(int)line
+- (void) lockInFunction:(char *)func atLine:(int)line
{
- if (ctx != NULL)
- {
- printLockDebugInfo("locked ", func, line);
- [self lock];
- }
+ printLockDebugInfo("locked ", func, line);
+ [self lock];
}
-+ (void) unlock
+- (void) unlock
{
- if (ctx != NULL)
- {
- pthread_mutex_unlock(&resourceLock);
- }
+ pthread_mutex_unlock(&resourceLock);
}
-+ (void) unlockInFunction:(char *)func atLine:(int)line
+- (void) unlockInFunction:(char *)func atLine:(int)line
{
- if (ctx != NULL)
- {
- printLockDebugInfo("unlocked", func, line);
- [self unlock];
- }
+ printLockDebugInfo("unlocked", func, line);
+ [self unlock];
}
- (void) update:(NSNotification *)notification
{
- [ContextUpdater lock];
+ [self lock];
NSRect r = [view frame];
if(viewRect.origin.x != r.origin.x ||
@@ -60,18 +48,18 @@ static void printLockDebugInfo(char *message, char *func, int line)
viewRect = r;
}
- [ContextUpdater unlock];
+ [self unlock];
}
- (BOOL) needsUpdate
{
BOOL r;
- [ContextUpdater lock];
+ [self lock];
r = viewUpdated;
viewUpdated = FALSE;
- [ContextUpdater unlock];
+ [self unlock];
return r;
}