aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax/media/opengl/awt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-11-17 21:53:16 +0100
committerSven Gothel <[email protected]>2010-11-17 21:53:16 +0100
commit29e3b223eae9f5775d1dd34f2aaeeb3db6d9233c (patch)
treeeae2c7d60a4cdbcdacd4057b020044bd42fb30b8 /src/jogl/classes/javax/media/opengl/awt
parent64aa219406c1aa1d6022fedce7a52c8c19d0e35d (diff)
Finishing Immutable changes including GLCapabiltiesImmutable.
Diffstat (limited to 'src/jogl/classes/javax/media/opengl/awt')
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java40
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java32
2 files changed, 40 insertions, 32 deletions
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);
}