aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/sun
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/classes/com/sun
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/classes/com/sun')
-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
39 files changed, 340 insertions, 239 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;