aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java33
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java19
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java7
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java47
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java6
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java8
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java40
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java6
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java20
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java5
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java5
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java57
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java7
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java24
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java32
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java18
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java23
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java5
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java5
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java30
22 files changed, 284 insertions, 121 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
index 16eb934bd..343ca7efe 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
@@ -73,9 +73,12 @@ public abstract class GLContextImpl extends GLContext {
// repeated glGet calls upon glMapBuffer operations
private GLBufferSizeTracker bufferSizeTracker;
+ protected GLDrawableImpl drawable;
+ protected GLDrawableImpl drawableRead;
+
protected GL gl;
- public GLContextImpl(GLProfile glp, GLContext shareWith) {
+ public GLContextImpl(GLDrawableImpl drawable, GLDrawableImpl drawableRead, GLContext shareWith) {
extensionAvailability = new ExtensionAvailabilityCache(this);
if (shareWith != null) {
GLContextShareSet.registerSharing(this, shareWith);
@@ -83,7 +86,33 @@ public abstract class GLContextImpl extends GLContext {
GLContextShareSet.registerForBufferObjectSharing(shareWith, this);
// This must occur after the above calls into the
// GLContextShareSet, which set up state needed by the GL object
- setGL(createGL(glp));
+ setGL(createGL(drawable.getGLProfile()));
+
+ this.drawable = drawable;
+ setGLDrawableRead(drawableRead);
+ }
+
+ public GLContextImpl(GLDrawableImpl drawable, GLContext shareWith) {
+ this(drawable, null, shareWith);
+ }
+
+ public void setGLDrawableRead(GLDrawable read) {
+ boolean lockHeld = lock.isHeld();
+ if(lockHeld) {
+ release();
+ }
+ drawableRead = ( null != read ) ? (GLDrawableImpl) read : drawable;
+ if(lockHeld) {
+ makeCurrent();
+ }
+ }
+
+ public GLDrawable getGLDrawable() {
+ return drawable;
+ }
+
+ public GLDrawable getGLDrawableRead() {
+ return drawableRead;
}
public GLDrawableImpl getDrawableImpl() {
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
index 9ea599b30..caa250597 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
@@ -69,17 +69,28 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
if(caps.isPBuffer()) {
throw new IllegalArgumentException("Onscreen target can't be PBuffer: "+caps);
}
+ if(DEBUG) {
+ System.out.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable: "+target);
+ }
result = createOnscreenDrawable(target);
} else {
- if(caps.isPBuffer() && canCreateGLPbuffer()) {
- // PBUFFER
- result = createGLPbufferDrawable(caps,
+ GLCapabilities caps2 = (GLCapabilities) caps.clone();
+ // OFFSCREEN !DOUBLE_BUFFER
+ caps2.setDoubleBuffered(false);
+ if(caps2.isPBuffer() && canCreateGLPbuffer()) {
+ if(DEBUG) {
+ System.out.println("GLDrawableFactoryImpl.createGLDrawable -> PbufferDrawable: "+target);
+ }
+ result = createGLPbufferDrawable(caps2,
chooser,
target.getWidth(),
target.getHeight());
}
if(null==result) {
- result = createOffscreenDrawable(caps,
+ if(DEBUG) {
+ System.out.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable: "+target);
+ }
+ result = createOffscreenDrawable(caps2,
chooser,
target.getWidth(),
target.getHeight());
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
index 81fc0b78b..8e0774402 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
@@ -72,10 +72,15 @@ public abstract class GLDrawableImpl implements GLDrawable {
public void swapBuffers() throws GLException {
GLCapabilities caps = (GLCapabilities)component.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
- if (caps.getDoubleBuffered()) {
+ if ( caps.getDoubleBuffered() ) {
if(!component.surfaceSwap()) {
swapBuffersImpl();
}
+ } else {
+ GLContext ctx = GLContext.getCurrent();
+ if(ctx.getGLDrawable()==this) {
+ ctx.getGL().glFinish();
+ }
}
component.surfaceUpdated();
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
index cc4dafa4c..a8c2521a3 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
@@ -43,7 +43,6 @@ import java.nio.*;
import java.util.*;
public abstract class EGLContext extends GLContextImpl {
- protected EGLDrawable drawable;
private long eglContext;
private boolean eglQueryStringInitialized;
private boolean eglQueryStringAvailable;
@@ -52,9 +51,14 @@ public abstract class EGLContext extends GLContextImpl {
// EGL extension functions.
private EGLExtProcAddressTable eglExtProcAddressTable;
- public EGLContext(EGLDrawable drawable, GLContext shareWith) {
- super(drawable.getGLProfile(), shareWith);
- this.drawable = drawable;
+ public EGLContext(GLDrawableImpl drawable, GLDrawableImpl drawableRead,
+ GLContext shareWith) {
+ super(drawable, drawableRead, shareWith);
+ }
+
+ public EGLContext(GLDrawableImpl drawable,
+ GLContext shareWith) {
+ this(drawable, null, shareWith);
}
public Object getPlatformGLExtensions() {
@@ -76,10 +80,6 @@ public abstract class EGLContext extends GLContextImpl {
return eglExtProcAddressTable;
}
- public GLDrawable getGLDrawable() {
- return drawable;
- }
-
protected String mapToRealGLFunctionName(String glFunctionName) {
return glFunctionName;
}
@@ -93,7 +93,7 @@ public abstract class EGLContext extends GLContextImpl {
}
protected int makeCurrentImpl() throws GLException {
- if(EGL.EGL_NO_DISPLAY==drawable.getDisplay() ) {
+ if(EGL.EGL_NO_DISPLAY==((EGLDrawable)drawable).getDisplay() ) {
System.err.println("drawable not properly initialized");
return CONTEXT_NOT_CURRENT;
}
@@ -107,9 +107,9 @@ public abstract class EGLContext extends GLContextImpl {
created = true;
}
if (EGL.eglGetCurrentContext() != eglContext) {
- if (!EGL.eglMakeCurrent(drawable.getDisplay(),
- drawable.getSurface(),
- drawable.getSurface(),
+ if (!EGL.eglMakeCurrent(((EGLDrawable)drawable).getDisplay(),
+ ((EGLDrawable)drawable).getSurface(),
+ ((EGLDrawable)drawableRead).getSurface(),
eglContext)) {
throw new GLException("Error making context 0x" +
Long.toHexString(eglContext) + " current: error code " + EGL.eglGetError());
@@ -126,7 +126,7 @@ public abstract class EGLContext extends GLContextImpl {
protected void releaseImpl() throws GLException {
getDrawableImpl().getFactoryImpl().lockToolkit();
try {
- if (!EGL.eglMakeCurrent(drawable.getDisplay(),
+ if (!EGL.eglMakeCurrent(((EGLDrawable)drawable).getDisplay(),
EGL.EGL_NO_SURFACE,
EGL.EGL_NO_SURFACE,
EGL.EGL_NO_CONTEXT)) {
@@ -142,7 +142,7 @@ public abstract class EGLContext extends GLContextImpl {
getDrawableImpl().getFactoryImpl().lockToolkit();
try {
if (eglContext != 0) {
- if (!EGL.eglDestroyContext(drawable.getDisplay(), eglContext)) {
+ if (!EGL.eglDestroyContext(((EGLDrawable)drawable).getDisplay(), eglContext)) {
throw new GLException("Error destroying OpenGL context 0x" +
Long.toHexString(eglContext) + ": error code " + EGL.eglGetError());
}
@@ -155,8 +155,8 @@ public abstract class EGLContext extends GLContextImpl {
}
protected void create() throws GLException {
- long eglDisplay = drawable.getDisplay();
- EGLGraphicsConfiguration config = drawable.getGraphicsConfiguration();
+ long eglDisplay = ((EGLDrawable)drawable).getDisplay();
+ EGLGraphicsConfiguration config = ((EGLDrawable)drawable).getGraphicsConfiguration();
GLProfile glProfile = drawable.getGLProfile();
_EGLConfig eglConfig = config.getNativeConfig();
long shareWith = EGL.EGL_NO_CONTEXT;
@@ -207,12 +207,12 @@ public abstract class EGLContext extends GLContextImpl {
if (DEBUG) {
System.err.println(getThreadName() + ": !!! Created OpenGL context 0x" +
Long.toHexString(eglContext) + " for " + this +
- ", surface 0x" + Long.toHexString(drawable.getSurface()) +
+ ", surface 0x" + Long.toHexString(((EGLDrawable)drawable).getSurface()) +
", sharing with 0x" + Long.toHexString(shareWith));
}
- if (!EGL.eglMakeCurrent(drawable.getDisplay(),
- drawable.getSurface(),
- drawable.getSurface(),
+ if (!EGL.eglMakeCurrent(((EGLDrawable)drawable).getDisplay(),
+ ((EGLDrawable)drawable).getSurface(),
+ ((EGLDrawable)drawableRead).getSurface(),
eglContext)) {
throw new GLException("Error making context 0x" +
Long.toHexString(eglContext) + " current: error code " + EGL.eglGetError());
@@ -228,6 +228,9 @@ public abstract class EGLContext extends GLContextImpl {
if (DEBUG) {
System.err.println(getThreadName() + ": !!! Initializing EGL extension address table");
}
+ eglQueryStringInitialized = false;
+ eglQueryStringAvailable = false;
+
if (eglExtProcAddressTable == null) {
// FIXME: cache ProcAddressTables by capability bits so we can
// share them among contexts with the same capabilities
@@ -247,7 +250,7 @@ public abstract class EGLContext extends GLContextImpl {
GLDrawableFactoryImpl factory = getDrawableImpl().getFactoryImpl();
factory.lockToolkit();
try {
- String ret = EGL.eglQueryString(drawable.getDisplay(),
+ String ret = EGL.eglQueryString(((EGLDrawable)drawable).getDisplay(),
EGL.EGL_EXTENSIONS);
if (DEBUG) {
System.err.println("!!! EGL extensions: " + ret);
@@ -262,7 +265,7 @@ public abstract class EGLContext extends GLContextImpl {
}
protected void setSwapIntervalImpl(int interval) {
- if (EGL.eglSwapInterval(drawable.getDisplay(), interval)) {
+ if (EGL.eglSwapInterval(((EGLDrawable)drawable).getDisplay(), interval)) {
currentSwapInterval = interval ;
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
index 1c3f8ead0..757a2bcf9 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
@@ -72,16 +72,20 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
GLCapabilitiesChooser chooser,
int width,
int height) {
+ capabilities.setOnscreen(false);
+ capabilities.setPBuffer(false);
throw new GLException("Not yet implemented");
}
public boolean canCreateGLPbuffer() {
return true;
}
- public GLDrawableImpl createGLPbufferDrawable(final GLCapabilities capabilities,
+ public GLDrawableImpl createGLPbufferDrawable(GLCapabilities capabilities,
final GLCapabilitiesChooser chooser,
final int initialWidth,
final int initialHeight) {
+ capabilities.setOnscreen(false);
+ capabilities.setPBuffer(true);
return new EGLPbufferDrawable(this, capabilities, chooser,
initialWidth, initialHeight);
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
index 574c3c8cf..7d9ab5b9d 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
@@ -73,7 +73,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
}
GLProfile glp = capsRequested.getGLProfile();
_EGLConfig _cfg = EGLConfigId2EGLConfig(glp, dpy, cfgID);
- GLCapabilities caps = EGLConfig2Capabilities(glp, dpy, _cfg);
+ GLCapabilities caps = EGLConfig2Capabilities(glp, dpy, _cfg, capsRequested.isOnscreen(), capsRequested.isPBuffer());
return new EGLGraphicsConfiguration(absScreen, caps, capsRequested, new DefaultGLCapabilitiesChooser(), _cfg, cfgID);
}
@@ -116,7 +116,8 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
return configs[0];
}
- public static GLCapabilities EGLConfig2Capabilities(GLProfile glp, long display, _EGLConfig _config) {
+ public static GLCapabilities EGLConfig2Capabilities(GLProfile glp, long display, _EGLConfig _config,
+ boolean onscreen, boolean pbuffer) {
GLCapabilities caps = new GLCapabilities(glp);
int[] val = new int[1];
@@ -161,6 +162,9 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
caps.setTransparentAlphaValue(val[0]==EGL.EGL_DONT_CARE?-1:val[0]);
} */
}
+ caps.setOnscreen(onscreen);
+ caps.setDoubleBuffered(onscreen);
+ caps.setPBuffer(pbuffer);
return caps;
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
index d05f10e5b..2b91edfec 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
@@ -97,12 +97,18 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
throw new GLException("Invalid EGL display: "+absDevice);
}
- EGLGraphicsConfiguration res = eglChooseConfig(eglDisplay, capabilities, capabilities, chooser, absScreen, eglSurfaceType);
+ GLCapabilities caps2 = (GLCapabilities) capabilities.clone();
+ if(!caps2.isOnscreen()) {
+ // OFFSCREEN !DOUBLE_BUFFER
+ caps2.setDoubleBuffered(false);
+ }
+
+ EGLGraphicsConfiguration res = eglChooseConfig(eglDisplay, caps2, capabilities, chooser, absScreen, eglSurfaceType);
if(null!=res) {
return res;
}
if(DEBUG) {
- System.err.println("eglChooseConfig failed with given capabilities surfaceType 0x"+Integer.toHexString(eglSurfaceType)+", "+capabilities);
+ System.err.println("eglChooseConfig failed with given capabilities surfaceType 0x"+Integer.toHexString(eglSurfaceType)+", "+caps2);
}
if (chooser == null) {
@@ -118,13 +124,14 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
if (numConfigs[0] == 0) {
throw new GLException("Graphics configuration fetch (eglGetConfigs) - no EGLConfig found");
}
- GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0]);
+ GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0],
+ caps2.isOnscreen(), caps2.isPBuffer());
if(DEBUG) {
printCaps("eglGetConfigs", caps, System.err);
}
int chosen = -1;
try {
- chosen = chooser.chooseCapabilities(capabilities, caps, -1);
+ chosen = chooser.chooseCapabilities(caps2, caps, -1);
} catch (NativeWindowException e) { throw new GLException(e); }
if(chosen<0) {
throw new GLException("Graphics configuration chooser failed");
@@ -142,11 +149,11 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
// Last try .. add a fixed embedded profile [ATI, Nokia, ..]
GLCapabilities fixedCaps = new GLCapabilities(glp);
+ /**
fixedCaps.setRedBits(5);
fixedCaps.setGreenBits(6);
fixedCaps.setBlueBits(5);
fixedCaps.setDepthBits(16);
- /**
fixedCaps.setSampleBuffers(true);
fixedCaps.setNumSamples(4); */
if(DEBUG) {
@@ -171,21 +178,22 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
}
protected static EGLGraphicsConfiguration eglChooseConfig(long eglDisplay,
- GLCapabilities capsChoosen0, GLCapabilities capsRequested, GLCapabilitiesChooser chooser,
+ GLCapabilities capsChosen0, GLCapabilities capsRequested, GLCapabilitiesChooser chooser,
AbstractGraphicsScreen absScreen, int eglSurfaceType) {
- GLProfile glp = capsChoosen0.getGLProfile();
- int[] attrs = EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChoosen0, eglSurfaceType);
+ GLProfile glp = capsChosen0.getGLProfile();
+ int[] attrs = EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChosen0, eglSurfaceType);
_EGLConfig[] configs = new _EGLConfig[10];
int[] numConfigs = new int[1];
if (!EGL.eglChooseConfig(eglDisplay,
attrs, 0,
configs, configs.length,
numConfigs, 0)) {
- throw new GLException("Graphics configuration selection (eglChooseConfig) failed for surfaceType 0x"+Integer.toHexString(eglSurfaceType)+", "+capsChoosen0);
+ throw new GLException("Graphics configuration selection (eglChooseConfig) failed for surfaceType 0x"+Integer.toHexString(eglSurfaceType)+", "+capsChosen0);
}
if (numConfigs[0] > 0) {
if(DEBUG) {
- GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0]);
+ GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0],
+ capsChosen0.isOnscreen(), capsChosen0.isPBuffer());
printCaps("eglChooseConfig", caps, System.err);
}
int[] val = new int[1];
@@ -193,13 +201,14 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
if(!EGL.eglGetConfigAttrib(eglDisplay, configs[0], EGL.EGL_CONFIG_ID, val, 0)) {
if(DEBUG) {
// FIXME: this happens on a ATI PC Emulation ..
- System.err.println("EGL couldn't retrieve ConfigID for already chosen eglConfig "+capsChoosen0+", error 0x"+Integer.toHexString(EGL.eglGetError()));
+ System.err.println("EGL couldn't retrieve ConfigID for already chosen eglConfig "+capsChosen0+", error 0x"+Integer.toHexString(EGL.eglGetError()));
}
val[0]=0;
}
- GLCapabilities capsChoosen1 = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[0]);
+ GLCapabilities capsChoosen1 = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[0],
+ capsChosen0.isOnscreen(), capsChosen0.isPBuffer());
if(DEBUG) {
- System.err.println("eglChooseConfig found: surfaceType 0x"+Integer.toHexString(eglSurfaceType)+", "+capsChoosen0+" -> "+capsChoosen1);
+ System.err.println("eglChooseConfig found: surfaceType 0x"+Integer.toHexString(eglSurfaceType)+", "+capsChosen0+" -> "+capsChoosen1);
}
return new EGLGraphicsConfiguration(absScreen, capsChoosen1, capsRequested, chooser, configs[0], val[0]);
@@ -207,11 +216,12 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
return null;
}
- protected static GLCapabilities[] eglConfigs2GLCaps(GLProfile glp, long eglDisplay, _EGLConfig[] configs, int num)
+ protected static GLCapabilities[] eglConfigs2GLCaps(GLProfile glp, long eglDisplay, _EGLConfig[] configs, int num,
+ boolean onscreen, boolean pbuffer)
{
GLCapabilities[] caps = new GLCapabilities[num];
for(int i=0; i<num; i++) {
- caps[i] = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[i]);
+ caps[i] = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[i], onscreen, pbuffer);
}
return caps;
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java
index a792762a4..448112ae0 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java
@@ -118,6 +118,10 @@ public class EGLPbufferDrawable extends EGLDrawable {
return new EGLPbufferContext(this, shareWith);
}
- protected void swapBuffersImpl() { }
+ protected void swapBuffersImpl() {
+ if(DEBUG) {
+ System.err.println("unhandled swapBuffersImpl() called for: "+this);
+ }
+ }
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java
index 111b215e3..ef3e9f930 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java
@@ -48,7 +48,6 @@ import com.sun.gluegen.runtime.ProcAddressTable;
public abstract class MacOSXCGLContext extends GLContextImpl
{
- protected MacOSXCGLDrawable drawable;
protected long nsContext; // NSOpenGLContext
protected long cglContext; // CGLContextObj
private CGLExt cglExt;
@@ -56,13 +55,16 @@ public abstract class MacOSXCGLContext extends GLContextImpl
// CGL extension functions.
private CGLExtProcAddressTable cglExtProcAddressTable;
- public MacOSXCGLContext(MacOSXCGLDrawable drawable,
- GLContext shareWith)
- {
- super(drawable.getGLProfile(), shareWith);
- this.drawable = drawable;
+ public MacOSXCGLContext(GLDrawableImpl drawable, GLDrawableImpl drawableRead,
+ GLContext shareWith) {
+ super(drawable, drawableRead, shareWith);
}
-
+
+ public MacOSXCGLContext(GLDrawableImpl drawable,
+ GLContext shareWith) {
+ this(drawable, null, shareWith);
+ }
+
public Object getPlatformGLExtensions() {
return getCGLExt();
}
@@ -82,10 +84,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl
return cglExtProcAddressTable;
}
- public GLDrawable getGLDrawable() {
- return drawable;
- }
-
protected String mapToRealGLFunctionName(String glFunctionName)
{
return glFunctionName;
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 2aefa7b5b..f398ed8a0 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
@@ -74,6 +74,8 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements D
int width,
int height) {
AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault();
+ capabilities.setOnscreen(false);
+ capabilities.setPBuffer(false);
return new MacOSXOffscreenCGLDrawable(this, aScreen, capabilities, chooser, width, height);
}
@@ -86,6 +88,8 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements D
final int initialWidth,
final int initialHeight) {
AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault();
+ capabilities.setOnscreen(false);
+ capabilities.setPBuffer(true);
return new MacOSXPbufferCGLDrawable(this, screen, capabilities, chooser,
initialWidth, initialHeight);
}
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 bb0984e58..9b6d8267d 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
@@ -88,7 +88,9 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
}
protected void swapBuffersImpl() {
- // FIXME: do we need to do anything if the pbuffer is double-buffered?
+ if(DEBUG) {
+ System.err.println("unhandled swapBuffersImpl() called for: "+this);
+ }
}
private void createPbuffer() {
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 71d82e784..a3e5f6da4 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
@@ -54,7 +54,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
GLCapabilitiesChooser chooser,
int width,
int height) {
- super(factory, new NullWindow(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(requestedCapabilities, chooser, absScreen, false, false)), true);
+ super(factory, new NullWindow(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(requestedCapabilities, chooser, absScreen)), true);
((NullWindow) getNativeWindow()).setSize(width, height);
create();
}
@@ -128,6 +128,9 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
}
protected void swapBuffersImpl() {
+ if(DEBUG) {
+ System.err.println("unhandled swapBuffersImpl() called for: "+this);
+ }
}
}
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 20a891414..41a4e3877 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
@@ -61,7 +61,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
WindowsWGLDrawable dummyDrawable,
WGLExt wglExt) {
super(factory, new NullWindow(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
- requestedCapabilities, chooser, absScreen, false, true) ), true);
+ requestedCapabilities, chooser, absScreen) ), true);
if (width <= 0 || height <= 0) {
throw new GLException("Width and height of pbuffer must be positive (were (" +
width + ", " + height + "))");
@@ -108,6 +108,9 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
}
protected void swapBuffersImpl() {
+ if(DEBUG) {
+ System.err.println("unhandled swapBuffersImpl() called for: "+this);
+ }
}
private void createPbuffer(long parentHdc, WGLExt wglExt) {
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 9a3860ae2..b07cd6046 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
@@ -47,10 +47,12 @@ import com.sun.opengl.impl.*;
import com.sun.gluegen.runtime.ProcAddressTable;
public class WindowsWGLContext extends GLContextImpl {
- protected WindowsWGLDrawable drawable;
protected long hglrc;
private boolean wglGetExtensionsStringEXTInitialized;
private boolean wglGetExtensionsStringEXTAvailable;
+ private boolean wglMakeContextCurrentInitialized;
+ private boolean wglMakeContextCurrentARBAvailable;
+ private boolean wglMakeContextCurrentEXTAvailable;
private static final Map/*<String, String>*/ functionNameMap;
private static final Map/*<String, String>*/ extensionNameMap;
private WGLExt wglExt;
@@ -69,12 +71,16 @@ public class WindowsWGLContext extends GLContextImpl {
}
// FIXME: figure out how to hook back in the Java 2D / JOGL bridge
- public WindowsWGLContext(WindowsWGLDrawable drawable,
- GLContext shareWith) {
- super(drawable.getGLProfile(), shareWith);
- this.drawable = drawable;
+ public WindowsWGLContext(GLDrawableImpl drawable, GLDrawableImpl drawableRead,
+ GLContext shareWith) {
+ super(drawable, drawableRead, shareWith);
}
+ public WindowsWGLContext(GLDrawableImpl drawable,
+ GLContext shareWith) {
+ this(drawable, null, shareWith);
+ }
+
public Object getPlatformGLExtensions() {
return getWGLExt();
}
@@ -86,6 +92,21 @@ public class WindowsWGLContext extends GLContextImpl {
return wglExt;
}
+ public boolean wglMakeContextCurrent(long hDrawDC, long hReadDC, long hglrc) {
+ WGLExt wglExt = getWGLExt();
+ if (!wglMakeContextCurrentInitialized) {
+ wglMakeContextCurrentARBAvailable = (WGL.wglGetProcAddress("wglMakeContextCurrentARB") != 0);
+ wglMakeContextCurrentEXTAvailable = (WGL.wglGetProcAddress("wglMakeContextCurrentEXT") != 0);
+ wglMakeContextCurrentInitialized = true;
+ }
+ if(wglMakeContextCurrentARBAvailable) {
+ return wglExt.wglMakeContextCurrentARB(hDrawDC, hReadDC, hglrc);
+ } else if(wglMakeContextCurrentEXTAvailable) {
+ return wglExt.wglMakeContextCurrentEXT(hDrawDC, hReadDC, hglrc);
+ }
+ return WGL.wglMakeCurrent(hDrawDC, hglrc);
+ }
+
public final ProcAddressTable getPlatformExtProcAddressTable() {
return getWGLExtProcAddressTable();
}
@@ -94,10 +115,6 @@ public class WindowsWGLContext extends GLContextImpl {
return wglExtProcAddressTable;
}
- public GLDrawable getGLDrawable() {
- return drawable;
- }
-
protected String mapToRealGLFunctionName(String glFunctionName) {
String lookup = (String) functionNameMap.get(glFunctionName);
if (lookup != null) {
@@ -146,7 +163,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 (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), temp_hglrc)) {
+ if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), temp_hglrc)) {
throw new GLException("Error making temp context current: 0x" + Integer.toHexString(WGL.GetLastError()));
}
setGLFunctionAvailability(true);
@@ -154,7 +171,7 @@ public class WindowsWGLContext extends GLContextImpl {
if( !isFunctionAvailable("wglCreateContextAttribsARB") ||
!isExtensionAvailable("WGL_ARB_create_context") ) {
if(glCaps.getGLProfile().isGL3()) {
- WGL.wglMakeCurrent(0, 0);
+ wglMakeContextCurrent(0, 0, 0);
WGL.wglDeleteContext(temp_hglrc);
throw new GLException("Unable to create OpenGL >= 3.1 context (no WGL_ARB_create_context)");
}
@@ -213,14 +230,14 @@ public class WindowsWGLContext extends GLContextImpl {
if(0==hglrc) {
if(glCaps.getGLProfile().isGL3()) {
- WGL.wglMakeCurrent(0, 0);
+ wglMakeContextCurrent(0, 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 (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), hglrc)) {
+ if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), hglrc)) {
throw new GLException("Error making old context current: 0x" + Integer.toHexString(WGL.GetLastError()));
}
if(DEBUG) {
@@ -228,10 +245,10 @@ public class WindowsWGLContext extends GLContextImpl {
}
} else {
hglrc2 = 0; // mark as shared ..
- WGL.wglMakeCurrent(0, 0);
+ wglMakeContextCurrent(0, 0, 0);
WGL.wglDeleteContext(temp_hglrc);
- if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), hglrc)) {
+ if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), hglrc)) {
throw new GLException("Error making new context current: 0x" + Integer.toHexString(WGL.GetLastError()));
}
updateGLProcAddressTable();
@@ -271,7 +288,7 @@ public class WindowsWGLContext extends GLContextImpl {
}
if (WGL.wglGetCurrentContext() != hglrc) {
- if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), hglrc)) {
+ if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), hglrc)) {
throw new GLException("Error making context current: 0x" + Integer.toHexString(WGL.GetLastError()));
} else {
if (DEBUG && VERBOSE) {
@@ -294,7 +311,7 @@ public class WindowsWGLContext extends GLContextImpl {
}
protected void releaseImpl() throws GLException {
- if (!WGL.wglMakeCurrent(0, 0)) {
+ if (!wglMakeContextCurrent(0, 0, 0)) {
throw new GLException("Error freeing OpenGL context: 0x" + Integer.toHexString(WGL.GetLastError()));
}
}
@@ -335,6 +352,12 @@ public class WindowsWGLContext extends GLContextImpl {
if (DEBUG) {
System.err.println(getThreadName() + ": !!! Initializing WGL extension address table for " + this);
}
+ wglGetExtensionsStringEXTInitialized=false;
+ wglGetExtensionsStringEXTAvailable=false;
+ wglMakeContextCurrentInitialized=false;
+ wglMakeContextCurrentARBAvailable=false;
+ wglMakeContextCurrentEXTAvailable=false;
+
if (wglExtProcAddressTable == null) {
// FIXME: cache ProcAddressTables by capability bits so we can
// share them among contexts with the same capabilities
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 d91cc0126..8feb36d25 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
@@ -83,6 +83,8 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
int width,
int height) {
AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault();
+ capabilities.setOnscreen(false);
+ capabilities.setPBuffer(false);
return new WindowsOffscreenWGLDrawable(this, aScreen, capabilities, chooser, width, height);
}
@@ -128,6 +130,9 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
if (!canCreateGLPbuffer()) {
throw new GLException("Pbuffer support not available with current graphics card");
}
+ capabilities.setOnscreen(false);
+ capabilities.setPBuffer(true);
+ final GLCapabilities caps = capabilities;
final List returnList = new ArrayList();
final GLDrawableFactory factory = this;
Runnable r = new Runnable() {
@@ -142,7 +147,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
WGLExt dummyWGLExt = dummyContext.getWGLExt();
try {
AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault();
- GLDrawableImpl pbufferDrawable = new WindowsPbufferWGLDrawable(factory, aScreen, capabilities, chooser,
+ GLDrawableImpl pbufferDrawable = new WindowsPbufferWGLDrawable(factory, aScreen, caps, chooser,
initialWidth,
initialHeight,
dummyDrawable,
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index a7d7be349..3fd96e7bc 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -55,36 +55,38 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
CapabilitiesChooser chooser,
AbstractGraphicsScreen absScreen) {
GLCapabilities caps = (GLCapabilities)capabilities;
- return chooseGraphicsConfigurationStatic(caps, chooser, absScreen, caps.isOnscreen(), caps.isPBuffer());
+ return chooseGraphicsConfigurationStatic(caps, chooser, absScreen);
}
protected static WindowsWGLGraphicsConfiguration createDefaultGraphicsConfiguration(AbstractGraphicsScreen absScreen, boolean onscreen, boolean usePBuffer) {
GLCapabilities caps = new GLCapabilities(null);
caps.setOnscreen (onscreen);
caps.setPBuffer (usePBuffer);
- if(!onscreen) {
- caps.setDoubleBuffered(false);
+
+ GLCapabilities caps2 = (GLCapabilities) caps.clone();
+ if(!caps2.isOnscreen()) {
+ // OFFSCREEN !DOUBLE_BUFFER
+ caps2.setDoubleBuffered(false);
}
if(null==absScreen) {
absScreen = DefaultGraphicsScreen.createScreenDevice(0);
}
- return new WindowsWGLGraphicsConfiguration(absScreen, caps, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps), -1, null);
+ return new WindowsWGLGraphicsConfiguration(absScreen, caps2, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps2), -1, null);
}
protected static WindowsWGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilities caps,
CapabilitiesChooser chooser,
- AbstractGraphicsScreen absScreen,
- boolean onscreen, boolean usePBuffer) {
+ AbstractGraphicsScreen absScreen) {
if(null==absScreen) {
absScreen = DefaultGraphicsScreen.createScreenDevice(0);
}
- caps.setOnscreen (onscreen);
- caps.setPBuffer (usePBuffer);
- if(!onscreen) {
- caps.setDoubleBuffered(false);
+ GLCapabilities caps2 = (GLCapabilities) caps.clone();
+ if(!caps2.isOnscreen()) {
+ // OFFSCREEN !DOUBLE_BUFFER
+ caps2.setDoubleBuffered(false);
}
- return new WindowsWGLGraphicsConfiguration(absScreen, caps, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps), -1,
+ return new WindowsWGLGraphicsConfiguration(absScreen, caps2, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps2), -1,
(GLCapabilitiesChooser)chooser);
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
index d5a5f3433..42b0f2a5f 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
@@ -50,7 +50,6 @@ import com.sun.nativewindow.impl.x11.*;
import com.sun.gluegen.runtime.ProcAddressTable;
public abstract class X11GLXContext extends GLContextImpl {
- protected X11GLXDrawable drawable;
protected long context;
private boolean glXQueryExtensionsStringInitialized;
private boolean glXQueryExtensionsStringAvailable;
@@ -66,10 +65,14 @@ public abstract class X11GLXContext extends GLContextImpl {
functionNameMap.put("glFreeMemoryNV", "glXFreeMemoryNV");
}
- public X11GLXContext(X11GLXDrawable drawable,
+ public X11GLXContext(GLDrawableImpl drawable, GLDrawableImpl drawableRead,
GLContext shareWith) {
- super(drawable.getGLProfile(), shareWith);
- this.drawable = drawable;
+ super(drawable, drawableRead, shareWith);
+ }
+
+ public X11GLXContext(GLDrawableImpl drawable,
+ GLContext shareWith) {
+ this(drawable, null, shareWith);
}
public final ProcAddressTable getPlatformExtProcAddressTable() {
@@ -91,10 +94,6 @@ public abstract class X11GLXContext extends GLContextImpl {
return glXExt;
}
- public GLDrawable getGLDrawable() {
- return drawable;
- }
-
protected String mapToRealGLFunctionName(String glFunctionName) {
String lookup = (String) functionNameMap.get(glFunctionName);
if (lookup != null) {
@@ -150,7 +149,7 @@ public abstract class X11GLXContext extends GLContextImpl {
}
if (!GLX.glXMakeContextCurrent(display,
drawable.getNativeWindow().getSurfaceHandle(),
- drawable.getNativeWindow().getSurfaceHandle(),
+ drawableRead.getNativeWindow().getSurfaceHandle(),
context)) {
throw new GLException("Error making temp context (old2) current: display 0x"+Long.toHexString(display)+", context 0x"+Long.toHexString(context)+", drawable "+drawable);
}
@@ -169,7 +168,7 @@ public abstract class X11GLXContext extends GLContextImpl {
} else {
if (!GLX.glXMakeContextCurrent(display,
drawable.getNativeWindow().getSurfaceHandle(),
- drawable.getNativeWindow().getSurfaceHandle(),
+ drawableRead.getNativeWindow().getSurfaceHandle(),
temp_context)) {
throw new GLException("Error making temp context (old) current: display 0x"+Long.toHexString(display)+", context 0x"+Long.toHexString(context)+", drawable "+drawable);
}
@@ -213,7 +212,7 @@ public abstract class X11GLXContext extends GLContextImpl {
if(0!=context) {
if (!GLX.glXMakeContextCurrent(display,
drawable.getNativeWindow().getSurfaceHandle(),
- drawable.getNativeWindow().getSurfaceHandle(),
+ drawableRead.getNativeWindow().getSurfaceHandle(),
context)) {
if(DEBUG) {
System.err.println("X11GLXContext.createContext couldn't make >= 3.2 core context current - fallback");
@@ -244,7 +243,7 @@ public abstract class X11GLXContext extends GLContextImpl {
if(0!=context) {
if (!GLX.glXMakeContextCurrent(display,
drawable.getNativeWindow().getSurfaceHandle(),
- drawable.getNativeWindow().getSurfaceHandle(),
+ drawableRead.getNativeWindow().getSurfaceHandle(),
context)) {
if(DEBUG) {
System.err.println("X11GLXContext.createContext couldn't make >= 3.0 core context current - fallback");
@@ -273,7 +272,7 @@ public abstract class X11GLXContext extends GLContextImpl {
context = temp_context;
if (!GLX.glXMakeContextCurrent(display,
drawable.getNativeWindow().getSurfaceHandle(),
- drawable.getNativeWindow().getSurfaceHandle(),
+ drawableRead.getNativeWindow().getSurfaceHandle(),
context)) {
GLX.glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_context);
@@ -316,9 +315,10 @@ public abstract class X11GLXContext extends GLContextImpl {
}
if (GLX.glXGetCurrentContext() != context) {
+
if (!GLX.glXMakeContextCurrent(drawable.getNativeWindow().getDisplayHandle(),
drawable.getNativeWindow().getSurfaceHandle(),
- drawable.getNativeWindow().getSurfaceHandle(),
+ drawableRead.getNativeWindow().getSurfaceHandle(),
context)) {
throw new GLException("Error making context current");
}
@@ -326,6 +326,7 @@ public abstract class X11GLXContext extends GLContextImpl {
System.err.println(getThreadName() + ": glXMakeCurrent(display " +
toHexString(drawable.getNativeWindow().getDisplayHandle()) +
", drawable " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) +
+ ", drawableRead " + toHexString(drawableRead.getNativeWindow().getSurfaceHandle()) +
", context " + toHexString(context) + ") succeeded");
}
}
@@ -402,6 +403,9 @@ public abstract class X11GLXContext extends GLContextImpl {
if (DEBUG) {
System.err.println(getThreadName() + ": !!! Initializing GLX extension address table");
}
+ glXQueryExtensionsStringInitialized = false;
+ glXQueryExtensionsStringAvailable = false;
+
if (glXExtProcAddressTable == null) {
// FIXME: cache ProcAddressTables by capability bits so we can
// share them among contexts with the same capabilities
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 456e04b77..8ee1efcb7 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
@@ -77,6 +77,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
int width,
int height) {
AbstractGraphicsScreen screen = X11GraphicsScreen.createDefault();
+ capabilities.setOnscreen(false);
+ capabilities.setPBuffer(false);
return new X11OffscreenGLXDrawable(this, screen, capabilities, chooser, width, height);
}
@@ -114,13 +116,16 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
return canCreateGLPbuffer;
}
- public GLDrawableImpl createGLPbufferDrawable(final GLCapabilities capabilities,
+ public GLDrawableImpl createGLPbufferDrawable(GLCapabilities capabilities,
final GLCapabilitiesChooser chooser,
final int initialWidth,
final int initialHeight) {
if (!canCreateGLPbuffer()) {
throw new GLException("Pbuffer support not available with current graphics card");
}
+
+ capabilities.setOnscreen(false);
+ capabilities.setPBuffer(true);
AbstractGraphicsScreen screen = X11GraphicsScreen.createDefault();
return new X11PbufferGLXDrawable(this, screen, capabilities, chooser,
initialWidth, initialHeight);
@@ -131,7 +136,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
final int initialWidth,
final int initialHeight,
final GLContext shareWith) {
- GLDrawableImpl drawable = createGLPbufferDrawable( capabilities, chooser, initialWidth, initialHeight);
+ GLDrawableImpl drawable = createGLPbufferDrawable(capabilities, chooser, initialWidth, initialHeight);
return new GLPbufferImpl(drawable, shareWith);
}
@@ -161,6 +166,15 @@ 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/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 074fbda5f..0d19d2063 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -58,7 +58,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
CapabilitiesChooser chooser,
AbstractGraphicsScreen absScreen) {
- return chooseGraphicsConfigurationStatic(capabilities, chooser, absScreen, capabilities.isOnscreen(), false);
+ return chooseGraphicsConfigurationStatic(capabilities, chooser, absScreen);
}
protected static X11GLXGraphicsConfiguration createDefaultGraphicsConfiguration(AbstractGraphicsScreen absScreen, boolean onscreen, boolean usePBuffer) {
@@ -114,8 +114,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
protected static X11GLXGraphicsConfiguration chooseGraphicsConfigurationStatic(Capabilities capabilities,
CapabilitiesChooser chooser,
- AbstractGraphicsScreen absScreen,
- boolean onscreen, boolean usePBuffer) {
+ AbstractGraphicsScreen absScreen) {
if (absScreen == null) {
throw new IllegalArgumentException("AbstractGraphicsScreen is null");
}
@@ -138,21 +137,25 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
if (capabilities == null) {
capabilities = new GLCapabilities(null);
}
- capabilities.setOnscreen (onscreen);
- ((GLCapabilities)capabilities).setPBuffer (usePBuffer);
- if(!onscreen) {
- ((GLCapabilities)capabilities).setDoubleBuffered(false);
+
+ boolean onscreen = capabilities.isOnscreen();
+ boolean usePBuffer = ((GLCapabilities)capabilities).isPBuffer();
+
+ GLCapabilities caps2 = (GLCapabilities) capabilities.clone();
+ if(!caps2.isOnscreen()) {
+ // OFFSCREEN !DOUBLE_BUFFER
+ caps2.setDoubleBuffered(false);
}
X11GLXGraphicsConfiguration res;
- res = chooseGraphicsConfigurationFBConfig((GLCapabilities) capabilities,
+ res = chooseGraphicsConfigurationFBConfig((GLCapabilities) caps2,
(GLCapabilitiesChooser) chooser,
x11Screen);
if(null==res) {
if(usePBuffer) {
throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig");
}
- res = chooseGraphicsConfigurationXVisual((GLCapabilities) capabilities,
+ res = chooseGraphicsConfigurationXVisual((GLCapabilities) caps2,
(GLCapabilitiesChooser) chooser,
x11Screen);
}
@@ -160,7 +163,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration");
}
if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationStatic("+x11Screen+","+capabilities+", pbuffer "+usePBuffer+"): "+res);
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationStatic("+x11Screen+","+caps2+"): "+res);
}
return res;
}
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 768f6b8e8..4c4546854 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
@@ -53,7 +53,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
GLCapabilitiesChooser chooser,
int width,
int height) {
- super(factory, new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, screen, false, false)), true);
+ super(factory, new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, screen)), true);
((NullWindow) getNativeWindow()).setSize(width, height);
create();
}
@@ -134,5 +134,8 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
}
}
protected void swapBuffersImpl() {
+ if(DEBUG) {
+ System.err.println("unhandled swapBuffersImpl() called for: "+this);
+ }
}
}
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 bee24fa47..0f758a2f7 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
@@ -51,7 +51,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
GLCapabilities caps,
GLCapabilitiesChooser chooser,
int width, int height) {
- super(factory, new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, screen, false, true)), true);
+ super(factory, new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, screen)), true);
if (width <= 0 || height <= 0) {
throw new GLException("Width and height of pbuffer must be positive (were (" +
width + ", " + height + "))");
@@ -149,5 +149,8 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
}
protected void swapBuffersImpl() {
+ if(DEBUG) {
+ System.err.println("unhandled swapBuffersImpl() called for: "+this);
+ }
}
}
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 8ff52b6e9..840de4764 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -74,6 +74,19 @@ public abstract class GLContext {
public abstract GLDrawable getGLDrawable();
/**
+ * Set the GLDrawable from which this context may be used to
+ * read.<br>
+ * If read is null, the default write drawable will be used.
+ */
+ public abstract void setGLDrawableRead(GLDrawable read);
+
+ /**
+ * Returns the GLDrawable from which this context may be used to
+ * read.
+ */
+ public abstract GLDrawable getGLDrawableRead();
+
+ /**
* Makes this GLContext current on the calling thread.
*
* There are two return values that indicate success and one that
@@ -244,8 +257,21 @@ public abstract class GLContext {
* Classname, GL, GLDrawable
*/
public final String toString() {
- return getClass().getName()+" ["+getGL()+
- ",\n\tDrawable: "+ getGLDrawable()+"] ";
+ StringBuffer sb = new StringBuffer();
+ sb.append(getClass().getName());
+ sb.append(" [");
+ sb.append(getGL());
+ if(getGLDrawable()!=getGLDrawableRead()) {
+ sb.append(",\n\tDrawable Read : ");
+ sb.append(getGLDrawableRead());
+ sb.append(",\n\tDrawable Write: ");
+ sb.append(getGLDrawable());
+ } else {
+ sb.append(",\n\tDrawable Read/Write: ");
+ sb.append(getGLDrawable());
+ }
+ sb.append("] ");
+ return sb.toString();
}
/** Returns a non-null (but possibly empty) string containing the