aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-10-25 06:11:14 +0200
committerSven Gothel <[email protected]>2011-10-25 06:11:14 +0200
commit4433f2a68fa3ca500e258a6862b0e95461fc5083 (patch)
tree9d0b33c44218834d403272a0a241f2e55c95a5ed /src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java
parent3b6ef84e25a3fcaa2de381be3758c144ae239b6a (diff)
MacOSX: Pull down (and fix releaseContext) NSOPENGL/CGL mode/impl, fixes SWT usage and FBOMRT
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java52
1 files changed, 22 insertions, 30 deletions
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java
index 513dc3a04..24276c39e 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java
@@ -41,51 +41,43 @@
package jogamp.opengl.macosx.cgl;
import java.lang.ref.WeakReference;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
-import javax.media.nativewindow.*;
-import javax.media.opengl.*;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
public class MacOSXOnscreenCGLDrawable extends MacOSXCGLDrawable {
- private List/*<WeakReference<GLContext>>*/ createdContexts =
- new ArrayList();
+ private List<WeakReference<MacOSXCGLContext>> createdContexts = new ArrayList<WeakReference<MacOSXCGLContext>>();
protected MacOSXOnscreenCGLDrawable(GLDrawableFactory factory, NativeSurface component) {
super(factory, component, false);
}
public GLContext createContext(GLContext shareWith) {
- MacOSXOnscreenCGLContext context =
- new MacOSXOnscreenCGLContext(this, shareWith);
+ MacOSXOnscreenCGLContext ctx= new MacOSXOnscreenCGLContext(this, shareWith);
// 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 (this) {
- List newContexts = new ArrayList();
- newContexts.addAll(createdContexts);
- newContexts.add(new WeakReference(context));
- createdContexts = newContexts;
+ synchronized (createdContexts) {
+ createdContexts.add(new WeakReference<MacOSXCGLContext>(ctx));
}
- return context;
+ return ctx;
}
protected void swapBuffersImpl() {
- for (Iterator iter = createdContexts.iterator(); iter.hasNext(); ) {
- WeakReference ref = (WeakReference) iter.next();
- MacOSXOnscreenCGLContext ctx = (MacOSXOnscreenCGLContext) ref.get();
- // FIXME: clear out unreachable contexts
- if (ctx != null) {
- ctx.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 void setOpenGLMode(int mode) {
- if (mode != NSOPENGL_MODE)
- throw new GLException("OpenGL mode switching not supported for on-screen GLDrawables");
- }
-
- public int getOpenGLMode() {
- return NSOPENGL_MODE;
- }
+ }
}