aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-06-03 19:57:05 +0000
committerSven Gothel <[email protected]>2009-06-03 19:57:05 +0000
commitaf23607f257b01777d52c93f8908912d1ae8c8bb (patch)
treea25f002e6ad9cc827981d6fe33ed15627edc7fdf /src/jogl
parent522e3b3ed592d80881938cc3176d5fba5289a79f (diff)
Tested:
- Linux / X11 / GL3 / GL2 / ES1 / ES2 - Using etc/profile.jogl JOGL_ALL . ./setenv-jogl.x86.sh JOGL_ALL - Java2D/GLJPanel: demos.jrefract.JRefract - GLCanvas: demos.gears.Gears - Newt/Nativewindow (demos.GLInfo, demos.es2.RedSquare, demos.es2.RedSquare) - with multiple instances of different GL profiles, ie java demos.es1.RedSquare -GLES2 -GLES1 java demos.GLInfo -GLES2 -GL2 - GL 3.1 test with demos.GLInfo java demos.GLInfo -GL3 java demos.GLInfo -GL3 -GL2 with NVIDIA 180.37.05 JOGL Enable parallel GLProfiles: - GL holds it's GLProfile - GL / GLBase added: hasGLSL() getGLProfile() - Removed all hardcoded GLProfile checks - Make GLProfile an instance of GLCapabilities - GLCapabilities needs GLProfile in constructor, or null for the default GLProfile - All GLProfiles are singelton mapped objects, setup and verified at static init. - All GLDrawableFactories in GLDrawableFactory are singelton objects, setup at static init. - GLDrawableFactories.getFactory() needs an argument, which leads to GLProfile, ie NativeWindow, AbstractGraphicsConfiguration, GLCapabilities or GLProfile. - EGLDrawableFactory takes GLProfile as an argument, being able to take the singleton role as ES1 or ES2 - EGLDrawableFactory loads ES & EGL libraries _local_, otherwise the symbols produce a collision (Unix/PC-Emulation). TODO: Check on Windows/WinCE ! - Fixing etc/profile.jogl JOGL_ALL EGLGraphicsConfigurationFactory - Added eglGetConfigs -> GLCapabilities -> eglChooseConfig, in case the simple eglChooseConfig fails. - Using given chooser, is null, use DefaultGLCapabilitiesChooser Moved FixedFuncUtil.class -> jogl.util.jar, otherwise the FixedFuncUtil pipeline cannot be used without emulation. GLDrawable Rename getChosenGLCapabilities() -> getGLCapabilities(), since all GLCapabilities access functions return the current state. Add getGLProfile() NativeLibLoader[Base] Added 'addLoaded' and 'isLoaded', so all LoadAction implementation can use it and circumvent double library loading. GlueGen Split openLibrary -> openLibraryLocal / Global, utilizing as an optional flag (global), which is true per default. TODO: How to do this on Windows ? TODO: Verify Windows and MacOSX !! git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1922 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java27
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java10
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java14
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java11
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/NativeLibLoader.java28
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/awt/Java2D.java2
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java9
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java8
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java24
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java16
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java69
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/glu/GLUquadricImpl.java33
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java5
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java5
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java5
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java5
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java15
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java8
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java11
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java12
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java3
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java13
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java13
-rw-r--r--src/jogl/classes/com/sun/opengl/util/GLArrayDataClient.java24
-rw-r--r--src/jogl/classes/com/sun/opengl/util/GLArrayDataServer.java36
-rw-r--r--src/jogl/classes/com/sun/opengl/util/GLArrayDataWrapper.java12
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/util/Gamma.java9
-rw-r--r--src/jogl/classes/com/sun/opengl/util/ImmModeSink.java32
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/util/awt/TextRenderer.java31
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/util/awt/TextureRenderer.java9
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/util/glsl/fixedfunc/impl/FixedFuncHook.java16
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/util/texture/Texture.java32
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javame_cdc_fp7
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javase7
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureData.java4
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/util/texture/spi/TGAImage.java.javame_cdc_fp5
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/util/texture/spi/TGAImage.java.javase5
-rw-r--r--src/jogl/classes/javax/media/opengl/GLBase.java9
-rw-r--r--src/jogl/classes/javax/media/opengl/GLCapabilities.java26
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java19
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawable.java14
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java150
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java625
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java58
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java65
47 files changed, 1000 insertions, 545 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
index 77a41a7dc..fac5401ee 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
@@ -76,7 +76,7 @@ public abstract class GLContextImpl extends GLContext {
protected GL gl;
- public GLContextImpl(GLContext shareWith) {
+ public GLContextImpl(GLProfile glp, GLContext shareWith) {
extensionAvailability = new ExtensionAvailabilityCache(this);
if (shareWith != null) {
GLContextShareSet.registerSharing(this, shareWith);
@@ -84,7 +84,7 @@ public abstract class GLContextImpl extends GLContext {
GLContextShareSet.registerForBufferObjectSharing(shareWith, this);
// This must occur after the above calls into the
// GLContextShareSet, which set up state needed by the GL object
- setGL(createGL());
+ setGL(createGL(glp));
}
public GLDrawableImpl getDrawableImpl() {
@@ -134,6 +134,11 @@ public abstract class GLContextImpl extends GLContext {
if (res == CONTEXT_NOT_CURRENT) {
lock.unlock();
} else {
+ if(res == CONTEXT_CURRENT_NEW) {
+ // check if the drawable's and the GL's GLProfile are equal
+ // throws an GLException if not
+ getGLDrawable().getGLProfile().verifyEquality(gl.getGLProfile());
+ }
setCurrent(this);
/* FIXME: refactor dependence on Java 2D / JOGL bridge
@@ -240,13 +245,13 @@ public abstract class GLContextImpl extends GLContext {
// Helpers for various context implementations
//
- private Object createInstance(String suffix, Class[] cstrArgTypes, Object[] cstrArgs) {
- return NWReflection.createInstance(GLProfile.getGLImplBaseClassName()+suffix, cstrArgTypes, cstrArgs);
+ private Object createInstance(GLProfile glp, String suffix, Class[] cstrArgTypes, Object[] cstrArgs) {
+ return NWReflection.createInstance(glp.getGLImplBaseClassName()+suffix, cstrArgTypes, cstrArgs);
}
/** Create the GL for this context. */
- protected GL createGL() {
- GL gl = (GL) createInstance("Impl", new Class[] { GLContextImpl.class }, new Object[] { this } );
+ protected GL createGL(GLProfile glp) {
+ GL gl = (GL) createInstance(glp, "Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { glp, this } );
/* FIXME: refactor dependence on Java 2D / JOGL bridge
if (tracker != null) {
@@ -322,11 +327,9 @@ public abstract class GLContextImpl extends GLContext {
if(null!=this.gl && null!=glProcAddressTable && !force) {
return; // already done and not forced
}
- // In order to be able to allow the user to uniformly install the
- // debug and trace pipelines in their GLEventListener.init()
- // method (for both GLCanvas and GLJPanel), we need to reset the
- // actual GL object in the GLDrawable as well
- setGL(createGL());
+ if(null==this.gl || force) {
+ setGL(createGL(getGLDrawable().getGLProfile()));
+ }
updateGLProcAddressTable();
}
@@ -345,7 +348,7 @@ public abstract class GLContextImpl extends GLContext {
System.err.println(getThreadName() + ": !!! Initializing OpenGL extension address table for " + this);
}
if (glProcAddressTable == null) {
- glProcAddressTable = (ProcAddressTable) createInstance("ProcAddressTable", new Class[0], null);
+ glProcAddressTable = (ProcAddressTable) createInstance(gl.getGLProfile(), "ProcAddressTable", new Class[0], null);
// FIXME: cache ProcAddressTables by capability bits so we can
// share them among contexts with the same capabilities
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
index fb1b8d6f4..2b9178d06 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
@@ -68,8 +68,14 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory implements
super();
}
- public static GLDrawableFactoryImpl getFactoryImpl() {
- return (GLDrawableFactoryImpl) getFactory();
+ /**
+ * Returns the sole GLDrawableFactoryImpl instance.
+ *
+ * @arg esProfile GLProfile to determine the EGL factory type,
+ * maybe null in case of non ES profile, ie GL2 or GL3.
+ */
+ public static GLDrawableFactoryImpl getFactoryImpl(GLProfile glp) {
+ return (GLDrawableFactoryImpl) getFactory(glp);
}
// Helper function for more lazily loading the GLU library;
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
index 7a0f072a4..4cff8f8f5 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
@@ -69,10 +69,15 @@ public abstract class GLDrawableImpl implements GLDrawable {
return GLContextImpl.toHexString(hex);
}
- public GLCapabilities getChosenGLCapabilities() {
- GLCapabilities caps = (GLCapabilities)component.getGraphicsConfiguration().getCapabilities();
- if (caps == null)
- return null;
+ public GLProfile getGLProfile() {
+ return getGLCapabilities().getGLProfile();
+ }
+
+ public GLCapabilities getGLCapabilities() {
+ GLCapabilities caps = (GLCapabilities)component.getGraphicsConfiguration().getNativeGraphicsConfiguration().getCapabilities();
+ if (caps == null) {
+ throw new GLException("No GLCapabilities: "+this);
+ }
// Must return a new copy to avoid mutation by end user
return (GLCapabilities)caps.clone();
@@ -123,6 +128,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
public String toString() {
return getClass().getName()+"[realized "+getRealized()+
+ ", capabilities "+getGLCapabilities()+
", window "+getNativeWindow()+
", factory "+getFactory()+"]";
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java
index b28dd1b53..ff8043f7e 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java
@@ -157,11 +157,18 @@ public class GLPbufferImpl implements GLPbuffer {
context.releasePbufferFromTexture();
}
- public GLCapabilities getChosenGLCapabilities() {
+ public GLCapabilities getGLCapabilities() {
if (pbufferDrawable == null)
return null;
- return pbufferDrawable.getChosenGLCapabilities();
+ return pbufferDrawable.getGLCapabilities();
+ }
+
+ public GLProfile getGLProfile() {
+ if (pbufferDrawable == null)
+ return null;
+
+ return pbufferDrawable.getGLProfile();
}
private boolean surfaceLocked = false;
diff --git a/src/jogl/classes/com/sun/opengl/impl/NativeLibLoader.java b/src/jogl/classes/com/sun/opengl/impl/NativeLibLoader.java
index eaed6ad81..ee4d160fc 100644
--- a/src/jogl/classes/com/sun/opengl/impl/NativeLibLoader.java
+++ b/src/jogl/classes/com/sun/opengl/impl/NativeLibLoader.java
@@ -49,6 +49,7 @@ import java.util.HashSet;
import com.sun.nativewindow.impl.NativeLibLoaderBase;
public class NativeLibLoader extends NativeLibLoaderBase {
+ protected static final boolean DEBUG = Debug.debug("NativeLibLoader");
public static void loadNEWT() {
AccessController.doPrivileged(new PrivilegedAction() {
@@ -68,7 +69,7 @@ public class NativeLibLoader extends NativeLibLoaderBase {
});
}
- public static void loadGL2ES12() {
+ public static void loadGLDesktopES12() {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
loadLibrary("jogl_gl2es12", nativewindowX11Preload, true);
@@ -109,26 +110,28 @@ public class NativeLibLoader extends NativeLibLoaderBase {
// Support for the new JNLPAppletLauncher
//
- private static boolean DEBUG = true;
-
private static class JOGLAction implements NativeLibLoaderBase.LoaderAction {
public void loadLibrary(String libname, String[] preload,
boolean preloadIgnoreError) {
if (null!=preload) {
for (int i=0; i<preload.length; i++) {
- try {
- loadLibraryInternal(preload[i]);
- }
- catch (UnsatisfiedLinkError e) {
- if(DEBUG) e.printStackTrace();
- if (!preloadIgnoreError && e.getMessage().indexOf("already loaded") < 0) {
- throw e;
- }
+ if(!isLoaded(preload[i])) {
+ try {
+ loadLibraryInternal(preload[i]);
+ addLoaded(preload[i]);
+ }
+ catch (UnsatisfiedLinkError e) {
+ if(DEBUG) e.printStackTrace();
+ if (!preloadIgnoreError && e.getMessage().indexOf("already loaded") < 0) {
+ throw e;
+ }
+ }
}
}
}
loadLibraryInternal(libname);
+ addLoaded(libname);
}
}
@@ -175,6 +178,9 @@ public class NativeLibLoader extends NativeLibLoaderBase {
// FIXME: remove
// System.out.println("sun.boot.library.path=" + System.getProperty("sun.boot.library.path"));
System.loadLibrary(libraryName);
+ if(DEBUG) {
+ System.err.println("JOGL Loaded Native Library: "+libraryName);
+ }
}
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/awt/Java2D.java b/src/jogl/classes/com/sun/opengl/impl/awt/Java2D.java
index 5bac0097c..0af368626 100755
--- a/src/jogl/classes/com/sun/opengl/impl/awt/Java2D.java
+++ b/src/jogl/classes/com/sun/opengl/impl/awt/Java2D.java
@@ -559,7 +559,7 @@ public class Java2D {
invokeWithOGLSharedContextCurrent(device.getDefaultConfiguration(), new Runnable() {
public void run() {
// AbstractGraphicsScreen awtscreen = AWTGraphicsScreen.createScreenDevice(device);
- j2dFBOShareContext = GLDrawableFactory.getFactory().createExternalGLContext(/*awtscreen*/);
+ j2dFBOShareContext = GLDrawableFactory.getFactory(GLProfile.GetProfileDefault()).createExternalGLContext(/*awtscreen*/);
}
});
if (DEBUG) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
index 8b790632e..d6cf2af8a 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
@@ -53,7 +53,7 @@ public class EGLContext extends GLContextImpl {
private EGLExtProcAddressTable eglExtProcAddressTable;
public EGLContext(EGLDrawable drawable, GLContext shareWith) {
- super(shareWith);
+ super(drawable.getGLProfile(), shareWith);
this.drawable = drawable;
}
@@ -183,6 +183,7 @@ public class EGLContext extends GLContextImpl {
protected void create() throws GLException {
long eglDisplay = drawable.getDisplay();
EGLGraphicsConfiguration config = drawable.getGraphicsConfiguration();
+ GLProfile glProfile = drawable.getGLProfile();
_EGLConfig eglConfig = config.getNativeConfig();
long shareWith = EGL.EGL_NO_CONTEXT;
@@ -204,12 +205,12 @@ public class EGLContext extends GLContextImpl {
EGL.EGL_CONTEXT_CLIENT_VERSION, -1,
EGL.EGL_NONE
};
- if (GLProfile.usesNativeGLES2()) {
+ if (glProfile.usesNativeGLES2()) {
contextAttrs[1] = 2;
- } else if (GLProfile.usesNativeGLES1()) {
+ } else if (glProfile.usesNativeGLES1()) {
contextAttrs[1] = 1;
} else {
- throw new GLException("Error creating OpenGL context - invalid GLProfile");
+ throw new GLException("Error creating OpenGL context - invalid GLProfile: "+glProfile);
}
eglContext = EGL.eglCreateContext(eglDisplay, eglConfig, shareWith, contextAttrs, 0);
if (eglContext == 0) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
index fe9544666..389278d96 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
@@ -68,6 +68,14 @@ public class EGLDrawable extends GLDrawableImpl {
return eglConfig;
}
+ public GLProfile getGLProfile() {
+ return (null==eglConfig)?super.getGLProfile():((GLCapabilities)eglConfig.getCapabilities()).getGLProfile();
+ }
+
+ public GLCapabilities getGLCapabilities() {
+ return (null==eglConfig)?super.getGLCapabilities():(GLCapabilities)eglConfig.getCapabilities();
+ }
+
protected void setSurface() {
if (EGL.EGL_NO_SURFACE==eglSurface) {
lockSurface();
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
index d9f17689c..aeb4db84a 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
@@ -47,10 +47,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
// We need more than one of these on certain devices (the NVidia APX 2500 in particular)
private List/*<NativeLibrary>*/ glesLibraries = new ArrayList();
- public EGLDrawableFactory() {
+ public EGLDrawableFactory(String esProfile) {
super();
- loadGLESLibrary();
+ loadGLESLibrary(esProfile);
EGL.resetProcAddressTable(this);
// Register our GraphicsConfigurationFactory implementations
@@ -58,7 +58,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
new EGLGraphicsConfigurationFactory();
// Check for other underlying stuff ..
- if(NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType())) {
+ if(NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(false))) {
try {
NWReflection.createInstance("com.sun.opengl.impl.x11.glx.X11GLXGraphicsConfigurationFactory");
} catch (Throwable t) {}
@@ -67,7 +67,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
private NativeLibrary loadFirstAvailable(List/*<String>*/ libNames, ClassLoader loader) {
for (Iterator iter = libNames.iterator(); iter.hasNext(); ) {
- NativeLibrary lib = NativeLibrary.open((String) iter.next(), loader);
+ NativeLibrary lib = NativeLibrary.open((String) iter.next(), loader, false /*global*/);
if (lib != null) {
return lib;
}
@@ -75,14 +75,14 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
return null;
}
- private void loadGLESLibrary() {
+ private void loadGLESLibrary(String esProfile) {
List/*<NativeLibrary>*/ libs = new ArrayList();
// Try several variants
List/*<String>*/ glesLibNames = new ArrayList();
List/*<String>*/ eglLibNames = new ArrayList();
- if (GLProfile.usesNativeGLES2()) {
+ if(GLProfile.UsesNativeGLES2(esProfile)) {
// Unix
glesLibNames.add("libGLES20");
glesLibNames.add("libGLESv2");
@@ -91,7 +91,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
glesLibNames.add("GLES20");
glesLibNames.add("GLESv2");
glesLibNames.add("GLESv2_CM");
- } else if (GLProfile.usesNativeGLES1()) {
+ } else if(GLProfile.UsesNativeGLES1(esProfile)) {
// Unix
glesLibNames.add("libGLES_CM");
glesLibNames.add("libGLES_CL");
@@ -102,7 +102,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
glesLibNames.add("GLES_CL");
glesLibNames.add("GLESv1_CM");
} else {
- throw new GLException("Invalid GL Profile for EGL: "+GLProfile.getProfile());
+ throw new GLException("Invalid GL Profile for EGL: "+esProfile);
}
// EGL Unix
@@ -113,18 +113,18 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
ClassLoader loader = getClass().getClassLoader();
NativeLibrary lib = loadFirstAvailable(glesLibNames, loader);
if (lib == null) {
- throw new GLException("Unable to dynamically load OpenGL ES library for profile \"" + GLProfile.getProfile() + "\"");
+ throw new GLException("Unable to dynamically load OpenGL ES library for profile \"" + esProfile + "\"");
}
glesLibraries.add(lib);
lib = loadFirstAvailable(eglLibNames, loader);
if (lib == null) {
- throw new GLException("Unable to dynamically load EGL library for profile \"" + GLProfile.getProfile() + "\"");
+ throw new GLException("Unable to dynamically load EGL library for profile \"" + esProfile + "\"");
}
glesLibraries.add(lib);
- if (GLProfile.usesNativeGLES2()) {
+ if (GLProfile.UsesNativeGLES2(esProfile)) {
NativeLibLoader.loadES2();
- } else if (GLProfile.usesNativeGLES1()) {
+ } else if (GLProfile.UsesNativeGLES1(esProfile)) {
NativeLibLoader.loadES1();
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
index 2b50b68a3..c3f4089ba 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
@@ -61,18 +61,18 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
return super.clone();
}
- public static _EGLConfig EGLConfigId2EGLConfig(long display, int configID) {
+ public static _EGLConfig EGLConfigId2EGLConfig(GLProfile glp, long display, int configID) {
int[] attrs = new int[] {
EGL.EGL_RENDERABLE_TYPE, -1,
EGL.EGL_CONFIG_ID, configID,
EGL.EGL_NONE
};
- if (GLProfile.usesNativeGLES2()) {
+ if (glp.usesNativeGLES2()) {
attrs[1] = EGL.EGL_OPENGL_ES2_BIT;
- } else if (GLProfile.usesNativeGLES1()) {
+ } else if (glp.usesNativeGLES1()) {
attrs[1] = EGL.EGL_OPENGL_ES_BIT;
} else {
- throw new GLException("Error creating EGL drawable - invalid GLProfile");
+ attrs[1] = EGL.EGL_OPENGL_BIT;
}
_EGLConfig[] configs = new _EGLConfig[1];
int[] numConfigs = new int[1];
@@ -88,8 +88,8 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
return configs[0];
}
- public static GLCapabilities EGLConfig2Capabilities(long display, _EGLConfig _config) {
- GLCapabilities caps = new GLCapabilities();
+ public static GLCapabilities EGLConfig2Capabilities(GLProfile glp, long display, _EGLConfig _config) {
+ GLCapabilities caps = new GLCapabilities(glp);
int[] val = new int[1];
// Read the actual configuration into the choosen caps
@@ -128,10 +128,10 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
EGL.EGL_NONE
};
- if(GLProfile.usesNativeGLES1()) {
+ if(caps.getGLProfile().usesNativeGLES1()) {
attrs[1] = EGL.EGL_OPENGL_ES_BIT;
}
- else if(GLProfile.usesNativeGLES2()) {
+ else if(caps.getGLProfile().usesNativeGLES2()) {
attrs[1] = EGL.EGL_OPENGL_ES2_BIT;
} else {
attrs[1] = EGL.EGL_OPENGL_BIT;
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
index da12cead6..f12d1c6a8 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
@@ -70,6 +70,10 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects");
}
+ if (chooser == null) {
+ chooser = new DefaultGLCapabilitiesChooser();
+ }
+
return chooseGraphicsConfigurationStatic((GLCapabilities) capabilities,
(GLCapabilitiesChooser) chooser,
absScreen);
@@ -79,8 +83,9 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
GLCapabilitiesChooser chooser,
AbstractGraphicsScreen absScreen) {
if (capabilities == null) {
- capabilities = new GLCapabilities();
+ capabilities = new GLCapabilities(null);
}
+ GLProfile glp = capabilities.getGLProfile();
if(null==absScreen) {
throw new GLException("Null AbstractGraphicsScreen");
@@ -96,6 +101,47 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
throw new GLException("Invalid EGL display: "+absDevice);
}
+ EGLGraphicsConfiguration res = eglChooseConfig(eglDisplay, capabilities, absScreen);
+ if(null!=res) {
+ return res;
+ }
+
+ _EGLConfig[] configs = new _EGLConfig[10];
+ int[] numConfigs = new int[1];
+
+ if(!EGL.eglGetConfigs(eglDisplay, configs, 10, numConfigs, 0)) {
+ throw new GLException("Graphics configuration fetch (eglGetConfigs) failed");
+ }
+ if (numConfigs[0] == 0) {
+ throw new GLException("Graphics configuration fetch (eglGetConfigs) - no EGLConfig found");
+ }
+ GLCapabilities[] caps = new GLCapabilities[numConfigs[0]];
+ for(int i=0; i<caps.length; i++) {
+ caps[i] = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[i]);
+ if(DEBUG) {
+ System.err.println("caps["+i+"] "+caps[i]);
+ }
+ }
+ int chosen = -1;
+ try {
+ chosen = chooser.chooseCapabilities(capabilities, caps, -1);
+ } catch (NativeWindowException e) { throw new GLException(e); }
+ if(chosen<0) {
+ throw new GLException("Graphics configuration chooser failed");
+ }
+ if(DEBUG) {
+ System.err.println("Choosen "+caps[chosen]);
+ }
+ res = eglChooseConfig(eglDisplay, caps[chosen], absScreen);
+ if(null==res) {
+ throw new GLException("Graphics configuration chooser/eglChoose failed");
+ }
+ return res;
+ }
+
+ protected static EGLGraphicsConfiguration eglChooseConfig(long eglDisplay, GLCapabilities capabilities,
+ AbstractGraphicsScreen absScreen) {
+ GLProfile glp = capabilities.getGLProfile();
int[] attrs = EGLGraphicsConfiguration.GLCapabilities2AttribList(capabilities);
_EGLConfig[] configs = new _EGLConfig[1];
int[] numConfigs = new int[1];
@@ -105,18 +151,17 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
numConfigs, 0)) {
throw new GLException("Graphics configuration selection (eglChooseConfig) failed");
}
- if (numConfigs[0] == 0) {
- throw new GLException("No valid graphics configuration selected from eglChooseConfig");
- }
-
- int[] val = new int[1];
- // get the configID
- if(!EGL.eglGetConfigAttrib(eglDisplay, configs[0], EGL.EGL_CONFIG_ID, val, 0)) {
- throw new GLException("EGL couldn't retrieve ConfigID");
+ if (numConfigs[0] > 0) {
+ int[] val = new int[1];
+ // get the configID
+ if(!EGL.eglGetConfigAttrib(eglDisplay, configs[0], EGL.EGL_CONFIG_ID, val, 0)) {
+ throw new GLException("EGL couldn't retrieve ConfigID");
+ }
+
+ return new EGLGraphicsConfiguration(absScreen,
+ EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[0]), configs[0], val[0]);
}
-
- return new EGLGraphicsConfiguration(absScreen,
- EGLGraphicsConfiguration.EGLConfig2Capabilities(eglDisplay, configs[0]), configs[0], val[0]);
+ return null;
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/glu/GLUquadricImpl.java b/src/jogl/classes/com/sun/opengl/impl/glu/GLUquadricImpl.java
index 129b24529..34b5ced6b 100644
--- a/src/jogl/classes/com/sun/opengl/impl/glu/GLUquadricImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/glu/GLUquadricImpl.java
@@ -138,42 +138,35 @@ public class GLUquadricImpl implements GLUquadric {
private boolean immModeSinkEnabled;
private boolean immModeSinkImmediate;
public int normalType;
+ public GL gl;
public static final boolean USE_NORM = true;
public static final boolean USE_TEXT = false;
- private ImmModeSink immModeSink;
+ private ImmModeSink immModeSink=null;
- public GLUquadricImpl(boolean useGLSL) {
+ public GLUquadricImpl(GL gl, boolean useGLSL) {
+ this.gl=gl;
this.useGLSL = useGLSL;
drawStyle = GLU.GLU_FILL;
orientation = GLU.GLU_OUTSIDE;
textureFlag = false;
normals = GLU.GLU_SMOOTH;
- normalType = GLProfile.isGLES1()?GL.GL_BYTE:GL.GL_FLOAT;
- if(useGLSL) {
- immModeSink = ImmModeSink.createGLSL (GL.GL_STATIC_DRAW, 32,
- 3, GL.GL_FLOAT, // vertex
- 0, GL.GL_FLOAT, // color
- USE_NORM?3:0, normalType,// normal
- USE_TEXT?2:0, GL.GL_FLOAT); // texture
- } else {
- immModeSink = ImmModeSink.createFixed(GL.GL_STATIC_DRAW, 32,
- 3, GL.GL_FLOAT, // vertex
- 0, GL.GL_FLOAT, // color
- USE_NORM?3:0, normalType,// normal
- USE_TEXT?2:0, GL.GL_FLOAT); // texture
- }
+ normalType = gl.isGLES1()?GL.GL_BYTE:GL.GL_FLOAT;
immModeSinkImmediate=true;
- immModeSinkEnabled=!GLProfile.isGL2();
+ immModeSinkEnabled=!gl.isGL2();
+ replaceImmModeSink();
}
public void enableImmModeSink(boolean val) {
- if(GLProfile.isGL2()) {
+ if(gl.isGL2()) {
immModeSinkEnabled=val;
} else {
immModeSinkEnabled=true;
}
+ if(null==immModeSink && immModeSinkEnabled) {
+ replaceImmModeSink();
+ }
}
public boolean isImmModeSinkEnabled() {
@@ -197,13 +190,13 @@ public class GLUquadricImpl implements GLUquadric {
ImmModeSink res = immModeSink;
if(useGLSL) {
- immModeSink = ImmModeSink.createGLSL (GL.GL_STATIC_DRAW, 32,
+ immModeSink = ImmModeSink.createGLSL (gl, GL.GL_STATIC_DRAW, 32,
3, GL.GL_FLOAT, // vertex
0, GL.GL_FLOAT, // color
USE_NORM?3:0, normalType,// normal
USE_TEXT?2:0, GL.GL_FLOAT); // texture
} else {
- immModeSink = ImmModeSink.createFixed(GL.GL_STATIC_DRAW, 32,
+ immModeSink = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 32,
3, GL.GL_FLOAT, // vertex
0, GL.GL_FLOAT, // color
USE_NORM?3:0, normalType,// normal
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java
index 7a092b278..b42f35e17 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java
@@ -58,7 +58,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
public MacOSXCGLContext(MacOSXCGLDrawable drawable,
GLContext shareWith)
{
- super(shareWith);
+ super(drawable.getGLProfile(), shareWith);
this.drawable = drawable;
}
@@ -112,6 +112,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilities capabilities = (GLCapabilities)config.getCapabilities();
+ GLProfile glProfile = capabilities.getGLProfile();
// FIXME: Shall being moved to MacOSXCGLGraphicsConfiguration !
int[] viewNotReady = new int[1];
int[] iattribs = new int[128];
@@ -174,7 +175,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
// Note: These restrictions of the platform's API might be considered as a bug anyways.
if (!config.getIsUpdated()) {
// Figure out what attributes we really got
- GLCapabilities caps = new GLCapabilities();
+ GLCapabilities caps = new GLCapabilities(glProfile);
CGL.queryPixelFormat(pixelFormat, iattribs, 0, idx, ivalues, 0);
for (int i = 0; i < idx; i++) {
int attr = iattribs[i];
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
index 71b9bd38e..8b33fefc4 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
@@ -59,13 +59,14 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GraphicsConfiguration
return chooseGraphicsConfigurationStatic(capabilities, chooser, absScreen, false);
}
+ /** FIXME: remove
protected static MacOSXCGLGraphicsConfiguration createDefaultGraphicsConfiguration(AbstractGraphicsScreen absScreen, boolean usePBuffer) {
if (absScreen == null) {
throw new IllegalArgumentException("AbstractGraphicsScreen is null");
}
return new MacOSXCGLGraphicsConfiguration(absScreen, new GLCapabilities());
- }
+ }*/
protected static MacOSXCGLGraphicsConfiguration chooseGraphicsConfigurationStatic(Capabilities capabilities,
CapabilitiesChooser chooser,
@@ -85,7 +86,7 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GraphicsConfiguration
}
if (capabilities == null) {
- capabilities = new GLCapabilities();
+ capabilities = new GLCapabilities(null);
}
return new MacOSXCGLGraphicsConfiguration(absScreen, (GLCapabilities)capabilities);
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
index 7176aaaf1..2e6716cf4 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
@@ -95,8 +95,9 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
NullWindow nw = (NullWindow) getNativeWindow();
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilities capabilities = (GLCapabilities)config.getCapabilities();
+ GLProfile glProfile = capabilities.getGLProfile();
int renderTarget;
- if (GLProfile.isGL2() && capabilities.getPbufferRenderToTextureRectangle()) {
+ if (glProfile.isGL2() && capabilities.getPbufferRenderToTextureRectangle()) {
renderTarget = GL2.GL_TEXTURE_RECTANGLE_EXT;
} else {
int w = getNextPowerOf2(getWidth());
@@ -116,7 +117,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
throw new GLException("Floating-point support (GL_APPLE_float_pixels) not available");
}
*/
- if(GLProfile.isGL2()) {
+ if(glProfile.isGL2()) {
switch (capabilities.getRedBits()) {
case 16: internalFormat = GL2.GL_RGBA_FLOAT16_APPLE; break;
case 32: internalFormat = GL2.GL_RGBA_FLOAT32_APPLE; break;
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
index 707d28ea8..4423f8da5 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
@@ -87,7 +87,7 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL
}
if (created) {
- resetGLFunctionAvailability();
+ setGLFunctionAvailability(false);
return CONTEXT_CURRENT_NEW;
}
return CONTEXT_CURRENT;
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
index a22a8bfec..62388173c 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
@@ -57,7 +57,7 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
NullWindow nw = (NullWindow) getNativeWindow();
nw.setSurfaceHandle(hdc);
// Choose a (hopefully hardware-accelerated) OpenGL pixel format for this device context
- GLCapabilities caps = new GLCapabilities();
+ GLCapabilities caps = new GLCapabilities(null);
caps.setDepthBits(16);
PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps, true);
int pixelFormat = WGL.ChoosePixelFormat(hdc, pfd);
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
index 247a00fa3..46d46de02 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -133,6 +133,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilities capabilities = (GLCapabilities)config.getCapabilities();
+ GLProfile glProfile = capabilities.getGLProfile();
if (DEBUG) {
System.out.println("Pbuffer parentHdc = " + toHexString(parentHdc));
@@ -300,7 +301,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(iattributes, niattribs, ivalues, false);
+ GLCapabilities newCaps = WindowsWGLGraphicsConfiguration.AttribList2GLCapabilities(glProfile, iattributes, niattribs, ivalues, false);
PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.createPixelFormatDescriptor();
if (WGL.DescribePixelFormat(parentHdc, pformats[whichFormat], pfd.size(), pfd) == 0) {
throw new GLException("Unable to describe pixel format " + pformats[whichFormat]);
@@ -311,7 +312,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
if (WGL.DescribePixelFormat(parentHdc, pformats[whichFormat], pfd.size(), pfd) == 0) {
throw new GLException("Unable to describe pixel format " + pformats[whichFormat]);
}
- GLCapabilities newCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(pfd);
+ GLCapabilities newCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, pfd);
config.setCapsPFD(newCaps, pfd, pformats[whichFormat]);
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
index 789bb16a3..1ff640df2 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -42,6 +42,7 @@ package com.sun.opengl.impl.windows.wgl;
import java.nio.*;
import java.util.*;
import javax.media.opengl.*;
+import javax.media.nativewindow.*;
import com.sun.opengl.impl.*;
import com.sun.gluegen.runtime.ProcAddressTable;
@@ -70,7 +71,7 @@ public class WindowsWGLContext extends GLContextImpl {
// FIXME: figure out how to hook back in the Java 2D / JOGL bridge
public WindowsWGLContext(WindowsWGLDrawable drawable,
GLContext shareWith) {
- super(shareWith);
+ super(drawable.getGLProfile(), shareWith);
this.drawable = drawable;
}
@@ -118,6 +119,12 @@ public class WindowsWGLContext extends GLContextImpl {
* called by {@link #makeCurrentImpl()}.
*/
protected void create() {
+ AbstractGraphicsConfiguration config = drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ if(DEBUG) {
+ System.err.println("WindowsWGLContext.create got "+config);
+ }
+ GLCapabilities glCaps = (GLCapabilities) config.getCapabilities();
+
if (drawable.getNativeWindow().getSurfaceHandle() == 0) {
throw new GLException("Internal error: attempted to create OpenGL context without an associated drawable");
}
@@ -147,7 +154,7 @@ public class WindowsWGLContext extends GLContextImpl {
if( !isFunctionAvailable("wglCreateContextAttribsARB") ||
!isExtensionAvailable("WGL_ARB_create_context") ) {
- if(GLProfile.isGL3()) {
+ if(glCaps.getGLProfile().isGL3()) {
if (!WGL.wglMakeCurrent(0, 0)) {
throw new GLException("Error freeing temp OpenGL context: " + WGL.GetLastError());
}
@@ -173,7 +180,7 @@ public class WindowsWGLContext extends GLContextImpl {
0
};
- if(GLProfile.isGL3()) {
+ if(glCaps.getGLProfile().isGL3()) {
attribs[1] |= 3;
attribs[3] |= 1;
attribs[5] |= WGLExt.WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /* | WGLExt.WGL_CONTEXT_DEBUG_BIT_ARB */;
@@ -181,7 +188,7 @@ public class WindowsWGLContext extends GLContextImpl {
hglrc = wglExt.wglCreateContextAttribsARB(drawable.getNativeWindow().getSurfaceHandle(), hglrc2, attribs, 0);
if(0==hglrc) {
- if(GLProfile.isGL3()) {
+ if(glCaps.getGLProfile().isGL3()) {
if (!WGL.wglMakeCurrent(0, 0)) {
throw new GLException("Error freeing temp OpenGL context: " + WGL.GetLastError());
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index d7293e3d4..babea70a1 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -235,11 +235,11 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
return true;
}
- public static GLCapabilities AttribList2GLCapabilities(int[] iattribs,
+ public static GLCapabilities AttribList2GLCapabilities(GLProfile glp, int[] iattribs,
int niattribs,
int[] iresults,
boolean requireRenderToWindow) {
- GLCapabilities res = new GLCapabilities();
+ GLCapabilities res = new GLCapabilities(glp);
for (int i = 0; i < niattribs; i++) {
int attr = iattribs[i];
switch (attr) {
@@ -341,11 +341,11 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
// PIXELFORMAT
- public static GLCapabilities PFD2GLCapabilities(PIXELFORMATDESCRIPTOR pfd) {
+ public static GLCapabilities PFD2GLCapabilities(GLProfile glp, PIXELFORMATDESCRIPTOR pfd) {
if ((pfd.dwFlags() & WGL.PFD_SUPPORT_OPENGL) == 0) {
return null;
}
- GLCapabilities res = new GLCapabilities();
+ GLCapabilities res = new GLCapabilities(glp);
res.setRedBits (pfd.cRedBits());
res.setGreenBits (pfd.cGreenBits());
res.setBlueBits (pfd.cBlueBits());
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index 64d55effb..9ab878b2a 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -61,7 +61,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
}
protected static WindowsWGLGraphicsConfiguration createDefaultGraphicsConfiguration(AbstractGraphicsScreen absScreen, boolean useOffScreen) {
- GLCapabilities caps = new GLCapabilities();
+ GLCapabilities caps = new GLCapabilities(null);
if(null==absScreen) {
absScreen = DefaultGraphicsScreen.createScreenDevice(0);
}
@@ -91,6 +91,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) nativeWindow.getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilities capabilities = (GLCapabilities) config.getCapabilities();
+ GLProfile glProfile = capabilities.getGLProfile();
long hdc = nativeWindow.getSurfaceHandle();
PIXELFORMATDESCRIPTOR pfd = null;
@@ -111,7 +112,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
throw new GLException("Unable to describe pixel format " + pixelFormat +
" of window set by Java2D/OpenGL pipeline");
}
- config.setCapsPFD(WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(pfd), pfd, pixelFormat);
+ config.setCapsPFD(WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, pfd), pfd, pixelFormat);
return;
}
@@ -230,7 +231,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
if (!dummyWGLExt.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");
}
- availableCaps[i] = WindowsWGLGraphicsConfiguration.AttribList2GLCapabilities(iattributes, niattribs, iresults, true);
+ availableCaps[i] = WindowsWGLGraphicsConfiguration.AttribList2GLCapabilities(glProfile, iattributes, niattribs, iresults, true);
}
gotAvailableCaps = true;
} else {
@@ -275,7 +276,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
if (WGL.DescribePixelFormat(hdc, 1 + i, pfd.size(), pfd) == 0) {
throw new GLException("Error describing pixel format " + (1 + i) + " of device context");
}
- availableCaps[i] = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(pfd);
+ availableCaps[i] = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, pfd);
}
}
@@ -331,7 +332,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
if (chosenCaps != null) {
capabilities = chosenCaps;
} else {
- capabilities = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(pfd);
+ capabilities = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, pfd);
}
config.setCapsPFD(capabilities, pfd, pixelFormat);
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
index 5d6209af8..480a91ea7 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
@@ -68,7 +68,7 @@ public abstract class X11GLXContext extends GLContextImpl {
public X11GLXContext(X11GLXDrawable drawable,
GLContext shareWith) {
- super(shareWith);
+ super(drawable.getGLProfile(), shareWith);
this.drawable = drawable;
}
@@ -132,11 +132,12 @@ public abstract class X11GLXContext extends GLContextImpl {
if(DEBUG) {
System.err.println("X11GLXContext.createContext got "+config);
}
+ GLCapabilities glCaps = (GLCapabilities) config.getCapabilities();
long display = config.getScreen().getDevice().getHandle();
if(config.getFBConfigID()<0) {
// not able to use FBConfig
- if(GLProfile.isGL3()) {
+ if(glCaps.getGLProfile().isGL3()) {
throw new GLException("Unable to create OpenGL 3.1 context");
}
context = GLX.glXCreateContext(display, config.getXVisualInfo(), share, onscreen);
@@ -172,7 +173,7 @@ public abstract class X11GLXContext extends GLContextImpl {
if( !isFunctionAvailable("glXCreateContextAttribsARB") ||
!isExtensionAvailable("GLX_ARB_create_context") ) {
- if(GLProfile.isGL3()) {
+ if(glCaps.getGLProfile().isGL3()) {
if (!GLX.glXMakeContextCurrent(display, 0, 0, 0)) {
throw new GLException("Error freeing temp OpenGL context");
}
@@ -197,7 +198,7 @@ public abstract class X11GLXContext extends GLContextImpl {
0
};
- if(GLProfile.isGL3()) {
+ if(glCaps.getGLProfile().isGL3()) {
attribs[1] |= 3;
attribs[3] |= 1;
attribs[5] |= GLX.GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /* | GLX.GLX_CONTEXT_DEBUG_BIT_ARB */;
@@ -205,7 +206,7 @@ public abstract class X11GLXContext extends GLContextImpl {
context = glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, onscreen, attribs, 0);
if(0==context) {
- if(GLProfile.isGL3()) {
+ if(glCaps.getGLProfile().isGL3()) {
if (!GLX.glXMakeContextCurrent(display, 0, 0, 0)) {
throw new GLException("Error freeing temp OpenGL context");
}
@@ -229,7 +230,6 @@ public abstract class X11GLXContext extends GLContextImpl {
drawable.getNativeWindow().getSurfaceHandle(),
drawable.getNativeWindow().getSurfaceHandle(),
context)) {
- // FIXME: Nvidia driver 185.18.10 can't make the 3.1 context current ..
throw new GLException("Error making context (new) current: display 0x"+Long.toHexString(display)+", context 0x"+Long.toHexString(context)+", drawable "+drawable);
}
updateGLProcAddressTable();
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index 661fa9fcb..cb42d9821 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -65,8 +65,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
try {
NWReflection.createInstance("com.sun.opengl.impl.x11.glx.awt.X11AWTGLXGraphicsConfigurationFactory",
new Object[] {});
- } catch (Exception e) {
- }
+ } catch (Throwable t) { }
}
public GLDrawable createGLDrawable(NativeWindow target) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
index 5ff9b5368..7644fad74 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
@@ -165,11 +165,12 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
return res;
}
- public static GLCapabilities AttribList2GLCapabilities(int[] iattribs,
+ public static GLCapabilities AttribList2GLCapabilities(GLProfile glp,
+ int[] iattribs,
int niattribs,
int[] ivalues,
boolean usePBuffer) {
- GLCapabilities caps = new GLCapabilities();
+ GLCapabilities caps = new GLCapabilities(glp);
for (int i = 0; i < niattribs; i++) {
int attr = iattribs[i];
@@ -252,14 +253,14 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
// FBConfig
- public static GLCapabilities GLXFBConfig2GLCapabilities(long display, long fbcfg) {
+ public static GLCapabilities GLXFBConfig2GLCapabilities(GLProfile glp, long display, long fbcfg) {
int[] tmp = new int[1];
int val;
val = glXGetFBConfig(display, fbcfg, GLX.GLX_RENDER_TYPE, tmp, 0);
if (val != GLX.GLX_RGBA_BIT) {
throw new GLException("Visual does not support RGBA");
}
- GLCapabilities res = new GLCapabilities();
+ GLCapabilities res = new GLCapabilities(glp);
res.setDoubleBuffered(glXGetFBConfig(display, fbcfg, GLX.GLX_DOUBLEBUFFER, tmp, 0) != 0);
res.setStereo (glXGetFBConfig(display, fbcfg, GLX.GLX_STEREO, tmp, 0) != 0);
res.setHardwareAccelerated(glXGetFBConfig(display, fbcfg, GLX.GLX_CONFIG_CAVEAT, tmp, 0) != GLX.GLX_SLOW_CONFIG);
@@ -327,7 +328,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
return res;
}
- public static GLCapabilities XVisualInfo2GLCapabilities(long display, XVisualInfo info) {
+ public static GLCapabilities XVisualInfo2GLCapabilities(GLProfile glp, long display, XVisualInfo info) {
int[] tmp = new int[1];
int val = glXGetConfig(display, info, GLX.GLX_USE_GL, tmp, 0);
if (val == 0) {
@@ -337,7 +338,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
if (val == 0) {
throw new GLException("Visual does not support RGBA");
}
- GLCapabilities res = new GLCapabilities();
+ GLCapabilities res = new GLCapabilities(glp);
res.setDoubleBuffered(glXGetConfig(display, info, GLX.GLX_DOUBLEBUFFER, tmp, 0) != 0);
res.setStereo (glXGetConfig(display, info, GLX.GLX_STEREO, tmp, 0) != 0);
// Note: use of hardware acceleration is determined by
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 8def9be0a..48ccaa8da 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -69,6 +69,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
X11GraphicsScreen x11Screen = (X11GraphicsScreen)absScreen;
+ GLProfile glProfile = GLProfile.GetProfileDefault();
GLCapabilities caps=null;
XVisualInfo xvis=null;
long fbcfg = 0;
@@ -83,7 +84,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
try {
long visID = X11Lib.DefaultVisualID(display, x11Screen.getIndex());
xvis = X11GLXGraphicsConfiguration.XVisualID2XVisualInfo(display, visID);
- caps = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(display, xvis);
+ caps = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, xvis);
int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(caps, true, GLXUtil.isMultisampleAvailable(), usePBuffer, 0, 0);
int[] count = { -1 };
@@ -92,7 +93,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
throw new Exception("Could not fetch FBConfig for "+caps);
}
fbcfg = fbcfgsL.get(0);
- GLCapabilities capFB = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(display, fbcfg);
+ GLCapabilities capFB = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfg);
int[] tmpID = new int[1];
fbid = X11GLXGraphicsConfiguration.glXGetFBConfig(display, fbcfg, GLX.GLX_FBCONFIG_ID, tmpID, 0);
@@ -133,7 +134,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
if (capabilities == null) {
- capabilities = new GLCapabilities();
+ capabilities = new GLCapabilities(null);
}
@@ -174,6 +175,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
int chosen=-1;
int retFBID=-1;
XVisualInfo retXVisualInfo = null;
+ GLProfile glProfile = capabilities.getGLProfile();
// Utilizing FBConfig
//
@@ -189,7 +191,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
recommendedIndex = 0; // 1st match is always recommended ..
caps = new GLCapabilities[fbcfgsL.limit()];
for (int i = 0; i < fbcfgsL.limit(); i++) {
- caps[i] = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(display, fbcfgsL.get(i));
+ caps[i] = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfgsL.get(i));
}
if(null==chooser) {
@@ -239,6 +241,7 @@ 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();
int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, GLXUtil.isMultisampleAvailable(), false, 0, 0);
XVisualInfo[] infos = null;
GLCapabilities[] caps = null;
@@ -266,7 +269,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
caps = new GLCapabilities[infos.length];
for (int i = 0; i < infos.length; i++) {
- caps[i] = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(display, infos[i]);
+ caps[i] = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, infos[i]);
// Attempt to find the visual chosen by glXChooseVisual
if (recommendedVis != null && recommendedVis.visualid() == infos[i].visualid()) {
recommendedIndex = i;
diff --git a/src/jogl/classes/com/sun/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/sun/opengl/util/GLArrayDataClient.java
index 7037da97d..e05a77226 100644
--- a/src/jogl/classes/com/sun/opengl/util/GLArrayDataClient.java
+++ b/src/jogl/classes/com/sun/opengl/util/GLArrayDataClient.java
@@ -37,36 +37,36 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
*
* @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int)
*/
- public static GLArrayDataClient createFixed(int index, String name, int comps, int dataType, boolean normalized,
+ public static GLArrayDataClient createFixed(GL gl, int index, String name, int comps, int dataType, boolean normalized,
int initialSize)
throws GLException
{
- GLProfile.isValidArrayDataType(index, comps, dataType, false, true);
+ gl.getGLProfile().isValidArrayDataType(index, comps, dataType, false, true);
GLArrayDataClient adc = new GLArrayDataClient();
GLArrayHandler glArrayHandler = new GLFixedArrayHandler(adc);
adc.init(name, index, comps, dataType, normalized, 0, null, initialSize, false, glArrayHandler, 0, 0);
return adc;
}
- public static GLArrayDataClient createFixed(int index, String name, int comps, int dataType, boolean normalized,
+ public static GLArrayDataClient createFixed(GL gl, int index, String name, int comps, int dataType, boolean normalized,
int stride, Buffer buffer)
throws GLException
{
- GLProfile.isValidArrayDataType(index, comps, dataType, false, true);
+ gl.getGLProfile().isValidArrayDataType(index, comps, dataType, false, true);
GLArrayDataClient adc = new GLArrayDataClient();
GLArrayHandler glArrayHandler = new GLFixedArrayHandler(adc);
adc.init(name, index, comps, dataType, normalized, stride, buffer, comps*comps, false, glArrayHandler, 0, 0);
return adc;
}
- public static GLArrayDataClient createGLSL(String name, int comps, int dataType, boolean normalized,
+ public static GLArrayDataClient createGLSL(GL gl, String name, int comps, int dataType, boolean normalized,
int initialSize)
throws GLException
{
- if(!GLProfile.hasGLSL()) {
- throw new GLException("GLArrayDataClient.GLSL not supported for profile: "+GLProfile.getProfile());
+ if(!gl.hasGLSL()) {
+ throw new GLException("GLArrayDataClient.GLSL not supported: "+gl);
}
- GLProfile.isValidArrayDataType(-1, comps, dataType, true, true);
+ gl.getGLProfile().isValidArrayDataType(-1, comps, dataType, true, true);
GLArrayDataClient adc = new GLArrayDataClient();
GLArrayHandler glArrayHandler = new GLSLArrayHandler(adc);
@@ -74,14 +74,14 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
return adc;
}
- public static GLArrayDataClient createGLSL(String name, int comps, int dataType, boolean normalized,
+ public static GLArrayDataClient createGLSL(GL gl, String name, int comps, int dataType, boolean normalized,
int stride, Buffer buffer)
throws GLException
{
- if(!GLProfile.hasGLSL()) {
- throw new GLException("GLArrayDataClient.GLSL not supported for profile: "+GLProfile.getProfile());
+ if(!gl.hasGLSL()) {
+ throw new GLException("GLArrayDataClient.GLSL not supported: "+gl);
}
- GLProfile.isValidArrayDataType(-1, comps, dataType, true, true);
+ gl.getGLProfile().isValidArrayDataType(-1, comps, dataType, true, true);
GLArrayDataClient adc = new GLArrayDataClient();
GLArrayHandler glArrayHandler = new GLSLArrayHandler(adc);
diff --git a/src/jogl/classes/com/sun/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/sun/opengl/util/GLArrayDataServer.java
index 5c3fc39f0..e9a5e2754 100644
--- a/src/jogl/classes/com/sun/opengl/util/GLArrayDataServer.java
+++ b/src/jogl/classes/com/sun/opengl/util/GLArrayDataServer.java
@@ -31,15 +31,15 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
*
* @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int)
*/
- public static GLArrayDataServer createFixed(int index, String name, int comps, int dataType, boolean normalized,
+ public static GLArrayDataServer createFixed(GL gl, int index, String name, int comps, int dataType, boolean normalized,
int stride, Buffer buffer, int vboBufferUsage)
throws GLException
{
- GLProfile.isValidArrayDataType(index, comps, dataType, false, true);
+ gl.getGLProfile().isValidArrayDataType(index, comps, dataType, false, true);
GLArrayDataServer ads = new GLArrayDataServer();
GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads);
- ads.init(name, index, comps, dataType, normalized, stride, buffer, buffer.limit(), false, glArrayHandler,
+ ads.init(gl, name, index, comps, dataType, normalized, stride, buffer, buffer.limit(), false, glArrayHandler,
0, 0, vboBufferUsage);
return ads;
}
@@ -55,15 +55,15 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
*
* @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int)
*/
- public static GLArrayDataServer createFixed(int index, String name, int comps, int dataType, boolean normalized,
+ public static GLArrayDataServer createFixed(GL gl, int index, String name, int comps, int dataType, boolean normalized,
int initialSize, int vboBufferUsage)
throws GLException
{
- GLProfile.isValidArrayDataType(index, comps, dataType, false, true);
+ gl.getGLProfile().isValidArrayDataType(index, comps, dataType, false, true);
GLArrayDataServer ads = new GLArrayDataServer();
GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads);
- ads.init(name, index, comps, dataType, normalized, 0, null, initialSize, false, glArrayHandler,
+ ads.init(gl, name, index, comps, dataType, normalized, 0, null, initialSize, false, glArrayHandler,
0, 0, vboBufferUsage);
return ads;
}
@@ -74,18 +74,18 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
*
* @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int)
*/
- public static GLArrayDataServer createGLSL(String name, int comps, int dataType, boolean normalized,
+ public static GLArrayDataServer createGLSL(GL gl, String name, int comps, int dataType, boolean normalized,
int initialSize, int vboBufferUsage)
throws GLException
{
- if(!GLProfile.hasGLSL()) {
- throw new GLException("GLArrayDataServer.GLSL not supported for profile: "+GLProfile.getProfile());
+ if(!gl.hasGLSL()) {
+ throw new GLException("GLArrayDataServer.GLSL not supported: "+gl);
}
- GLProfile.isValidArrayDataType(-1, comps, dataType, true, true);
+ gl.getGLProfile().isValidArrayDataType(-1, comps, dataType, true, true);
GLArrayDataServer ads = new GLArrayDataServer();
GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads);
- ads.init(name, -1, comps, dataType, normalized, 0, null, initialSize, true, glArrayHandler,
+ ads.init(gl, name, -1, comps, dataType, normalized, 0, null, initialSize, true, glArrayHandler,
0, 0, vboBufferUsage);
return ads;
}
@@ -96,18 +96,18 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
*
* @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int)
*/
- public static GLArrayDataServer createGLSL(String name, int comps, int dataType, boolean normalized,
+ public static GLArrayDataServer createGLSL(GL gl, String name, int comps, int dataType, boolean normalized,
int stride, Buffer buffer, int vboBufferUsage)
throws GLException
{
- if(!GLProfile.hasGLSL()) {
- throw new GLException("GLArrayDataServer.GLSL not supported for profile: "+GLProfile.getProfile());
+ if(!gl.hasGLSL()) {
+ throw new GLException("GLArrayDataServer.GLSL not supported: "+gl);
}
- GLProfile.isValidArrayDataType(-1, comps, dataType, true, true);
+ gl.getGLProfile().isValidArrayDataType(-1, comps, dataType, true, true);
GLArrayDataServer ads = new GLArrayDataServer();
GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads);
- ads.init(name, -1, comps, dataType, normalized, stride, buffer, buffer.limit(), true, glArrayHandler,
+ ads.init(gl, name, -1, comps, dataType, normalized, stride, buffer, buffer.limit(), true, glArrayHandler,
0, 0, vboBufferUsage);
return ads;
}
@@ -172,7 +172,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
// non public matters ..
//
- protected void init(String name, int index, int comps, int dataType, boolean normalized,
+ protected void init(GL gl, String name, int index, int comps, int dataType, boolean normalized,
int stride, Buffer data, int initialSize, boolean isVertexAttribute,
GLArrayHandler glArrayHandler,
int vboName, long bufferOffset, int vboBufferUsage)
@@ -183,7 +183,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
vboUsage=true;
- if( ! (GLProfile.isGL2ES2() && vboBufferUsage==GL2ES2.GL_STREAM_DRAW) ) {
+ if( ! (gl.isGL2ES2() && vboBufferUsage==GL2ES2.GL_STREAM_DRAW) ) {
switch(vboBufferUsage) {
case -1: // nop
case GL.GL_STATIC_DRAW:
diff --git a/src/jogl/classes/com/sun/opengl/util/GLArrayDataWrapper.java b/src/jogl/classes/com/sun/opengl/util/GLArrayDataWrapper.java
index 04009595e..72e7c19bb 100644
--- a/src/jogl/classes/com/sun/opengl/util/GLArrayDataWrapper.java
+++ b/src/jogl/classes/com/sun/opengl/util/GLArrayDataWrapper.java
@@ -9,27 +9,27 @@ import java.nio.*;
public class GLArrayDataWrapper implements GLArrayData {
- public static GLArrayDataWrapper createFixed(int index, int comps, int dataType, boolean normalized,
+ public static GLArrayDataWrapper createFixed(GL gl, int index, int comps, int dataType, boolean normalized,
int stride, Buffer buffer,
int vboName, long bufferOffset)
throws GLException
{
- GLProfile.isValidArrayDataType(index, comps, dataType, false, true);
+ gl.getGLProfile().isValidArrayDataType(index, comps, dataType, false, true);
GLArrayDataWrapper adc = new GLArrayDataWrapper();
adc.init(null, index, comps, dataType, normalized, stride, buffer, false,
vboName, bufferOffset);
return adc;
}
- public static GLArrayDataWrapper createGLSL(String name, int comps, int dataType, boolean normalized,
+ public static GLArrayDataWrapper createGLSL(GL gl, String name, int comps, int dataType, boolean normalized,
int stride, Buffer buffer,
int vboName, long bufferOffset)
throws GLException
{
- if(!GLProfile.hasGLSL()) {
- throw new GLException("GLArrayDataWrapper.GLSL not supported for profile: "+GLProfile.getProfile());
+ if(!gl.hasGLSL()) {
+ throw new GLException("GLArrayDataWrapper.GLSL not supported: "+gl);
}
- GLProfile.isValidArrayDataType(-1, comps, dataType, true, true);
+ gl.getGLProfile().isValidArrayDataType(-1, comps, dataType, true, true);
GLArrayDataWrapper adc = new GLArrayDataWrapper();
adc.init(name, -1, comps, dataType, normalized, stride, buffer, true,
diff --git a/src/jogl/classes/com/sun/opengl/util/Gamma.java b/src/jogl/classes/com/sun/opengl/util/Gamma.java
index 8be4f4edf..da0d7bd96 100755
--- a/src/jogl/classes/com/sun/opengl/util/Gamma.java
+++ b/src/jogl/classes/com/sun/opengl/util/Gamma.java
@@ -39,6 +39,7 @@
package com.sun.opengl.util;
+import javax.media.opengl.*;
import com.sun.opengl.impl.*;
/** Provides control over the primary display's gamma, brightness and
@@ -86,8 +87,8 @@ public class Gamma {
* @throws IllegalArgumentException if any of the parameters were
* out-of-bounds
*/
- public static boolean setDisplayGamma(float gamma, float brightness, float contrast) throws IllegalArgumentException {
- return GLDrawableFactoryImpl.getFactoryImpl().setDisplayGamma(gamma, brightness, contrast);
+ public static boolean setDisplayGamma(GL gl, float gamma, float brightness, float contrast) throws IllegalArgumentException {
+ return GLDrawableFactoryImpl.getFactoryImpl(gl.getContext().getGLDrawable().getGLProfile()).setDisplayGamma(gamma, brightness, contrast);
}
/**
@@ -100,7 +101,7 @@ public class Gamma {
* exiting, calling it is recommended because of the inevitable
* unspecified behavior during JVM teardown.
*/
- public static void resetDisplayGamma() {
- GLDrawableFactoryImpl.getFactoryImpl().resetDisplayGamma();
+ public static void resetDisplayGamma(GL gl) {
+ GLDrawableFactoryImpl.getFactoryImpl(gl.getContext().getGLDrawable().getGLProfile()).resetDisplayGamma();
}
}
diff --git a/src/jogl/classes/com/sun/opengl/util/ImmModeSink.java b/src/jogl/classes/com/sun/opengl/util/ImmModeSink.java
index ad4e58129..65c676f4a 100644
--- a/src/jogl/classes/com/sun/opengl/util/ImmModeSink.java
+++ b/src/jogl/classes/com/sun/opengl/util/ImmModeSink.java
@@ -20,12 +20,12 @@ public class ImmModeSink {
/**
* Uses a GL2ES1, or ES2 fixed function emulation immediate mode sink
*/
- public static ImmModeSink createFixed(int glBufferUsage, int initialSize,
+ public static ImmModeSink createFixed(GL gl, int glBufferUsage, int initialSize,
int vComps, int vDataType,
int cComps, int cDataType,
int nComps, int nDataType,
int tComps, int tDataType) {
- return new ImmModeSink(glBufferUsage, initialSize,
+ return new ImmModeSink(gl, glBufferUsage, initialSize,
vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, false);
}
@@ -38,12 +38,12 @@ public class ImmModeSink {
* @see javax.media.opengl.glsl.ShaderState#glUseProgram(GL2ES2, boolean)
* @see javax.media.opengl.glsl.ShaderState#getCurrent()
*/
- public static ImmModeSink createGLSL(int glBufferUsage, int initialSize,
+ public static ImmModeSink createGLSL(GL gl, int glBufferUsage, int initialSize,
int vComps, int vDataType,
int cComps, int cDataType,
int nComps, int nDataType,
int tComps, int tDataType) {
- return new ImmModeSink(glBufferUsage, initialSize,
+ return new ImmModeSink(gl, glBufferUsage, initialSize,
vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, true);
}
@@ -253,15 +253,15 @@ public class ImmModeSink {
vboSet.glTexCoord3b(x,y,z);
}
- protected ImmModeSink(int glBufferUsage, int initialSize,
+ protected ImmModeSink(GL gl, int glBufferUsage, int initialSize,
int vComps, int vDataType,
int cComps, int cDataType,
int nComps, int nDataType,
int tComps, int tDataType, boolean useGLSL) {
- if(useGLSL && !GLProfile.hasGLSL()) {
- throw new GLException("ImmModeSink GLSL usage not supported for profile: "+GLProfile.getProfile());
+ if(useGLSL && !gl.hasGLSL()) {
+ throw new GLException("ImmModeSink GLSL usage not supported: "+gl);
}
- vboSet = new VBOSet(glBufferUsage, initialSize,
+ vboSet = new VBOSet(gl, glBufferUsage, initialSize,
vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, useGLSL);
this.vboSetList = new ArrayList();
}
@@ -278,11 +278,12 @@ public class ImmModeSink {
private static boolean vboUsage = true;
protected static class VBOSet {
- protected VBOSet (int glBufferUsage, int initialSize,
+ protected VBOSet (GL gl, int glBufferUsage, int initialSize,
int vComps, int vDataType,
int cComps, int cDataType,
int nComps, int nDataType,
int tComps, int tDataType, boolean useGLSL) {
+ this.gl=gl;
this.glBufferUsage=glBufferUsage;
this.initialSize=initialSize;
this.vDataType=vDataType;
@@ -307,7 +308,7 @@ public class ImmModeSink {
}
protected final VBOSet regenerate() {
- return new VBOSet(glBufferUsage, initialSize,
+ return new VBOSet(gl, glBufferUsage, initialSize,
vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, useGLSL);
}
@@ -805,7 +806,7 @@ public class ImmModeSink {
"]";
}
- // non public matters
+ // non public matters
protected void allocateBuffer(int elements) {
int vWidth = vComps * BufferUtil.sizeOfGLType(vDataType);
@@ -859,25 +860,25 @@ public class ImmModeSink {
buffer.flip();
if(vComps>0) {
- vArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_VERTEX_ARRAY, vComps, vDataType, false,
+ vArrayData = GLArrayDataWrapper.createFixed(gl, GLPointerFunc.GL_VERTEX_ARRAY, vComps, vDataType, false,
0, vertexArray, 0, vOffset);
} else {
vArrayData = null;
}
if(cComps>0) {
- cArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_COLOR_ARRAY, cComps, cDataType, false,
+ cArrayData = GLArrayDataWrapper.createFixed(gl, GLPointerFunc.GL_COLOR_ARRAY, cComps, cDataType, false,
0, colorArray, 0, cOffset);
} else {
cArrayData = null;
}
if(nComps>0) {
- nArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_NORMAL_ARRAY, nComps, nDataType, false,
+ nArrayData = GLArrayDataWrapper.createFixed(gl, GLPointerFunc.GL_NORMAL_ARRAY, nComps, nDataType, false,
0, normalArray, 0, nOffset);
} else {
nArrayData = null;
}
if(tComps>0) {
- tArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_TEXTURE_COORD_ARRAY, tComps, tDataType, false,
+ tArrayData = GLArrayDataWrapper.createFixed(gl, GLPointerFunc.GL_TEXTURE_COORD_ARRAY, tComps, tDataType, false,
0, textCoordArray, 0, tOffset);
} else {
tArrayData = null;
@@ -966,6 +967,7 @@ public class ImmModeSink {
protected boolean sealed, sealedGL, useGLSL;
protected boolean bufferEnabled, bufferWritten;
+ protected GL gl;
}
}
diff --git a/src/jogl/classes/com/sun/opengl/util/awt/TextRenderer.java b/src/jogl/classes/com/sun/opengl/util/awt/TextRenderer.java
index 6e668b84a..059ead63d 100755
--- a/src/jogl/classes/com/sun/opengl/util/awt/TextRenderer.java
+++ b/src/jogl/classes/com/sun/opengl/util/awt/TextRenderer.java
@@ -645,8 +645,10 @@ public class TextRenderer {
private void beginRendering(boolean ortho, int width, int height,
boolean disableDepthTestForOrtho) {
+ GL2 gl = GLContext.getCurrentGL().getGL2();
+
if (DEBUG && !debugged) {
- debug();
+ debug(gl);
}
inBeginEndPair = true;
@@ -662,8 +664,6 @@ public class TextRenderer {
getBackingStore().begin3DRendering();
}
- GL2 gl = GLUgl2.getCurrentGL2();
-
// Push client attrib bits used by the pipelined quad renderer
gl.glPushClientAttrib((int) GL2.GL_ALL_CLIENT_ATTRIB_BITS);
@@ -709,7 +709,7 @@ public class TextRenderer {
inBeginEndPair = false;
- GL2 gl = GLUgl2.getCurrentGL2();
+ GL2 gl = GLContext.getCurrentGL().getGL2();
// Pop client attrib bits used by the pipelined quad renderer
gl.glPopClientAttrib();
@@ -897,12 +897,12 @@ public class TextRenderer {
//----------------------------------------------------------------------
// Debugging functionality
//
- private void debug() {
+ private void debug(GL gl) {
dbgFrame = new Frame("TextRenderer Debug Output");
- GLCanvas dbgCanvas = new GLCanvas(new GLCapabilities(), null,
+ GLCanvas dbgCanvas = new GLCanvas(new GLCapabilities(gl.getGLProfile()), null,
GLContext.getCurrent(), null);
- dbgCanvas.addGLEventListener(new DebugListener(dbgFrame));
+ dbgCanvas.addGLEventListener(new DebugListener(gl, dbgFrame));
dbgFrame.add(dbgCanvas);
final FPSAnimator anim = new FPSAnimator(dbgCanvas, 10);
@@ -1225,7 +1225,7 @@ public class TextRenderer {
// Draw any outstanding glyphs
flush();
- GL2 gl = GLUgl2.getCurrentGL2();
+ GL2 gl = GLContext.getCurrentGL().getGL2();
// Pop client attrib bits used by the pipelined quad renderer
gl.glPopClientAttrib();
@@ -1291,7 +1291,7 @@ public class TextRenderer {
}
// Push client attrib bits used by the pipelined quad renderer
- GL2 gl = GLUgl2.getCurrentGL2();
+ GL2 gl = GLContext.getCurrentGL().getGL2();
gl.glPushClientAttrib((int) GL2.GL_ALL_CLIENT_ATTRIB_BITS);
if (haveCachedColor) {
@@ -1706,7 +1706,7 @@ public class TextRenderer {
int mVBO_For_ResuableTileTexCoords;
Pipelined_QuadRenderer() {
- GL2 gl = GLUgl2.getCurrentGL2();
+ GL2 gl = GLContext.getCurrentGL().getGL2();
mVertCoords = BufferUtil.newFloatBuffer(kTotalBufferSizeCoordsVerts);
mTexCoords = BufferUtil.newFloatBuffer(kTotalBufferSizeCoordsTex);
@@ -1763,7 +1763,7 @@ public class TextRenderer {
private void drawVertexArrays() {
if (mOutstandingGlyphsVerticesPipeline > 0) {
- GL2 gl = GLUgl2.getCurrentGL2();
+ GL2 gl = GLContext.getCurrentGL().getGL2();
TextureRenderer renderer = getBackingStore();
Texture texture = renderer.getTexture(); // triggers texture uploads. Maybe this should be more obvious?
@@ -1811,7 +1811,7 @@ public class TextRenderer {
TextureRenderer renderer = getBackingStore();
Texture texture = renderer.getTexture(); // triggers texture uploads. Maybe this should be more obvious?
- GL2 gl = GLUgl2.getCurrentGL2();
+ GL2 gl = GLContext.getCurrentGL().getGL2();
gl.glBegin(GL2.GL_QUADS);
try {
@@ -1849,15 +1849,16 @@ public class TextRenderer {
}
class DebugListener implements GLEventListener {
- private GLU glu = GLU.createGLU();
+ private GLU glu;
private Frame frame;
- DebugListener(Frame frame) {
+ DebugListener(GL gl, Frame frame) {
+ this.glu = GLU.createGLU(gl);
this.frame = frame;
}
public void display(GLAutoDrawable drawable) {
- GL2 gl = GLUgl2.getCurrentGL2();
+ GL2 gl = GLContext.getCurrentGL().getGL2();
gl.glClear(GL2.GL_DEPTH_BUFFER_BIT | GL2.GL_COLOR_BUFFER_BIT);
if (packer == null) {
diff --git a/src/jogl/classes/com/sun/opengl/util/awt/TextureRenderer.java b/src/jogl/classes/com/sun/opengl/util/awt/TextureRenderer.java
index 9650d759a..1f6393d39 100755
--- a/src/jogl/classes/com/sun/opengl/util/awt/TextureRenderer.java
+++ b/src/jogl/classes/com/sun/opengl/util/awt/TextureRenderer.java
@@ -401,7 +401,7 @@ public class TextureRenderer {
@throws GLException If an OpenGL context is not current when this method is called
*/
public void setColor(float r, float g, float b, float a) throws GLException {
- GL2 gl = GLUgl2.getCurrentGL2();
+ GL2 gl = GLContext.getCurrentGL().getGL2();
this.r = r * a;
this.g = g * a;
this.b = b * a;
@@ -498,7 +498,7 @@ public class TextureRenderer {
int texturex, int texturey,
int width, int height,
float scaleFactor) throws GLException {
- GL2 gl = GLUgl2.getCurrentGL2();
+ GL2 gl = GLContext.getCurrentGL().getGL2();
Texture texture = getTexture();
TextureCoords coords = texture.getSubImageTexCoords(texturex, texturey,
texturex + width,
@@ -552,7 +552,7 @@ public class TextureRenderer {
//
private void beginRendering(boolean ortho, int width, int height, boolean disableDepthTestForOrtho) {
- GL2 gl = GLUgl2.getCurrentGL2();
+ GL2 gl = GLContext.getCurrentGL().getGL2();
int attribBits =
GL2.GL_ENABLE_BIT | GL2.GL_TEXTURE_BIT | GL2.GL_COLOR_BUFFER_BIT |
(ortho ? (GL2.GL_DEPTH_BUFFER_BIT | GL2.GL_TRANSFORM_BIT) : 0);
@@ -599,7 +599,7 @@ public class TextureRenderer {
}
private void endRendering(boolean ortho) {
- GL2 gl = GLUgl2.getCurrentGL2();
+ GL2 gl = GLContext.getCurrentGL().getGL2();
Texture texture = getTexture();
texture.disable();
if (ortho) {
@@ -614,6 +614,7 @@ public class TextureRenderer {
}
private void init(int width, int height) {
+ GL2 gl = GLContext.getCurrentGL().getGL2();
// Discard previous BufferedImage if any
if (image != null) {
image.flush();
diff --git a/src/jogl/classes/com/sun/opengl/util/glsl/fixedfunc/impl/FixedFuncHook.java b/src/jogl/classes/com/sun/opengl/util/glsl/fixedfunc/impl/FixedFuncHook.java
index b08f5893a..6f44f10b7 100755
--- a/src/jogl/classes/com/sun/opengl/util/glsl/fixedfunc/impl/FixedFuncHook.java
+++ b/src/jogl/classes/com/sun/opengl/util/glsl/fixedfunc/impl/FixedFuncHook.java
@@ -214,14 +214,14 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
}
public void glVertexPointer(int size, int type, int stride, java.nio.Buffer pointer) {
- glVertexPointer(GLArrayDataWrapper.createFixed(GL_VERTEX_ARRAY, size, type, false, stride, pointer, 0, 0));
+ glVertexPointer(GLArrayDataWrapper.createFixed(gl, GL_VERTEX_ARRAY, size, type, false, stride, pointer, 0, 0));
}
public void glVertexPointer(int size, int type, int stride, long pointer_buffer_offset) {
int vboName = gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER);
if(vboName==0) {
throw new GLException("no GL_ARRAY_BUFFER VBO bound");
}
- glVertexPointer(GLArrayDataWrapper.createFixed(GL_VERTEX_ARRAY, size, type, false,
+ glVertexPointer(GLArrayDataWrapper.createFixed(gl, GL_VERTEX_ARRAY, size, type, false,
stride, null, vboName, pointer_buffer_offset));
}
@@ -241,7 +241,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
fixedFunction.glColorPointer(gl, array);
}
public void glColorPointer(int size, int type, int stride, java.nio.Buffer pointer) {
- glColorPointer(GLArrayDataWrapper.createFixed(GL_COLOR_ARRAY, size, type, false,
+ glColorPointer(GLArrayDataWrapper.createFixed(gl, GL_COLOR_ARRAY, size, type, false,
stride, pointer, 0, 0));
}
public void glColorPointer(int size, int type, int stride, long pointer_buffer_offset) {
@@ -249,7 +249,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
if(vboName==0) {
throw new GLException("no GL_ARRAY_BUFFER VBO bound");
}
- glColorPointer(GLArrayDataWrapper.createFixed(GL_COLOR_ARRAY, size, type, false,
+ glColorPointer(GLArrayDataWrapper.createFixed(gl, GL_COLOR_ARRAY, size, type, false,
stride, null, vboName, pointer_buffer_offset));
}
@@ -272,7 +272,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
fixedFunction.glNormalPointer(gl, array);
}
public void glNormalPointer(int type, int stride, java.nio.Buffer pointer) {
- glNormalPointer(GLArrayDataWrapper.createFixed(GL_NORMAL_ARRAY, 3, type, false,
+ glNormalPointer(GLArrayDataWrapper.createFixed(gl, GL_NORMAL_ARRAY, 3, type, false,
stride, pointer, 0, 0));
}
public void glNormalPointer(int type, int stride, long pointer_buffer_offset) {
@@ -280,7 +280,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
if(vboName==0) {
throw new GLException("no GL_ARRAY_BUFFER VBO bound");
}
- glNormalPointer(GLArrayDataWrapper.createFixed(GL_NORMAL_ARRAY, 3, type, false,
+ glNormalPointer(GLArrayDataWrapper.createFixed(gl, GL_NORMAL_ARRAY, 3, type, false,
stride, null, vboName, pointer_buffer_offset));
}
@@ -301,7 +301,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
}
public void glTexCoordPointer(int size, int type, int stride, java.nio.Buffer pointer) {
glTexCoordPointer(
- GLArrayDataWrapper.createFixed(GL_TEXTURE_COORD_ARRAY, size, type, false, stride, pointer, 0,0));
+ GLArrayDataWrapper.createFixed(gl, GL_TEXTURE_COORD_ARRAY, size, type, false, stride, pointer, 0,0));
}
public void glTexCoordPointer(int size, int type, int stride, long pointer_buffer_offset) {
int vboName = gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER);
@@ -309,7 +309,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
throw new GLException("no GL_ARRAY_BUFFER VBO bound");
}
glTexCoordPointer(
- GLArrayDataWrapper.createFixed(GL_TEXTURE_COORD_ARRAY, size, type, false,
+ GLArrayDataWrapper.createFixed(gl, GL_TEXTURE_COORD_ARRAY, size, type, false,
stride, null, vboName, pointer_buffer_offset) );
}
diff --git a/src/jogl/classes/com/sun/opengl/util/texture/Texture.java b/src/jogl/classes/com/sun/opengl/util/texture/Texture.java
index 1cb8545c7..776045f41 100755
--- a/src/jogl/classes/com/sun/opengl/util/texture/Texture.java
+++ b/src/jogl/classes/com/sun/opengl/util/texture/Texture.java
@@ -175,7 +175,7 @@ public class Texture {
private static final boolean disableTexRect = Debug.isPropertyDefined("jogl.texture.notexrect");
public Texture(TextureData data) throws GLException {
- GL gl = GLU.getCurrentGL();
+ GL gl = GLContext.getCurrentGL();
texID = createTextureID(gl);
updateImage(data);
@@ -184,7 +184,7 @@ public class Texture {
// Constructor for use when creating e.g. cube maps, where there is
// no initial texture data
public Texture(int target) throws GLException {
- GL gl = GLU.getCurrentGL();
+ GL gl = GLContext.getCurrentGL();
texID = createTextureID(gl);
this.target = target;
}
@@ -221,7 +221,7 @@ public class Texture {
* OpenGL-related errors occurred
*/
public void enable() throws GLException {
- GLU.getCurrentGL().glEnable(target);
+ GLContext.getCurrentGL().glEnable(target);
}
/**
@@ -239,7 +239,7 @@ public class Texture {
* OpenGL-related errors occurred
*/
public void disable() throws GLException {
- GLU.getCurrentGL().glDisable(target);
+ GLContext.getCurrentGL().glDisable(target);
}
/**
@@ -256,7 +256,7 @@ public class Texture {
* OpenGL-related errors occurred
*/
public void bind() throws GLException {
- GLU.getCurrentGL().glBindTexture(target, texID);
+ GLContext.getCurrentGL().glBindTexture(target, texID);
}
/**
@@ -267,7 +267,7 @@ public class Texture {
* @deprecated use destroy(GL)
*/
public void dispose() throws GLException {
- destroy(GLU.getCurrentGL());
+ destroy(GLContext.getCurrentGL());
}
/**
@@ -438,7 +438,7 @@ public class Texture {
* OpenGL-related errors occurred
*/
public void updateImage(TextureData data, int target) throws GLException {
- GL gl = GLU.getCurrentGL();
+ GL gl = GLContext.getCurrentGL();
imgWidth = data.getWidth();
imgHeight = data.getHeight();
@@ -580,7 +580,7 @@ public class Texture {
try {
// FIXME: may need check for GLUnsupportedException
- GLU glu = GLU.createGLU();
+ GLU glu = GLU.createGLU(gl);
glu.gluBuild2DMipmaps(texTarget, data.getInternalFormat(),
data.getWidth(), data.getHeight(),
data.getPixelFormat(), data.getPixelType(), data.getBuffer());
@@ -763,7 +763,7 @@ public class Texture {
public void setTexParameterf(int parameterName,
float value) {
bind();
- GL gl = GLU.getCurrentGL();
+ GL gl = GLContext.getCurrentGL();
gl.glTexParameterf(target, parameterName, value);
}
@@ -778,7 +778,7 @@ public class Texture {
public void setTexParameterfv(int parameterName,
FloatBuffer params) {
bind();
- GL gl = GLU.getCurrentGL();
+ GL gl = GLContext.getCurrentGL();
gl.glTexParameterfv(target, parameterName, params);
}
@@ -793,7 +793,7 @@ public class Texture {
public void setTexParameterfv(int parameterName,
float[] params, int params_offset) {
bind();
- GL gl = GLU.getCurrentGL();
+ GL gl = GLContext.getCurrentGL();
gl.glTexParameterfv(target, parameterName, params, params_offset);
}
@@ -811,7 +811,7 @@ public class Texture {
public void setTexParameteri(int parameterName,
int value) {
bind();
- GL gl = GLU.getCurrentGL();
+ GL gl = GLContext.getCurrentGL();
gl.glTexParameteri(target, parameterName, value);
}
@@ -826,7 +826,7 @@ public class Texture {
public void setTexParameteriv(int parameterName,
IntBuffer params) {
bind();
- GL gl = GLU.getCurrentGL();
+ GL gl = GLContext.getCurrentGL();
gl.glTexParameteriv(target, parameterName, params);
}
@@ -841,7 +841,7 @@ public class Texture {
public void setTexParameteriv(int parameterName,
int[] params, int params_offset) {
bind();
- GL gl = GLU.getCurrentGL();
+ GL gl = GLContext.getCurrentGL();
gl.glTexParameteriv(target, parameterName, params, params_offset);
}
@@ -933,7 +933,7 @@ public class Texture {
private void updateSubImageImpl(TextureData data, int newTarget, int mipmapLevel,
int dstx, int dsty,
int srcx, int srcy, int width, int height) throws GLException {
- GL gl = GLU.getCurrentGL();
+ GL gl = GLContext.getCurrentGL();
data.setHaveEXTABGR(gl.isExtensionAvailable("GL_EXT_abgr"));
data.setHaveGL12(gl.isExtensionAvailable("GL_VERSION_1_2"));
@@ -1047,7 +1047,7 @@ public class Texture {
}
private void checkCompressedTextureExtensions(TextureData data) {
- GL gl = GLU.getCurrentGL();
+ GL gl = GLContext.getCurrentGL();
if (data.isDataCompressed()) {
switch (data.getInternalFormat()) {
case GL.GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
diff --git a/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javame_cdc_fp b/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javame_cdc_fp
index 7ea88a9ca..1f6b89c7e 100755
--- a/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javame_cdc_fp
+++ b/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javame_cdc_fp
@@ -560,7 +560,7 @@ public class TextureIO {
}
// First fetch the texture data
- GL _gl = GLU.getCurrentGL();
+ GL _gl = GLContext.getCurrentGL();
if (!_gl.isGL2()) {
throw new GLException("Only GL2 supports fetching compressed images, GL: " + _gl);
}
@@ -1044,7 +1044,8 @@ public class TextureIO {
pixelFormat = image.getGLFormat();
}
if (internalFormat == 0) {
- if(GLProfile.isGL2()) {
+ GL gl = GLContext.getCurrentGL();
+ if(gl.isGL2()) {
internalFormat = GL.GL_RGBA8;
} else {
internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA:GL.GL_RGB;
@@ -1210,7 +1211,7 @@ public class TextureIO {
private static int glGetInteger(int pname) {
int[] tmp = new int[1];
- GL gl = GLU.getCurrentGL();
+ GL gl = GLContext.getCurrentGL();
gl.glGetIntegerv(pname, tmp, 0);
return tmp[0];
}
diff --git a/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javase b/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javase
index 29912db24..2b2f123a0 100755
--- a/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javase
+++ b/src/jogl/classes/com/sun/opengl/util/texture/TextureIO.java.javase
@@ -560,7 +560,7 @@ public class TextureIO {
}
// First fetch the texture data
- GL _gl = GLU.getCurrentGL();
+ GL _gl = GLContext.getCurrentGL();
if (!_gl.isGL2()) {
throw new GLException("Only GL2 supports fetching compressed images, GL: " + _gl);
}
@@ -1046,7 +1046,8 @@ public class TextureIO {
pixelFormat = image.getGLFormat();
}
if (internalFormat == 0) {
- if(GLProfile.isGL2()) {
+ GL gl = GLContext.getCurrentGL();
+ if(gl.isGL2()) {
internalFormat = GL.GL_RGBA8;
} else {
internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA:GL.GL_RGB;
@@ -1212,7 +1213,7 @@ public class TextureIO {
private static int glGetInteger(int pname) {
int[] tmp = new int[1];
- GL gl = GLU.getCurrentGL();
+ GL gl = GLContext.getCurrentGL();
gl.glGetIntegerv(pname, tmp, 0);
return tmp[0];
}
diff --git a/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureData.java b/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureData.java
index 7e275cf3d..b3cf537f6 100755
--- a/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureData.java
+++ b/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureData.java
@@ -170,7 +170,9 @@ public class AWTTextureData extends TextureData {
return;
}
- if (GLProfile.isGL2()) {
+ GLProfile glp = GLContext.getCurrentGL().getGLProfile();
+
+ if (glp.isGL2()) {
switch (image.getType()) {
case BufferedImage.TYPE_INT_RGB:
pixelFormat = GL2.GL_BGRA;
diff --git a/src/jogl/classes/com/sun/opengl/util/texture/spi/TGAImage.java.javame_cdc_fp b/src/jogl/classes/com/sun/opengl/util/texture/spi/TGAImage.java.javame_cdc_fp
index e85e71687..c54713a5e 100755
--- a/src/jogl/classes/com/sun/opengl/util/texture/spi/TGAImage.java.javame_cdc_fp
+++ b/src/jogl/classes/com/sun/opengl/util/texture/spi/TGAImage.java.javame_cdc_fp
@@ -305,9 +305,10 @@ public class TGAImage {
System.arraycopy(rawBuf, 0, tmpData, y * rawWidth, rawBuf.length);
}
+ GL gl = GLContext.getCurrentGL();
if (header.pixelDepth() == 24) {
bpp=3;
- if(GLProfile.isGL2()) {
+ if(gl.isGL2()) {
format = GL2.GL_BGR;
} else {
format = GL.GL_RGB;
@@ -317,7 +318,7 @@ public class TGAImage {
assert header.pixelDepth() == 32;
bpp=4;
- if(GLProfile.isGL2()) {
+ if(gl.isGL2()) {
format = GL2.GL_BGRA;
} else {
format = GL.GL_RGBA;
diff --git a/src/jogl/classes/com/sun/opengl/util/texture/spi/TGAImage.java.javase b/src/jogl/classes/com/sun/opengl/util/texture/spi/TGAImage.java.javase
index 2df306124..1e78ef20d 100755
--- a/src/jogl/classes/com/sun/opengl/util/texture/spi/TGAImage.java.javase
+++ b/src/jogl/classes/com/sun/opengl/util/texture/spi/TGAImage.java.javase
@@ -307,9 +307,10 @@ public class TGAImage {
System.arraycopy(rawBuf, 0, tmpData, y * rawWidth, rawBuf.length);
}
+ GL gl = GLContext.getCurrentGL();
if (header.pixelDepth() == 24) {
bpp=3;
- if(GLProfile.isGL2()) {
+ if(gl.isGL2()) {
format = GL2.GL_BGR;
} else {
format = GL.GL_RGB;
@@ -319,7 +320,7 @@ public class TGAImage {
assert header.pixelDepth() == 32;
bpp=4;
- if(GLProfile.isGL2()) {
+ if(gl.isGL2()) {
format = GL2.GL_BGRA;
} else {
format = GL.GL_RGBA;
diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java
index dcbd3e4cf..efd2eedd1 100644
--- a/src/jogl/classes/javax/media/opengl/GLBase.java
+++ b/src/jogl/classes/javax/media/opengl/GLBase.java
@@ -63,6 +63,9 @@ public interface GLBase {
*/
public boolean isGL2ES2();
+ /** Indicates whether this GL object supports GLSL. */
+ public boolean hasGLSL();
+
/**
* Casts this object to the GL interface.
* @return this object cast to the GL interface
@@ -117,4 +120,10 @@ public interface GLBase {
* @return the GLContext with which this GL object is associated
*/
public GLContext getContext();
+
+ /**
+ * Returns the GLProfile with which this GL object is associated.
+ * @return the GLProfile with which this GL object is associated
+ */
+ public GLProfile getGLProfile();
}
diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilities.java b/src/jogl/classes/javax/media/opengl/GLCapabilities.java
index 0a73856c0..bc49bbde1 100644
--- a/src/jogl/classes/javax/media/opengl/GLCapabilities.java
+++ b/src/jogl/classes/javax/media/opengl/GLCapabilities.java
@@ -47,6 +47,7 @@ import javax.media.nativewindow.Capabilities;
configuration on all supported window systems. */
public class GLCapabilities extends Capabilities implements Cloneable {
+ private GLProfile glProfile = null;
private boolean doubleBuffered = true;
private boolean stereo = false;
private boolean hardwareAccelerated = true;
@@ -72,10 +73,18 @@ public class GLCapabilities extends Capabilities implements Cloneable {
private boolean pbufferRenderToTexture;
private boolean pbufferRenderToTextureRectangle;
- /** Creates a GLCapabilities object. All attributes are in a default
- state.
+ /** Creates a GLCapabilities object. All attributes are in a default state.
+ * @param glp GLProfile, or null for the default GLProfile
*/
- public GLCapabilities() {}
+ public GLCapabilities(GLProfile glp) {
+ glProfile = (null!=glp)?glp:GLProfile.GetProfileDefault();
+ if(glProfile.usesNativeGLES()) {
+ setRedBits(5);
+ setGreenBits(6);
+ setBlueBits(5);
+ setDepthBits(16);
+ }
+ }
public Object clone() {
try {
@@ -85,6 +94,16 @@ public class GLCapabilities extends Capabilities implements Cloneable {
}
}
+ /** Returns the GL profile you desire or used by the drawable. */
+ public GLProfile getGLProfile() {
+ return glProfile;
+ }
+
+ /** Sets the GL profile you desire */
+ public void setGLProfile(GLProfile profile) {
+ glProfile=profile;
+ }
+
/** Indicates whether double-buffering is enabled. */
public boolean getDoubleBuffered() {
return doubleBuffered;
@@ -290,6 +309,7 @@ public class GLCapabilities extends Capabilities implements Cloneable {
public String toString() {
return getClass().toString()+"[" +
super.toString()+
+ ", GL profile: " + glProfile +
", DoubleBuffered: " + doubleBuffered +
", Stereo: " + stereo +
", HardwareAccelerated: " + hardwareAccelerated +
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index c7e5899a7..ce4bc14d1 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -149,8 +149,23 @@ public abstract class GLContext {
public abstract void copy(GLContext source, int mask) throws GLException;
/**
- * Returns the context which is current on the current thread. If no
- * context is current, returns null.
+ * Returns the GL object bound to this thread current context.
+ * If no context is current, throw an GLException
+ *
+ * @return the current context's GL object on this thread
+ * @thows GLException if no context is current
+ */
+ public static GL getCurrentGL() throws GLException {
+ GLContext glc = getCurrent();
+ if(null==glc) {
+ throw new GLException("No OpenGL context current on this thread");
+ }
+ return glc.getGL();
+ }
+
+ /**
+ * Returns this thread current context.
+ * If no context is current, returns null.
*
* @return the context current on this thread, or null if no context
* is current.
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawable.java b/src/jogl/classes/javax/media/opengl/GLDrawable.java
index 746c8e728..f85147a79 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawable.java
@@ -144,16 +144,18 @@ public interface GLDrawable {
public void swapBuffers() throws GLException;
/** Fetches the {@link GLCapabilities} corresponding to the chosen
- OpenGL capabilities (pixel format / visual) for this drawable.
- Some drawables, in particular on-screen drawables, may be
- created lazily; null is returned if the drawable is not
- currently created or if its pixel format has not been set yet.
+ OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.
On some platforms, the pixel format is not directly associated
with the drawable; a best attempt is made to return a reasonable
value in this case.
- Returns a copy of the passed object.
+ Returns a copy of the queried object.
*/
- public GLCapabilities getChosenGLCapabilities();
+ public GLCapabilities getGLCapabilities();
+
+ /** Fetches the {@link GLProfile} for this drawable.
+ Returns the GLProfile object, no copy.
+ */
+ public GLProfile getGLProfile();
public NativeWindow getNativeWindow();
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index e9208f49e..6cfe66dff 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -80,68 +80,140 @@ import com.sun.nativewindow.impl.NWReflection;
*/
public abstract class GLDrawableFactory {
- private static GLDrawableFactory factory;
-
/** Creates a new GLDrawableFactory instance. End users do not need
to call this method. */
protected GLDrawableFactory() {
}
- /** Returns the sole GLDrawableFactory instance. The {@link
- GLProfile GLProfile} must be configured before calling this
- method. */
- public static GLDrawableFactory getFactory() throws GLException {
- if (null == factory) {
- if (null == GLProfile.getProfile()) {
- GLProfile.setProfileGLAny(); // do it now .. last resort
- }
+ private static final GLDrawableFactory eglES1Factory;
+ private static final GLDrawableFactory eglES2Factory;
+ private static final GLDrawableFactory nativeOSFactory;
+ private static final String nativeOSType;
- // See if the user is requesting one of the embedded profiles,
- // and if so, try to instantiate the EGLDrawableFactory
- if ( GLProfile.usesNativeGLES() ) {
- try {
- factory = (GLDrawableFactory) NWReflection.createInstance("com.sun.opengl.impl.egl.EGLDrawableFactory");
- } catch (Exception e) {
- e.printStackTrace();
+ /**
+ * Instantiate singleton factories if available, EGLES1, EGLES2 and the OS native ones.
+ */
+ static {
+ GLDrawableFactory tmp = null;
+ try {
+ tmp = (GLDrawableFactory) NWReflection.createInstance("com.sun.opengl.impl.egl.EGLDrawableFactory", new Object[] { GLProfile.GLES1 });
+ } catch (Throwable t) {
+ if (GLProfile.DEBUG) {
+ System.err.println("GLDrawableFactory.static - EGLDrawableFactory GLES1 - not available");
+ t.printStackTrace();
}
- } else if ( !GLProfile.isGL2ES1() && !GLProfile.isGL2ES2() ) {
- // We require that the user passes in one of the known profiles
- throw new GLException("Unknown or unsupported profile \"" + GLProfile.getProfile() + "\"");
- }
+ }
+ eglES1Factory = tmp;
+
+ tmp = null;
+ try {
+ tmp = (GLDrawableFactory) NWReflection.createInstance("com.sun.opengl.impl.egl.EGLDrawableFactory", new Object[] { GLProfile.GLES2 });
+ } catch (Throwable t) {
+ if (GLProfile.DEBUG) {
+ System.err.println("GLDrawableFactory.static - EGLDrawableFactory GLES2 - not available");
+ t.printStackTrace();
+ }
+ }
+ eglES2Factory = tmp;
- if (null == factory) {
- // Use the desktop OpenGL as the fallback always
- try {
- String factoryClassName =
+ nativeOSType = NativeWindowFactory.getNativeWindowType(false);
+
+ String factoryClassName = null;
+ tmp = null;
+ try {
+ factoryClassName =
(String) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return System.getProperty("opengl.factory.class.name");
}
});
- String osName = System.getProperty("os.name");
- String osNameLowerCase = osName.toLowerCase();
- if (factoryClassName == null) {
- if (osNameLowerCase.startsWith("windows")) {
+ if (null == factoryClassName) {
+ if ( nativeOSType.equals(NativeWindowFactory.TYPE_EGL) ) {
+ // use egl*Factory ..
+ } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_X11) ) {
+ factoryClassName = "com.sun.opengl.impl.x11.glx.X11GLXDrawableFactory";
+ } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_WINDOWS) ) {
factoryClassName = "com.sun.opengl.impl.windows.wgl.WindowsWGLDrawableFactory";
- } else if (osNameLowerCase.startsWith("mac os x") ||
- osNameLowerCase.startsWith("darwin")) {
+ } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_MACOSX) ) {
// FIXME: remove this residual dependence on the AWT
factoryClassName = "com.sun.opengl.impl.macosx.cgl.awt.MacOSXAWTCGLDrawableFactory";
} else {
- // Assume Linux, Solaris, etc. Should probably test for these explicitly.
- factoryClassName = "com.sun.opengl.impl.x11.glx.X11GLXDrawableFactory";
+ throw new GLException("Unsupported NativeWindow type: "+nativeOSType);
}
- }
-
- factory = (GLDrawableFactory) NWReflection.createInstance(factoryClassName);
- } catch (Exception e) {
- throw new GLException(e);
}
+ if (null != factoryClassName) {
+ tmp = (GLDrawableFactory) NWReflection.createInstance(factoryClassName);
+ }
+ } catch (Throwable t) {
+ if (GLProfile.DEBUG) {
+ System.err.println("GLDrawableFactory.static - Native Platform: "+nativeOSType+" - not available: "+factoryClassName);
+ t.printStackTrace();
+ }
+ }
+ nativeOSFactory = tmp;
+ }
+
+ /**
+ * Returns the sole GLDrawableFactory instance.
+ *
+ * @arg nw NativeWindow object to query the ES GLProfile type,
+ * which itself helps to determine the EGL factory type.
+ */
+ public static GLDrawableFactory getFactory(NativeWindow nw) throws GLException {
+ return getFactory(nw.getGraphicsConfiguration().getNativeGraphicsConfiguration());
+ }
+
+ /**
+ * Returns the sole GLDrawableFactory instance.
+ *
+ * @arg agc AbstractGraphicsConfiguration object to query the ES GLProfile type,
+ * which itself helps to determine the EGL factory type.
+ */
+ public static GLDrawableFactory getFactory(AbstractGraphicsConfiguration agc) throws GLException {
+ if(null==agc) {
+ throw new GLException("Null AbstractGraphicsConfiguration");
+ }
+ if( !(agc.getCapabilities() instanceof GLCapabilities) ) {
+ throw new GLException("Unsupported AbstractGraphicsConfiguration for OpenGL: "+agc);
}
+ return getFactory((GLCapabilities)agc.getCapabilities());
+ }
+
+ /**
+ * Returns the sole GLDrawableFactory instance.
+ *
+ * @arg esCaps GLCapabilities object to query the ES GLProfile type,
+ * which itself helps to determine the EGL factory type.
+ */
+ public static GLDrawableFactory getFactory(GLCapabilities esCaps) throws GLException {
+ return getFactory(esCaps.getGLProfile());
+ }
+
+ /**
+ * Returns the sole GLDrawableFactory instance.
+ *
+ * @arg esProfile GLProfile to determine the EGL factory type.
+ */
+ public static GLDrawableFactory getFactory(GLProfile esProfile) throws GLException {
+ return getFactory(esProfile.getImplName());
+ }
+
+ protected static GLDrawableFactory getFactory(String profileImpl) throws GLException {
+ if ( GLProfile.UsesNativeGLES1(profileImpl) ) {
+ if(null==eglES1Factory) throw new GLException("GLDrawableFactory unavailable for EGL/ES1: "+profileImpl);
+ return eglES1Factory;
+ } else if ( GLProfile.UsesNativeGLES2(profileImpl) ) {
+ if(null==eglES2Factory) throw new GLException("GLDrawableFactory unavailable for EGL/ES2: "+profileImpl);
+ return eglES2Factory;
}
- return factory;
+ return getNativeOSFactory();
+ }
+
+ protected static GLDrawableFactory getNativeOSFactory() {
+ if(null==nativeOSFactory) throw new GLException("GLDrawableFactory unavailable for Native Platform "+nativeOSType);
+ return nativeOSFactory;
}
/** Shuts down this GLDrawableFactory, releasing resources
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index bf0f5bbb5..1d92fbb18 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -38,298 +38,262 @@ package javax.media.opengl;
import javax.media.opengl.fixedfunc.*;
import java.lang.reflect.*;
+import java.util.HashMap;
import java.security.*;
import com.sun.opengl.impl.*;
import com.sun.nativewindow.impl.NWReflection;
-public class GLProfile {
+/**
+ * Manages all available OpenGL Profiles.
+ * Each GLProfile is a singleton instance queried at static initialization time.
+ * All returned GLProfile objects are references to such singletons.
+ */
+public class GLProfile implements Cloneable {
public static final boolean DEBUG = Debug.debug("GLProfile");
//
// Public (user-visible) profiles
//
- /** The desktop (OpenGL 3.1) profile */
+ /** The desktop OpenGL >= 3.1 profile */
public static final String GL3 = "GL3";
- /** The desktop (OpenGL 2.0) profile */
+ /** The desktop OpenGL [1.5 .. 3.0] profile */
public static final String GL2 = "GL2";
- /** The OpenGL ES 1 (really, 1.1) profile */
+ /** The embedded OpenGL ES >= 1.0 profile */
public static final String GLES1 = "GLES1";
- /** The OpenGL ES 2 (really, 2.0) profile */
+ /** The embedded OpenGL ES >= 2.0 profile */
public static final String GLES2 = "GLES2";
- /** The intersection of the desktop (OpenGL 2.0) and OpenGL ES 1.x profiles */
+ /** The intersection of the desktop GL2 and embedded ES1 profiles */
public static final String GL2ES1 = "GL2ES1";
- /** The intersection of the desktop (OpenGL 2.0) and OpenGL ES 2.x profiles */
+ /** The intersection of the desktop GL2 and embedded ES2 profiles */
public static final String GL2ES2 = "GL2ES2";
- //
- // Profiles which are implementation details
- //
-
- // The intersection between desktop OpenGL and the union of the OpenGL ES profiles
- // This is here only to avoid having separate GL2ES1Impl and GL2ES2Impl classes
- private static final String GL2ES12 = "GL2ES12";
-
- /** The JVM/process wide chosen GL profile **/
- private static String profile = null;
+ /**
+ * All GL Profiles in the order of default detection.
+ * Order: GL2, GL2ES2, GL2ES1, GL3, GLES2, GLES1
+ */
+ public static final String[] GL_PROFILE_LIST = new String[] { GL2, GL2ES2, GL2ES1, GL3, GLES2, GLES1 };
- /** The "real" profile implementing the chosen profile; for example,
- both GL2ES1 and GL2ES2 currently map to GL2ES12 */
- private static String realProfile = null;
+ /**
+ * All GL2ES2 Profiles in the order of default detection
+ * Order: GL2ES2, GL2, GL3, GLES2
+ */
+ public static final String[] GL2ES2_PROFILE_LIST = new String[] { GL2ES2, GL2, GL3, GLES2 };
- private static final Throwable tryLibrary()
- {
- String clazzName = getGLImplBaseClassName() + "Impl" ;
- try {
- Class clazz = Class.forName(clazzName);
- if(GL3.equals(realProfile) || GL2.equals(realProfile)) {
- // See DRIHack.java for an explanation of why this is necessary
- DRIHack.begin();
- NativeLibLoader.loadGLDesktop();
- DRIHack.end();
- } if(GL2ES12.equals(realProfile)) {
- // See DRIHack.java for an explanation of why this is necessary
- DRIHack.begin();
- NativeLibLoader.loadGL2ES12();
- DRIHack.end();
- } else if(usesNativeGLES()) {
- Object eGLDrawableFactory = NWReflection.createInstance("com.sun.opengl.impl.egl.EGLDrawableFactory");
- if(null==eGLDrawableFactory) {
- throw new GLException("com.sun.opengl.impl.egl.EGLDrawableFactory not available");
- }
- }
- System.out.println("Successfully loaded profile " + profile + " ("+realProfile+"/"+clazzName+")");
- return null;
- } catch (Throwable e) {
- if (DEBUG) {
- System.err.println("GLProfile.tryLibrary: failed: " + profile + " ("+realProfile+"/"+clazzName+")");
- e.printStackTrace();
- }
- profile=null;
- realProfile = null;
- return e;
+ /**
+ * All GL2ES1 Profiles in the order of default detection
+ * Order: GL2ES1, GL2, GLES1
+ */
+ public static final String[] GL2ES1_PROFILE_LIST = new String[] { GL2ES1, GL2, GLES1 };
+
+ /** Returns a default GLProfile object, reflecting the best for the running platform.
+ * It selects the first of the set {@link GLProfile#GL_PROFILE_LIST}
+ */
+ public static final GLProfile GetProfileDefault() {
+ if(null==defaultGLProfile) {
+ throw new GLException("No default profile available"); // should never be reached
}
+ return defaultGLProfile;
}
- private static boolean hasGL2ES12Impl = null!=NWReflection.getClass("com.sun.opengl.impl.gl2es12.GL2ES12Impl");
- private static boolean hasGL2Impl = null!=NWReflection.getClass("com.sun.opengl.impl.gl2.GL2Impl");
-
- private static String computeRealProfile() {
- if (GL2ES1.equals(profile) ||
- GL2ES2.equals(profile)) {
- if(hasGL2Impl) {
- realProfile = GL2;
- return realProfile;
- } else if(hasGL2ES12Impl) {
- realProfile = GL2ES12;
- return realProfile;
- }
+ /** Returns a GLProfile object.
+ * Verfifies the given profile and chooses an apropriate implementation.
+ *
+ * @throws GLException if no implementation for the given profile is found.
+ */
+ public static final GLProfile GetProfile(String profile)
+ throws GLException
+ {
+ if(null==profile) return GetProfileDefault();
+ GLProfile glProfile = (GLProfile) mappedProfiles.get(profile);
+ if(null==glProfile) {
+ throw new GLException("No implementation for profile "+profile+" available");
}
- realProfile = profile;
- return realProfile;
+ return glProfile;
}
- private static final void initStatics() {
- GLDrawableFactory.getFactory();
+ /**
+ * Returns a profile, implementing the interface GL2ES1.
+ * It selects the first of the set: {@link GLProfile#GL2ES1_PROFILE_LIST}
+ *
+ * @throws GLException if no implementation for the given profile is found.
+ */
+ public static final GLProfile GetProfileGL2ES1()
+ throws GLException
+ {
+ return GetProfile(GL2ES1_PROFILE_LIST);
}
- public static synchronized final void setProfile(String profile)
+ /**
+ * Returns a profile, implementing the interface GL2ES2.
+ * It selects the first of the set: {@link GLProfile#GL2ES2_PROFILE_LIST}
+ *
+ * @throws GLException if no implementation for the given profile is found.
+ */
+ public static final GLProfile GetProfileGL2ES2()
throws GLException
{
- if(null==GLProfile.profile) {
- GLProfile.profile = profile;
- String rp = computeRealProfile();
- Throwable t = tryLibrary();
- if (GLProfile.profile == null) {
- throw new GLException("Profile " + profile + " ("+rp+") not available", t);
- }
- initStatics();
- } else {
- if(!GLProfile.profile.equals(profile)) {
- throw new GLException("Requested profile ("+profile+") doesn't match already chosen one: "+GLProfile.profile);
- }
- }
+ return GetProfile(GL2ES2_PROFILE_LIST);
}
- public static synchronized final void setProfile(String[] profiles)
+ /**
+ * Returns the first profile from the given list,
+ * where an implementation is available.
+ *
+ * @throws GLException if no implementation for the given profile is found.
+ */
+ public static final GLProfile GetProfile(String[] profiles)
throws GLException
{
- Throwable t = null;
- for(int i=0; profile==null && i<profiles.length; i++) {
- profile = profiles[i];
- computeRealProfile();
- if (t == null) {
- t = tryLibrary();
- } else {
- tryLibrary();
+ for(int i=0; i<profiles.length; i++) {
+ String profile = profiles[i];
+ GLProfile glProfile = (GLProfile) mappedProfiles.get(profile);
+ if(null!=glProfile) {
+ return glProfile;
}
}
- if(null==profile) {
- StringBuffer msg = new StringBuffer();
- msg.append("[");
- for (int i = 0; i < profiles.length; i++) {
- if (i > 0)
- msg.append(", ");
- msg.append(profiles[i]);
- }
- msg.append("]");
- throw new GLException("Profiles "+msg.toString()+" not available", t);
- }
- initStatics();
+ throw new GLException("Profiles "+list2String(profiles)+" not available");
}
- /**
- * Selects a profile, implementing the interface GL2ES1.
- * Order: GL2ES1, GL2, GLES1
+ /** Indicates whether the native OpenGL ES1 profile is in use.
+ * This requires an EGL interface.
*/
- public static synchronized final void setProfileGL2ES1() {
- setProfile(new String[] { GL2ES1, GL2, GLES1 });
+ public static final boolean UsesNativeGLES1(String profileImpl) {
+ return GLES1.equals(profileImpl) || GL2ES1.equals(profileImpl) ;
}
- /**
- * Selects a profile, implementing the interface GL2ES2.
- * Order: GL2ES2, GL2, GL3, GLES2
+ /** Indicates whether the native OpenGL ES2 profile is in use.
+ * This requires an EGL interface.
*/
- public static synchronized final void setProfileGL2ES2() {
- setProfile(new String[] { GL2ES2, GL2, /*GL3,*/ GLES2 });
+ public static final boolean UsesNativeGLES2(String profileImpl) {
+ return GLES2.equals(profileImpl) || GL2ES2.equals(profileImpl) ;
+ }
+
+ /** Indicates whether either of the native OpenGL ES profiles are in use. */
+ public static final boolean UsesNativeGLES(String profileImpl) {
+ return UsesNativeGLES2(profileImpl) || UsesNativeGLES1(profileImpl);
+ }
+
+ public static final String GetGLImplBaseClassName(String profileImpl) {
+ if(GL3.equals(profileImpl)) {
+ return "com.sun.opengl.impl.gl3.GL3";
+ } else if(GL2.equals(profileImpl)) {
+ return "com.sun.opengl.impl.gl2.GL2";
+ } else if(GL2ES12.equals(profileImpl)) {
+ return "com.sun.opengl.impl.gl2es12.GL2ES12";
+ } else if(GLES1.equals(profileImpl) || GL2ES1.equals(profileImpl)) {
+ return "com.sun.opengl.impl.es1.GLES1";
+ } else if(GLES2.equals(profileImpl) || GL2ES2.equals(profileImpl)) {
+ return "com.sun.opengl.impl.es2.GLES2";
+ } else {
+ throw new GLException("unsupported profile \"" + profileImpl + "\"");
+ }
+ }
+
+ public final String getGLImplBaseClassName() {
+ return GetGLImplBaseClassName(profileImpl);
+ }
+
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (Exception e) {
+ throw new GLException(e);
+ }
}
/**
- * Selects a profile, implementing the interface GL
- * Order: GL2, GL2ES2, GL2ES1, GL3, GLES2, GLES1
+ * @param o GLProfile object to compare with
+ * @return true if given Object is a GLProfile and
+ * if both, profile and profileImpl is equal with this.
+ */
+ public final boolean equals(Object o) {
+ if(o instanceof GLProfile) {
+ GLProfile glp = (GLProfile)o;
+ return profile.equals(glp.getName()) &&
+ profileImpl.equals(glp.getImplName()) ;
+ }
+ return false;
+ }
+
+ /**
+ * @param glp GLProfile to compare with
+ * @throws GLException if given GLProfile and this aren't equal
*/
- public static synchronized final void setProfileGLAny() {
- setProfile(new String[] { GL2, GL2ES2, GL2ES1, /*GL3,*/ GLES2, GLES1 });
+ public final void verifyEquality(GLProfile glp)
+ throws GLException
+ {
+ if(!this.equals(glp)) throw new GLException("GLProfiles are not equal: "+this+" != "+glp);
}
- public static final String getProfile() {
+ public final String getName() {
return profile;
}
-
- public static final boolean isGL3() {
+
+ public final String getImplName() {
+ return profileImpl;
+ }
+
+ /** Indicates whether this profile is capable os GL3. */
+ public final boolean isGL3() {
return GL3.equals(profile);
}
- public static final boolean isGL2() {
+ /** Indicates whether this profile is capable os GL2. */
+ public final boolean isGL2() {
return GL2.equals(profile);
}
- public static final boolean isGLES1() {
+ /** Indicates whether this profile is capable os GLES1. */
+ public final boolean isGLES1() {
return GLES1.equals(profile);
}
- public static final boolean isGLES2() {
+ /** Indicates whether this profile is capable os GLES2. */
+ public final boolean isGLES2() {
return GLES2.equals(profile);
}
- /* Indicates whether a GL2ES1 capable profile is in use, ie GL2ES1, GL2, GLES1 */
- public static final boolean isGL2ES1() {
+ /** Indicates whether this profile is capable os GL2ES1. */
+ public final boolean isGL2ES1() {
return GL2ES1.equals(profile) || isGL2() || isGLES1() ;
}
- /* Indicates whether a GL2ES2 capable profile is in use, ie GL2ES2, GL2, GLES2 */
- public static final boolean isGL2ES2() {
+ /** Indicates whether this profile is capable os GL2ES2. */
+ public final boolean isGL2ES2() {
return GL2ES2.equals(profile) || isGL2() || isGL3() || isGLES2() ;
}
- /** Indicates whether the native OpenGL ES1 profile is in use.
- * This requires an EGL interface.
- */
- public static final boolean usesNativeGLES1() {
- return GLES1.equals(realProfile) || GL2ES1.equals(realProfile) ;
+ /** Indicates whether this profile uses the native OpenGL ES1 implementations. */
+ public final boolean usesNativeGLES1() {
+ return GLES1.equals(profileImpl) || GL2ES1.equals(profileImpl) ;
}
- /** Indicates whether the native OpenGL ES2 profile is in use.
- * This requires an EGL interface.
- */
- public static final boolean usesNativeGLES2() {
- return GLES2.equals(realProfile) || GL2ES2.equals(realProfile) ;
+ /** Indicates whether this profile uses the native OpenGL ES2 implementations. */
+ public final boolean usesNativeGLES2() {
+ return GLES2.equals(profileImpl) || GL2ES2.equals(profileImpl) ;
}
- /** Indicates whether either of the native OpenGL ES profiles are in use. */
- public static final boolean usesNativeGLES() {
+ /** Indicates whether this profile uses either of the native OpenGL ES implementations. */
+ public final boolean usesNativeGLES() {
return usesNativeGLES2() || usesNativeGLES1();
}
- /** Indicates whether a GLSL capable profiles is in use. */
- public static final boolean hasGLSL() {
+ /** Indicates whether this profile supports GLSL. */
+ public final boolean hasGLSL() {
return isGL2ES2() ;
}
- public static final boolean matches(String test_profile) {
- return (null==test_profile)?false:test_profile.equals(profile);
- }
-
- public static final String getGLImplBaseClassName() {
- if(GL3.equals(realProfile)) {
- return "com.sun.opengl.impl.gl3.GL3";
- } else if(GL2.equals(realProfile)) {
- return "com.sun.opengl.impl.gl2.GL2";
- } else if(GL2ES12.equals(realProfile)) {
- return "com.sun.opengl.impl.gl2es12.GL2ES12";
- } else if(GLES1.equals(realProfile) || GL2ES1.equals(realProfile)) {
- return "com.sun.opengl.impl.es1.GLES1";
- } else if(GLES2.equals(realProfile) || GL2ES2.equals(realProfile)) {
- return "com.sun.opengl.impl.es2.GLES2";
- } else {
- throw new GLException("unsupported profile \"" + profile + "\"");
- }
- }
-
- private static String getGLTypeName(int type) {
- switch (type) {
- case GL.GL_UNSIGNED_BYTE:
- return "GL_UNSIGNED_BYTE";
- case GL.GL_BYTE:
- return "GL_BYTE";
- case GL.GL_UNSIGNED_SHORT:
- return "GL_UNSIGNED_SHORT";
- case GL.GL_SHORT:
- return "GL_SHORT";
- case GL.GL_FLOAT:
- return "GL_FLOAT";
- case GL.GL_FIXED:
- return "GL_FIXED";
- case javax.media.opengl.GL2ES2.GL_INT:
- return "GL_INT";
- case javax.media.opengl.GL2ES2.GL_UNSIGNED_INT:
- return "GL_UNSIGNED_INT";
- case javax.media.opengl.GL2.GL_DOUBLE:
- return "GL_DOUBLE";
- case javax.media.opengl.GL2.GL_2_BYTES:
- return "GL_2_BYTES";
- case javax.media.opengl.GL2.GL_3_BYTES:
- return "GL_3_BYTES";
- case javax.media.opengl.GL2.GL_4_BYTES:
- return "GL_4_BYTES";
- }
- return null;
- }
-
- private static String getGLArrayName(int array) {
- switch(array) {
- case GLPointerFunc.GL_VERTEX_ARRAY:
- return "GL_VERTEX_ARRAY";
- case GLPointerFunc.GL_NORMAL_ARRAY:
- return "GL_NORMAL_ARRAY";
- case GLPointerFunc.GL_COLOR_ARRAY:
- return "GL_COLOR_ARRAY";
- case GLPointerFunc.GL_TEXTURE_COORD_ARRAY:
- return "GL_TEXTURE_COORD_ARRAY";
- }
- return null;
- }
-
/**
* General validation if type is a valid GL data type
* for the current profile
*/
- public static boolean isValidDataType(int type, boolean throwException) {
+ public boolean isValidDataType(int type, boolean throwException) {
switch(type) {
case GL.GL_UNSIGNED_BYTE:
case GL.GL_BYTE:
@@ -355,15 +319,15 @@ public class GLProfile {
}
}
if(throwException) {
- throw new GLException("Illegal data type on profile "+GLProfile.getProfile()+": "+type);
+ throw new GLException("Illegal data type on profile "+this+": "+type);
}
return false;
}
- public static boolean isValidArrayDataType(int index, int comps, int type,
- boolean isVertexAttribPointer, boolean throwException) {
- String arrayName = getGLArrayName(index);
- if(GLProfile.isGLES1()) {
+ public boolean isValidArrayDataType(int index, int comps, int type,
+ boolean isVertexAttribPointer, boolean throwException) {
+ String arrayName = GetGLArrayName(index);
+ if(isGLES1()) {
if(isVertexAttribPointer) {
if(throwException) {
throw new GLException("Illegal array type for "+arrayName+" on profile GLES1: VertexAttribPointer");
@@ -446,7 +410,7 @@ public class GLProfile {
}
break;
}
- } else if(GLProfile.isGLES2()) {
+ } else if(isGLES2()) {
// simply ignore !isVertexAttribPointer case, since it is simulated anyway ..
switch(type) {
@@ -476,7 +440,7 @@ public class GLProfile {
}
return false;
}
- } else if( GLProfile.isGL2ES2() ) {
+ } else if( isGL2ES2() ) {
if(isVertexAttribPointer) {
switch(type) {
case GL.GL_UNSIGNED_BYTE:
@@ -621,4 +585,239 @@ public class GLProfile {
}
return true;
}
+
+ public String toString() {
+ return "GLProfile[" + profile + "/" + profileImpl + "]";
+ }
+
+ // The intersection between desktop OpenGL and the union of the OpenGL ES profiles
+ // This is here only to avoid having separate GL2ES1Impl and GL2ES2Impl classes
+ private static final String GL2ES12 = "GL2ES12";
+
+ private static final boolean hasGL3Impl;
+ private static final boolean hasGL2Impl;
+ private static final boolean hasGL2ES12Impl;
+ private static final boolean hasGLES2Impl;
+ private static final boolean hasGLES1Impl;
+
+ /** The JVM/process wide default GL profile **/
+ private static GLProfile defaultGLProfile;
+
+ /** All GLProfiles */
+ private static final HashMap/*<String, GLProfile>*/ mappedProfiles;
+
+ /**
+ * Tries the profiles implementation and native libraries.
+ * Throws an GLException if no profile could be found at all.
+ */
+ static {
+ boolean hasDesktopGL = false;
+ try {
+ // See DRIHack.java for an explanation of why this is necessary
+ DRIHack.begin();
+ NativeLibLoader.loadGLDesktop();
+ DRIHack.end();
+ hasDesktopGL = true;
+ } catch (Throwable t) {
+ if (DEBUG) {
+ System.err.println("GLProfile.static Desktop GL Library not available");
+ t.printStackTrace();
+ }
+ }
+ boolean hasDesktopGLES12 = false;
+ try {
+ // See DRIHack.java for an explanation of why this is necessary
+ DRIHack.begin();
+ NativeLibLoader.loadGLDesktopES12();
+ DRIHack.end();
+ hasDesktopGLES12 = true;
+ } catch (Throwable t) {
+ if (DEBUG) {
+ System.err.println("GLProfile.static Desktop GL ES12 Library not available");
+ t.printStackTrace();
+ }
+ }
+
+ boolean hasNativeOSFactory = false;
+ if(hasDesktopGL||hasDesktopGLES12) {
+ try {
+ hasNativeOSFactory = null!=GLDrawableFactory.getNativeOSFactory();
+ } catch (Throwable t) {
+ if (DEBUG) {
+ System.err.println("GLProfile.static - Native platform GLDrawable factory not available");
+ t.printStackTrace();
+ }
+ }
+ }
+ if(!hasNativeOSFactory) {
+ hasDesktopGLES12=false;
+ hasDesktopGL=false;
+ }
+
+ // FIXME: check for real GL3 availability .. ?
+ hasGL3Impl = hasDesktopGL && null!=NWReflection.getClass("com.sun.opengl.impl.gl3.GL3Impl");
+ hasGL2Impl = hasDesktopGL && null!=NWReflection.getClass("com.sun.opengl.impl.gl2.GL2Impl");
+
+ hasGL2ES12Impl = hasDesktopGLES12 && null!=NWReflection.getClass("com.sun.opengl.impl.gl2es12.GL2ES12Impl");
+
+ boolean btest = false;
+ try {
+ btest = null!=GLDrawableFactory.getFactory(GLES2) && null!=NWReflection.getClass("com.sun.opengl.impl.es2.GLES2Impl");
+ } catch (Throwable t) {
+ if (DEBUG) {
+ System.err.println("GLProfile.static - GL ES2 Factory/Library not available");
+ t.printStackTrace();
+ }
+ }
+ hasGLES2Impl = btest;
+
+ btest = false;
+ try {
+ btest = null!=GLDrawableFactory.getFactory(GLES1) && null!=NWReflection.getClass("com.sun.opengl.impl.es1.GLES1Impl");
+ } catch (Throwable t) {
+ if (DEBUG) {
+ System.err.println("GLProfile.static - GL ES1 Factory/Library not available");
+ t.printStackTrace();
+ }
+ }
+ hasGLES1Impl = btest;
+
+ if (DEBUG) {
+ System.err.println("GLProfile.static hasNativeOSFactory "+hasNativeOSFactory);
+ System.err.println("GLProfile.static hasDesktopGLES12 "+hasDesktopGLES12);
+ System.err.println("GLProfile.static hasDesktopGL "+hasDesktopGL);
+ System.err.println("GLProfile.static hasGL3Impl "+hasGL3Impl);
+ System.err.println("GLProfile.static hasGL2Impl "+hasGL2Impl);
+ System.err.println("GLProfile.static hasGL2ES12Impl "+hasGL2ES12Impl);
+ System.err.println("GLProfile.static hasGLES2Impl "+hasGLES2Impl);
+ System.err.println("GLProfile.static hasGLES1Impl "+hasGLES1Impl);
+ }
+
+ HashMap/*<String, GLProfile>*/ _mappedProfiles = new HashMap(GL_PROFILE_LIST.length);
+ for(int i=0; i<GL_PROFILE_LIST.length; i++) {
+ String profile = GL_PROFILE_LIST[i];
+ String profileImpl = ComputeProfileImpl(profile);
+ if(null!=profileImpl) {
+ GLProfile glProfile = new GLProfile(profile, profileImpl);
+ _mappedProfiles.put(profile, glProfile);
+ if (DEBUG) {
+ System.err.println("GLProfile.static map "+glProfile);
+ }
+ if(null==defaultGLProfile) {
+ defaultGLProfile=glProfile;
+ if (DEBUG) {
+ System.err.println("GLProfile.static default "+glProfile);
+ }
+ }
+ } else {
+ if (DEBUG) {
+ System.err.println("GLProfile.static map *** no mapping for "+profile);
+ }
+ }
+ }
+ mappedProfiles = _mappedProfiles; // final ..
+ if(null==defaultGLProfile) {
+ throw new GLException("No profile available: "+list2String(GL_PROFILE_LIST));
+ }
+ }
+
+ private static final String list2String(String[] list) {
+ StringBuffer msg = new StringBuffer();
+ msg.append("[");
+ for (int i = 0; i < list.length; i++) {
+ if (i > 0)
+ msg.append(", ");
+ msg.append(list[i]);
+ }
+ msg.append("]");
+ return msg.toString();
+ }
+
+
+ /**
+ * Returns the profile implementation
+ */
+ private static String ComputeProfileImpl(String profile) {
+ if (GL2ES1.equals(profile)) {
+ if(hasGL2Impl) {
+ return GL2;
+ } else if(hasGL2ES12Impl) {
+ return GL2ES12;
+ } else if(hasGLES1Impl) {
+ return GLES1;
+ }
+ } else if (GL2ES2.equals(profile)) {
+ if(hasGL2ES12Impl) {
+ return GL2ES12;
+ } else if(hasGL2Impl) {
+ return GL2;
+ } else if(hasGL3Impl) {
+ return GL3;
+ } else if(hasGLES2Impl) {
+ return GLES2;
+ }
+ } else if(GL3.equals(profile) && hasGL3Impl) {
+ return GL3;
+ } else if(GL2.equals(profile) && hasGL2Impl) {
+ return GL2;
+ } else if(GLES2.equals(profile) && hasGLES2Impl) {
+ return GLES2;
+ } else if(GLES1.equals(profile) && hasGLES1Impl) {
+ return GLES1;
+ }
+ return null;
+ }
+
+ public static String GetGLTypeName(int type) {
+ switch (type) {
+ case GL.GL_UNSIGNED_BYTE:
+ return "GL_UNSIGNED_BYTE";
+ case GL.GL_BYTE:
+ return "GL_BYTE";
+ case GL.GL_UNSIGNED_SHORT:
+ return "GL_UNSIGNED_SHORT";
+ case GL.GL_SHORT:
+ return "GL_SHORT";
+ case GL.GL_FLOAT:
+ return "GL_FLOAT";
+ case GL.GL_FIXED:
+ return "GL_FIXED";
+ case javax.media.opengl.GL2ES2.GL_INT:
+ return "GL_INT";
+ case javax.media.opengl.GL2ES2.GL_UNSIGNED_INT:
+ return "GL_UNSIGNED_INT";
+ case javax.media.opengl.GL2.GL_DOUBLE:
+ return "GL_DOUBLE";
+ case javax.media.opengl.GL2.GL_2_BYTES:
+ return "GL_2_BYTES";
+ case javax.media.opengl.GL2.GL_3_BYTES:
+ return "GL_3_BYTES";
+ case javax.media.opengl.GL2.GL_4_BYTES:
+ return "GL_4_BYTES";
+ }
+ return null;
+ }
+
+ public static String GetGLArrayName(int array) {
+ switch(array) {
+ case GLPointerFunc.GL_VERTEX_ARRAY:
+ return "GL_VERTEX_ARRAY";
+ case GLPointerFunc.GL_NORMAL_ARRAY:
+ return "GL_NORMAL_ARRAY";
+ case GLPointerFunc.GL_COLOR_ARRAY:
+ return "GL_COLOR_ARRAY";
+ case GLPointerFunc.GL_TEXTURE_COORD_ARRAY:
+ return "GL_TEXTURE_COORD_ARRAY";
+ }
+ return null;
+ }
+
+ private GLProfile(String profile, String profileImpl) {
+ this.profile = profile;
+ this.profileImpl = profileImpl;
+ }
+
+ private String profileImpl = null;
+ private String profile = null;
+
}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 727d06b61..7ed6d3c3c 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -76,6 +76,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
private static final boolean DEBUG = Debug.debug("GLCanvas");
+ static private GLProfile glProfileDefault = GLProfile.GetProfileDefault();
+ private GLProfile glProfile;
private GLDrawableHelper drawableHelper = new GLDrawableHelper();
private GLDrawable drawable;
private GLContextImpl context;
@@ -83,16 +85,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
private boolean sendReshape = false;
private GraphicsConfiguration chosen;
- private GLCapabilities glCaps;
+ private AWTGraphicsConfiguration awtConfig;
private GLCapabilitiesChooser glCapChooser;
- static {
- // Default to the GL2 profile, which is the default on the desktop
- if (GLProfile.getProfile() == null) {
- GLProfile.setProfile(GLProfile.GL2);
- }
- }
-
/** Creates a new GLCanvas component with a default set of OpenGL
capabilities, using the default OpenGL capabilities selection
mechanism, on the default screen device. */
@@ -133,17 +128,23 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
* below.
*/
super();
+
+ if(null==capabilities) {
+ capabilities = new GLCapabilities(glProfileDefault);
+ }
+ glProfile = capabilities.getGLProfile();
+
/*
* Save the chosen capabilities for use in getGraphicsConfiguration().
*/
- AWTGraphicsConfiguration config = chooseGraphicsConfiguration(capabilities, chooser, device);
+ awtConfig = chooseGraphicsConfiguration(capabilities, chooser, device);
if(DEBUG) {
- Exception e = new Exception("Created Config: "+config);
+ Exception e = new Exception("Created Config: "+awtConfig);
e.printStackTrace();
}
- if(null!=config) {
+ if(null!=awtConfig) {
// update ..
- chosen = config.getGraphicsConfiguration();
+ chosen = awtConfig.getGraphicsConfiguration();
/*
* If we are running on a platform that
@@ -151,13 +152,12 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
* save these for later use in getGraphicsConfiguration().
*/
this.glCapChooser = chooser;
- this.glCaps = (GLCapabilities)config.getCapabilities();
}
if (!Beans.isDesignTime()) {
- if(null==config) {
+ if(null==awtConfig) {
throw new GLException("Error: AWTGraphicsConfiguration is null");
}
- drawable = GLDrawableFactory.getFactory().createGLDrawable(NativeWindowFactory.getNativeWindow(this, config));
+ drawable = GLDrawableFactory.getFactory(awtConfig).createGLDrawable(NativeWindowFactory.getNativeWindow(this, awtConfig));
context = (GLContextImpl) drawable.createContext(shareWith);
context.setSynchronized(true);
}
@@ -245,7 +245,7 @@ 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(glCaps, glCapChooser, gc.getDevice());
+ AWTGraphicsConfiguration config = chooseGraphicsConfiguration((GLCapabilities)awtConfig.getCapabilities(), glCapChooser, gc.getDevice());
final GraphicsConfiguration compatible = (null!=config)?config.getGraphicsConfiguration():null;
if (compatible != null) {
@@ -254,6 +254,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
* any outside callers of this method.
*/
chosen = compatible;
+ awtConfig = config; // FIXME: ??
}
}
@@ -448,16 +449,18 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
if (Beans.isDesignTime()) {
return null;
}
-
- return getContext().getGL();
+ GLContext context = getContext();
+ return (context == null) ? null : context.getGL();
}
public void setGL(GL gl) {
- if (!Beans.isDesignTime()) {
- getContext().setGL(gl);
+ GLContext context = getContext();
+ if (context != null) {
+ context.setGL(gl);
}
}
+
public void setAutoSwapBufferMode(boolean onOrOff) {
drawableHelper.setAutoSwapBufferMode(onOrOff);
}
@@ -470,11 +473,16 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
maybeDoSingleThreadedWorkaround(swapBuffersOnEventDispatchThreadAction, swapBuffersAction);
}
- public GLCapabilities getChosenGLCapabilities() {
- if (drawable == null)
- return null;
+ public GLProfile getGLProfile() {
+ return getGLCapabilities().getGLProfile();
+ }
+
+ public GLCapabilities getGLCapabilities() {
+ if (awtConfig == null) {
+ throw new GLException("No AWTGraphicsConfiguration: "+this);
+ }
- return drawable.getChosenGLCapabilities();
+ return (GLCapabilities)awtConfig.getCapabilities();
}
public NativeWindow getNativeWindow() {
@@ -486,7 +494,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
public String toString() {
- return "AWT-GLCanvas[ "+((null!=drawable)?drawable.getClass().getName():"null-drawable")+", "+drawableHelper+"]";
+ return "AWT-GLCanvas[ "+awtConfig+", "+((null!=drawable)?drawable.getClass().getName():"null-drawable")+", "+drawableHelper+"]";
}
//----------------------------------------------------------------------
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index bf4176a08..eff9b8f3f 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -93,6 +93,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
// Data used for either pbuffers or pixmap-based offscreen surfaces
private GLCapabilities offscreenCaps;
+ private GLProfile glProfile;
+ private GLDrawableFactoryImpl factory;
private GLCapabilitiesChooser chooser;
private GLContext shareWith;
// Width of the actual GLJPanel
@@ -102,8 +104,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
private boolean handleReshape = false;
private boolean sendReshape = true;
- private static GLDrawableFactoryImpl factory;
-
// The backend in use
private Backend backend;
@@ -145,8 +145,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
getLocalGraphicsEnvironment().
getDefaultScreenDevice());
}
- GLProfile.setProfile(GLProfile.GL2);
- factory = GLDrawableFactoryImpl.getFactoryImpl();
}
/** Creates a new GLJPanel component with a default set of OpenGL
@@ -182,9 +180,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
if (capabilities != null) {
offscreenCaps = (GLCapabilities) capabilities.clone();
} else {
- offscreenCaps = new GLCapabilities();
+ offscreenCaps = new GLCapabilities(null);
}
offscreenCaps.setDoubleBuffered(false);
+ this.glProfile = offscreenCaps.getGLProfile();
+ this.factory = GLDrawableFactoryImpl.getFactoryImpl(glProfile);
this.chooser = ((chooser != null) ? chooser : new DefaultGLCapabilitiesChooser());
this.shareWith = shareWith;
}
@@ -352,6 +352,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
}
public GL getGL() {
+ if (Beans.isDesignTime()) {
+ return null;
+ }
GLContext context = getContext();
return (context == null) ? null : context.getGL();
}
@@ -404,15 +407,19 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return oglPipelineEnabled;
}
- public GLCapabilities getChosenGLCapabilities() {
- return backend.getChosenGLCapabilities();
+ public GLCapabilities getGLCapabilities() {
+ return backend.getGLCapabilities();
+ }
+
+ public final GLProfile getGLProfile() {
+ return glProfile;
}
public NativeWindow getNativeWindow() {
throw new GLException("FIXME");
}
- public GLDrawableFactory getFactory() {
+ public final GLDrawableFactory getFactory() {
return factory;
}
@@ -620,8 +627,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
// Called to get the current backend's GLDrawable
public GLDrawable getDrawable();
- // Called to fetch the "real" chosen GLCapabilities for the backend
- public GLCapabilities getChosenGLCapabilities();
+ // Called to fetch the "real" GLCapabilities for the backend
+ public GLCapabilities getGLCapabilities();
+
+ // Called to fetch the "real" GLProfile for the backend
+ public GLProfile getGLProfile();
// Called to handle a reshape event. When this is called, the
// OpenGL context associated with the backend is not current, to
@@ -861,11 +871,18 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return offscreenDrawable;
}
- public GLCapabilities getChosenGLCapabilities() {
+ public GLCapabilities getGLCapabilities() {
+ if (offscreenDrawable == null) {
+ return null;
+ }
+ return offscreenDrawable.getGLCapabilities();
+ }
+
+ public GLProfile getGLProfile() {
if (offscreenDrawable == null) {
return null;
}
- return offscreenDrawable.getChosenGLCapabilities();
+ return offscreenDrawable.getGLProfile();
}
public void handleReshape() {
@@ -952,11 +969,18 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return pbuffer;
}
- public GLCapabilities getChosenGLCapabilities() {
+ public GLCapabilities getGLCapabilities() {
+ if (pbuffer == null) {
+ return null;
+ }
+ return pbuffer.getGLCapabilities();
+ }
+
+ public GLProfile getGLProfile() {
if (pbuffer == null) {
return null;
}
- return pbuffer.getChosenGLCapabilities();
+ return pbuffer.getGLProfile();
}
public void handleReshape() {
@@ -1123,9 +1147,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return joglDrawable;
}
- public GLCapabilities getChosenGLCapabilities() {
+ public GLCapabilities getGLCapabilities() {
+ // FIXME: should do better than this; is it possible to using only platform-independent code?
+ return new GLCapabilities(null);
+ }
+
+ public GLProfile getGLProfile() {
// FIXME: should do better than this; is it possible to using only platform-independent code?
- return new GLCapabilities();
+ return GLProfile.GetProfileDefault();
}
public void handleReshape() {
@@ -1388,9 +1417,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
if (factory.canCreateExternalGLDrawable()) {
joglDrawable = factory.createExternalGLDrawable();
joglContext = joglDrawable.createContext(shareWith);
- } else if (((GLDrawableFactoryImpl) factory).canCreateContextOnJava2DSurface()) {
+ } else if (factory.canCreateContextOnJava2DSurface()) {
// Mac OS X code path
- joglContext = ((GLDrawableFactoryImpl) factory).createContextOnJava2DSurface(g, shareWith);
+ joglContext = factory.createContextOnJava2DSurface(g, shareWith);
}
if (DEBUG) {
joglContext.setGL(new DebugGL2(joglContext.getGL().getGL2()));