aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-06-05 03:48:58 +0000
committerSven Gothel <[email protected]>2009-06-05 03:48:58 +0000
commitde20e7830781385eb98b90e2bd223509bc699761 (patch)
tree34e05e783d7b48b77700b1d70dd131d6d14b8afc /src/jogl/classes
parent886dc3ffa4f55d1f37cf22cb4167aedf3bf8f69b (diff)
Fix/Clean EGL path; Adding Windows AWT path; Windows works with MinGW (GL2)
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1925 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java1
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java1
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/NativeLibLoader.java12
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java4
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java21
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java83
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java19
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java31
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java19
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java6
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java112
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java2
-rw-r--r--src/jogl/classes/javax/media/opengl/GLCapabilities.java6
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java7
19 files changed, 269 insertions, 65 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
index fac5401ee..c744aaf06 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
@@ -341,7 +341,7 @@ public abstract class GLContextImpl extends GLContext {
*/
protected void updateGLProcAddressTable() {
if(null==this.gl) {
- throw new GLException("setGLFunctionAvailability no called yet");
+ throw new GLException("setGLFunctionAvailability not called yet");
}
extensionAvailability.flush();
if (DEBUG) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
index 2b9178d06..9fecbdaaf 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
@@ -52,6 +52,7 @@ import java.lang.reflect.*;
these GLDrawables is not supplied directly to end users, though
they may be instantiated by the GLJPanel implementation. */
public abstract class GLDrawableFactoryImpl extends GLDrawableFactory implements DynamicLookupHelper {
+ protected static final boolean DEBUG = Debug.debug("GLDrawableFactory");
/** Creates a (typically software-accelerated) offscreen GLDrawable
used to implement the fallback rendering path of the
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
index 4cff8f8f5..01be01dbd 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
@@ -43,6 +43,7 @@ import javax.media.nativewindow.*;
import javax.media.opengl.*;
public abstract class GLDrawableImpl implements GLDrawable {
+ protected static final boolean DEBUG = Debug.debug("GLDrawable");
protected GLDrawableImpl(GLDrawableFactory factory,
NativeWindow comp,
diff --git a/src/jogl/classes/com/sun/opengl/impl/NativeLibLoader.java b/src/jogl/classes/com/sun/opengl/impl/NativeLibLoader.java
index ee4d160fc..f4425c9df 100644
--- a/src/jogl/classes/com/sun/opengl/impl/NativeLibLoader.java
+++ b/src/jogl/classes/com/sun/opengl/impl/NativeLibLoader.java
@@ -54,7 +54,7 @@ public class NativeLibLoader extends NativeLibLoaderBase {
public static void loadNEWT() {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
- loadLibrary("newt", nativewindowX11Preload, true);
+ loadLibrary("newt", nativeOSPreload, true);
return null;
}
});
@@ -63,7 +63,7 @@ public class NativeLibLoader extends NativeLibLoaderBase {
public static void loadGLDesktop() {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
- loadLibrary("jogl_gl2", nativewindowX11Preload, true);
+ loadLibrary("jogl_gl2", nativeOSPreload, true);
return null;
}
});
@@ -72,7 +72,7 @@ public class NativeLibLoader extends NativeLibLoaderBase {
public static void loadGLDesktopES12() {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
- loadLibrary("jogl_gl2es12", nativewindowX11Preload, true);
+ loadLibrary("jogl_gl2es12", nativeOSPreload, true);
return null;
}
});
@@ -81,7 +81,7 @@ public class NativeLibLoader extends NativeLibLoaderBase {
public static void loadES2() {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
- loadLibrary("jogl_es2", nativewindowX11Preload, true);
+ loadLibrary("jogl_es2", nativeOSPreload, true);
return null;
}
});
@@ -90,7 +90,7 @@ public class NativeLibLoader extends NativeLibLoaderBase {
public static void loadES1() {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
- loadLibrary("jogl_es1", nativewindowX11Preload, true);
+ loadLibrary("jogl_es1", nativeOSPreload, true);
return null;
}
});
@@ -135,7 +135,7 @@ public class NativeLibLoader extends NativeLibLoaderBase {
}
}
- private static final String[] nativewindowX11Preload = { "nativewindow_x11" };
+ private static final String[] nativeOSPreload = { "nativewindow_x11" };
private static boolean usingJNLPAppletLauncher;
private static Method jnlpLoadLibraryMethod;
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 d6cf2af8a..8253699af 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
@@ -124,7 +124,6 @@ public class EGLContext extends GLContextImpl {
System.err.println("drawable not properly initialized");
return CONTEXT_NOT_CURRENT;
}
- drawable.setSurface();
int lockRes = NativeWindow.LOCK_SUCCESS;
// FIXME: freezes AWT: int lockRes = drawable.lockSurface();
@@ -214,7 +213,8 @@ public class EGLContext extends GLContextImpl {
}
eglContext = EGL.eglCreateContext(eglDisplay, eglConfig, shareWith, contextAttrs, 0);
if (eglContext == 0) {
- throw new GLException("Error creating OpenGL context");
+ throw new GLException("Error creating OpenGL context: eglDisplay 0x"+Long.toHexString(eglDisplay)+
+ ", "+glProfile+", error 0x"+Integer.toHexString(EGL.eglGetError()));
}
GLContextShareSet.contextCreated(this);
if (DEBUG) {
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 389278d96..6ffae08b8 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
@@ -76,14 +76,19 @@ public class EGLDrawable extends GLDrawableImpl {
return (null==eglConfig)?super.getGLCapabilities():(GLCapabilities)eglConfig.getCapabilities();
}
- protected void setSurface() {
+ private void setSurface() {
if (EGL.EGL_NO_SURFACE==eglSurface) {
lockSurface();
try {
+ if(DEBUG) {
+ System.err.println("setSurface using component: handle 0x"+Long.toHexString(component.getWindowHandle())+", "+component);
+ }
// Create the window surface
eglSurface = EGL.eglCreateWindowSurface(eglDisplay, eglConfig.getNativeConfig(), component.getWindowHandle(), null);
if (EGL.EGL_NO_SURFACE==eglSurface) {
- throw new GLException("Creation of window surface (eglCreateWindowSurface) failed, component: "+component);
+ throw new GLException("Creation of window surface (eglCreateWindowSurface) failed, component: "+component+", error 0x"+Integer.toHexString(EGL.eglGetError()));
+ } else if(DEBUG) {
+ System.err.println("setSurface result: eglSurface 0x"+Long.toHexString(eglSurface));
}
} finally {
unlockSurface();
@@ -116,12 +121,15 @@ public class EGLDrawable extends GLDrawableImpl {
} else {
// create a new EGL config ..
ownEGLDisplay=true;
- eglDisplay = EGL.eglGetDisplay((0!=aDevice.getHandle())?aDevice.getHandle():EGL.EGL_DEFAULT_DISPLAY);
+ long ndisplay = (0!=aDevice.getHandle())?aDevice.getHandle():EGL.EGL_DEFAULT_DISPLAY;
+ eglDisplay = EGL.eglGetDisplay(ndisplay);
if (eglDisplay == EGL.EGL_NO_DISPLAY) {
- throw new GLException("Failed to created EGL display from "+aDevice);
+ throw new GLException("Failed to created EGL display: nhandle 0x"+Long.toHexString(ndisplay)+", "+aDevice+", error 0x"+Integer.toHexString(EGL.eglGetError()));
+ } else if(DEBUG) {
+ System.err.println("eglDisplay("+ndisplay+"): 0x"+Long.toHexString(eglDisplay));
}
if (!EGL.eglInitialize(eglDisplay, null, null)) {
- throw new GLException("eglInitialize failed");
+ throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError()));
}
EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay);
DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, aConfig.getScreen().getIndex());
@@ -129,8 +137,11 @@ public class EGLDrawable extends GLDrawableImpl {
eglConfig = (EGLGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(e).chooseGraphicsConfiguration(caps, null, s);
if (null == eglConfig) {
throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);
+ } else if(DEBUG) {
+ System.err.println("Chosen eglConfig: "+eglConfig);
}
}
+ setSurface();
} else if (eglSurface != EGL.EGL_NO_SURFACE) {
// Destroy the window surface
if (!EGL.eglDestroySurface(eglDisplay, eglSurface)) {
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 aeb4db84a..3f1fb6435 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
@@ -44,15 +44,7 @@ import com.sun.gluegen.runtime.NativeLibrary;
public class EGLDrawableFactory extends GLDrawableFactoryImpl {
- // We need more than one of these on certain devices (the NVidia APX 2500 in particular)
- private List/*<NativeLibrary>*/ glesLibraries = new ArrayList();
-
- public EGLDrawableFactory(String esProfile) {
- super();
-
- loadGLESLibrary(esProfile);
- EGL.resetProcAddressTable(this);
-
+ static {
// Register our GraphicsConfigurationFactory implementations
// The act of constructing them causes them to be registered
new EGLGraphicsConfigurationFactory();
@@ -65,6 +57,16 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
}
+ // We need more than one of these on certain devices (the NVidia APX 2500 in particular)
+ private List/*<NativeLibrary>*/ glesLibraries = new ArrayList();
+
+ public EGLDrawableFactory(String esProfile) {
+ super();
+
+ loadGLESLibrary(esProfile);
+ EGL.resetProcAddressTable(this);
+ }
+
private NativeLibrary loadFirstAvailable(List/*<String>*/ libNames, ClassLoader loader) {
for (Iterator iter = libNames.iterator(); iter.hasNext(); ) {
NativeLibrary lib = NativeLibrary.open((String) iter.next(), loader, false /*global*/);
@@ -82,40 +84,53 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
List/*<String>*/ glesLibNames = new ArrayList();
List/*<String>*/ eglLibNames = new ArrayList();
+ // ES
if(GLProfile.UsesNativeGLES2(esProfile)) {
- // Unix
- glesLibNames.add("libGLES20");
- glesLibNames.add("libGLESv2");
- glesLibNames.add("libGLESv2_CM");
- // Windows
glesLibNames.add("GLES20");
glesLibNames.add("GLESv2");
glesLibNames.add("GLESv2_CM");
+ // for windows distributions using the 'unlike' lib prefix
+ // where our tool does not add it.
+ glesLibNames.add("libGLES20");
+ glesLibNames.add("libGLESv2");
+ glesLibNames.add("libGLESv2_CM");
} else if(GLProfile.UsesNativeGLES1(esProfile)) {
- // Unix
- glesLibNames.add("libGLES_CM");
- glesLibNames.add("libGLES_CL");
- glesLibNames.add("libGLESv1_CM");
-
- // Windows
glesLibNames.add("GLES_CM");
glesLibNames.add("GLES_CL");
glesLibNames.add("GLESv1_CM");
+ // for windows distributions using the 'unlike' lib prefix,
+ // where our tool does not add it.
+ glesLibNames.add("libGLES_CM");
+ glesLibNames.add("libGLES_CL");
+ glesLibNames.add("libGLESv1_CM");
} else {
throw new GLException("Invalid GL Profile for EGL: "+esProfile);
}
- // EGL Unix
- eglLibNames.add("libEGL");
- // EGL Windows
+ // EGL
eglLibNames.add("EGL");
+ // for windows distributions using the 'unlike' lib prefix,
+ // where our tool does not add it.
+ eglLibNames.add("libEGL");
ClassLoader loader = getClass().getClassLoader();
- NativeLibrary lib = loadFirstAvailable(glesLibNames, loader);
+ NativeLibrary lib = null;
+
+ // ES libraries ..
+ lib = loadFirstAvailable(glesLibNames, loader);
if (lib == null) {
throw new GLException("Unable to dynamically load OpenGL ES library for profile \"" + esProfile + "\"");
}
glesLibraries.add(lib);
+
+ // ES libraries ..
+ lib = loadFirstAvailable(glesLibNames, loader);
+ if (lib == null) {
+ throw new GLException("Unable to dynamically load OpenGL ES library for profile \"" + esProfile + "\"");
+ }
+ glesLibraries.add(lib);
+
+ // EGL libraries ..
lib = loadFirstAvailable(eglLibNames, loader);
if (lib == null) {
throw new GLException("Unable to dynamically load EGL library for profile \"" + esProfile + "\"");
@@ -175,10 +190,15 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
NativeLibrary lib = (NativeLibrary) iter.next();
long addr = lib.lookupFunction(glFuncName);
if (addr != 0) {
+ if(DEBUG) {
+ System.err.println("Lookup-Native: <"+glFuncName+"> 0x"+Long.toHexString(addr));
+ }
return addr;
}
}
-
+ if(DEBUG) {
+ System.err.println("Lookup-Native: <*"+glFuncName+"> ** FAILED ** ");
+ }
return 0;
}
@@ -193,7 +213,11 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
if(0==eglGetProcAddressHandle) {
eglGetProcAddressHandle = dynamicLookupFunctionOnLibs("eglGetProcAddress");
if(0==eglGetProcAddressHandle) {
- throw new GLException("Couldn't find eglGetProcAddress function entry");
+ GLException e = new GLException("Couldn't find eglGetProcAddress function entry");
+ if(DEBUG) {
+ e.printStackTrace();
+ }
+ throw e;
}
}
@@ -202,6 +226,13 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
long addr = EGL.eglGetProcAddress(eglGetProcAddressHandle, glFuncName);
+ if(DEBUG) {
+ if(0!=addr) {
+ System.err.println("Lookup-EGL: <"+glFuncName+"> 0x"+Long.toHexString(addr));
+ } else {
+ System.err.println("Lookup-EGL: <"+glFuncName+"> ** FAILED ** ");
+ }
+ }
if(0==addr) {
addr = dynamicLookupFunctionOnLibs(glFuncName);
}
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 c3f4089ba..14e91bef1 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
@@ -111,6 +111,21 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_DEPTH_SIZE, val, 0)) {
caps.setDepthBits(val[0]);
}
+ if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_SAMPLES, val, 0)) {
+ caps.setSampleBuffers(val[0]>0?true:false);
+ caps.setNumSamples(val[0]);
+ }
+ if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_TRANSPARENT_TYPE, val, 0)) {
+ caps.setBackgroundOpaque(val[0] != EGL.EGL_TRANSPARENT_RGB);
+ }
+ /**
+ // FIXME - Add transparency values to Capabilities !
+ if(!caps.isBackgroundOpaque()) {
+ if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_TRANSPARENT_RED_VALUE, val, 0)) {
+ caps.setTransparentRed(val[0]);
+ }
+ }
+ */
return caps;
}
@@ -118,13 +133,15 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
int[] attrs = new int[] {
EGL.EGL_RENDERABLE_TYPE, -1,
// FIXME: does this need to be configurable?
- EGL.EGL_SURFACE_TYPE, EGL.EGL_WINDOW_BIT,
+ EGL.EGL_SURFACE_TYPE, EGL.EGL_WINDOW_BIT, // or EGL_PBUFFER_BIT, EGL_PIXMAP_BIT
EGL.EGL_RED_SIZE, caps.getRedBits(),
EGL.EGL_GREEN_SIZE, caps.getGreenBits(),
EGL.EGL_BLUE_SIZE, caps.getBlueBits(),
EGL.EGL_ALPHA_SIZE, (caps.getAlphaBits() > 0 ? caps.getAlphaBits() : EGL.EGL_DONT_CARE),
EGL.EGL_STENCIL_SIZE, (caps.getStencilBits() > 0 ? caps.getStencilBits() : EGL.EGL_DONT_CARE),
EGL.EGL_DEPTH_SIZE, caps.getDepthBits(),
+ EGL.EGL_SAMPLES, (caps.getSampleBuffers() ? caps.getNumSamples() : 1),
+ EGL.EGL_TRANSPARENT_TYPE,(caps.isBackgroundOpaque() ? EGL.EGL_NONE : EGL.EGL_TRANSPARENT_TYPE),
EGL.EGL_NONE
};
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
index f12d1c6a8..8fa086d85 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
@@ -105,6 +105,9 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
if(null!=res) {
return res;
}
+ if(DEBUG) {
+ System.err.println("eglChooseConfig failed with given capabilities");
+ }
_EGLConfig[] configs = new _EGLConfig[10];
int[] numConfigs = new int[1];
@@ -133,8 +136,28 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
System.err.println("Choosen "+caps[chosen]);
}
res = eglChooseConfig(eglDisplay, caps[chosen], absScreen);
+ if(null!=res) {
+ return res;
+ }
+ if(DEBUG) {
+ System.err.println("eglChooseConfig failed with eglGetConfig/choosen capabilities");
+ }
+
+ // Last try .. add a fixed embedded profile [ATI, Nokia, ..]
+ GLCapabilities fixedCaps = new GLCapabilities(glp);
+ fixedCaps.setRedBits(5);
+ fixedCaps.setGreenBits(6);
+ fixedCaps.setBlueBits(5);
+ fixedCaps.setDepthBits(16);
+ fixedCaps.setSampleBuffers(true);
+ fixedCaps.setNumSamples(4);
+ if(DEBUG) {
+ System.err.println("trying fixed caps: "+fixedCaps);
+ }
+
+ res = eglChooseConfig(eglDisplay, fixedCaps, absScreen);
if(null==res) {
- throw new GLException("Graphics configuration chooser/eglChoose failed");
+ throw new GLException("Graphics configuration failed [direct caps, eglGetConfig/chooser and fixed-caps]");
}
return res;
}
@@ -155,7 +178,11 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
int[] val = new int[1];
// get the configID
if(!EGL.eglGetConfigAttrib(eglDisplay, configs[0], EGL.EGL_CONFIG_ID, val, 0)) {
- throw new GLException("EGL couldn't retrieve ConfigID");
+ if(DEBUG) {
+ // FIXME: this happens on a ATI PC Emulation ..
+ System.err.println("EGL couldn't retrieve ConfigID for already chosen eglConfig "+capabilities+", use 0");
+ }
+ val[0]=0;
}
return new EGLGraphicsConfiguration(absScreen,
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
index 472c5f2bc..18ec81b81 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
@@ -44,8 +44,6 @@ import javax.media.opengl.*;
import com.sun.opengl.impl.*;
public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
- protected static final boolean DEBUG = Debug.debug("MacOSXCGLDrawable");
-
// The Java2D/OpenGL pipeline on OS X uses low-level CGLContextObjs
// to represent the contexts for e.g. the Java2D back buffer. When
// the Java2D/JOGL bridge is active, this means that if we want to
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
index 2c0891344..9e3f1820a 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -48,8 +48,6 @@ import com.sun.opengl.impl.*;
import com.sun.nativewindow.impl.*;
public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
- protected static final boolean DEBUG = com.sun.opengl.impl.Debug.debug("GraphicsConfiguration");
-
public MacOSXCGLDrawableFactory() {
super();
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 1ff640df2..ae9d33889 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
@@ -152,8 +152,20 @@ public class WindowsWGLContext extends GLContextImpl {
}
setGLFunctionAvailability(true);
- if( !isFunctionAvailable("wglCreateContextAttribsARB") ||
- !isExtensionAvailable("WGL_ARB_create_context") ) {
+ boolean haswglCreateContextAttribsARB = isFunctionAvailable("wglCreateContextAttribsARB");
+ boolean hasWGL_ARB_create_context = false;
+ try {
+ hasWGL_ARB_create_context = isExtensionAvailable("WGL_ARB_create_context");
+ } catch (Exception e) {
+ // funny .. so let's take the result of the available function
+ hasWGL_ARB_create_context = haswglCreateContextAttribsARB;
+ if(DEBUG) {
+ e.printStackTrace();
+ }
+ }
+
+ if( !haswglCreateContextAttribsARB ||
+ !hasWGL_ARB_create_context ) {
if(glCaps.getGLProfile().isGL3()) {
if (!WGL.wglMakeCurrent(0, 0)) {
throw new GLException("Error freeing temp OpenGL context: " + WGL.GetLastError());
@@ -183,7 +195,8 @@ public class WindowsWGLContext extends GLContextImpl {
if(glCaps.getGLProfile().isGL3()) {
attribs[1] |= 3;
attribs[3] |= 1;
- attribs[5] |= WGLExt.WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /* | WGLExt.WGL_CONTEXT_DEBUG_BIT_ARB */;
+ // 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 ;
}
hglrc = wglExt.wglCreateContextAttribsARB(drawable.getNativeWindow().getSurfaceHandle(), hglrc2, attribs, 0);
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 1e908f703..d638926ab 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
@@ -44,8 +44,6 @@ import javax.media.opengl.*;
import com.sun.opengl.impl.*;
public abstract class WindowsWGLDrawable extends GLDrawableImpl {
- protected static final boolean DEBUG = Debug.debug("WindowsWGLDrawable");
-
// Workaround for problems on Intel 82855 cards
private int setPixelFormatFailCount;
private static final int MAX_SET_PIXEL_FORMAT_FAIL_COUNT = 5;
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
index 9bb8797dc..33c81045d 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -44,9 +44,9 @@ import java.util.*;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.sun.opengl.impl.*;
+import com.sun.nativewindow.impl.NWReflection;
public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
- private static final boolean DEBUG = Debug.debug("WindowsWGLDrawableFactory");
private static final boolean VERBOSE = Debug.verbose();
// Handle to GLU32.dll
@@ -59,6 +59,10 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
// Register our GraphicsConfigurationFactory implementations
// The act of constructing them causes them to be registered
new WindowsWGLGraphicsConfigurationFactory();
+ try {
+ NWReflection.createInstance("com.sun.opengl.impl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory",
+ new Object[] {});
+ } catch (Throwable t) { }
}
public GLDrawable createGLDrawable(NativeWindow target) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
new file mode 100644
index 000000000..d682df5eb
--- /dev/null
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2008 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.
+ */
+
+package com.sun.opengl.impl.windows.wgl.awt;
+
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.windows.*;
+import javax.media.nativewindow.awt.*;
+import javax.media.opengl.*;
+import javax.media.opengl.awt.*;
+
+import com.sun.opengl.impl.*;
+import com.sun.opengl.impl.windows.wgl.*;
+import com.sun.nativewindow.impl.jawt.*;
+import com.sun.nativewindow.impl.jawt.windows.*;
+
+public class WindowsAWTWGLGraphicsConfigurationFactory extends GraphicsConfigurationFactory {
+ protected static final boolean DEBUG = com.sun.opengl.impl.Debug.debug("GraphicsConfiguration");
+
+ public WindowsAWTWGLGraphicsConfigurationFactory() {
+ GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, this);
+ }
+
+ public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
+ CapabilitiesChooser chooser,
+ AbstractGraphicsScreen absScreen) {
+ GraphicsDevice device = null;
+ if (absScreen != null &&
+ !(absScreen instanceof AWTGraphicsScreen)) {
+ throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only AWTGraphicsScreen objects");
+ }
+
+ if(null==absScreen) {
+ absScreen = AWTGraphicsScreen.createScreenDevice(-1);
+ }
+ AWTGraphicsScreen awtScreen = (AWTGraphicsScreen) absScreen;
+ device = ((AWTGraphicsDevice)awtScreen.getDevice()).getGraphicsDevice();
+
+ if (capabilities != null &&
+ !(capabilities instanceof GLCapabilities)) {
+ throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects");
+ }
+
+ if (chooser != null &&
+ !(chooser instanceof GLCapabilitiesChooser)) {
+ throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilitiesChooser objects");
+ }
+
+ if(DEBUG) {
+ System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: got "+absScreen);
+ }
+
+ long displayHandle = 0;
+
+ WindowsGraphicsDevice winDevice = new WindowsGraphicsDevice();
+ DefaultGraphicsScreen winScreen = new DefaultGraphicsScreen(winDevice, awtScreen.getIndex());
+ if(DEBUG) {
+ System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: made "+winScreen);
+ }
+
+ WindowsWGLGraphicsConfiguration winConfig = (WindowsWGLGraphicsConfiguration)
+ GraphicsConfigurationFactory.getFactory(winDevice).chooseGraphicsConfiguration(capabilities,
+ chooser,
+ winScreen);
+ if (winConfig != null) {
+ // FIXME: we have nothing to match .. so choose the 1st
+ GraphicsConfiguration[] configs = device.getConfigurations();
+ if(configs.length>0) {
+ return new AWTGraphicsConfiguration(awtScreen, winConfig.getCapabilities(), configs[0], winConfig);
+ }
+ }
+
+ // Either we weren't able to reflectively introspect on the
+ // X11GraphicsConfig or something went wrong in the steps above;
+ // we're going to return null without signaling an error condition
+ // in this case (although we should distinguish between the two
+ // and possibly report more of an error in the latter case)
+ return null;
+ }
+}
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 baffad289..1ed58dbb2 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
@@ -45,8 +45,6 @@ import com.sun.opengl.impl.*;
import com.sun.nativewindow.impl.x11.*;
public abstract class X11GLXDrawable extends GLDrawableImpl {
- protected static final boolean DEBUG = Debug.debug("X11GLXDrawable");
-
protected X11GLXDrawable(GLDrawableFactory factory, NativeWindow comp, boolean realized) {
super(factory, comp, realized);
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index cb42d9821..29bfc18a7 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -52,8 +52,6 @@ import com.sun.nativewindow.impl.x11.*;
import com.sun.nativewindow.impl.jawt.x11.*;
public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
- protected static final boolean DEBUG = Debug.debug("X11GLXDrawableFactory");
-
public X11GLXDrawableFactory() {
super();
// Must initialize GLX support eagerly in case a pbuffer is the
diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilities.java b/src/jogl/classes/javax/media/opengl/GLCapabilities.java
index bc49bbde1..69263ad70 100644
--- a/src/jogl/classes/javax/media/opengl/GLCapabilities.java
+++ b/src/jogl/classes/javax/media/opengl/GLCapabilities.java
@@ -78,12 +78,6 @@ public class GLCapabilities extends Capabilities implements Cloneable {
*/
public GLCapabilities(GLProfile glp) {
glProfile = (null!=glp)?glp:GLProfile.GetProfileDefault();
- if(glProfile.usesNativeGLES()) {
- setRedBits(5);
- setGreenBits(6);
- setBlueBits(5);
- setDepthBits(16);
- }
}
public Object clone() {
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 1d92fbb18..20414126b 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -612,6 +612,9 @@ public class GLProfile implements Cloneable {
*/
static {
boolean hasDesktopGL = false;
+ boolean hasDesktopGLES12 = false;
+ boolean hasNativeOSFactory = false;
+
try {
// See DRIHack.java for an explanation of why this is necessary
DRIHack.begin();
@@ -624,7 +627,7 @@ public class GLProfile implements Cloneable {
t.printStackTrace();
}
}
- boolean hasDesktopGLES12 = false;
+
try {
// See DRIHack.java for an explanation of why this is necessary
DRIHack.begin();
@@ -638,7 +641,6 @@ public class GLProfile implements Cloneable {
}
}
- boolean hasNativeOSFactory = false;
if(hasDesktopGL||hasDesktopGLES12) {
try {
hasNativeOSFactory = null!=GLDrawableFactory.getNativeOSFactory();
@@ -649,6 +651,7 @@ public class GLProfile implements Cloneable {
}
}
}
+
if(!hasNativeOSFactory) {
hasDesktopGLES12=false;
hasDesktopGL=false;