aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2009-08-08 21:43:30 +0200
committerMichael Bien <[email protected]>2009-08-08 21:43:30 +0200
commit8ef9d7364a942c19ec5e1f306e08193e83f4fea6 (patch)
tree6dcf95825d2933992199a7062b15e38d3f721c95 /src/jogl/classes
parent2a8e9876ca4567de3b08813c280d006f9b2c32e6 (diff)
parentfb3e50b4e7e11df911a83ab7966cf8f293c20da2 (diff)
Merge branch 'master' of ssh://[email protected]/jogl~jogl-git
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java175
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java46
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java15
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java4
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java19
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java38
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java2
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java9
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java20
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java1
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java5
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java15
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java4
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java7
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java14
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java121
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java63
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java149
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java123
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java114
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java31
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java46
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/util/GLArrayDataClient.java10
-rw-r--r--src/jogl/classes/com/sun/opengl/util/GLArrayDataServer.java10
-rw-r--r--src/jogl/classes/com/sun/opengl/util/glsl/ShaderCode.java98
-rw-r--r--src/jogl/classes/com/sun/opengl/util/glsl/ShaderState.java14
-rw-r--r--src/jogl/classes/com/sun/opengl/util/glsl/ShaderUtil.java78
-rw-r--r--src/jogl/classes/com/sun/opengl/util/glsl/fixedfunc/FixedFuncUtil.java15
-rw-r--r--src/jogl/classes/javax/media/opengl/GLAutoDrawable.java5
-rw-r--r--src/jogl/classes/javax/media/opengl/GLBase.java163
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java4
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java16
-rw-r--r--src/jogl/classes/javax/media/opengl/GLPipelineFactory.java194
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java22
-rw-r--r--src/jogl/classes/javax/media/opengl/GLUniformData.java12
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java4
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java34
47 files changed, 1267 insertions, 457 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java b/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java
index eee308088..26072519e 100644
--- a/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java
+++ b/src/jogl/classes/com/sun/opengl/impl/ExtensionAvailabilityCache.java
@@ -65,7 +65,25 @@ public final class ExtensionAvailabilityCache {
*/
public void flush()
{
+ if(DEBUG) {
+ System.out.println("ExtensionAvailabilityCache: Flush availability OpenGL "+majorVersion+"."+minorVersion);
+ }
availableExtensionCache.clear();
+ initialized = false;
+ majorVersion = 1;
+ minorVersion = 0;
+ }
+
+ /**
+ * Flush the cache and rebuild the cache.
+ */
+ public void reset() {
+ flush();
+ initAvailableExtensions();
+ }
+
+ public boolean isInitialized() {
+ return initialized && !availableExtensionCache.isEmpty() ;
}
public boolean isExtensionAvailable(String glExtensionName) {
@@ -73,19 +91,101 @@ public final class ExtensionAvailabilityCache {
return availableExtensionCache.contains(mapGLExtensionName(glExtensionName));
}
- protected void initAvailableExtensions() {
+ public String getPlatformExtensionsString() {
+ initAvailableExtensions();
+ return glXExtensions;
+ }
+
+ public String getGLExtensions() {
+ initAvailableExtensions();
+ if(DEBUG) {
+ System.err.println("ExtensionAvailabilityCache: getGLExtensions() called");
+ }
+ return glExtensions;
+ }
+
+ public int getMajorVersion() {
+ initAvailableExtensions();
+ return majorVersion;
+ }
+
+ public int getMinorVersion() {
+ initAvailableExtensions();
+ return minorVersion;
+ }
+
+ private void initAvailableExtensions() {
// if hash is empty (meaning it was flushed), pre-cache it with the list
// of extensions that are in the GL_EXTENSIONS string
- if (availableExtensionCache.isEmpty()) {
+ if (availableExtensionCache.isEmpty() || !initialized) {
GL gl = context.getGL();
+
if (DEBUG) {
- System.err.println("!!! Pre-caching extension availability");
+ System.err.println("ExtensionAvailabilityCache: Pre-caching init "+gl+", GL_VERSION "+gl.glGetString(GL.GL_VERSION));
}
- String allAvailableExtensions =
- gl.glGetString(GL.GL_EXTENSIONS) + " " + context.getPlatformExtensionsString();
+
+ // Set version
+ Version version = new Version(gl.glGetString(GL.GL_VERSION));
+ if (version.isValid()) {
+ majorVersion = version.getMajor();
+ minorVersion = version.getMinor();
+
+ if( !gl.isGL3() &&
+ ( majorVersion > 3 ||
+ ( majorVersion == 3 && minorVersion >= 1 ) ) ) {
+ // downsize version to 3.0 in case we are not using GL3 (3.1)
+ majorVersion = 3;
+ minorVersion = 0;
+ }
+ }
+
+ boolean useGetStringi = false;
+
+ if ( majorVersion > 3 ||
+ ( majorVersion == 3 && minorVersion >= 0 ) ||
+ gl.isGL3() ) {
+ if ( ! gl.isGL2GL3() ) {
+ if(DEBUG) {
+ System.err.println("ExtensionAvailabilityCache: GL >= 3.1 usage, but no GL2GL3 interface: "+gl.getClass().getName());
+ }
+ } else if ( ! gl.isFunctionAvailable("glGetStringi") ) {
+ if(DEBUG) {
+ System.err.println("ExtensionAvailabilityCache: GL >= 3.1 usage, but no glGetStringi");
+ }
+ } else {
+ useGetStringi = true;
+ }
+ }
+
if (DEBUG) {
- System.err.println("!!! Available extensions: " + allAvailableExtensions);
- System.err.println("!!! GL vendor: " + gl.glGetString(GL.GL_VENDOR));
+ System.err.println("ExtensionAvailabilityCache: Pre-caching extension availability OpenGL "+majorVersion+"."+minorVersion+
+ ", use "+ ( useGetStringi ? "glGetStringi" : "glGetString" ) );
+ }
+
+ StringBuffer sb = new StringBuffer();
+ if(useGetStringi) {
+ GL2GL3 gl2gl3 = gl.getGL2GL3();
+ int[] numExtensions = { 0 } ;
+ gl2gl3.glGetIntegerv(gl2gl3.GL_NUM_EXTENSIONS, numExtensions, 0);
+ for (int i = 0; i < numExtensions[0]; i++) {
+ sb.append(gl2gl3.glGetStringi(gl2gl3.GL_EXTENSIONS, i));
+ if(i < numExtensions[0]) {
+ sb.append(" ");
+ }
+ }
+ } else {
+ sb.append(gl.glGetString(GL.GL_EXTENSIONS));
+ }
+ glExtensions = sb.toString();
+ glXExtensions = context.getPlatformExtensionsString();
+
+ sb.append(" ");
+ sb.append(glXExtensions);
+
+ String allAvailableExtensions = sb.toString();
+ if (DEBUG_AVAILABILITY) {
+ System.err.println("ExtensionAvailabilityCache: Available extensions: " + allAvailableExtensions);
+ System.err.println("ExtensionAvailabilityCache: GL vendor: " + gl.glGetString(GL.GL_VENDOR));
}
StringTokenizer tok = new StringTokenizer(allAvailableExtensions);
while (tok.hasMoreTokens()) {
@@ -93,42 +193,50 @@ public final class ExtensionAvailabilityCache {
availableExt = availableExt.intern();
availableExtensionCache.add(availableExt);
if (DEBUG_AVAILABILITY) {
- System.err.println("!!! Available: " + availableExt);
+ System.err.println("ExtensionAvailabilityCache: Available: " + availableExt);
}
}
// Put GL version strings in the table as well
- Version version = new Version(gl.glGetString(GL.GL_VERSION));
- if (version.isValid()) {
- int major = version.getMajor();
- int minor = version.getMinor();
- // FIXME: this needs to be adjusted when the major rev changes
- // beyond the known ones
- while (major > 0) {
- while (minor >= 0) {
- availableExtensionCache.add("GL_VERSION_" + major + "_" + minor);
- if (DEBUG) {
- System.err.println("!!! Added GL_VERSION_" + major + "_" + minor + " to known extensions");
- }
- --minor;
+ // FIXME: this needs to be adjusted when the major rev changes
+ // beyond the known ones
+ int major = majorVersion;
+ int minor = minorVersion;
+ while (major > 0) {
+ while (minor >= 0) {
+ availableExtensionCache.add("GL_VERSION_" + major + "_" + minor);
+ if (DEBUG) {
+ System.err.println("ExtensionAvailabilityCache: Added GL_VERSION_" + major + "_" + minor + " to known extensions");
}
+ --minor;
+ }
- switch (major) {
- case 2:
- // Restart loop at version 1.5
- minor = 5;
- break;
- case 1:
- break;
+ switch (major) {
+ case 3:
+ if(gl.isGL3()) {
+ // GL3 is a GL 3.1 forward compatible context,
+ // hence no 2.0, 1.0 - 1.5 GL versions are supported.
+ major=0;
}
-
- --major;
+ // Restart loop at version 2.1
+ minor = 1;
+ break;
+ case 2:
+ // Restart loop at version 1.5
+ minor = 5;
+ break;
+ case 1:
+ break;
}
+
+ --major;
}
// put a dummy var in here so that the cache is no longer empty even if
// no extensions are in the GL_EXTENSIONS string
availableExtensionCache.add("<INTERNAL_DUMMY_PLACEHOLDER>");
+
+ initialized = true;
}
}
@@ -146,6 +254,11 @@ public final class ExtensionAvailabilityCache {
// Internals only below this point
//
+ private boolean initialized = false;
+ private int majorVersion = 1;
+ private int minorVersion = 0;
+ private String glExtensions = null;
+ private String glXExtensions = null;
private HashSet availableExtensionCache = new HashSet(50);
private GLContextImpl context;
@@ -236,7 +349,7 @@ public final class ExtensionAvailabilityCache {
{
// FIXME: refactor desktop OpenGL dependencies and make this
// class work properly for OpenGL ES
- System.err.println("FunctionAvailabilityCache.Version.<init>: "+e);
+ System.err.println("ExtensionAvailabilityCache: FunctionAvailabilityCache.Version.<init>: "+e);
major = 1;
minor = 0;
/*
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
index c60cccec6..16eb934bd 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
@@ -228,7 +228,7 @@ public abstract class GLContextImpl extends GLContext {
return gl;
}
- public void setGL(GL gl) {
+ public GL setGL(GL gl) {
if(DEBUG) {
String sgl1 = (null!=this.gl)?this.gl.getClass().toString()+", "+this.gl.toString():new String("<null>");
String sgl2 = (null!=gl)?gl.getClass().toString()+", "+gl.toString():new String("<null>");
@@ -236,6 +236,7 @@ public abstract class GLContextImpl extends GLContext {
e.printStackTrace();
}
this.gl = gl;
+ return gl;
}
public abstract Object getPlatformGLExtensions();
@@ -284,11 +285,23 @@ public abstract class GLContextImpl extends GLContext {
public abstract ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3);
- /*
- * Sets the swap interval for onscreen OpenGL contexts. Has no
- * effect for offscreen contexts.
- */
public void setSwapInterval(final int interval) {
+ GLContext current = getCurrent();
+ if (current != this) {
+ throw new GLException("This context is not current. Current context: "+current+
+ ", this context "+this);
+ }
+ setSwapIntervalImpl(interval);
+ }
+
+ protected int currentSwapInterval = -1; // default: not set yet ..
+
+ public int getSwapInterval() {
+ return currentSwapInterval;
+ }
+
+ protected void setSwapIntervalImpl(final int interval) {
+ // nop per default ..
}
/** Maps the given "platform-independent" function name to a real function
@@ -342,7 +355,6 @@ public abstract class GLContextImpl extends GLContext {
if(null==this.gl) {
throw new GLException("setGLFunctionAvailability not called yet");
}
- extensionAvailability.flush();
if (DEBUG) {
System.err.println(getThreadName() + ": !!! Initializing OpenGL extension address table for " + this);
}
@@ -352,6 +364,8 @@ public abstract class GLContextImpl extends GLContext {
// share them among contexts with the same capabilities
}
resetProcAddressTable(getGLProcAddressTable());
+
+ extensionAvailability.reset();
}
/**
@@ -414,6 +428,26 @@ public abstract class GLContextImpl extends GLContext {
return extensionAvailability.isExtensionAvailable(mapToRealGLExtensionName(glExtensionName));
}
+ public String getPlatformExtensionsString() {
+ return extensionAvailability.getPlatformExtensionsString();
+ }
+
+ public String getGLExtensions() {
+ return extensionAvailability.getGLExtensions();
+ }
+
+ public int getMajorVersion() {
+ return extensionAvailability.getMajorVersion();
+ }
+
+ public int getMinorVersion() {
+ return extensionAvailability.getMinorVersion();
+ }
+
+ public boolean isExtensionCacheInitialized() {
+ return extensionAvailability.isInitialized();
+ }
+
/** Indicates which floating-point pbuffer implementation is in
use. Returns one of GLPbuffer.APPLE_FLOAT, GLPbuffer.ATI_FLOAT,
or GLPbuffer.NV_FLOAT. */
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
index de911950a..0d540647a 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
@@ -69,7 +69,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
/**
* Returns the sole GLDrawableFactoryImpl instance.
*
- * @arg glProfile GLProfile to determine the factory type, ie EGLDrawableFactory,
+ * @param glProfile GLProfile to determine the factory type, ie EGLDrawableFactory,
* or one of the native GLDrawableFactory's, ie X11/GLX, Windows/WGL or MacOSX/CGL.
*/
public static GLDrawableFactoryImpl getFactoryImpl(GLProfile glp) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
index c381f68f5..81fc0b78b 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
@@ -71,8 +71,17 @@ public abstract class GLDrawableImpl implements GLDrawable {
}
public void swapBuffers() throws GLException {
+ GLCapabilities caps = (GLCapabilities)component.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+ if (caps.getDoubleBuffered()) {
+ if(!component.surfaceSwap()) {
+ swapBuffersImpl();
+ }
+ }
+ component.surfaceUpdated();
}
+ protected abstract void swapBuffersImpl();
+
public static String toHexString(long hex) {
return GLContextImpl.toHexString(hex);
}
@@ -131,10 +140,10 @@ public abstract class GLDrawableImpl implements GLDrawable {
public String toString() {
return getClass().getName()+"[realized "+getRealized()+
- ",\n\trequested "+getRequestedGLCapabilities()+
- ",\n\tchosen "+getChosenGLCapabilities()+
+ ",\n\tfactory "+getFactory()+
",\n\twindow "+getNativeWindow()+
- ",\n\tfactory "+getFactory()+"]";
+ ",\n\trequested "+getRequestedGLCapabilities()+
+ ",\n\tchosen "+getChosenGLCapabilities()+"]";
}
protected GLDrawableFactory factory;
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java
index e414fbc8e..8aba26fc6 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java
@@ -129,8 +129,8 @@ public class GLPbufferImpl implements GLPbuffer {
return getContext().getGL();
}
- public void setGL(GL gl) {
- getContext().setGL(gl);
+ public GL setGL(GL gl) {
+ return getContext().setGL(gl);
}
public void setAutoSwapBufferMode(boolean onOrOff) {
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 653bddb9d..cc4dafa4c 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
@@ -168,8 +168,15 @@ public abstract class EGLContext extends GLContextImpl {
throw new GLException("Error: attempted to create an OpenGL context without a graphics configuration");
}
- if(!EGL.eglBindAPI(EGL.EGL_OPENGL_ES_API)) {
- throw new GLException("eglBindAPI to ES failed , error 0x"+Integer.toHexString(EGL.eglGetError()));
+ try {
+ // might be unavailable on EGL < 1.2
+ if(!EGL.eglBindAPI(EGL.EGL_OPENGL_ES_API)) {
+ throw new GLException("eglBindAPI to ES failed , error 0x"+Integer.toHexString(EGL.eglGetError()));
+ }
+ } catch (GLException glex) {
+ if (DEBUG) {
+ glex.printStackTrace();
+ }
}
EGLContext other = (EGLContext) GLContextShareSet.getShareContext(this);
@@ -218,7 +225,6 @@ public abstract class EGLContext extends GLContextImpl {
}
protected void updateGLProcAddressTable() {
- super.updateGLProcAddressTable();
if (DEBUG) {
System.err.println(getThreadName() + ": !!! Initializing EGL extension address table");
}
@@ -228,6 +234,7 @@ public abstract class EGLContext extends GLContextImpl {
eglExtProcAddressTable = new EGLExtProcAddressTable();
}
resetProcAddressTable(getEGLExtProcAddressTable());
+ super.updateGLProcAddressTable();
}
public synchronized String getPlatformExtensionsString() {
@@ -254,6 +261,12 @@ public abstract class EGLContext extends GLContextImpl {
}
}
+ protected void setSwapIntervalImpl(int interval) {
+ if (EGL.eglSwapInterval(drawable.getDisplay(), interval)) {
+ currentSwapInterval = interval ;
+ }
+ }
+
public abstract void bindPbufferToTexture();
public abstract void releasePbufferFromTexture();
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
index d2907c83d..aabc6f263 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
@@ -45,10 +45,10 @@ import javax.media.opengl.*;
public abstract class EGLDrawable extends GLDrawableImpl {
protected boolean ownEGLDisplay = false;
+ protected boolean ownEGLSurface = false;
private EGLGraphicsConfiguration eglConfig;
protected long eglDisplay;
protected long eglSurface;
- private int[] tmp = new int[1];
protected EGLDrawable(EGLDrawableFactory factory,
NativeWindow component) throws GLException {
@@ -78,13 +78,16 @@ public abstract class EGLDrawable extends GLDrawableImpl {
protected abstract long createSurface(long eglDpy, _EGLConfig eglNativeCfg);
private void recreateSurface() {
- if(EGL.EGL_NO_SURFACE!=eglSurface) {
- EGL.eglDestroySurface(eglDisplay, eglSurface);
- }
- eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig());
+ if(ownEGLSurface) {
+ // create a new EGLSurface ..
+ if(EGL.EGL_NO_SURFACE!=eglSurface) {
+ EGL.eglDestroySurface(eglDisplay, eglSurface);
+ }
+ eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig());
- if(DEBUG) {
- System.err.println("setSurface using component: handle 0x"+Long.toHexString(component.getWindowHandle())+" -> 0x"+Long.toHexString(eglSurface));
+ if(DEBUG) {
+ System.err.println("setSurface using component: handle 0x"+Long.toHexString(component.getWindowHandle())+" -> 0x"+Long.toHexString(eglSurface));
+ }
}
}
@@ -110,13 +113,28 @@ public abstract class EGLDrawable extends GLDrawableImpl {
if (null == eglConfig) {
throw new GLException("Null EGLGraphicsConfiguration from "+aConfig);
}
- eglConfig.updateGraphicsConfiguration();
+ int[] tmp = new int[1];
+ if (EGL.eglQuerySurface(eglDisplay, component.getWindowHandle(), EGL.EGL_CONFIG_ID, tmp, 0)) {
+ // component holds static EGLSurface
+ eglSurface = component.getWindowHandle();
+ if(DEBUG) {
+ System.err.println("setSurface re-using component's EGLSurface: handle 0x"+Long.toHexString(eglSurface));
+ }
+ } else {
+ // EGLSurface is ours ..
+ ownEGLSurface=true;
+
+ eglConfig.updateGraphicsConfiguration();
+ }
} else {
throw new GLException("EGLGraphicsConfiguration doesn't carry a EGLGraphicsDevice: "+aConfig);
}
} else {
// create a new EGL config ..
ownEGLDisplay=true;
+ // EGLSurface is ours ..
+ ownEGLSurface=true;
+
long nDisplay;
if( NativeWindowFactory.TYPE_WINDOWS.equals(NativeWindowFactory.getNativeWindowType(false)) ) {
nDisplay = component.getSurfaceHandle(); // don't even ask ..
@@ -153,7 +171,7 @@ public abstract class EGLDrawable extends GLDrawableImpl {
} finally {
unlockSurface();
}
- } else if (eglSurface != EGL.EGL_NO_SURFACE) {
+ } else if (ownEGLSurface && eglSurface != EGL.EGL_NO_SURFACE) {
// Destroy the window surface
if (!EGL.eglDestroySurface(eglDisplay, eglSurface)) {
throw new GLException("Error destroying window surface (eglDestroySurface)");
@@ -168,6 +186,7 @@ public abstract class EGLDrawable extends GLDrawableImpl {
}
public int getWidth() {
+ int[] tmp = new int[1];
if (!EGL.eglQuerySurface(eglDisplay, eglSurface, EGL.EGL_WIDTH, tmp, 0)) {
throw new GLException("Error querying surface width");
}
@@ -175,6 +194,7 @@ public abstract class EGLDrawable extends GLDrawableImpl {
}
public int getHeight() {
+ int[] tmp = new int[1];
if (!EGL.eglQuerySurface(eglDisplay, eglSurface, EGL.EGL_HEIGHT, tmp, 0)) {
throw new GLException("Error querying surface height");
}
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 396580c1d..7af45d683 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
@@ -50,7 +50,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
new EGLGraphicsConfigurationFactory();
// Check for other underlying stuff ..
- if(NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(false))) {
+ if(NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(true))) {
try {
NWReflection.createInstance("com.sun.opengl.impl.x11.glx.X11GLXGraphicsConfigurationFactory");
} catch (Throwable t) {}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java
index 8bed0eb35..02aed9788 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java
@@ -42,6 +42,7 @@ import com.sun.opengl.impl.*;
import com.sun.nativewindow.impl.*;
import com.sun.gluegen.runtime.NativeLibrary;
import com.sun.gluegen.runtime.DynamicLookupHelper;
+import java.security.*;
/**
* Abstract implementation of the DynamicLookupHelper for EGL,
@@ -51,12 +52,16 @@ import com.sun.gluegen.runtime.DynamicLookupHelper;
*/
public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper {
protected static final boolean DEBUG = com.sun.opengl.impl.Debug.debug("EGL");
+ protected static final boolean DEBUG_LOOKUP;
private static final EGLDynamicLookupHelper eglES1DynamicLookupHelper;
private static final EGLDynamicLookupHelper eglES2DynamicLookupHelper;
private List/*<NativeLibrary>*/ glesLibraries;
static {
+ AccessControlContext localACC=AccessController.getContext();
+ DEBUG_LOOKUP = com.sun.opengl.impl.Debug.isPropertyDefined("jogl.debug.DynamicLookup", true, localACC);
+
EGLDynamicLookupHelper tmp=null;
try {
tmp = new EGLES1DynamicLookupHelper();
@@ -190,7 +195,7 @@ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper {
addr = dynamicLookupFunctionOnLibsImpl(funcName);
}
}
- if(DEBUG) {
+ if(DEBUG_LOOKUP) {
if(0!=addr) {
System.err.println("Lookup-Native: "+glFuncName+" / "+funcName+" 0x"+Long.toHexString(addr));
} else {
@@ -236,7 +241,7 @@ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper {
}
long addr = EGL.eglGetProcAddress(eglGetProcAddressHandle, glFuncName);
- if(DEBUG) {
+ if(DEBUG_LOOKUP) {
if(0!=addr) {
System.err.println("Lookup-EGL: <"+glFuncName+"> 0x"+Long.toHexString(addr));
}
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 4f04bb57a..574c3c8cf 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
@@ -37,6 +37,7 @@ package com.sun.opengl.impl.egl;
import java.util.*;
import javax.media.nativewindow.*;
+import javax.media.nativewindow.egl.*;
import javax.media.opengl.*;
import com.sun.opengl.impl.*;
import com.sun.gluegen.runtime.NativeLibrary;
@@ -52,15 +53,30 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
return configID;
}
- public EGLGraphicsConfiguration(AbstractGraphicsScreen screen,
+ public EGLGraphicsConfiguration(AbstractGraphicsScreen absScreen,
GLCapabilities capsChosen, GLCapabilities capsRequested, GLCapabilitiesChooser chooser,
_EGLConfig cfg, int cfgID) {
- super(screen, capsChosen, capsRequested);
+ super(absScreen, capsChosen, capsRequested);
this.chooser = chooser;
_config = cfg;
configID = cfgID;
}
+ public static EGLGraphicsConfiguration create(GLCapabilities capsRequested, AbstractGraphicsScreen absScreen, int cfgID) {
+ AbstractGraphicsDevice absDevice = absScreen.getDevice();
+ if(null==absDevice || !(absDevice instanceof EGLGraphicsDevice)) {
+ throw new GLException("GraphicsDevice must be a valid EGLGraphicsDevice");
+ }
+ long dpy = absDevice.getHandle();
+ if (dpy == EGL.EGL_NO_DISPLAY) {
+ throw new GLException("Invalid EGL display: "+absDevice);
+ }
+ GLProfile glp = capsRequested.getGLProfile();
+ _EGLConfig _cfg = EGLConfigId2EGLConfig(glp, dpy, cfgID);
+ GLCapabilities caps = EGLConfig2Capabilities(glp, dpy, _cfg);
+ return new EGLGraphicsConfiguration(absScreen, caps, capsRequested, new DefaultGLCapabilitiesChooser(), _cfg, cfgID);
+ }
+
public Object clone() {
return super.clone();
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java
index c7c2bcab2..36117f059 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java
@@ -64,7 +64,7 @@ public class EGLOnscreenDrawable extends EGLDrawable {
return surf;
}
- public void swapBuffers() throws GLException {
+ protected void swapBuffersImpl() {
boolean didLock = false;
try {
if ( !isSurfaceLocked() ) {
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 bcf3294c1..a792762a4 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java
@@ -118,5 +118,6 @@ public class EGLPbufferDrawable extends EGLDrawable {
return new EGLPbufferContext(this, shareWith);
}
+ protected void swapBuffersImpl() { }
}
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 b424e9516..181efc8bb 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
@@ -320,7 +320,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
protected void updateGLProcAddressTable() {
- super.updateGLProcAddressTable();
if (DEBUG) {
System.err.println("!!! Initializing CGL extension address table");
}
@@ -330,6 +329,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
cglExtProcAddressTable = new CGLExtProcAddressTable();
}
resetProcAddressTable(getCGLExtProcAddressTable());
+ super.updateGLProcAddressTable();
}
public String getPlatformExtensionsString()
@@ -337,11 +337,12 @@ public abstract class MacOSXCGLContext extends GLContextImpl
return "";
}
- public void setSwapInterval(int interval) {
+ protected void setSwapIntervalImpl(int interval) {
if (nsContext == 0) {
throw new GLException("OpenGL context not current");
}
CGL.setSwapInterval(nsContext, interval);
+ currentSwapInterval = interval ;
}
public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java
index f87cc150b..4a3e0a8eb 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java
@@ -102,7 +102,7 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
}
}
- public void swapBuffers() throws GLException {
+ protected void swapBuffers() {
if (!CGL.flushBuffer(nsContext)) {
throw new GLException("Error swapping buffers");
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java
index 98687b5ef..56951ae10 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java
@@ -78,7 +78,7 @@ public class MacOSXOnscreenCGLDrawable extends MacOSXCGLDrawable {
return component.getHeight();
}
- public void swapBuffers() throws GLException {
+ protected void swapBuffersImpl() {
for (Iterator iter = createdContexts.iterator(); iter.hasNext(); ) {
WeakReference ref = (WeakReference) iter.next();
MacOSXOnscreenCGLContext ctx = (MacOSXOnscreenCGLContext) ref.get();
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
index d702150d3..0754c4b57 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
@@ -86,7 +86,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
rect = false;
}
}
- textureTarget = (rect ? GL2.GL_TEXTURE_RECTANGLE_EXT: GL.GL_TEXTURE_2D);
+ textureTarget = (rect ? GL2.GL_TEXTURE_RECTANGLE : GL.GL_TEXTURE_2D);
int[] tmp = new int[1];
gl.glGenTextures(1, tmp, 0);
texture = tmp[0];
@@ -121,11 +121,12 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
}
}
- public void setSwapInterval(int interval) {
+ protected void setSwapIntervalImpl(int interval) {
if (nsContext == 0) {
throw new GLException("OpenGL context not current");
}
impl.setSwapInterval(nsContext, interval);
+ currentSwapInterval = impl.getSwapInterval() ;
}
public int getFloatingPointMode() {
@@ -210,6 +211,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
public boolean makeCurrent(long ctx);
public boolean release(long ctx);
public void setSwapInterval(long ctx, int interval);
+ public int getSwapInterval();
}
// NSOpenGLContext-based implementation
@@ -241,8 +243,14 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
return CGL.clearCurrentContext(ctx);
}
+ private int currentSwapInterval = 0 ;
+
public void setSwapInterval(long ctx, int interval) {
CGL.setSwapInterval(ctx, interval);
+ currentSwapInterval = interval ;
+ }
+ public int getSwapInterval() {
+ return currentSwapInterval;
}
}
@@ -344,5 +352,8 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
public void setSwapInterval(long ctx, int interval) {
// For now not supported (not really relevant for off-screen contexts anyway)
}
+ public int getSwapInterval() {
+ return 0;
+ }
}
}
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 54101331d..2d7b3ea34 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
@@ -87,7 +87,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
return pBuffer;
}
- public void swapBuffers() throws GLException {
+ protected void swapBuffersImpl() {
// FIXME: do we need to do anything if the pbuffer is double-buffered?
}
@@ -98,7 +98,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
GLProfile glProfile = capabilities.getGLProfile();
int renderTarget;
if (glProfile.isGL2() && capabilities.getPbufferRenderToTextureRectangle()) {
- renderTarget = GL2.GL_TEXTURE_RECTANGLE_EXT;
+ renderTarget = GL2.GL_TEXTURE_RECTANGLE;
} else {
int w = getNextPowerOf2(getWidth());
int h = getNextPowerOf2(getHeight());
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
index 4423f8da5..22b0ffe55 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
@@ -144,10 +144,6 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL
}
}
- public void setSwapInterval(int interval) {
- // Not supported in this context implementation
- }
-
public void setOpenGLMode(int mode) {
if (mode != MacOSXCGLDrawable.CGL_MODE)
throw new GLException("OpenGL mode switching not supported for Java2D GLContexts");
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
index b9fc80156..31e65fc8c 100755
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
@@ -51,7 +51,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext {
private boolean created = true;
private GLContext lastContext;
- private WindowsExternalWGLContext(Drawable drawable, long hglrc) {
+ private WindowsExternalWGLContext(Drawable drawable, long hglrc, WindowsWGLGraphicsConfiguration cfg) {
super(drawable, null);
this.hglrc = hglrc;
if (DEBUG) {
@@ -59,6 +59,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext {
}
GLContextShareSet.contextCreated(this);
setGLFunctionAvailability(false);
+ cfg.updateCapabilitiesByWGL(this);
}
protected static WindowsExternalWGLContext create(GLDrawableFactory factory, GLProfile glp) {
@@ -76,12 +77,12 @@ public class WindowsExternalWGLContext extends WindowsWGLContext {
}
AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault();
- WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.create(glp, aScreen, hdc, pfdID, true, true);
+ WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.create(hdc, pfdID, glp, aScreen, true, true);
NullWindow nw = new NullWindow(cfg);
nw.setSurfaceHandle(hdc);
- return new WindowsExternalWGLContext(new Drawable(factory, nw), hglrc);
+ return new WindowsExternalWGLContext(new Drawable(factory, nw), hglrc, cfg);
}
public int makeCurrent() throws GLException {
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java
index 706675893..9b87afc38 100755
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java
@@ -61,12 +61,12 @@ public class WindowsExternalWGLDrawable extends WindowsWGLDrawable {
}
AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault();
- WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.create(glp, aScreen, hdc, pfdID, true, true);
+ WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.create(hdc, pfdID, glp, aScreen, true, true);
NullWindow nw = new NullWindow(cfg);
nw.setSurfaceHandle(hdc);
- // cfg.updateGraphicsConfiguration(factory, nw);
+ cfg.updateGraphicsConfiguration(factory, nw);
return new WindowsExternalWGLDrawable(factory, nw);
}
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 ecd4e1685..71d82e784 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
@@ -127,7 +127,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
}
}
- public void swapBuffers() throws GLException {
+ protected void swapBuffersImpl() {
}
}
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 6a03406f9..20a891414 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
@@ -107,7 +107,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
return floatMode;
}
- public void swapBuffers() throws GLException {
+ protected void swapBuffersImpl() {
}
private void createPbuffer(long parentHdc, WGLExt wglExt) {
@@ -290,12 +290,14 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
GLCapabilities newCaps = WindowsWGLGraphicsConfiguration.AttribList2GLCapabilities(glProfile, iattributes, niattribs, ivalues, true, false, true);
PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.createPixelFormatDescriptor();
if (WGL.DescribePixelFormat(parentHdc, pformats[whichFormat], pfd.size(), pfd) == 0) {
- throw new GLException("Unable to describe pixel format " + pformats[whichFormat]);
+ if (DEBUG) {
+ System.err.println("Unable to describe pixel format (Continue: true) " + whichFormat + "/" + nformats + " pfdID " + pformats[whichFormat]+":\n\t"+newCaps);
+ }
}
if(newCaps.isOnscreen()) {
- throw new GLException("Error: Selected Onscreen Caps for PBuffer: "+newCaps);
+ throw new GLException("Error: Selected Onscreen Caps for PBuffer: "+newCaps+"\n\t"+newCaps);
}
- config.setCapsPFD(newCaps, pfd, pformats[whichFormat]);
+ config.setCapsPFD(newCaps, pfd, pformats[whichFormat], true);
} else {
PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.createPixelFormatDescriptor();
if (WGL.DescribePixelFormat(parentHdc, pformats[whichFormat], pfd.size(), pfd) == 0) {
@@ -303,9 +305,9 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
}
GLCapabilities newCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, pfd, false, true);
if(newCaps.isOnscreen()) {
- throw new GLException("Error: Selected Onscreen Caps for PBuffer: "+newCaps);
+ throw new GLException("Error: Selected Onscreen Caps for PBuffer: "+newCaps+"\n\t"+newCaps);
}
- config.setCapsPFD(newCaps, pfd, pformats[whichFormat]);
+ config.setCapsPFD(newCaps, pfd, pformats[whichFormat], false);
}
}
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 1bc3acada..9a3860ae2 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
@@ -147,20 +147,16 @@ public class WindowsWGLContext extends GLContextImpl {
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)) {
- throw new GLException("Error making temp context current: " + WGL.GetLastError());
+ throw new GLException("Error making temp context current: 0x" + Integer.toHexString(WGL.GetLastError()));
}
setGLFunctionAvailability(true);
if( !isFunctionAvailable("wglCreateContextAttribsARB") ||
!isExtensionAvailable("WGL_ARB_create_context") ) {
if(glCaps.getGLProfile().isGL3()) {
- if (!WGL.wglMakeCurrent(0, 0)) {
- throw new GLException("Error freeing temp OpenGL context: " + WGL.GetLastError());
- }
- if (!WGL.wglDeleteContext(temp_hglrc)) {
- throw new GLException("Unable to delete OpenGL context");
- }
- throw new GLException("Unable to create OpenGL 3.1 context (no WGL_ARB_create_context)");
+ WGL.wglMakeCurrent(0, 0);
+ WGL.wglDeleteContext(temp_hglrc);
+ throw new GLException("Unable to create OpenGL >= 3.1 context (no WGL_ARB_create_context)");
}
// continue with temp context for GL < 3.0
@@ -173,47 +169,70 @@ public class WindowsWGLContext extends GLContextImpl {
// preset with default values
int attribs[] = {
- WGLExt.WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
- WGLExt.WGL_CONTEXT_MINOR_VERSION_ARB, 0,
- WGLExt.WGL_CONTEXT_FLAGS_ARB, 0,
- 0
+ /* 0 */ WGLExt.WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
+ /* 2 */ WGLExt.WGL_CONTEXT_MINOR_VERSION_ARB, 0,
+ /* 4 */ WGLExt.WGL_CONTEXT_FLAGS_ARB, 0 /* WGLExt.WGL_CONTEXT_DEBUG_BIT_ARB */,
+ /* 6 */ 0, 0,
+ /* 8 */ 0
};
if(glCaps.getGLProfile().isGL3()) {
- attribs[1] |= 3;
- attribs[3] |= 1;
- // attribs[5] |= WGLExt.WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB ; // NVidia WGL driver doesn't support this one ..
- // attribs[5] |= WGLExt.WGL_CONTEXT_DEBUG_BIT_ARB ;
+ // Try >= 3.2 core first !
+ // In contrast to GLX no verify with a None drawable binding (default framebuffer) is necessary,
+ // if no 3.2 is available creation fails already!
+ attribs[0+1] = 3;
+ attribs[2+1] = 2;
+ attribs[6+0] = WGLExt.WGL_CONTEXT_PROFILE_MASK_ARB;
+ attribs[6+1] = WGLExt.WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
+ hglrc = wglExt.wglCreateContextAttribsARB(drawable.getNativeWindow().getSurfaceHandle(), hglrc2, attribs, 0);
+ if(0==hglrc) {
+ if(DEBUG) {
+ System.err.println("WindowsWGLContext.createContext couldn't create >= 3.2 core context - fallback");
+ }
+ // Try >= 3.1 forward compatible - last resort for GL3 !
+ attribs[0+1] = 3;
+ attribs[2+1] = 1;
+ attribs[4+1] |= WGLExt.WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
+ attribs[6+0] = 0;
+ attribs[6+1] = 0;
+ } else if(DEBUG) {
+ System.err.println("WindowsWGLContext.createContext >= 3.2 available 0x"+Long.toHexString(hglrc));
+ }
+ }
+ if(0==hglrc) {
+ // 3.1 or 3.0 ..
+ hglrc = wglExt.wglCreateContextAttribsARB(drawable.getNativeWindow().getSurfaceHandle(), hglrc2, attribs, 0);
+ if(DEBUG) {
+ if(0==hglrc) {
+ System.err.println("WindowsWGLContext.createContext couldn't create >= 3.0 context - fallback");
+ } else {
+ System.err.println("WindowsWGLContext.createContext >= 3.0 available 0x"+Long.toHexString(hglrc));
+ }
+ }
}
- hglrc = wglExt.wglCreateContextAttribsARB(drawable.getNativeWindow().getSurfaceHandle(), hglrc2, attribs, 0);
if(0==hglrc) {
if(glCaps.getGLProfile().isGL3()) {
- if (!WGL.wglMakeCurrent(0, 0)) {
- throw new GLException("Error freeing temp OpenGL context: " + WGL.GetLastError());
- }
- if (!WGL.wglDeleteContext(temp_hglrc)) {
- throw new GLException("Unable to delete OpenGL context");
- }
- throw new GLException("Unable to create OpenGL 3.1 context (have WGL_ARB_create_context)");
+ WGL.wglMakeCurrent(0, 0);
+ WGL.wglDeleteContext(temp_hglrc);
+ throw new GLException("Unable to create OpenGL >= 3.1 context (have WGL_ARB_create_context)");
}
// continue with temp context for GL < 3.0
hglrc = temp_hglrc;
+ if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), hglrc)) {
+ throw new GLException("Error making old context current: 0x" + Integer.toHexString(WGL.GetLastError()));
+ }
if(DEBUG) {
System.err.println("WindowsWGLContext.create done (old ctx < 3.0 - no 3.0) 0x"+Long.toHexString(hglrc));
}
} else {
hglrc2 = 0; // mark as shared ..
- if (!WGL.wglMakeCurrent(0, 0)) {
- throw new GLException("Error freeing temp OpenGL context: " + WGL.GetLastError());
- }
- if (!WGL.wglDeleteContext(temp_hglrc)) {
- throw new GLException("Unable to delete temp OpenGL context");
- }
+ WGL.wglMakeCurrent(0, 0);
+ WGL.wglDeleteContext(temp_hglrc);
if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), hglrc)) {
- throw new GLException("Error making new context current: " + WGL.GetLastError());
+ throw new GLException("Error making new context current: 0x" + Integer.toHexString(WGL.GetLastError()));
}
updateGLProcAddressTable();
if(DEBUG) {
@@ -225,8 +244,8 @@ public class WindowsWGLContext extends GLContextImpl {
if(0!=hglrc2) {
if (!WGL.wglShareLists(hglrc2, hglrc)) {
throw new GLException("wglShareLists(" + toHexString(hglrc2) +
- ", " + toHexString(hglrc) + ") failed: error code " +
- WGL.GetLastError());
+ ", " + toHexString(hglrc) + ") failed: error code 0x" +
+ Integer.toHexString(WGL.GetLastError()));
}
}
GLContextShareSet.contextCreated(this);
@@ -253,7 +272,7 @@ public class WindowsWGLContext extends GLContextImpl {
if (WGL.wglGetCurrentContext() != hglrc) {
if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), hglrc)) {
- throw new GLException("Error making context current: " + WGL.GetLastError());
+ throw new GLException("Error making context current: 0x" + Integer.toHexString(WGL.GetLastError()));
} else {
if (DEBUG && VERBOSE) {
System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) +
@@ -264,6 +283,11 @@ public class WindowsWGLContext extends GLContextImpl {
if (created) {
setGLFunctionAvailability(false);
+
+ WindowsWGLGraphicsConfiguration config =
+ (WindowsWGLGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ config.updateCapabilitiesByWGL(this);
+
return CONTEXT_CURRENT_NEW;
}
return CONTEXT_CURRENT;
@@ -271,7 +295,7 @@ public class WindowsWGLContext extends GLContextImpl {
protected void releaseImpl() throws GLException {
if (!WGL.wglMakeCurrent(0, 0)) {
- throw new GLException("Error freeing OpenGL context: " + WGL.GetLastError());
+ throw new GLException("Error freeing OpenGL context: 0x" + Integer.toHexString(WGL.GetLastError()));
}
}
@@ -308,7 +332,6 @@ public class WindowsWGLContext extends GLContextImpl {
}
protected void updateGLProcAddressTable() {
- super.updateGLProcAddressTable();
if (DEBUG) {
System.err.println(getThreadName() + ": !!! Initializing WGL extension address table for " + this);
}
@@ -318,6 +341,7 @@ public class WindowsWGLContext extends GLContextImpl {
wglExtProcAddressTable = new WGLExtProcAddressTable();
}
resetProcAddressTable(getWGLExtProcAddressTable());
+ super.updateGLProcAddressTable();
}
public String getPlatformExtensionsString() {
@@ -332,29 +356,12 @@ public class WindowsWGLContext extends GLContextImpl {
}
}
- public boolean isFunctionAvailable(String glFunctionName)
- {
- boolean available = super.isFunctionAvailable(glFunctionName);
-
- // Sanity check for implementations that use proc addresses for run-time
- // linking: if the function IS available, then make sure there's a proc
- // address for it if it's an extension or not part of the OpenGL 1.1 core
- // (post GL 1.1 functions are run-time linked on windows).
- /* FIXME:
- assert(!available ||
- (getGLProcAddressTable().getAddressFor(mapToRealGLFunctionName(glFunctionName)) != 0 ||
- FunctionAvailabilityCache.isPartOfGLCore("1.1", mapToRealGLFunctionName(glFunctionName)))
- ); */
-
- return available;
- }
-
- public void setSwapInterval(int interval) {
- // FIXME: make the context current first? Currently assumes that
- // will not be necessary. Make the caller do this?
+ protected void setSwapIntervalImpl(int interval) {
WGLExt wglExt = getWGLExt();
if (wglExt.isExtensionAvailable("WGL_EXT_swap_control")) {
- wglExt.wglSwapIntervalEXT(interval);
+ if ( wglExt.wglSwapIntervalEXT(interval) ) {
+ currentSwapInterval = interval ;
+ }
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java
index 3017d258b..01e259665 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java
@@ -82,44 +82,41 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
}
}
- public void swapBuffers() throws GLException {
- GLCapabilities caps = (GLCapabilities)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
- if (caps.getDoubleBuffered()) {
- boolean didLock = false;
+ protected void swapBuffersImpl() {
+ boolean didLock = false;
- try {
- if ( !isSurfaceLocked() ) {
- // Usually the surface shall be locked within [makeCurrent .. swap .. release]
- if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
- return;
- }
- didLock = true;
+ try {
+ if ( !isSurfaceLocked() ) {
+ // Usually the surface shall be locked within [makeCurrent .. swap .. release]
+ if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
+ return;
}
+ didLock = true;
+ }
- long startTime = 0;
- if (PROFILING) {
- startTime = System.currentTimeMillis();
- }
+ long startTime = 0;
+ if (PROFILING) {
+ startTime = System.currentTimeMillis();
+ }
- if (!WGL.SwapBuffers(getNativeWindow().getSurfaceHandle()) && (WGL.GetLastError() != 0)) {
- throw new GLException("Error swapping buffers");
- }
+ if (!WGL.SwapBuffers(getNativeWindow().getSurfaceHandle()) && (WGL.GetLastError() != 0)) {
+ throw new GLException("Error swapping buffers");
+ }
- if (PROFILING) {
- long endTime = System.currentTimeMillis();
- profilingSwapBuffersTime += (endTime - startTime);
- int ticks = PROFILING_TICKS;
- if (++profilingSwapBuffersTicks == ticks) {
- System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + ticks + " calls (" +
- ((float) profilingSwapBuffersTime / (float) ticks) + " ms/call)");
- profilingSwapBuffersTime = 0;
- profilingSwapBuffersTicks = 0;
- }
- }
- } finally {
- if (didLock) {
- unlockSurface();
- }
+ if (PROFILING) {
+ long endTime = System.currentTimeMillis();
+ profilingSwapBuffersTime += (endTime - startTime);
+ int ticks = PROFILING_TICKS;
+ if (++profilingSwapBuffersTicks == ticks) {
+ System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + ticks + " calls (" +
+ ((float) profilingSwapBuffersTime / (float) ticks) + " ms/call)");
+ profilingSwapBuffersTime = 0;
+ profilingSwapBuffersTicks = 0;
+ }
+ }
+ } finally {
+ if (didLock) {
+ unlockSurface();
}
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index 1a8d45465..844e72841 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -49,6 +49,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
private int pixelfmtID;
private boolean isChosen = false;
private GLCapabilitiesChooser chooser;
+ private boolean choosenByWGLPixelFormat=false;
public WindowsWGLGraphicsConfiguration(AbstractGraphicsScreen screen, GLCapabilities capsChosen, GLCapabilities capsRequested,
PIXELFORMATDESCRIPTOR pixelfmt, int pixelfmtID, GLCapabilitiesChooser chooser) {
@@ -58,17 +59,26 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
this.pixelfmtID = pixelfmtID;
}
- public static WindowsWGLGraphicsConfiguration create(GLProfile glp, AbstractGraphicsScreen screen, long hdc, int pfdID, boolean onscreen, boolean usePBuffer) {
- PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor();
- if (WGL.DescribePixelFormat(hdc, pfdID, pfd.size(), pfd) == 0) {
- throw new GLException("Unable to describe pixel format " + pfdID);
+ public static WindowsWGLGraphicsConfiguration create(long hdc, int pfdID,
+ GLProfile glp, AbstractGraphicsScreen screen, boolean onscreen, boolean usePBuffer)
+ {
+ if(pfdID<=0) {
+ throw new GLException("Invalid pixelformat id "+pfdID);
}
if(null==glp) {
glp = GLProfile.getDefault();
}
+ PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor();
+ if (WGL.DescribePixelFormat(hdc, pfdID, pfd.size(), pfd) == 0) {
+ throw new GLException("Unable to describe pixel format " + pfdID);
+ }
+
GLCapabilities caps = PFD2GLCapabilities(glp, pfd, onscreen, usePBuffer);
+ if(null==caps) {
+ throw new GLException("Couldn't choose Capabilities by: HDC 0x"+Long.toHexString(hdc)+", pfdID "+pfdID);
+ }
WindowsWGLGraphicsConfiguration cfg = new WindowsWGLGraphicsConfiguration(screen, caps, caps, pfd, pfdID, new DefaultGLCapabilitiesChooser());
- cfg.setCapsPFD(caps, pfd, pfdID);
+ cfg.setCapsPFD(caps, pfd, pfdID, false);
return cfg;
}
@@ -77,15 +87,40 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
return super.clone();
}
+ /** Update config - before having a valid context */
protected void updateGraphicsConfiguration(GLDrawableFactory factory, NativeWindow nativeWindow) {
WindowsWGLGraphicsConfigurationFactory.updateGraphicsConfiguration(chooser, factory, nativeWindow);
}
- protected void setCapsPFD(GLCapabilities caps, PIXELFORMATDESCRIPTOR pfd, int pfdID) {
- // FIXME: setScreen ( .. )
+
+ /** Update config - after having a valid and current context */
+ protected void updateCapabilitiesByWGL(GLContextImpl context) {
+ if(choosenByWGLPixelFormat) return; // already done ..
+
+ GLCapabilities capabilities = (GLCapabilities) getRequestedCapabilities();
+ boolean onscreen = capabilities.isOnscreen();
+ boolean usePBuffer = capabilities.isPBuffer();
+ GLProfile glp = capabilities.getGLProfile();
+
+ WGLExt wglExt = (WGLExt) context.getPlatformGLExtensions();
+ GLDrawable drawable = context.getGLDrawable();
+ NativeWindow nativeWindow = drawable.getNativeWindow();
+ long hdc = nativeWindow.getSurfaceHandle();
+
+ GLCapabilities[] caps = HDC2GLCapabilities(wglExt, hdc, getPixelFormatID(), glp, true, onscreen, usePBuffer);
+ if(null!=caps && null!=caps[0]) {
+ setCapsPFD(caps[0], getPixelFormat(), getPixelFormatID(), true);
+ }
+ }
+
+ protected void setCapsPFD(GLCapabilities caps, PIXELFORMATDESCRIPTOR pfd, int pfdID, boolean choosenByWGLPixelFormat) {
this.pixelfmt = pfd;
this.pixelfmtID = pfdID;
setChosenCapabilities(caps);
- isChosen=true;
+ this.isChosen=true;
+ this.choosenByWGLPixelFormat=choosenByWGLPixelFormat;
+ if (DEBUG) {
+ System.err.println("*** setCapsPFD: WGL-Choosen "+choosenByWGLPixelFormat+", pfdID "+pfdID+", "+caps);
+ }
}
public boolean getCapabilitiesChosen() {
@@ -94,6 +129,102 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
public PIXELFORMATDESCRIPTOR getPixelFormat() { return pixelfmt; }
public int getPixelFormatID() { return pixelfmtID; }
+ public boolean isChoosenByWGL() { return choosenByWGLPixelFormat; }
+
+ private static int haveWGLChoosePixelFormatARB = -1;
+ private static int haveWGLARBMultisample = -1;
+
+ public static GLCapabilities[] HDC2GLCapabilities(WGLExt wglExt, long hdc, int pfdIDOnly,
+ GLProfile glp, boolean relaxed, boolean onscreen, boolean usePBuffer) {
+
+ if(haveWGLChoosePixelFormatARB<0) {
+ haveWGLChoosePixelFormatARB = wglExt.isExtensionAvailable("WGL_ARB_pixel_format")?1:0;
+ }
+ if(haveWGLARBMultisample<0) {
+ haveWGLARBMultisample = wglExt.isExtensionAvailable("WGL_ARB_multisample")?1:0;
+ }
+ if (0==haveWGLChoosePixelFormatARB) {
+ return null;
+ }
+
+ // Produce a list of GLCapabilities to give to the
+ // GLCapabilitiesChooser.
+ // Use wglGetPixelFormatAttribivARB instead of
+ // DescribePixelFormat to get higher-precision information
+ // about the pixel format (should make the GLCapabilities
+ // more precise as well...i.e., remove the
+ // "HardwareAccelerated" bit, which is basically
+ // meaningless, and put in whether it can render to a
+ // window, to a pbuffer, or to a pixmap)
+ GLCapabilities[] availableCaps = null;
+ int numFormats = 0;
+ int niattribs = 0;
+ int[] iattributes = new int [2*MAX_ATTRIBS];
+ int[] iresults = new int [2*MAX_ATTRIBS];
+
+ iattributes[0] = WGLExt.WGL_NUMBER_PIXEL_FORMATS_ARB;
+ if (wglExt.wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, iattributes, 0, iresults, 0)) {
+ numFormats = iresults[0];
+
+ if (DEBUG) {
+ System.err.println("wglGetPixelFormatAttribivARB reported WGL_NUMBER_PIXEL_FORMATS = " + numFormats);
+ }
+
+ if(pfdIDOnly>0 && pfdIDOnly>numFormats) {
+ throw new GLException("Invalid pixelformat ID " + pfdIDOnly + " (should be between 1 and " + numFormats + ")");
+ }
+
+ // Should we be filtering out the pixel formats which aren't
+ // applicable, as we are doing here?
+ // We don't have enough information in the GLCapabilities to
+ // represent those that aren't...
+ iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_WINDOW_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_ACCELERATION_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_SUPPORT_OPENGL_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_DEPTH_BITS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_STENCIL_BITS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_DOUBLE_BUFFER_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_STEREO_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_PIXEL_TYPE_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_RED_BITS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_GREEN_BITS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_BLUE_BITS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_ALPHA_BITS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_ACCUM_RED_BITS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_ACCUM_GREEN_BITS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_ACCUM_BLUE_BITS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_ACCUM_ALPHA_BITS_ARB;
+ if (1==haveWGLARBMultisample) {
+ iattributes[niattribs++] = WGLExt.WGL_SAMPLE_BUFFERS_ARB;
+ iattributes[niattribs++] = WGLExt.WGL_SAMPLES_ARB;
+ }
+
+ if(pfdIDOnly>0) {
+ availableCaps = new GLCapabilities[1];
+ if (!wglExt.wglGetPixelFormatAttribivARB(hdc, pfdIDOnly, 0, niattribs, iattributes, 0, iresults, 0)) {
+ throw new GLException("Error getting pixel format attributes for pixel format " + pfdIDOnly + " of device context");
+ }
+ availableCaps[0] = AttribList2GLCapabilities(glp, iattributes, niattribs, iresults,
+ relaxed, onscreen, usePBuffer);
+ } else {
+ availableCaps = new GLCapabilities[numFormats];
+ for (int i = 0; i < numFormats; i++) {
+ if (!wglExt.wglGetPixelFormatAttribivARB(hdc, i+1, 0, niattribs, iattributes, 0, iresults, 0)) {
+ throw new GLException("Error getting pixel format attributes for pixel format " + (i + 1) + " of device context");
+ }
+ availableCaps[i] = AttribList2GLCapabilities(glp, iattributes, niattribs, iresults,
+ relaxed, onscreen, usePBuffer);
+ }
+ }
+ } else {
+ long lastErr = WGL.GetLastError();
+ // Intel Extreme graphics fails with a zero error code
+ if (lastErr != 0) {
+ throw new GLException("Unable to enumerate pixel formats of window using wglGetPixelFormatAttribivARB: error code " + WGL.GetLastError());
+ }
+ }
+ return availableCaps;
+ }
public static boolean GLCapabilities2AttribList(GLCapabilities caps,
int[] iattributes,
@@ -498,7 +629,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
}
public String toString() {
- return "WindowsWGLGraphicsConfiguration["+getScreen()+", pfdID " + pixelfmtID +
+ return "WindowsWGLGraphicsConfiguration["+getScreen()+", pfdID " + pixelfmtID + ", wglChoosen "+choosenByWGLPixelFormat+
",\n\trequested " + getRequestedCapabilities() +
",\n\tchosen " + getChosenCapabilities() +
"]";
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 f5974dc61..a7d7be349 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
@@ -99,6 +99,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects");
}
+ boolean choosenBywGLPixelFormat = false;
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) nativeWindow.getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilities capabilities = (GLCapabilities) config.getRequestedCapabilities();
boolean onscreen = capabilities.isOnscreen();
@@ -113,7 +114,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
}
PIXELFORMATDESCRIPTOR pfd = null;
- int pixelFormat = -1;
+ int pixelFormat = -1; // 1-based pixel format
boolean pixelFormatSet = false;
GLCapabilities chosenCaps = null;
@@ -125,7 +126,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
// - or the Java2D/OpenGL pipeline's configuration
if (DEBUG) {
System.err.println("!!!! NOTE: pixel format already chosen for HDC: 0x" + Long.toHexString(hdc)+
- ", pixelformat "+WGL.GetPixelFormat(hdc));
+ ", pixelformat "+pixelFormat);
}
pixelFormatSet = true;
}
@@ -138,27 +139,25 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
WindowsWGLDrawable dummyDrawable = null;
GLContextImpl dummyContext = null;
WGLExt dummyWGLExt = null;
- dummyDrawable = new WindowsDummyWGLDrawable(factory);
- dummyContext = (GLContextImpl) dummyDrawable.createContext(null);
- if (dummyContext != null) {
- dummyContext.makeCurrent();
- dummyWGLExt = (WGLExt) dummyContext.getPlatformGLExtensions();
- }
- int recommendedPixelFormat = pixelFormat - 1;
+ if (capabilities.getSampleBuffers()) {
+ dummyDrawable = new WindowsDummyWGLDrawable(factory);
+ dummyContext = (GLContextImpl) dummyDrawable.createContext(null);
+ if (dummyContext != null) {
+ dummyContext.makeCurrent();
+ dummyWGLExt = (WGLExt) dummyContext.getPlatformGLExtensions();
+ }
+ }
+ int recommendedPixelFormat = pixelFormat; // 1-based pixel format
boolean haveWGLChoosePixelFormatARB = false;
- boolean haveWGLARBMultisample = false;
boolean gotAvailableCaps = false;
if (dummyWGLExt != null) {
try {
haveWGLChoosePixelFormatARB = dummyWGLExt.isExtensionAvailable("WGL_ARB_pixel_format");
if (haveWGLChoosePixelFormatARB) {
- haveWGLARBMultisample = dummyWGLExt.isExtensionAvailable("WGL_ARB_multisample");
-
- int[] iattributes = new int [2*WindowsWGLGraphicsConfiguration.MAX_ATTRIBS];
- int[] iresults = new int [2*WindowsWGLGraphicsConfiguration.MAX_ATTRIBS];
- float[] fattributes = new float[1];
-
if(pixelFormat<=0) {
+ int[] iattributes = new int [2*WindowsWGLGraphicsConfiguration.MAX_ATTRIBS];
+ float[] fattributes = new float[1];
+
if(WindowsWGLGraphicsConfiguration.GLCapabilities2AttribList(capabilities,
iattributes,
dummyWGLExt,
@@ -174,8 +173,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
numFormatsTmp, 0)) {
numFormats = numFormatsTmp[0];
if (recommendedPixelFormat<=0 && numFormats > 0) {
- // Remove one-basing of pixel format (added on later)
- recommendedPixelFormat = pformats[0] - 1;
+ recommendedPixelFormat = pformats[0];
if (DEBUG) {
System.err.println(getThreadName() + ": Used wglChoosePixelFormatARB to recommend pixel format " + recommendedPixelFormat);
}
@@ -187,7 +185,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
}
}
if (DEBUG) {
- if (recommendedPixelFormat < 0) {
+ if (recommendedPixelFormat <= 0) {
System.err.print(getThreadName() + ": wglChoosePixelFormatARB didn't recommend a pixel format");
if (capabilities.getSampleBuffers()) {
System.err.print(" for multisampled GLCapabilities");
@@ -198,65 +196,9 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
}
}
- // Produce a list of GLCapabilities to give to the
- // GLCapabilitiesChooser.
- // Use wglGetPixelFormatAttribivARB instead of
- // DescribePixelFormat to get higher-precision information
- // about the pixel format (should make the GLCapabilities
- // more precise as well...i.e., remove the
- // "HardwareAccelerated" bit, which is basically
- // meaningless, and put in whether it can render to a
- // window, to a pbuffer, or to a pixmap)
- int niattribs = 0;
- iattributes[0] = WGLExt.WGL_NUMBER_PIXEL_FORMATS_ARB;
- if (dummyWGLExt.wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, iattributes, 0, iresults, 0)) {
- numFormats = iresults[0];
-
- if (DEBUG) {
- System.err.println("wglGetPixelFormatAttribivARB reported WGL_NUMBER_PIXEL_FORMATS = " + numFormats);
- }
-
- // Should we be filtering out the pixel formats which aren't
- // applicable, as we are doing here?
- // We don't have enough information in the GLCapabilities to
- // represent those that aren't...
- iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_WINDOW_ARB;
- iattributes[niattribs++] = WGLExt.WGL_ACCELERATION_ARB;
- iattributes[niattribs++] = WGLExt.WGL_SUPPORT_OPENGL_ARB;
- iattributes[niattribs++] = WGLExt.WGL_DEPTH_BITS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_STENCIL_BITS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_DOUBLE_BUFFER_ARB;
- iattributes[niattribs++] = WGLExt.WGL_STEREO_ARB;
- iattributes[niattribs++] = WGLExt.WGL_PIXEL_TYPE_ARB;
- iattributes[niattribs++] = WGLExt.WGL_RED_BITS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_GREEN_BITS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_BLUE_BITS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_ALPHA_BITS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_ACCUM_RED_BITS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_ACCUM_GREEN_BITS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_ACCUM_BLUE_BITS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_ACCUM_ALPHA_BITS_ARB;
- if (haveWGLARBMultisample) {
- iattributes[niattribs++] = WGLExt.WGL_SAMPLE_BUFFERS_ARB;
- iattributes[niattribs++] = WGLExt.WGL_SAMPLES_ARB;
- }
-
- availableCaps = new GLCapabilities[numFormats];
- for (int i = 0; i < numFormats; i++) {
- if (!dummyWGLExt.wglGetPixelFormatAttribivARB(hdc, i+1, 0, niattribs, iattributes, 0, iresults, 0)) {
- throw new GLException("Error getting pixel format attributes for pixel format " + (i + 1) + " of device context");
- }
- availableCaps[i] = WindowsWGLGraphicsConfiguration.AttribList2GLCapabilities(glProfile, iattributes, niattribs, iresults,
- pixelFormatSet, onscreen, usePBuffer);
- }
- gotAvailableCaps = true;
- } else {
- long lastErr = WGL.GetLastError();
- // Intel Extreme graphics fails with a zero error code
- if (lastErr != 0) {
- throw new GLException("Unable to enumerate pixel formats of window using wglGetPixelFormatAttribivARB: error code " + WGL.GetLastError());
- }
- }
+ availableCaps = WindowsWGLGraphicsConfiguration.HDC2GLCapabilities(dummyWGLExt, hdc, -1, glProfile, pixelFormatSet, onscreen, usePBuffer);
+ gotAvailableCaps = null!=availableCaps ;
+ choosenBywGLPixelFormat = gotAvailableCaps ;
}
} finally {
dummyContext.release();
@@ -265,7 +207,6 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
}
}
- // Fallback path for older cards, in particular Intel Extreme motherboard graphics
if (!gotAvailableCaps) {
if (DEBUG) {
if (!capabilities.getSampleBuffers()) {
@@ -279,8 +220,6 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
if (DEBUG) {
System.err.println(getThreadName() + ": Recommended pixel format = " + recommendedPixelFormat);
}
- // Remove one-basing of pixel format (added on later)
- recommendedPixelFormat -= 1;
numFormats = WGL.DescribePixelFormat(hdc, 1, 0, null);
if (numFormats == 0) {
@@ -305,19 +244,27 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
if(null!=chooser) {
// Supply information to chooser
try {
- pixelFormat = chooser.chooseCapabilities(capabilities, availableCaps, recommendedPixelFormat);
+ pixelFormat = chooser.chooseCapabilities(capabilities, availableCaps, recommendedPixelFormat) + 1;
} catch (NativeWindowException e) {
- throw new GLException(e);
+ if(DEBUG) {
+ e.printStackTrace();
+ }
+ pixelFormat = -1;
}
} else {
pixelFormat = recommendedPixelFormat;
}
- if ((pixelFormat < 0) || (pixelFormat >= numFormats)) {
+ if (pixelFormat <= 0) {
+ // keep on going ..
+ if(DEBUG) {
+ System.err.println("WindowsWGLGraphicsConfigurationFactory.updateGraphicsConfiguration .. unable to choose config, using first");
+ }
+ pixelFormat = 1; // default ..
+ } else if ( pixelFormat > numFormats ) {
throw new GLException("Invalid result " + pixelFormat +
- " from GLCapabilitiesChooser (should be between 0 and " +
- (numFormats - 1) + ")");
+ " from GLCapabilitiesChooser (should be between 1 and " +
+ numFormats + ")");
}
- pixelFormat += 1; // one-base the index
}
chosenCaps = availableCaps[pixelFormat-1];
if (DEBUG) {
@@ -355,7 +302,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
} else {
capabilities = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, pfd, onscreen, usePBuffer);
}
- config.setCapsPFD(capabilities, pfd, pixelFormat);
+ config.setCapsPFD(capabilities, pfd, pixelFormat, choosenBywGLPixelFormat);
}
protected static String getThreadName() {
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 57abcf588..d5a5f3433 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
@@ -142,7 +142,7 @@ public abstract class X11GLXContext extends GLContextImpl {
if(config.getFBConfigID()<0) {
// not able to use FBConfig
if(glCaps.getGLProfile().isGL3()) {
- throw new GLException("Unable to create OpenGL 3.1 context");
+ throw new GLException("Unable to create OpenGL >= 3.1 context");
}
context = GLX.glXCreateContext(display, config.getXVisualInfo(), share, direct);
if (context == 0) {
@@ -178,11 +178,9 @@ public abstract class X11GLXContext extends GLContextImpl {
if( !isFunctionAvailable("glXCreateContextAttribsARB") ||
!isExtensionAvailable("GLX_ARB_create_context") ) {
if(glCaps.getGLProfile().isGL3()) {
- if (!GLX.glXMakeContextCurrent(display, 0, 0, 0)) {
- throw new GLException("Error freeing temp OpenGL context");
- }
+ GLX.glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_context);
- throw new GLException("Unable to create OpenGL 3.1 context (no GLX_ARB_create_context)");
+ throw new GLException("Unable to create OpenGL >= 3.1 context (no GLX_ARB_create_context)");
}
// continue with temp context for GL < 3.0
@@ -195,47 +193,99 @@ public abstract class X11GLXContext extends GLContextImpl {
// preset with default values
int attribs[] = {
- GLX.GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
- GLX.GLX_CONTEXT_MINOR_VERSION_ARB, 0,
- GLX.GLX_CONTEXT_FLAGS_ARB, 0,
- GLX.GLX_RENDER_TYPE, GLX.GLX_RGBA_TYPE,
- 0
+ /* 0 */ GLX.GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
+ /* 2 */ GLX.GLX_CONTEXT_MINOR_VERSION_ARB, 0,
+ /* 4 */ GLX.GLX_RENDER_TYPE, GLX.GLX_RGBA_TYPE,
+ /* 6 */ GLX.GLX_CONTEXT_FLAGS_ARB, 0 /* GLX.GLX_CONTEXT_DEBUG_BIT_ARB */,
+ /* 8 */ 0, 0,
+ /* 10 */ 0
};
if(glCaps.getGLProfile().isGL3()) {
- attribs[1] |= 3;
- attribs[3] |= 1;
- attribs[5] |= GLX.GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /* | GLX.GLX_CONTEXT_DEBUG_BIT_ARB */;
+ // Try >= 3.2 core first
+ // and verify with a None drawable binding (default framebuffer)
+ attribs[0+1] = 3;
+ attribs[2+1] = 2;
+ // FIXME NV Bug: attribs[8+0] = GLX.GLX_CONTEXT_PROFILE_MASK_ARB;
+ // FIXME NV Bug: attribs[8+1] = GLX.GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
+
+ context = glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs, 0);
+ if(0!=context) {
+ if (!GLX.glXMakeContextCurrent(display,
+ drawable.getNativeWindow().getSurfaceHandle(),
+ drawable.getNativeWindow().getSurfaceHandle(),
+ context)) {
+ if(DEBUG) {
+ System.err.println("X11GLXContext.createContext couldn't make >= 3.2 core context current - fallback");
+ }
+ GLX.glXMakeContextCurrent(display, 0, 0, 0);
+ GLX.glXDestroyContext(display, context);
+ context = 0;
+ } else if(DEBUG) {
+ System.err.println("X11GLXContext.createContext >= 3.2 available 0x"+Long.toHexString(context));
+ }
+ } else {
+ if(DEBUG) {
+ System.err.println("X11GLXContext.createContext couldn't create >= 3.2 core context - fallback");
+ }
+ }
+ if(0==context) {
+ // Try >= 3.1 forward compatible - last resort for GL3 !
+ attribs[0+1] = 3;
+ attribs[2+1] = 1;
+ attribs[6+1] |= GLX.GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
+ attribs[8+0] = 0;
+ attribs[8+1] = 0;
+ }
+ }
+ if(0==context) {
+ // 3.1 or 3.0 ..
+ context = glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs, 0);
+ if(0!=context) {
+ if (!GLX.glXMakeContextCurrent(display,
+ drawable.getNativeWindow().getSurfaceHandle(),
+ drawable.getNativeWindow().getSurfaceHandle(),
+ context)) {
+ if(DEBUG) {
+ System.err.println("X11GLXContext.createContext couldn't make >= 3.0 core context current - fallback");
+ }
+ GLX.glXMakeContextCurrent(display, 0, 0, 0);
+ GLX.glXDestroyContext(display, context);
+ context = 0;
+ } else if(DEBUG) {
+ System.err.println("X11GLXContext.createContext >= 3.0 available 0x"+Long.toHexString(context));
+ }
+ } else {
+ if(DEBUG) {
+ System.err.println("X11GLXContext.createContext couldn't create >= 3.0 core context - fallback");
+ }
+ }
}
- context = glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs, 0);
if(0==context) {
if(glCaps.getGLProfile().isGL3()) {
- if (!GLX.glXMakeContextCurrent(display, 0, 0, 0)) {
- throw new GLException("Error freeing temp OpenGL context");
- }
+ GLX.glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_context);
- throw new GLException("Unable to create OpenGL 3.1 context (have GLX_ARB_create_context)");
+ throw new GLException("Unable to create OpenGL >= 3.1 context (have GLX_ARB_create_context)");
}
// continue with temp context for GL < 3.0
context = temp_context;
+ if (!GLX.glXMakeContextCurrent(display,
+ drawable.getNativeWindow().getSurfaceHandle(),
+ drawable.getNativeWindow().getSurfaceHandle(),
+ context)) {
+ GLX.glXMakeContextCurrent(display, 0, 0, 0);
+ GLX.glXDestroyContext(display, temp_context);
+ throw new GLException("Error making context (old) current: display 0x"+Long.toHexString(display)+", context 0x"+Long.toHexString(context)+", drawable "+drawable);
+ }
if(DEBUG) {
System.err.println("X11GLXContext.createContext done (old ctx < 3.0 - no 3.0) 0x"+Long.toHexString(context));
}
} else {
- if (!GLX.glXMakeContextCurrent(display, 0, 0, 0)) {
- throw new GLException("Error freeing temp OpenGL context");
- }
GLX.glXDestroyContext(display, temp_context);
// need to update the GL func table ..
- if (!GLX.glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawable.getNativeWindow().getSurfaceHandle(),
- context)) {
- throw new GLException("Error making context (new) current: display 0x"+Long.toHexString(display)+", context 0x"+Long.toHexString(context)+", drawable "+drawable);
- }
updateGLProcAddressTable();
if(DEBUG) {
System.err.println("X11GLXContext.createContext done (new ctx >= 3.0) 0x"+Long.toHexString(context));
@@ -349,7 +399,6 @@ public abstract class X11GLXContext extends GLContextImpl {
}
protected void updateGLProcAddressTable() {
- super.updateGLProcAddressTable();
if (DEBUG) {
System.err.println(getThreadName() + ": !!! Initializing GLX extension address table");
}
@@ -359,6 +408,7 @@ public abstract class X11GLXContext extends GLContextImpl {
glXExtProcAddressTable = new GLXExtProcAddressTable();
}
resetProcAddressTable(getGLXExtProcAddressTable());
+ super.updateGLProcAddressTable();
}
public synchronized String getPlatformExtensionsString() {
@@ -396,11 +446,9 @@ public abstract class X11GLXContext extends GLContextImpl {
private int hasSwapIntervalSGI = 0;
- public void setSwapInterval(int interval) {
+ protected void setSwapIntervalImpl(int interval) {
getDrawableImpl().getFactoryImpl().lockToolkit();
try {
- // FIXME: make the context current first? Currently assumes that
- // will not be necessary. Make the caller do this?
GLXExt glXExt = getGLXExt();
if(0==hasSwapIntervalSGI) {
try {
@@ -409,7 +457,9 @@ public abstract class X11GLXContext extends GLContextImpl {
}
if (hasSwapIntervalSGI>0) {
try {
- glXExt.glXSwapIntervalSGI(interval);
+ if( 0 == glXExt.glXSwapIntervalSGI(interval) ) {
+ currentSwapInterval = interval;
+ }
} catch (Throwable t) { hasSwapIntervalSGI=-1; }
}
} finally {
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java
index 738714ecb..1abc36c58 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java
@@ -76,26 +76,23 @@ public abstract class X11GLXDrawable extends GLDrawableImpl {
}
}
- public void swapBuffers() throws GLException {
- GLCapabilities caps = (GLCapabilities)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
- if (caps.getDoubleBuffered()) {
- boolean didLock = false;
- try {
- if ( !isSurfaceLocked() ) {
- // Usually the surface shall be locked within [makeCurrent .. swap .. release]
- if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
- return;
- }
- didLock=true;
+ protected void swapBuffersImpl() {
+ boolean didLock = false;
+ try {
+ if ( !isSurfaceLocked() ) {
+ // Usually the surface shall be locked within [makeCurrent .. swap .. release]
+ if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
+ return;
}
+ didLock=true;
+ }
- GLX.glXSwapBuffers(component.getDisplayHandle(), component.getSurfaceHandle());
+ GLX.glXSwapBuffers(component.getDisplayHandle(), component.getSurfaceHandle());
- } finally {
- if(didLock) {
- unlockSurface();
- }
- }
+ } finally {
+ if(didLock) {
+ unlockSurface();
+ }
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
index 4cd174bec..dbf69e865 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
@@ -198,7 +198,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
String glXExtensions = GLX.glXQueryExtensionsString(display, screen);
if (glXExtensions == null ||
glXExtensions.indexOf("GLX_NV_float_buffer") < 0) {
- throw new GLException("Floating-point pbuffers on X11 currently require NVidia hardware");
+ throw new GLException("Floating-point pbuffers on X11 currently require NVidia hardware: "+glXExtensions);
}
res[idx++] = GLXExt.GLX_FLOAT_COMPONENTS_NV;
res[idx++] = GL.GL_TRUE;
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 9cb7eac08..074fbda5f 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
@@ -89,7 +89,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
xvis = X11GLXGraphicsConfiguration.XVisualID2XVisualInfo(display, visID);
caps = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, xvis, onscreen, usePBuffer, isMultisampleAvailable);
- int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(caps, true, isMultisampleAvailable, 0, 0);
+ int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(caps, true, isMultisampleAvailable, display, screen);
int[] count = { -1 };
PointerBuffer fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, attribs, 0, count, 0);
if (fbcfgsL == null || fbcfgsL.limit()<1) {
@@ -186,19 +186,19 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
AbstractGraphicsDevice absDevice = x11Screen.getDevice();
long display = absDevice.getHandle();
boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
- int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, true, isMultisampleAvailable, 0, 0);
+ int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, true, isMultisampleAvailable, display, screen);
int[] count = { -1 };
fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, attribs, 0, count, 0);
if (fbcfgsL == null || fbcfgsL.limit()<1) {
if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: glXChooseFBConfig ("+x11Screen+","+capabilities+"): "+fbcfgsL+", "+count[0]);
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXChooseFBConfig ("+x11Screen+","+capabilities+"): "+fbcfgsL+", "+count[0]);
}
return null;
}
if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(0) ) ) {
if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: GLX FBConfig invalid: ("+x11Screen+","+capabilities+"): "+fbcfgsL+", fbcfg: 0x"+Long.toHexString(fbcfgsL.get(0)));
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed - GLX FBConfig invalid: ("+x11Screen+","+capabilities+"): "+fbcfgsL+", fbcfg: 0x"+Long.toHexString(fbcfgsL.get(0)));
}
return null;
}
@@ -215,11 +215,19 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
try {
chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
} catch (NativeWindowException e) {
- throw new GLException(e);
+ if(DEBUG) {
+ e.printStackTrace();
+ }
+ chosen = -1;
}
}
-
- if (chosen < 0 || chosen >= caps.length) {
+ if (chosen < 0) {
+ // keep on going ..
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig Failed .. unable to choose config, using first");
+ }
+ chosen = 0; // default ..
+ } else if (chosen >= caps.length) {
throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
}
@@ -228,9 +236,12 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
retXVisualInfo = GLX.glXGetVisualFromFBConfigCopied(display, fbcfgsL.get(chosen));
if (retXVisualInfo==null) {
if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: glXGetVisualFromFBConfig ("+x11Screen+", "+fbcfgsL.get(chosen) +": "+fbcfgsL);
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXGetVisualFromFBConfig ("+x11Screen+", "+fbcfgsL.get(chosen) +" (Continue: "+(false==caps[chosen].isOnscreen())+"):\n\t"+caps[chosen]);
+ }
+ if(caps[chosen].isOnscreen()) {
+ // Onscreen drawables shall have a XVisual ..
+ return null;
}
- return null;
}
} finally {
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
@@ -255,7 +266,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
GLCapabilities[] caps = null;
int recommendedIndex = -1;
XVisualInfo retXVisualInfo = null;
- int chosen;
+ int chosen=-1;
NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
try {
@@ -263,7 +274,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
AbstractGraphicsDevice absDevice = x11Screen.getDevice();
long display = absDevice.getHandle();
boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
- int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, isMultisampleAvailable, 0, 0);
+ int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, isMultisampleAvailable, display, screen);
XVisualInfo[] infos = null;
XVisualInfo recommendedVis = GLX.glXChooseVisualCopied(display, screen, attribs, 0);
@@ -293,9 +304,18 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
try {
chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
} catch (NativeWindowException e) {
- throw new GLException(e);
+ if(DEBUG) {
+ e.printStackTrace();
+ }
+ chosen = -1;
}
- if (chosen < 0 || chosen >= caps.length) {
+ if (chosen < 0) {
+ // keep on going ..
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationXVisual Failed .. unable to choose config, using first");
+ }
+ chosen = 0; // default ..
+ } else if (chosen >= caps.length) {
throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
}
if (infos[chosen] == null) {
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 51938df5f..768f6b8e8 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
@@ -133,6 +133,6 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
getFactoryImpl().unlockToolkit();
}
}
- public void swapBuffers() throws GLException {
+ protected void swapBuffersImpl() {
}
}
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 eecd92a53..bee24fa47 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
@@ -148,6 +148,6 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
return GLPbuffer.NV_FLOAT;
}
- public void swapBuffers() throws GLException {
+ protected void swapBuffersImpl() {
}
}
diff --git a/src/jogl/classes/com/sun/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/sun/opengl/util/GLArrayDataClient.java
index e05a77226..ec4c5e393 100644
--- a/src/jogl/classes/com/sun/opengl/util/GLArrayDataClient.java
+++ b/src/jogl/classes/com/sun/opengl/util/GLArrayDataClient.java
@@ -27,13 +27,13 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
}) != null;
/**
- * @arg index The GL array index
- * @arg name The optional custom name for the GL array index, maybe null.
+ * @param index The GL array index
+ * @param name The optional custom name for the GL array index, maybe null.
* If null, the default name mapping will be used, see 'getPredefinedArrayIndexName(int)'.
* This name might be used as the shader attribute name.
- * @arg comps The array component number
- * @arg dataType The array index GL data type
- * @arg normalized Wheather the data shall be normalized
+ * @param comps The array component number
+ * @param dataType The array index GL data type
+ * @param normalized Wheather the data shall be normalized
*
* @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int)
*/
diff --git a/src/jogl/classes/com/sun/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/sun/opengl/util/GLArrayDataServer.java
index e9a5e2754..dc233ce36 100644
--- a/src/jogl/classes/com/sun/opengl/util/GLArrayDataServer.java
+++ b/src/jogl/classes/com/sun/opengl/util/GLArrayDataServer.java
@@ -21,13 +21,13 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
* EnableVertexAttribArray and VertexAttribPointer calls,
* and a predefined vertex attribute variable name will be choosen.
*
- * @arg index The GL array index
- * @arg name The optional custom name for the GL array index, maybe null.
+ * @param index The GL array index
+ * @param name The optional custom name for the GL array index, maybe null.
* If null, the default name mapping will be used, see 'getPredefinedArrayIndexName(int)'.
* This name might be used as the shader attribute name.
- * @arg comps The array component number
- * @arg dataType The array index GL data type
- * @arg normalized Wheather the data shall be normalized
+ * @param comps The array component number
+ * @param dataType The array index GL data type
+ * @param normalized Wheather the data shall be normalized
*
* @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int)
*/
diff --git a/src/jogl/classes/com/sun/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/sun/opengl/util/glsl/ShaderCode.java
index 6e7512e6a..606d2e1b5 100644
--- a/src/jogl/classes/com/sun/opengl/util/glsl/ShaderCode.java
+++ b/src/jogl/classes/com/sun/opengl/util/glsl/ShaderCode.java
@@ -3,13 +3,18 @@ package com.sun.opengl.util.glsl;
import javax.media.opengl.*;
import com.sun.opengl.util.*;
+import com.sun.opengl.impl.Debug;
import java.util.*;
import java.nio.*;
import java.io.*;
import java.net.*;
+import java.security.*;
public class ShaderCode {
+ public static final boolean DEBUG = Debug.debug("GLSLCode");
+ public static final boolean DEBUG_CODE = Debug.isPropertyDefined("jogl.debug.GLSLCode", true, AccessController.getContext());
+
public static final String SUFFIX_VERTEX_SOURCE = "vp" ;
public static final String SUFFIX_VERTEX_BINARY = "bvp" ;
public static final String SUFFIX_FRAGMENT_SOURCE = "fp" ;
@@ -31,6 +36,11 @@ public class ShaderCode {
shaderType = type;
shader = BufferUtil.newIntBuffer(number);
id = getNextID();
+
+ if(DEBUG_CODE) {
+ System.out.println("Created: "+toString());
+ dumpShaderSource(System.out);
+ }
}
public ShaderCode(int type, int number, int binFormat, Buffer binary) {
@@ -134,61 +144,6 @@ public class ShaderCode {
return res;
}
- public static boolean createAndLoadShader(GL2ES2 gl, IntBuffer shader, int shaderType,
- int binFormat, java.nio.Buffer bin,
- PrintStream verboseOut)
- {
- int err = gl.glGetError(); // flush previous errors ..
- if(err!=GL.GL_NO_ERROR && null!=verboseOut) {
- verboseOut.println("createAndLoadShader: Pre GL Error: 0x"+Integer.toHexString(err));
- }
-
- ShaderUtil.createShader(gl, shaderType, shader);
- err = gl.glGetError();
- if(err!=GL.GL_NO_ERROR) {
- throw new GLException("createAndLoadShader: CreateShader failed, GL Error: 0x"+Integer.toHexString(err));
- }
-
-
- ShaderUtil.shaderBinary(gl, shader, binFormat, bin);
-
- err = gl.glGetError();
- if(err!=GL.GL_NO_ERROR && null!=verboseOut) {
- verboseOut.println("createAndLoadShader: ShaderBinary failed, GL Error: 0x"+Integer.toHexString(err));
- }
- return err == GL.GL_NO_ERROR;
- }
-
- public static boolean createAndCompileShader(GL2ES2 gl, IntBuffer shader, int shaderType,
- java.lang.String[][] sources,
- PrintStream verboseOut)
- {
- int err = gl.glGetError(); // flush previous errors ..
- if(err!=GL.GL_NO_ERROR && null!=verboseOut) {
- verboseOut.println("createAndCompileShader: Pre GL Error: 0x"+Integer.toHexString(err));
- }
-
- ShaderUtil.createShader(gl, shaderType, shader);
- err = gl.glGetError();
- if(err!=GL.GL_NO_ERROR) {
- throw new GLException("createAndCompileShader: CreateShader failed, GL Error: 0x"+Integer.toHexString(err));
- }
-
- ShaderUtil.shaderSource(gl, shader, sources);
- err = gl.glGetError();
- if(err!=GL.GL_NO_ERROR) {
- throw new GLException("createAndCompileShader: ShaderSource failed, GL Error: 0x"+Integer.toHexString(err));
- }
-
- ShaderUtil.compileShader(gl, shader);
- err = gl.glGetError();
- if(err!=GL.GL_NO_ERROR && null!=verboseOut) {
- verboseOut.println("createAndCompileShader: CompileShader failed, GL Error: 0x"+Integer.toHexString(err));
- }
-
- return ShaderUtil.isShaderStatusValid(gl, shader, gl.GL_COMPILE_STATUS, verboseOut) && err == GL.GL_NO_ERROR;
- }
-
/**
* returns the uniq shader id as an integer
* @see #key()
@@ -231,11 +186,11 @@ public class ShaderCode {
// Create & Compile the vertex/fragment shader objects
if(null!=shaderSource) {
- valid=createAndCompileShader(gl, shader, shaderType,
- shaderSource, verboseOut);
+ valid=ShaderUtil.createAndCompileShader(gl, shader, shaderType,
+ shaderSource, verboseOut);
} else if(null!=shaderBinary) {
- valid=createAndLoadShader(gl, shader, shaderType,
- shaderBinaryFormat, shaderBinary, verboseOut);
+ valid=ShaderUtil.createAndLoadShader(gl, shader, shaderType,
+ shaderBinaryFormat, shaderBinary, verboseOut);
} else {
throw new GLException("no code (source or binary)");
}
@@ -282,6 +237,31 @@ public class ShaderCode {
return buf.toString();
}
+ public void dumpShaderSource(PrintStream out) {
+ if(null==shaderSource) {
+ out.println("<no shader source>");
+ return;
+ }
+ int sourceNum = (null!=shaderSource)?shaderSource.length:0;
+ int shaderNum = (null!=shader)?shader.capacity():0;
+ for(int i=0; i<shaderNum; i++) {
+ out.println("");
+ out.println("Shader #"+i+"/"+shaderNum+" name "+shader.get(i));
+ out.println("--------------------------------------------------------------");
+ if(i>=sourceNum) {
+ out.println("<no shader source>");
+ } else {
+ String[] src = shaderSource[i];
+ for(int j=0; j<src.length; j++) {
+ out.println("Segment "+j+"/"+src.length+" :");
+ out.println(src[j]);
+ out.println("");
+ }
+ }
+ out.println("--------------------------------------------------------------");
+ }
+ }
+
public static void readShaderSource(ClassLoader context, String path, URL url, StringBuffer result) {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
diff --git a/src/jogl/classes/com/sun/opengl/util/glsl/ShaderState.java b/src/jogl/classes/com/sun/opengl/util/glsl/ShaderState.java
index bab9ef4f3..8712ac7e2 100644
--- a/src/jogl/classes/com/sun/opengl/util/glsl/ShaderState.java
+++ b/src/jogl/classes/com/sun/opengl/util/glsl/ShaderState.java
@@ -3,14 +3,17 @@ package com.sun.opengl.util.glsl;
import javax.media.opengl.*;
import com.sun.opengl.util.*;
+import com.sun.opengl.impl.Debug;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.nio.*;
import java.io.PrintStream;
+import java.security.*;
public class ShaderState {
+ public static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.GLSLState", true, AccessController.getContext());
public ShaderState() {
}
@@ -77,8 +80,10 @@ public class ShaderState {
int curId = (null!=shaderProgram)?shaderProgram.id():-1;
int newId = (null!=prog)?prog.id():-1;
System.err.println("Info: attachShaderProgram: "+curId+" -> "+newId+"\n\t"+shaderProgram+"\n\t"+prog);
- Throwable tX = new Throwable("Info: attachShaderProgram: Trace");
- tX.printStackTrace();
+ if(verbose) {
+ Throwable tX = new Throwable("Info: attachShaderProgram: Trace");
+ tX.printStackTrace();
+ }
}
if(null!=shaderProgram) {
if(shaderProgram.equals(prog)) {
@@ -313,7 +318,7 @@ public class ShaderState {
* Even if the attribute is not found in the current shader,
* it is stored in this state.
*
- * @arg data the GLArrayData's name must match the attributes one,
+ * @param data the GLArrayData's name must match the attributes one,
* it's index will be set with the attribute's location,
* if found.
*
@@ -544,7 +549,7 @@ public class ShaderState {
* Even if the uniform is not found in the current shader,
* it is stored in this state.
*
- * @arg data the GLUniforms's name must match the uniform one,
+ * @param data the GLUniforms's name must match the uniform one,
* it's index will be set with the uniforms's location,
* if found.
*
@@ -635,7 +640,6 @@ public class ShaderState {
return buf.toString();
}
- protected static final boolean DEBUG = false;
protected boolean verbose = false;
protected ShaderProgram shaderProgram=null;
protected HashMap attribMap2Idx = new HashMap();
diff --git a/src/jogl/classes/com/sun/opengl/util/glsl/ShaderUtil.java b/src/jogl/classes/com/sun/opengl/util/glsl/ShaderUtil.java
index d1bb8b32b..390fb27c7 100644
--- a/src/jogl/classes/com/sun/opengl/util/glsl/ShaderUtil.java
+++ b/src/jogl/classes/com/sun/opengl/util/glsl/ShaderUtil.java
@@ -60,6 +60,14 @@ public class ShaderUtil {
public abstract void attachShader(GL gl, int program, IntBuffer shaders);
public abstract void detachShader(GL gl, int program, IntBuffer shaders);
public abstract void deleteShader(GL gl, IntBuffer shaders);
+
+ public abstract boolean createAndLoadShader(GL gl, IntBuffer shader, int shaderType,
+ int binFormat, java.nio.Buffer bin,
+ PrintStream verboseOut);
+
+ public abstract boolean createAndCompileShader(GL gl, IntBuffer shader, int shaderType,
+ java.lang.String[][] sources,
+ PrintStream verboseOut);
}
static class GL2ES2Impl extends Impl {
@@ -307,6 +315,64 @@ public class ShaderUtil {
}
}
+
+ public boolean createAndLoadShader(GL _gl, IntBuffer shader, int shaderType,
+ int binFormat, java.nio.Buffer bin,
+ PrintStream verboseOut)
+ {
+ GL2ES2 gl = _gl.getGL2ES2();
+ int err = gl.glGetError(); // flush previous errors ..
+ if(err!=GL.GL_NO_ERROR && null!=verboseOut) {
+ verboseOut.println("createAndLoadShader: Pre GL Error: 0x"+Integer.toHexString(err));
+ }
+
+ createShader(gl, shaderType, shader);
+ err = gl.glGetError();
+ if(err!=GL.GL_NO_ERROR) {
+ throw new GLException("createAndLoadShader: CreateShader failed, GL Error: 0x"+Integer.toHexString(err));
+ }
+
+
+ shaderBinary(gl, shader, binFormat, bin);
+
+ err = gl.glGetError();
+ if(err!=GL.GL_NO_ERROR && null!=verboseOut) {
+ verboseOut.println("createAndLoadShader: ShaderBinary failed, GL Error: 0x"+Integer.toHexString(err));
+ }
+ return err == GL.GL_NO_ERROR;
+ }
+
+ public boolean createAndCompileShader(GL _gl, IntBuffer shader, int shaderType,
+ java.lang.String[][] sources,
+ PrintStream verboseOut)
+ {
+ GL2ES2 gl = _gl.getGL2ES2();
+ int err = gl.glGetError(); // flush previous errors ..
+ if(err!=GL.GL_NO_ERROR && null!=verboseOut) {
+ verboseOut.println("createAndCompileShader: Pre GL Error: 0x"+Integer.toHexString(err));
+ }
+
+ createShader(gl, shaderType, shader);
+ err = gl.glGetError();
+ if(err!=GL.GL_NO_ERROR) {
+ throw new GLException("createAndCompileShader: CreateShader failed, GL Error: 0x"+Integer.toHexString(err));
+ }
+
+ shaderSource(gl, shader, sources);
+ err = gl.glGetError();
+ if(err!=GL.GL_NO_ERROR) {
+ throw new GLException("createAndCompileShader: ShaderSource failed, GL Error: 0x"+Integer.toHexString(err));
+ }
+
+ compileShader(gl, shader);
+ err = gl.glGetError();
+ if(err!=GL.GL_NO_ERROR && null!=verboseOut) {
+ verboseOut.println("createAndCompileShader: CompileShader failed, GL Error: 0x"+Integer.toHexString(err));
+ }
+
+ return isShaderStatusValid(gl, shader, gl.GL_COMPILE_STATUS, verboseOut) && err == GL.GL_NO_ERROR;
+ }
+
}
public static String getShaderInfoLog(GL gl, int shaderObj) {
@@ -385,6 +451,18 @@ public class ShaderUtil {
getImpl(gl).deleteShader(gl, shaders);
}
+ public static boolean createAndLoadShader(GL gl, IntBuffer shader, int shaderType,
+ int binFormat, java.nio.Buffer bin,
+ PrintStream verboseOut) {
+ return getImpl(gl).createAndLoadShader(gl, shader, shaderType, binFormat, bin, verboseOut);
+ }
+
+ public static boolean createAndCompileShader(GL gl, IntBuffer shader, int shaderType,
+ java.lang.String[][] sources,
+ PrintStream verboseOut) {
+ return getImpl(gl).createAndCompileShader(gl, shader, shaderType, sources, verboseOut);
+ }
+
private static Impl getImpl(GL _gl) {
GL2ES2 gl = _gl.getGL2ES2();
GLContext context = gl.getContext();
diff --git a/src/jogl/classes/com/sun/opengl/util/glsl/fixedfunc/FixedFuncUtil.java b/src/jogl/classes/com/sun/opengl/util/glsl/fixedfunc/FixedFuncUtil.java
index 9c8a65173..4149aec69 100644
--- a/src/jogl/classes/com/sun/opengl/util/glsl/fixedfunc/FixedFuncUtil.java
+++ b/src/jogl/classes/com/sun/opengl/util/glsl/fixedfunc/FixedFuncUtil.java
@@ -14,12 +14,12 @@ import com.sun.opengl.util.glsl.fixedfunc.impl.*;
*/
public class FixedFuncUtil {
/**
- * @return If gl is a GL2ES1, return the type cast object,
+ * @return If gl is a GL2ES1 and force is false, return the type cast object,
* otherwise create a fixed function emulation pipeline with the GL2ES2 impl.
* @throws GLException if the GL object is neither GL2ES1 nor GL2ES2
*/
- public static final GL2ES1 getFixedFuncImpl(GL gl) {
- if(gl.isGL2ES1()) {
+ public static final GL2ES1 getFixedFuncImpl(GL gl, boolean force) {
+ if(!force && gl.isGL2ES1()) {
return gl.getGL2ES1();
} else if(gl.isGL2ES2()) {
GL2ES2 es2 = gl.getGL2ES2();
@@ -32,6 +32,15 @@ public class FixedFuncUtil {
}
/**
+ * @return If gl is a GL2ES1, return the type cast object,
+ * otherwise create a fixed function emulation pipeline with the GL2ES2 impl.
+ * @throws GLException if the GL object is neither GL2ES1 nor GL2ES2
+ */
+ public static final GL2ES1 getFixedFuncImpl(GL gl) {
+ return getFixedFuncImpl(gl, false);
+ }
+
+ /**
* Mapping fixed function (client) array indices to
* GLSL array attribute names.
*
diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
index 43347c416..a94c14f33 100644
--- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
@@ -208,6 +208,7 @@ public interface GLAutoDrawable extends GLDrawable {
This should only be called from within the GLEventListener's
callback methods, and usually only from within the init()
method, in order to install a composable pipeline. See the JOGL
- demos for examples. */
- public void setGL(GL gl);
+ demos for examples.
+ @return the set GL pipeline or null if not successful */
+ public GL setGL(GL gl);
}
diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java
index efd2eedd1..92498077b 100644
--- a/src/jogl/classes/javax/media/opengl/GLBase.java
+++ b/src/jogl/classes/javax/media/opengl/GLBase.java
@@ -7,9 +7,53 @@ package javax.media.opengl;
import java.nio.*;
/**
- * The base interface from which all GL profiles derive, providing
- * checked conversion down to concrete profiles, and access to the
- * OpenGL context associated with the GL.
+ * <P>The base interface from which all GL profiles derive, providing
+ * checked conversion down to concrete profiles, access to the
+ * OpenGL context associated with the GL and extension/function
+ * availability queries as described below.</P>
+ *
+ * <P> While the APIs for vendor extensions are unconditionally
+ * exposed, the underlying functions may not be present. The method
+ * {@link #isFunctionAvailable} should be used to query the
+ * availability of any non-core function before it is used for the
+ * first time; for example,
+ * <code>gl.isFunctionAvailable("glProgramStringARB")</code>. On
+ * certain platforms (Windows in particular), the most "core"
+ * functionality is only OpenGL 1.1, so in theory any routines first
+ * exposed in OpenGL 1.2, 1.3, and 1.4, 1.5, or 2.0 as well as vendor
+ * extensions should all be queried. Calling an unavailable function
+ * will cause a {@link GLException} to be raised. </P>
+ *
+ * {@link #isExtensionAvailable} may also be used to determine whether
+ * a specific extension is available before calling the routines or
+ * using the functionality it exposes: for example,
+ * <code>gl.isExtensionAvailable("GL_ARB_vertex_program");</code>.
+ * However, in this case it is up to the end user to know which
+ * routines or functionality are associated with which OpenGL
+ * extensions. It may also be used to test for the availability of a
+ * particular version of OpenGL: for example,
+ * <code>gl.isExtensionAvailable("GL_VERSION_1_5");</code>.
+ *
+ * <P> Exceptions to the window system extension naming rules:
+ *
+ * <UL>
+ *
+ * <LI> The memory allocators for the NVidia vertex_array_range (VAR)
+ * extension, in particular <code>wglAllocateMemoryNV</code> /
+ * <code>glXAllocateMemoryNV</code> and associated routines. {@link
+ * #glAllocateMemoryNV} has been provided for window system-independent
+ * access to VAR. {@link #isFunctionAvailable} will translate an argument
+ * of "glAllocateMemoryNV" or "glFreeMemoryNV" into the appropriate
+ * window system-specific name. </P>
+ *
+ * <LI> WGL_ARB_pbuffer, WGL_ARB_pixel_format, and other
+ * platform-specific pbuffer functionality; the availability of
+ * pbuffers can be queried on Windows, X11 and Mac OS X platforms by
+ * querying {@link #isExtensionAvailable} with an argument of
+ * "GL_ARB_pbuffer" or "GL_ARB_pixel_format".
+ *
+ * </UL> <P>
+ *
*/
public interface GLBase {
@@ -63,6 +107,12 @@ public interface GLBase {
*/
public boolean isGL2ES2();
+ /**
+ * Indicates whether this GL object conforms to the GL2GL3 compatible profile.
+ * @return whether this GL object conforms to the GL2GL3 profile
+ */
+ public boolean isGL2GL3();
+
/** Indicates whether this GL object supports GLSL. */
public boolean hasGLSL();
@@ -116,14 +166,115 @@ public interface GLBase {
public GL2ES2 getGL2ES2() throws GLException;
/**
- * Returns the GLContext with which this GL object is associated.
- * @return the GLContext with which this GL object is associated
+ * Casts this object to the GL2GL3 interface.
+ * @return this object cast to the GL2GL3 interface
+ * @throws GLException if this GLObject is not a GL2GL3 implementation
*/
- public GLContext getContext();
+ public GL2GL3 getGL2GL3() throws GLException;
/**
* Returns the GLProfile with which this GL object is associated.
* @return the GLProfile with which this GL object is associated
*/
public GLProfile getGLProfile();
+
+ /**
+ * Returns the GLContext with which this GL object is associated.
+ * @return the GLContext with which this GL object is associated
+ */
+ public GLContext getContext();
+
+ /**
+ * Returns true if the specified OpenGL core- or extension-function can be
+ * used successfully through this GL instance given the current host (OpenGL
+ * <i>client</i>) and display (OpenGL <i>server</i>) configuration.<P>
+ * By "successfully" we mean that the function is both <i>callable</i>
+ * on the machine running the program and <i>available</i> on the current
+ * display.<P>
+ *
+ * In order to call a function successfully, the function must be both
+ * <i>callable</i> on the machine running the program and <i>available</i> on
+ * the display device that is rendering the output (note: on non-networked,
+ * single-display machines these two conditions are identical; on networked and/or
+ * multi-display machines this becomes more complicated). These conditions are
+ * met if the function is either part of the core OpenGL version supported by
+ * both the host and display, or it is an OpenGL extension function that both
+ * the host and display support. <P>
+ *
+ * A GL function is <i>callable</i> if it is successfully linked at runtime,
+ * hence the GLContext must be made current at least once.
+ *
+ * @param glFunctionName the name of the OpenGL function (e.g., use
+ * "glBindRenderbufferEXT" or "glBindRenderbuffer" to check if {@link
+ * #glBindRenderbuffer(int,int)} is available).
+ */
+ public boolean isFunctionAvailable(String glFunctionName);
+
+ /**
+ * Returns true if the specified OpenGL extension can be
+ * used successfully through this GL instance given the current host (OpenGL
+ * <i>client</i>) and display (OpenGL <i>server</i>) configuration.<P>
+ *
+ * @param glExtensionName the name of the OpenGL extension (e.g.,
+ * "GL_ARB_vertex_program").
+ */
+ public boolean isExtensionAvailable(String glExtensionName);
+
+ /** Provides a platform-independent way to specify the minimum swap
+ interval for buffer swaps. An argument of 0 disables
+ sync-to-vertical-refresh completely, while an argument of 1
+ causes the application to wait until the next vertical refresh
+ until swapping buffers. The default, which is platform-specific,
+ is usually either 0 or 1. This function is not guaranteed to
+ have an effect, and in particular only affects heavyweight
+ onscreen components.
+
+ @see #getSwapInterval
+ @throws GLException if this context is not the current
+ */
+ public void setSwapInterval(int interval);
+
+ /** Provides a platform-independent way to get the swap
+ interval set by {@link #setSwapInterval}. <br>
+
+ If the interval is not set by {@link #setSwapInterval} yet,
+ -1 is returned, indicating that the platforms default
+ is being used.
+
+ @see #setSwapInterval
+ */
+ public int getSwapInterval();
+
+ /**
+ * Returns an object through which platform-specific OpenGL extensions
+ * (EGL, GLX, WGL, etc.) may be accessed. The data type of the returned
+ * object and its associated capabilities are undefined. Most
+ * applications will never need to call this method. It is highly
+ * recommended that any applications which do call this method perform
+ * all accesses on the returned object reflectively to guard
+ * themselves against changes to the implementation.
+ */
+ public Object getPlatformGLExtensions();
+
+ /**
+ * Returns an object providing access to the specified OpenGL
+ * extension. This is intended to provide a mechanism for vendors who
+ * wish to provide access to new OpenGL extensions without changing
+ * the public API of the core package. For example, a user may request
+ * access to extension "GL_VENDOR_foo" and receive back an object
+ * which implements a vendor-specified interface which can call the
+ * OpenGL extension functions corresponding to that extension. It is
+ * up to the vendor to specify both the extension name and Java API
+ * for accessing it, including which class or interface contains the
+ * functions.
+ *
+ * <P>
+ *
+ * Note: it is the intent to add new extensions as quickly as possible
+ * to the core GL API. Therefore it is unlikely that most vendors will
+ * use this extension mechanism, but it is being provided for
+ * completeness.
+ */
+ public Object getExtension(String extensionName);
}
+
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index a2bff729a..8ff52b6e9 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -205,8 +205,10 @@ public abstract class GLContext {
/**
* Sets the GL pipeline object for this GLContext.
+ *
+ * @return the set GL pipeline or null if not successful
*/
- public abstract void setGL(GL gl);
+ public abstract GL setGL(GL gl);
/**
* Returns the attached user object for the given name to this GLContext.
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index cee721fa6..1a18a60f8 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -106,16 +106,14 @@ public abstract class GLDrawableFactory {
}
eglFactory = tmp;
- nativeOSType = NativeWindowFactory.getNativeWindowType(false);
+ nativeOSType = NativeWindowFactory.getNativeWindowType(true);
String factoryClassName = null;
tmp = null;
try {
factoryClassName = Debug.getProperty("jogl.gldrawablefactory.class.name", true, AccessController.getContext());
if (null == factoryClassName) {
- if ( nativeOSType.equals(NativeWindowFactory.TYPE_EGL) ) {
- // use egl*Factory ..
- } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_X11) ) {
+ if ( nativeOSType.equals(NativeWindowFactory.TYPE_X11) ) {
factoryClassName = "com.sun.opengl.impl.x11.glx.X11GLXDrawableFactory";
} else if ( nativeOSType.equals(NativeWindowFactory.TYPE_WINDOWS) ) {
factoryClassName = "com.sun.opengl.impl.windows.wgl.WindowsWGLDrawableFactory";
@@ -126,10 +124,16 @@ public abstract class GLDrawableFactory {
factoryClassName = macosxFactoryClassNameCGL;
}
} else {
- throw new GLException("Unsupported NativeWindow type: "+nativeOSType);
+ // may use egl*Factory ..
+ if (GLProfile.DEBUG) {
+ System.err.println("GLDrawableFactory.static - No Native OS Factory for: "+nativeOSType);
+ }
}
}
if (null != factoryClassName) {
+ if (GLProfile.DEBUG) {
+ System.err.println("GLDrawableFactory.static - Native OS Factory for: "+nativeOSType+": "+factoryClassName);
+ }
tmp = (GLDrawableFactory) NWReflection.createInstance(factoryClassName);
}
} catch (Throwable t) {
@@ -144,7 +148,7 @@ public abstract class GLDrawableFactory {
/**
* Returns the sole GLDrawableFactory instance.
*
- * @arg glProfile GLProfile to determine the factory type, ie EGLDrawableFactory,
+ * @param glProfile GLProfile to determine the factory type, ie EGLDrawableFactory,
* or one of the native GLDrawableFactory's, ie X11/GLX, Windows/WGL or MacOSX/CGL.
*/
public static GLDrawableFactory getFactory(GLProfile glProfile) throws GLException {
diff --git a/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java
new file mode 100644
index 000000000..63b50cb3c
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ */
+
+package javax.media.opengl;
+
+import java.lang.reflect.*;
+import java.util.StringTokenizer;
+
+import com.sun.opengl.impl.*;
+
+/**
+ * Factory for pipelining GL instances
+ */
+public class GLPipelineFactory {
+ public static final boolean DEBUG = Debug.debug("GLPipelineFactory");
+
+ /**
+ * Creates a pipelined GL instance using the given downstream <code>downstream</code>
+ * and optional arguments <code>additionalArgs</code> for the constructor.<br>
+ *
+ * The upstream GL instance is determined as follows:
+ * <ul>
+ * <li> Use <code>pipelineClazzBaseName</code> as the class name's full basename, incl. package name</li>
+ * <li> For the <code>downstream</code> class and it's superclasses, do:</li>
+ * <ul>
+ * <li> For all <code>downstream</code> class and superclass interfaces, do:</li>
+ * <ul>
+ * <li> If <code>reqInterface</code> is not null and the interface is unequal, continue loop.</li>
+ * <li> If <code>downstream</code> is not instance of interface, continue loop.</li>
+ * <li> If upstream class is available use it, end loop.</li>
+ * </ul>
+ * </ul>
+ * </ul><br>
+ *
+ * @param pipelineClazzBaseName the basename of the pipline class name
+ * @param reqInterface optional requested interface to be used, may be null, in which case the first matching one is used
+ * @param downstream is always the 1st argument for the upstream constructor
+ * @param additionalArgs additional arguments for the upstream constructor
+ */
+ public static final GL create(String pipelineClazzBaseName, Class reqInterface, GL downstream, Object[] additionalArgs) {
+ Class downstreamClazz = downstream.getClass();
+ Class upstreamClazz = null;
+ Class interfaceClazz = null;
+
+ if(DEBUG) {
+ System.out.println("GLPipelineFactory: Start "+downstreamClazz.getName()+", req. Interface: "+reqInterface+" -> "+pipelineClazzBaseName);
+ }
+
+ // For all classes: child -> parent
+ do {
+ // For all interfaces: right -> left == child -> parent
+ // It is important that this matches with the gluegen cfg file's 'Implements' clause !
+ Class[] clazzes = downstreamClazz.getInterfaces();
+ for(int i=clazzes.length-1; null==upstreamClazz && i>=0; i--) {
+ if(DEBUG) {
+ System.out.println("GLPipelineFactory: Try "+downstreamClazz.getName()+" Interface["+i+"]: "+clazzes[i].getName());
+ }
+ if( reqInterface != null && !reqInterface.getName().equals(clazzes[i].getName()) ) {
+ if(DEBUG) {
+ System.out.println("GLPipelineFactory: requested Interface "+reqInterface+" is _not_ "+ clazzes[i].getName());
+ }
+ continue; // not the requested one ..
+ }
+ if( ! clazzes[i].isInstance(downstream) ) {
+ if(DEBUG) {
+ System.out.println("GLPipelineFactory: "+downstream.getClass().getName() + " is _not_ instance of "+ clazzes[i].getName());
+ }
+ continue; // not a compatible one
+ } else {
+ if(DEBUG) {
+ System.out.println("GLPipelineFactory: "+downstream.getClass().getName() + " _is_ instance of "+ clazzes[i].getName());
+ }
+ }
+ upstreamClazz = getUpstreamClazz(clazzes[i], pipelineClazzBaseName);
+ if( null != upstreamClazz ) {
+ interfaceClazz = clazzes[i];
+ }
+ }
+
+ if(null==upstreamClazz) {
+ downstreamClazz = downstreamClazz.getSuperclass();
+ }
+ } while (null!=downstreamClazz && null==upstreamClazz);
+
+
+ if(null==upstreamClazz) {
+ throw new GLException("No pipeline ("+pipelineClazzBaseName+"*) available for :"+downstream.getClass().getName());
+ }
+
+ if(DEBUG) {
+ System.out.println("GLPipelineFactory: Got : "+ upstreamClazz.getName()+", base interface: "+interfaceClazz.getName());
+ }
+
+ Class[] cstrArgTypes = new Class[ 1 + ( ( null==additionalArgs ) ? 0 : additionalArgs.length ) ] ;
+ {
+ int i = 0;
+ cstrArgTypes[i++] = interfaceClazz;
+ for(int j=0; null!=additionalArgs && j<additionalArgs.length; j++) {
+ cstrArgTypes[i++] = additionalArgs[j].getClass();
+ }
+ }
+ Constructor cstr = null;
+ try {
+ cstr = upstreamClazz.getDeclaredConstructor( cstrArgTypes );
+ } catch(NoSuchMethodException nsme) {
+ throw new GLException("Couldn't find pipeline constructor: " + upstreamClazz.getName() +
+ " ( "+getArgsClassNameList(downstreamClazz, additionalArgs) +" )");
+ }
+ Object instance = null;
+ try {
+ Object[] cstrArgs = new Object[ 1 + ( ( null==additionalArgs ) ? 0 : additionalArgs.length ) ] ;
+ {
+ int i = 0;
+ cstrArgs[i++] = downstream;
+ for(int j=0; null!=additionalArgs && j<additionalArgs.length; j++) {
+ cstrArgs[i++] = additionalArgs[j];
+ }
+ }
+ instance = cstr.newInstance( cstrArgs ) ;
+ } catch (Throwable t) { t.printStackTrace(); }
+ if(null==instance) {
+ throw new GLException("Couldn't create instance of pipeline: "+upstreamClazz.getName()+
+ " ( "+getArgsClassNameList(downstreamClazz, additionalArgs) +" )");
+ }
+ if( ! (instance instanceof GL) ) {
+ throw new GLException(upstreamClazz.getName()+" not an instance of GL");
+ }
+ return (GL) instance;
+ }
+
+ private static final String getArgsClassNameList(Class arg0, Object[] args) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(arg0.getName());
+ if(args!=null) {
+ for(int j=0; j<args.length; j++) {
+ sb.append(", ");
+ sb.append(args[j].getClass().getName());
+ }
+ }
+ return sb.toString();
+ }
+
+ private static final Class getUpstreamClazz(Class downstreamClazz, String pipelineClazzBaseName) {
+ String downstreamClazzName = downstreamClazz.getName();
+
+ StringTokenizer st = new StringTokenizer(downstreamClazzName, ".");
+ String downstreamClazzBaseName = downstreamClazzName;
+ while(st.hasMoreTokens()) {
+ downstreamClazzBaseName = st.nextToken();
+ }
+ String upstreamClazzName = pipelineClazzBaseName+downstreamClazzBaseName;
+
+ Class upstreamClazz = null;
+ try {
+ upstreamClazz = Class.forName(upstreamClazzName, true, GLPipelineFactory.class.getClassLoader());
+ } catch (Throwable e) { e.printStackTrace(); }
+
+ return upstreamClazz;
+ }
+}
+
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index ead5f6396..756c80009 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -78,10 +78,13 @@ public class GLProfile implements Cloneable {
/** The intersection of the desktop GL3, GL2 and embedded ES2 profile */
public static final String GL2ES2 = "GL2ES2";
+ /** The intersection of the desktop GL3 and GL2 profile */
+ public static final String GL2GL3 = "GL2GL3";
+
/**
- * All GL Profiles in the order of default detection: GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL3
+ * All GL Profiles in the order of default detection: GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL2GL3, GL3
*/
- public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL3 };
+ public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL2GL3, GL3 };
/**
* All GL2ES2 Profiles in the order of default detection: GL2ES2, GL2, GLES2, GL3
@@ -273,6 +276,11 @@ public class GLProfile implements Cloneable {
return GL2ES2.equals(profile) || isGL2() || isGL3() || isGLES2() ;
}
+ /** Indicates whether this profile is capable os GL2GL3. */
+ public final boolean isGL2GL3() {
+ return GL2GL3.equals(profile) || isGL2() || isGL3() ;
+ }
+
/** Indicates whether this profile uses the native OpenGL ES1 implementations. */
public final boolean usesNativeGLES1() {
return GLES1.equals(profileImpl) || GL2ES1.equals(profileImpl) ;
@@ -709,6 +717,8 @@ public class GLProfile implements Cloneable {
System.err.println("GLProfile.static hasGL3Impl "+hasGL3Impl);
System.err.println("GLProfile.static hasGL2Impl "+hasGL2Impl);
System.err.println("GLProfile.static hasGL2ES12Impl "+hasGL2ES12Impl);
+ System.err.println("GLProfile.static hasEGLDynLookup "+hasEGLDynLookup);
+ System.err.println("GLProfile.static hasEGLDrawableFactory "+hasEGLDrawableFactory);
System.err.println("GLProfile.static hasGLES2Impl "+hasGLES2Impl);
System.err.println("GLProfile.static hasGLES1Impl "+hasGLES1Impl);
}
@@ -758,10 +768,10 @@ public class GLProfile implements Cloneable {
*/
private static String computeProfileImpl(String profile) {
if (GL2ES1.equals(profile)) {
- if(hasGL2Impl) {
- return GL2;
- } else if(hasGL2ES12Impl) {
+ if(hasGL2ES12Impl) {
return GL2ES12;
+ } else if(hasGL2Impl) {
+ return GL2;
} else if(hasGLES1Impl) {
return GLES1;
}
@@ -779,6 +789,8 @@ public class GLProfile implements Cloneable {
return GL3;
} else if(GL2.equals(profile) && hasGL2Impl) {
return GL2;
+ } else if(GL2GL3.equals(profile) && hasGL2Impl) {
+ return GL2;
} else if(GLES2.equals(profile) && hasGLES2Impl) {
return GLES2;
} else if(GLES1.equals(profile) && hasGLES1Impl) {
diff --git a/src/jogl/classes/javax/media/opengl/GLUniformData.java b/src/jogl/classes/javax/media/opengl/GLUniformData.java
index 8b5fb1a03..f628ce35a 100644
--- a/src/jogl/classes/javax/media/opengl/GLUniformData.java
+++ b/src/jogl/classes/javax/media/opengl/GLUniformData.java
@@ -10,7 +10,7 @@ public class GLUniformData {
*
* Number of objects is 1
*
- * @arg components number of elements of one object, ie 4 for GL_FLOAT_VEC4,
+ * @param components number of elements of one object, ie 4 for GL_FLOAT_VEC4,
*/
public GLUniformData(String name, int val) {
init(name, 1, new Integer(val));
@@ -21,7 +21,7 @@ public class GLUniformData {
*
* Number of objects is 1
*
- * @arg components number of elements of one object, ie 4 for GL_FLOAT_VEC4,
+ * @param components number of elements of one object, ie 4 for GL_FLOAT_VEC4,
*/
public GLUniformData(String name, float val) {
init(name, 1, new Float(val));
@@ -32,7 +32,7 @@ public class GLUniformData {
*
* Number of objects is calculated by data.limit()/components
*
- * @arg components number of elements of one object, ie 4 for GL_FLOAT_VEC4,
+ * @param components number of elements of one object, ie 4 for GL_FLOAT_VEC4,
*/
public GLUniformData(String name, int components, IntBuffer data) {
init(name, components, data);
@@ -43,7 +43,7 @@ public class GLUniformData {
*
* Number of objects is calculated by data.limit()/components
*
- * @arg components number of elements of one object, ie 4 for GL_FLOAT_VEC4,
+ * @param components number of elements of one object, ie 4 for GL_FLOAT_VEC4,
*/
public GLUniformData(String name, int components, FloatBuffer data) {
init(name, components, data);
@@ -54,8 +54,8 @@ public class GLUniformData {
*
* Number of objects is calculated by data.limit()/(rows*columns)
*
- * @arg rows the matrix rows
- * @arg column the matrix column
+ * @param rows the matrix rows
+ * @param column the matrix column
*/
public GLUniformData(String name, int rows, int columns, FloatBuffer data) {
init(name, rows, columns, data);
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 4282e9985..038d6d280 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -486,11 +486,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
return (context == null) ? null : context.getGL();
}
- public void setGL(GL gl) {
+ public GL setGL(GL gl) {
GLContext context = getContext();
if (context != null) {
context.setGL(gl);
+ return gl;
}
+ return null;
}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index dd2a487e7..fe55b2dbd 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -404,11 +404,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return (context == null) ? null : context.getGL();
}
- public void setGL(GL gl) {
+ public GL setGL(GL gl) {
GLContext context = getContext();
if (context != null) {
context.setGL(gl);
+ return gl;
}
+ return null;
}
public void setAutoSwapBufferMode(boolean onOrOff) {
@@ -1322,16 +1324,16 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
" with width " + width[0] + ", height " + height[0]);
}
- gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER, frameBufferDepthBuffer[0]);
+ gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, frameBufferDepthBuffer[0]);
// FIXME: may need a loop here like in Java2D
- gl.glRenderbufferStorage(GL2.GL_RENDERBUFFER, GL2.GL_DEPTH_COMPONENT24, width[0], height[0]);
+ gl.glRenderbufferStorage(GL.GL_RENDERBUFFER, GL2GL3.GL_DEPTH_COMPONENT24, width[0], height[0]);
gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER, 0);
createNewDepthBuffer = false;
}
gl.glBindTexture(fboTextureTarget, 0);
- gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, frameBuffer[0]);
+ gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, frameBuffer[0]);
if (fbObjectWorkarounds) {
// Hook up the color and depth buffer attachment points for this framebuffer
@@ -1435,29 +1437,29 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
j2dContext.makeCurrent();
GL gl = j2dContext.getGL();
- if ((getGLInteger(gl, GL2.GL_RED_BITS) < offscreenCaps.getRedBits()) ||
- (getGLInteger(gl, GL2.GL_GREEN_BITS) < offscreenCaps.getGreenBits()) ||
- (getGLInteger(gl, GL2.GL_BLUE_BITS) < offscreenCaps.getBlueBits()) ||
- // (getGLInteger(gl, GL2.GL_ALPHA_BITS) < offscreenCaps.getAlphaBits()) ||
+ if ((getGLInteger(gl, GL.GL_RED_BITS) < offscreenCaps.getRedBits()) ||
+ (getGLInteger(gl, GL.GL_GREEN_BITS) < offscreenCaps.getGreenBits()) ||
+ (getGLInteger(gl, GL.GL_BLUE_BITS) < offscreenCaps.getBlueBits()) ||
+ // (getGLInteger(gl, GL.GL_ALPHA_BITS) < offscreenCaps.getAlphaBits()) ||
(getGLInteger(gl, GL2.GL_ACCUM_RED_BITS) < offscreenCaps.getAccumRedBits()) ||
(getGLInteger(gl, GL2.GL_ACCUM_GREEN_BITS) < offscreenCaps.getAccumGreenBits()) ||
(getGLInteger(gl, GL2.GL_ACCUM_BLUE_BITS) < offscreenCaps.getAccumBlueBits()) ||
(getGLInteger(gl, GL2.GL_ACCUM_ALPHA_BITS) < offscreenCaps.getAccumAlphaBits()) ||
// (getGLInteger(gl, GL2.GL_DEPTH_BITS) < offscreenCaps.getDepthBits()) ||
- (getGLInteger(gl, GL2.GL_STENCIL_BITS) < offscreenCaps.getStencilBits())) {
+ (getGLInteger(gl, GL.GL_STENCIL_BITS) < offscreenCaps.getStencilBits())) {
if (DEBUG) {
System.err.println("GLJPanel: Falling back to pbuffer-based support because Java2D context insufficient");
System.err.println(" Available Required");
- System.err.println("GL_RED_BITS " + getGLInteger(gl, GL2.GL_RED_BITS) + " " + offscreenCaps.getRedBits());
- System.err.println("GL_GREEN_BITS " + getGLInteger(gl, GL2.GL_GREEN_BITS) + " " + offscreenCaps.getGreenBits());
- System.err.println("GL_BLUE_BITS " + getGLInteger(gl, GL2.GL_BLUE_BITS) + " " + offscreenCaps.getBlueBits());
- System.err.println("GL_ALPHA_BITS " + getGLInteger(gl, GL2.GL_ALPHA_BITS) + " " + offscreenCaps.getAlphaBits());
+ System.err.println("GL_RED_BITS " + getGLInteger(gl, GL.GL_RED_BITS) + " " + offscreenCaps.getRedBits());
+ System.err.println("GL_GREEN_BITS " + getGLInteger(gl, GL.GL_GREEN_BITS) + " " + offscreenCaps.getGreenBits());
+ System.err.println("GL_BLUE_BITS " + getGLInteger(gl, GL.GL_BLUE_BITS) + " " + offscreenCaps.getBlueBits());
+ System.err.println("GL_ALPHA_BITS " + getGLInteger(gl, GL.GL_ALPHA_BITS) + " " + offscreenCaps.getAlphaBits());
System.err.println("GL_ACCUM_RED_BITS " + getGLInteger(gl, GL2.GL_ACCUM_RED_BITS) + " " + offscreenCaps.getAccumRedBits());
System.err.println("GL_ACCUM_GREEN_BITS " + getGLInteger(gl, GL2.GL_ACCUM_GREEN_BITS) + " " + offscreenCaps.getAccumGreenBits());
System.err.println("GL_ACCUM_BLUE_BITS " + getGLInteger(gl, GL2.GL_ACCUM_BLUE_BITS) + " " + offscreenCaps.getAccumBlueBits());
System.err.println("GL_ACCUM_ALPHA_BITS " + getGLInteger(gl, GL2.GL_ACCUM_ALPHA_BITS) + " " + offscreenCaps.getAccumAlphaBits());
- System.err.println("GL_DEPTH_BITS " + getGLInteger(gl, GL2.GL_DEPTH_BITS) + " " + offscreenCaps.getDepthBits());
- System.err.println("GL_STENCIL_BITS " + getGLInteger(gl, GL2.GL_STENCIL_BITS) + " " + offscreenCaps.getStencilBits());
+ System.err.println("GL_DEPTH_BITS " + getGLInteger(gl, GL.GL_DEPTH_BITS) + " " + offscreenCaps.getDepthBits());
+ System.err.println("GL_STENCIL_BITS " + getGLInteger(gl, GL.GL_STENCIL_BITS) + " " + offscreenCaps.getStencilBits());
}
isInitialized = false;
backend = null;
@@ -1587,7 +1589,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
if (!checkedGLVendor) {
checkedGLVendor = true;
- String vendor = gl.glGetString(GL2.GL_VENDOR);
+ String vendor = gl.glGetString(GL.GL_VENDOR);
if ((vendor != null) &&
vendor.startsWith("ATI")) {