aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java48
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java12
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java11
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfiguration.java19
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java114
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/egl/EGLPbufferDrawable.java10
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java8
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java15
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java41
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java8
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java56
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java20
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java8
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java9
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java39
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java62
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java56
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java9
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java8
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java20
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java124
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java21
-rw-r--r--src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java16
-rw-r--r--src/jogl/classes/javax/media/opengl/GLCapabilities.java30
-rw-r--r--src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java147
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawable.java8
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java6
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java40
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java32
-rw-r--r--src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java4
-rw-r--r--src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java2
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestGLWindows00NEWT.java2
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java14
-rw-r--r--src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java12
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/GraphicsConfigurationFactoryImpl.java5
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java7
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/Capabilities.java25
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java4
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java47
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java6
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java10
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java23
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java10
-rw-r--r--src/newt/classes/com/jogamp/newt/NewtFactory.java20
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java3
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtFactoryAWT.java7
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java5
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/WindowImpl.java15
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java16
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java3
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java7
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java10
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java3
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java3
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java13
69 files changed, 848 insertions, 469 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
index 6c15a2d92..4892303e3 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
@@ -54,7 +54,7 @@ import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.NativeSurface;
import javax.media.opengl.GL;
-import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLException;
@@ -499,7 +499,7 @@ public abstract class GLContextImpl extends GLContext {
{
AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
AbstractGraphicsDevice device = config.getScreen().getDevice();
- GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities();
+ GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
GLProfile glp = glCaps.getGLProfile();
if (DEBUG) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
index 43f705e34..ef5f67081 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
@@ -71,7 +71,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
throw new IllegalArgumentException("Null target");
}
AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities caps = (GLCapabilities) config.getChosenCapabilities();
+ GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
AbstractGraphicsDevice adevice = config.getScreen().getDevice();
GLDrawable result = null;
adevice.lock();
@@ -131,7 +131,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
return createGLPbufferDrawableImpl(target);
}
- public GLDrawable createGLPbufferDrawable(GLCapabilities capabilities,
+ public GLDrawable createGLPbufferDrawable(GLCapabilitiesImmutable capsRequested,
GLCapabilitiesChooser chooser,
int width,
int height) {
@@ -139,18 +139,28 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
throw new GLException("Width and height of pbuffer must be positive (were (" +
width + ", " + height + "))");
}
- capabilities.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN
- capabilities.setOnscreen(false);
- capabilities.setPBuffer(true);
+
+ GLCapabilitiesImmutable capsChosen;
+
+ if( capsRequested.getDoubleBuffered() || capsRequested.isOnscreen() || !capsRequested.isPBuffer()) {
+ // fix caps ..
+ GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable();
+ caps2.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN
+ caps2.setOnscreen(false);
+ caps2.setPBuffer(true);
+ capsChosen = caps2;
+ } else {
+ capsChosen = capsRequested;
+ }
NativeWindowFactory.getDefaultToolkitLock().lock();
try {
- return createGLPbufferDrawable( createOffscreenSurfaceImpl(capabilities, chooser, height, height) );
+ return createGLPbufferDrawable( createOffscreenSurfaceImpl(capsChosen, capsRequested, chooser, height, height) );
} finally {
NativeWindowFactory.getDefaultToolkitLock().unlock();
}
}
- public GLPbuffer createGLPbuffer(GLCapabilities capabilities,
+ public GLPbuffer createGLPbuffer(GLCapabilitiesImmutable capabilities,
GLCapabilitiesChooser chooser,
int width,
int height,
@@ -167,7 +177,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
protected abstract GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) ;
- public GLDrawable createOffscreenDrawable(GLCapabilities capabilities,
+ public GLDrawable createOffscreenDrawable(GLCapabilitiesImmutable capsRequested,
GLCapabilitiesChooser chooser,
int width,
int height) {
@@ -175,12 +185,21 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
throw new GLException("Width and height of pbuffer must be positive (were (" +
width + ", " + height + "))");
}
- capabilities.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN
- capabilities.setOnscreen(false);
- capabilities.setPBuffer(false);
+ GLCapabilitiesImmutable capsChosen;
+
+ if( capsRequested.getDoubleBuffered() || capsRequested.isOnscreen() || capsRequested.isPBuffer()) {
+ // fix caps ..
+ GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable();
+ caps2.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN
+ caps2.setOnscreen(false);
+ caps2.setPBuffer(false);
+ capsChosen = caps2;
+ } else {
+ capsChosen = capsRequested;
+ }
NativeWindowFactory.getDefaultToolkitLock().lock();
try {
- return createOffscreenDrawableImpl( createOffscreenSurfaceImpl(capabilities, chooser, width, height) );
+ return createOffscreenDrawableImpl( createOffscreenSurfaceImpl(capsChosen, capsRequested, chooser, width, height) );
} finally {
NativeWindowFactory.getDefaultToolkitLock().unlock();
}
@@ -190,8 +209,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
* creates an offscreen NativeSurface, which must implement SurfaceChangeable as well,
* so the windowing system related implementation is able to set the surface handle.
*/
- protected abstract NativeSurface createOffscreenSurfaceImpl(GLCapabilities capabilities, GLCapabilitiesChooser chooser,
- int width, int height);
+ protected abstract NativeSurface createOffscreenSurfaceImpl(GLCapabilitiesImmutable capabilities, GLCapabilitiesImmutable capsRequested,
+ GLCapabilitiesChooser chooser,
+ int width, int height);
//---------------------------------------------------------------------------
//
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
index e68ee3644..d7d2836aa 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
@@ -52,7 +52,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
this.factory = factory;
this.surface = comp;
this.realized = realized;
- this.requestedCapabilities = (GLCapabilities)surface.getGraphicsConfiguration().getNativeGraphicsConfiguration().getRequestedCapabilities(); // a copy ..
+ this.requestedCapabilities = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getNativeGraphicsConfiguration().getRequestedCapabilities();
}
/**
@@ -79,7 +79,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
}
public final void swapBuffers() throws GLException {
- GLCapabilities caps = (GLCapabilities)surface.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+ GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)surface.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
if ( caps.getDoubleBuffered() ) {
if(!surface.surfaceSwap()) {
int lockRes = lockSurface(); // it's recursive, so it's ok within [makeCurrent .. release]
@@ -114,11 +114,11 @@ public abstract class GLDrawableImpl implements GLDrawable {
return requestedCapabilities.getGLProfile();
}
- public GLCapabilities getChosenGLCapabilities() {
- return (GLCapabilities)surface.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); // a copy
+ public GLCapabilitiesImmutable getChosenGLCapabilities() {
+ return (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
}
- public GLCapabilities getRequestedGLCapabilities() {
+ public GLCapabilitiesImmutable getRequestedGLCapabilities() {
return requestedCapabilities;
}
@@ -204,7 +204,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
protected GLDrawableFactory factory;
protected NativeSurface surface;
- protected GLCapabilities requestedCapabilities;
+ protected GLCapabilitiesImmutable requestedCapabilities;
// Indicates whether the surface (if an onscreen context) has been
// realized. Plausibly, before the surface is realized the JAWT
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java
index 7a30f9a6f..d282d2f84 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java
@@ -64,7 +64,7 @@ public class GLPbufferImpl implements GLPbuffer {
public GLPbufferImpl(GLDrawableImpl pbufferDrawable,
GLContext parentContext) {
- GLCapabilities caps = (GLCapabilities)
+ GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)
pbufferDrawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
if(caps.isOnscreen()) {
if(caps.isPBuffer()) {
@@ -195,14 +195,14 @@ public class GLPbufferImpl implements GLPbuffer {
context.releasePbufferFromTexture();
}
- public GLCapabilities getChosenGLCapabilities() {
+ public GLCapabilitiesImmutable getChosenGLCapabilities() {
if (pbufferDrawable == null)
return null;
return pbufferDrawable.getChosenGLCapabilities();
}
- public GLCapabilities getRequestedGLCapabilities() {
+ public GLCapabilitiesImmutable getRequestedGLCapabilities() {
if (pbufferDrawable == null)
return null;
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java
index 81dcc12d5..88685faf7 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java
@@ -69,8 +69,8 @@ public abstract class EGLDrawable extends GLDrawableImpl {
return eglConfig;
}
- public GLCapabilities getChosenGLCapabilities() {
- return (null==eglConfig)?super.getChosenGLCapabilities():(GLCapabilities)eglConfig.getChosenCapabilities();
+ public GLCapabilitiesImmutable getChosenGLCapabilities() {
+ return (null==eglConfig)?super.getChosenGLCapabilities():(GLCapabilitiesImmutable)eglConfig.getChosenCapabilities();
}
public abstract GLContext createContext(GLContext shareWith);
@@ -168,8 +168,11 @@ public abstract class EGLDrawable extends GLDrawableImpl {
}
EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay, AbstractGraphicsDevice.DEFAULT_UNIT);
DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, aConfig.getScreen().getIndex());
- GLCapabilities caps = (GLCapabilities) aConfig.getChosenCapabilities(); // yes, use the already choosen Capabilities (x11,win32,..)
- eglConfig = (EGLGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(e).chooseGraphicsConfiguration(caps, null, s);
+ // yes, use the already choosen/requested Capabilities (x11,win32,..)
+ GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) aConfig.getChosenCapabilities();
+ GLCapabilitiesImmutable capsRequested = (GLCapabilitiesImmutable) aConfig.getRequestedCapabilities();
+ eglConfig = (EGLGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(e).chooseGraphicsConfiguration(
+ capsChosen, capsRequested, null, s);
if (null == eglConfig) {
throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);
} else if(DEBUG) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
index 3c8c4c98f..737aa5519 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
@@ -163,8 +163,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
return new EGLPbufferDrawable(this, target);
}
- protected NativeSurface createOffscreenSurfaceImpl(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
- ProxySurface ns = new ProxySurface(EGLGraphicsConfigurationFactory.createOffscreenGraphicsConfiguration(capabilities, chooser));
+ protected NativeSurface createOffscreenSurfaceImpl(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) {
+ ProxySurface ns = new ProxySurface(EGLGraphicsConfigurationFactory.createOffscreenGraphicsConfiguration(capsChosen, capsRequested, chooser));
ns.setSize(width, height);
return ns;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfiguration.java
index 2e4b06d94..dc74d3651 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfiguration.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -36,7 +37,6 @@
package com.jogamp.opengl.impl.egl;
import com.jogamp.common.nio.PointerBuffer;
-import java.util.*;
import javax.media.nativewindow.*;
import javax.media.nativewindow.egl.*;
import javax.media.opengl.*;
@@ -54,7 +54,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
}
public EGLGraphicsConfiguration(AbstractGraphicsScreen absScreen,
- GLCapabilities capsChosen, GLCapabilities capsRequested, GLCapabilitiesChooser chooser,
+ GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser,
long cfg, int cfgID) {
super(absScreen, capsChosen, capsRequested);
this.chooser = chooser;
@@ -62,7 +62,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
configID = cfgID;
}
- public static EGLGraphicsConfiguration create(GLCapabilities capsRequested, AbstractGraphicsScreen absScreen, int cfgID) {
+ public static EGLGraphicsConfiguration create(GLCapabilitiesImmutable capsRequested, AbstractGraphicsScreen absScreen, int cfgID) {
AbstractGraphicsDevice absDevice = absScreen.getDevice();
if(null==absDevice || !(absDevice instanceof EGLGraphicsDevice)) {
throw new GLException("GraphicsDevice must be a valid EGLGraphicsDevice");
@@ -73,7 +73,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
}
GLProfile glp = capsRequested.getGLProfile();
long cfg = EGLConfigId2EGLConfig(glp, dpy, cfgID);
- GLCapabilities caps = EGLConfig2Capabilities(glp, dpy, cfg, false, capsRequested.isOnscreen(), capsRequested.isPBuffer());
+ GLCapabilitiesImmutable caps = EGLConfig2Capabilities(glp, dpy, cfg, false, capsRequested.isOnscreen(), capsRequested.isPBuffer());
return new EGLGraphicsConfiguration(absScreen, caps, capsRequested, new DefaultGLCapabilitiesChooser(), cfg, cfgID);
}
@@ -83,9 +83,8 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
protected void updateGraphicsConfiguration() {
EGLGraphicsConfiguration newConfig = (EGLGraphicsConfiguration)
- GraphicsConfigurationFactory.getFactory(getScreen().getDevice()).chooseGraphicsConfiguration(getRequestedCapabilities().cloneCapabilites(),
- chooser,
- getScreen());
+ GraphicsConfigurationFactory.getFactory(getScreen().getDevice()).chooseGraphicsConfiguration(
+ getChosenCapabilities(), getRequestedCapabilities(), chooser, getScreen());
if(null!=newConfig) {
// FIXME: setScreen( ... );
setChosenCapabilities(newConfig.getChosenCapabilities());
@@ -132,8 +131,8 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
return res;
}
- public static GLCapabilities EGLConfig2Capabilities(GLProfile glp, long display, long config,
- boolean relaxed, boolean onscreen, boolean usePBuffer) {
+ public static GLCapabilitiesImmutable EGLConfig2Capabilities(GLProfile glp, long display, long config,
+ boolean relaxed, boolean onscreen, boolean usePBuffer) {
GLCapabilities caps = new GLCapabilities(glp);
int[] val = new int[1];
@@ -200,7 +199,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
return caps;
}
- public static int[] GLCapabilities2AttribList(GLCapabilities caps) {
+ public static int[] GLCapabilities2AttribList(GLCapabilitiesImmutable caps) {
int[] attrs = new int[32];
int idx=0;
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
index c678707fc..8f0f036aa 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,12 +33,25 @@
package com.jogamp.opengl.impl.egl;
-import com.jogamp.common.nio.PointerBuffer;
import java.io.PrintStream;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.egl.*;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.CapabilitiesChooser;
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.nativewindow.DefaultGraphicsScreen;
+import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.egl.EGLGraphicsDevice;
+
+import javax.media.opengl.DefaultGLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
-import javax.media.opengl.*;
+import com.jogamp.common.nio.PointerBuffer;
/** Subclass of GraphicsConfigurationFactory used when non-AWT tookits
@@ -54,14 +68,18 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
}
protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl (
- Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
+ CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
+ CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
if (absScreen == null) {
throw new IllegalArgumentException("This NativeWindowFactory accepts only AbstractGraphicsDevice objects");
}
- if (capabilities != null &&
- !(capabilities instanceof GLCapabilities)) {
- throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects");
+ if (! (capsChosen instanceof GLCapabilitiesImmutable) ) {
+ throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - chosen");
+ }
+
+ if (! (capsRequested instanceof GLCapabilitiesImmutable) ) {
+ throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - requested");
}
if (chooser != null &&
@@ -69,18 +87,20 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects");
}
- return chooseGraphicsConfigurationStatic((GLCapabilities) capabilities,
+ return chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable) capsChosen,
+ (GLCapabilitiesImmutable) capsRequested,
(GLCapabilitiesChooser) chooser,
absScreen);
}
- private static EGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- AbstractGraphicsScreen absScreen) {
- if (capabilities == null) {
- capabilities = new GLCapabilities(null);
- }
- GLProfile glp = capabilities.getGLProfile();
+ private static EGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilitiesImmutable capsChosen,
+ GLCapabilitiesImmutable capsReq,
+ GLCapabilitiesChooser chooser,
+ AbstractGraphicsScreen absScreen) {
+ if (capsChosen == null) {
+ capsChosen = new GLCapabilities(null);
+ }
+ GLProfile glp = capsChosen.getGLProfile();
if(null==absScreen) {
throw new GLException("Null AbstractGraphicsScreen");
@@ -96,18 +116,19 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
throw new GLException("Invalid EGL display: "+absDevice);
}
- GLCapabilities caps2 = (GLCapabilities) capabilities.clone();
- if(!caps2.isOnscreen()) {
+ if(!capsChosen.isOnscreen() && capsChosen.getDoubleBuffered()) {
// OFFSCREEN !DOUBLE_BUFFER // FIXME DBLBUFOFFSCRN
+ GLCapabilities caps2 = (GLCapabilities) capsChosen.cloneMutable();
caps2.setDoubleBuffered(false);
+ capsChosen = caps2;
}
- EGLGraphicsConfiguration res = eglChooseConfig(eglDisplay, caps2, capabilities, chooser, absScreen);
+ EGLGraphicsConfiguration res = eglChooseConfig(eglDisplay, capsChosen, capsReq, chooser, absScreen);
if(null!=res) {
return res;
}
if(DEBUG) {
- System.err.println("eglChooseConfig failed with given capabilities "+caps2);
+ System.err.println("eglChooseConfig failed with given capabilities "+capsChosen);
}
if (chooser == null) {
@@ -123,15 +144,15 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
if (numConfigs[0] == 0) {
throw new GLException("Graphics configuration fetch (eglGetConfigs) - no EGLConfig found");
}
- GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0],
- caps2.isOnscreen(), caps2.isPBuffer());
+ GLCapabilitiesImmutable[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0],
+ capsChosen.isOnscreen(), capsChosen.isPBuffer());
if(DEBUG) {
System.err.println("EGL Get Configs: "+numConfigs[0]+", Caps "+caps.length);
printCaps("eglGetConfigs", caps, System.err);
}
int chosen = -1;
try {
- chosen = chooser.chooseCapabilities(caps2, caps, -1);
+ chosen = chooser.chooseCapabilities(capsChosen, caps, -1);
} catch (NativeWindowException e) { throw new GLException(e); }
if(chosen<0) {
throw new GLException("Graphics configuration chooser failed");
@@ -139,7 +160,7 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
if(DEBUG) {
System.err.println("Chosen "+caps[chosen]);
}
- res = eglChooseConfig(eglDisplay, caps[chosen], capabilities, chooser, absScreen);
+ res = eglChooseConfig(eglDisplay, caps[chosen], capsReq, chooser, absScreen);
if(null!=res) {
return res;
}
@@ -160,7 +181,7 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
if(DEBUG) {
System.err.println("trying fixed caps (1): "+fixedCaps);
}
- res = eglChooseConfig(eglDisplay, fixedCaps, capabilities, chooser, absScreen);
+ res = eglChooseConfig(eglDisplay, fixedCaps, capsReq, chooser, absScreen);
if(null!=res) {
return res;
}
@@ -175,7 +196,7 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
if(DEBUG) {
System.err.println("trying fixed caps (2): "+fixedCaps);
}
- res = eglChooseConfig(eglDisplay, fixedCaps, capabilities, chooser, absScreen);
+ res = eglChooseConfig(eglDisplay, fixedCaps, capsReq, chooser, absScreen);
if(null!=res) {
return res;
}
@@ -192,7 +213,7 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
if(DEBUG) {
System.err.println("trying fixed caps (3): "+fixedCaps);
}
- res = eglChooseConfig(eglDisplay, fixedCaps, capabilities, chooser, absScreen);
+ res = eglChooseConfig(eglDisplay, fixedCaps, capsReq, chooser, absScreen);
if(null!=res) {
return res;
}
@@ -200,7 +221,8 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
}
protected static EGLGraphicsConfiguration eglChooseConfig(long eglDisplay,
- GLCapabilities capsChosen0, GLCapabilities capsRequested, GLCapabilitiesChooser chooser,
+ GLCapabilitiesImmutable capsChosen0, GLCapabilitiesImmutable capsRequested,
+ GLCapabilitiesChooser chooser,
AbstractGraphicsScreen absScreen) {
GLProfile glp = capsChosen0.getGLProfile();
int[] attrs = EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChosen0);
@@ -214,8 +236,8 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
}
if (numConfigs[0] > 0) {
if(DEBUG) {
- GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0],
- capsChosen0.isOnscreen(), capsChosen0.isPBuffer());
+ GLCapabilitiesImmutable[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0],
+ capsChosen0.isOnscreen(), capsChosen0.isPBuffer());
System.err.println("EGL Choose Configs: "+numConfigs[0]+", Caps "+caps.length);
printCaps("eglChooseConfig", caps, System.err);
}
@@ -228,8 +250,9 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
}
return null;
}
- GLCapabilities capsChosen1 = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs.get(0),
- true, capsChosen0.isOnscreen(), capsChosen0.isPBuffer());
+ GLCapabilitiesImmutable capsChosen1 = EGLGraphicsConfiguration.EGLConfig2Capabilities(
+ glp, eglDisplay, configs.get(0),
+ true, capsChosen0.isOnscreen(), capsChosen0.isPBuffer());
if(null!=capsChosen1) {
if(DEBUG) {
System.err.println("eglChooseConfig found: eglDisplay 0x"+Long.toHexString(eglDisplay)+
@@ -252,27 +275,34 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
return null;
}
- protected static GLCapabilities[] eglConfigs2GLCaps(GLProfile glp, long eglDisplay, PointerBuffer configs, int num,
- boolean onscreen, boolean usePBuffer) {
- GLCapabilities[] caps = new GLCapabilities[num];
+ protected static GLCapabilitiesImmutable[] eglConfigs2GLCaps(GLProfile glp, long eglDisplay, PointerBuffer configs, int num,
+ boolean onscreen, boolean usePBuffer) {
+ GLCapabilitiesImmutable[] caps = new GLCapabilitiesImmutable[num];
for(int i=0; i<num; i++) {
caps[i] = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs.get(i),
- true, onscreen, usePBuffer);
+ true, onscreen, usePBuffer);
}
return caps;
}
- protected static void printCaps(String prefix, GLCapabilities[] caps, PrintStream out) {
+ protected static void printCaps(String prefix, GLCapabilitiesImmutable[] caps, PrintStream out) {
for(int i=0; i<caps.length; i++) {
out.println(prefix+"["+i+"] "+caps[i]);
}
}
- protected static EGLGraphicsConfiguration createOffscreenGraphicsConfiguration(GLCapabilities caps, GLCapabilitiesChooser chooser) {
- if(caps.isOnscreen()) {
- throw new GLException("Error: Onscreen set: "+caps);
+ protected static EGLGraphicsConfiguration createOffscreenGraphicsConfiguration(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsReq, GLCapabilitiesChooser chooser) {
+ if(capsChosen.isOnscreen()) {
+ throw new GLException("Error: Onscreen set: "+capsChosen);
}
- caps.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN
+
+ if(capsChosen.getDoubleBuffered()) {
+ // OFFSCREEN !DOUBLE_BUFFER // FIXME DBLBUFOFFSCRN
+ GLCapabilities caps2 = (GLCapabilities) capsChosen.cloneMutable();
+ caps2.setDoubleBuffered(false);
+ capsChosen = caps2;
+ }
+
long eglDisplay = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
if (eglDisplay == EGL.EGL_NO_DISPLAY) {
throw new GLException("Failed to created EGL default display: error 0x"+Integer.toHexString(EGL.eglGetError()));
@@ -284,7 +314,7 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
}
EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay, AbstractGraphicsDevice.DEFAULT_UNIT);
DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, 0);
- EGLGraphicsConfiguration eglConfig = chooseGraphicsConfigurationStatic(caps, chooser, s);
+ EGLGraphicsConfiguration eglConfig = chooseGraphicsConfigurationStatic(capsChosen, capsReq, chooser, s);
if (null == eglConfig) {
EGL.eglTerminate(eglDisplay);
throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLPbufferDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLPbufferDrawable.java
index e633d0b47..3189324d1 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLPbufferDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLPbufferDrawable.java
@@ -40,8 +40,11 @@
package com.jogamp.opengl.impl.egl;
-import javax.media.opengl.*;
-import javax.media.nativewindow.*;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.SurfaceChangeable;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLException;
public class EGLPbufferDrawable extends EGLDrawable {
private int texFormat;
@@ -52,7 +55,8 @@ public class EGLPbufferDrawable extends EGLDrawable {
ownEGLDisplay = true;
// get choosen ones ..
- GLCapabilities caps = (GLCapabilities) getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+ GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)
+ getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
if(useTexture) {
this.texFormat = caps.getAlphaBits() > 0 ? EGL.EGL_TEXTURE_RGBA : EGL.EGL_TEXTURE_RGB ;
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java
index e9b543721..3cd2aa650 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java
@@ -116,13 +116,13 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
}
MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilitiesRequested = (GLCapabilities)config.getRequestedCapabilities();
+ GLCapabilitiesImmutable capabilitiesRequested = (GLCapabilitiesImmutable) config.getRequestedCapabilities();
GLProfile glProfile = capabilitiesRequested.getGLProfile();
if(glProfile.isGL3()) {
throw new GLException("GL3 profile currently not supported on MacOSX, due to the lack of a OpenGL 3.1 implementation");
}
// HACK .. bring in OnScreen/PBuffer selection to the DrawableFactory !!
- GLCapabilities capabilities = (GLCapabilities) capabilitiesRequested.clone();
+ GLCapabilities capabilities = (GLCapabilities) capabilitiesRequested.cloneMutable();
capabilities.setPBuffer(pbuffer);
capabilities.setPbufferFloatingPointBuffers(floatingPoint);
@@ -154,7 +154,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
CGL.setContextOpacity(contextHandle, 0);
}
- GLCapabilities caps = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(glProfile, pixelFormat);
+ GLCapabilitiesImmutable caps = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(glProfile, pixelFormat);
config.setChosenCapabilities(caps);
} finally {
CGL.deletePixelFormat(pixelFormat);
@@ -260,7 +260,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
protected void swapBuffers() {
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities caps = (GLCapabilities)config.getChosenCapabilities();
+ GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)config.getChosenCapabilities();
if(caps.isOnscreen()) {
if(isNSContext) {
if (!CGL.flushBuffer(contextHandle)) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
index a8a82b46a..71b99c2d5 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -151,9 +151,9 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
return new MacOSXPbufferCGLDrawable(this, target);
}
- protected NativeSurface createOffscreenSurfaceImpl(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
+ protected NativeSurface createOffscreenSurfaceImpl(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) {
AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_MACOSX);
- ProxySurface ns = new ProxySurface(MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, screen, true));
+ ProxySurface ns = new ProxySurface(MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, true));
ns.setSize(width, height);
return ns;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
index d2be9d0de..b912efd1f 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
@@ -42,7 +42,8 @@ import javax.media.opengl.*;
public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable {
long pixelformat;
- public MacOSXCGLGraphicsConfiguration(AbstractGraphicsScreen screen, GLCapabilities capsChosen, GLCapabilities capsRequested,
+ public MacOSXCGLGraphicsConfiguration(AbstractGraphicsScreen screen,
+ GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested,
long pixelformat) {
super(screen, capsChosen, capsRequested);
this.pixelformat=pixelformat;
@@ -56,7 +57,7 @@ public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration
this.pixelformat=pixelformat;
}
- protected void setChosenCapabilities(GLCapabilities caps) {
+ protected void setChosenCapabilities(GLCapabilitiesImmutable caps) {
super.setChosenCapabilities(caps);
}
@@ -73,7 +74,7 @@ public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration
CGL.NSOpenGLPFASampleBuffers,
CGL.NSOpenGLPFASamples };
- protected static int[] GLCapabilities2AttribList(GLCapabilities caps) {
+ protected static int[] GLCapabilities2AttribList(GLCapabilitiesImmutable caps) {
int[] ivalues = new int[cglInternalAttributeToken.length];
for (int idx = 0; idx < cglInternalAttributeToken.length; idx++) {
@@ -130,20 +131,20 @@ public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration
return ivalues;
}
- protected static long GLCapabilities2NSPixelFormat(GLCapabilities caps) {
+ protected static long GLCapabilities2NSPixelFormat(GLCapabilitiesImmutable caps) {
int[] ivalues = GLCapabilities2AttribList(caps);
return CGL.createPixelFormat(cglInternalAttributeToken, 0, cglInternalAttributeToken.length, ivalues, 0);
}
- protected static GLCapabilities NSPixelFormat2GLCapabilities(GLProfile glp, long pixelFormat) {
+ protected static GLCapabilitiesImmutable NSPixelFormat2GLCapabilities(GLProfile glp, long pixelFormat) {
return PixelFormat2GLCapabilities(glp, pixelFormat, true);
}
- protected static GLCapabilities CGLPixelFormat2GLCapabilities(GLProfile glp, long pixelFormat) {
+ protected static GLCapabilitiesImmutable CGLPixelFormat2GLCapabilities(GLProfile glp, long pixelFormat) {
return PixelFormat2GLCapabilities(glp, pixelFormat, false);
}
- private static GLCapabilities PixelFormat2GLCapabilities(GLProfile glp, long pixelFormat, boolean nsUsage) {
+ private static GLCapabilitiesImmutable PixelFormat2GLCapabilities(GLProfile glp, long pixelFormat, boolean nsUsage) {
int[] ivalues = new int[cglInternalAttributeToken.length];
// On this platform the pixel format is associated with the
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
index 69bb245e1..f53fff168 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,12 +33,14 @@
package com.jogamp.opengl.impl.macosx.cgl;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.macosx.*;
-import com.jogamp.nativewindow.impl.*;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.CapabilitiesChooser;
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesImmutable;
-import javax.media.opengl.*;
-import com.jogamp.opengl.impl.*;
/** Subclass of GraphicsConfigurationFactory used when non-AWT tookits
are used on OSX platforms. Toolkits will likely need to delegate
@@ -52,20 +55,25 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GraphicsConfiguration
}
protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
- Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
- return chooseGraphicsConfigurationStatic(capabilities, chooser, absScreen, false);
+ CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
+ CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
+ return chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, absScreen, false);
}
- protected static MacOSXCGLGraphicsConfiguration chooseGraphicsConfigurationStatic(Capabilities capabilities,
- CapabilitiesChooser chooser,
- AbstractGraphicsScreen absScreen, boolean usePBuffer) {
+ protected static MacOSXCGLGraphicsConfiguration chooseGraphicsConfigurationStatic(CapabilitiesImmutable capsChosen,
+ CapabilitiesImmutable capsRequested,
+ CapabilitiesChooser chooser,
+ AbstractGraphicsScreen absScreen, boolean usePBuffer) {
if (absScreen == null) {
throw new IllegalArgumentException("AbstractGraphicsScreen is null");
}
- if (capabilities != null &&
- !(capabilities instanceof GLCapabilities)) {
- throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects");
+ if (! (capsChosen instanceof GLCapabilitiesImmutable) ) {
+ throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - chosen");
+ }
+
+ if (! (capsRequested instanceof GLCapabilitiesImmutable) ) {
+ throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - requested");
}
if (chooser != null &&
@@ -73,11 +81,6 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GraphicsConfiguration
throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects");
}
- if (capabilities == null) {
- capabilities = new GLCapabilities(null);
- }
-
- return new MacOSXCGLGraphicsConfiguration(absScreen, (GLCapabilities)capabilities, (GLCapabilities)capabilities, 0);
+ return new MacOSXCGLGraphicsConfiguration(absScreen, (GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested, 0);
}
}
-
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java
index 5dcc103b2..80a396a29 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java
@@ -92,7 +92,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext {
if (0 == pixelFormat) {
throw new GLException("Error: current pixelformat of current Context 0x"+Long.toHexString(contextHandle)+" is null");
}
- GLCapabilities caps = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(glp, pixelFormat);
+ GLCapabilitiesImmutable caps = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(glp, pixelFormat);
if(DEBUG) {
System.err.println("MacOSXExternalCGLContext Create "+caps);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
index 5cf8c6eb9..93e5767b3 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
@@ -87,7 +87,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
if (newCreated) {
// Initialize render-to-texture support if requested
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
+ GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities();
GL gl = getGL();
boolean rect = gl.isGL2GL3() && capabilities.getPbufferRenderToTextureRectangle();
if (rect) {
@@ -136,7 +136,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
protected boolean createImpl() throws GLException {
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
+ GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities();
if (capabilities.getPbufferFloatingPointBuffers() &&
!isTigerOrLater) {
throw new GLException("Floating-point pbuffers supported only on OS X 10.4 or later");
@@ -224,7 +224,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
public boolean isNSContext() { return true; }
public long create() {
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
+ GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities();
if (capabilities.getPbufferFloatingPointBuffers() &&
!isTigerOrLater) {
throw new GLException("Floating-point pbuffers supported only on OS X 10.4 or later");
@@ -288,7 +288,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
int i = 0;
attrs[i++] = CGL.kCGLPFAPBuffer;
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
+ GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities();
if (capabilities.getPbufferFloatingPointBuffers())
attrs[i++] = CGL.kCGLPFAColorFloat;
if (capabilities.getDoubleBuffered())
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
index 14ed02918..37c6cfb70 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
@@ -110,7 +110,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
private void createPbuffer() {
NativeSurface ns = getNativeSurface();
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
+ GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities();
GLProfile glProfile = capabilities.getGLProfile();
int renderTarget;
if (glProfile.isGL2GL3() && capabilities.getPbufferRenderToTextureRectangle()) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
index af8841d3d..690e0466b 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -34,17 +35,24 @@ package com.jogamp.opengl.impl.macosx.cgl.awt;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
-import java.awt.GraphicsEnvironment;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.macosx.*;
-import javax.media.nativewindow.awt.*;
-import javax.media.opengl.*;
-import javax.media.opengl.awt.*;
-
-import com.jogamp.opengl.impl.*;
-import com.jogamp.opengl.impl.macosx.cgl.*;
-import com.jogamp.nativewindow.impl.jawt.*;
-import com.jogamp.nativewindow.impl.jawt.macosx.*;
+
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.CapabilitiesChooser;
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.nativewindow.DefaultGraphicsScreen;
+import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
+import javax.media.nativewindow.awt.AWTGraphicsDevice;
+import javax.media.nativewindow.awt.AWTGraphicsScreen;
+import javax.media.nativewindow.macosx.MacOSXGraphicsDevice;
+
+import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLException;
+
+import com.jogamp.opengl.impl.macosx.cgl.MacOSXCGLGraphicsConfiguration;
public class MacOSXAWTCGLGraphicsConfigurationFactory extends GraphicsConfigurationFactory {
protected static final boolean DEBUG = com.jogamp.opengl.impl.Debug.debug("GraphicsConfiguration");
@@ -54,7 +62,8 @@ public class MacOSXAWTCGLGraphicsConfigurationFactory extends GraphicsConfigurat
}
protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
- Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
+ CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
+ CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
GraphicsDevice device = null;
if (absScreen != null &&
!(absScreen instanceof AWTGraphicsScreen)) {
@@ -67,9 +76,12 @@ public class MacOSXAWTCGLGraphicsConfigurationFactory extends GraphicsConfigurat
AWTGraphicsScreen awtScreen = (AWTGraphicsScreen) absScreen;
device = ((AWTGraphicsDevice)awtScreen.getDevice()).getGraphicsDevice();
- if (capabilities != null &&
- !(capabilities instanceof GLCapabilities)) {
- throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects");
+ if ( !(capsChosen instanceof GLCapabilitiesImmutable) ) {
+ throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects - chosen");
+ }
+
+ if ( !(capsRequested instanceof GLCapabilitiesImmutable) ) {
+ throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects - requested");
}
if (chooser != null &&
@@ -81,8 +93,6 @@ public class MacOSXAWTCGLGraphicsConfigurationFactory extends GraphicsConfigurat
System.err.println("MacOSXAWTCGLGraphicsConfigurationFactory: got "+absScreen);
}
- long displayHandle = 0;
-
MacOSXGraphicsDevice macDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
DefaultGraphicsScreen macScreen = new DefaultGraphicsScreen(macDevice, awtScreen.getIndex());
if(DEBUG) {
@@ -90,18 +100,18 @@ public class MacOSXAWTCGLGraphicsConfigurationFactory extends GraphicsConfigurat
}
GraphicsConfiguration gc = device.getDefaultConfiguration();
- AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capabilities, gc);
+ capsChosen = (GLCapabilitiesImmutable) AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capsChosen, gc);
if(DEBUG) {
- System.err.println("AWT Colormodel compatible: "+capabilities);
+ System.err.println("AWT Colormodel compatible: "+capsChosen);
}
MacOSXCGLGraphicsConfiguration macConfig = (MacOSXCGLGraphicsConfiguration)
- GraphicsConfigurationFactory.getFactory(macDevice).chooseGraphicsConfiguration(capabilities,
- chooser,
- macScreen);
+ GraphicsConfigurationFactory.getFactory(macDevice).chooseGraphicsConfiguration(capsChosen,
+ capsRequested,
+ chooser, macScreen);
if (macConfig == null) {
- throw new GLException("Unable to choose a GraphicsConfiguration: "+capabilities+",\n\t"+chooser+"\n\t"+macScreen);
+ throw new GLException("Unable to choose a GraphicsConfiguration: "+capsChosen+",\n\t"+chooser+"\n\t"+macScreen);
}
// FIXME: we have nothing to match .. so choose the default
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
index 3f7028d56..054c01fdb 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
@@ -40,7 +40,6 @@
package com.jogamp.opengl.impl.windows.wgl;
-import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLProfile;
@@ -48,12 +47,14 @@ import javax.media.opengl.GLProfile;
import com.jogamp.nativewindow.impl.ProxySurface;
import com.jogamp.nativewindow.impl.windows.GDI;
import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
private long hwnd, hdc;
- public WindowsDummyWGLDrawable(GLDrawableFactory factory, GLProfile glp) {
- super(factory, new ProxySurface(WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(glp, null, true, true)), true);
+ protected WindowsDummyWGLDrawable(GLDrawableFactory factory, GLCapabilitiesImmutable caps) {
+ super(factory, new ProxySurface(WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(caps, null)), true);
// All entries to CreateDummyWindow must synchronize on one object
// to avoid accidentally registering the dummy window class twice
synchronized (WindowsDummyWGLDrawable.class) {
@@ -64,9 +65,7 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
ns.setSurfaceHandle(hdc);
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
// Choose a (hopefully hardware-accelerated) OpenGL pixel format for this device context
- GLCapabilities caps = (GLCapabilities) config.getChosenCapabilities();
- caps.setDepthBits(16);
- PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps);
+ PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.GLCapabilities2PFD((GLCapabilitiesImmutable)config.getChosenCapabilities());
int pixelFormat = GDI.ChoosePixelFormat(hdc, pfd);
if ((pixelFormat == 0) ||
(!GDI.SetPixelFormat(hdc, pixelFormat, pfd))) {
@@ -74,6 +73,15 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
}
}
+ public static WindowsDummyWGLDrawable create(GLDrawableFactory factory, GLProfile glp) {
+ GLCapabilities caps = new GLCapabilities(glp);
+ caps.setDepthBits(16);
+ caps.setDoubleBuffered(true);
+ caps.setOnscreen (true);
+ caps.setPBuffer (true);
+ return new WindowsDummyWGLDrawable(factory, caps);
+ }
+
public void setSize(int width, int height) {
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
index 8bb781a45..3452d3b55 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
@@ -42,7 +42,6 @@ package com.jogamp.opengl.impl.windows.wgl;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.SurfaceChangeable;
-import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLException;
@@ -50,6 +49,7 @@ import javax.media.opengl.GLException;
import com.jogamp.nativewindow.impl.windows.BITMAPINFO;
import com.jogamp.nativewindow.impl.windows.BITMAPINFOHEADER;
import com.jogamp.nativewindow.impl.windows.GDI;
+import javax.media.opengl.GLCapabilitiesImmutable;
public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
private long origbitmap;
@@ -75,7 +75,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
private void create() {
NativeSurface ns = getNativeSurface();
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getRequestedCapabilities();
+ GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getRequestedCapabilities();
int width = getWidth();
int height = getHeight();
BITMAPINFO info = BITMAPINFO.create();
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java
index abbaf5004..db86b3232 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java
@@ -89,7 +89,7 @@ public class WindowsPbufferWGLContext extends WindowsWGLContext {
protected void makeCurrentImpl(boolean newCreated) throws GLException {
super.makeCurrentImpl(newCreated);
if (newCreated) {
- GLCapabilities capabilities = drawable.getChosenGLCapabilities();
+ GLCapabilitiesImmutable capabilities = drawable.getChosenGLCapabilities();
// Initialize render-to-texture support if requested
GL gl = getGL();
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
index a5631aded..751ae5380 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -43,7 +43,6 @@ package com.jogamp.opengl.impl.windows.wgl;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.SurfaceChangeable;
import javax.media.opengl.GL;
-import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLException;
@@ -52,6 +51,7 @@ import javax.media.opengl.GLProfile;
import com.jogamp.nativewindow.impl.windows.GDI;
import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR;
+import javax.media.opengl.GLCapabilitiesImmutable;
public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
private WGLExt cachedWGLExt; // cached WGLExt instance from parent GLCanvas,
@@ -134,7 +134,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
int width, height;
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getRequestedCapabilities();
+ GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getRequestedCapabilities();
GLProfile glProfile = capabilities.getGLProfile();
if (DEBUG) {
@@ -302,7 +302,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
iattributes[niattribs++] = WGLExt.WGL_DRAW_TO_PBUFFER_ARB;
int[] ivalues = new int[niattribs];
if (wglExt.wglGetPixelFormatAttribivARB(parentHdc, pformats[whichFormat], 0, niattribs, iattributes, 0, ivalues, 0)) {
- GLCapabilities newCaps = WindowsWGLGraphicsConfiguration.AttribList2GLCapabilities(glProfile, iattributes, niattribs, ivalues, true, false, true);
+ GLCapabilitiesImmutable newCaps = WindowsWGLGraphicsConfiguration.AttribList2GLCapabilities(glProfile, iattributes, niattribs, ivalues, true, false, true);
PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.createPixelFormatDescriptor();
if (GDI.DescribePixelFormat(parentHdc, pformats[whichFormat], pfd.size(), pfd) == 0) {
if (DEBUG) {
@@ -318,7 +318,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
if (GDI.DescribePixelFormat(parentHdc, pformats[whichFormat], pfd.size(), pfd) == 0) {
throw new GLException("Unable to describe pixel format " + pformats[whichFormat]);
}
- GLCapabilities newCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, pfd, false, true);
+ GLCapabilitiesImmutable newCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, pfd, false, true);
if(newCaps.isOnscreen()) {
throw new GLException("Error: Selected Onscreen Caps for PBuffer: "+newCaps+"\n\t"+newCaps);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
index 529fda2c9..816532262 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -46,7 +46,6 @@ import java.util.Map;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
-import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLException;
@@ -56,6 +55,7 @@ import com.jogamp.nativewindow.impl.windows.GDI;
import com.jogamp.opengl.impl.GLContextImpl;
import com.jogamp.opengl.impl.GLContextShareSet;
import com.jogamp.opengl.impl.GLDrawableImpl;
+import javax.media.opengl.GLCapabilitiesImmutable;
public class WindowsWGLContext extends GLContextImpl {
@@ -232,7 +232,7 @@ public class WindowsWGLContext extends GLContextImpl {
AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
AbstractGraphicsDevice device = config.getScreen().getDevice();
WindowsWGLContext sharedContext = (WindowsWGLContext) factory.getOrCreateSharedContextImpl(device);
- GLCapabilities glCaps = drawable.getChosenGLCapabilities();
+ GLCapabilitiesImmutable glCaps = drawable.getChosenGLCapabilities();
// Windows can set up sharing of display lists after creation time
WindowsWGLContext other = (WindowsWGLContext) GLContextShareSet.getShareContext(this);
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
index 462079913..51c5875cc 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -55,7 +55,6 @@ import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.NativeWindowFactory;
import javax.media.nativewindow.windows.WindowsGraphicsDevice;
-import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawable;
@@ -66,11 +65,11 @@ import com.jogamp.common.JogampRuntimeException;
import com.jogamp.common.util.ReflectionUtil;
import com.jogamp.nativewindow.impl.ProxySurface;
import com.jogamp.nativewindow.impl.windows.GDI;
-import com.jogamp.opengl.impl.Debug;
import com.jogamp.opengl.impl.DesktopGLDynamicLookupHelper;
import com.jogamp.opengl.impl.GLDrawableFactoryImpl;
import com.jogamp.opengl.impl.GLDrawableImpl;
import com.jogamp.opengl.impl.GLDynamicLookupHelper;
+import javax.media.opengl.GLCapabilitiesImmutable;
public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
private static final DesktopGLDynamicLookupHelper windowsWGLDynamicLookupHelper;
@@ -157,7 +156,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
addDeviceTried(connection);
NativeWindowFactory.getDefaultToolkitLock().lock(); // OK
try {
- WindowsDummyWGLDrawable sharedDrawable = new WindowsDummyWGLDrawable(this, null);
+ WindowsDummyWGLDrawable sharedDrawable = WindowsDummyWGLDrawable.create(this, null);
WindowsWGLContext ctx = (WindowsWGLContext) sharedDrawable.createContext(null);
ctx.makeCurrent();
boolean canCreateGLPbuffer = ctx.getGL().isExtensionAvailable("GL_ARB_pbuffer");
@@ -276,10 +275,10 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
return (GLDrawableImpl) returnList.get(0);
}
- protected final NativeSurface createOffscreenSurfaceImpl(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
+ protected final NativeSurface createOffscreenSurfaceImpl(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) {
AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS);
ProxySurface ns = new ProxySurface(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
- capabilities, chooser, screen) );
+ capsChosen, capsRequested, chooser, screen) );
ns.setSize(width, height);
return ns;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index 6c006577e..f714c7719 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -49,6 +49,7 @@ import javax.media.opengl.GLProfile;
import com.jogamp.nativewindow.impl.windows.GDI;
import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR;
import com.jogamp.opengl.impl.GLContextImpl;
+import javax.media.opengl.GLCapabilitiesImmutable;
public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable {
// Keep this under the same debug flag as the drawable factory for convenience
@@ -63,7 +64,8 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
private GLCapabilitiesChooser chooser;
private boolean choosenByWGLPixelFormat=false;
- public WindowsWGLGraphicsConfiguration(AbstractGraphicsScreen screen, GLCapabilities capsChosen, GLCapabilities capsRequested,
+ public WindowsWGLGraphicsConfiguration(AbstractGraphicsScreen screen,
+ GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested,
PIXELFORMATDESCRIPTOR pixelfmt, int pixelfmtID, GLCapabilitiesChooser chooser) {
super(screen, capsChosen, capsRequested);
this.chooser=chooser;
@@ -85,7 +87,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
throw new GLException("Unable to describe pixel format " + pfdID);
}
- GLCapabilities caps = PFD2GLCapabilities(glp, pfd, onscreen, usePBuffer);
+ GLCapabilitiesImmutable caps = PFD2GLCapabilities(glp, pfd, onscreen, usePBuffer);
if(null==caps) {
throw new GLException("Couldn't choose Capabilities by: HDC 0x"+Long.toHexString(hdc)+", pfdID "+pfdID);
}
@@ -108,7 +110,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
protected void updateCapabilitiesByWGL(GLContextImpl context) {
if(choosenByWGLPixelFormat) return; // already done ..
- GLCapabilities capabilities = (GLCapabilities) getRequestedCapabilities();
+ GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable) getRequestedCapabilities();
boolean onscreen = capabilities.isOnscreen();
boolean usePBuffer = capabilities.isPBuffer();
GLProfile glp = capabilities.getGLProfile();
@@ -118,13 +120,13 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
NativeSurface ns = drawable.getNativeSurface();
long hdc = ns.getSurfaceHandle();
- GLCapabilities[] caps = HDC2GLCapabilities(wglExt, hdc, getPixelFormatID(), glp, true, onscreen, usePBuffer);
+ GLCapabilitiesImmutable[] caps = HDC2GLCapabilities(wglExt, hdc, getPixelFormatID(), glp, true, onscreen, usePBuffer);
if(null!=caps && null!=caps[0]) {
setCapsPFD(caps[0], getPixelFormat(), getPixelFormatID(), true);
}
}
- protected void setCapsPFD(GLCapabilities caps, PIXELFORMATDESCRIPTOR pfd, int pfdID, boolean choosenByWGLPixelFormat) {
+ protected void setCapsPFD(GLCapabilitiesImmutable caps, PIXELFORMATDESCRIPTOR pfd, int pfdID, boolean choosenByWGLPixelFormat) {
this.pixelfmt = pfd;
this.pixelfmtID = pfdID;
setChosenCapabilities(caps);
@@ -146,8 +148,8 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
private static int haveWGLChoosePixelFormatARB = -1;
private static int haveWGLARBMultisample = -1;
- public static GLCapabilities[] HDC2GLCapabilities(WGLExt wglExt, long hdc, int pfdIDOnly,
- GLProfile glp, boolean relaxed, boolean onscreen, boolean usePBuffer) {
+ public static GLCapabilitiesImmutable[] HDC2GLCapabilities(WGLExt wglExt, long hdc, int pfdIDOnly,
+ GLProfile glp, boolean relaxed, boolean onscreen, boolean usePBuffer) {
if(haveWGLChoosePixelFormatARB<0) {
haveWGLChoosePixelFormatARB = wglExt.isExtensionAvailable("WGL_ARB_pixel_format")?1:0;
@@ -168,7 +170,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
// "HardwareAccelerated" bit, which is basically
// meaningless, and put in whether it can render to a
// window, to a pbuffer, or to a pixmap)
- GLCapabilities[] availableCaps = null;
+ GLCapabilitiesImmutable[] availableCaps = null;
int numFormats = 0;
int niattribs = 0;
int[] iattributes = new int [2*MAX_ATTRIBS];
@@ -212,14 +214,14 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
}
if(pfdIDOnly>0) {
- availableCaps = new GLCapabilities[1];
+ availableCaps = new GLCapabilitiesImmutable[1];
if (!wglExt.wglGetPixelFormatAttribivARB(hdc, pfdIDOnly, 0, niattribs, iattributes, 0, iresults, 0)) {
throw new GLException("Error getting pixel format attributes for pixel format " + pfdIDOnly + " of device context");
}
availableCaps[0] = AttribList2GLCapabilities(glp, iattributes, niattribs, iresults,
relaxed, onscreen, usePBuffer);
} else {
- availableCaps = new GLCapabilities[numFormats];
+ availableCaps = new GLCapabilitiesImmutable[numFormats];
for (int i = 0; i < numFormats; i++) {
if (!wglExt.wglGetPixelFormatAttribivARB(hdc, i+1, 0, niattribs, iattributes, 0, iresults, 0)) {
throw new GLException("Error getting pixel format attributes for pixel format " + (i + 1) + " of device context");
@@ -238,11 +240,11 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
return availableCaps;
}
- public static boolean GLCapabilities2AttribList(GLCapabilities caps,
- int[] iattributes,
- WGLExt wglExt,
- boolean pbuffer,
- int[] floatMode) throws GLException {
+ public static boolean GLCapabilities2AttribList(GLCapabilitiesImmutable caps,
+ int[] iattributes,
+ WGLExt wglExt,
+ boolean pbuffer,
+ int[] floatMode) throws GLException {
if (!wglExt.isExtensionAvailable("WGL_ARB_pixel_format")) {
return false;
}
@@ -436,7 +438,8 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
return res;
}
- public static GLCapabilities AttribList2GLCapabilities(GLProfile glp, int[] iattribs,
+ public static GLCapabilitiesImmutable AttribList2GLCapabilities(
+ GLProfile glp, int[] iattribs,
int niattribs,
int[] iresults,
boolean relaxed, boolean onscreen, boolean usePBuffer) {
@@ -552,7 +555,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
// PIXELFORMAT
- public static GLCapabilities PFD2GLCapabilities(GLProfile glp, PIXELFORMATDESCRIPTOR pfd, boolean onscreen, boolean usePBuffer) {
+ public static GLCapabilitiesImmutable PFD2GLCapabilities(GLProfile glp, PIXELFORMATDESCRIPTOR pfd, boolean onscreen, boolean usePBuffer) {
if ((pfd.getDwFlags() & GDI.PFD_SUPPORT_OPENGL) == 0) {
return null;
}
@@ -586,7 +589,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
return res;
}
- public static PIXELFORMATDESCRIPTOR GLCapabilities2PFD(GLCapabilities caps) {
+ public static PIXELFORMATDESCRIPTOR GLCapabilities2PFD(GLCapabilitiesImmutable caps) {
int colorDepth = (caps.getRedBits() +
caps.getGreenBits() +
caps.getBlueBits());
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index 1d8f14d94..46b169343 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -36,7 +36,6 @@ package com.jogamp.opengl.impl.windows.wgl;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.AbstractGraphicsScreen;
-import javax.media.nativewindow.Capabilities;
import javax.media.nativewindow.CapabilitiesChooser;
import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.GraphicsConfigurationFactory;
@@ -51,6 +50,8 @@ import javax.media.opengl.GLProfile;
import com.jogamp.nativewindow.impl.windows.GDI;
import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR;
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.opengl.GLCapabilitiesImmutable;
/** Subclass of GraphicsConfigurationFactory used when non-AWT tookits
are used on Windows platforms. Toolkits will likely need to delegate
@@ -65,36 +66,44 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
}
protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
- Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
- GLCapabilities caps = (GLCapabilities)capabilities;
- return chooseGraphicsConfigurationStatic(caps, chooser, absScreen);
- }
+ CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
+
+ if (! (capsChosen instanceof GLCapabilitiesImmutable) ) {
+ throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - chosen");
+ }
- protected static WindowsWGLGraphicsConfiguration createDefaultGraphicsConfiguration(GLProfile glp, AbstractGraphicsScreen absScreen, boolean onscreen, boolean usePBuffer) {
- GLCapabilities caps = new GLCapabilities(glp);
- caps.setDoubleBuffered(onscreen); // FIXME DBLBUFOFFSCRN
- caps.setOnscreen (onscreen);
- caps.setPBuffer (usePBuffer);
+ if (! (capsRequested instanceof GLCapabilitiesImmutable) ) {
+ throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - requested");
+ }
+
+ return chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested, chooser, absScreen);
+ }
+ protected static WindowsWGLGraphicsConfiguration createDefaultGraphicsConfiguration(GLCapabilitiesImmutable caps,
+ AbstractGraphicsScreen absScreen) {
if(null==absScreen) {
absScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS);
}
return new WindowsWGLGraphicsConfiguration(absScreen, caps, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps), -1, null);
-
}
- protected static WindowsWGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilities caps,
+ protected static WindowsWGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilitiesImmutable capsChosen,
+ GLCapabilitiesImmutable capsReq,
CapabilitiesChooser chooser,
AbstractGraphicsScreen absScreen) {
if(null==absScreen) {
absScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS);
}
- GLCapabilities caps2 = (GLCapabilities) caps.clone();
- if(!caps2.isOnscreen()) {
+
+ if(!capsChosen.isOnscreen() && capsChosen.getDoubleBuffered()) {
// OFFSCREEN !DOUBLE_BUFFER // FIXME DBLBUFOFFSCRN
+ GLCapabilities caps2 = (GLCapabilities) capsChosen.cloneMutable();
caps2.setDoubleBuffered(false);
+ capsChosen = caps2;
}
- return new WindowsWGLGraphicsConfiguration(absScreen, caps2, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps2), -1,
+
+ return new WindowsWGLGraphicsConfiguration(absScreen, capsChosen, capsReq,
+ WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(capsChosen), -1,
(GLCapabilitiesChooser)chooser);
}
@@ -117,7 +126,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
throw new InternalError("SharedContext is null: "+device);
}
boolean choosenBywGLPixelFormat = false;
- GLCapabilities capabilities = (GLCapabilities) config.getRequestedCapabilities();
+ GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable) config.getChosenCapabilities();
boolean onscreen = capabilities.isOnscreen();
boolean usePBuffer = capabilities.isPBuffer();
GLProfile glProfile = capabilities.getGLProfile();
@@ -134,7 +143,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
PIXELFORMATDESCRIPTOR pfd = null;
int pixelFormat = -1; // 1-based pixel format
boolean pixelFormatSet = false;
- GLCapabilities chosenCaps = null;
+ GLCapabilitiesImmutable chosenCaps = null;
if (onscreen) {
if ((pixelFormat = GDI.GetPixelFormat(hdc)) != 0) {
@@ -149,7 +158,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
pixelFormatSet = true;
}
- GLCapabilities[] availableCaps = null;
+ GLCapabilitiesImmutable[] availableCaps = null;
int numFormats = 0;
pfd = WindowsWGLGraphicsConfiguration.createPixelFormatDescriptor();
// Produce a recommended pixel format selection for the GLCapabilitiesChooser.
@@ -234,7 +243,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
throw new GLException("Unable to enumerate pixel formats of window " +
toHexString(hdc) + " for GLCapabilitiesChooser (LastError: "+GDI.GetLastError()+")");
}
- availableCaps = new GLCapabilities[numFormats];
+ availableCaps = new GLCapabilitiesImmutable[numFormats];
for (int i = 0; i < numFormats; i++) {
if (GDI.DescribePixelFormat(hdc, 1 + i, pfd.size(), pfd) == 0) {
throw new GLException("Error describing pixel format " + (1 + i) + " of device context");
@@ -255,7 +264,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
pixelFormat = chooser.chooseCapabilities(capabilities, availableCaps, recommendedPixelFormat) + 1;
} catch (NativeWindowException e) {
if(DEBUG) {
- e.printStackTrace();
+ e.printStackTrace();
}
pixelFormat = -1;
}
@@ -315,11 +324,12 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
config.setCapsPFD(capabilities, pfd, pixelFormat, choosenBywGLPixelFormat);
}
- protected static String getThreadName() {
- return Thread.currentThread().getName();
- }
- public static String toHexString(long hex) {
- return "0x" + Long.toHexString(hex);
- }
+ protected static String getThreadName() {
+ return Thread.currentThread().getName();
+ }
+
+ public static String toHexString(long hex) {
+ return "0x" + Long.toHexString(hex);
+ }
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
index 48850440d..363881ef0 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
@@ -32,19 +32,27 @@
package com.jogamp.opengl.impl.windows.wgl.awt;
+
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
-import java.awt.GraphicsEnvironment;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.windows.*;
-import javax.media.nativewindow.awt.*;
-import javax.media.opengl.*;
-import javax.media.opengl.awt.*;
-
-import com.jogamp.opengl.impl.*;
-import com.jogamp.opengl.impl.windows.wgl.*;
-import com.jogamp.nativewindow.impl.jawt.*;
-import com.jogamp.nativewindow.impl.jawt.windows.*;
+
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.CapabilitiesChooser;
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.nativewindow.DefaultGraphicsScreen;
+import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
+import javax.media.nativewindow.awt.AWTGraphicsDevice;
+import javax.media.nativewindow.awt.AWTGraphicsScreen;
+import javax.media.nativewindow.windows.WindowsGraphicsDevice;
+
+import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLException;
+
+import com.jogamp.opengl.impl.windows.wgl.WindowsWGLGraphicsConfiguration;
public class WindowsAWTWGLGraphicsConfigurationFactory extends GraphicsConfigurationFactory {
protected static final boolean DEBUG = com.jogamp.opengl.impl.Debug.debug("GraphicsConfiguration");
@@ -54,7 +62,8 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GraphicsConfigura
}
protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
- Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
+ CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
+ CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
GraphicsDevice device = null;
if (absScreen != null &&
!(absScreen instanceof AWTGraphicsScreen)) {
@@ -67,9 +76,12 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GraphicsConfigura
AWTGraphicsScreen awtScreen = (AWTGraphicsScreen) absScreen;
device = ((AWTGraphicsDevice)awtScreen.getDevice()).getGraphicsDevice();
- if (capabilities != null &&
- !(capabilities instanceof GLCapabilities)) {
- throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects");
+ if ( !(capsChosen instanceof GLCapabilitiesImmutable) ) {
+ throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects - chosen");
+ }
+
+ if ( !(capsRequested instanceof GLCapabilitiesImmutable) ) {
+ throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects - requested");
}
if (chooser != null &&
@@ -81,13 +93,11 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GraphicsConfigura
System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: got "+absScreen);
}
GraphicsConfiguration gc = device.getDefaultConfiguration();
- AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capabilities, gc);
+ capsChosen = AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capsChosen, gc);
if(DEBUG) {
- System.err.println("AWT Colormodel compatible: "+capabilities);
+ System.err.println("AWT Colormodel compatible: "+capsChosen);
}
- long displayHandle = 0;
-
WindowsGraphicsDevice winDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
DefaultGraphicsScreen winScreen = new DefaultGraphicsScreen(winDevice, awtScreen.getIndex());
if(DEBUG) {
@@ -95,12 +105,12 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GraphicsConfigura
}
WindowsWGLGraphicsConfiguration winConfig = (WindowsWGLGraphicsConfiguration)
- GraphicsConfigurationFactory.getFactory(winDevice).chooseGraphicsConfiguration(capabilities,
- chooser,
- winScreen);
+ GraphicsConfigurationFactory.getFactory(winDevice).chooseGraphicsConfiguration(capsChosen,
+ capsRequested,
+ chooser, winScreen);
if (winConfig == null) {
- throw new GLException("Unable to choose a GraphicsConfiguration: "+capabilities+",\n\t"+chooser+"\n\t"+winScreen);
+ throw new GLException("Unable to choose a GraphicsConfiguration: "+capsChosen+",\n\t"+chooser+"\n\t"+winScreen);
}
if(DEBUG) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java
index e77735637..6c8d1fc91 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java
@@ -43,10 +43,10 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable {
* we cannot switch the Display as we please,
* hence we reuse the target's screen configuration.
*/
- public X11DummyGLXDrawable(X11GraphicsScreen screen, GLDrawableFactory factory, GLProfile glp) {
+ public X11DummyGLXDrawable(X11GraphicsScreen screen, GLDrawableFactory factory, GLCapabilitiesImmutable caps) {
super(factory,
new ProxySurface(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
- new GLCapabilities(glp), null, screen)));
+ caps, caps, null, screen)));
this.realized = true;
ProxySurface ns = (ProxySurface) getNativeSurface();
@@ -63,6 +63,11 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable {
updateHandle();
}
+ public static X11DummyGLXDrawable create(X11GraphicsScreen screen, GLDrawableFactory factory, GLProfile glp) {
+ GLCapabilities caps = new GLCapabilities(glp);
+ return new X11DummyGLXDrawable(screen, factory, caps);
+ }
+
public void setSize(int width, int height) {
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
index 63b758da3..1dadc2edf 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
@@ -268,7 +268,7 @@ public abstract class X11GLXContext extends GLContextImpl {
direct = GLX.glXIsDirect(display, share);
}
- GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities();
+ GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
GLProfile glp = glCaps.getGLProfile();
isVendorATI = factory.isVendorATI(device);
@@ -494,7 +494,7 @@ public abstract class X11GLXContext extends GLContextImpl {
protected void setSwapIntervalImpl(int interval) {
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities();
+ GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
if(!glCaps.isOnscreen()) return;
GLXExt glXExt = getGLXExt();
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index d98d8a436..d4df76315 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -210,7 +210,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
try {
String vendorName = GLXUtil.getVendorName(sharedDevice.getHandle());
X11GraphicsScreen sharedScreen = new X11GraphicsScreen(sharedDevice, 0);
- X11DummyGLXDrawable sharedDrawable = new X11DummyGLXDrawable(sharedScreen, X11GLXDrawableFactory.this, GLProfile.getDefault(sharedDevice));
+ X11DummyGLXDrawable sharedDrawable = X11DummyGLXDrawable.create(sharedScreen, X11GLXDrawableFactory.this,
+ GLProfile.getDefault(sharedDevice));
if (null == sharedScreen || null == sharedDrawable) {
throw new GLException("Couldn't init shared screen(" + sharedScreen + ")/drawable(" + sharedDrawable + ")");
}
@@ -482,7 +483,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
- protected final NativeSurface createOffscreenSurfaceImpl(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
+ protected final NativeSurface createOffscreenSurfaceImpl(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser,
+ int width, int height) {
X11GraphicsScreen screen = null;
SharedResource sr = getOrCreateShared(defaultDevice);
if(null!=sr) {
@@ -493,7 +495,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
ProxySurface ns = new ProxySurface(
- X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, screen) );
+ X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen) );
if(ns != null) {
ns.setSize(width, height);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
index b2bc59578..9cb00b198 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -48,7 +49,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
private GLCapabilitiesChooser chooser;
public X11GLXGraphicsConfiguration(X11GraphicsScreen screen,
- GLCapabilities capsChosen, GLCapabilities capsRequested, GLCapabilitiesChooser chooser,
+ GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser,
XVisualInfo info, long fbcfg, int fbcfgID) {
super(screen, capsChosen, capsRequested, info);
this.chooser=chooser;
@@ -69,7 +70,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
if(null==glp) {
glp = GLProfile.getDefault(x11Screen.getDevice());
}
- GLCapabilities caps = GLXFBConfig2GLCapabilities(glp, display, fbcfg, true, true, true, GLXUtil.isMultisampleAvailable(display));
+ GLCapabilitiesImmutable caps = GLXFBConfig2GLCapabilities(glp, display, fbcfg, true, true, true, GLXUtil.isMultisampleAvailable(display));
if(null==caps) {
throw new GLException("GLCapabilities null of "+toHexString(fbcfg));
}
@@ -89,9 +90,8 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
protected void updateGraphicsConfiguration() {
X11GLXGraphicsConfiguration newConfig = (X11GLXGraphicsConfiguration)
- GraphicsConfigurationFactory.getFactory(getScreen().getDevice()).chooseGraphicsConfiguration(getRequestedCapabilities().cloneCapabilites(),
- chooser,
- getScreen());
+ GraphicsConfigurationFactory.getFactory(getScreen().getDevice()).chooseGraphicsConfiguration(
+ getChosenCapabilities(), getRequestedCapabilities(), chooser, getScreen());
if(null!=newConfig) {
// FIXME: setScreen( ... );
setXVisualInfo(newConfig.getXVisualInfo());
@@ -108,7 +108,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
return value != 0 ? value : (int)GLX.GLX_DONT_CARE ;
}
- public static int[] GLCapabilities2AttribList(GLCapabilities caps,
+ public static int[] GLCapabilities2AttribList(GLCapabilitiesImmutable caps,
boolean forFBAttr,
boolean isMultisampleAvailable,
long display,
@@ -236,8 +236,9 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
return res;
}
- public static GLCapabilities GLXFBConfig2GLCapabilities(GLProfile glp, long display, long fbcfg,
- boolean relaxed, boolean onscreen, boolean usePBuffer, boolean isMultisampleEnabled) {
+ public static GLCapabilitiesImmutable GLXFBConfig2GLCapabilities(GLProfile glp, long display, long fbcfg,
+ boolean relaxed, boolean onscreen, boolean usePBuffer,
+ boolean isMultisampleEnabled) {
int[] tmp = new int[1];
int val;
val = glXGetFBConfig(display, fbcfg, GLX.GLX_RENDER_TYPE, tmp, 0);
@@ -351,7 +352,8 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
return res;
}
- public static GLCapabilities XVisualInfo2GLCapabilities(GLProfile glp, long display, XVisualInfo info, boolean onscreen, boolean usePBuffer, boolean isMultisampleEnabled) {
+ public static GLCapabilitiesImmutable XVisualInfo2GLCapabilities(GLProfile glp, long display, XVisualInfo info,
+ boolean onscreen, boolean usePBuffer, boolean isMultisampleEnabled) {
int[] tmp = new int[1];
int val = glXGetConfig(display, info, GLX.GLX_USE_GL, tmp, 0);
if (val == 0) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 8dbd69dce..1b20040b0 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,13 +33,26 @@
package com.jogamp.opengl.impl.x11.glx;
-import com.jogamp.common.nio.PointerBuffer;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.*;
-import com.jogamp.nativewindow.impl.x11.*;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.AbstractGraphicsScreen;
+import javax.media.nativewindow.CapabilitiesChooser;
+import javax.media.nativewindow.CapabilitiesImmutable;
+import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.x11.X11GraphicsScreen;
+import javax.media.opengl.DefaultGLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesChooser;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
-import javax.media.opengl.*;
-import com.jogamp.opengl.impl.*;
+import com.jogamp.common.nio.PointerBuffer;
+import com.jogamp.nativewindow.impl.x11.X11Lib;
+import com.jogamp.nativewindow.impl.x11.X11Util;
+import com.jogamp.nativewindow.impl.x11.XVisualInfo;
+import com.jogamp.opengl.impl.Debug;
/** Subclass of GraphicsConfigurationFactory used when non-AWT toolkits
@@ -54,19 +68,24 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
- Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
+ CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
if (!(absScreen instanceof X11GraphicsScreen)) {
throw new IllegalArgumentException("Only X11GraphicsScreen are allowed here");
}
- if (capabilities != null && !(capabilities instanceof GLCapabilities)) {
- throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects");
+ if ( !(capsChosen instanceof GLCapabilitiesImmutable) ) {
+ throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - chosen");
+ }
+
+ if ( !(capsRequested instanceof GLCapabilitiesImmutable)) {
+ throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - requested");
}
if (chooser != null && !(chooser instanceof GLCapabilitiesChooser)) {
throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects");
}
- return chooseGraphicsConfigurationStatic((GLCapabilities)capabilities, (GLCapabilitiesChooser)chooser, (X11GraphicsScreen)absScreen);
+ return chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested,
+ (GLCapabilitiesChooser)chooser, (X11GraphicsScreen)absScreen);
}
/**
@@ -119,56 +138,58 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
return new X11GLXGraphicsConfiguration(x11Screen, (null!=capsFB)?capsFB:caps, caps, null, xvis, fbcfg, fbid);
} */
- protected static X11GLXGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- X11GraphicsScreen x11Screen) {
+ protected static X11GLXGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilitiesImmutable capsChosen,
+ GLCapabilitiesImmutable capsReq,
+ GLCapabilitiesChooser chooser,
+ X11GraphicsScreen x11Screen) {
if (x11Screen == null) {
throw new IllegalArgumentException("AbstractGraphicsScreen is null");
}
- if (capabilities == null) {
- capabilities = new GLCapabilities(null);
+ if (capsChosen == null) {
+ capsChosen = new GLCapabilities(null);
}
- GLCapabilities caps2 = (GLCapabilities) capabilities.clone();
-
- boolean usePBuffer = caps2.isPBuffer();
-
- if(!caps2.isOnscreen()) {
+ if(!capsChosen.isOnscreen() && capsChosen.getDoubleBuffered()) {
// OFFSCREEN !DOUBLE_BUFFER // FIXME DBLBUFOFFSCRN
+ GLCapabilities caps2 = (GLCapabilities) capsChosen.cloneMutable();
caps2.setDoubleBuffered(false);
+ capsChosen = caps2;
}
+
+ boolean usePBuffer = capsChosen.isPBuffer();
X11GLXGraphicsConfiguration res;
- res = chooseGraphicsConfigurationFBConfig(caps2, chooser, x11Screen);
+ res = chooseGraphicsConfigurationFBConfig(capsChosen, capsReq, chooser, x11Screen);
if(null==res) {
if(usePBuffer) {
- throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig for "+caps2);
+ throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig for "+capsChosen);
}
- res = chooseGraphicsConfigurationXVisual(caps2, chooser, x11Screen);
+ res = chooseGraphicsConfigurationXVisual(capsChosen, capsReq, chooser, x11Screen);
}
if(null==res) {
- throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig and XVisual for "+caps2);
+ throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig and XVisual for "+capsChosen);
}
if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationStatic("+x11Screen+","+caps2+"): "+res);
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationStatic("+x11Screen+","+capsChosen+"): "+res);
}
return res;
}
- private static X11GLXGraphicsConfiguration chooseGraphicsConfigurationFBConfig(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- X11GraphicsScreen x11Screen) {
+ private static X11GLXGraphicsConfiguration chooseGraphicsConfigurationFBConfig(GLCapabilitiesImmutable capsChosen,
+ GLCapabilitiesImmutable capsReq,
+ GLCapabilitiesChooser chooser,
+ X11GraphicsScreen x11Screen) {
long recommendedFBConfig = 0;
int recommendedIndex = -1;
- GLCapabilities[] caps = null;
+ GLCapabilitiesImmutable[] caps = null;
PointerBuffer fbcfgsL = null;
int chosen=-1;
int retFBID=-1;
XVisualInfo retXVisualInfo = null;
- GLProfile glProfile = capabilities.getGLProfile();
- boolean onscreen = capabilities.isOnscreen();
- boolean usePBuffer = capabilities.isPBuffer();
+ GLProfile glProfile = capsChosen.getGLProfile();
+ boolean onscreen = capsChosen.isOnscreen();
+ boolean usePBuffer = capsChosen.isPBuffer();
// Utilizing FBConfig
//
@@ -177,18 +198,18 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
int screen = x11Screen.getIndex();
boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
- int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, true, isMultisampleAvailable, display, screen);
+ int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capsChosen, true, isMultisampleAvailable, display, screen);
int[] count = { -1 };
// determine the recommended FBConfig ..
fbcfgsL = GLX.glXChooseFBConfig(display, screen, attribs, 0, count, 0);
if (fbcfgsL == null || fbcfgsL.limit()<1) {
if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXChooseFBConfig ("+x11Screen+","+capabilities+"): "+fbcfgsL+", "+count[0]);
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXChooseFBConfig ("+x11Screen+","+capsChosen+"): "+fbcfgsL+", "+count[0]);
}
} else if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(0) ) ) {
if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed - GLX FBConfig invalid: ("+x11Screen+","+capabilities+"): "+fbcfgsL+", fbcfg: "+toHexString(fbcfgsL.get(0)));
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed - GLX FBConfig invalid: ("+x11Screen+","+capsChosen+"): "+fbcfgsL+", fbcfg: "+toHexString(fbcfgsL.get(0)));
}
} else {
recommendedFBConfig = fbcfgsL.get(0);
@@ -204,11 +225,11 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
// make GLCapabilities and seek the recommendedIndex
- caps = new GLCapabilities[fbcfgsL.limit()];
+ caps = new GLCapabilitiesImmutable[fbcfgsL.limit()];
for (int i = 0; i < fbcfgsL.limit(); i++) {
if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(i) ) ) {
if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid: ("+x11Screen+","+capabilities+"): fbcfg: "+toHexString(fbcfgsL.get(i)));
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid: ("+x11Screen+","+capsChosen+"): fbcfg: "+toHexString(fbcfgsL.get(i)));
}
} else {
caps[i] = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfgsL.get(i),
@@ -232,7 +253,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
chooser = new DefaultGLCapabilitiesChooser();
}
try {
- chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
+ chosen = chooser.chooseCapabilities(capsChosen, caps, recommendedIndex);
} catch (NativeWindowException e) {
if(DEBUG) {
e.printStackTrace();
@@ -246,7 +267,9 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig Failed .. unable to choose config, using first");
}
// seek first available one ..
- for(chosen = 0; chosen < caps.length && caps[chosen]==null; chosen++) ;
+ for(chosen = 0; chosen < caps.length && caps[chosen]==null; chosen++) {
+ // nop
+ }
if(chosen==caps.length) {
// give up ..
if(DEBUG) {
@@ -274,12 +297,13 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
}
- return new X11GLXGraphicsConfiguration(x11Screen, caps[chosen], capabilities, chooser, retXVisualInfo, fbcfgsL.get(chosen), retFBID);
+ return new X11GLXGraphicsConfiguration(x11Screen, caps[chosen], capsReq, chooser, retXVisualInfo, fbcfgsL.get(chosen), retFBID);
}
- private static X11GLXGraphicsConfiguration chooseGraphicsConfigurationXVisual(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- X11GraphicsScreen x11Screen) {
+ private static X11GLXGraphicsConfiguration chooseGraphicsConfigurationXVisual(GLCapabilitiesImmutable capsChosen,
+ GLCapabilitiesImmutable capsReq,
+ GLCapabilitiesChooser chooser,
+ X11GraphicsScreen x11Screen) {
if (chooser == null) {
chooser = new DefaultGLCapabilitiesChooser();
}
@@ -288,9 +312,9 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
// in pure Java, we're going to provide the underlying window
// system's selection to the chooser as a hint
- GLProfile glProfile = capabilities.getGLProfile();
- boolean onscreen = capabilities.isOnscreen();
- GLCapabilities[] caps = null;
+ GLProfile glProfile = capsChosen.getGLProfile();
+ boolean onscreen = capsChosen.isOnscreen();
+ GLCapabilitiesImmutable[] caps = null;
int recommendedIndex = -1;
XVisualInfo retXVisualInfo = null;
int chosen=-1;
@@ -300,7 +324,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
int screen = x11Screen.getIndex();
boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
- int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, isMultisampleAvailable, display, screen);
+ int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capsChosen, false, isMultisampleAvailable, display, screen);
XVisualInfo[] infos = null;
XVisualInfo recommendedVis = GLX.glXChooseVisual(display, screen, attribs, 0);
@@ -319,7 +343,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
if (infos == null || infos.length<1) {
throw new GLException("Error while enumerating available XVisualInfos");
}
- caps = new GLCapabilities[infos.length];
+ caps = new GLCapabilitiesImmutable[infos.length];
for (int i = 0; i < infos.length; i++) {
caps[i] = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, infos[i], onscreen, false, isMultisampleAvailable);
// Attempt to find the visual chosen by glXChooseVisual
@@ -328,7 +352,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
}
try {
- chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
+ chosen = chooser.chooseCapabilities(capsChosen, caps, recommendedIndex);
} catch (NativeWindowException e) {
if(DEBUG) {
e.printStackTrace();
@@ -348,7 +372,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
throw new GLException("GLCapabilitiesChooser chose an invalid visual for "+caps[chosen]);
}
retXVisualInfo = XVisualInfo.create(infos[chosen]);
- return new X11GLXGraphicsConfiguration(x11Screen, caps[chosen], capabilities, chooser, retXVisualInfo, 0, -1);
+ return new X11GLXGraphicsConfiguration(x11Screen, caps[chosen], capsReq, chooser, retXVisualInfo, 0, -1);
}
public static String toHexString(int val) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java
index 7054faa0c..5ae641278 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java
@@ -55,7 +55,7 @@ public class X11OffscreenGLXContext extends X11GLXContext {
}
public int getOffscreenContextReadBuffer() {
- GLCapabilities caps = (GLCapabilities)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+ GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
if (caps.getDoubleBuffered()) {
return GL.GL_BACK;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
index b86394cc6..41cd543aa 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
@@ -94,7 +94,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
NativeSurface ns = getNativeSurface();
- GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
+ GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities();
if (capabilities.getPbufferRenderToTexture()) {
throw new GLException("Render-to-texture pbuffers not supported yet on X11");
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
index d4af56aca..03955b439 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -51,7 +52,8 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfiguration
}
protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
- Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
+ CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
+ CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) {
GraphicsDevice device = null;
if (absScreen != null &&
!(absScreen instanceof AWTGraphicsScreen)) {
@@ -64,9 +66,12 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfiguration
AWTGraphicsScreen awtScreen = (AWTGraphicsScreen) absScreen;
device = ((AWTGraphicsDevice)awtScreen.getDevice()).getGraphicsDevice();
- if (capabilities != null &&
- !(capabilities instanceof GLCapabilities)) {
- throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects");
+ if ( !(capsChosen instanceof GLCapabilitiesImmutable) ) {
+ throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects - chosen");
+ }
+
+ if ( !(capsRequested instanceof GLCapabilitiesImmutable) ) {
+ throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only GLCapabilities objects - requested");
}
if (chooser != null &&
@@ -103,14 +108,14 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfiguration
}
gc = device.getDefaultConfiguration();
- AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capabilities, gc);
+ capsChosen = AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capsChosen, gc);
if(DEBUG) {
- System.err.println("AWT Colormodel compatible: "+capabilities);
+ System.err.println("AWT Colormodel compatible: "+capsChosen);
}
GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(x11Device);
- x11Config = (X11GraphicsConfiguration)factory.chooseGraphicsConfiguration(capabilities, chooser, x11Screen);
+ x11Config = (X11GraphicsConfiguration)factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen);
if (x11Config == null) {
- throw new GLException("Unable to choose a GraphicsConfiguration: "+capabilities+",\n\t"+chooser+"\n\t"+x11Screen);
+ throw new GLException("Unable to choose a GraphicsConfiguration: "+capsChosen+",\n\t"+chooser+"\n\t"+x11Screen);
}
long visualID = x11Config.getVisualID();
diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
index dc6daa645..695fad5a9 100644
--- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
+++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
@@ -40,9 +40,9 @@
package javax.media.opengl;
-import javax.media.nativewindow.Capabilities;
import javax.media.nativewindow.NativeWindowException;
import com.jogamp.opengl.impl.Debug;
+import javax.media.nativewindow.CapabilitiesImmutable;
/** <P> The default implementation of the {@link
GLCapabilitiesChooser} interface, which provides consistent visual
@@ -85,11 +85,11 @@ import com.jogamp.opengl.impl.Debug;
public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
private static final boolean DEBUG = Debug.debug("CapabilitiesChooser");
- public int chooseCapabilities(Capabilities desired,
- Capabilities[] available,
+ public int chooseCapabilities(CapabilitiesImmutable desired,
+ CapabilitiesImmutable[] available,
int windowSystemRecommendedChoice) {
- GLCapabilities _desired = (GLCapabilities) desired;
- GLCapabilities[] _available = (GLCapabilities[]) available;
+ GLCapabilitiesImmutable _desired = (GLCapabilitiesImmutable) desired;
+ GLCapabilitiesImmutable[] _available = (GLCapabilitiesImmutable[]) available;
int availnum = 0;
for (int i = 0; i < _available.length; i++) {
@@ -132,7 +132,7 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
}
// Compute score for each
for (int i = 0; i < scores.length; i++) {
- GLCapabilities cur = _available[i];
+ GLCapabilitiesImmutable cur = _available[i];
if (cur == null) {
continue;
}
@@ -177,7 +177,7 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
if (score == NO_SCORE) {
continue;
}
- GLCapabilities cur = _available[i];
+ GLCapabilitiesImmutable cur = _available[i];
if (cur.getHardwareAccelerated()) {
int absScore = Math.abs(score);
if (!gotHW ||
@@ -193,7 +193,7 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
if (score == NO_SCORE) {
continue;
}
- GLCapabilities cur = _available[i];
+ GLCapabilitiesImmutable cur = _available[i];
if (!cur.getHardwareAccelerated()) {
if (score <= 0) {
score -= maxAbsoluteHWScore;
diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilities.java b/src/jogl/classes/javax/media/opengl/GLCapabilities.java
index d48b95c79..3d2e2bcc9 100644
--- a/src/jogl/classes/javax/media/opengl/GLCapabilities.java
+++ b/src/jogl/classes/javax/media/opengl/GLCapabilities.java
@@ -53,7 +53,7 @@ import javax.media.nativewindow.Capabilities;
It currently contains the minimal number of routines which allow
configuration on all supported window systems. */
-public class GLCapabilities extends Capabilities implements Cloneable {
+public class GLCapabilities extends Capabilities implements Cloneable, GLCapabilitiesImmutable {
private GLProfile glProfile = null;
private boolean pbuffer = false;
private boolean doubleBuffered = true;
@@ -84,6 +84,10 @@ public class GLCapabilities extends Capabilities implements Cloneable {
glProfile = (null!=glp)?glp:GLProfile.getDefault(GLProfile.getDefaultDevice());
}
+ public Object cloneMutable() {
+ return clone();
+ }
+
public Object clone() {
try {
return super.clone();
@@ -92,12 +96,32 @@ public class GLCapabilities extends Capabilities implements Cloneable {
}
}
+ public int hashCode() {
+ // 31 * x == (x << 5) - x
+ int hash = 31 + this.glProfile.hashCode() ;
+ hash = ((hash << 5) - hash) + ( this.pbuffer ? 1 : 0 );
+ hash = ((hash << 5) - hash) + ( this.stereo ? 1 : 0 );
+ hash = ((hash << 5) - hash) + ( this.hardwareAccelerated ? 1 : 0 );
+ hash = ((hash << 5) - hash) + this.depthBits;
+ hash = ((hash << 5) - hash) + this.stencilBits;
+ hash = ((hash << 5) - hash) + this.accumRedBits;
+ hash = ((hash << 5) - hash) + this.accumGreenBits;
+ hash = ((hash << 5) - hash) + this.accumBlueBits;
+ hash = ((hash << 5) - hash) + this.accumAlphaBits;
+ hash = ((hash << 5) - hash) + ( this.sampleBuffers ? 1 : 0 );
+ hash = ((hash << 5) - hash) + this.numSamples;
+ hash = ((hash << 5) - hash) + ( this.pbufferFloatingPointBuffers ? 1 : 0 );
+ hash = ((hash << 5) - hash) + ( this.pbufferRenderToTexture ? 1 : 0 );
+ hash = ((hash << 5) - hash) + ( this.pbufferRenderToTextureRectangle ? 1 : 0 );
+ return hash;
+ }
+
public boolean equals(Object obj) {
if(this == obj) { return true; }
- if(!(obj instanceof GLCapabilities)) {
+ if(!(obj instanceof GLCapabilitiesImmutable)) {
return false;
}
- GLCapabilities other = (GLCapabilities)obj;
+ GLCapabilitiesImmutable other = (GLCapabilitiesImmutable)obj;
boolean res = super.equals(obj) &&
other.getGLProfile()==glProfile &&
other.isPBuffer()==pbuffer &&
diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java
new file mode 100644
index 000000000..7224d65a8
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java
@@ -0,0 +1,147 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package javax.media.opengl;
+
+import com.jogamp.common.type.WriteCloneable;
+import javax.media.nativewindow.CapabilitiesImmutable;
+
+/**
+ * Specifies an immutable set of OpenGL capabilities.<br>
+ *
+ * @see javax.media.opengl.GLCapabilities
+ * @see javax.media.nativewindow.CapabilitiesImmutable
+ */
+public interface GLCapabilitiesImmutable extends WriteCloneable, CapabilitiesImmutable {
+
+ /**
+ * 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.
+ */
+ int getAccumAlphaBits();
+
+ /**
+ * 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.
+ */
+ int getAccumBlueBits();
+
+ /**
+ * 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.
+ */
+ int getAccumGreenBits();
+
+ /**
+ * 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.
+ */
+ int getAccumRedBits();
+
+ /**
+ * Returns the number of bits requested for the depth buffer.
+ */
+ int getDepthBits();
+
+ /**
+ * Indicates whether double-buffering is enabled.
+ */
+ boolean getDoubleBuffered();
+
+ /**
+ * Returns the GL profile you desire or used by the drawable.
+ */
+ GLProfile getGLProfile();
+
+ /**
+ * Indicates whether hardware acceleration is enabled.
+ */
+ boolean getHardwareAccelerated();
+
+ /**
+ * Returns the number of sample buffers to be allocated if sample
+ * buffers are enabled. Defaults to 2.
+ */
+ int getNumSamples();
+
+ /**
+ * For pbuffers only, returns whether floating-point buffers should
+ * be used if available. Defaults to false.
+ */
+ boolean getPbufferFloatingPointBuffers();
+
+ /**
+ * For pbuffers only, returns whether the render-to-texture
+ * extension should be used if available. Defaults to false.
+ */
+ boolean getPbufferRenderToTexture();
+
+ /**
+ * For pbuffers only, returns whether the render-to-texture
+ * extension should be used. Defaults to false.
+ */
+ boolean getPbufferRenderToTextureRectangle();
+
+ /**
+ * Returns whether sample buffers for full-scene antialiasing
+ * (FSAA) should be allocated for this drawable. Defaults to
+ * false.
+ */
+ boolean getSampleBuffers();
+
+ /**
+ * Returns the number of bits requested for the stencil buffer.
+ */
+ int getStencilBits();
+
+ /**
+ * Indicates whether stereo is enabled.
+ */
+ boolean getStereo();
+
+ /**
+ * Indicates whether pbuffer is used/requested.
+ */
+ boolean isPBuffer();
+
+ Object cloneMutable();
+
+ boolean equals(Object obj);
+
+ int hashCode();
+
+ String toString();
+}
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawable.java b/src/jogl/classes/javax/media/opengl/GLDrawable.java
index e4861edd2..f4cd77059 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawable.java
@@ -40,7 +40,9 @@
package javax.media.opengl;
-import javax.media.nativewindow.*;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.NativeSurface;
+
/** An abstraction for an OpenGL rendering target. A GLDrawable's
primary functionality is to create OpenGL contexts which can be
@@ -139,7 +141,7 @@ public interface GLDrawable {
automatically and should not be called by the end user. */
public void swapBuffers() throws GLException;
- /** Fetches the {@link GLCapabilities} corresponding to the chosen
+ /** Fetches the {@link GLCapabilitiesImmutable} corresponding to the chosen
OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.<br>
On some platforms, the pixel format is not directly associated
with the drawable; a best attempt is made to return a reasonable
@@ -149,7 +151,7 @@ public interface GLDrawable {
they should reflect those as well.
@return A copy of the queried object.
*/
- public GLCapabilities getChosenGLCapabilities();
+ public GLCapabilitiesImmutable getChosenGLCapabilities();
/** Fetches the {@link GLProfile} for this drawable.
Returns the GLProfile object, no copy.
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index ab23e18f8..fd6aa7859 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -329,7 +329,7 @@ public abstract class GLDrawableFactory {
* @throws GLException if any window system-specific errors caused
* the creation of the Offscreen to fail.
*/
- public abstract GLDrawable createOffscreenDrawable(GLCapabilities capabilities,
+ public abstract GLDrawable createOffscreenDrawable(GLCapabilitiesImmutable capabilities,
GLCapabilitiesChooser chooser,
int width, int height)
throws GLException;
@@ -347,7 +347,7 @@ public abstract class GLDrawableFactory {
* @throws GLException if any window system-specific errors caused
* the creation of the GLPbuffer to fail.
*/
- public abstract GLDrawable createGLPbufferDrawable(GLCapabilities capabilities,
+ public abstract GLDrawable createGLPbufferDrawable(GLCapabilitiesImmutable capabilities,
GLCapabilitiesChooser chooser,
int initialWidth,
int initialHeight)
@@ -362,7 +362,7 @@ public abstract class GLDrawableFactory {
* @throws GLException if any window system-specific errors caused
* the creation of the GLPbuffer to fail.
*/
- public abstract GLPbuffer createGLPbuffer(GLCapabilities capabilities,
+ public abstract GLPbuffer createGLPbuffer(GLCapabilitiesImmutable capabilities,
GLCapabilitiesChooser chooser,
int initialWidth,
int initialHeight,
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 292bfba7c..dba041f8d 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -41,7 +41,6 @@
package javax.media.opengl.awt;
import com.jogamp.common.GlueGenVersion;
-import com.jogamp.common.util.VersionUtil;
import com.jogamp.nativewindow.NativeWindowVersion;
import javax.media.opengl.*;
import javax.media.nativewindow.*;
@@ -95,7 +94,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
private boolean sendReshape = false;
// copy of the cstr args ..
- private GLCapabilities capabilities;
+ private GLCapabilitiesImmutable capabilities;
private GLCapabilitiesChooser chooser;
private GLContext shareWith;
private GraphicsDevice device;
@@ -110,8 +109,8 @@ 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(GLCapabilities capabilities) {
- this(capabilities, null, null, null);
+ public GLCanvas(GLCapabilitiesImmutable capsReqUser) {
+ this(capsReqUser, null, null, null);
}
/** Creates a new GLCanvas component. The passed GLCapabilities
@@ -129,7 +128,7 @@ 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(GLCapabilities capabilities,
+ public GLCanvas(GLCapabilitiesImmutable capsReqUser,
GLCapabilitiesChooser chooser,
GLContext shareWith,
GraphicsDevice device) {
@@ -141,12 +140,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
*/
super();
- if(null==capabilities) {
+ if(null==capsReqUser) {
capabilities = new GLCapabilities(defaultGLProfile);
+ } else {
+ // don't allow the user to change data
+ capabilities = (GLCapabilitiesImmutable) capsReqUser.cloneMutable();
}
glProfile = capabilities.getGLProfile();
- this.capabilities = capabilities;
this.chooser = chooser;
this.shareWith=shareWith;
this.device = device;
@@ -231,7 +232,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
* block, both devices should have the same visual list, and the
* same configuration should be selected here.
*/
- AWTGraphicsConfiguration config = chooseGraphicsConfiguration((GLCapabilities)awtConfig.getRequestedCapabilities(), chooser, gc.getDevice());
+ AWTGraphicsConfiguration config = chooseGraphicsConfiguration( (GLCapabilitiesImmutable)awtConfig.getChosenCapabilities(),
+ (GLCapabilitiesImmutable)awtConfig.getRequestedCapabilities(),
+ chooser, gc.getDevice());
final GraphicsConfiguration compatible = (null!=config)?config.getGraphicsConfiguration():null;
boolean equalCaps = config.getChosenCapabilities().equals(awtConfig.getChosenCapabilities());
if(DEBUG) {
@@ -429,7 +432,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
*/
NativeWindowFactory.getDefaultToolkitLock().lock();
try {
- awtConfig = chooseGraphicsConfiguration(capabilities, chooser, device);
+ awtConfig = chooseGraphicsConfiguration(capabilities, capabilities, chooser, device);
if(DEBUG) {
System.err.println(Thread.currentThread().getName()+" - Created Config: "+awtConfig);
}
@@ -578,20 +581,20 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
return glProfile;
}
- public GLCapabilities getChosenGLCapabilities() {
+ public GLCapabilitiesImmutable getChosenGLCapabilities() {
if (awtConfig == null) {
throw new GLException("No AWTGraphicsConfiguration: "+this);
}
- return (GLCapabilities)awtConfig.getChosenCapabilities();
+ return (GLCapabilitiesImmutable)awtConfig.getChosenCapabilities();
}
- public GLCapabilities getRequestedGLCapabilities() {
+ public GLCapabilitiesImmutable getRequestedGLCapabilities() {
if (awtConfig == null) {
throw new GLException("No AWTGraphicsConfiguration: "+this);
}
- return (GLCapabilities)awtConfig.getRequestedCapabilities();
+ return (GLCapabilitiesImmutable)awtConfig.getRequestedCapabilities();
}
public NativeSurface getNativeSurface() {
@@ -771,7 +774,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
}
- private static AWTGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities,
+ private static AWTGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilitiesImmutable capsChosen,
+ GLCapabilitiesImmutable capsRequested,
GLCapabilitiesChooser chooser,
GraphicsDevice device) {
// Make GLCanvas behave better in NetBeans GUI builder
@@ -781,9 +785,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
AbstractGraphicsScreen aScreen = AWTGraphicsScreen.createScreenDevice(device, AbstractGraphicsDevice.DEFAULT_UNIT);
AWTGraphicsConfiguration config = (AWTGraphicsConfiguration)
- GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class).chooseGraphicsConfiguration(capabilities,
- chooser,
- aScreen);
+ GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class).chooseGraphicsConfiguration(capsChosen,
+ capsRequested,
+ chooser, aScreen);
if (config == null) {
throw new GLException("Error: Couldn't fetch AWTGraphicsConfiguration");
}
@@ -799,7 +803,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
System.err.println(NativeWindowVersion.getInstance());
System.err.print(JoglVersion.getInstance());
- GLCapabilities caps = new GLCapabilities( GLProfile.getDefault(GLProfile.getDefaultDesktopDevice()) );
+ GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault(GLProfile.getDefaultDesktopDevice()) );
Frame frame = new Frame("JOGL AWT Test");
GLCanvas glCanvas = new GLCanvas(caps);
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 955e51e69..0f724d558 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -91,7 +91,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
private volatile boolean isInitialized;
// Data used for either pbuffers or pixmap-based offscreen surfaces
- private GLCapabilities offscreenCaps;
+ private GLCapabilitiesImmutable offscreenCaps;
private GLProfile glProfile;
private GLDrawableFactoryImpl factory;
private GLCapabilitiesChooser chooser;
@@ -158,8 +158,8 @@ 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(GLCapabilities capabilities) {
- this(capabilities, null, null);
+ public GLJPanel(GLCapabilitiesImmutable userCapsRequest) {
+ this(userCapsRequest, null, null);
}
/** Creates a new GLJPanel component. The passed GLCapabilities
@@ -176,17 +176,21 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
Note: Sharing cannot be enabled using J2D OpenGL FBO sharing,
since J2D GL Context must be shared and we can only share one context.
*/
- public GLJPanel(GLCapabilities capabilities, GLCapabilitiesChooser chooser, GLContext shareWith) {
+ public GLJPanel(GLCapabilitiesImmutable userCapsRequest, 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 = (GLCapabilities) capabilities.clone();
- } else {
- offscreenCaps = new GLCapabilities(null);
+ {
+ GLCapabilities caps;
+ if (userCapsRequest != null) {
+ caps = (GLCapabilities) userCapsRequest.cloneMutable();
+ } else {
+ caps = new GLCapabilities(null);
+ }
+ caps.setDoubleBuffered(false);
+ offscreenCaps = caps;
}
- offscreenCaps.setDoubleBuffered(false);
this.glProfile = offscreenCaps.getGLProfile();
this.factory = GLDrawableFactoryImpl.getFactoryImpl(glProfile);
this.chooser = ((chooser != null) ? chooser : new DefaultGLCapabilitiesChooser());
@@ -485,7 +489,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return oglPipelineEnabled;
}
- public GLCapabilities getChosenGLCapabilities() {
+ public GLCapabilitiesImmutable getChosenGLCapabilities() {
return backend.getChosenGLCapabilities();
}
@@ -748,7 +752,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
public GLDrawable getDrawable();
// Called to fetch the "real" GLCapabilities for the backend
- public GLCapabilities getChosenGLCapabilities();
+ public GLCapabilitiesImmutable getChosenGLCapabilities();
// Called to fetch the "real" GLProfile for the backend
public GLProfile getGLProfile();
@@ -992,7 +996,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return offscreenDrawable;
}
- public GLCapabilities getChosenGLCapabilities() {
+ public GLCapabilitiesImmutable getChosenGLCapabilities() {
if (offscreenDrawable == null) {
return null;
}
@@ -1090,7 +1094,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return pbuffer;
}
- public GLCapabilities getChosenGLCapabilities() {
+ public GLCapabilitiesImmutable getChosenGLCapabilities() {
if (pbuffer == null) {
return null;
}
@@ -1268,7 +1272,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return joglDrawable;
}
- public GLCapabilities getChosenGLCapabilities() {
+ public GLCapabilitiesImmutable getChosenGLCapabilities() {
// FIXME: should do better than this; is it possible to using only platform-independent code?
return new GLCapabilities(null);
}
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java
index ef4b657fc..d0b8cc7de 100644
--- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java
+++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/newt/TestGearsNewtAWTWrapper.java
@@ -63,7 +63,7 @@ public class TestGearsNewtAWTWrapper extends UITestCase {
public static void releaseClass() {
}
- protected void runTestGL(GLCapabilities caps) throws InterruptedException {
+ protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException {
Display nDisplay = NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null, false); // local display
Screen nScreen = NewtFactory.createScreen(nDisplay, 0); // screen 0
Window nWindow = NewtFactory.createWindow(nScreen, caps);
@@ -94,7 +94,7 @@ public class TestGearsNewtAWTWrapper extends UITestCase {
@Test
public void test01() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ GLCapabilitiesImmutable caps = new GLCapabilities(GLProfile.getDefault());
runTestGL(caps);
}
diff --git a/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java b/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java
index 6deacf726..cfe956c61 100644
--- a/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java
+++ b/src/junit/com/jogamp/test/junit/jogl/offscreen/WindowUtilNEWT.java
@@ -41,7 +41,7 @@ import com.jogamp.newt.opengl.*;
public class WindowUtilNEWT {
public static GLCapabilities fixCaps(GLCapabilities caps, boolean onscreen, boolean pbuffer, boolean undecorated) {
- GLCapabilities caps2 = (GLCapabilities) caps.clone();
+ GLCapabilities caps2 = (GLCapabilities) caps.cloneMutable();
caps2.setOnscreen(onscreen);
caps2.setPBuffer(!onscreen && pbuffer);
caps2.setDoubleBuffered(!onscreen);
diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows00NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows00NEWT.java
index d28dd2c11..2769dc550 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows00NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestGLWindows00NEWT.java
@@ -58,7 +58,7 @@ public class TestGLWindows00NEWT extends UITestCase {
glp = GLProfile.getDefault();
}
- static GLWindow createWindow(Screen screen, GLCapabilities caps)
+ static GLWindow createWindow(Screen screen, GLCapabilitiesImmutable caps)
throws InterruptedException
{
Assert.assertNotNull(caps);
diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java
index 934d75f7c..e2c65adb8 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestGLWindows01NEWT.java
@@ -57,7 +57,7 @@ public class TestGLWindows01NEWT extends UITestCase {
glp = GLProfile.getDefault();
}
- static GLWindow createWindow(Screen screen, GLCapabilities caps,
+ static GLWindow createWindow(Screen screen, GLCapabilities caps,
int width, int height, boolean onscreen, boolean undecorated,
boolean addGLEventListenerAfterVisible)
throws InterruptedException
@@ -102,12 +102,12 @@ public class TestGLWindows01NEWT extends UITestCase {
// Create native OpenGL resources .. XGL/WGL/CGL ..
// equivalent to GLAutoDrawable methods: setVisible(true)
//
- caps = glWindow.getChosenGLCapabilities();
- Assert.assertNotNull(caps);
- Assert.assertTrue(caps.getGreenBits()>5);
- Assert.assertTrue(caps.getBlueBits()>5);
- Assert.assertTrue(caps.getRedBits()>5);
- Assert.assertEquals(caps.isOnscreen(),onscreen);
+ GLCapabilitiesImmutable caps2 = glWindow.getChosenGLCapabilities();
+ Assert.assertNotNull(caps2);
+ Assert.assertTrue(caps2.getGreenBits()>=5);
+ Assert.assertTrue(caps2.getBlueBits()>=5);
+ Assert.assertTrue(caps2.getRedBits()>=5);
+ Assert.assertEquals(caps2.isOnscreen(),onscreen);
if(addGLEventListenerAfterVisible) {
glWindow.addGLEventListener(demo);
diff --git a/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java b/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java
index 78b9773a8..e79d57a4f 100644
--- a/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java
+++ b/src/junit/com/jogamp/test/junit/newt/TestGLWindows02NEWTAnimated.java
@@ -104,12 +104,12 @@ public class TestGLWindows02NEWTAnimated extends UITestCase {
// Create native OpenGL resources .. XGL/WGL/CGL ..
// equivalent to GLAutoDrawable methods: setVisible(true)
//
- caps = glWindow.getChosenGLCapabilities();
- Assert.assertNotNull(caps);
- Assert.assertTrue(caps.getGreenBits()>5);
- Assert.assertTrue(caps.getBlueBits()>5);
- Assert.assertTrue(caps.getRedBits()>5);
- Assert.assertEquals(caps.isOnscreen(),onscreen);
+ GLCapabilitiesImmutable caps2 = glWindow.getChosenGLCapabilities();
+ Assert.assertNotNull(caps2);
+ Assert.assertTrue(caps2.getGreenBits()>=5);
+ Assert.assertTrue(caps2.getBlueBits()>=5);
+ Assert.assertTrue(caps2.getRedBits()>=5);
+ Assert.assertEquals(caps2.isOnscreen(),onscreen);
return glWindow;
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/GraphicsConfigurationFactoryImpl.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/GraphicsConfigurationFactoryImpl.java
index 96f6ab2ba..c53f4c88b 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/GraphicsConfigurationFactoryImpl.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/GraphicsConfigurationFactoryImpl.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -36,7 +37,7 @@ import javax.media.nativewindow.*;
public class GraphicsConfigurationFactoryImpl extends GraphicsConfigurationFactory {
protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
- Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen screen) {
- return new DefaultGraphicsConfiguration(screen, capabilities, capabilities);
+ CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen screen) {
+ return new DefaultGraphicsConfiguration(screen, capsChosen, capsRequested);
}
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
index ff07fab44..fec7ca29d 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -34,18 +35,16 @@ package com.jogamp.nativewindow.impl.x11;
import javax.media.nativewindow.*;
import javax.media.nativewindow.x11.*;
-import com.jogamp.nativewindow.impl.x11.XVisualInfo;
-import com.jogamp.nativewindow.impl.x11.X11Lib;
public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactory {
protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
- Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen screen)
+ CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen screen)
throws IllegalArgumentException, NativeWindowException {
if(!(screen instanceof X11GraphicsScreen)) {
throw new NativeWindowException("Only valid X11GraphicsScreen are allowed");
}
- return new X11GraphicsConfiguration((X11GraphicsScreen)screen, capabilities, capabilities, getXVisualInfo(screen, capabilities));
+ return new X11GraphicsConfiguration((X11GraphicsScreen)screen, capsChosen, capsRequested, getXVisualInfo(screen, capsChosen));
}
public static XVisualInfo getXVisualInfo(AbstractGraphicsScreen screen, long visualID)
diff --git a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
index ff6e077ee..e844c4f3e 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -43,7 +44,6 @@ package javax.media.nativewindow;
must support, such as color depth per channel. It currently
contains the minimal number of routines which allow configuration
on all supported window systems. */
-
public class Capabilities implements CapabilitiesImmutable, Cloneable {
private int redBits = 8;
private int greenBits = 8;
@@ -65,8 +65,8 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable {
*/
public Capabilities() {}
- public Capabilities cloneCapabilites() {
- return (Capabilities) clone();
+ public Object cloneMutable() {
+ return clone();
}
public Object clone() {
@@ -77,12 +77,27 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable {
}
}
+ public int hashCode() {
+ // 31 * x == (x << 5) - x
+ int hash = 31 + this.redBits;
+ hash = ((hash << 5) - hash) + this.greenBits;
+ hash = ((hash << 5) - hash) + this.blueBits;
+ hash = ((hash << 5) - hash) + this.alphaBits;
+ hash = ((hash << 5) - hash) + ( this.backgroundOpaque ? 1 : 0 );
+ hash = ((hash << 5) - hash) + this.transparentValueRed;
+ hash = ((hash << 5) - hash) + this.transparentValueGreen;
+ hash = ((hash << 5) - hash) + this.transparentValueBlue;
+ hash = ((hash << 5) - hash) + this.transparentValueAlpha;
+ hash = ((hash << 5) - hash) + ( this.onscreen ? 1 : 0 );
+ return hash;
+ }
+
public boolean equals(Object obj) {
if(this == obj) { return true; }
- if(!(obj instanceof Capabilities)) {
+ if(!(obj instanceof CapabilitiesImmutable)) {
return false;
}
- Capabilities other = (Capabilities)obj;
+ CapabilitiesImmutable other = (CapabilitiesImmutable)obj;
boolean res = other.getRedBits()==redBits &&
other.getGreenBits()==greenBits &&
other.getBlueBits()==blueBits &&
diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java
index d61ebd4ef..94b0f68af 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java
@@ -62,7 +62,7 @@ public interface CapabilitiesChooser {
invoked by users directly, unless it is desired to delegate the
choice to some other CapabilitiesChooser object.
*/
- public int chooseCapabilities(Capabilities desired,
- Capabilities[] available,
+ public int chooseCapabilities(CapabilitiesImmutable desired,
+ CapabilitiesImmutable[] available,
int windowSystemRecommendedChoice);
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
index 9369221cb..72828b9f0 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
@@ -1,12 +1,42 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
package javax.media.nativewindow;
+import com.jogamp.common.type.WriteCloneable;
+
/**
* Specifies an immutable set of capabilities that a window's rendering context
* must support, such as color depth per channel.
*
* @see javax.media.nativewindow.Capabilities
*/
-public interface CapabilitiesImmutable extends Cloneable {
+public interface CapabilitiesImmutable extends WriteCloneable {
/**
* Returns the number of bits requested for the color buffer's red
@@ -71,11 +101,14 @@ public interface CapabilitiesImmutable extends Cloneable {
*/
int getTransparentAlphaValue();
- /**
- * Get a mutable clone of this instance.
- *
- * @see java.lang.Object#clone()
- */
- Capabilities cloneCapabilites();
+ Object cloneMutable();
+
+ /** Equality over the immutable attributes of both objects */
+ boolean equals(Object obj);
+
+ /** hash code over the immutable attributes of both objects */
+ int hashCode();
+ /** Returns a textual representation of this object. */
+ String toString();
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java
index cead0a4a8..856c29420 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java
@@ -63,8 +63,8 @@ package javax.media.nativewindow;
public class DefaultCapabilitiesChooser implements CapabilitiesChooser {
private static final boolean DEBUG = false; // FIXME: Debug.debug("DefaultCapabilitiesChooser");
- public int chooseCapabilities(Capabilities desired,
- Capabilities[] available,
+ public int chooseCapabilities(CapabilitiesImmutable desired,
+ CapabilitiesImmutable[] available,
int windowSystemRecommendedChoice) {
if (DEBUG) {
System.err.println("Desired: " + desired);
@@ -93,7 +93,7 @@ public class DefaultCapabilitiesChooser implements CapabilitiesChooser {
}
// Compute score for each
for (int i = 0; i < scores.length; i++) {
- Capabilities cur = available[i];
+ CapabilitiesImmutable cur = available[i];
if (cur == null) {
continue;
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
index 3d06388c2..47110add9 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
@@ -41,9 +41,8 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested) {
this.screen = screen;
- // Create "immutable" copies of capabilities.
- this.capabilitiesChosen = capsChosen.cloneCapabilites();
- this.capabilitiesRequested = capsRequested.cloneCapabilites();
+ this.capabilitiesChosen = capsChosen;
+ this.capabilitiesRequested = capsRequested;
}
public Object clone() {
@@ -76,13 +75,12 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
* The use case for setting the Capabilities at a later time is
* a change of the graphics device in a multi-screen environment.<br>
*
- * A copy of the passed object is being used.
+ * The objects reference is being used.
*
* @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
*/
protected void setChosenCapabilities(CapabilitiesImmutable capsChosen) {
- // Create "immutable" copy of capabilities.
- capabilitiesChosen = (CapabilitiesImmutable) capsChosen.cloneCapabilites();
+ capabilitiesChosen = capsChosen;
}
/**
diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
index 1d3a7445f..c061f597f 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,7 +33,6 @@
package javax.media.nativewindow;
-import java.lang.reflect.*;
import java.util.*;
import com.jogamp.common.util.*;
@@ -187,6 +187,12 @@ public abstract class GraphicsConfigurationFactory {
* javax.media.nativewindow.x11.X11GraphicsConfiguration
* X11GraphicsConfiguration} objects.</P>
*
+ * @param capsChosen the intermediate chosen capabilities to be refined by this implementation, may be equal to capsRequested
+ * @param capsRequested the original requested capabilities
+ * @param chooser the choosing implementation
+ * @param screen the referring Screen
+ * @return the complete GraphicsConfiguration
+ *
* @throws IllegalArgumentException if the data type of the passed
* AbstractGraphicsDevice is not supported by this
* NativeWindowFactory.
@@ -197,10 +203,16 @@ public abstract class GraphicsConfigurationFactory {
* @see javax.media.nativewindow.DefaultGraphicsConfiguration#setChosenCapabilities(Capabilities caps)
*/
public final AbstractGraphicsConfiguration
- chooseGraphicsConfiguration(Capabilities capabilities,
+ chooseGraphicsConfiguration(CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
CapabilitiesChooser chooser,
AbstractGraphicsScreen screen)
throws IllegalArgumentException, NativeWindowException {
+ if(null==capsChosen) {
+ throw new NativeWindowException("Chosen Capabilities are null");
+ }
+ if(null==capsRequested) {
+ throw new NativeWindowException("Requested Capabilities are null");
+ }
if(null==screen) {
throw new NativeWindowException("Screen is null");
}
@@ -210,15 +222,14 @@ public abstract class GraphicsConfigurationFactory {
}
device.lock();
try {
- return chooseGraphicsConfigurationImpl(capabilities, chooser, screen);
+ return chooseGraphicsConfigurationImpl(capsChosen, capsRequested, chooser, screen);
} finally {
device.unlock();
}
}
protected abstract AbstractGraphicsConfiguration
- chooseGraphicsConfigurationImpl(Capabilities capabilities,
- CapabilitiesChooser chooser,
- AbstractGraphicsScreen screen)
+ chooseGraphicsConfigurationImpl(CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
+ CapabilitiesChooser chooser, AbstractGraphicsScreen screen)
throws IllegalArgumentException, NativeWindowException;
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
index bce9b248d..41051ab46 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -63,7 +64,8 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple
this.encapsulated=encapsulated;
}
- public AWTGraphicsConfiguration(AWTGraphicsScreen screen, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, GraphicsConfiguration config) {
+ public AWTGraphicsConfiguration(AWTGraphicsScreen screen, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
+ GraphicsConfiguration config) {
super(screen, capsChosen, capsRequested);
this.config = config;
this.encapsulated=null;
@@ -97,7 +99,7 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple
if(null==capsChosen) {
GraphicsConfiguration gc = awtGraphicsDevice.getDefaultConfiguration();
- capsChosen = setupCapabilitiesRGBABits(capsRequested.cloneCapabilites(), gc);
+ capsChosen = setupCapabilitiesRGBABits(capsChosen, gc);
}
return new AWTGraphicsConfiguration(awtScreen, capsChosen, capsRequested, awtGfxConfig);
}
@@ -121,7 +123,9 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple
* @param gc the GraphicsConfiguration from which to derive the RGBA bit depths
* @return the passed Capabilities
*/
- public static Capabilities setupCapabilitiesRGBABits(Capabilities capabilities, GraphicsConfiguration gc) {
+ public static CapabilitiesImmutable setupCapabilitiesRGBABits(CapabilitiesImmutable capabilitiesIn, GraphicsConfiguration gc) {
+ Capabilities capabilities = (Capabilities) capabilitiesIn.cloneMutable();
+
int cmTransparency = capabilities.isBackgroundOpaque()?Transparency.OPAQUE:Transparency.TRANSLUCENT;
ColorModel cm = gc.getColorModel(cmTransparency);
if(null==cm && !capabilities.isBackgroundOpaque()) {
diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java
index 892a2426e..3b836787e 100644
--- a/src/newt/classes/com/jogamp/newt/NewtFactory.java
+++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java
@@ -112,14 +112,14 @@ public class NewtFactory {
* The Display/Screen is created and owned, ie destructed atomatically.<br>
* A new Display is only created if no preexisting one could be found via {@link Display#getLastDisplayOf(java.lang.String, java.lang.String, int)}.
*/
- public static Window createWindow(Capabilities caps) {
+ public static Window createWindow(CapabilitiesImmutable caps) {
return createWindowImpl(NativeWindowFactory.getNativeWindowType(true), caps);
}
/**
* Create a top level Window entity, incl native creation
*/
- public static Window createWindow(Screen screen, Capabilities caps) {
+ public static Window createWindow(Screen screen, CapabilitiesImmutable caps) {
return createWindowImpl(screen, caps);
}
@@ -140,7 +140,7 @@ public class NewtFactory {
*
* @param parentWindowObject either a NativeWindow instance
*/
- public static Window createWindow(NativeWindow nParentWindow, Capabilities caps) {
+ public static Window createWindow(NativeWindow nParentWindow, CapabilitiesImmutable caps) {
final String type = NativeWindowFactory.getNativeWindowType(true);
Screen screen = null;
@@ -173,19 +173,19 @@ public class NewtFactory {
return win;
}
- protected static Window createWindowImpl(NativeWindow parentNativeWindow, Screen screen, Capabilities caps) {
+ protected static Window createWindowImpl(NativeWindow parentNativeWindow, Screen screen, CapabilitiesImmutable caps) {
return WindowImpl.create(parentNativeWindow, 0, screen, caps);
}
- protected static Window createWindowImpl(long parentWindowHandle, Screen screen, Capabilities caps) {
+ protected static Window createWindowImpl(long parentWindowHandle, Screen screen, CapabilitiesImmutable caps) {
return WindowImpl.create(null, parentWindowHandle, screen, caps);
}
- protected static Window createWindowImpl(Screen screen, Capabilities caps) {
+ protected static Window createWindowImpl(Screen screen, CapabilitiesImmutable caps) {
return WindowImpl.create(null, 0, screen, caps);
}
- protected static Window createWindowImpl(String type, Capabilities caps) {
+ protected static Window createWindowImpl(String type, CapabilitiesImmutable caps) {
Display display = NewtFactory.createDisplay(type, null, true); // local display
Screen screen = NewtFactory.createScreen(display, 0); // screen 0
return WindowImpl.create(null, 0, screen, caps);
@@ -197,7 +197,7 @@ public class NewtFactory {
* @param parentWindowObject the native parent window handle
* @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always
*/
- public static Window createWindow(long parentWindowHandle, Screen screen, Capabilities caps) {
+ public static Window createWindow(long parentWindowHandle, Screen screen, CapabilitiesImmutable caps) {
return createWindowImpl(parentWindowHandle, screen, caps);
}
@@ -208,7 +208,7 @@ public class NewtFactory {
*
* @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always
*/
- public static Window createWindow(Object[] cstrArguments, Screen screen, Capabilities caps) {
+ public static Window createWindow(Object[] cstrArguments, Screen screen, CapabilitiesImmutable caps) {
return WindowImpl.create(cstrArguments, screen, caps);
}
@@ -219,7 +219,7 @@ public class NewtFactory {
return DisplayImpl.create(type, null, handle, false);
}
- private static final boolean instanceOf(Object obj, String clazzName) {
+ private static boolean instanceOf(Object obj, String clazzName) {
Class clazz = obj.getClass();
do {
if(clazz.getName().equals(clazzName)) {
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 29e8c91b4..a0ab5f9f6 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -168,8 +168,7 @@ public class NewtCanvasAWT extends java.awt.Canvas {
newtChild.setFocusAction(null); // no AWT focus traversal ..
if(add) {
- nativeWindow = NewtFactoryAWT.getNativeWindow(this,
- newtChild.getRequestedCapabilities().cloneCapabilites());
+ nativeWindow = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities());
if(null!=nativeWindow) {
if(DEBUG) {
System.err.println("NewtCanvasAWT.reparentWindow: "+newtChild);
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtFactoryAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtFactoryAWT.java
index 7b9130188..cd03454c8 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtFactoryAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtFactoryAWT.java
@@ -51,7 +51,7 @@ public class NewtFactoryAWT extends NewtFactory {
*
* @param awtCompObject must be of type java.awt.Component
*/
- public static NativeWindow getNativeWindow(Object awtCompObject, Capabilities capsRequested) {
+ public static NativeWindow getNativeWindow(Object awtCompObject, CapabilitiesImmutable capsRequested) {
if(null==awtCompObject) {
throw new NativeWindowException("Null AWT Component");
}
@@ -61,9 +61,8 @@ public class NewtFactoryAWT extends NewtFactory {
return getNativeWindow( (java.awt.Component) awtCompObject, capsRequested );
}
- public static NativeWindow getNativeWindow(java.awt.Component awtComp, Capabilities capsRequested) {
- DefaultGraphicsConfiguration config =
- AWTGraphicsConfiguration.create(awtComp, (Capabilities) capsRequested.clone(), capsRequested);
+ public static NativeWindow getNativeWindow(java.awt.Component awtComp, CapabilitiesImmutable capsRequested) {
+ DefaultGraphicsConfiguration config = AWTGraphicsConfiguration.create(awtComp, capsRequested, capsRequested);
NativeWindow awtNative = NativeWindowFactory.getNativeWindow(awtComp, config); // a JAWTWindow
if(DEBUG_IMPLEMENTATION) {
System.err.println("NewtFactoryAWT.getNativeWindow: "+awtComp+" -> "+awtNative);
diff --git a/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java b/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java
index 30dc945db..6e827dd77 100644
--- a/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/OffscreenWindow.java
@@ -50,11 +50,12 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable {
if(0!=getParentWindowHandle()) {
throw new NativeWindowException("OffscreenWindow does not support window parenting");
}
- if(caps.isOnscreen()) {
+ if(capsRequested.isOnscreen()) {
throw new NativeWindowException("Capabilities is onscreen");
}
AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen();
- config = GraphicsConfigurationFactory.getFactory(aScreen.getDevice()).chooseGraphicsConfiguration(caps, null, aScreen);
+ config = GraphicsConfigurationFactory.getFactory(aScreen.getDevice()).chooseGraphicsConfiguration(
+ capsRequested, capsRequested, null, aScreen);
if (config == null) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
index 572ed5bb7..30b17c575 100644
--- a/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
+++ b/src/newt/classes/com/jogamp/newt/impl/WindowImpl.java
@@ -56,7 +56,6 @@ import java.util.ArrayList;
import java.lang.reflect.Method;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
-import javax.media.nativewindow.Capabilities;
import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.NativeWindow;
@@ -79,7 +78,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
private NativeWindow parentWindow;
private long parentWindowHandle;
protected AbstractGraphicsConfiguration config;
- protected Capabilities caps;
+ protected CapabilitiesImmutable capsRequested;
protected boolean fullscreen, visible, hasFocus;
protected int width, height, x, y;
protected int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen dimensions ..
@@ -165,7 +164,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
return windowClass;
}
- public static WindowImpl create(NativeWindow parentWindow, long parentWindowHandle, Screen screen, Capabilities caps) {
+ public static WindowImpl create(NativeWindow parentWindow, long parentWindowHandle, Screen screen, CapabilitiesImmutable caps) {
try {
Class windowClass;
if(caps.isOnscreen()) {
@@ -178,7 +177,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
window.parentWindow = parentWindow;
window.parentWindowHandle = parentWindowHandle;
window.screen = (ScreenImpl) screen;
- window.caps = (Capabilities)caps.clone();
+ window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable();
window.setUndecorated(0!=parentWindowHandle);
return window;
} catch (Throwable t) {
@@ -187,7 +186,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
}
}
- public static WindowImpl create(Object[] cstrArguments, Screen screen, Capabilities caps) {
+ public static WindowImpl create(Object[] cstrArguments, Screen screen, CapabilitiesImmutable caps) {
try {
Class windowClass = getWindowClass(screen.getDisplay().getType());
Class[] cstrArgumentTypes = getCustomConstructorArgumentTypes(windowClass);
@@ -201,7 +200,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
WindowImpl window = (WindowImpl) ReflectionUtil.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ;
window.initializeStates();
window.screen = (ScreenImpl) screen;
- window.caps = (Capabilities)caps.clone();
+ window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable();
return window;
} catch (Throwable t) {
throw new NativeWindowException(t);
@@ -825,7 +824,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
parentWindowHandle = 0;
parentWindow = null;
- caps = null;
+ capsRequested = null;
lifecycleHook = null;
// Default position and dimension will be re-set immediately by user
@@ -1151,7 +1150,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer, ScreenMod
}
public final CapabilitiesImmutable getRequestedCapabilities() {
- return caps;
+ return capsRequested;
}
public String getTitle() {
diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java
index 4b30e10b6..169b7bc3a 100644
--- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java
+++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java
@@ -50,11 +50,11 @@ public class AWTCanvas extends Canvas {
private GraphicsConfiguration chosen;
private AWTGraphicsConfiguration awtConfig;
- private Capabilities capabilities;
+ private CapabilitiesImmutable capabilities;
private boolean displayConfigChanged=false;
- public AWTCanvas(Capabilities capabilities) {
+ public AWTCanvas(CapabilitiesImmutable capabilities) {
super();
if(null==capabilities) {
@@ -86,7 +86,7 @@ public class AWTCanvas extends Canvas {
/*
* Save the chosen capabilities for use in getGraphicsConfiguration().
*/
- awtConfig = chooseGraphicsConfiguration(capabilities, device);
+ awtConfig = chooseGraphicsConfiguration(capabilities, capabilities, device);
if(Window.DEBUG_IMPLEMENTATION) {
Exception e = new Exception("Info: Created Config: "+awtConfig);
e.printStackTrace();
@@ -174,7 +174,7 @@ public class AWTCanvas extends Canvas {
* block, both devices should have the same visual list, and the
* same configuration should be selected here.
*/
- AWTGraphicsConfiguration config = chooseGraphicsConfiguration((Capabilities)awtConfig.getRequestedCapabilities(), gc.getDevice());
+ AWTGraphicsConfiguration config = chooseGraphicsConfiguration(awtConfig.getChosenCapabilities(), awtConfig.getRequestedCapabilities(), gc.getDevice());
final GraphicsConfiguration compatible = (null!=config)?config.getGraphicsConfiguration():null;
if(Window.DEBUG_IMPLEMENTATION) {
Exception e = new Exception("Info: Call Stack: "+Thread.currentThread().getName());
@@ -225,13 +225,13 @@ public class AWTCanvas extends Canvas {
return gc;
}
- private static AWTGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
+ private static AWTGraphicsConfiguration chooseGraphicsConfiguration(CapabilitiesImmutable capsChosen,
+ CapabilitiesImmutable capsRequested,
GraphicsDevice device) {
AbstractGraphicsScreen aScreen = AWTGraphicsScreen.createScreenDevice(device, AbstractGraphicsDevice.DEFAULT_UNIT);
AWTGraphicsConfiguration config = (AWTGraphicsConfiguration)
- GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class).chooseGraphicsConfiguration(capabilities,
- null,
- aScreen);
+ GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class).chooseGraphicsConfiguration(capsChosen, capsRequested,
+ null, aScreen);
if (config == null) {
throw new NativeWindowException("Error: Couldn't fetch AWTGraphicsConfiguration");
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java
index edd851451..7aa5874c4 100644
--- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTWindow.java
@@ -119,7 +119,7 @@ public class AWTWindow extends WindowImpl {
frame.setTitle(getTitle());
}
container.setLayout(new BorderLayout());
- canvas = new AWTCanvas(caps);
+ canvas = new AWTCanvas(capsRequested);
addWindowListener(new LocalWindowListener());
diff --git a/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java b/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java
index 749be8506..613d9eb02 100644
--- a/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java
+++ b/src/newt/classes/com/jogamp/newt/impl/intel/gdl/Window.java
@@ -53,7 +53,7 @@ public class Window extends com.jogamp.newt.impl.WindowImpl {
AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen();
AbstractGraphicsDevice aDevice = getScreen().getDisplay().getGraphicsDevice();
- config = GraphicsConfigurationFactory.getFactory(aDevice).chooseGraphicsConfiguration(caps, null, aScreen);
+ config = GraphicsConfigurationFactory.getFactory(aDevice).chooseGraphicsConfiguration(capsRequested, capsRequested, null, aScreen);
if (config == null) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
index 59b41c2aa..3d1f52eed 100644
--- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
@@ -143,7 +143,8 @@ public class MacWindow extends WindowImpl {
}
protected void createNativeImpl() {
- config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen());
+ config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(
+ capsRequested, capsRequested, null, getScreen().getGraphicsScreen());
if (config == null) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java b/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java
index ad903731b..6548cf6c4 100644
--- a/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java
+++ b/src/newt/classes/com/jogamp/newt/impl/opengl/broadcom/egl/Window.java
@@ -35,9 +35,9 @@ package com.jogamp.newt.impl.opengl.broadcom.egl;
import com.jogamp.opengl.impl.egl.*;
import javax.media.nativewindow.*;
-import javax.media.opengl.GLCapabilities;
import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.util.Point;
+import javax.media.opengl.GLCapabilitiesImmutable;
public class Window extends com.jogamp.newt.impl.WindowImpl {
static {
@@ -53,7 +53,8 @@ public class Window extends com.jogamp.newt.impl.WindowImpl {
}
// query a good configuration .. even thought we drop this one
// and reuse the EGLUtil choosen one later.
- config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen());
+ config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(
+ capsRequested, capsRequested, null, getScreen().getGraphicsScreen());
if (config == null) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
@@ -149,7 +150,7 @@ public class Window extends com.jogamp.newt.impl.WindowImpl {
private void windowCreated(int cfgID, int width, int height) {
this.width = width;
this.height = height;
- GLCapabilities capsReq = (GLCapabilities) config.getRequestedCapabilities();
+ GLCapabilitiesImmutable capsReq = (GLCapabilitiesImmutable) config.getRequestedCapabilities();
config = EGLGraphicsConfiguration.create(capsReq, getScreen().getGraphicsScreen(), cfgID);
if (config == null) {
throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this);
diff --git a/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java b/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java
index f0bc8587b..eb03dc9dc 100644
--- a/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/opengl/kd/KDWindow.java
@@ -33,15 +33,12 @@
package com.jogamp.newt.impl.opengl.kd;
-import com.jogamp.newt.*;
-import com.jogamp.newt.event.*;
import com.jogamp.newt.impl.*;
import com.jogamp.opengl.impl.egl.*;
import javax.media.nativewindow.*;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLProfile;
import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.util.Point;
+import javax.media.opengl.GLCapabilitiesImmutable;
public class KDWindow extends WindowImpl {
private static final String WINDOW_CLASS_NAME = "NewtWindow";
@@ -57,12 +54,13 @@ public class KDWindow extends WindowImpl {
if(0!=getParentWindowHandle()) {
throw new RuntimeException("Window parenting not supported (yet)");
}
- config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen());
+ config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(
+ capsRequested, capsRequested, null, getScreen().getGraphicsScreen());
if (config == null) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
- GLCapabilities eglCaps = (GLCapabilities)config.getChosenCapabilities();
+ GLCapabilitiesImmutable eglCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
int[] eglAttribs = EGLGraphicsConfiguration.GLCapabilities2AttribList(eglCaps);
eglWindowHandle = CreateWindow(getDisplayHandle(), eglAttribs);
diff --git a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
index 2c3ffc3cc..b188a580e 100644
--- a/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/windows/WindowsWindow.java
@@ -92,7 +92,8 @@ public class WindowsWindow extends WindowImpl {
protected void createNativeImpl() {
WindowsScreen screen = (WindowsScreen) getScreen();
WindowsDisplay display = (WindowsDisplay) screen.getDisplay();
- config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen());
+ config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(
+ capsRequested, capsRequested, null, screen.getGraphicsScreen());
if (config == null) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java b/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
index 91143923d..e81acee3e 100644
--- a/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
+++ b/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
@@ -52,7 +52,8 @@ public class X11Window extends WindowImpl {
protected void createNativeImpl() {
X11Screen screen = (X11Screen) getScreen();
X11Display display = (X11Display) screen.getDisplay();
- config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen());
+ config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(
+ capsRequested, capsRequested, null, screen.getGraphicsScreen());
if (config == null) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 967836cf6..d6da09bec 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -35,7 +35,6 @@
package com.jogamp.newt.opengl;
import com.jogamp.common.GlueGenVersion;
-import com.jogamp.common.util.VersionUtil;
import com.jogamp.nativewindow.NativeWindowVersion;
import com.jogamp.newt.*;
import com.jogamp.newt.event.*;
@@ -101,7 +100,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer {
* <P>
* The resulting GLWindow owns the Window, Screen and Device, ie it will be destructed.
*/
- public static GLWindow create(GLCapabilities caps) {
+ public static GLWindow create(GLCapabilitiesImmutable caps) {
return new GLWindow(NewtFactory.createWindow(caps));
}
@@ -111,7 +110,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer {
* <P>
* The resulting GLWindow owns the Window, ie it will be destructed.
*/
- public static GLWindow create(Screen screen, GLCapabilities caps) {
+ public static GLWindow create(Screen screen, GLCapabilitiesImmutable caps) {
return new GLWindow(NewtFactory.createWindow(screen, caps));
}
@@ -133,7 +132,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer {
* <P>
* The resulting GLWindow owns the Window, ie it will be destructed.
*/
- public static GLWindow create(NativeWindow parentNativeWindow, GLCapabilities caps) {
+ public static GLWindow create(NativeWindow parentNativeWindow, GLCapabilitiesImmutable caps) {
return new GLWindow(NewtFactory.createWindow(parentNativeWindow, caps));
}
@@ -359,7 +358,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer {
} else {
nw = window;
}
- GLCapabilities glCaps = (GLCapabilities) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+ GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
if(null==factory) {
factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
}
@@ -670,7 +669,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer {
return ( null != drawable ) ? drawable.isRealized() : false;
}
- public final GLCapabilities getChosenGLCapabilities() {
+ public final GLCapabilitiesImmutable getChosenGLCapabilities() {
if (drawable == null) {
throw new GLException("No drawable yet");
}
@@ -863,7 +862,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer {
System.err.println(NativeWindowVersion.getInstance());
System.err.print(JoglVersion.getInstance());
System.err.println(NewtVersion.getInstance());
- GLCapabilities caps = new GLCapabilities( GLProfile.getDefault() );
+ GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault() );
GLWindow glWindow = GLWindow.create(caps);
glWindow.setSize(128, 128);