From 29e3b223eae9f5775d1dd34f2aaeeb3db6d9233c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 17 Nov 2010 21:53:16 +0100 Subject: Finishing Immutable changes including GLCapabiltiesImmutable. --- .../opengl/impl/x11/glx/X11DummyGLXDrawable.java | 9 +- .../jogamp/opengl/impl/x11/glx/X11GLXContext.java | 4 +- .../opengl/impl/x11/glx/X11GLXDrawableFactory.java | 8 +- .../impl/x11/glx/X11GLXGraphicsConfiguration.java | 20 ++-- .../glx/X11GLXGraphicsConfigurationFactory.java | 124 ++++++++++++--------- .../impl/x11/glx/X11OffscreenGLXContext.java | 2 +- .../opengl/impl/x11/glx/X11PbufferGLXDrawable.java | 2 +- .../awt/X11AWTGLXGraphicsConfigurationFactory.java | 21 ++-- 8 files changed, 114 insertions(+), 76 deletions(-) (limited to 'src/jogl/classes/com/jogamp/opengl/impl/x11') 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(); -- cgit v1.2.3