aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/build-jogl.xml6
-rw-r--r--make/build-nativewindow.xml2
-rw-r--r--make/build-newt.xml6
-rwxr-xr-xmake/config/jogl/eglext.cfg2
-rwxr-xr-xmake/config/jogl/gl-es1.cfg4
-rwxr-xr-xmake/config/jogl/gl-es2.cfg4
-rw-r--r--make/config/jogl/gl-gl2.cfg6
-rw-r--r--make/config/jogl/gl-gl2es12.cfg6
-rwxr-xr-xmake/config/jogl/gl-if-gl2_es1.cfg2
-rwxr-xr-xmake/config/jogl/gl-if-gl2_es2.cfg2
-rwxr-xr-xmake/config/jogl/glxext.cfg2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java43
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java20
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLConfig.java14
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java21
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java16
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java12
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java12
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java22
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLDrawable.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java8
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java4
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java8
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java6
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java12
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java68
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java22
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java27
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java70
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java (renamed from src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXNativeWindowFactory.java)109
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java8
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXContext.java6
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java8
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java8
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java (renamed from src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXNativeWindowFactory.java)106
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/util/awt/TextRenderer.java3
-rw-r--r--src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java239
-rw-r--r--src/jogl/classes/javax/media/opengl/GLCapabilities.java310
-rw-r--r--src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java55
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawable.java4
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java30
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java19
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java31
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java42
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/GraphicsConfigurationFactoryImpl.java44
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java8
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/NativeWindowFactoryImpl.java8
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java4
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java4
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java10
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java6
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java4
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java10
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11SunJDKReflection.java14
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java60
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java76
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11Util.java2
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/x11/awt/X11AWTNativeWindowFactory.java4
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/Capabilities.java256
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java24
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java96
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java180
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java31
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java127
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java4
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/NewtFactory.java13
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Window.java43
-rw-r--r--src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java8
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java11
-rw-r--r--src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java32
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java19
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java13
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/x11/X11Window.java21
78 files changed, 1598 insertions, 959 deletions
diff --git a/make/build-jogl.xml b/make/build-jogl.xml
index bcb930b05..79fdb06e2 100644
--- a/make/build-jogl.xml
+++ b/make/build-jogl.xml
@@ -336,7 +336,7 @@
<isset property="rootrel.build"/>
</not>
</condition>
- <property name="rootrel.build.jogl" value="${rootrel.build}-jogl" />
+ <property name="rootrel.build.jogl" value="${rootrel.build}/jogl" />
<property name="rootrel.src.java" value="src/jogl/classes" />
<property name="rootrel.src.c" value="src/jogl/native" />
<property name="rootrel.src.c.openmax" value="src/jogl/native/openmax" />
@@ -355,13 +355,13 @@
<property name="gluegen.build.xml" value="${gluegen.make.dir}/build.xml" />
<property name="gluegen.jar" value="../../gluegen/${rootrel.build}/gluegen.jar" />
<property name="gluegen-rt.jar" value="../../gluegen/${rootrel.build}/gluegen-rt.jar" />
- <property name="nativewindow.all.jar" value="../${rootrel.build}-nativewindow/nativewindow.all.jar" />
+ <property name="nativewindow.all.jar" value="../${rootrel.build}/nativewindow/nativewindow.all.jar" />
<!-- The source directories. -->
<property name="src.java" value="${project.root}/${rootrel.src.java}" />
<property name="src.c" value="${project.root}/${rootrel.src.c}" />
<property name="build" value="${project.root}/${rootrel.build.jogl}" />
- <property name="tempdir" value="${project.root}/build-temp" />
+ <property name="tempdir" value="${build}/temp" />
<!-- The generated source directories. -->
<property name="src.generated" value="${build}/gensrc" />
diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml
index 2fc8414fa..da09e286d 100644
--- a/make/build-nativewindow.xml
+++ b/make/build-nativewindow.xml
@@ -214,7 +214,7 @@
<isset property="rootrel.build"/>
</not>
</condition>
- <property name="rootrel.build.nativewindow" value="${rootrel.build}-nativewindow" />
+ <property name="rootrel.build.nativewindow" value="${rootrel.build}/nativewindow" />
<property name="rootrel.src" value="src/nativewindow" />
<property name="rootrel.src.java" value="${rootrel.src}/classes" />
<property name="rootrel.src.c" value="${rootrel.src}/native" />
diff --git a/make/build-newt.xml b/make/build-newt.xml
index e8349b49d..a899e8bb1 100644
--- a/make/build-newt.xml
+++ b/make/build-newt.xml
@@ -177,15 +177,15 @@
<isset property="rootrel.build"/>
</not>
</condition>
- <property name="rootrel.build.newt" value="${rootrel.build}-newt" />
+ <property name="rootrel.build.newt" value="${rootrel.build}/newt" />
<property name="rootrel.src" value="src/newt" />
<property name="rootrel.src.java" value="${rootrel.src}/classes" />
<property name="rootrel.src.c" value="${rootrel.src}/native" />
<property name="rootrel.obj" value="${rootrel.build.newt}/obj" />
<property name="gluegen-rt.jar" value="../../gluegen/${rootrel.build}/gluegen-rt.jar" />
- <property name="nativewindow.all.jar" value="../${rootrel.build}-nativewindow/nativewindow.all.jar" />
- <property name="jogl.all.jar" value="../${rootrel.build}-jogl/jogl.all.jar" />
+ <property name="nativewindow.all.jar" value="../${rootrel.build}/nativewindow/nativewindow.all.jar" />
+ <property name="jogl.all.jar" value="../${rootrel.build}/jogl/jogl.all.jar" />
<!-- The source directories. -->
<property name="src.java" value="${project.root}/${rootrel.src.java}" />
diff --git a/make/config/jogl/eglext.cfg b/make/config/jogl/eglext.cfg
index bdd9a3655..e0280c056 100755
--- a/make/config/jogl/eglext.cfg
+++ b/make/config/jogl/eglext.cfg
@@ -10,7 +10,7 @@ ImplPackage com.sun.opengl.impl.egl
ImplJavaClass EGLExtImpl
# Shouldn't matter which one of these we pick up
-ExtendedInterfaceSymbols ../build-temp/gensrc/classes/com/sun/opengl/impl/egl/EGL.java
+ExtendedInterfaceSymbols ../build/jogl/temp/gensrc/classes/com/sun/opengl/impl/egl/EGL.java
HierarchicalNativeOutput false
Include gl-common.cfg
diff --git a/make/config/jogl/gl-es1.cfg b/make/config/jogl/gl-es1.cfg
index 2b630ee70..a90c47874 100755
--- a/make/config/jogl/gl-es1.cfg
+++ b/make/config/jogl/gl-es1.cfg
@@ -2,8 +2,8 @@
JavaOutputDir gensrc/classes
NativeOutputDir gensrc/native/jogl/es1
-ExtendedInterfaceSymbols ../build-temp/gensrc/classes/javax/media/opengl/GL.java
-ExtendedInterfaceSymbols ../build-temp/gensrc/classes/javax/media/opengl/GL2ES1.java
+ExtendedInterfaceSymbols ../build/jogl/temp/gensrc/classes/javax/media/opengl/GL.java
+ExtendedInterfaceSymbols ../build/jogl/temp/gensrc/classes/javax/media/opengl/GL2ES1.java
ExtendedInterfaceSymbols ../src/jogl/classes/javax/media/opengl/sub/GLObject.java
ExtendedInterfaceSymbols ../src/jogl/classes/javax/media/opengl/sub/fixed/GLMatrixIf.java
ExtendedInterfaceSymbols ../src/jogl/classes/javax/media/opengl/sub/fixed/GLPointerIf.java
diff --git a/make/config/jogl/gl-es2.cfg b/make/config/jogl/gl-es2.cfg
index 669eabcf3..b9f2f2de4 100755
--- a/make/config/jogl/gl-es2.cfg
+++ b/make/config/jogl/gl-es2.cfg
@@ -2,8 +2,8 @@
JavaOutputDir gensrc/classes
NativeOutputDir gensrc/native/jogl/es2
-ExtendedInterfaceSymbols ../build-temp/gensrc/classes/javax/media/opengl/GL.java
-ExtendedInterfaceSymbols ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java
+ExtendedInterfaceSymbols ../build/jogl/temp/gensrc/classes/javax/media/opengl/GL.java
+ExtendedInterfaceSymbols ../build/jogl/temp/gensrc/classes/javax/media/opengl/GL2ES2.java
ExtendedInterfaceSymbols ../src/jogl/classes/javax/media/opengl/sub/GLObject.java
Package javax.media.opengl
diff --git a/make/config/jogl/gl-gl2.cfg b/make/config/jogl/gl-gl2.cfg
index 76cb0573a..5d3df7574 100644
--- a/make/config/jogl/gl-gl2.cfg
+++ b/make/config/jogl/gl-gl2.cfg
@@ -2,9 +2,9 @@
JavaOutputDir gensrc/classes
NativeOutputDir gensrc/native/jogl/gl2
-ExtendedInterfaceSymbols ../build-temp/gensrc/classes/javax/media/opengl/GL.java
-ExtendedInterfaceSymbols ../build-temp/gensrc/classes/javax/media/opengl/GL2ES1.java
-ExtendedInterfaceSymbols ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java
+ExtendedInterfaceSymbols ../build/jogl/temp/gensrc/classes/javax/media/opengl/GL.java
+ExtendedInterfaceSymbols ../build/jogl/temp/gensrc/classes/javax/media/opengl/GL2ES1.java
+ExtendedInterfaceSymbols ../build/jogl/temp/gensrc/classes/javax/media/opengl/GL2ES2.java
ExtendedInterfaceSymbols ../src/jogl/classes/javax/media/opengl/sub/GLObject.java
ExtendedInterfaceSymbols ../src/jogl/classes/javax/media/opengl/sub/fixed/GLMatrixIf.java
ExtendedInterfaceSymbols ../src/jogl/classes/javax/media/opengl/sub/fixed/GLPointerIf.java
diff --git a/make/config/jogl/gl-gl2es12.cfg b/make/config/jogl/gl-gl2es12.cfg
index 2d0704577..98c2fd3f1 100644
--- a/make/config/jogl/gl-gl2es12.cfg
+++ b/make/config/jogl/gl-gl2es12.cfg
@@ -2,9 +2,9 @@
JavaOutputDir gensrc/classes
NativeOutputDir gensrc/native/jogl/gl2es12
-ExtendedInterfaceSymbolsOnly ../build-temp/gensrc/classes/javax/media/opengl/GL.java
-ExtendedInterfaceSymbolsOnly ../build-temp/gensrc/classes/javax/media/opengl/GL2ES1.java
-ExtendedInterfaceSymbolsOnly ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java
+ExtendedInterfaceSymbolsOnly ../build/jogl/temp/gensrc/classes/javax/media/opengl/GL.java
+ExtendedInterfaceSymbolsOnly ../build/jogl/temp/gensrc/classes/javax/media/opengl/GL2ES1.java
+ExtendedInterfaceSymbolsOnly ../build/jogl/temp/gensrc/classes/javax/media/opengl/GL2ES2.java
ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/sub/GLObject.java
ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/sub/fixed/GLMatrixIf.java
ExtendedInterfaceSymbolsOnly ../src/jogl/classes/javax/media/opengl/sub/fixed/GLPointerIf.java
diff --git a/make/config/jogl/gl-if-gl2_es1.cfg b/make/config/jogl/gl-if-gl2_es1.cfg
index 72e0dbcd3..654659343 100755
--- a/make/config/jogl/gl-if-gl2_es1.cfg
+++ b/make/config/jogl/gl-if-gl2_es1.cfg
@@ -8,7 +8,7 @@ Extends GL2ES1 GLMatrixIf
Extends GL2ES1 GLPointerIf
Extends GL2ES1 GLLightingIf
-ExtendedInterfaceSymbols ../build-temp/gensrc/classes/javax/media/opengl/GL.java
+ExtendedInterfaceSymbols ../build/jogl/temp/gensrc/classes/javax/media/opengl/GL.java
ExtendedInterfaceSymbols ../src/jogl/classes/javax/media/opengl/sub/GLObject.java
ExtendedInterfaceSymbols ../src/jogl/classes/javax/media/opengl/sub/fixed/GLMatrixIf.java
ExtendedInterfaceSymbols ../src/jogl/classes/javax/media/opengl/sub/fixed/GLPointerIf.java
diff --git a/make/config/jogl/gl-if-gl2_es2.cfg b/make/config/jogl/gl-if-gl2_es2.cfg
index 7e219a3fb..493dc2242 100755
--- a/make/config/jogl/gl-if-gl2_es2.cfg
+++ b/make/config/jogl/gl-if-gl2_es2.cfg
@@ -5,7 +5,7 @@ JavaClass GL2ES2
Extends GL2ES2 GLObject
Extends GL2ES2 GL
-ExtendedInterfaceSymbols ../build-temp/gensrc/classes/javax/media/opengl/GL.java
+ExtendedInterfaceSymbols ../build/jogl/temp/gensrc/classes/javax/media/opengl/GL.java
ExtendedInterfaceSymbols ../src/jogl/classes/javax/media/opengl/sub/GLObject.java
HierarchicalNativeOutput false
Include gl-common.cfg
diff --git a/make/config/jogl/glxext.cfg b/make/config/jogl/glxext.cfg
index d69a3df3b..564dfc6a7 100755
--- a/make/config/jogl/glxext.cfg
+++ b/make/config/jogl/glxext.cfg
@@ -9,7 +9,7 @@ JavaClass GLXExt
ImplPackage com.sun.opengl.impl.x11.glx
ImplJavaClass GLXExtImpl
-ExtendedInterfaceSymbols ../build-temp/gensrc/classes/com/sun/opengl/impl/x11/glx/GLX.java
+ExtendedInterfaceSymbols ../build/jogl/temp/gensrc/classes/com/sun/opengl/impl/x11/glx/GLX.java
Include gl-common-gl2.cfg
Include gl-desktop.cfg
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
index 5549da170..fb1b8d6f4 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
@@ -53,18 +53,11 @@ import java.lang.reflect.*;
they may be instantiated by the GLJPanel implementation. */
public abstract class GLDrawableFactoryImpl extends GLDrawableFactory implements DynamicLookupHelper {
- /**
- * Make sure the right NativeWindowFactory is registered
- */
- static {
- initializeNativeWindowFactory();
- }
-
/** Creates a (typically software-accelerated) offscreen GLDrawable
used to implement the fallback rendering path of the
GLJPanel. */
- public abstract GLDrawableImpl createOffscreenDrawable(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
+ public abstract GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
int width,
int height);
@@ -261,36 +254,4 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory implements
gammaShutdownHookRegistered = false;
// Leave the original gamma ramp data alone
}
-
- private static void initializeNativeWindowFactory() {
- String osName = System.getProperty("os.name");
- String osNameLowerCase = osName.toLowerCase();
- String factoryClassName = null;
-
- // We break compile-time dependencies on the AWT here to
- // make it easier to run this code on mobile devices
-
- NativeWindowFactory factory = null;
-
- if (!osNameLowerCase.startsWith("wind") &&
- !osNameLowerCase.startsWith("mac os x")) {
- // Assume X11 platform -- should probably test for these explicitly
- try {
- // try X11 AWT GLX ..
- Constructor factoryConstructor = NWReflection.getConstructor("com.sun.opengl.impl.x11.glx.awt.X11AWTGLXNativeWindowFactory", new Class[] {});
- factory = (NativeWindowFactory) factoryConstructor.newInstance(null);
- } catch (Exception e) {}
- if(null==factory) {
- try {
- // try X11 GLX ..
- Constructor factoryConstructor = NWReflection.getConstructor("com.sun.opengl.impl.x11.glx.X11GLXNativeWindowFactory", new Class[] {});
- factory = (NativeWindowFactory) factoryConstructor.newInstance(null);
- } catch (Exception e) {}
- }
- /**
- if(null==factory) {
- // must be EGL then ..
- } */
- }
- }
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
index ce1dc6fdf..9df572af1 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
@@ -43,16 +43,16 @@ import javax.media.nativewindow.*;
import javax.media.opengl.*;
public abstract class GLDrawableImpl implements GLDrawable {
- private NWCapabilities requestedCapabilities;
+ private GLCapabilities requestedCapabilities;
protected GLDrawableImpl(GLDrawableFactory factory,
NativeWindow comp,
- NWCapabilities requestedCapabilities,
+ GLCapabilities requestedCapabilities,
boolean realized) {
this.factory = factory;
this.component = comp;
this.requestedCapabilities =
- (requestedCapabilities == null) ? null : (NWCapabilities) requestedCapabilities.clone();
+ (requestedCapabilities == null) ? null : (GLCapabilities) requestedCapabilities.clone();
this.realized = realized;
}
@@ -73,20 +73,20 @@ public abstract class GLDrawableImpl implements GLDrawable {
return GLContextImpl.toHexString(hex);
}
- protected NWCapabilities getRequestedNWCapabilities() {
+ protected GLCapabilities getRequestedGLCapabilities() {
return requestedCapabilities;
}
- public NWCapabilities getChosenNWCapabilities() {
+ public GLCapabilities getChosenGLCapabilities() {
if (chosenCapabilities == null)
return null;
// Must return a new copy to avoid mutation by end user
- return (NWCapabilities) chosenCapabilities.clone();
+ return (GLCapabilities) chosenCapabilities.clone();
}
- protected void setChosenNWCapabilities(NWCapabilities caps) {
- chosenCapabilities = (caps==null) ? null : (NWCapabilities) caps.clone();
+ protected void setChosenGLCapabilities(GLCapabilities caps) {
+ chosenCapabilities = (caps==null) ? null : (GLCapabilities) caps.clone();
}
public NativeWindow getNativeWindow() {
@@ -100,7 +100,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
public void setRealized(boolean realized) {
this.realized = realized;
if(!realized) {
- setChosenNWCapabilities(null);
+ setChosenGLCapabilities(null);
component.invalidate();
}
}
@@ -141,7 +141,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
protected GLDrawableFactory factory;
protected NativeWindow component;
- private NWCapabilities chosenCapabilities;
+ private GLCapabilities chosenCapabilities;
// Indicates whether the component (if an onscreen context) has been
// realized. Plausibly, before the component is realized the JAWT
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java
index c6cf74e19..b28dd1b53 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java
@@ -157,11 +157,11 @@ public class GLPbufferImpl implements GLPbuffer {
context.releasePbufferFromTexture();
}
- public NWCapabilities getChosenNWCapabilities() {
+ public GLCapabilities getChosenGLCapabilities() {
if (pbufferDrawable == null)
return null;
- return pbufferDrawable.getChosenNWCapabilities();
+ return pbufferDrawable.getChosenGLCapabilities();
}
private boolean surfaceLocked = false;
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLConfig.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLConfig.java
index f9ad6e318..0f60dd6b4 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLConfig.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLConfig.java
@@ -41,7 +41,7 @@ import javax.media.opengl.*;
import com.sun.opengl.impl.*;
import com.sun.gluegen.runtime.NativeLibrary;
-public class EGLConfig {
+public class EGLConfig implements AbstractGraphicsConfiguration {
public _EGLConfig getNativeConfig() {
return _config;
@@ -51,7 +51,7 @@ public class EGLConfig {
return configID;
}
- public NWCapabilities getCapabilities() {
+ public GLCapabilities getCapabilities() {
return capabilities;
}
@@ -83,11 +83,11 @@ public class EGLConfig {
if (numConfigs[0] == 0) {
throw new GLException("No valid graphics configuration selected from eglChooseConfig");
}
- capabilities = new NWCapabilities();
+ capabilities = new GLCapabilities();
setup(display, configID, configs[0]);
}
- public EGLConfig(long display, NWCapabilities caps) {
+ public EGLConfig(long display, GLCapabilities caps) {
int[] attrs = glCapabilities2AttribList(caps);
_EGLConfig[] configs = new _EGLConfig[1];
int[] numConfigs = new int[1];
@@ -100,7 +100,7 @@ public class EGLConfig {
if (numConfigs[0] == 0) {
throw new GLException("No valid graphics configuration selected from eglChooseConfig");
}
- capabilities = (NWCapabilities)caps.clone();
+ capabilities = (GLCapabilities)caps.clone();
setup(display, -1, configs[0]);
}
@@ -137,7 +137,7 @@ public class EGLConfig {
}
}
- public static int[] glCapabilities2AttribList(NWCapabilities caps) {
+ public static int[] glCapabilities2AttribList(GLCapabilities caps) {
int[] attrs = new int[] {
EGL.EGL_RENDERABLE_TYPE, -1,
// FIXME: does this need to be configurable?
@@ -167,6 +167,6 @@ public class EGLConfig {
}
private _EGLConfig _config;
private int configID;
- private NWCapabilities capabilities;
+ private GLCapabilities capabilities;
}
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 733891009..105ccc6d9 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
@@ -42,7 +42,7 @@ import javax.media.nativewindow.*;
import javax.media.opengl.*;
public class EGLDrawable extends GLDrawableImpl {
- private NWCapabilitiesChooser chooser;
+ private GLCapabilitiesChooser chooser;
private long display;
private EGLConfig config;
private long surface;
@@ -50,8 +50,8 @@ public class EGLDrawable extends GLDrawableImpl {
public EGLDrawable(EGLDrawableFactory factory,
NativeWindow component,
- NWCapabilities requestedCapabilities,
- NWCapabilitiesChooser chooser) throws GLException {
+ GLCapabilities requestedCapabilities,
+ GLCapabilitiesChooser chooser) throws GLException {
super(factory, component, requestedCapabilities, false);
this.chooser = chooser;
surface=EGL.EGL_NO_SURFACE;
@@ -92,7 +92,7 @@ public class EGLDrawable extends GLDrawableImpl {
public void setRealized(boolean realized) {
if (realized) {
- if (NWReflection.instanceOf(component, "com.sun.javafx.newt.kd.KDWindow")) {
+ if (NWReflection.instanceOf(component, "com.sun.javafx.newt.opengl.kd.KDWindow")) {
// KDWindows holds already determined EGL values
display = component.getDisplayHandle();
if (display==0) {
@@ -101,11 +101,10 @@ public class EGLDrawable extends GLDrawableImpl {
if (display == EGL.EGL_NO_DISPLAY) {
throw new GLException("KDWindow has EGL_NO_DISPLAY");
}
- Long setConfigID = new Long(component.getVisualID());
- if ( 0 <= setConfigID.longValue() && setConfigID.longValue() <= Integer.MAX_VALUE ) {
- config = new EGLConfig(display, setConfigID.intValue());
- } else {
- throw new GLException("KDWindow has invalid visualID/configID");
+ EGLConfig config = (EGLConfig) component.getGraphicsConfiguration();
+ int configID = 0;
+ if (config != null) {
+ configID = config.getNativeConfigID();
}
} else {
display = EGL.eglGetDisplay((0!=component.getDisplayHandle())?component.getDisplayHandle():EGL.EGL_DEFAULT_DISPLAY);
@@ -115,9 +114,9 @@ public class EGLDrawable extends GLDrawableImpl {
if (!EGL.eglInitialize(display, null, null)) {
throw new GLException("eglInitialize failed");
}
- config = new EGLConfig(display, getRequestedNWCapabilities());
+ config = new EGLConfig(display, getRequestedGLCapabilities());
}
- setChosenNWCapabilities(config.getCapabilities());
+ setChosenGLCapabilities(config.getCapabilities());
} else if (surface != EGL.EGL_NO_SURFACE) {
// Destroy the window surface
if (!EGL.eglDestroySurface(display, surface)) {
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 332a0a815..b73cfbd3e 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
@@ -117,23 +117,23 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
}
- public AbstractGraphicsConfiguration chooseGraphicsConfiguration(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
+ public AbstractGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
AbstractGraphicsDevice device) {
return null;
}
public GLDrawable createGLDrawable(NativeWindow target,
- NWCapabilities capabilities,
- NWCapabilitiesChooser chooser) {
+ GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser) {
target = NativeWindowFactory.getNativeWindow(target);
return new EGLDrawable(this, target,
capabilities,
chooser);
}
- public GLDrawableImpl createOffscreenDrawable(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
+ public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
int width,
int height) {
throw new GLException("Not yet implemented");
@@ -143,8 +143,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
// Not supported on OpenGL ES
return false;
}
- public GLPbuffer createGLPbuffer(final NWCapabilities capabilities,
- final NWCapabilitiesChooser chooser,
+ public GLPbuffer createGLPbuffer(final GLCapabilities capabilities,
+ final GLCapabilitiesChooser chooser,
final int initialWidth,
final int initialHeight,
final GLContext shareWith) {
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 4e4c2e329..62bacdda1 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
@@ -111,7 +111,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
}
int[] viewNotReady = new int[1];
- NWCapabilities capabilities = drawable.getRequestedNWCapabilities();
+ GLCapabilities capabilities = drawable.getRequestedGLCapabilities();
int[] iattribs = new int[128];
int[] ivalues = new int[128];
int idx = 0;
@@ -140,7 +140,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
long pixelFormat = CGL.createPixelFormat(iattribs, 0, idx, ivalues, 0);
if (pixelFormat == 0) {
- throw new GLException("Unable to allocate pixel format with requested NWCapabilities");
+ throw new GLException("Unable to allocate pixel format with requested GLCapabilities");
}
try {
// Try to allocate a context with this
@@ -168,10 +168,10 @@ public abstract class MacOSXCGLContext extends GLContextImpl
// context and not the drawable. However it's a reasonable
// approximation to just store the chosen pixel format up in the
// drawable since the public API doesn't provide for a different
- // NWCapabilities per context.
- if (drawable.getChosenNWCapabilities() == null) {
+ // GLCapabilities per context.
+ if (drawable.getChosenGLCapabilities() == null) {
// Figure out what attributes we really got
- NWCapabilities caps = new NWCapabilities();
+ GLCapabilities caps = new GLCapabilities();
CGL.queryPixelFormat(pixelFormat, iattribs, 0, idx, ivalues, 0);
for (int i = 0; i < idx; i++) {
int attr = iattribs[i];
@@ -235,7 +235,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
}
- drawable.setChosenNWCapabilities(caps);
+ drawable.setChosenGLCapabilities(caps);
}
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 67358878e..7dc94b74d 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
@@ -46,7 +46,7 @@ import com.sun.opengl.impl.*;
public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
protected static final boolean DEBUG = Debug.debug("MacOSXCGLDrawable");
- protected NWCapabilitiesChooser chooser;
+ protected GLCapabilitiesChooser chooser;
// The Java2D/OpenGL pipeline on OS X uses low-level CGLContextObjs
// to represent the contexts for e.g. the Java2D back buffer. When
@@ -82,18 +82,18 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
public static final int CGL_MODE = 2;
public MacOSXCGLDrawable(GLDrawableFactory factory, NativeWindow comp, boolean realized,
- NWCapabilities requestedCapabilities, NWCapabilitiesChooser chooser) {
+ GLCapabilities requestedCapabilities, GLCapabilitiesChooser chooser) {
super(factory, comp, requestedCapabilities, realized);
this.chooser = chooser;
}
// These are public to allow access from a couple of context implementations
- public void setChosenNWCapabilities(NWCapabilities caps) {
- super.setChosenNWCapabilities(caps);
+ public void setChosenGLCapabilities(GLCapabilities caps) {
+ super.setChosenGLCapabilities(caps);
}
- public NWCapabilities getRequestedNWCapabilities() {
- return super.getRequestedNWCapabilities();
+ public GLCapabilities getRequestedGLCapabilities() {
+ return super.getRequestedGLCapabilities();
}
protected static String getThreadName() {
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 318b6b123..2868a0899 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
@@ -51,30 +51,24 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
super();
}
- public AbstractGraphicsConfiguration chooseGraphicsConfiguration(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
- AbstractGraphicsDevice device) {
- return null;
- }
-
public GLDrawable createGLDrawable(NativeWindow target,
- NWCapabilities capabilities,
- NWCapabilitiesChooser chooser) {
+ GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
target = NativeWindowFactory.getNativeWindow(target);
if (capabilities == null) {
- capabilities = new NWCapabilities();
+ capabilities = new GLCapabilities();
}
if (chooser == null) {
- chooser = new DefaultNWCapabilitiesChooser();
+ chooser = new DefaultGLCapabilitiesChooser();
}
return new MacOSXOnscreenCGLDrawable(this, target, capabilities, chooser);
}
- public GLDrawableImpl createOffscreenDrawable(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
+ public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
int width,
int height) {
return new MacOSXOffscreenCGLDrawable(this, capabilities, width, height);
@@ -84,8 +78,8 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
return true;
}
- public GLPbuffer createGLPbuffer(final NWCapabilities capabilities,
- final NWCapabilitiesChooser chooser,
+ public GLPbuffer createGLPbuffer(final GLCapabilities capabilities,
+ final GLCapabilitiesChooser chooser,
final int initialWidth,
final int initialHeight,
final GLContext shareWith) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java
index 42eab51a1..ee469b71f 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOffscreenCGLDrawable.java
@@ -46,7 +46,7 @@ import com.sun.opengl.impl.*;
public class MacOSXOffscreenCGLDrawable extends MacOSXPbufferCGLDrawable {
public MacOSXOffscreenCGLDrawable(GLDrawableFactory factory,
- NWCapabilities capabilities,
+ GLCapabilities capabilities,
int width,
int height) {
super(factory, capabilities, width, height);
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 42e3957c2..12fc7c3ad 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
@@ -52,8 +52,8 @@ public class MacOSXOnscreenCGLDrawable extends MacOSXCGLDrawable {
new ArrayList();
protected MacOSXOnscreenCGLDrawable(GLDrawableFactory factory, NativeWindow component,
- NWCapabilities capabilities,
- NWCapabilitiesChooser chooser) {
+ GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser) {
super(factory, component, false, capabilities, chooser);
}
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 7141778ae..f8241af0d 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
@@ -81,7 +81,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
// Initialize render-to-texture support if requested
GL gl = getGL();
- boolean rect = gl.isGL2() && drawable.getRequestedNWCapabilities().getPbufferRenderToTextureRectangle();
+ boolean rect = gl.isGL2() && drawable.getRequestedGLCapabilities().getPbufferRenderToTextureRectangle();
if (rect) {
if (!gl.isExtensionAvailable("GL_EXT_texture_rectangle")) {
System.err.println("MacOSXPbufferCGLContext: WARNING: GL_EXT_texture_rectangle extension not " +
@@ -136,7 +136,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
}
protected boolean create() {
- NWCapabilities capabilities = drawable.getRequestedNWCapabilities();
+ GLCapabilities capabilities = drawable.getRequestedGLCapabilities();
if (capabilities.getPbufferFloatingPointBuffers() &&
!isTigerOrLater) {
throw new GLException("Floating-point pbuffers supported only on OS X 10.4 or later");
@@ -211,7 +211,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
// NSOpenGLContext-based implementation
class NSOpenGLImpl implements Impl {
public long create() {
- NWCapabilities capabilities = drawable.getRequestedNWCapabilities();
+ GLCapabilities capabilities = drawable.getRequestedGLCapabilities();
if (capabilities.getPbufferFloatingPointBuffers() &&
!isTigerOrLater) {
throw new GLException("Floating-point pbuffers supported only on OS X 10.4 or later");
@@ -266,7 +266,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
int[] attrs = new int[256];
int i = 0;
attrs[i++] = CGL.kCGLPFAPBuffer;
- NWCapabilities capabilities = drawable.getRequestedNWCapabilities();
+ GLCapabilities capabilities = drawable.getRequestedGLCapabilities();
if (capabilities.getPbufferFloatingPointBuffers())
attrs[i++] = CGL.kCGLPFAColorFloat;
if (capabilities.getDoubleBuffered())
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 6be7392b0..d8dea7595 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
@@ -57,7 +57,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
// semantic is that contains an NSView
protected long pBuffer;
- public MacOSXPbufferCGLDrawable(GLDrawableFactory factory, NWCapabilities capabilities, int width, int height) {
+ public MacOSXPbufferCGLDrawable(GLDrawableFactory factory, GLCapabilities capabilities, int width, int height) {
super(factory, new NullWindow(), true, capabilities, null);
NullWindow nw = (NullWindow) getNativeWindow();
nw.setSize(width, height);
@@ -90,7 +90,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
private void createPbuffer() {
NullWindow nw = (NullWindow) getNativeWindow();
int renderTarget;
- NWCapabilities capabilities = getRequestedNWCapabilities();
+ GLCapabilities capabilities = getRequestedGLCapabilities();
if (GLProfile.isGL2() && capabilities.getPbufferRenderToTextureRectangle()) {
renderTarget = GL2.GL_TEXTURE_RECTANGLE;
} else {
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
index 619d28720..9bdc42087 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
@@ -48,7 +48,7 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
private long hwnd, hdc;
public WindowsDummyWGLDrawable(GLDrawableFactory factory) {
- super(factory, new NullWindow(), true, new NWCapabilities(), null);
+ super(factory, new NullWindow(), true, new GLCapabilities(), null);
// All entries to CreateDummyWindow must synchronize on one object
// to avoid accidentally registering the dummy window class twice
synchronized (WindowsDummyWGLDrawable.class) {
@@ -58,7 +58,7 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
NullWindow nw = (NullWindow) getNativeWindow();
nw.setSurfaceHandle(hdc);
// Choose a (hopefully hardware-accelerated) OpenGL pixel format for this device context
- NWCapabilities caps = new NWCapabilities();
+ GLCapabilities caps = new GLCapabilities();
caps.setDepthBits(16);
PIXELFORMATDESCRIPTOR pfd = glCapabilities2PFD(caps, true);
int pixelFormat = WGL.ChoosePixelFormat(hdc, pfd);
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 9de51e04c..78b06307a 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
@@ -47,7 +47,7 @@ import com.sun.nativewindow.impl.NullWindow;
public class WindowsExternalWGLDrawable extends WindowsWGLDrawable {
public WindowsExternalWGLDrawable(GLDrawableFactory factory, NativeWindow component) {
- super(factory, component, true, new NWCapabilities(), null);
+ super(factory, component, true, new GLCapabilities(), null);
}
public static WindowsExternalWGLDrawable create(GLDrawableFactory factory) {
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 979362780..efea5842f 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
@@ -49,8 +49,8 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
private long hbitmap;
public WindowsOffscreenWGLDrawable(GLDrawableFactory factory,
- NWCapabilities requestedCapabilities,
- NWCapabilitiesChooser chooser,
+ GLCapabilities requestedCapabilities,
+ GLCapabilitiesChooser chooser,
int width,
int height) {
super(factory, new NullWindow(), true, requestedCapabilities, chooser);
@@ -64,7 +64,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
private void create() {
NullWindow nw = (NullWindow) getNativeWindow();
- NWCapabilities capabilities = getRequestedNWCapabilities();
+ GLCapabilities capabilities = getRequestedGLCapabilities();
int width = getWidth();
int height = getHeight();
BITMAPINFO info = BITMAPINFO.create();
@@ -122,7 +122,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
origbitmap = 0;
hbitmap = 0;
nw.setSurfaceHandle(0);
- setChosenNWCapabilities(null);
+ setChosenGLCapabilities(null);
}
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java
index ef9bf49c1..368462d6b 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java
@@ -54,8 +54,8 @@ public class WindowsOnscreenWGLDrawable extends WindowsWGLDrawable {
private long profilingSwapBuffersTime;
protected WindowsOnscreenWGLDrawable(GLDrawableFactory factory, NativeWindow component,
- NWCapabilities capabilities,
- NWCapabilitiesChooser chooser) {
+ GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser) {
super(factory, component, false, capabilities, chooser);
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java
index 87921f7e0..19c0d9d9c 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java
@@ -63,7 +63,7 @@ public class WindowsPbufferWGLContext extends WindowsWGLContext {
public void bindPbufferToTexture() {
if (!rtt) {
throw new GLException("Shouldn't try to bind a pbuffer to a texture if render-to-texture hasn't been " +
- "specified in its NWCapabilities");
+ "specified in its GLCapabilities");
}
GL gl = getGL();
WGLExt wglExt = getWGLExt();
@@ -81,7 +81,7 @@ public class WindowsPbufferWGLContext extends WindowsWGLContext {
public void releasePbufferFromTexture() {
if (!rtt) {
throw new GLException("Shouldn't try to bind a pbuffer to a texture if render-to-texture hasn't been " +
- "specified in its NWCapabilities");
+ "specified in its GLCapabilities");
}
if (rtt && hasRTT) {
WGLExt wglExt = getWGLExt();
@@ -97,7 +97,7 @@ public class WindowsPbufferWGLContext extends WindowsWGLContext {
System.err.println("WindowsPbufferWGLContext: super.makeCurrentImpl() = " + res);
}
if (res == CONTEXT_CURRENT_NEW) {
- NWCapabilities capabilities = drawable.getRequestedNWCapabilities();
+ GLCapabilities capabilities = drawable.getRequestedGLCapabilities();
// Initialize render-to-texture support if requested
GL gl = getGL();
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 c829cca63..f0c0503e1 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
@@ -53,7 +53,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
private int floatMode;
public WindowsPbufferWGLDrawable(GLDrawableFactory factory,
- NWCapabilities requestedCapabilities,
+ GLCapabilities requestedCapabilities,
int width,
int height,
WindowsWGLDrawable dummyDrawable,
@@ -96,7 +96,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
throw new GLException("Error destroying pbuffer: error code " + WGL.GetLastError());
}
buffer = 0;
- setChosenNWCapabilities(null);
+ setChosenGLCapabilities(null);
}
}
@@ -126,8 +126,8 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
}
// This is public to allow access from PbufferContext
- public NWCapabilities getRequestedNWCapabilities() {
- return super.getRequestedNWCapabilities();
+ public GLCapabilities getRequestedGLCapabilities() {
+ return super.getRequestedGLCapabilities();
}
private void createPbuffer(long parentHdc, WGLExt wglExt) {
@@ -137,7 +137,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
int niattribs = 0;
int width, height;
- NWCapabilities capabilities = getRequestedNWCapabilities();
+ GLCapabilities capabilities = getRequestedGLCapabilities();
if (DEBUG) {
System.out.println("Pbuffer parentHdc = " + toHexString(parentHdc));
@@ -309,7 +309,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
int[] ivalues = new int[niattribs];
// FIXME: usually prefer to throw exceptions, but failure here is not critical
if (wglExt.wglGetPixelFormatAttribiv(parentHdc, pformats[whichFormat], 0, niattribs, iattributes, 0, ivalues, 0)) {
- setChosenNWCapabilities(iattributes2NWCapabilities(iattributes, niattribs, ivalues, false));
+ setChosenGLCapabilities(iattributes2GLCapabilities(iattributes, niattribs, ivalues, false));
}
}
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 534b0adf0..1885de1db 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
@@ -46,7 +46,7 @@ import com.sun.opengl.impl.*;
public abstract class WindowsWGLDrawable extends GLDrawableImpl {
protected static final boolean DEBUG = Debug.debug("WindowsWGLDrawable");
- protected NWCapabilitiesChooser chooser;
+ protected GLCapabilitiesChooser chooser;
protected boolean pixelFormatChosen;
// Workaround for problems on Intel 82855 cards
@@ -57,8 +57,8 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
protected static final int MAX_ATTRIBS = 256;
public WindowsWGLDrawable(GLDrawableFactory factory, NativeWindow comp, boolean realized,
- NWCapabilities requestedCapabilities,
- NWCapabilitiesChooser chooser) {
+ GLCapabilities requestedCapabilities,
+ GLCapabilitiesChooser chooser) {
super(factory, comp, requestedCapabilities, realized);
this.chooser = chooser;
}
@@ -90,7 +90,7 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
}
return NativeWindow.LOCK_SURFACE_NOT_READY;
} else {
- // Probably a user error in the NWCapabilitiesChooser or similar.
+ // Probably a user error in the GLCapabilitiesChooser or similar.
// Don't propagate non-GLExceptions out because calling code
// expects to catch only that exception type
throw new GLException(e);
@@ -104,8 +104,8 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
protected void choosePixelFormat(boolean onscreen) {
PIXELFORMATDESCRIPTOR pfd = null;
int pixelFormat = 0;
- NWCapabilities chosenCaps = null;
- NWCapabilities capabilities = getRequestedNWCapabilities();
+ GLCapabilities chosenCaps = null;
+ GLCapabilities capabilities = getRequestedGLCapabilities();
long hdc = getNativeWindow().getSurfaceHandle();
if (onscreen) {
if ((pixelFormat = WGL.GetPixelFormat(hdc)) != 0) {
@@ -121,15 +121,15 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
throw new GLException("Unable to describe pixel format " + pixelFormat +
" of window set by Java2D/OpenGL pipeline");
}
- setChosenNWCapabilities(pfd2NWCapabilities(pfd));
+ setChosenGLCapabilities(pfd2GLCapabilities(pfd));
pixelFormatChosen = true;
return;
}
- NWCapabilities[] availableCaps = null;
+ GLCapabilities[] availableCaps = null;
int numFormats = 0;
pfd = newPixelFormatDescriptor();
- // Produce a recommended pixel format selection for the NWCapabilitiesChooser.
+ // Produce a recommended pixel format selection for the GLCapabilitiesChooser.
// Use wglChoosePixelFormatARB if user requested multisampling and if we have it available
WindowsWGLDrawable dummyDrawable = null;
GLContextImpl dummyContext = null;
@@ -187,17 +187,17 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
if (recommendedPixelFormat < 0) {
System.err.print(getThreadName() + ": wglChoosePixelFormatARB didn't recommend a pixel format");
if (capabilities.getSampleBuffers()) {
- System.err.print(" for multisampled NWCapabilities");
+ System.err.print(" for multisampled GLCapabilities");
}
System.err.println();
}
}
- // Produce a list of NWCapabilities to give to the
- // NWCapabilitiesChooser.
+ // 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 NWCapabilities
+ // 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
@@ -213,7 +213,7 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
// 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 NWCapabilities to
+ // We don't have enough information in the GLCapabilities to
// represent those that aren't...
iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_WINDOW;
iattributes[niattribs++] = WGLExt.WGL_ACCELERATION;
@@ -236,12 +236,12 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
iattributes[niattribs++] = WGLExt.WGL_SAMPLES;
}
- availableCaps = new NWCapabilities[numFormats];
+ availableCaps = new GLCapabilities[numFormats];
for (int i = 0; i < numFormats; i++) {
if (!dummyWGLExt.wglGetPixelFormatAttribiv(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] = iattributes2NWCapabilities(iattributes, niattribs, iresults, true);
+ availableCaps[i] = iattributes2GLCapabilities(iattributes, niattribs, iresults, true);
}
gotAvailableCaps = true;
} else {
@@ -279,27 +279,31 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
numFormats = WGL.DescribePixelFormat(hdc, 1, 0, null);
if (numFormats == 0) {
throw new GLException("Unable to enumerate pixel formats of window " +
- toHexString(hdc) + " for NWCapabilitiesChooser");
+ toHexString(hdc) + " for GLCapabilitiesChooser");
}
- availableCaps = new NWCapabilities[numFormats];
+ availableCaps = new GLCapabilities[numFormats];
for (int i = 0; i < numFormats; i++) {
if (WGL.DescribePixelFormat(hdc, 1 + i, pfd.size(), pfd) == 0) {
throw new GLException("Error describing pixel format " + (1 + i) + " of device context");
}
- availableCaps[i] = pfd2NWCapabilities(pfd);
+ availableCaps[i] = pfd2GLCapabilities(pfd);
}
}
// NOTE: officially, should make a copy of all of these
- // NWCapabilities to avoid mutation by the end user during the
+ // GLCapabilities to avoid mutation by the end user during the
// chooseCapabilities call, but for the time being, assume they
// won't be changed
// Supply information to chooser
- pixelFormat = chooser.chooseCapabilities(capabilities, availableCaps, recommendedPixelFormat);
+ try {
+ pixelFormat = chooser.chooseCapabilities(capabilities, availableCaps, recommendedPixelFormat);
+ } catch (NativeWindowException e) {
+ throw new GLException(e);
+ }
if ((pixelFormat < 0) || (pixelFormat >= numFormats)) {
throw new GLException("Invalid result " + pixelFormat +
- " from NWCapabilitiesChooser (should be between 0 and " +
+ " from GLCapabilitiesChooser (should be between 0 and " +
(numFormats - 1) + ")");
}
if (DEBUG) {
@@ -327,19 +331,19 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
}
throw new GLException("Unable to set pixel format " + pixelFormat + " for device context " + toHexString(hdc) + ": error code " + lastError);
}
- // Reuse the previously-constructed NWCapabilities because it
+ // Reuse the previously-constructed GLCapabilities because it
// turns out that using DescribePixelFormat on some pixel formats
// (which, for example, support full-scene antialiasing) for some
// reason return that they are not OpenGL-capable
if (chosenCaps != null) {
- setChosenNWCapabilities(chosenCaps);
+ setChosenGLCapabilities(chosenCaps);
} else {
- setChosenNWCapabilities(pfd2NWCapabilities(pfd));
+ setChosenGLCapabilities(pfd2GLCapabilities(pfd));
}
pixelFormatChosen = true;
}
- protected static PIXELFORMATDESCRIPTOR glCapabilities2PFD(NWCapabilities caps, boolean onscreen) {
+ protected static PIXELFORMATDESCRIPTOR glCapabilities2PFD(GLCapabilities caps, boolean onscreen) {
int colorDepth = (caps.getRedBits() +
caps.getGreenBits() +
caps.getBlueBits());
@@ -388,11 +392,11 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
return pfd;
}
- protected static NWCapabilities pfd2NWCapabilities(PIXELFORMATDESCRIPTOR pfd) {
+ protected static GLCapabilities pfd2GLCapabilities(PIXELFORMATDESCRIPTOR pfd) {
if ((pfd.dwFlags() & WGL.PFD_SUPPORT_OPENGL) == 0) {
return null;
}
- NWCapabilities res = new NWCapabilities();
+ GLCapabilities res = new GLCapabilities();
res.setRedBits (pfd.cRedBits());
res.setGreenBits (pfd.cGreenBits());
res.setBlueBits (pfd.cBlueBits());
@@ -410,7 +414,7 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
return res;
}
- protected static boolean glCapabilities2iattributes(NWCapabilities capabilities,
+ protected static boolean glCapabilities2iattributes(GLCapabilities capabilities,
int[] iattributes,
WGLExt wglExt,
boolean pbuffer,
@@ -532,7 +536,7 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
} else {
if (!rtt) {
// Currently we don't support non-truecolor visuals in the
- // NWCapabilities, so we don't offer the option of making
+ // GLCapabilities, so we don't offer the option of making
// color-index pbuffers.
iattributes[niattribs++] = WGLExt.WGL_PIXEL_TYPE;
iattributes[niattribs++] = WGLExt.WGL_TYPE_RGBA;
@@ -565,11 +569,11 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
return true;
}
- protected static NWCapabilities iattributes2NWCapabilities(int[] iattribs,
+ protected static GLCapabilities iattributes2GLCapabilities(int[] iattribs,
int niattribs,
int[] iresults,
boolean requireRenderToWindow) {
- NWCapabilities res = new NWCapabilities();
+ GLCapabilities res = new GLCapabilities();
for (int i = 0; i < niattribs; i++) {
int attr = iattribs[i];
switch (attr) {
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 d5dd930ed..10d7c5a22 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
@@ -58,30 +58,24 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
super();
}
- public AbstractGraphicsConfiguration chooseGraphicsConfiguration(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
- AbstractGraphicsDevice device) {
- return null;
- }
-
public GLDrawable createGLDrawable(NativeWindow target,
- NWCapabilities capabilities,
- NWCapabilitiesChooser chooser) {
+ GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
target = NativeWindowFactory.getNativeWindow(target);
if (capabilities == null) {
- capabilities = new NWCapabilities();
+ capabilities = new GLCapabilities();
}
if (chooser == null) {
- chooser = new DefaultNWCapabilitiesChooser();
+ chooser = new DefaultGLCapabilitiesChooser();
}
return new WindowsOnscreenWGLDrawable(this, target, capabilities, chooser);
}
- public GLDrawableImpl createOffscreenDrawable(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
+ public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
int width,
int height) {
return new WindowsOffscreenWGLDrawable(this, capabilities, chooser, width, height);
@@ -122,8 +116,8 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
return canCreateGLPbuffer;
}
- public GLPbuffer createGLPbuffer(final NWCapabilities capabilities,
- final NWCapabilitiesChooser chooser,
+ public GLPbuffer createGLPbuffer(final GLCapabilities capabilities,
+ final GLCapabilitiesChooser chooser,
final int initialWidth,
final int initialHeight,
final GLContext shareWith) {
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 2f1f777c9..0b916213c 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
@@ -47,11 +47,11 @@ import com.sun.nativewindow.impl.x11.*;
public abstract class X11GLXDrawable extends GLDrawableImpl {
protected static final boolean DEBUG = Debug.debug("X11GLXDrawable");
- protected NWCapabilitiesChooser chooser;
+ protected GLCapabilitiesChooser chooser;
protected X11GLXDrawable(GLDrawableFactory factory, NativeWindow comp, boolean realized,
- NWCapabilities requestedCapabilities,
- NWCapabilitiesChooser chooser) {
+ GLCapabilities requestedCapabilities,
+ GLCapabilitiesChooser chooser) {
super(factory, comp, requestedCapabilities, realized);
this.chooser = chooser;
}
@@ -62,7 +62,7 @@ public abstract class X11GLXDrawable extends GLDrawableImpl {
protected XVisualInfo chooseVisual(boolean onscreen) {
long display = getNativeWindow().getDisplayHandle();
- long visualID = getNativeWindow().getVisualID();
+ long visualID = ((X11GLXDrawableFactory) getFactory()).getVisualID(getNativeWindow().getGraphicsConfiguration());
if (display == 0) {
throw new GLException("null display");
}
@@ -105,24 +105,29 @@ public abstract class X11GLXDrawable extends GLDrawableImpl {
XVisualInfo template = XVisualInfo.create();
template.screen(screen);
XVisualInfo[] infos = null;
- NWCapabilities[] caps = null;
+ GLCapabilities[] caps = null;
getFactoryImpl().lockToolkit();
try {
infos = X11Lib.XGetVisualInfo(display, X11Lib.VisualScreenMask, template, count, 0);
if (infos == null) {
throw new GLException("Error while enumerating available XVisualInfos");
}
- caps = new NWCapabilities[infos.length];
+ caps = new GLCapabilities[infos.length];
for (int i = 0; i < infos.length; i++) {
- caps[i] = ((X11GLXDrawableFactory)getFactory()).xvi2NWCapabilities(display, infos[i]);
+ caps[i] = ((X11GLXDrawableFactory)getFactory()).xvi2GLCapabilities(display, infos[i]);
}
} finally {
getFactoryImpl().unlockToolkit();
}
- NWCapabilities capabilities = getRequestedNWCapabilities();
- int chosen = chooser.chooseCapabilities(capabilities, caps, -1);
+ GLCapabilities capabilities = getRequestedGLCapabilities();
+ int chosen;
+ try {
+ chosen = chooser.chooseCapabilities(capabilities, caps, -1);
+ } catch (NativeWindowException e) {
+ throw new GLException(e);
+ }
if (chosen < 0 || chosen >= caps.length) {
- throw new GLException("NWCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
+ throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
}
if (DEBUG) {
System.err.println("Chosen visual (" + chosen + "):");
@@ -130,7 +135,7 @@ public abstract class X11GLXDrawable extends GLDrawableImpl {
}
vis = infos[chosen];
if (vis == null) {
- throw new GLException("NWCapabilitiesChooser chose an invalid visual");
+ throw new GLException("GLCapabilitiesChooser chose an invalid visual");
}
// FIXME: the storage for the infos array is leaked (should
// clean it up somehow when we're done with the visual we're
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 a0c3a7758..3ca1396d2 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
@@ -40,18 +40,21 @@ import java.nio.*;
import java.security.*;
import java.util.*;
import javax.media.nativewindow.*;
+import javax.media.nativewindow.x11.*;
import javax.media.opengl.*;
import com.sun.gluegen.runtime.*;
import com.sun.gluegen.runtime.opengl.*;
import com.sun.opengl.impl.*;
import com.sun.opengl.impl.x11.glx.*;
import com.sun.nativewindow.impl.NullWindow;
+import com.sun.nativewindow.impl.NWReflection;
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");
- // Map for rediscovering the NWCapabilities associated with a
+ // Map for rediscovering the GLCapabilities associated with a
// particular screen and visualID after the fact
protected static Map visualToGLCapsMap = Collections.synchronizedMap(new HashMap());
// The screens for which we've already initialized it
@@ -90,19 +93,27 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
// Must initialize GLX support eagerly in case a pbuffer is the
// first thing instantiated
GLProcAddressHelper.resetProcAddressTable(GLX.getGLXProcAddressTable(), this);
+ // Register our GraphicsConfigurationFactory implementations
+ // The act of constructing them causes them to be registered
+ new X11GLXGraphicsConfigurationFactory();
+ try {
+ NWReflection.createInstance("com.sun.opengl.impl.x11.glx.awt.X11AWTGLXGraphicsConfigurationFactory",
+ new Object[] {});
+ } catch (Exception e) {
+ }
}
private static final int MAX_ATTRIBS = 128;
- public AbstractGraphicsConfiguration chooseGraphicsConfiguration(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
+ public AbstractGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
AbstractGraphicsDevice absDevice) {
return null;
}
public GLDrawable createGLDrawable(NativeWindow target,
- NWCapabilities capabilities,
- NWCapabilitiesChooser chooser) {
+ GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
@@ -110,9 +121,9 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
return new X11OnscreenGLXDrawable(this, target);
}
- public void initializeVisualToNWCapabilitiesMap(int screen,
+ public void initializeVisualToGLCapabilitiesMap(int screen,
XVisualInfo[] infos,
- NWCapabilities[] caps) {
+ GLCapabilities[] caps) {
Integer key = new Integer(screen);
if (!initializedScreenSet.contains(key)) {
for (int i = 0; i < infos.length; i++) {
@@ -125,13 +136,32 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
}
- public NWCapabilities lookupCapabilitiesByScreenAndVisualID(int screenIndex,
- long visualID) {
- return (NWCapabilities) visualToGLCapsMap.get(new ScreenAndVisualIDKey(screenIndex, visualID));
+ public GLCapabilities lookupCapabilitiesByScreenAndConfig(int screenIndex,
+ AbstractGraphicsConfiguration config) {
+ return (GLCapabilities) visualToGLCapsMap.get(new ScreenAndVisualIDKey(screenIndex, getVisualID(config)));
+ }
+
+ public long getVisualID(AbstractGraphicsConfiguration config) {
+ if (config == null) {
+ return 0;
+ }
+ // FIXME: this is hopefully the last remaining place in this
+ // implementation that is over-specialized; third-party toolkits
+ // would need to use the X11GraphicsConfiguration in order to
+ // interoperate with this code
+ if (config instanceof X11GraphicsConfiguration) {
+ return ((X11GraphicsConfiguration) config).getVisualID();
+ }
+ try {
+ // The AWT-specific code and casts have been moved to the X11SunJDKReflection helper class
+ return X11SunJDKReflection.graphicsConfigurationGetVisualID(config);
+ } catch (Throwable t) {
+ return 0;
+ }
}
- public GLDrawableImpl createOffscreenDrawable(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
+ public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
int width,
int height) {
return new X11OffscreenGLXDrawable(this, capabilities, chooser, width, height);
@@ -181,8 +211,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
return canCreateGLPbuffer;
}
- public GLPbuffer createGLPbuffer(final NWCapabilities capabilities,
- final NWCapabilitiesChooser chooser,
+ public GLPbuffer createGLPbuffer(final GLCapabilities capabilities,
+ final GLCapabilitiesChooser chooser,
final int initialWidth,
final int initialHeight,
final GLContext shareWith) {
@@ -230,7 +260,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
return res;
}
- public NWCapabilities xvi2NWCapabilities(long display, XVisualInfo info) {
+ public GLCapabilities xvi2GLCapabilities(long display, XVisualInfo info) {
int[] tmp = new int[1];
int val = glXGetConfig(display, info, GLX.GLX_USE_GL, tmp, 0);
if (val == 0) {
@@ -242,12 +272,12 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
// Visual does not support RGBA
return null;
}
- NWCapabilities res = new NWCapabilities();
+ GLCapabilities res = new GLCapabilities();
res.setDoubleBuffered(glXGetConfig(display, info, GLX.GLX_DOUBLEBUFFER, tmp, 0) != 0);
res.setStereo (glXGetConfig(display, info, GLX.GLX_STEREO, tmp, 0) != 0);
// Note: use of hardware acceleration is determined by
// glXCreateContext, not by the XVisualInfo. Optimistically claim
- // that all NWCapabilities have the capability to be hardware
+ // that all GLCapabilities have the capability to be hardware
// accelerated.
res.setHardwareAccelerated(true);
res.setDepthBits (glXGetConfig(display, info, GLX.GLX_DEPTH_SIZE, tmp, 0));
@@ -267,7 +297,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
return res;
}
- public static int[] glCapabilities2AttribList(NWCapabilities caps,
+ public static int[] glCapabilities2AttribList(GLCapabilities caps,
boolean isMultisampleAvailable,
boolean pbuffer,
long display,
@@ -357,11 +387,11 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
return res;
}
- public static NWCapabilities attribList2NWCapabilities(int[] iattribs,
+ public static GLCapabilities attribList2GLCapabilities(int[] iattribs,
int niattribs,
int[] ivalues,
boolean pbuffer) {
- NWCapabilities caps = new NWCapabilities();
+ GLCapabilities caps = new GLCapabilities();
for (int i = 0; i < niattribs; i++) {
int attr = iattribs[i];
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXNativeWindowFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 3944f4180..8120dca52 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXNativeWindowFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -43,44 +43,58 @@ import javax.media.opengl.*;
import com.sun.opengl.impl.*;
import com.sun.opengl.impl.x11.glx.*;
-/** Subclass of NativeWindowFactory used when non-AWT tookits are used
- on X11 platforms. Toolkits will likely need to subclass this one
- to add synchronization in certain places and change the accepted
- and returned types of the GraphicsDevice and GraphicsConfiguration
- abstractions. */
-
-public class X11GLXNativeWindowFactory extends NativeWindowFactoryImpl {
-
- public X11GLXNativeWindowFactory() {
- NativeWindowFactory.registerFactory(javax.media.nativewindow.NativeWindow.class, this);
+/** Subclass of GraphicsConfigurationFactory used when non-AWT tookits
+ are used on X11 platforms. Toolkits will likely need to delegate
+ to this one to change the accepted and returned types of the
+ GraphicsDevice and GraphicsConfiguration abstractions. */
+
+public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFactory {
+ // Keep this under the same debug flag as the drawable factory for convenience
+ protected static final boolean DEBUG = Debug.debug("X11GLXDrawableFactory");
+
+ public X11GLXGraphicsConfigurationFactory() {
+ GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.x11.X11GraphicsDevice.class,
+ this);
}
- public AbstractGraphicsConfiguration chooseGraphicsConfiguration(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
+ public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
+ CapabilitiesChooser chooser,
AbstractGraphicsDevice absDevice) {
if (absDevice != null &&
!(absDevice instanceof X11GraphicsDevice)) {
throw new IllegalArgumentException("This NativeWindowFactory accepts only X11GraphicsDevice objects");
}
+ if (capabilities != null &&
+ !(capabilities instanceof GLCapabilities)) {
+ throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects");
+ }
+
+ if (chooser != null &&
+ !(chooser instanceof GLCapabilitiesChooser)) {
+ throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects");
+ }
+
int screen = 0;
if (absDevice != null) {
screen = ((X11GraphicsDevice) absDevice).getScreen();
}
- long visualID = chooseGraphicsConfigurationImpl(capabilities, chooser, screen);
+ long visualID = chooseGraphicsConfigurationImpl((GLCapabilities) capabilities,
+ (GLCapabilitiesChooser) chooser,
+ screen);
return new X11GraphicsConfiguration(visualID);
}
/** Returns the visual ID of the chosen GraphicsConfiguration. */
- protected long chooseGraphicsConfigurationImpl(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
+ protected long chooseGraphicsConfigurationImpl(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
int screen) {
if (capabilities == null) {
- capabilities = new NWCapabilities();
+ capabilities = new GLCapabilities();
}
if (chooser == null) {
- chooser = new DefaultNWCapabilitiesChooser();
+ chooser = new DefaultGLCapabilitiesChooser();
}
if (X11Util.isXineramaEnabled()) {
@@ -93,9 +107,9 @@ public class X11GLXNativeWindowFactory extends NativeWindowFactoryImpl {
int[] attribs = X11GLXDrawableFactory.glCapabilities2AttribList(capabilities, GLXUtil.isMultisampleAvailable(), false, 0, 0);
XVisualInfo[] infos = null;
- NWCapabilities[] caps = null;
+ GLCapabilities[] caps = null;
int recommendedIndex = -1;
- getDefaultFactory().getToolkitLock().lock();
+ NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
try {
long display = X11Util.getDisplayConnection();
XVisualInfo recommendedVis = GLX.glXChooseVisual(display, screen, attribs, 0);
@@ -114,66 +128,33 @@ public class X11GLXNativeWindowFactory extends NativeWindowFactoryImpl {
if (infos == null) {
throw new GLException("Error while enumerating available XVisualInfos");
}
- caps = new NWCapabilities[infos.length];
+ caps = new GLCapabilities[infos.length];
for (int i = 0; i < infos.length; i++) {
- caps[i] = ((X11GLXDrawableFactory) GLDrawableFactory.getFactory()).xvi2NWCapabilities(display, infos[i]);
+ caps[i] = ((X11GLXDrawableFactory) GLDrawableFactory.getFactory()).xvi2GLCapabilities(display, infos[i]);
// Attempt to find the visual chosen by glXChooseVisual
if (recommendedVis != null && recommendedVis.visualid() == infos[i].visualid()) {
recommendedIndex = i;
}
}
} finally {
- getDefaultFactory().getToolkitLock().unlock();
+ NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
// Store these away for later
((X11GLXDrawableFactory) GLDrawableFactory.getFactory()).
- initializeVisualToNWCapabilitiesMap(screen, infos, caps);
- int chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
+ initializeVisualToGLCapabilitiesMap(screen, infos, caps);
+ int chosen;
+ try {
+ chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
+ } catch (NativeWindowException e) {
+ throw new GLException(e);
+ }
if (chosen < 0 || chosen >= caps.length) {
- throw new GLException("NWCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
+ throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
}
XVisualInfo vis = infos[chosen];
if (vis == null) {
- throw new GLException("NWCapabilitiesChooser chose an invalid visual");
+ throw new GLException("GLCapabilitiesChooser chose an invalid visual");
}
return vis.visualid();
}
-
- // On X11 platforms we need to do some locking; this basic
- // implementation should suffice for some simple window toolkits
- private ToolkitLock toolkitLock = new ToolkitLock() {
- private Thread owner;
- private int recursionCount;
-
- public synchronized void lock() {
- Thread cur = Thread.currentThread();
- if (owner == cur) {
- ++recursionCount;
- return;
- }
- while (owner != null) {
- try {
- wait();
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
- owner = cur;
- }
-
- public synchronized void unlock() {
- if (owner != Thread.currentThread()) {
- throw new RuntimeException("Not owner");
- }
- if (recursionCount > 0) {
- --recursionCount;
- return;
- }
- owner = null;
- }
- };
-
- public ToolkitLock getToolkitLock() {
- return toolkitLock;
- }
}
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 46712bced..63dcca80e 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
@@ -50,8 +50,8 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
private boolean isDoubleBuffered;
protected X11OffscreenGLXDrawable(GLDrawableFactory factory,
- NWCapabilities requestedCapabilities,
- NWCapabilitiesChooser chooser,
+ GLCapabilities requestedCapabilities,
+ GLCapabilitiesChooser chooser,
int width,
int height) {
super(factory, new NullWindow(), true, requestedCapabilities, chooser);
@@ -92,7 +92,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
", GLXPixmap " + toHexString(drawable) +
", display " + toHexString(dpy));
}
- setChosenNWCapabilities(((X11GLXDrawableFactory)getFactory()).xvi2NWCapabilities(dpy, vis));
+ setChosenGLCapabilities(((X11GLXDrawableFactory)getFactory()).xvi2GLCapabilities(dpy, vis));
} finally {
getFactoryImpl().unlockToolkit();
}
@@ -131,7 +131,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
drawable = 0;
pixmap = 0;
display = 0;
- setChosenNWCapabilities(null);
+ setChosenGLCapabilities(null);
} finally {
getFactoryImpl().unlockToolkit();
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXContext.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXContext.java
index 9da86205d..b4370e142 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXContext.java
@@ -61,11 +61,11 @@ public class X11OnscreenGLXContext extends X11GLXContext {
protected int makeCurrentImpl() throws GLException {
int lockRes = drawable.lockSurface();
- if (drawable.getChosenNWCapabilities() == null) {
+ if (drawable.getChosenGLCapabilities() == null) {
X11GLXDrawableFactory factory = (X11GLXDrawableFactory) drawable.getFactory();
NativeWindow window = drawable.getNativeWindow();
- drawable.setChosenNWCapabilities(factory.lookupCapabilitiesByScreenAndVisualID(window.getScreenIndex(),
- window.getVisualID()));
+ drawable.setChosenGLCapabilities(factory.lookupCapabilitiesByScreenAndConfig(window.getScreenIndex(),
+ window.getGraphicsConfiguration()));
}
boolean exceptionOccurred = false;
try {
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
index 5c1a5071c..4a22940b6 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
@@ -79,16 +79,16 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable {
}
// This is public to allow access from the DrawableFactory
- protected void setChosenNWCapabilities(NWCapabilities caps) {
- super.setChosenNWCapabilities(caps);
+ protected void setChosenGLCapabilities(GLCapabilities caps) {
+ super.setChosenGLCapabilities(caps);
}
public void setRealized(boolean realized) {
if (realized) {
X11GLXDrawableFactory factory = (X11GLXDrawableFactory) getFactory();
NativeWindow window = getNativeWindow();
- setChosenNWCapabilities(factory.lookupCapabilitiesByScreenAndVisualID(window.getScreenIndex(),
- window.getVisualID()));
+ setChosenGLCapabilities(factory.lookupCapabilitiesByScreenAndConfig(window.getScreenIndex(),
+ window.getGraphicsConfiguration()));
}
super.setRealized(realized);
}
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 99aebb4ed..91be786dd 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
@@ -56,7 +56,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
protected static final int MAX_ATTRIBS = 256;
protected X11PbufferGLXDrawable(GLDrawableFactory factory,
- NWCapabilities requestedCapabilities,
+ GLCapabilities requestedCapabilities,
int width, int height) {
super(factory, new NullWindow(), true, requestedCapabilities, null);
if (width <= 0 || height <= 0) {
@@ -106,7 +106,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
int screen = X11Lib.DefaultScreen(display);
nw.setScreenIndex(screen);
- NWCapabilities capabilities = getRequestedNWCapabilities();
+ GLCapabilities capabilities = getRequestedGLCapabilities();
if (capabilities.getPbufferRenderToTexture()) {
throw new GLException("Render-to-texture pbuffers not supported yet on X11");
@@ -174,7 +174,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
int samplesAttrib = GLXUtil.isMultisampleAvailable() ? GLX.GLX_SAMPLES: GLX.GLX_RED_SIZE;
int floatNV = capabilities.getPbufferFloatingPointBuffers() ? GLXExt.GLX_FLOAT_COMPONENTS_NV : GLX.GLX_RED_SIZE;
- // Query the fbconfig to determine its NWCapabilities
+ // Query the fbconfig to determine its GLCapabilities
int[] iattribs = {
GLX.GLX_DOUBLEBUFFER,
GLX.GLX_STEREO,
@@ -195,7 +195,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
int[] ivalues = new int[iattribs.length];
queryFBConfig(display, fbConfig, iattribs, iattribs.length, ivalues);
- setChosenNWCapabilities(X11GLXDrawableFactory.attribList2NWCapabilities(iattribs, iattribs.length, ivalues, true));
+ setChosenGLCapabilities(X11GLXDrawableFactory.attribList2GLCapabilities(iattribs, iattribs.length, ivalues, true));
// Determine the actual width and height we were able to create.
int[] tmp = new int[1];
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXNativeWindowFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
index 4029d90bd..0d75056c4 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXNativeWindowFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
@@ -36,8 +36,10 @@ import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import javax.media.nativewindow.*;
-import javax.media.nativewindow.awt.AWTGraphicsDevice;
+import javax.media.nativewindow.x11.X11GraphicsConfiguration;
+import javax.media.nativewindow.x11.X11GraphicsDevice;
import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
+import javax.media.nativewindow.awt.AWTGraphicsDevice;
import javax.media.opengl.*;
import javax.media.opengl.awt.*;
@@ -47,26 +49,19 @@ import com.sun.nativewindow.impl.jawt.x11.*;
import com.sun.opengl.impl.x11.*;
import com.sun.opengl.impl.x11.glx.*;
-public class X11AWTGLXNativeWindowFactory extends X11GLXNativeWindowFactory {
-
- public X11AWTGLXNativeWindowFactory() {
- Class componentClass = null;
- try {
- componentClass = Class.forName("java.awt.Component");
- } catch (Exception e) {
- throw new GLException(e);
- }
-
- NativeWindowFactory.registerFactory(componentClass, this);
+public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfigurationFactory {
+ public X11AWTGLXGraphicsConfigurationFactory() {
+ GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class,
+ this);
}
- public AbstractGraphicsConfiguration chooseGraphicsConfiguration(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
+ public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
+ CapabilitiesChooser chooser,
AbstractGraphicsDevice absDevice) {
GraphicsDevice device = null;
if (absDevice != null &&
!(absDevice instanceof AWTGraphicsDevice)) {
- throw new IllegalArgumentException("This NativeWindowFactory accepts only AWTGraphicsDevice objects");
+ throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only AWTGraphicsDevice objects");
}
if ((absDevice == null) ||
@@ -76,21 +71,40 @@ public class X11AWTGLXNativeWindowFactory extends X11GLXNativeWindowFactory {
device = ((AWTGraphicsDevice) absDevice).getGraphicsDevice();
}
- long visualID = chooseGraphicsConfigurationImpl(capabilities, chooser,
- X11SunJDKReflection.graphicsDeviceGetScreen(device));
+ if (capabilities != null &&
+ !(capabilities instanceof GLCapabilities)) {
+ throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects");
+ }
- // Now figure out which GraphicsConfiguration corresponds to this
- // visual by matching the visual ID
- GraphicsConfiguration[] configs = device.getConfigurations();
- for (int i = 0; i < configs.length; i++) {
- GraphicsConfiguration config = configs[i];
- if (config != null) {
- if (X11SunJDKReflection.graphicsConfigurationGetVisualID(config) == visualID) {
- return new AWTGraphicsConfiguration(config);
+ if (chooser != null &&
+ !(chooser instanceof GLCapabilitiesChooser)) {
+ throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilitiesChooser objects");
+ }
+
+ // Fabricate an X11GraphicsDevice and delegate to the GraphicsConfigurationFactory for those
+ //
+ // Note that we could derive from X11GLXGraphicsConfigurationFactory, but that would
+ // limit the ability of third parties to plug in new visual selection algorithms
+ X11GraphicsDevice x11Device = new X11GraphicsDevice(X11SunJDKReflection.graphicsDeviceGetScreen(device));
+ X11GraphicsConfiguration x11Config = (X11GraphicsConfiguration)
+ GraphicsConfigurationFactory.getFactory(x11Device).chooseGraphicsConfiguration(capabilities,
+ chooser,
+ x11Device);
+ if (x11Config != null) {
+ long visualID = x11Config.getVisualID();
+ // Now figure out which GraphicsConfiguration corresponds to this
+ // visual by matching the visual ID
+ GraphicsConfiguration[] configs = device.getConfigurations();
+ for (int i = 0; i < configs.length; i++) {
+ GraphicsConfiguration config = configs[i];
+ if (config != null) {
+ if (X11SunJDKReflection.graphicsConfigurationGetVisualID(config) == visualID) {
+ return new AWTGraphicsConfiguration(config);
+ }
}
}
}
-
+
// 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
@@ -98,44 +112,4 @@ public class X11AWTGLXNativeWindowFactory extends X11GLXNativeWindowFactory {
// and possibly report more of an error in the latter case)
return null;
}
-
- // When running the AWT on X11 platforms, we use the AWT native
- // interface (JAWT) to lock and unlock the toolkit
- private ToolkitLock toolkitLock = new ToolkitLock() {
- private Thread owner;
- private int recursionCount;
-
- public synchronized void lock() {
- Thread cur = Thread.currentThread();
- if (owner == cur) {
- ++recursionCount;
- return;
- }
- while (owner != null) {
- try {
- wait();
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
- owner = cur;
- JAWTUtil.lockToolkit();
- }
-
- public synchronized void unlock() {
- if (owner != Thread.currentThread()) {
- throw new RuntimeException("Not owner");
- }
- if (recursionCount > 0) {
- --recursionCount;
- return;
- }
- owner = null;
- JAWTUtil.unlockToolkit();
- }
- };
-
- public ToolkitLock getToolkitLock() {
- return toolkitLock;
- }
}
diff --git a/src/jogl/classes/com/sun/opengl/util/awt/TextRenderer.java b/src/jogl/classes/com/sun/opengl/util/awt/TextRenderer.java
index 58f021e90..d40339264 100755
--- a/src/jogl/classes/com/sun/opengl/util/awt/TextRenderer.java
+++ b/src/jogl/classes/com/sun/opengl/util/awt/TextRenderer.java
@@ -66,7 +66,6 @@ import java.text.*;
import java.util.*;
-import javax.media.nativewindow.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import javax.media.opengl.glu.gl2.*;
@@ -902,7 +901,7 @@ public class TextRenderer {
private void debug() {
dbgFrame = new Frame("TextRenderer Debug Output");
- GLCanvas dbgCanvas = new GLCanvas(new NWCapabilities(), null,
+ GLCanvas dbgCanvas = new GLCanvas(new GLCapabilities(), null,
GLContext.getCurrent(), null);
dbgCanvas.addGLEventListener(new DebugListener(dbgFrame));
dbgFrame.add(dbgCanvas);
diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
new file mode 100644
index 000000000..782d041a5
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
@@ -0,0 +1,239 @@
+/*
+ * Copyright (c) 2003-2009 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.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package javax.media.opengl;
+
+import javax.media.nativewindow.Capabilities;
+import javax.media.nativewindow.NativeWindowException;
+
+/** <P> The default implementation of the {@link
+ GLCapabilitiesChooser} interface, which provides consistent visual
+ selection behavior across platforms. The precise algorithm is
+ deliberately left loosely specified. Some properties are: </P>
+
+ <UL>
+
+ <LI> As long as there is at least one available non-null
+ GLCapabilities which matches the "stereo" option, will return a
+ valid index.
+
+ <LI> Attempts to match as closely as possible the given
+ GLCapabilities, but will select one with fewer capabilities (i.e.,
+ lower color depth) if necessary.
+
+ <LI> Prefers hardware-accelerated visuals to
+ non-hardware-accelerated.
+
+ <LI> If there is no exact match, prefers a more-capable visual to
+ a less-capable one.
+
+ <LI> If there is more than one exact match, chooses an arbitrary
+ one.
+
+ <LI> May select the opposite of a double- or single-buffered
+ visual (based on the user's request) in dire situations.
+
+ <LI> Color depth (including alpha) mismatches are weighted higher
+ than depth buffer mismatches, which are in turn weighted higher
+ than accumulation buffer (including alpha) and stencil buffer
+ depth mismatches.
+
+ <LI> If a valid windowSystemRecommendedChoice parameter is
+ supplied, chooses that instead of using the cross-platform code.
+
+ </UL>
+*/
+
+public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
+ private static final boolean DEBUG = false; // FIXME: Debug.debug("DefaultGLCapabilitiesChooser");
+
+ public int chooseCapabilities(Capabilities desired,
+ Capabilities[] available,
+ int windowSystemRecommendedChoice) {
+ GLCapabilities _desired = (GLCapabilities) desired;
+ GLCapabilities[] _available = (GLCapabilities[]) available;
+
+ if (DEBUG) {
+ System.err.println("Desired: " + _desired);
+ for (int i = 0; i < _available.length; i++) {
+ System.err.println("Available " + i + ": " + _available[i]);
+ }
+ System.err.println("Window system's recommended choice: " + windowSystemRecommendedChoice);
+ }
+
+ if (windowSystemRecommendedChoice >= 0 &&
+ windowSystemRecommendedChoice < _available.length &&
+ _available[windowSystemRecommendedChoice] != null) {
+ if (DEBUG) {
+ System.err.println("Choosing window system's recommended choice of " + windowSystemRecommendedChoice);
+ System.err.println(_available[windowSystemRecommendedChoice]);
+ }
+ return windowSystemRecommendedChoice;
+ }
+
+ // Create score array
+ int[] scores = new int[_available.length];
+ int NO_SCORE = -9999999;
+ int DOUBLE_BUFFER_MISMATCH_PENALTY = 1000;
+ int STENCIL_MISMATCH_PENALTY = 500;
+ // Pseudo attempt to keep equal rank penalties scale-equivalent
+ // (e.g., stencil mismatch is 3 * accum because there are 3 accum
+ // components)
+ int COLOR_MISMATCH_PENALTY_SCALE = 36;
+ int DEPTH_MISMATCH_PENALTY_SCALE = 6;
+ int ACCUM_MISMATCH_PENALTY_SCALE = 1;
+ int STENCIL_MISMATCH_PENALTY_SCALE = 3;
+ for (int i = 0; i < scores.length; i++) {
+ scores[i] = NO_SCORE;
+ }
+ // Compute score for each
+ for (int i = 0; i < scores.length; i++) {
+ GLCapabilities cur = _available[i];
+ if (cur == null) {
+ continue;
+ }
+ if (_desired.getStereo() != cur.getStereo()) {
+ continue;
+ }
+ int score = 0;
+ // Compute difference in color depth
+ // (Note that this decides the direction of all other penalties)
+ score += (COLOR_MISMATCH_PENALTY_SCALE *
+ ((cur.getRedBits() + cur.getGreenBits() + cur.getBlueBits() + cur.getAlphaBits()) -
+ (_desired.getRedBits() + _desired.getGreenBits() + _desired.getBlueBits() + _desired.getAlphaBits())));
+ // Compute difference in depth buffer depth
+ score += (DEPTH_MISMATCH_PENALTY_SCALE * sign(score) *
+ Math.abs(cur.getDepthBits() - _desired.getDepthBits()));
+ // Compute difference in accumulation buffer depth
+ score += (ACCUM_MISMATCH_PENALTY_SCALE * sign(score) *
+ Math.abs((cur.getAccumRedBits() + cur.getAccumGreenBits() + cur.getAccumBlueBits() + cur.getAccumAlphaBits()) -
+ (_desired.getAccumRedBits() + _desired.getAccumGreenBits() + _desired.getAccumBlueBits() + _desired.getAccumAlphaBits())));
+ // Compute difference in stencil bits
+ score += STENCIL_MISMATCH_PENALTY_SCALE * sign(score) * (cur.getStencilBits() - _desired.getStencilBits());
+ if (cur.getDoubleBuffered() != _desired.getDoubleBuffered()) {
+ score += sign(score) * DOUBLE_BUFFER_MISMATCH_PENALTY;
+ }
+ if ((_desired.getStencilBits() > 0) && (cur.getStencilBits() == 0)) {
+ score += sign(score) * STENCIL_MISMATCH_PENALTY;
+ }
+ scores[i] = score;
+ }
+ // Now prefer hardware-accelerated visuals by pushing scores of
+ // non-hardware-accelerated visuals out
+ boolean gotHW = false;
+ int maxAbsoluteHWScore = 0;
+ for (int i = 0; i < scores.length; i++) {
+ int score = scores[i];
+ if (score == NO_SCORE) {
+ continue;
+ }
+ GLCapabilities cur = _available[i];
+ if (cur.getHardwareAccelerated()) {
+ int absScore = Math.abs(score);
+ if (!gotHW ||
+ (absScore > maxAbsoluteHWScore)) {
+ gotHW = true;
+ maxAbsoluteHWScore = absScore;
+ }
+ }
+ }
+ if (gotHW) {
+ for (int i = 0; i < scores.length; i++) {
+ int score = scores[i];
+ if (score == NO_SCORE) {
+ continue;
+ }
+ GLCapabilities cur = _available[i];
+ if (!cur.getHardwareAccelerated()) {
+ if (score <= 0) {
+ score -= maxAbsoluteHWScore;
+ } else if (score > 0) {
+ score += maxAbsoluteHWScore;
+ }
+ scores[i] = score;
+ }
+ }
+ }
+
+ if (DEBUG) {
+ System.err.print("Scores: [");
+ for (int i = 0; i < _available.length; i++) {
+ if (i > 0) {
+ System.err.print(",");
+ }
+ System.err.print(" " + scores[i]);
+ }
+ System.err.println(" ]");
+ }
+
+ // Ready to select. Choose score closest to 0.
+ int scoreClosestToZero = NO_SCORE;
+ int chosenIndex = -1;
+ for (int i = 0; i < scores.length; i++) {
+ int score = scores[i];
+ if (score == NO_SCORE) {
+ continue;
+ }
+ // Don't substitute a positive score for a smaller negative score
+ if ((scoreClosestToZero == NO_SCORE) ||
+ (Math.abs(score) < Math.abs(scoreClosestToZero) &&
+ ((sign(scoreClosestToZero) < 0) || (sign(score) > 0)))) {
+ scoreClosestToZero = score;
+ chosenIndex = i;
+ }
+ }
+ if (chosenIndex < 0) {
+ throw new NativeWindowException("Unable to select one of the provided GLCapabilities");
+ }
+ if (DEBUG) {
+ System.err.println("Chosen index: " + chosenIndex);
+ System.err.println("Chosen capabilities:");
+ System.err.println(_available[chosenIndex]);
+ }
+
+ return chosenIndex;
+ }
+
+ private static int sign(int score) {
+ if (score < 0) {
+ return -1;
+ }
+ return 1;
+ }
+}
diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilities.java b/src/jogl/classes/javax/media/opengl/GLCapabilities.java
new file mode 100644
index 000000000..35b04d5f6
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/GLCapabilities.java
@@ -0,0 +1,310 @@
+/*
+ * Copyright (c) 2003-2009 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.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package javax.media.opengl;
+
+import javax.media.nativewindow.Capabilities;
+
+/** Specifies a set of OpenGL capabilities that a rendering context
+ must support, such as color depth and whether stereo is enabled.
+ It currently contains the minimal number of routines which allow
+ configuration on all supported window systems. */
+
+public class GLCapabilities extends Capabilities implements Cloneable {
+ private boolean doubleBuffered = true;
+ private boolean stereo = false;
+ private boolean hardwareAccelerated = true;
+ private int depthBits = 24;
+ private int stencilBits = 0;
+ private int accumRedBits = 0;
+ private int accumGreenBits = 0;
+ private int accumBlueBits = 0;
+ private int accumAlphaBits = 0;
+ // Shift bits from PIXELFORMATDESCRIPTOR not present because they
+ // are unlikely to be supported on Windows anyway
+
+ // Support for full-scene antialiasing (FSAA)
+ private boolean sampleBuffers = false;
+ private int numSamples = 2;
+
+ // Support for transparent windows containing OpenGL content
+ // (currently only has an effect on Mac OS X)
+ private boolean backgroundOpaque = true;
+
+ // Bits for pbuffer creation
+ private boolean pbufferFloatingPointBuffers;
+ private boolean pbufferRenderToTexture;
+ private boolean pbufferRenderToTextureRectangle;
+
+ /** Creates a GLCapabilities object. All attributes are in a default
+ state.
+ */
+ public GLCapabilities() {}
+
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (RuntimeException e) {
+ throw new GLException(e);
+ }
+ }
+
+ /** Indicates whether double-buffering is enabled. */
+ public boolean getDoubleBuffered() {
+ return doubleBuffered;
+ }
+
+ /** Enables or disables double buffering. */
+ public void setDoubleBuffered(boolean onOrOff) {
+ doubleBuffered = onOrOff;
+ }
+
+ /** Indicates whether stereo is enabled. */
+ public boolean getStereo() {
+ return stereo;
+ }
+
+ /** Enables or disables stereo viewing. */
+ public void setStereo(boolean onOrOff) {
+ stereo = onOrOff;
+ }
+
+ /** Indicates whether hardware acceleration is enabled. */
+ public boolean getHardwareAccelerated() {
+ return hardwareAccelerated;
+ }
+
+ /** Enables or disables hardware acceleration. */
+ public void setHardwareAccelerated(boolean onOrOff) {
+ hardwareAccelerated = onOrOff;
+ }
+
+ /** Returns the number of bits requested for the depth buffer. */
+ public int getDepthBits() {
+ return depthBits;
+ }
+
+ /** Sets the number of bits requested for the depth buffer. */
+ public void setDepthBits(int depthBits) {
+ this.depthBits = depthBits;
+ }
+
+ /** Returns the number of bits requested for the stencil buffer. */
+ public int getStencilBits() {
+ return stencilBits;
+ }
+
+ /** Sets the number of bits requested for the stencil buffer. */
+ public void setStencilBits(int stencilBits) {
+ this.stencilBits = stencilBits;
+ }
+
+ /** Returns the number of bits requested for the accumulation
+ buffer's red component. On some systems only the accumulation
+ buffer depth, which is the sum of the red, green, and blue bits,
+ is considered. */
+ public int getAccumRedBits() {
+ return accumRedBits;
+ }
+
+ /** Sets the number of bits requested for the accumulation buffer's
+ red component. On some systems only the accumulation buffer
+ depth, which is the sum of the red, green, and blue bits, is
+ considered. */
+ public void setAccumRedBits(int accumRedBits) {
+ this.accumRedBits = accumRedBits;
+ }
+
+ /** Returns the number of bits requested for the accumulation
+ buffer's green component. On some systems only the accumulation
+ buffer depth, which is the sum of the red, green, and blue bits,
+ is considered. */
+ public int getAccumGreenBits() {
+ return accumGreenBits;
+ }
+
+ /** Sets the number of bits requested for the accumulation buffer's
+ green component. On some systems only the accumulation buffer
+ depth, which is the sum of the red, green, and blue bits, is
+ considered. */
+ public void setAccumGreenBits(int accumGreenBits) {
+ this.accumGreenBits = accumGreenBits;
+ }
+
+ /** Returns the number of bits requested for the accumulation
+ buffer's blue component. On some systems only the accumulation
+ buffer depth, which is the sum of the red, green, and blue bits,
+ is considered. */
+ public int getAccumBlueBits() {
+ return accumBlueBits;
+ }
+
+ /** Sets the number of bits requested for the accumulation buffer's
+ blue component. On some systems only the accumulation buffer
+ depth, which is the sum of the red, green, and blue bits, is
+ considered. */
+ public void setAccumBlueBits(int accumBlueBits) {
+ this.accumBlueBits = accumBlueBits;
+ }
+
+ /** Returns the number of bits requested for the accumulation
+ buffer's alpha component. On some systems only the accumulation
+ buffer depth, which is the sum of the red, green, and blue bits,
+ is considered. */
+ public int getAccumAlphaBits() {
+ return accumAlphaBits;
+ }
+
+ /** Sets number of bits requested for accumulation buffer's alpha
+ component. On some systems only the accumulation buffer depth,
+ which is the sum of the red, green, and blue bits, is
+ considered. */
+ public void setAccumAlphaBits(int accumAlphaBits) {
+ this.accumAlphaBits = accumAlphaBits;
+ }
+
+ /** Indicates whether sample buffers for full-scene antialiasing
+ (FSAA) should be allocated for this drawable. Defaults to
+ false. */
+ public void setSampleBuffers(boolean onOrOff) {
+ sampleBuffers = onOrOff;
+ }
+
+ /** Returns whether sample buffers for full-scene antialiasing
+ (FSAA) should be allocated for this drawable. Defaults to
+ false. */
+ public boolean getSampleBuffers() {
+ return sampleBuffers;
+ }
+
+ /** If sample buffers are enabled, indicates the number of buffers
+ to be allocated. Defaults to 2. */
+ public void setNumSamples(int numSamples) {
+ this.numSamples = numSamples;
+ }
+
+ /** Returns the number of sample buffers to be allocated if sample
+ buffers are enabled. Defaults to 2. */
+ public int getNumSamples() {
+ return numSamples;
+ }
+
+ /** For pbuffers only, indicates whether floating-point buffers
+ should be used if available. Defaults to false. */
+ public void setPbufferFloatingPointBuffers(boolean onOrOff) {
+ pbufferFloatingPointBuffers = onOrOff;
+ }
+
+ /** For pbuffers only, returns whether floating-point buffers should
+ be used if available. Defaults to false. */
+ public boolean getPbufferFloatingPointBuffers() {
+ return pbufferFloatingPointBuffers;
+ }
+
+ /** For pbuffers only, indicates whether the render-to-texture
+ extension should be used if available. Defaults to false. */
+ public void setPbufferRenderToTexture(boolean onOrOff) {
+ pbufferRenderToTexture = onOrOff;
+ }
+
+ /** For pbuffers only, returns whether the render-to-texture
+ extension should be used if available. Defaults to false. */
+ public boolean getPbufferRenderToTexture() {
+ return pbufferRenderToTexture;
+ }
+
+ /** For pbuffers only, indicates whether the
+ render-to-texture-rectangle extension should be used if
+ available. Defaults to false. */
+ public void setPbufferRenderToTextureRectangle(boolean onOrOff) {
+ pbufferRenderToTextureRectangle = onOrOff;
+ }
+
+ /** For pbuffers only, returns whether the render-to-texture
+ extension should be used. Defaults to false. */
+ public boolean getPbufferRenderToTextureRectangle() {
+ return pbufferRenderToTextureRectangle;
+ }
+
+ /** For on-screen OpenGL contexts on some platforms, sets whether
+ the background of the context should be considered opaque. On
+ supported platforms, setting this to false, in conjunction with
+ other changes at the window toolkit level, can allow
+ hardware-accelerated OpenGL content inside of windows of
+ arbitrary shape. To achieve this effect it is necessary to use
+ an OpenGL clear color with an alpha less than 1.0. The default
+ value for this flag is <code>true</code>; setting it to false
+ may incur a certain performance penalty, so it is not
+ recommended to arbitrarily set it to false. */
+ public void setBackgroundOpaque(boolean opaque) {
+ backgroundOpaque = opaque;
+ }
+
+ /** Indicates whether the background of this OpenGL context should
+ be considered opaque. Defaults to true.
+
+ @see #setBackgroundOpaque
+ */
+ public boolean isBackgroundOpaque() {
+ return backgroundOpaque;
+ }
+
+ /** Returns a textual representation of this GLCapabilities
+ object. */
+ public String toString() {
+ return ("GLCapabilities [" +
+ "DoubleBuffered: " + doubleBuffered +
+ ", Stereo: " + stereo +
+ ", HardwareAccelerated: " + hardwareAccelerated +
+ ", DepthBits: " + depthBits +
+ ", StencilBits: " + stencilBits +
+ ", Red: " + getRedBits() +
+ ", Green: " + getGreenBits() +
+ ", Blue: " + getBlueBits() +
+ ", Alpha: " + getAlphaBits() +
+ ", Red Accum: " + accumRedBits +
+ ", Green Accum: " + accumGreenBits +
+ ", Blue Accum: " + accumBlueBits +
+ ", Alpha Accum: " + accumAlphaBits +
+ ", Multisample: " + sampleBuffers +
+ (sampleBuffers ? ", Num samples: " + numSamples : "") +
+ ", Opaque: " + backgroundOpaque +
+ " ]");
+ }
+}
diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java
new file mode 100644
index 000000000..38cda8cdf
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2003-2009 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.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package javax.media.opengl;
+
+import javax.media.nativewindow.CapabilitiesChooser;
+
+/** Provides a mechanism by which applications can customize the
+ window type selection for a given {@link GLCapabilities}.
+ Developers can implement this interface and pass an instance into
+ the appropriate method of {@link GLDrawableFactory}; the chooser
+ will be called during the OpenGL context creation process. Note
+ that this is only a marker interface; its signature is the same as
+ {@link CapabilitiesChooser}, but the array of {@link Capabilities}
+ objects passed to {@link #chooseCapabilities chooseCapabilities}
+ will actually be an array of {@link GLCapabilities}. */
+
+public interface GLCapabilitiesChooser extends CapabilitiesChooser {
+}
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawable.java b/src/jogl/classes/javax/media/opengl/GLDrawable.java
index 26fdc8753..746c8e728 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawable.java
@@ -143,7 +143,7 @@ public interface GLDrawable {
automatically and should not be called by the end user. */
public void swapBuffers() throws GLException;
- /** Fetches the {@link NWCapabilities} corresponding to the chosen
+ /** Fetches the {@link GLCapabilities} corresponding to the chosen
OpenGL capabilities (pixel format / visual) for this drawable.
Some drawables, in particular on-screen drawables, may be
created lazily; null is returned if the drawable is not
@@ -153,7 +153,7 @@ public interface GLDrawable {
value in this case.
Returns a copy of the passed object.
*/
- public NWCapabilities getChosenNWCapabilities();
+ public GLCapabilities getChosenGLCapabilities();
public NativeWindow getNativeWindow();
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index 21e5ddcbb..66585eb56 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -49,21 +49,21 @@ import com.sun.nativewindow.impl.NWReflection;
/** <P> Provides a virtual machine- and operating system-independent
mechanism for creating {@link GLDrawable}s. </P>
- <P> The {@link javax.media.opengl.NWCapabilities} objects passed
+ <P> The {@link javax.media.opengl.GLCapabilities} objects passed
in to the various factory methods are used as a hint for the
properties of the returned drawable. The default capabilities
selection algorithm (equivalent to passing in a null {@link
- NWCapabilitiesChooser}) is described in {@link
- DefaultNWCapabilitiesChooser}. Sophisticated applications needing
+ GLCapabilitiesChooser}) is described in {@link
+ DefaultGLCapabilitiesChooser}. Sophisticated applications needing
to change the selection algorithm may pass in their own {@link
- NWCapabilitiesChooser} which can select from the available pixel
- formats. The NWCapabilitiesChooser mechanism may not be supported
+ GLCapabilitiesChooser} which can select from the available pixel
+ formats. The GLCapabilitiesChooser mechanism may not be supported
by all implementations or on all platforms, in which case any
- passed NWCapabilitiesChooser will be ignored. </P>
+ passed GLCapabilitiesChooser will be ignored. </P>
<P> Because of the multithreaded nature of the Java platform's
Abstract Window Toolkit, it is typically not possible to immediately
- reject a given {@link NWCapabilities} as being unsupportable by
+ reject a given {@link GLCapabilities} as being unsupportable by
either returning <code>null</code> from the creation routines or
raising a {@link GLException}. The semantics of the rejection
process are (unfortunately) left unspecified for now. The current
@@ -156,19 +156,19 @@ public abstract class GLDrawableFactory {
* Returns a GLDrawable that wraps a platform-specific window system
* object, such as an AWT or LCDUI Canvas. On platforms which
* support it, selects a pixel format compatible with the supplied
- * NWCapabilities, or if the passed NWCapabilities object is null,
+ * GLCapabilities, or if the passed GLCapabilities object is null,
* uses a default set of capabilities. On these platforms, uses
- * either the supplied NWCapabilitiesChooser object, or if the
- * passed NWCapabilitiesChooser object is null, uses a
- * DefaultNWCapabilitiesChooser instance.
+ * either the supplied GLCapabilitiesChooser object, or if the
+ * passed GLCapabilitiesChooser object is null, uses a
+ * DefaultGLCapabilitiesChooser instance.
*
* @throws IllegalArgumentException if the passed target is null
* @throws GLException if any window system-specific errors caused
* the creation of the GLDrawable to fail.
*/
public abstract GLDrawable createGLDrawable(NativeWindow target,
- NWCapabilities capabilities,
- NWCapabilitiesChooser chooser)
+ GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser)
throws IllegalArgumentException, GLException;
//----------------------------------------------------------------------
@@ -189,8 +189,8 @@ public abstract class GLDrawableFactory {
* @throws GLException if any window system-specific errors caused
* the creation of the GLPbuffer to fail.
*/
- public abstract GLPbuffer createGLPbuffer(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
+ public abstract GLPbuffer createGLPbuffer(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
int initialWidth,
int initialHeight,
GLContext shareWith)
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 5180a4e2d..54bf63dda 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -58,7 +58,7 @@ public class GLProfile {
/** The JVM/process wide chosen GL profile **/
private static String profile = null;
- private static final void tryLibrary()
+ private static final Throwable tryLibrary()
{
try {
Class clazz = Class.forName(getGLImplBaseClassName()+"Impl");
@@ -79,11 +79,13 @@ public class GLProfile {
}
}
System.out.println("Successfully loaded profile " + profile);
+ return null;
} catch (Throwable e) {
if (Debug.debug("GLProfile")) {
e.printStackTrace();
}
profile=null;
+ return e;
}
}
@@ -92,9 +94,9 @@ public class GLProfile {
{
if(null==GLProfile.profile) {
GLProfile.profile = profile;
- tryLibrary();
- if (profile == null) {
- throw new GLException("Profile " + profile + " not available");
+ Throwable t = tryLibrary();
+ if (GLProfile.profile == null) {
+ throw new GLException("Profile " + profile + " not available", t);
}
} else {
if(!GLProfile.profile.equals(profile)) {
@@ -106,9 +108,14 @@ public class GLProfile {
public static synchronized final void setProfile(String[] profiles)
throws GLException
{
+ Throwable t = null;
for(int i=0; profile==null && i<profiles.length; i++) {
profile = profiles[i];
- tryLibrary();
+ if (t == null) {
+ t = tryLibrary();
+ } else {
+ tryLibrary();
+ }
}
if(null==profile) {
StringBuffer msg = new StringBuffer();
@@ -119,7 +126,7 @@ public class GLProfile {
msg.append(profiles[i]);
}
msg.append("]");
- throw new GLException("Profiles "+msg.toString()+" not available");
+ throw new GLException("Profiles "+msg.toString()+" not available", t);
}
}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 8ef797c97..232299594 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -84,8 +84,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
private boolean sendReshape = false;
private GraphicsConfiguration chosen;
- private NWCapabilities glCaps;
- private NWCapabilitiesChooser glCapChooser;
+ private GLCapabilities glCaps;
+ private GLCapabilitiesChooser glCapChooser;
static {
// Default to the GL2 profile, which is the default on the desktop
@@ -104,15 +104,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
/** Creates a new GLCanvas component with the requested set of
OpenGL capabilities, using the default OpenGL capabilities
selection mechanism, on the default screen device. */
- public GLCanvas(NWCapabilities capabilities) {
+ public GLCanvas(GLCapabilities capabilities) {
this(capabilities, null, null, null);
}
- /** Creates a new GLCanvas component. The passed NWCapabilities
+ /** Creates a new GLCanvas component. The passed GLCapabilities
specifies the OpenGL capabilities for the component; if null, a
- default set of capabilities is used. The NWCapabilitiesChooser
+ default set of capabilities is used. The GLCapabilitiesChooser
specifies the algorithm for selecting one of the available
- NWCapabilities for the component; a DefaultGLCapabilitesChooser
+ GLCapabilities for the component; a DefaultGLCapabilitesChooser
is used if null is passed for this argument. The passed
GLContext specifies an OpenGL context with which to share
textures, display lists and other OpenGL state, and may be null
@@ -123,8 +123,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
which to create the GLCanvas; the GLDrawableFactory uses the
default screen device of the local GraphicsEnvironment if null
is passed for this argument. */
- public GLCanvas(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
+ public GLCanvas(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
GLContext shareWith,
GraphicsDevice device) {
// The platform-specific GLDrawableFactory will only provide a
@@ -466,11 +466,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
maybeDoSingleThreadedWorkaround(swapBuffersOnEventDispatchThreadAction, swapBuffersAction);
}
- public NWCapabilities getChosenNWCapabilities() {
+ public GLCapabilities getChosenGLCapabilities() {
if (drawable == null)
return null;
- return drawable.getChosenNWCapabilities();
+ return drawable.getChosenGLCapabilities();
}
public NativeWindow getNativeWindow() {
@@ -609,18 +609,19 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
}
- private static GraphicsConfiguration chooseGraphicsConfiguration(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
+ private static GraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities,
+ GLCapabilitiesChooser chooser,
GraphicsDevice device) {
// Make GLCanvas behave better in NetBeans GUI builder
if (Beans.isDesignTime()) {
return null;
}
+ AWTGraphicsDevice awtDevice = new AWTGraphicsDevice(device);
AWTGraphicsConfiguration config = (AWTGraphicsConfiguration)
- NativeWindowFactory.getFactory(Component.class).chooseGraphicsConfiguration(capabilities,
- chooser,
- new AWTGraphicsDevice(device));
+ GraphicsConfigurationFactory.getFactory(awtDevice).chooseGraphicsConfiguration(capabilities,
+ chooser,
+ awtDevice);
if (config == null) {
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 9ea7d59dd..86668373d 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -64,7 +64,7 @@ import com.sun.opengl.impl.awt.*;
Z-ordering or LayoutManager problems. <P>
The GLJPanel can be made transparent by creating it with a
- NWCapabilities object with alpha bits specified and calling {@link
+ GLCapabilities object with alpha bits specified and calling {@link
#setOpaque}(false). Pixels with resulting OpenGL alpha values less
than 1.0 will be overlaid on any underlying Swing rendering. <P>
@@ -91,8 +91,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
private volatile boolean isInitialized;
// Data used for either pbuffers or pixmap-based offscreen surfaces
- private NWCapabilities offscreenCaps;
- private NWCapabilitiesChooser chooser;
+ private GLCapabilities offscreenCaps;
+ private GLCapabilitiesChooser chooser;
private GLContext shareWith;
// Width of the actual GLJPanel
private int panelWidth = 0;
@@ -159,33 +159,33 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
/** Creates a new GLJPanel component with the requested set of
OpenGL capabilities, using the default OpenGL capabilities
selection mechanism. */
- public GLJPanel(NWCapabilities capabilities) {
+ public GLJPanel(GLCapabilities capabilities) {
this(capabilities, null, null);
}
- /** Creates a new GLJPanel component. The passed NWCapabilities
+ /** Creates a new GLJPanel component. The passed GLCapabilities
specifies the OpenGL capabilities for the component; if null, a
- default set of capabilities is used. The NWCapabilitiesChooser
+ default set of capabilities is used. The GLCapabilitiesChooser
specifies the algorithm for selecting one of the available
- NWCapabilities for the component; a DefaultGLCapabilitesChooser
+ GLCapabilities for the component; a DefaultGLCapabilitesChooser
is used if null is passed for this argument. The passed
GLContext specifies an OpenGL context with which to share
textures, display lists and other OpenGL state, and may be null
if sharing is not desired. See the note in the overview documentation on
<a href="../../../overview-summary.html#SHARING">context sharing</a>.
*/
- public GLJPanel(NWCapabilities capabilities, NWCapabilitiesChooser chooser, GLContext shareWith) {
+ public GLJPanel(GLCapabilities capabilities, GLCapabilitiesChooser chooser, GLContext shareWith) {
super();
// Works around problems on many vendors' cards; we don't need a
// back buffer for the offscreen surface anyway
if (capabilities != null) {
- offscreenCaps = (NWCapabilities) capabilities.clone();
+ offscreenCaps = (GLCapabilities) capabilities.clone();
} else {
- offscreenCaps = new NWCapabilities();
+ offscreenCaps = new GLCapabilities();
}
offscreenCaps.setDoubleBuffered(false);
- this.chooser = ((chooser != null) ? chooser : new DefaultNWCapabilitiesChooser());
+ this.chooser = ((chooser != null) ? chooser : new DefaultGLCapabilitiesChooser());
this.shareWith = shareWith;
}
@@ -404,8 +404,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return oglPipelineEnabled;
}
- public NWCapabilities getChosenNWCapabilities() {
- return backend.getChosenNWCapabilities();
+ public GLCapabilities getChosenGLCapabilities() {
+ return backend.getChosenGLCapabilities();
}
public NativeWindow getNativeWindow() {
@@ -620,8 +620,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
// Called to get the current backend's GLDrawable
public GLDrawable getDrawable();
- // Called to fetch the "real" chosen NWCapabilities for the backend
- public NWCapabilities getChosenNWCapabilities();
+ // Called to fetch the "real" chosen GLCapabilities for the backend
+ public GLCapabilities getChosenGLCapabilities();
// Called to handle a reshape event. When this is called, the
// OpenGL context associated with the backend is not current, to
@@ -861,11 +861,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return offscreenDrawable;
}
- public NWCapabilities getChosenNWCapabilities() {
+ public GLCapabilities getChosenGLCapabilities() {
if (offscreenDrawable == null) {
return null;
}
- return offscreenDrawable.getChosenNWCapabilities();
+ return offscreenDrawable.getChosenGLCapabilities();
}
public void handleReshape() {
@@ -952,11 +952,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return pbuffer;
}
- public NWCapabilities getChosenNWCapabilities() {
+ public GLCapabilities getChosenGLCapabilities() {
if (pbuffer == null) {
return null;
}
- return pbuffer.getChosenNWCapabilities();
+ return pbuffer.getChosenGLCapabilities();
}
public void handleReshape() {
@@ -1123,9 +1123,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return joglDrawable;
}
- public NWCapabilities getChosenNWCapabilities() {
+ public GLCapabilities getChosenGLCapabilities() {
// FIXME: should do better than this; is it possible to using only platform-independent code?
- return new NWCapabilities();
+ return new GLCapabilities();
}
public void handleReshape() {
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/GraphicsConfigurationFactoryImpl.java b/src/nativewindow/classes/com/sun/nativewindow/impl/GraphicsConfigurationFactoryImpl.java
new file mode 100644
index 000000000..eb39b9f59
--- /dev/null
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/GraphicsConfigurationFactoryImpl.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2009 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.nativewindow.impl;
+
+import javax.media.nativewindow.*;
+
+public class GraphicsConfigurationFactoryImpl extends GraphicsConfigurationFactory {
+ // By default we just return null; X11 is the only window system requiring eager visual selection
+ public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
+ CapabilitiesChooser chooser,
+ AbstractGraphicsDevice device) {
+ return null;
+ }
+}
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java
index aec6e3175..89b620161 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java
@@ -64,19 +64,19 @@ public final class NWReflection {
try {
factoryClass = Class.forName(clazzName);
if (factoryClass == null) {
- throw new NWException(clazzName + " not available");
+ throw new NativeWindowException(clazzName + " not available");
}
try {
factory = factoryClass.getDeclaredConstructor( cstrArgTypes );
} catch(NoSuchMethodException nsme) {
- throw new NWException("Constructor: '" + clazzName + "("+cstrArgTypes+")' not found");
+ throw new NativeWindowException("Constructor: '" + clazzName + "("+cstrArgTypes+")' not found");
}
return factory;
} catch (Throwable e) {
if (DEBUG) {
e.printStackTrace();
}
- throw new NWException(e);
+ throw new NativeWindowException(e);
}
}
@@ -91,7 +91,7 @@ public final class NWReflection {
factory = getConstructor(clazzName, cstrArgTypes);
return factory.newInstance( cstrArgs ) ;
} catch (Exception e) {
- throw new NWException(e);
+ throw new NativeWindowException(e);
}
}
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NativeWindowFactoryImpl.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NativeWindowFactoryImpl.java
index 6e8542181..8a865733a 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/NativeWindowFactoryImpl.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NativeWindowFactoryImpl.java
@@ -98,14 +98,6 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory {
}
}
- // All platforms except for X11 perform the OpenGL pixel format
- // selection lazily
- public AbstractGraphicsConfiguration chooseGraphicsConfiguration(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
- AbstractGraphicsDevice device) {
- return null;
- }
-
// On most platforms the toolkit lock is a no-op
private ToolkitLock toolkitLock = new ToolkitLock() {
public void lock() {
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java
index fe07b0f16..b4124a375 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java
@@ -101,8 +101,8 @@ public class NullWindow implements NativeWindow {
public void setSurfaceHandle(long handle) {
surfaceHandle=handle;
}
- public long getVisualID() {
- return 0;
+ public AbstractGraphicsConfiguration getGraphicsConfiguration() {
+ return null;
}
public Object getWrappedWindow() {
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java
index a996f9ea9..e6aa3ca74 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java
@@ -57,9 +57,9 @@ public class JAWTUtil {
private static boolean lockedToolkit;
- public static synchronized void lockToolkit() throws NWException {
+ public static synchronized void lockToolkit() throws NativeWindowException {
if (lockedToolkit) {
- throw new NWException("Toolkit already locked");
+ throw new NativeWindowException("Toolkit already locked");
}
lockedToolkit = true;
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java
index c710a67bf..cccf911bd 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java
@@ -61,7 +61,7 @@ public abstract class JAWTWindow implements NativeWindow {
protected long display;
protected long screen;
protected long drawable;
- protected long visualID;
+ protected AbstractGraphicsConfiguration config;
protected int screenIndex;
public JAWTWindow(Object comp) {
@@ -83,7 +83,7 @@ public abstract class JAWTWindow implements NativeWindow {
screen= 0;
screenIndex = -1;
drawable= 0;
- visualID = 0;
+ config = null;
}
public synchronized int lockSurface() throws NativeWindowException {
@@ -119,8 +119,8 @@ public abstract class JAWTWindow implements NativeWindow {
public long getSurfaceHandle() {
return drawable;
}
- public long getVisualID() {
- return visualID;
+ public AbstractGraphicsConfiguration getGraphicsConfiguration() {
+ return config;
}
public Object getWrappedWindow() {
@@ -147,7 +147,7 @@ public abstract class JAWTWindow implements NativeWindow {
", pos "+component.getX()+"/"+component.getY()+", size "+getWidth()+"x"+getHeight()+
", visible "+component.isVisible()+
", wrappedWindow "+getWrappedWindow()+
- ", visualID "+visualID+
+ ", config "+config+
", screen handle/index "+getScreenHandle()+"/"+getScreenIndex() +
", display handle "+getDisplayHandle()+"]");
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java
index 310f17f64..e627b18f4 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java
@@ -69,7 +69,7 @@ public class MacOSXJAWTWindow extends JAWTWindow {
}
int res = ds.Lock();
if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) {
- throw new NWException("Unable to lock surface");
+ throw new NativeWindowException("Unable to lock surface");
}
// See whether the surface changed and if so destroy the old
// OpenGL context so it will be recreated (NOTE: removeNotify
@@ -110,7 +110,7 @@ public class MacOSXJAWTWindow extends JAWTWindow {
drawable = macosxdsi.cocoaViewRef();
// FIXME: Are the followup abstractions available ? would it be usefull ?
display = 0;
- visualID = 0;
+ config = null;
screen= 0;
screenIndex = 0;
@@ -127,7 +127,7 @@ public class MacOSXJAWTWindow extends JAWTWindow {
return ret;
}
- public void unlockSurface() throws NWException {
+ public void unlockSurface() throws NativeWindowException {
if(!isSurfaceLocked()) return;
ds.FreeDrawingSurfaceInfo(dsi);
ds.Unlock();
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java
index 364ee9d32..122ee3f8d 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java
@@ -73,7 +73,7 @@ public class WindowsJAWTWindow extends JAWTWindow {
}
int res = ds.Lock();
if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) {
- throw new NWException("Unable to lock surface");
+ throw new NativeWindowException("Unable to lock surface");
}
// See whether the surface changed and if so destroy the old
// OpenGL context so it will be recreated (NOTE: removeNotify
@@ -95,7 +95,7 @@ public class WindowsJAWTWindow extends JAWTWindow {
drawable = win32dsi.hdc();
// FIXME: Are the followup abstractions available ? would it be usefull ?
display = 0;
- visualID = 0;
+ config = null;
screen= 0;
screenIndex = 0;
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java
index 60b68c0e8..e8d955b21 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java
@@ -36,12 +36,13 @@
package com.sun.nativewindow.impl.jawt.x11;
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.x11.*;
+
import com.sun.nativewindow.impl.x11.*;
import com.sun.nativewindow.impl.jawt.*;
import com.sun.nativewindow.impl.*;
-import javax.media.nativewindow.*;
-
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
@@ -87,7 +88,8 @@ public class X11JAWTWindow extends JAWTWindow {
x11dsi = (JAWT_X11DrawingSurfaceInfo) dsi.platformInfo();
display = x11dsi.display();
drawable = x11dsi.drawable();
- visualID = x11dsi.visualID();
+ long visualID = x11dsi.visualID();
+ config = new X11GraphicsConfiguration(visualID);
screen= 0;
if (X11Lib.XineramaEnabled(display)) {
screenIndex = 0;
@@ -105,7 +107,7 @@ public class X11JAWTWindow extends JAWTWindow {
x11dsi = null;
display = 0;
drawable = 0;
- visualID = 0;
+ config = null;
screen= 0;
screenIndex = -1;
return LOCK_SURFACE_NOT_READY;
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11SunJDKReflection.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11SunJDKReflection.java
index f8c1624df..a4160033d 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11SunJDKReflection.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11SunJDKReflection.java
@@ -46,6 +46,9 @@ import java.awt.GraphicsDevice;
import java.lang.reflect.*;
import java.security.*;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
+
/** This class encapsulates the reflection routines necessary to peek
inside a few data structures in the AWT implementation on X11 for
the purposes of correctly enumerating the available visuals. */
@@ -89,6 +92,17 @@ public class X11SunJDKReflection {
}
}
+ public static int graphicsConfigurationGetVisualID(AbstractGraphicsConfiguration config) {
+ try {
+ if (config instanceof AWTGraphicsConfiguration) {
+ return graphicsConfigurationGetVisualID(((AWTGraphicsConfiguration) config).getGraphicsConfiguration());
+ }
+ return 0;
+ } catch (Exception e) {
+ return 0;
+ }
+ }
+
public static int graphicsConfigurationGetVisualID(GraphicsConfiguration config) {
if (!initted) {
return 0;
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
new file mode 100644
index 000000000..5250e251b
--- /dev/null
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
@@ -0,0 +1,60 @@
+/*
+ * 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.nativewindow.impl.x11;
+
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.x11.*;
+
+public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactory {
+ // FIXME: there is a "quality of implementation" issue here. We
+ // want to allow the use of the GraphicsConfigurationFactory in
+ // conjunction with OpenGL as well as other rendering mechanisms.
+ // On X11 platforms the OpenGL pixel format is associated with the
+ // window's visual. On other platforms, the OpenGL pixel format is
+ // chosen lazily. As in the OpenGL binding, the default
+ // X11GraphicsConfigurationFactory would need to provide a default
+ // mechanism for selecting a visual based on a set of
+ // capabilities. Here we always return 0 for the visual ID, which
+ // presumably corresponds to the default visual (which may be a
+ // bad assumption). When using OpenGL, the OpenGL binding is
+ // responsible for registering a GraphicsConfigurationFactory
+ // which actually performs visual selection, though based on
+ // GLCapabilities.
+ public AbstractGraphicsConfiguration
+ chooseGraphicsConfiguration(Capabilities capabilities,
+ CapabilitiesChooser chooser,
+ AbstractGraphicsDevice device)
+ throws IllegalArgumentException, NativeWindowException {
+ return new X11GraphicsConfiguration(0);
+ }
+}
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java
new file mode 100644
index 000000000..1643c30d8
--- /dev/null
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2009 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.nativewindow.impl.x11;
+
+import javax.media.nativewindow.*;
+import com.sun.nativewindow.impl.*;
+
+public class X11NativeWindowFactory extends NativeWindowFactoryImpl {
+ // On X11 platforms we need to do some locking; this basic
+ // implementation should suffice for some simple window toolkits
+ private ToolkitLock toolkitLock = new ToolkitLock() {
+ private Thread owner;
+ private int recursionCount;
+
+ public synchronized void lock() {
+ Thread cur = Thread.currentThread();
+ if (owner == cur) {
+ ++recursionCount;
+ return;
+ }
+ while (owner != null) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ owner = cur;
+ }
+
+ public synchronized void unlock() {
+ if (owner != Thread.currentThread()) {
+ throw new RuntimeException("Not owner");
+ }
+ if (recursionCount > 0) {
+ --recursionCount;
+ return;
+ }
+ owner = null;
+ }
+ };
+
+ public ToolkitLock getToolkitLock() {
+ return toolkitLock;
+ }
+}
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11Util.java b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11Util.java
index af3300ec8..703f8baf3 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11Util.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11Util.java
@@ -60,7 +60,7 @@ public class X11Util {
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
if (staticDisplay == 0) {
- throw new NWException("Unable to open default display");
+ throw new NativeWindowException("Unable to open default display");
}
}
return staticDisplay;
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/awt/X11AWTNativeWindowFactory.java b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/awt/X11AWTNativeWindowFactory.java
index e3bf428cc..4102715ce 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/awt/X11AWTNativeWindowFactory.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/awt/X11AWTNativeWindowFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2008-2009 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
@@ -42,7 +42,7 @@ import com.sun.nativewindow.impl.jawt.*;
import com.sun.nativewindow.impl.jawt.x11.*;
import com.sun.nativewindow.impl.x11.*;
-public class X11AWTNativeWindowFactory extends NativeWindowFactoryImpl {
+public class X11AWTNativeWindowFactory extends X11NativeWindowFactory {
// When running the AWT on X11 platforms, we use the AWT native
// interface (JAWT) to lock and unlock the toolkit
diff --git a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
index 0b0ee99f7..6fadd3e7e 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
@@ -39,45 +39,21 @@
package javax.media.nativewindow;
-/** Specifies a set of OpenGL capabilities that a rendering context
- must support, such as color depth and whether stereo is enabled.
- It currently contains the minimal number of routines which allow
- configuration on all supported window systems. */
+/** Specifies a set of capabilities that a window's rendering context
+ must support, such as color depth per channel. It currently
+ contains the minimal number of routines which allow configuration
+ on all supported window systems. */
-public class NWCapabilities implements Cloneable {
- private boolean doubleBuffered = true;
- private boolean stereo = false;
- private boolean hardwareAccelerated = true;
- private int depthBits = 24;
- private int stencilBits = 0;
+public class Capabilities implements Cloneable {
private int redBits = 8;
private int greenBits = 8;
private int blueBits = 8;
private int alphaBits = 0;
- private int accumRedBits = 0;
- private int accumGreenBits = 0;
- private int accumBlueBits = 0;
- private int accumAlphaBits = 0;
- // Shift bits from PIXELFORMATDESCRIPTOR not present because they
- // are unlikely to be supported on Windows anyway
- // Support for full-scene antialiasing (FSAA)
- private boolean sampleBuffers = false;
- private int numSamples = 2;
-
- // Support for transparent windows containing OpenGL content
- // (currently only has an effect on Mac OS X)
- private boolean backgroundOpaque = true;
-
- // Bits for pbuffer creation
- private boolean pbufferFloatingPointBuffers;
- private boolean pbufferRenderToTexture;
- private boolean pbufferRenderToTextureRectangle;
-
- /** Creates a NWCapabilities object. All attributes are in a default
+ /** Creates a Capabilities object. All attributes are in a default
state.
*/
- public NWCapabilities() {}
+ public Capabilities() {}
public Object clone() {
try {
@@ -87,56 +63,6 @@ public class NWCapabilities implements Cloneable {
}
}
- /** Indicates whether double-buffering is enabled. */
- public boolean getDoubleBuffered() {
- return doubleBuffered;
- }
-
- /** Enables or disables double buffering. */
- public void setDoubleBuffered(boolean onOrOff) {
- doubleBuffered = onOrOff;
- }
-
- /** Indicates whether stereo is enabled. */
- public boolean getStereo() {
- return stereo;
- }
-
- /** Enables or disables stereo viewing. */
- public void setStereo(boolean onOrOff) {
- stereo = onOrOff;
- }
-
- /** Indicates whether hardware acceleration is enabled. */
- public boolean getHardwareAccelerated() {
- return hardwareAccelerated;
- }
-
- /** Enables or disables hardware acceleration. */
- public void setHardwareAccelerated(boolean onOrOff) {
- hardwareAccelerated = onOrOff;
- }
-
- /** Returns the number of bits requested for the depth buffer. */
- public int getDepthBits() {
- return depthBits;
- }
-
- /** Sets the number of bits requested for the depth buffer. */
- public void setDepthBits(int depthBits) {
- this.depthBits = depthBits;
- }
-
- /** Returns the number of bits requested for the stencil buffer. */
- public int getStencilBits() {
- return stencilBits;
- }
-
- /** Sets the number of bits requested for the stencil buffer. */
- public void setStencilBits(int stencilBits) {
- this.stencilBits = stencilBits;
- }
-
/** Returns the number of bits requested for the color buffer's red
component. On some systems only the color depth, which is the
sum of the red, green, and blue bits, is considered. */
@@ -192,177 +118,15 @@ public class NWCapabilities implements Cloneable {
public void setAlphaBits(int alphaBits) {
this.alphaBits = alphaBits;
}
-
- /** Returns the number of bits requested for the accumulation
- buffer's red component. On some systems only the accumulation
- buffer depth, which is the sum of the red, green, and blue bits,
- is considered. */
- public int getAccumRedBits() {
- return accumRedBits;
- }
-
- /** Sets the number of bits requested for the accumulation buffer's
- red component. On some systems only the accumulation buffer
- depth, which is the sum of the red, green, and blue bits, is
- considered. */
- public void setAccumRedBits(int accumRedBits) {
- this.accumRedBits = accumRedBits;
- }
-
- /** Returns the number of bits requested for the accumulation
- buffer's green component. On some systems only the accumulation
- buffer depth, which is the sum of the red, green, and blue bits,
- is considered. */
- public int getAccumGreenBits() {
- return accumGreenBits;
- }
-
- /** Sets the number of bits requested for the accumulation buffer's
- green component. On some systems only the accumulation buffer
- depth, which is the sum of the red, green, and blue bits, is
- considered. */
- public void setAccumGreenBits(int accumGreenBits) {
- this.accumGreenBits = accumGreenBits;
- }
-
- /** Returns the number of bits requested for the accumulation
- buffer's blue component. On some systems only the accumulation
- buffer depth, which is the sum of the red, green, and blue bits,
- is considered. */
- public int getAccumBlueBits() {
- return accumBlueBits;
- }
-
- /** Sets the number of bits requested for the accumulation buffer's
- blue component. On some systems only the accumulation buffer
- depth, which is the sum of the red, green, and blue bits, is
- considered. */
- public void setAccumBlueBits(int accumBlueBits) {
- this.accumBlueBits = accumBlueBits;
- }
-
- /** Returns the number of bits requested for the accumulation
- buffer's alpha component. On some systems only the accumulation
- buffer depth, which is the sum of the red, green, and blue bits,
- is considered. */
- public int getAccumAlphaBits() {
- return accumAlphaBits;
- }
-
- /** Sets number of bits requested for accumulation buffer's alpha
- component. On some systems only the accumulation buffer depth,
- which is the sum of the red, green, and blue bits, is
- considered. */
- public void setAccumAlphaBits(int accumAlphaBits) {
- this.accumAlphaBits = accumAlphaBits;
- }
-
- /** Indicates whether sample buffers for full-scene antialiasing
- (FSAA) should be allocated for this drawable. Defaults to
- false. */
- public void setSampleBuffers(boolean onOrOff) {
- sampleBuffers = onOrOff;
- }
-
- /** Returns whether sample buffers for full-scene antialiasing
- (FSAA) should be allocated for this drawable. Defaults to
- false. */
- public boolean getSampleBuffers() {
- return sampleBuffers;
- }
-
- /** If sample buffers are enabled, indicates the number of buffers
- to be allocated. Defaults to 2. */
- public void setNumSamples(int numSamples) {
- this.numSamples = numSamples;
- }
-
- /** Returns the number of sample buffers to be allocated if sample
- buffers are enabled. Defaults to 2. */
- public int getNumSamples() {
- return numSamples;
- }
-
- /** For pbuffers only, indicates whether floating-point buffers
- should be used if available. Defaults to false. */
- public void setPbufferFloatingPointBuffers(boolean onOrOff) {
- pbufferFloatingPointBuffers = onOrOff;
- }
-
- /** For pbuffers only, returns whether floating-point buffers should
- be used if available. Defaults to false. */
- public boolean getPbufferFloatingPointBuffers() {
- return pbufferFloatingPointBuffers;
- }
-
- /** For pbuffers only, indicates whether the render-to-texture
- extension should be used if available. Defaults to false. */
- public void setPbufferRenderToTexture(boolean onOrOff) {
- pbufferRenderToTexture = onOrOff;
- }
-
- /** For pbuffers only, returns whether the render-to-texture
- extension should be used if available. Defaults to false. */
- public boolean getPbufferRenderToTexture() {
- return pbufferRenderToTexture;
- }
-
- /** For pbuffers only, indicates whether the
- render-to-texture-rectangle extension should be used if
- available. Defaults to false. */
- public void setPbufferRenderToTextureRectangle(boolean onOrOff) {
- pbufferRenderToTextureRectangle = onOrOff;
- }
-
- /** For pbuffers only, returns whether the render-to-texture
- extension should be used. Defaults to false. */
- public boolean getPbufferRenderToTextureRectangle() {
- return pbufferRenderToTextureRectangle;
- }
-
- /** For on-screen OpenGL contexts on some platforms, sets whether
- the background of the context should be considered opaque. On
- supported platforms, setting this to false, in conjunction with
- other changes at the window toolkit level, can allow
- hardware-accelerated OpenGL content inside of windows of
- arbitrary shape. To achieve this effect it is necessary to use
- an OpenGL clear color with an alpha less than 1.0. The default
- value for this flag is <code>true</code>; setting it to false
- may incur a certain performance penalty, so it is not
- recommended to arbitrarily set it to false. */
- public void setBackgroundOpaque(boolean opaque) {
- backgroundOpaque = opaque;
- }
-
- /** Indicates whether the background of this OpenGL context should
- be considered opaque. Defaults to true.
-
- @see #setBackgroundOpaque
- */
- public boolean isBackgroundOpaque() {
- return backgroundOpaque;
- }
- /** Returns a textual representation of this NWCapabilities
+ /** Returns a textual representation of this Capabilities
object. */
public String toString() {
- return ("NWCapabilities [" +
- "DoubleBuffered: " + doubleBuffered +
- ", Stereo: " + stereo +
- ", HardwareAccelerated: " + hardwareAccelerated +
- ", DepthBits: " + depthBits +
- ", StencilBits: " + stencilBits +
- ", Red: " + redBits +
+ return ("Capabilities [" +
+ "Red: " + redBits +
", Green: " + greenBits +
", Blue: " + blueBits +
", Alpha: " + alphaBits +
- ", Red Accum: " + accumRedBits +
- ", Green Accum: " + accumGreenBits +
- ", Blue Accum: " + accumBlueBits +
- ", Alpha Accum: " + accumAlphaBits +
- ", Multisample: " + sampleBuffers +
- (sampleBuffers ? ", Num samples: " + numSamples : "") +
- ", Opaque: " + backgroundOpaque +
" ]");
}
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java
index a980462f5..4d99216f0 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java
@@ -40,14 +40,14 @@
package javax.media.nativewindow;
/** Provides a mechanism by which applications can customize the
- window type selection for a given {@link NWCapabilities}.
+ window type selection for a given {@link Capabilities}.
Developers can implement this interface and pass an instance into
- the appropriate method of {@link GLDrawableFactory}; the chooser
- will be called during the OpenGL context creation process. */
+ the appropriate method of {@link NativeWindowFactory}; the chooser
+ will be called at window creation time, on some platforms. */
-public interface NWCapabilitiesChooser {
+public interface CapabilitiesChooser {
/** Chooses the index (0..available.length - 1) of the {@link
- NWCapabilities} most closely matching the desired one from the
+ Capabilities} most closely matching the desired one from the
list of all supported. Some of the entries in the
<code>available</code> array may be null; the chooser must
ignore these. The <em>windowSystemRecommendedChoice</em>
@@ -56,12 +56,14 @@ public interface NWCapabilitiesChooser {
not necessarily required, that the chooser select that entry.
<P> <em>Note:</em> this method is called automatically by the
- {@link GLDrawableFactory} when an instance of this class is
- passed in to one of its factory methods. It should generally not
- be invoked by users directly, unless it is desired to delegate
- the choice to some other NWCapabilitiesChooser object.
+ {@link NativeWindowFactory} when an instance of this class is
+ passed in to its {@link
+ NativeWindowFactory#chooseGraphicsConfiguration
+ chooseGraphicsConfiguration} method. It should generally not be
+ invoked by users directly, unless it is desired to delegate the
+ choice to some other CapabilitiesChooser object.
*/
- public int chooseCapabilities(NWCapabilities desired,
- NWCapabilities[] available,
+ public int chooseCapabilities(Capabilities desired,
+ Capabilities[] available,
int windowSystemRecommendedChoice);
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java
index 0e18a301d..cead0a4a8 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java
@@ -40,48 +40,31 @@
package javax.media.nativewindow;
/** <P> The default implementation of the {@link
- NWCapabilitiesChooser} interface, which provides consistent visual
+ CapabilitiesChooser} interface, which provides consistent visual
selection behavior across platforms. The precise algorithm is
deliberately left loosely specified. Some properties are: </P>
- <UL>
-
- <LI> As long as there is at least one available non-null
- NWCapabilities which matches the "stereo" option, will return a
- valid index.
-
<LI> Attempts to match as closely as possible the given
- NWCapabilities, but will select one with fewer capabilities (i.e.,
+ Capabilities, but will select one with fewer capabilities (i.e.,
lower color depth) if necessary.
- <LI> Prefers hardware-accelerated visuals to
- non-hardware-accelerated.
-
<LI> If there is no exact match, prefers a more-capable visual to
a less-capable one.
<LI> If there is more than one exact match, chooses an arbitrary
one.
- <LI> May select the opposite of a double- or single-buffered
- visual (based on the user's request) in dire situations.
-
- <LI> Color depth (including alpha) mismatches are weighted higher
- than depth buffer mismatches, which are in turn weighted higher
- than accumulation buffer (including alpha) and stencil buffer
- depth mismatches.
-
<LI> If a valid windowSystemRecommendedChoice parameter is
supplied, chooses that instead of using the cross-platform code.
</UL>
*/
-public class DefaultNWCapabilitiesChooser implements NWCapabilitiesChooser {
- private static final boolean DEBUG = false; // FIXME: Debug.debug("DefaultNWCapabilitiesChooser");
+public class DefaultCapabilitiesChooser implements CapabilitiesChooser {
+ private static final boolean DEBUG = false; // FIXME: Debug.debug("DefaultCapabilitiesChooser");
- public int chooseCapabilities(NWCapabilities desired,
- NWCapabilities[] available,
+ public int chooseCapabilities(Capabilities desired,
+ Capabilities[] available,
int windowSystemRecommendedChoice) {
if (DEBUG) {
System.err.println("Desired: " + desired);
@@ -104,86 +87,23 @@ public class DefaultNWCapabilitiesChooser implements NWCapabilitiesChooser {
// Create score array
int[] scores = new int[available.length];
int NO_SCORE = -9999999;
- int DOUBLE_BUFFER_MISMATCH_PENALTY = 1000;
- int STENCIL_MISMATCH_PENALTY = 500;
- // Pseudo attempt to keep equal rank penalties scale-equivalent
- // (e.g., stencil mismatch is 3 * accum because there are 3 accum
- // components)
int COLOR_MISMATCH_PENALTY_SCALE = 36;
- int DEPTH_MISMATCH_PENALTY_SCALE = 6;
- int ACCUM_MISMATCH_PENALTY_SCALE = 1;
- int STENCIL_MISMATCH_PENALTY_SCALE = 3;
for (int i = 0; i < scores.length; i++) {
scores[i] = NO_SCORE;
}
// Compute score for each
for (int i = 0; i < scores.length; i++) {
- NWCapabilities cur = available[i];
+ Capabilities cur = available[i];
if (cur == null) {
continue;
}
- if (desired.getStereo() != cur.getStereo()) {
- continue;
- }
int score = 0;
// Compute difference in color depth
- // (Note that this decides the direction of all other penalties)
score += (COLOR_MISMATCH_PENALTY_SCALE *
((cur.getRedBits() + cur.getGreenBits() + cur.getBlueBits() + cur.getAlphaBits()) -
(desired.getRedBits() + desired.getGreenBits() + desired.getBlueBits() + desired.getAlphaBits())));
- // Compute difference in depth buffer depth
- score += (DEPTH_MISMATCH_PENALTY_SCALE * sign(score) *
- Math.abs(cur.getDepthBits() - desired.getDepthBits()));
- // Compute difference in accumulation buffer depth
- score += (ACCUM_MISMATCH_PENALTY_SCALE * sign(score) *
- Math.abs((cur.getAccumRedBits() + cur.getAccumGreenBits() + cur.getAccumBlueBits() + cur.getAccumAlphaBits()) -
- (desired.getAccumRedBits() + desired.getAccumGreenBits() + desired.getAccumBlueBits() + desired.getAccumAlphaBits())));
- // Compute difference in stencil bits
- score += STENCIL_MISMATCH_PENALTY_SCALE * sign(score) * (cur.getStencilBits() - desired.getStencilBits());
- if (cur.getDoubleBuffered() != desired.getDoubleBuffered()) {
- score += sign(score) * DOUBLE_BUFFER_MISMATCH_PENALTY;
- }
- if ((desired.getStencilBits() > 0) && (cur.getStencilBits() == 0)) {
- score += sign(score) * STENCIL_MISMATCH_PENALTY;
- }
scores[i] = score;
}
- // Now prefer hardware-accelerated visuals by pushing scores of
- // non-hardware-accelerated visuals out
- boolean gotHW = false;
- int maxAbsoluteHWScore = 0;
- for (int i = 0; i < scores.length; i++) {
- int score = scores[i];
- if (score == NO_SCORE) {
- continue;
- }
- NWCapabilities cur = available[i];
- if (cur.getHardwareAccelerated()) {
- int absScore = Math.abs(score);
- if (!gotHW ||
- (absScore > maxAbsoluteHWScore)) {
- gotHW = true;
- maxAbsoluteHWScore = absScore;
- }
- }
- }
- if (gotHW) {
- for (int i = 0; i < scores.length; i++) {
- int score = scores[i];
- if (score == NO_SCORE) {
- continue;
- }
- NWCapabilities cur = available[i];
- if (!cur.getHardwareAccelerated()) {
- if (score <= 0) {
- score -= maxAbsoluteHWScore;
- } else if (score > 0) {
- score += maxAbsoluteHWScore;
- }
- scores[i] = score;
- }
- }
- }
if (DEBUG) {
System.err.print("Scores: [");
@@ -213,7 +133,7 @@ public class DefaultNWCapabilitiesChooser implements NWCapabilitiesChooser {
}
}
if (chosenIndex < 0) {
- throw new NativeWindowException("Unable to select one of the provided NWCapabilities");
+ throw new NativeWindowException("Unable to select one of the provided Capabilities");
}
if (DEBUG) {
System.err.println("Chosen index: " + chosenIndex);
diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
new file mode 100644
index 000000000..afddaf7aa
--- /dev/null
+++ b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2008-2009 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 javax.media.nativewindow;
+
+import java.lang.reflect.*;
+import java.util.*;
+
+import com.sun.nativewindow.impl.*;
+
+/**
+ * Provides the mechanism by which the graphics configuration for a
+ * given window can be chosen before the window is created. On some
+ * window systems (X11 in particular) the graphics configuration
+ * decides parameters related to hardware accelerated rendering such
+ * as the OpenGL pixel format. On these platforms it is necessary to
+ * choose the graphics configuration early. Note that the selection of
+ * the graphics configuration is an algorithm which does not have
+ * strong dependencies on the particular Java window toolkit in use
+ * (e.g., AWT) and therefore it is strongly desirable to factor this
+ * functionality out of the core {@link NativeWindowFactory} so that
+ * new window toolkits can replace just the {@link
+ * NativeWindowFactory} and reuse the graphics configuration selection
+ * algorithm provided by, for example, an OpenGL binding.
+ */
+
+public abstract class GraphicsConfigurationFactory {
+ private static Map/*<Class, NativeWindowFactory>*/ registeredFactories =
+ Collections.synchronizedMap(new HashMap());
+ private static Class abstractGraphicsDeviceClass;
+
+ static {
+ initialize();
+ }
+
+ /** Creates a new NativeWindowFactory instance. End users do not
+ need to call this method. */
+ protected GraphicsConfigurationFactory() {
+ }
+
+ private static void initialize() {
+ String osName = System.getProperty("os.name");
+ String osNameLowerCase = osName.toLowerCase();
+ String factoryClassName = null;
+
+ abstractGraphicsDeviceClass = javax.media.nativewindow.AbstractGraphicsDevice.class;
+
+ if (!osNameLowerCase.startsWith("wind") &&
+ !osNameLowerCase.startsWith("mac os x")) {
+ // Assume X11 platform -- should probably test for these explicitly
+ try {
+ GraphicsConfigurationFactory factory = (GraphicsConfigurationFactory)
+ NWReflection.createInstance("com.sun.nativewindow.impl.x11.X11GraphicsConfigurationFactory", new Object[] {});
+ registerFactory(javax.media.nativewindow.x11.X11GraphicsDevice.class, factory);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ // Register the default no-op factory for arbitrary
+ // AbstractGraphicsDevice implementations, including
+ // AWTGraphicsDevice instances -- the OpenGL binding will take
+ // care of handling AWTGraphicsDevices on X11 platforms (as
+ // well as X11GraphicsDevices in non-AWT situations)
+ registerFactory(abstractGraphicsDeviceClass, new GraphicsConfigurationFactoryImpl());
+ }
+
+ /** Returns the factory for use with the given type of
+ AbstractGraphicsDevice. */
+ public static GraphicsConfigurationFactory getFactory(AbstractGraphicsDevice device) {
+ if (device == null) {
+ return getFactory(AbstractGraphicsDevice.class);
+ }
+ return getFactory(device.getClass());
+ }
+
+ /**
+ * Returns the graphics configuration factory for use with the
+ * given class, which must implement the {@link
+ * AbstractGraphicsDevice} interface.
+ *
+ * @throws IllegalArgumentException if the given class does not implement AbstractGraphicsDevice
+ */
+ public static GraphicsConfigurationFactory getFactory(Class abstractGraphicsDeviceImplementor)
+ throws IllegalArgumentException, NativeWindowException
+ {
+ if (!(abstractGraphicsDeviceClass.isAssignableFrom(abstractGraphicsDeviceImplementor))) {
+ throw new IllegalArgumentException("Given class must implement AbstractGraphicsDevice");
+ }
+ Class clazz = abstractGraphicsDeviceImplementor;
+ while (clazz != null) {
+ GraphicsConfigurationFactory factory =
+ (GraphicsConfigurationFactory) registeredFactories.get(clazz);
+ if (factory != null) {
+ return factory;
+ }
+ clazz = clazz.getSuperclass();
+ }
+ // Return the default
+ return (GraphicsConfigurationFactory) registeredFactories.get(abstractGraphicsDeviceClass);
+ }
+
+ /** Registers a GraphicsConfigurationFactory handling graphics
+ * device objects of the given class. This does not need to be
+ * called by end users, only implementors of new
+ * GraphicsConfigurationFactory subclasses.
+ *
+ * @throws IllegalArgumentException if the given class does not implement AbstractGraphicsDevice
+ */
+ protected static void registerFactory(Class abstractGraphicsDeviceImplementor, GraphicsConfigurationFactory factory)
+ throws IllegalArgumentException
+ {
+ if (!(abstractGraphicsDeviceClass.isAssignableFrom(abstractGraphicsDeviceImplementor))) {
+ throw new IllegalArgumentException("Given class must implement AbstractGraphicsDevice");
+ }
+ registeredFactories.put(abstractGraphicsDeviceImplementor, factory);
+ }
+
+ /**
+ * <P> Selects a graphics configuration on the specified graphics
+ * device compatible with the supplied {@link Capabilities}. Some
+ * platforms (specifically X11) require the graphics configuration
+ * to be specified when the native window is created. This method
+ * is mainly intended to be both used and implemented by the
+ * OpenGL binding, and may return null on platforms on which the
+ * OpenGL pixel format selection process is performed later or in
+ * other unspecified situations. </P>
+ *
+ * <P> The concrete data type of the passed graphics device and
+ * returned graphics configuration must be specified in the
+ * documentation binding this particular API to the underlying
+ * window toolkit. The Reference Implementation accepts {@link
+ * AWTGraphicsDevice AWTGraphicsDevice} objects and returns {@link
+ * AWTGraphicsConfiguration AWTGraphicsConfiguration} objects. On
+ * X11 platforms where the AWT is not in use, it also accepts
+ * {@link javax.media.nativewindow.x11.X11GraphicsDevice
+ * X11GraphicsDevice} objects and returns {@link
+ * javax.media.nativewindow.x11.X11GraphicsConfiguration
+ * X11GraphicsConfiguration} objects.</P>
+ *
+ * @throws IllegalArgumentException if the data type of the passed
+ * AbstractGraphicsDevice is not supported by this
+ * NativeWindowFactory.
+ * @throws NativeWindowException if any window system-specific errors caused
+ * the selection of the graphics configuration to fail.
+ */
+ public abstract AbstractGraphicsConfiguration
+ chooseGraphicsConfiguration(Capabilities capabilities,
+ CapabilitiesChooser chooser,
+ AbstractGraphicsDevice device)
+ throws IllegalArgumentException, NativeWindowException;
+}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java
index 99b301997..75e8552f9 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java
@@ -39,19 +39,18 @@
package javax.media.nativewindow;
-/** Provides the mechanism by which the Java / OpenGL binding
- interacts with windows. A window toolkit such as the AWT may
- either implement this interface directly with one of its
- components, or provide and register an implementation of {@link
- NativeWindowFactory NativeWindowFactory} which can create
- NativeWindow objects for its components. <P>
+/** Provides the low-level information required for
+ hardware-accelerated rendering in a platform-independent manner. A
+ window toolkit such as the AWT may either implement this interface
+ directly with one of its components, or provide and register an
+ implementation of {@link NativeWindowFactory NativeWindowFactory}
+ which can create NativeWindow objects for its components. <P>
A NativeWindow created for a particular on-screen component is
expected to have the same lifetime as that component. As long as
the component is alive, the NativeWindow must be able to control
it, and any time it is visible and locked, provide information
- such as the window handle to the Java / OpenGL binding so that
- GLDrawables and GLContexts may be created for the window.
+ such as the window handle.
*/
public interface NativeWindow {
@@ -107,9 +106,21 @@ public interface NativeWindow {
public long getSurfaceHandle();
/**
- * Lifetime: after 1st lock, until invalidation
+ * Returns the graphics configuration corresponding to this window.
+ * The graphics configuration is most relevant on X11 platforms
+ * where it also decides other properties related to hardware
+ * accelerated rendering such as the OpenGL pixel format. This
+ * method may return null on platforms where it is not needed, and
+ * is only guaranteed to return a valid value while the window is
+ * locked.
+ */
+ public AbstractGraphicsConfiguration getGraphicsConfiguration();
+
+ /**
+ * Returns the index of the screen on which this window currently
+ * lies. This method is only guaranteed to return a valid value
+ * while the window is locked.
*/
- public long getVisualID();
public int getScreenIndex();
/** Returns the current width of this window. */
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
index fc9235075..80ee97081 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2008-2009 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
@@ -32,23 +32,22 @@
package javax.media.nativewindow;
-import javax.media.nativewindow.*;
import java.lang.reflect.*;
import java.security.*;
import java.util.*;
import com.sun.nativewindow.impl.*;
-/** Provides the link between the window toolkit and the Java binding
- to the OpenGL API. The NativeWindowFactory, and NativeWindow
- instances it creates, encompass all of the toolkit-specific
- functionality, leaving the GLDrawableFactory independent of any
- particular toolkit. */
+/** Provides a pluggable mechanism for arbitrary window toolkits to
+ adapt their components to the {@link NativeWindow} interface,
+ which provides a platform-independent mechanism of accessing the
+ information required to perform operations like
+ hardware-accelerated rendering using the OpenGL API. */
public abstract class NativeWindowFactory {
private static NativeWindowFactory defaultFactory;
- private static HashMap/*<Class, NativeWindowFactory>*/ registeredFactories =
- new HashMap();
+ private static Map/*<Class, NativeWindowFactory>*/ registeredFactories =
+ Collections.synchronizedMap(new HashMap());
private static Class nativeWindowClass;
/** Creates a new NativeWindowFactory instance. End users do not
@@ -56,40 +55,54 @@ public abstract class NativeWindowFactory {
protected NativeWindowFactory() {
}
- static {
- initialize();
- }
-
+ private static boolean initialized = false;
private static void initialize() {
- String osName = System.getProperty("os.name");
- String osNameLowerCase = osName.toLowerCase();
- String factoryClassName = null;
+ synchronized (NativeWindowFactory.class) {
+ if (initialized) {
+ return;
+ }
+ initialized = true;
- // We break compile-time dependencies on the AWT here to
- // make it easier to run this code on mobile devices
+ String osName = System.getProperty("os.name");
+ String osNameLowerCase = osName.toLowerCase();
+ String factoryClassName = null;
- NativeWindowFactory factory = new NativeWindowFactoryImpl();
- nativeWindowClass = javax.media.nativewindow.NativeWindow.class;
- registerFactory(nativeWindowClass, factory);
- defaultFactory = factory;
+ // We break compile-time dependencies on the AWT here to
+ // make it easier to run this code on mobile devices
+
+ NativeWindowFactory factory = new NativeWindowFactoryImpl();
+ nativeWindowClass = javax.media.nativewindow.NativeWindow.class;
+ registerFactory(nativeWindowClass, factory);
+ defaultFactory = factory;
- Class componentClass = null;
- try {
- componentClass = Class.forName("java.awt.Component");
- } catch (Exception e) {
- }
- if (componentClass != null) {
- if (!osNameLowerCase.startsWith("wind") &&
- !osNameLowerCase.startsWith("mac os x")) {
- // Assume X11 platform -- should probably test for these explicitly
- try {
- Constructor factoryConstructor =
- NWReflection.getConstructor("com.sun.nativewindow.impl.x11.awt.X11AWTNativeWindowFactory", new Class[] {});
- factory = (NativeWindowFactory) factoryConstructor.newInstance(null);
- } catch (Exception e) { }
+ Class componentClass = null;
+ try {
+ componentClass = Class.forName("java.awt.Component");
+ } catch (Exception e) {
+ }
+ if (componentClass != null) {
+ if (!osNameLowerCase.startsWith("wind") &&
+ !osNameLowerCase.startsWith("mac os x")) {
+ // Assume X11 platform -- should probably test for these explicitly
+ boolean exceptionOccurred = true;
+ try {
+ Constructor factoryConstructor =
+ NWReflection.getConstructor("com.sun.nativewindow.impl.x11.awt.X11AWTNativeWindowFactory", new Class[] {});
+ factory = (NativeWindowFactory) factoryConstructor.newInstance(null);
+ exceptionOccurred = false;
+ } catch (Exception e) { }
+ if (exceptionOccurred) {
+ // Try the non-AWT X11 native window factory
+ try {
+ Constructor factoryConstructor =
+ NWReflection.getConstructor("com.sun.nativewindow.impl.x11.X11NativeWindowFactory", new Class[] {});
+ factory = (NativeWindowFactory) factoryConstructor.newInstance(null);
+ } catch (Exception e) { }
+ }
+ }
+ registerFactory(componentClass, factory);
+ defaultFactory = factory;
}
- registerFactory(componentClass, factory);
- defaultFactory = factory;
}
}
@@ -105,6 +118,7 @@ public abstract class NativeWindowFactory {
within the Java binding to OpenGL. By default, if the AWT is
available, the default toolkit will support the AWT. */
public static void setDefaultFactory(NativeWindowFactory factory) {
+ initialize();
defaultFactory = factory;
}
@@ -120,6 +134,7 @@ public abstract class NativeWindowFactory {
within the Java binding to OpenGL. By default, if the AWT is
available, the default toolkit will support the AWT. */
public static NativeWindowFactory getDefaultFactory() {
+ initialize();
return defaultFactory;
}
@@ -130,6 +145,7 @@ public abstract class NativeWindowFactory {
NativeWindow implementation, or it might be that of a toolkit
class like {@link java.awt.Component Component}. */
public static NativeWindowFactory getFactory(Class windowClass) throws IllegalArgumentException {
+ initialize();
if (nativeWindowClass.isAssignableFrom(windowClass)) {
return (NativeWindowFactory) registeredFactories.get(nativeWindowClass);
}
@@ -146,8 +162,9 @@ public abstract class NativeWindowFactory {
/** Registers a NativeWindowFactory handling window objects of the
given class. This does not need to be called by end users,
- only implementors of new NativeWindowFactory subclasses, .. */
+ only implementors of new NativeWindowFactory subclasses. */
protected static void registerFactory(Class windowClass, NativeWindowFactory factory) {
+ initialize();
registeredFactories.put(windowClass, factory);
}
@@ -173,38 +190,6 @@ public abstract class NativeWindowFactory {
return getFactory(winObj.getClass()).getNativeWindowImpl(winObj);
}
- /**
- * <P> Selects a graphics configuration on the specified graphics
- * device compatible with the supplied NWCapabilities. This method
- * is intended to be used by applications which do not use the
- * supplied GLCanvas class but instead wrap their own Canvas or
- * other window toolkit-specific object with a GLDrawable. Some
- * platforms (specifically X11) require the graphics configuration
- * to be specified when the window toolkit object is created. This
- * method may return null on platforms on which the OpenGL pixel
- * format selection process is performed later. </P>
- *
- * <P> The concrete data type of the passed graphics device and
- * returned graphics configuration must be specified in the
- * documentation binding this particular API to the underlying
- * window toolkit. The Reference Implementation accepts {@link
- * AWTGraphicsDevice AWTGraphicsDevice} objects and returns {@link
- * AWTGraphicsConfiguration AWTGraphicsConfiguration} objects. </P>
- *
- * @see java.awt.Canvas#Canvas(java.awt.GraphicsConfiguration)
- *
- * @throws IllegalArgumentException if the data type of the passed
- * AbstractGraphicsDevice is not supported by this
- * NativeWindowFactory.
- * @throws NWException if any window system-specific errors caused
- * the selection of the graphics configuration to fail.
- */
- public abstract AbstractGraphicsConfiguration
- chooseGraphicsConfiguration(NWCapabilities capabilities,
- NWCapabilitiesChooser chooser,
- AbstractGraphicsDevice device)
- throws IllegalArgumentException, NWException;
-
/** Performs the conversion from a toolkit's window object to a
NativeWindow. Implementors of concrete NativeWindowFactory
subclasses should override this method. */
diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java
index c40f26a94..1cf4da42a 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java
@@ -52,4 +52,8 @@ public class X11GraphicsConfiguration implements AbstractGraphicsConfiguration {
public long getVisualID() {
return visualID;
}
+
+ public String toString() {
+ return "[X11GraphicsConfiguration visualID = " + visualID + "]";
+ }
}
diff --git a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java b/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
index c0116d0a3..c455dce19 100755
--- a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
+++ b/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
@@ -33,7 +33,8 @@
package com.sun.javafx.newt;
-import javax.media.nativewindow.NWCapabilities;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.Capabilities;
import java.util.ArrayList;
import java.util.Iterator;
@@ -124,18 +125,18 @@ public abstract class NewtFactory {
/**
* Create a Window entity, incl native creation
*/
- public static Window createWindow(Screen screen, NWCapabilities caps) {
+ public static Window createWindow(Screen screen, Capabilities caps) {
return Window.create(getWindowType(), screen, caps);
}
- public static Window createWindow(Screen screen, NWCapabilities caps, boolean undecorated) {
+ public static Window createWindow(Screen screen, Capabilities caps, boolean undecorated) {
return Window.create(getWindowType(), screen, caps, undecorated);
}
/**
* Create a Window entity using the given implementation type, incl native creation
*/
- public static Window createWindow(String type, Screen screen, NWCapabilities caps) {
+ public static Window createWindow(String type, Screen screen, Capabilities caps) {
return Window.create(type, screen, caps);
}
@@ -156,10 +157,10 @@ public abstract class NewtFactory {
/**
* Instantiate a Window entity using the native handle.
*/
- public static Window wrapWindow(Screen screen, NWCapabilities caps, long visualID,
+ public static Window wrapWindow(Screen screen, Capabilities caps, AbstractGraphicsConfiguration config,
long windowHandle, boolean fullscreen, boolean visible,
int x, int y, int width, int height) {
- return Window.wrapHandle(getWindowType(), screen, caps, visualID,
+ return Window.wrapHandle(getWindowType(), screen, caps, config,
windowHandle, fullscreen, visible, x, y, width, height);
}
diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java
index e9466b7d6..f323f824e 100755
--- a/src/newt/classes/com/sun/javafx/newt/Window.java
+++ b/src/newt/classes/com/sun/javafx/newt/Window.java
@@ -34,7 +34,8 @@
package com.sun.javafx.newt;
import com.sun.javafx.newt.impl.Debug;
-import javax.media.nativewindow.NWCapabilities;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.Capabilities;
import javax.media.nativewindow.NativeWindow;
import javax.media.nativewindow.NativeWindowException;
@@ -82,17 +83,16 @@ public abstract class Window implements NativeWindow
return windowClass;
}
- protected static Window create(String type, Screen screen, NWCapabilities caps) {
+ protected static Window create(String type, Screen screen, Capabilities caps) {
return create(type, screen, caps, false);
}
- protected static Window create(String type, Screen screen, NWCapabilities caps, boolean undecorated) {
+ protected static Window create(String type, Screen screen, Capabilities caps, boolean undecorated) {
try {
Class windowClass = getWindowClass(type);
Window window = (Window) windowClass.newInstance();
window.invalidate();
window.screen = screen;
- window.visualID = 0;
window.setUndecorated(undecorated);
window.createNative(caps);
return window;
@@ -102,7 +102,7 @@ public abstract class Window implements NativeWindow
}
}
- protected static Window wrapHandle(String type, Screen screen, NWCapabilities caps, long visualID,
+ protected static Window wrapHandle(String type, Screen screen, Capabilities caps, AbstractGraphicsConfiguration config,
long windowHandle, boolean fullscreen, boolean visible,
int x, int y, int width, int height)
{
@@ -112,7 +112,7 @@ public abstract class Window implements NativeWindow
window.invalidate();
window.screen = screen;
window.chosenCaps = caps;
- window.visualID = visualID;
+ window.config = config;
window.windowHandle = windowHandle;
window.fullscreen=fullscreen;
window.visible=visible;
@@ -128,12 +128,12 @@ public abstract class Window implements NativeWindow
}
/**
- * Create native windowHandle, ie creates a new native invisible window
+ * Create native windowHandle, ie creates a new native invisible window.
*
- * Shall use the capabilities to determine the visualID
- * and shall set chosenCaps.
+ * Shall use the capabilities to determine the graphics configuration
+ * and shall set the chosen capabilities.
*/
- protected abstract void createNative(NWCapabilities caps);
+ protected abstract void createNative(Capabilities caps);
protected abstract void closeNative();
@@ -170,7 +170,7 @@ public abstract class Window implements NativeWindow
", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
", visible "+isVisible()+
", wrappedWindow "+getWrappedWindow()+
- ", visualID "+visualID+
+ ", config "+config+
", "+chosenCaps+
", screen handle/index "+getScreenHandle()+"/"+getScreenIndex() +
", display handle "+getDisplayHandle());
@@ -193,14 +193,9 @@ public abstract class Window implements NativeWindow
protected Screen screen;
- /**
- * The NWCapabilities shall be used to determine the visualID
- */
- protected NWCapabilities chosenCaps;
- /**
- * The visualID shall be determined using the NWCapabilities
- */
- protected long visualID;
+ // The Capabilities is used to determine the AbstractGraphicsConfiguration
+ protected Capabilities chosenCaps;
+ protected AbstractGraphicsConfiguration config;
protected long windowHandle;
protected boolean locked=false;
protected boolean fullscreen, visible;
@@ -272,7 +267,7 @@ public abstract class Window implements NativeWindow
public void invalidate(boolean internal) {
unlockSurface();
screen = null;
- visualID = 0;
+ config = null;
chosenCaps = null;
windowHandle = 0;
locked = false;
@@ -315,16 +310,16 @@ public abstract class Window implements NativeWindow
return windowHandle; // default: return window handle
}
- public NWCapabilities getChosenCapabilities() {
+ public Capabilities getChosenCapabilities() {
if (chosenCaps == null)
return null;
// Must return a new copy to avoid mutation by end user
- return (NWCapabilities) chosenCaps.clone();
+ return (Capabilities) chosenCaps.clone();
}
- public long getVisualID() {
- return visualID;
+ public AbstractGraphicsConfiguration getGraphicsConfiguration() {
+ return config;
}
public int getWidth() {
diff --git a/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java b/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java
index bc1ffb828..bd29d7576 100644
--- a/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java
@@ -47,7 +47,7 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
import com.sun.javafx.newt.Window;
-import javax.media.nativewindow.NWCapabilities;
+import javax.media.nativewindow.Capabilities;
import javax.media.nativewindow.NativeWindowException;
/** An implementation of the Newt Window class built using the
@@ -75,9 +75,9 @@ public class AWTWindow extends Window {
}
}
- protected void createNative(NWCapabilities caps) {
- chosenCaps = (NWCapabilities) caps.clone(); // FIXME: visualID := f1(caps); caps := f2(visualID)
- visualID = 0; // n/a
+ protected void createNative(Capabilities caps) {
+ chosenCaps = (Capabilities) caps.clone(); // FIXME: visualID := f1(caps); caps := f2(visualID)
+ config = null; // n/a
runOnEDT(new Runnable() {
public void run() {
frame = new Frame(getTitle());
diff --git a/src/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java b/src/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java
index 3447ea888..598313fcd 100755
--- a/src/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java
@@ -33,7 +33,7 @@
package com.sun.javafx.newt.macosx;
-import javax.media.nativewindow.NWCapabilities;
+import javax.media.nativewindow.Capabilities;
import javax.media.nativewindow.NativeWindowException;
import com.sun.javafx.newt.*;
@@ -143,9 +143,12 @@ public class MacWindow extends Window {
public MacWindow() {
}
- protected void createNative(NWCapabilities caps) {
- chosenCaps = (NWCapabilities) caps.clone(); // FIXME: visualID := f1(caps); caps := f2(visualID)
- visualID = 0; // n/a
+ protected void createNative(Capabilities caps) {
+ // FIXME: no way to really set the proper Capabilities nor the
+ // AbstractGraphicsConfiguration since we don't do (OpenGL)
+ // pixel format selection here
+ chosenCaps = (Capabilities) caps.clone(); // FIXME: visualID := f1(caps); caps := f2(visualID)
+ config = null; // n/a
}
protected void closeNative() {
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
index 1d4b4c5ad..196396857 100644
--- a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
@@ -90,7 +90,7 @@ public class GLWindow extends Window implements GLAutoDrawable {
}
/** Creates a new GLWindow on the local display, screen 0, with a
- dummy visual ID, and with the default NWCapabilities. */
+ dummy visual ID, and with the default GLCapabilities. */
public static GLWindow create() {
return create(null, null, false);
}
@@ -103,26 +103,26 @@ public class GLWindow extends Window implements GLAutoDrawable {
public static GLWindow create(Window window) {
return create(window, null, false);
}
- public static GLWindow create(NWCapabilities caps) {
+ public static GLWindow create(GLCapabilities caps) {
return create(null, caps, false);
}
/** Creates a new GLWindow on the local display, screen 0, with a
- dummy visual ID, and with the given NWCapabilities. */
- public static GLWindow create(NWCapabilities caps, boolean undecorated) {
+ dummy visual ID, and with the given GLCapabilities. */
+ public static GLWindow create(GLCapabilities caps, boolean undecorated) {
return create(null, caps, undecorated);
}
- /** Creates a new GLWindow referring to the given window, and with the given NWCapabilities. */
- public static GLWindow create(Window window, NWCapabilities caps) {
+ /** Creates a new GLWindow referring to the given window, and with the given GLCapabilities. */
+ public static GLWindow create(Window window, GLCapabilities caps) {
return create(window, caps, false);
}
public static GLWindow create(Window window,
- NWCapabilities caps,
+ GLCapabilities caps,
boolean undecorated) {
if (caps == null) {
- caps = new NWCapabilities();
+ caps = new GLCapabilities();
}
if (window == null) {
Display display = NewtFactory.createDisplay(null); // local display
@@ -133,7 +133,7 @@ public class GLWindow extends Window implements GLAutoDrawable {
return new GLWindow(window);
}
- protected void createNative(NWCapabilities caps) {
+ protected void createNative(Capabilities caps) {
shouldNotCallThis();
}
@@ -247,7 +247,7 @@ public class GLWindow extends Window implements GLAutoDrawable {
if (window.getWrappedWindow() != null) {
nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow());
}
- drawable = factory.createGLDrawable(nw, window.getChosenCapabilities(), null);
+ drawable = factory.createGLDrawable(nw, (GLCapabilities) window.getChosenCapabilities(), null);
window.setVisible(true);
drawable.setRealized(true);
context = drawable.createContext(null);
@@ -501,6 +501,14 @@ public class GLWindow extends Window implements GLAutoDrawable {
private SwapBuffersAction swapBuffersAction = new SwapBuffersAction();
//----------------------------------------------------------------------
+ // Window methods that are not really needed
+ //
+
+ public Capabilities getChosenCapabilities() {
+ return getChosenGLCapabilities();
+ }
+
+ //----------------------------------------------------------------------
// GLDrawable methods that are not really needed
//
@@ -511,11 +519,11 @@ public class GLWindow extends Window implements GLAutoDrawable {
public void setRealized(boolean realized) {
}
- public NWCapabilities getChosenNWCapabilities() {
+ public GLCapabilities getChosenGLCapabilities() {
if (drawable == null)
return null;
- return drawable.getChosenNWCapabilities();
+ return drawable.getChosenGLCapabilities();
}
public NativeWindow getNativeWindow() {
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java
index e17e3040d..7b7662e7c 100755
--- a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java
@@ -36,7 +36,8 @@ package com.sun.javafx.newt.opengl.kd;
import com.sun.javafx.newt.*;
import com.sun.javafx.newt.impl.*;
import com.sun.opengl.impl.egl.*;
-import javax.media.nativewindow.NWCapabilities;
+import javax.media.nativewindow.Capabilities;
+import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import javax.media.nativewindow.NativeWindowException;
@@ -56,7 +57,7 @@ public class KDWindow extends Window {
public KDWindow() {
}
- protected void createNative(NWCapabilities caps) {
+ protected void createNative(Capabilities caps) {
int eglRenderableType;
if(GLProfile.isGLES1()) {
eglRenderableType = EGL.EGL_OPENGL_ES_BIT;
@@ -66,8 +67,18 @@ public class KDWindow extends Window {
} else {
eglRenderableType = EGL.EGL_OPENGL_BIT;
}
- EGLConfig config = new EGLConfig(getDisplayHandle(), caps);
- visualID = config.getNativeConfigID();
+ GLCapabilities glCaps = null;
+ if (caps instanceof GLCapabilities) {
+ glCaps = (GLCapabilities) caps;
+ } else {
+ glCaps = new GLCapabilities();
+ glCaps.setRedBits(caps.getRedBits());
+ glCaps.setGreenBits(caps.getGreenBits());
+ glCaps.setBlueBits(caps.getBlueBits());
+ glCaps.setAlphaBits(caps.getAlphaBits());
+ }
+ EGLConfig config = new EGLConfig(getDisplayHandle(), glCaps);
+ this.config = config;
chosenCaps = config.getCapabilities();
windowHandle = 0;
diff --git a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
index 956220c47..0d9015d66 100755
--- a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
@@ -33,7 +33,7 @@
package com.sun.javafx.newt.windows;
-import javax.media.nativewindow.NWCapabilities;
+import javax.media.nativewindow.Capabilities;
import javax.media.nativewindow.NativeWindowException;
import com.sun.javafx.newt.*;
@@ -63,11 +63,14 @@ public class WindowsWindow extends Window {
return hdc;
}
- protected void createNative(NWCapabilities caps) {
+ protected void createNative(Capabilities caps) {
long wndClass = getWindowClass();
- chosenCaps = (NWCapabilities) caps.clone(); // FIXME: visualID := f1(caps); caps := f2(visualID)
- visualID = 0; // n/a
- windowHandle = CreateWindow(WINDOW_CLASS_NAME, getHInstance(), visualID, x, y, width, height);
+ // FIXME: no way to really set the proper Capabilities nor the
+ // AbstractGraphicsConfiguration since we don't do (OpenGL)
+ // pixel format selection here
+ chosenCaps = (Capabilities) caps.clone(); // FIXME: visualID := f1(caps); caps := f2(visualID)
+ config = null; // n/a
+ windowHandle = CreateWindow(WINDOW_CLASS_NAME, getHInstance(), 0, x, y, width, height);
if (windowHandle == 0) {
throw new NativeWindowException("Error creating window");
}
diff --git a/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java b/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java
index 6e336f25d..9314cc0ae 100755
--- a/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java
+++ b/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java
@@ -35,8 +35,10 @@ package com.sun.javafx.newt.x11;
import com.sun.javafx.newt.*;
import com.sun.javafx.newt.impl.*;
-import javax.media.nativewindow.NWCapabilities;
+import javax.media.nativewindow.Capabilities;
+import javax.media.nativewindow.GraphicsConfigurationFactory;
import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.x11.*;
public class X11Window extends Window {
private static final String WINDOW_CLASS_NAME = "NewtWindow";
@@ -54,9 +56,18 @@ public class X11Window extends Window {
public X11Window() {
}
- protected void createNative(NWCapabilities caps) {
- chosenCaps = (NWCapabilities) caps.clone(); // FIXME: visualID := f1(caps); caps := f2(visualID)
- visualID = 0; // n/a
+ protected void createNative(Capabilities caps) {
+ // FIXME: we're running the visual selection algorithm (i.e.,
+ // from the OpenGL binding) but have no mechanism for
+ // capturing the chosen Capabilities
+ chosenCaps = (Capabilities) caps.clone(); // FIXME: visualID := f1(caps); caps := f2(visualID)
+ X11GraphicsDevice device = new X11GraphicsDevice(getScreenIndex());
+ X11GraphicsConfiguration config = (X11GraphicsConfiguration)
+ GraphicsConfigurationFactory.getFactory(device).chooseGraphicsConfiguration(caps, null, device);
+ long visualID = 0;
+ if (config != null) {
+ visualID = ((X11GraphicsConfiguration) config).getVisualID();
+ }
long w = CreateWindow(getDisplayHandle(), getScreenHandle(), getScreenIndex(), visualID, x, y, width, height);
if (w == 0 || w!=windowHandle) {
throw new NativeWindowException("Error creating window: "+w);
@@ -153,7 +164,7 @@ public class X11Window extends Window {
}
private void windowCreated(long visualID, long windowHandle, long windowDeleteAtom) {
- this.visualID = visualID;
+ this.config = new X11GraphicsConfiguration(visualID);
this.windowHandle = windowHandle;
this.windowDeleteAtom=windowDeleteAtom;
}