aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/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
38 files changed, 968 insertions, 415 deletions
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() {