aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/impl/macosx
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/macosx')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java45
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java10
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java21
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDynamicLibraryBundleInfo.java (renamed from src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDynamicLookupHelper.java)60
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java86
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java51
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java49
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java31
9 files changed, 104 insertions, 251 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java
index 371df1ee5..46b86a557 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java
@@ -134,7 +134,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
int[] viewNotReady = new int[1];
// Try to allocate a context with this
contextHandle = CGL.createContext(share,
- drawable.getNativeWindow().getSurfaceHandle(),
+ drawable.getHandle(),
pixelFormat,
viewNotReady, 0);
if (contextHandle == 0) {
@@ -166,26 +166,8 @@ public abstract class MacOSXCGLContext extends GLContextImpl
GLContextShareSet.contextCreated(this);
return true;
}
-
- protected int makeCurrentImpl() throws GLException {
- if (0 == drawable.getNativeWindow().getSurfaceHandle()) {
- throw new GLException("drawable has invalid surface handle: "+drawable);
- }
- boolean newCreated = false;
- if (!isCreated()) {
- create();
- newCreated = isCreated();
- if(!newCreated) {
- if (DEBUG) {
- System.err.println("!!! GL Context creation failed for " + getClass().getName());
- }
- return CONTEXT_NOT_CURRENT;
- }
- if (DEBUG) {
- System.err.println("!!! Created OpenGL context " + toHexString(contextHandle) + " for " + getClass().getName());
- }
- }
-
+
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
if ( isNSContext ) {
if (!CGL.makeCurrentContext(contextHandle)) {
throw new GLException("Error making Context (NS) current");
@@ -195,12 +177,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl
throw new GLException("Error making Context (CGL) current");
}
}
-
- if (newCreated) {
- setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
- return CONTEXT_CURRENT_NEW;
- }
- return CONTEXT_CURRENT;
}
protected void releaseImpl() throws GLException {
@@ -214,9 +190,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
protected void destroyImpl() throws GLException {
- if( ! isCreated() ) {
- return;
- }
if ( !isNSContext ) {
if (CGL.kCGLNoError != CGL.CGLDestroyContext(contextHandle)) {
throw new GLException("Unable to delete OpenGL Context (CGL)");
@@ -224,8 +197,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl
if (DEBUG) {
System.err.println("!!! Destroyed OpenGL Context (CGL) " + contextHandle);
}
- contextHandle = 0;
- GLContextShareSet.contextDestroyed(this);
} else {
if (!CGL.deleteContext(contextHandle)) {
throw new GLException("Unable to delete OpenGL Context (NS)");
@@ -233,20 +204,12 @@ public abstract class MacOSXCGLContext extends GLContextImpl
if (DEBUG) {
System.err.println("!!! Destroyed OpenGL Context (NS) " + contextHandle);
}
- contextHandle = 0;
}
- GLContextShareSet.contextDestroyed(this);
}
- public void copy(GLContext source, int mask) throws GLException {
+ protected void copyImpl(GLContext source, int mask) throws GLException {
long dst = getHandle();
- if (0 == dst) {
- throw new GLException("Destination OpenGL Context has not been created");
- }
long src = source.getHandle();
- if (0 == src) {
- throw new GLException("Source OpenGL Context has not been created");
- }
if( !isNSContext() ) {
if ( ((MacOSXCGLContext)source).isNSContext() ) {
throw new GLException("Source OpenGL Context is NS ; Destination Context is CGL.");
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
index 3f41d95cb..23fdcbf6d 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
@@ -42,7 +42,6 @@ package com.jogamp.opengl.impl.macosx.cgl;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.jogamp.opengl.impl.*;
-import com.jogamp.common.os.DynamicLookupHelper;
public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
// The Java2D/OpenGL pipeline on OS X uses low-level CGLContextObjs
@@ -83,17 +82,10 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
}
protected void setRealizedImpl() {
- if(realized) {
- if( NativeWindow.LOCK_SURFACE_NOT_READY == lockSurface() ) {
- throw new GLException("Couldn't lock surface");
- }
- // locking the surface is essential to update surface data
- unlockSurface();
- }
}
public GLDynamicLookupHelper getGLDynamicLookupHelper() {
- return MacOSXCGLDynamicLookupHelper.getMacOSXCGLDynamicLookupHelper();
+ return getFactoryImpl().getGLDynamicLookupHelper(0);
}
protected static String getThreadName() {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
index e507e4886..7f050412d 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -48,9 +48,26 @@ import com.jogamp.opengl.impl.*;
import com.jogamp.nativewindow.impl.NullWindow;
public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
+ private static final DesktopGLDynamicLookupHelper macOSXCGLDynamicLookupHelper;
+
+ static {
+ DesktopGLDynamicLookupHelper tmp = null;
+ try {
+ tmp = new DesktopGLDynamicLookupHelper(new MacOSXCGLDynamicLibraryBundleInfo());
+ } catch (GLException gle) {
+ if(DEBUG) {
+ gle.printStackTrace();
+ }
+ }
+ macOSXCGLDynamicLookupHelper = tmp;
+ /** FIXME ??
+ if(null!=macOSXCGLDynamicLookupHelper) {
+ CGL.getCGLProcAddressTable().reset(macOSXCGLDynamicLookupHelper);
+ } */
+ }
public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
- return MacOSXCGLDynamicLookupHelper.getMacOSXCGLDynamicLookupHelper();
+ return macOSXCGLDynamicLookupHelper;
}
public MacOSXCGLDrawableFactory() {
@@ -60,8 +77,6 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
// The act of constructing them causes them to be registered
new MacOSXCGLGraphicsConfigurationFactory();
- MacOSXCGLDynamicLookupHelper.getMacOSXCGLDynamicLookupHelper(); // setup and initialize
-
try {
ReflectionUtil.createInstance("com.jogamp.opengl.impl.macosx.cgl.awt.MacOSXAWTCGLGraphicsConfigurationFactory",
new Object[] {});
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDynamicLookupHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDynamicLibraryBundleInfo.java
index 3ed75b245..154cf61b5 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDynamicLookupHelper.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDynamicLibraryBundleInfo.java
@@ -35,59 +35,37 @@ import java.util.*;
import java.security.*;
import javax.media.opengl.GLException;
-public class MacOSXCGLDynamicLookupHelper extends DesktopGLDynamicLookupHelper {
- private static final MacOSXCGLDynamicLookupHelper macOSXCGLDynamicLookupHelper;
-
- static {
- MacOSXCGLDynamicLookupHelper tmp = null;
- try {
- tmp = new MacOSXCGLDynamicLookupHelper();
- } catch (GLException gle) {
- if(DEBUG) {
- gle.printStackTrace();
- }
- }
- macOSXCGLDynamicLookupHelper = tmp;
- }
-
- public static MacOSXCGLDynamicLookupHelper getMacOSXCGLDynamicLookupHelper() {
- return macOSXCGLDynamicLookupHelper;
- }
-
- protected MacOSXCGLDynamicLookupHelper() {
+public class MacOSXCGLDynamicLibraryBundleInfo extends DesktopGLDynamicLibraryBundleInfo {
+ protected MacOSXCGLDynamicLibraryBundleInfo() {
super();
}
- public synchronized void loadGLULibrary() {
- if(null==gluLib) {
- List/*<String>*/ gluLibNames = new ArrayList();
- gluLibNames.add("/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib");
- gluLibNames.add("GLU");
- gluLib = loadFirstAvailable(gluLibNames, null, false);
- if(null != gluLib) {
- glLibraries.add(gluLib);
- }
- }
- }
- NativeLibrary gluLib = null;
+ public List getToolLibNames() {
+ List/*<List>*/ libNamesList = new ArrayList();
- protected final List/*<String>*/ getGLLibNames() {
List/*<String>*/ glesLibNames = new ArrayList();
+
glesLibNames.add("/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib");
glesLibNames.add("GL");
- return glesLibNames;
- }
- protected final List/*<String>*/ getGLXLibNames() {
- return null;
+ libNamesList.add(glesLibNames);
+
+ return libNamesList;
}
- protected final String getGLXGetProcAddressFuncName() {
- return "getProcAddress" ; // dummy
+ public final List getToolGetProcAddressFuncNameList() {
+ return null;
+ /** OSX manual says: NSImage use is discouraged
+ List res = new ArrayList();
+ res.add("GetProcAddress"); // dummy
+ return res; */
}
- protected long dynamicLookupFunctionOnGLX(long glxGetProcAddressHandle, String glFuncName) {
- return CGL.getProcAddress(glFuncName); // manual implementation
+ public final long toolDynamicLookupFunction(long toolGetProcAddressHandle, String funcName) {
+ return 0;
+ /** OSX manual says: NSImage use is discouraged
+ return CGL.getProcAddress(glFuncName); // manual implementation
+ */
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java
index 9865fdfca..e8518925a 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java
@@ -60,56 +60,52 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext {
}
protected static MacOSXExternalCGLContext create(GLDrawableFactory factory, GLProfile glp) {
- ((GLDrawableFactoryImpl)factory).lockToolkit();
- try {
- long pixelFormat = 0;
- long currentDrawable = 0;
- long contextHandle = CGL.getCurrentContext(); // Check: MacOSX 10.3 ..
- boolean isNSContext = 0 != contextHandle;
- if( isNSContext ) {
- currentDrawable = CGL.getNSView(contextHandle);
- long ctx = CGL.getCGLContext(contextHandle);
- if (ctx == 0) {
- throw new GLException("Error: NULL Context (CGL) of Context (NS) 0x" +Long.toHexString(contextHandle));
- }
- pixelFormat = CGL.CGLGetPixelFormat(ctx);
- if(DEBUG) {
- System.err.println("MacOSXExternalCGLContext Create Context (NS) 0x"+Long.toHexString(contextHandle)+
- ", Context (CGL) 0x"+Long.toHexString(ctx)+
- ", pixelFormat 0x"+Long.toHexString(pixelFormat));
- }
- } else {
- contextHandle = CGL.CGLGetCurrentContext();
- if (contextHandle == 0) {
- throw new GLException("Error: current Context (CGL) null, no Context (NS)");
- }
- pixelFormat = CGL.CGLGetPixelFormat(contextHandle);
- if(DEBUG) {
- System.err.println("MacOSXExternalCGLContext Create Context (CGL) 0x"+Long.toHexString(contextHandle)+
- ", pixelFormat 0x"+Long.toHexString(pixelFormat));
- }
+ long pixelFormat = 0;
+ long currentDrawable = 0;
+ long contextHandle = CGL.getCurrentContext(); // Check: MacOSX 10.3 ..
+ boolean isNSContext = 0 != contextHandle;
+ if( isNSContext ) {
+ currentDrawable = CGL.getNSView(contextHandle);
+ long ctx = CGL.getCGLContext(contextHandle);
+ if (ctx == 0) {
+ throw new GLException("Error: NULL Context (CGL) of Context (NS) 0x" +Long.toHexString(contextHandle));
}
-
- if (0 == pixelFormat) {
- throw new GLException("Error: current pixelformat of current Context 0x"+Long.toHexString(contextHandle)+" is null");
+ pixelFormat = CGL.CGLGetPixelFormat(ctx);
+ if(DEBUG) {
+ System.err.println("MacOSXExternalCGLContext Create Context (NS) 0x"+Long.toHexString(contextHandle)+
+ ", Context (CGL) 0x"+Long.toHexString(ctx)+
+ ", pixelFormat 0x"+Long.toHexString(pixelFormat));
}
- GLCapabilities caps = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(glp, pixelFormat);
+ } else {
+ contextHandle = CGL.CGLGetCurrentContext();
+ if (contextHandle == 0) {
+ throw new GLException("Error: current Context (CGL) null, no Context (NS)");
+ }
+ pixelFormat = CGL.CGLGetPixelFormat(contextHandle);
if(DEBUG) {
- System.err.println("MacOSXExternalCGLContext Create "+caps);
+ System.err.println("MacOSXExternalCGLContext Create Context (CGL) 0x"+Long.toHexString(contextHandle)+
+ ", pixelFormat 0x"+Long.toHexString(pixelFormat));
}
+ }
- AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault();
- MacOSXCGLGraphicsConfiguration cfg = new MacOSXCGLGraphicsConfiguration(aScreen, caps, caps, pixelFormat);
-
- NullWindow nw = new NullWindow(cfg);
- nw.setSurfaceHandle(currentDrawable);
- return new MacOSXExternalCGLContext(new Drawable(factory, nw), isNSContext, contextHandle);
- } finally {
- ((GLDrawableFactoryImpl)factory).unlockToolkit();
+ if (0 == pixelFormat) {
+ throw new GLException("Error: current pixelformat of current Context 0x"+Long.toHexString(contextHandle)+" is null");
+ }
+ GLCapabilities caps = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(glp, pixelFormat);
+ if(DEBUG) {
+ System.err.println("MacOSXExternalCGLContext Create "+caps);
}
+
+ AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault();
+ MacOSXCGLGraphicsConfiguration cfg = new MacOSXCGLGraphicsConfiguration(aScreen, caps, caps, pixelFormat);
+
+ NullWindow nw = new NullWindow(cfg);
+ nw.setSurfaceHandle(currentDrawable);
+ return new MacOSXExternalCGLContext(new Drawable(factory, nw), isNSContext, contextHandle);
}
- protected void create() {
+ protected boolean createImpl() throws GLException {
+ return true;
}
public int makeCurrent() throws GLException {
@@ -129,20 +125,16 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext {
lastContext = null;
}
- protected int makeCurrentImpl() throws GLException {
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
if (firstMakeCurrent) {
firstMakeCurrent = false;
- return CONTEXT_CURRENT_NEW;
}
- return CONTEXT_CURRENT;
}
protected void releaseImpl() throws GLException {
}
protected void destroyImpl() throws GLException {
- contextHandle = 0;
- GLContextShareSet.contextDestroyed(this);
}
public void setOpenGLMode(int mode) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java
index ede0c28eb..568204384 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java
@@ -54,52 +54,13 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
this.drawable = drawable;
}
- protected int makeCurrentImpl() throws GLException {
- int lockRes = drawable.lockSurface();
- boolean exceptionOccurred = false;
- try {
- if (lockRes == NativeWindow.LOCK_SURFACE_NOT_READY) {
- return CONTEXT_NOT_CURRENT;
- }
- int ret = super.makeCurrentImpl();
- if ((ret == CONTEXT_CURRENT) ||
- (ret == CONTEXT_CURRENT_NEW)) {
- // Assume the canvas might have been resized or moved and tell the OpenGL
- // context to update itself. This used to be done only upon receiving a
- // reshape event but that doesn't appear to be sufficient. An experiment
- // was also done to add a HierarchyBoundsListener to the GLCanvas and
- // do this updating only upon reshape of this component or reshape or movement
- // of an ancestor, but this also wasn't sufficient and left garbage on the
- // screen in some situations.
- CGL.updateContext(contextHandle);
- } else {
- if (!isOptimizable()) {
- // This can happen if the window currently is zero-sized, for example.
- // Make sure we don't leave the surface locked in this case.
- drawable.unlockSurface();
- lockRes = NativeWindow.LOCK_SURFACE_NOT_READY;
- }
- }
- return ret;
- } catch (RuntimeException e) {
- exceptionOccurred = true;
- throw e;
- } finally {
- if (exceptionOccurred ||
- (isOptimizable() && lockRes != NativeWindow.LOCK_SURFACE_NOT_READY)) {
- drawable.unlockSurface();
- }
- }
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
+ super.makeCurrentImpl(newCreated);
+ CGL.updateContext(contextHandle);
}
protected void releaseImpl() throws GLException {
- try {
- super.releaseImpl();
- } finally {
- if (!isOptimizable() && drawable.isSurfaceLocked()) {
- drawable.unlockSurface();
- }
- }
+ super.releaseImpl();
}
protected void swapBuffers() {
@@ -115,8 +76,8 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
CGL.updateContext(contextHandle);
}
- protected void create() {
- create(false, false);
+ protected boolean createImpl() {
+ return create(false, false);
}
public void setOpenGLMode(int mode) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
index 391908540..9c630d24b 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
@@ -38,45 +38,22 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
// FIXME: not clear whether this is really necessary, but since
// the API docs seem to imply it is and since it doesn't seem to
// impact performance, leaving it in
- CGL.setContextTextureImageToPBuffer(contextHandle, drawable.getPbuffer(), GL.GL_FRONT);
+ CGL.setContextTextureImageToPBuffer(contextHandle, drawable.getHandle(), GL.GL_FRONT);
}
public void releasePbufferFromTexture() {
}
- protected int makeCurrentImpl() throws GLException {
- if (drawable.getPbuffer() == 0) {
- if (DEBUG) {
- System.err.println("Pbuffer not instantiated yet for " + this);
- }
- // pbuffer not instantiated yet
- return CONTEXT_NOT_CURRENT;
- }
-
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
if (getOpenGLMode() != drawable.getOpenGLMode()) {
setOpenGLMode(drawable.getOpenGLMode());
}
- if (contextHandle == 0) {
- create();
- if(!isCreated()) {
- return CONTEXT_NOT_CURRENT;
- }
- if(!isNSContext()) {
- throw new GLException("Not a NS Context");
- }
- if (DEBUG) {
- System.err.println("!!! Created OpenGL context (NS) " + toHexString(contextHandle) + " for " + getClass().getName());
- }
- }
-
if (!impl.makeCurrent(contextHandle)) {
throw new GLException("Error making Context (NS) current");
}
- if (isCreated()) {
- setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
-
+ if (newCreated) {
// Initialize render-to-texture support if requested
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
@@ -99,10 +76,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
gl.glCopyTexImage2D(textureTarget, 0, GL.GL_RGB, 0, 0, drawable.getWidth(), drawable.getHeight(), 0);
-
- return CONTEXT_CURRENT_NEW;
}
- return CONTEXT_CURRENT;
}
protected void releaseImpl() throws GLException {
@@ -112,22 +86,15 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
}
protected void destroyImpl() throws GLException {
- if (contextHandle != 0) {
if (!impl.destroy(contextHandle)) {
throw new GLException("Unable to delete OpenGL context");
}
if (DEBUG) {
System.err.println("!!! Destroyed OpenGL context " + contextHandle);
}
- contextHandle = 0;
- GLContextShareSet.contextDestroyed(this);
- }
}
protected void setSwapIntervalImpl(int interval) {
- if (contextHandle == 0) {
- throw new GLException("OpenGL context not current");
- }
impl.setSwapInterval(contextHandle, interval);
currentSwapInterval = impl.getSwapInterval() ;
}
@@ -136,7 +103,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
return GLPbuffer.APPLE_FLOAT;
}
- protected void create() {
+ protected boolean createImpl() throws GLException {
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
if (capabilities.getPbufferFloatingPointBuffers() &&
@@ -155,7 +122,11 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
if (!impl.makeCurrent(contextHandle)) {
throw new GLException("Error making Context (NS:"+isNSContext()+") current");
}
+ if(!isNSContext()) { // FIXME: ??
+ throw new GLException("Not a NS Context");
+ }
setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
+ return true;
}
//---------------------------------------------------------------------------
@@ -231,7 +202,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
throw new GLException("Error creating context for pbuffer");
}
// Must now associate the pbuffer with our newly-created context
- CGL.setContextPBuffer(contextHandle, drawable.getPbuffer());
+ CGL.setContextPBuffer(contextHandle, drawable.getHandle());
return contextHandle;
}
@@ -335,7 +306,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
throw new GLException("Error code " + res + " while creating context");
}
// Attach newly-created context to the pbuffer
- res = CGL.CGLSetPBuffer(ctx.get(0), drawable.getPbuffer(), 0, 0, 0);
+ res = CGL.CGLSetPBuffer(ctx.get(0), drawable.getHandle(), 0, 0, 0);
if (res != CGL.kCGLNoError) {
throw new GLException("Error code " + res + " while attaching context to pbuffer");
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
index afdc40dbb..64d646cfb 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
@@ -96,7 +96,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
}
}
- public long getPbuffer() {
+ public long getHandle() {
return pBuffer;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
index 9a90cbdc4..b42f1132c 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
@@ -70,29 +70,13 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL
this.graphics = g;
}
- protected int makeCurrentImpl() throws GLException {
- if (contextHandle == 0) {
- create();
- if(!isCreated()) {
- return CONTEXT_NOT_CURRENT;
- }
- if (DEBUG) {
- System.err.println("!!! Created GL Context (NS) for " + getClass().getName());
- }
- }
-
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
if (!Java2D.makeOGLContextCurrentOnSurface(graphics, contextHandle)) {
throw new GLException("Error making context current");
- }
-
- if (isCreated()) {
- setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
- return CONTEXT_CURRENT_NEW;
- }
- return CONTEXT_CURRENT;
+ }
}
- protected void create() {
+ protected boolean createImpl() {
// Find and configure share context
MacOSXCGLContext other = (MacOSXCGLContext) GLContextShareSet.getShareContext(this);
long share = 0;
@@ -118,11 +102,13 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL
long ctx = Java2D.createOGLContextOnSurface(graphics, share);
if (ctx == 0) {
- return;
+ return false;
}
+ setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
// FIXME: think about GLContext sharing
contextHandle = ctx;
isNSContext = true;
+ return true;
}
protected void releaseImpl() throws GLException {
@@ -132,15 +118,10 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL
}
protected void destroyImpl() throws GLException {
- if (contextHandle != 0) {
Java2D.destroyOGLContext(contextHandle);
if (DEBUG) {
System.err.println("!!! Destroyed OpenGL context " + contextHandle);
}
- contextHandle = 0;
- // FIXME
- // GLContextShareSet.contextDestroyed(this);
- }
}
public void setOpenGLMode(int mode) {