aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-06-10 14:28:03 +0200
committerMichael Bien <[email protected]>2010-06-10 14:28:03 +0200
commit2522d4f1ebffec030d7e8c3688e5f952c574c3d0 (patch)
tree81d631cb11dadc483a4615996dedf773eed083da /src/jogl/classes/com
parent57d3d3f9f9475ae167cd9d33c9450eea66439fd2 (diff)
parent1d333a771ce0bc7c8594e21d031703f698f06a46 (diff)
Merge branch 'master' of github.com:sgothel/jogl
Diffstat (limited to 'src/jogl/classes/com')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java84
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/DRIHack.java137
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/DesktopGLDynamicLibraryBundleInfo.java66
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/DesktopGLDynamicLookupHelper.java71
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/GLBufferSizeTracker.java71
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/GLBufferStateTracker.java53
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java155
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java24
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLDrawableHelper.java5
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java52
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/GLDynamicLibraryBundleInfo.java57
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/GLDynamicLookupHelper.java49
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLJNILibLoader.java46
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java17
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/GLStateTracker.java143
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/InternalBufferUtil.java.javame_cdc_fp189
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/InternalBufferUtil.java.javase199
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/ProjectFloat.java3
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java76
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java152
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java52
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLibraryBundleInfo.java72
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLookupHelper.java270
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLES1DynamicLibraryBundleInfo.java72
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLES1DynamicLookupHelper.java68
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLES2DynamicLibraryBundleInfo.java72
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLES2DynamicLookupHelper.java68
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLExternalContext.java7
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenContext.java31
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenDrawable.java16
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/gl2/ProjectDouble.java3
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/glu/mipmap/BuildMipmap.java35
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/glu/mipmap/Mipmap.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/glu/mipmap/ScaleInternal.java10
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java45
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java12
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java34
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDynamicLibraryBundleInfo.java71
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java86
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java51
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java49
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java31
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java14
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java8
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java22
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOnscreenWGLContext.java37
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java14
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java13
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java98
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java70
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java97
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDynamicLibraryBundleInfo.java62
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java34
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java30
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/GLXUtil.java29
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java13
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java56
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXDrawable.java77
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java222
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawable.java33
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java149
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDynamicLibraryBundleInfo.java88
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java24
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java301
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java103
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXContext.java14
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java45
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXContext.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java18
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java80
-rw-r--r--src/jogl/classes/com/jogamp/openmax/OMXInstance.java2
74 files changed, 1956 insertions, 2619 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java
new file mode 100644
index 000000000..c28e52d07
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2010, Sven Gothel
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sven Gothel nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Sven Gothel BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.jogamp.opengl.cg;
+
+import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.common.os.DynamicLibraryBundleInfo;
+import com.jogamp.common.os.NativeLibrary;
+import com.jogamp.common.os.Platform;
+import java.util.*;
+import java.security.*;
+import javax.media.opengl.GLException;
+
+public class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
+ private static List/*<String>*/ glueLibNames;
+ static {
+ glueLibNames = new ArrayList();
+ // glueLibNames.addAll(getGlueLibNamesPreload());
+ glueLibNames.add("jogl_cg");
+ }
+
+ public static final int getCgGlueLibIndex() {
+ return glueLibNames.size()-1;
+ }
+
+ protected CgDynamicLibraryBundleInfo() {
+ super();
+ }
+
+ /** Make Cg symbols available to CgGL */
+ public boolean shallLinkGlobal() { return true; }
+
+ /** default **/
+ public boolean shallLookupGlobal() { return false; }
+
+ /** Tool has none **/
+ public final List getToolGetProcAddressFuncNameList() {
+ return null;
+ }
+
+ /** Tool has none **/
+ public final long toolDynamicLookupFunction(long toolGetProcAddressHandle, String funcName) {
+ return 0;
+ }
+
+ public List/*<List<String>>*/ getToolLibNames() {
+ List/*<List>*/ libNamesList = new ArrayList();
+
+ libNamesList.add("Cg");
+ libNamesList.add("CgGL");
+
+ return libNamesList;
+ }
+
+ public final List/*<String>*/ getGlueLibNames() {
+ return glueLibNames;
+ }
+}
+
+
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/DRIHack.java b/src/jogl/classes/com/jogamp/opengl/impl/DRIHack.java
deleted file mode 100755
index 7e81d194b..000000000
--- a/src/jogl/classes/com/jogamp/opengl/impl/DRIHack.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl.impl;
-
-import com.jogamp.common.os.NativeLibrary;
-import com.jogamp.common.os.Platform;
-import java.io.*;
-import java.security.*;
-
-/**
- * Helper class for working around problems with open-source DRI
- * drivers. In the current DRI implementation it is required that the
- * symbols in libGL.so.1.2 be globally visible to be accessible from
- * other libraries that are dynamically loaded by the implementation.
- * Applications may typically satisfy this need either by linking
- * against libGL.so on the command line (-lGL) or by dlopen'ing
- * libGL.so.1.2 with the RTLD_GLOBAL flag. The JOGL implementation
- * links against libGL on all platforms rather than forcing all OpenGL
- * entry points to be called through a function pointer. This allows
- * the JOGL library to link directly to core 1.1 OpenGL entry points
- * like glVertex3f, while calling through function pointers for entry
- * points from later OpenGL versions as well as from
- * extensions. However, because libjogl.so (which links against
- * libGL.so) is loaded by the JVM, and because the JVM implicitly uses
- * RTLD_LOCAL in the implementation of System.loadLibrary(), this
- * means via transitivity that the symbols for libGL.so have only
- * RTLD_LOCAL visibility to the rest of the application, so the DRI
- * drivers can not find the symbols required. <P>
- *
- * There are at least two possible solutions. One would be to change
- * the JOGL implementation to call through function pointers uniformly
- * so that it does not need to link against libGL.so. This is
- * possible, but requires changes to GlueGen and also is not really
- * necessary in any other situation than with the DRI drivers. Another
- * solution is to force the first load of libGL.so.1.2 to be done
- * dynamically with RTLD_GLOBAL before libjogl.so is loaded and causes
- * libGL.so.1.2 to be loaded again. The NativeLibrary class in the
- * GlueGen runtime has this property, and we use it to implement this
- * workaround.
- */
-
-public class DRIHack {
-
- private static final boolean DEBUG = Debug.debug("DRIHack");
- private static boolean driHackNeeded;
- private static NativeLibrary oglLib;
-
- static {
- // Allow manual overriding for now as a workaround for
- // problems seen in some situations -- needs more investigation
- if (Debug.getProperty("jogl.drihack.disable", true) != null) {
- driHackNeeded = false;
- } else {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- String os = Platform.getOS().toLowerCase();
- // Do DRI hack on all Linux distributions for best robustness
- driHackNeeded = os.startsWith("linux")
- || new File("/usr/lib/dri").exists()
- || new File("/usr/X11R6/lib/modules/dri").exists();
- return null;
- }
- });
- }
- }
-
- public static void begin() {
-
- if (driHackNeeded) {
- if (DEBUG) {
- System.err.println("Beginning DRI hack");
- }
-
- // Try a few different variants for best robustness
- // In theory probably only the first is necessary
- oglLib = NativeLibrary.open("libGL.so.1", null);
- if (DEBUG && oglLib != null) {
- System.err.println(" Found libGL.so.1");
- }
- if (oglLib == null) {
- oglLib = NativeLibrary.open("/usr/lib/libGL.so.1", null);
- if (DEBUG && oglLib != null) {
- System.err.println(" Found /usr/lib/libGL.so.1");
- }
- }
- }
-
- }
-
- public static void end() {
- if (oglLib != null) {
- if (DEBUG) {
- System.err.println("Ending DRI hack");
- }
-
- oglLib.close();
- oglLib = null;
- }
- }
-}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/DesktopGLDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/impl/DesktopGLDynamicLibraryBundleInfo.java
new file mode 100755
index 000000000..57a69af4c
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/DesktopGLDynamicLibraryBundleInfo.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2010, Sven Gothel
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sven Gothel nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Sven Gothel BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.jogamp.opengl.impl;
+
+import com.jogamp.common.os.DynamicLibraryBundleInfo;
+import java.util.List;
+import java.util.ArrayList;
+
+public abstract class DesktopGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundleInfo {
+ private static int posGlueLibGL2ES12;
+ private static int posGlueLibGLDESKTOP;
+ private static List/*<String>*/ glueLibNames;
+ static {
+ glueLibNames = new ArrayList();
+
+ glueLibNames.addAll(getGlueLibNamesPreload());
+
+ posGlueLibGL2ES12 = glueLibNames.size();
+ glueLibNames.add("jogl_gl2es12");
+
+ posGlueLibGLDESKTOP = glueLibNames.size();
+ glueLibNames.add("jogl_desktop");
+ }
+
+ public static final int getGlueLibPosGL2ES12() {
+ return posGlueLibGL2ES12;
+ }
+
+ public static final int getGlueLibPosGLDESKTOP() {
+ return posGlueLibGLDESKTOP;
+ }
+
+ public DesktopGLDynamicLibraryBundleInfo() {
+ super();
+ }
+
+ public final List/*<String>*/ getGlueLibNames() {
+ return glueLibNames;
+ }
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/DesktopGLDynamicLookupHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/DesktopGLDynamicLookupHelper.java
new file mode 100755
index 000000000..4aeea9d42
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/DesktopGLDynamicLookupHelper.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2010, Sven Gothel
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sven Gothel nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Sven Gothel BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.jogamp.opengl.impl;
+
+import com.jogamp.common.os.DynamicLibraryBundle;
+import com.jogamp.common.os.DynamicLibraryBundleInfo;
+import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.common.os.NativeLibrary;
+import java.util.*;
+import java.security.*;
+import javax.media.opengl.GLException;
+
+public class DesktopGLDynamicLookupHelper extends GLDynamicLookupHelper {
+
+ public DesktopGLDynamicLookupHelper(DesktopGLDynamicLibraryBundleInfo info) {
+ super(info);
+ }
+
+ public DesktopGLDynamicLibraryBundleInfo getDesktopGLBundleInfo() { return (DesktopGLDynamicLibraryBundleInfo) getBundleInfo(); }
+
+ public boolean hasGLBinding() {
+ return isToolLibLoaded() && isGlueLibLoaded(DesktopGLDynamicLibraryBundleInfo.getGlueLibPosGLDESKTOP());
+ }
+
+ public boolean hasGLES12Binding() {
+ return isToolLibLoaded() && isGlueLibLoaded(DesktopGLDynamicLibraryBundleInfo.getGlueLibPosGL2ES12());
+ }
+
+ public synchronized boolean loadGLULibrary() {
+ /** hacky code .. where all platform GLU libs are tried ..*/
+ if(null==gluLib) {
+ List/*<String>*/ gluLibNames = new ArrayList();
+ gluLibNames.add("/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib"); // osx
+ gluLibNames.add("libGLU.so"); // unix
+ gluLibNames.add("GLU32"); // windows
+ gluLibNames.add("GLU"); // generic
+ gluLib = loadFirstAvailable(gluLibNames, null, true);
+ if(null != gluLib) {
+ nativeLibraries.add(gluLib);
+ }
+ }
+ return null != gluLib ;
+ }
+ NativeLibrary gluLib = null;
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLBufferSizeTracker.java b/src/jogl/classes/com/jogamp/opengl/impl/GLBufferSizeTracker.java
index 48affa534..b4237501e 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLBufferSizeTracker.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLBufferSizeTracker.java
@@ -39,8 +39,8 @@
package com.jogamp.opengl.impl;
-import java.util.*;
import javax.media.opengl.*;
+import com.jogamp.common.util.IntIntHashMap;
/**
* Tracks as closely as possible the sizes of allocated OpenGL buffer
@@ -93,18 +93,17 @@ public class GLBufferSizeTracker {
// objects, which is probably sub-optimal. The expected usage
// pattern of buffer objects indicates that the fact that this map
// never shrinks is probably not that bad.
- private Map/*<Integer,Integer>*/ bufferSizeMap =
- Collections.synchronizedMap(new HashMap/*<Integer,Integer>*/());
+ private IntIntHashMap bufferSizeMap;
private static final boolean DEBUG = Debug.debug("GLBufferSizeTracker");
public GLBufferSizeTracker() {
+ bufferSizeMap = new IntIntHashMap();
+ bufferSizeMap.setKeyNotFoundValue(-1);
}
public void setBufferSize(GLBufferStateTracker bufferStateTracker,
- int target,
- GL caller,
- int size) {
+ int target, GL caller, int size) {
// Need to do some similar queries to getBufferSize below
int buffer = bufferStateTracker.getBoundBufferObject(target, caller);
boolean valid = bufferStateTracker.isBoundBufferObjectKnown(target);
@@ -118,7 +117,7 @@ public class GLBufferSizeTracker {
throw new GLException("Error: no OpenGL buffer object appears to be bound to target 0x" +
Integer.toHexString(target));
}
- bufferSizeMap.put(new Integer(buffer), new Integer(size));
+ setDirectStateBufferSize(buffer, caller, size);
}
// We don't know the current buffer state. Note that the buffer
// state tracker will have made the appropriate OpenGL query if it
@@ -126,6 +125,10 @@ public class GLBufferSizeTracker {
// left to do except drop this piece of information on the floor.
}
+ public void setDirectStateBufferSize(int buffer, GL caller, int size) {
+ bufferSizeMap.put(buffer, size);
+ }
+
public int getBufferSize(GLBufferStateTracker bufferStateTracker,
int target,
GL caller) {
@@ -134,7 +137,7 @@ public class GLBufferSizeTracker {
int buffer = bufferStateTracker.getBoundBufferObject(target, caller);
boolean valid = bufferStateTracker.isBoundBufferObjectKnown(target);
if (valid) {
- if (buffer == 0) {
+ if (0 == buffer) {
// FIXME: this really should not happen if we know what's
// going on. Very likely there is an OpenGL error in the
// application if we get here. Could silently return 0, but it
@@ -143,38 +146,56 @@ public class GLBufferSizeTracker {
throw new GLException("Error: no OpenGL buffer object appears to be bound to target 0x" +
Integer.toHexString(target));
}
+ return getBufferSizeImpl(target, buffer, caller);
+ }
+ // We don't know what's going on in this case; query the GL for an answer
+ int[] tmp = new int[1];
+ caller.glGetBufferParameteriv(target, GL.GL_BUFFER_SIZE, tmp, 0);
+ if (DEBUG) {
+ System.err.println("GLBufferSizeTracker.getBufferSize(): no cached buffer information");
+ }
+ return tmp[0];
+ }
+
+ public int getDirectStateBufferSize(int buffer, GL caller) {
+ return getBufferSizeImpl(0, buffer, caller);
+ }
+
+ private int getBufferSizeImpl(int target, int buffer, GL caller) {
// See whether we know the size of this buffer object; at this
// point we almost certainly should if the application is
// written correctly
- Integer key = new Integer(buffer);
- Integer sz = (Integer) bufferSizeMap.get(key);
- if (sz == null) {
+ int sz = bufferSizeMap.get(buffer);
+ if (0 > sz) {
// For robustness, try to query this value from the GL as we used to
int[] tmp = new int[1];
- caller.glGetBufferParameteriv(target, GL.GL_BUFFER_SIZE, tmp, 0);
+ if(0==target) {
+ // DirectState ..
+ if(caller.isFunctionAvailable("glGetNamedBufferParameterivEXT")) {
+ caller.getGL2().glGetNamedBufferParameterivEXT(buffer, GL.GL_BUFFER_SIZE, tmp, 0);
+ } else {
+ throw new GLException("Error: getDirectStateBufferSize called with unknown state and GL function 'glGetNamedBufferParameterivEXT' n/a to query size");
+ }
+ } else {
+ caller.glGetBufferParameteriv(target, GL.GL_BUFFER_SIZE, tmp, 0);
+ }
if (tmp[0] == 0) {
// Assume something is wrong rather than silently going along
- throw new GLException("Error: buffer size returned by glGetBufferParameteriv was zero; probably application error");
+ throw new GLException("Error: buffer size returned by "+
+ ((0==target)?"glGetNamedBufferParameterivEXT":"glGetBufferParameteriv")+
+ " was zero; probably application error");
}
// Assume we just don't know what's happening
- sz = new Integer(tmp[0]);
- bufferSizeMap.put(key, sz);
+ sz = tmp[0];
+ bufferSizeMap.put(buffer, sz);
if (DEBUG) {
System.err.println("GLBufferSizeTracker.getBufferSize(): made slow query to cache size " +
- tmp[0] +
+ sz +
" for buffer " +
buffer);
}
}
- return sz.intValue();
- }
- // We don't know what's going on in this case; query the GL for an answer
- int[] tmp = new int[1];
- caller.glGetBufferParameteriv(target, GL.GL_BUFFER_SIZE, tmp, 0);
- if (DEBUG) {
- System.err.println("GLBufferSizeTracker.getBufferSize(): no cached buffer information");
- }
- return tmp[0];
+ return sz;
}
// This should be called on any major event where we might start
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLBufferStateTracker.java b/src/jogl/classes/com/jogamp/opengl/impl/GLBufferStateTracker.java
index df8d673a1..05b2a2fa9 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLBufferStateTracker.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLBufferStateTracker.java
@@ -39,8 +39,8 @@
package com.jogamp.opengl.impl;
-import java.util.*;
import javax.media.opengl.*;
+import com.jogamp.common.util.IntIntHashMap;
/**
* Tracks as closely as possible which OpenGL buffer object is bound
@@ -77,29 +77,28 @@ import javax.media.opengl.*;
public class GLBufferStateTracker {
private static final boolean DEBUG = Debug.debug("GLBufferStateTracker");
- private static final Integer arrayBufferEnum = new Integer(GL.GL_ARRAY_BUFFER);
- private static final Integer elementArrayBufferEnum = new Integer(GL.GL_ELEMENT_ARRAY_BUFFER);
- private static final Integer pixelPackBufferEnum = new Integer(GL2.GL_PIXEL_PACK_BUFFER);
- private static final Integer pixelUnpackBufferEnum = new Integer(GL2.GL_PIXEL_UNPACK_BUFFER);
- private static final Integer zero = new Integer(0);
-
// Maps binding targets to buffer objects. A null value indicates
// that the binding is unknown. A zero value indicates that it is
- // known that no buffer is bound to the target.
- private Map/*<Integer,Integer>*/ bindingMap = new HashMap/*<Integer,Integer>*/();
+ // known that no buffer is bound to the target, according to the
+ // OpenGL specifications.
+ // http://www.opengl.org/sdk/docs/man/xhtml/glBindBuffer.xml
+ private IntIntHashMap bindingMap;
private int[] bufTmp = new int[1];
public GLBufferStateTracker() {
+ bindingMap = new IntIntHashMap();
+ bindingMap.setKeyNotFoundValue(-1);
+
// Start with known unbound targets for known keys
- bindingMap.put(arrayBufferEnum, zero);
- bindingMap.put(elementArrayBufferEnum, zero);
- bindingMap.put(pixelPackBufferEnum, zero);
- bindingMap.put(pixelUnpackBufferEnum, zero);
+ bindingMap.put(GL.GL_ARRAY_BUFFER, 0);
+ bindingMap.put(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
+ bindingMap.put(GL2.GL_PIXEL_PACK_BUFFER, 0);
+ bindingMap.put(GL2.GL_PIXEL_UNPACK_BUFFER, 0);
}
public void setBoundBufferObject(int target, int buffer) {
- bindingMap.put(box(target), box(buffer));
+ bindingMap.put(target, buffer);
}
/** Note: returns an unspecified value if the binding for the
@@ -107,8 +106,8 @@ public class GLBufferStateTracker {
You must use isBoundBufferObjectKnown() to see whether the
return value is valid. */
public int getBoundBufferObject(int target, GL caller) {
- Integer value = (Integer) bindingMap.get(box(target));
- if (value == null) {
+ int value = bindingMap.get(target);
+ if (0 > value) {
// User probably either called glPushClientAttrib /
// glPopClientAttrib or is querying an unknown target. See
// whether we know how to fetch this state.
@@ -129,19 +128,19 @@ public class GLBufferStateTracker {
" for query target 0x" + Integer.toHexString(queryTarget));
}
setBoundBufferObject(target, bufTmp[0]);
- // Try once more
- return getBoundBufferObject(target, caller);
+ return bufTmp[0];
}
return 0;
}
- return value.intValue();
+ return value;
}
/** Indicates whether the binding state for the specified target is
- currently known. Should be called after getBoundBufferObject()
+ currently known, ie it could be bound or not but it must be tracked.<br>
+ Should be called after getBoundBufferObject()
because that method may change the answer for a given target. */
public boolean isBoundBufferObjectKnown(int target) {
- return (bindingMap.get(box(target)) != null);
+ return 0 < bindingMap.get(target) ;
}
/** Clears out the known/unknown state of the various buffer object
@@ -154,16 +153,4 @@ public class GLBufferStateTracker {
public void clearBufferObjectState() {
bindingMap.clear();
}
-
- // FIXME: could largely remove this and use Integer.valueOf() in JDK 5
- private static Integer box(int key) {
- switch (key) {
- case 0: return zero;
- case GL.GL_ARRAY_BUFFER: return arrayBufferEnum;
- case GL.GL_ELEMENT_ARRAY_BUFFER: return elementArrayBufferEnum;
- case GL2.GL_PIXEL_PACK_BUFFER: return pixelPackBufferEnum;
- case GL2.GL_PIXEL_UNPACK_BUFFER: return pixelUnpackBufferEnum;
- default: return new Integer(key);
- }
- }
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
index 416f0d694..dc98b5514 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java
@@ -53,16 +53,6 @@ public abstract class GLContextImpl extends GLContext {
protected GLContextLock lock = new GLContextLock();
protected static final boolean DEBUG = Debug.debug("GLContext");
protected static final boolean VERBOSE = Debug.verbose();
- // NOTE: default sense of GLContext optimization disabled in JSR-231
- // 1.0 beta 5 due to problems on X11 platforms (both Linux and
- // Solaris) when moving and resizing windows. Apparently GLX tokens
- // get sent to the X server under the hood (and out from under the
- // cover of the AWT lock) in these situations. Users requiring
- // multi-screen X11 applications can manually enable this flag. It
- // basically had no tangible effect on the Windows or Mac OS X
- // platforms anyway in particular with the disabling of the
- // GLWorkerThread which we found to be necessary in 1.0 beta 4.
- protected boolean optimizationEnabled = Debug.isPropertyDefined("jogl.GLContext.optimize", true);
// Cache of the functions that are available to be called at the current
// moment in time
@@ -151,21 +141,24 @@ public abstract class GLContextImpl extends GLContext {
public abstract Object getPlatformGLExtensions();
+ // Note: the surface is locked within [makeCurrent .. swap .. release]
public void release() throws GLException {
if (!lock.isHeld()) {
throw new GLException("Context not current on current thread");
}
setCurrent(null);
try {
- releaseImpl();
+ releaseImpl();
} finally {
+ if (drawable.isSurfaceLocked()) {
+ drawable.unlockSurface();
+ }
lock.unlock();
}
}
-
protected abstract void releaseImpl() throws GLException;
- public void destroy() {
+ public final void destroy() {
if (lock.isHeld()) {
// release current context
release();
@@ -209,14 +202,47 @@ public abstract class GLContextImpl extends GLContext {
glStateTracker.clearStates(false);
}
- destroyImpl();
+ if (contextHandle != 0) {
+ int lockRes = drawable.lockSurface();
+ if (NativeWindow.LOCK_SURFACE_NOT_READY == lockRes) {
+ // this would be odd ..
+ throw new GLException("Surface not ready to lock: "+drawable);
+ }
+ try {
+ destroyImpl();
+ contextHandle = 0;
+ GLContextShareSet.contextDestroyed(this);
+ } finally {
+ drawable.unlockSurface();
+ }
+ }
} finally {
lock.unlock();
}
}
-
protected abstract void destroyImpl() throws GLException;
+ public final void copy(GLContext source, int mask) throws GLException {
+ if (source.getHandle() == 0) {
+ throw new GLException("Source OpenGL context has not been created");
+ }
+ if (getHandle() == 0) {
+ throw new GLException("Destination OpenGL context has not been created");
+ }
+
+ int lockRes = drawable.lockSurface();
+ if (NativeWindow.LOCK_SURFACE_NOT_READY == lockRes) {
+ // this would be odd ..
+ throw new GLException("Surface not ready to lock");
+ }
+ try {
+ copyImpl(source, mask);
+ } finally {
+ drawable.unlockSurface();
+ }
+ }
+ protected abstract void copyImpl(GLContext source, int mask) throws GLException;
+
//----------------------------------------------------------------------
//
@@ -234,7 +260,7 @@ public abstract class GLContextImpl extends GLContext {
* </ul>
* </ul><br>
*
- * Once at startup, ie triggered by the singleton {@link GLDrawableImpl} constructor,
+ * Once at startup, ie triggered by the singleton constructor of a {@link GLDrawableFactoryImpl} specialization,
* calling {@link #createContextARB} will query all available OpenGL versions:<br>
* <ul>
* <li> <code>FOR ALL GL* DO</code>:
@@ -285,7 +311,7 @@ public abstract class GLContextImpl extends GLContext {
lock.lock();
int res = 0;
try {
- res = makeCurrentImpl();
+ res = makeCurrentLocking();
/* FIXME: refactor dependence on Java 2D / JOGL bridge
if ((tracker != null) &&
@@ -320,15 +346,50 @@ public abstract class GLContextImpl extends GLContext {
return res;
}
- /**
- * @see #makeCurrent
- */
- protected abstract int makeCurrentImpl() throws GLException;
-
- /**
- * @see #makeCurrent
- */
- protected abstract void create() throws GLException ;
+ // Note: the surface is locked within [makeCurrent .. swap .. release]
+ protected final int makeCurrentLocking() throws GLException {
+ boolean exceptionOccurred = false;
+ int lockRes = drawable.lockSurface();
+ try {
+ if (NativeWindow.LOCK_SURFACE_NOT_READY == lockRes) {
+ return CONTEXT_NOT_CURRENT;
+ }
+ try {
+ if (NativeWindow.LOCK_SURFACE_CHANGED == lockRes) {
+ drawable.updateHandle();
+ }
+ if (0 == drawable.getHandle()) {
+ throw new GLException("drawable has invalid handle: "+drawable);
+ }
+ boolean newCreated = false;
+ if (!isCreated()) {
+ newCreated = createImpl(); // may throws exception if fails!
+ if (DEBUG) {
+ if(newCreated) {
+ System.err.println(getThreadName() + ": !!! Create GL context OK: " + toHexString(contextHandle) + " for " + getClass().getName());
+ } else {
+ System.err.println(getThreadName() + ": !!! Create GL context FAILED for " + getClass().getName());
+ }
+ }
+ if(!newCreated) {
+ return CONTEXT_NOT_CURRENT;
+ }
+ GLContextShareSet.contextCreated(this);
+ }
+ makeCurrentImpl(newCreated);
+ return newCreated ? CONTEXT_CURRENT_NEW : CONTEXT_CURRENT ;
+ } catch (RuntimeException e) {
+ exceptionOccurred = true;
+ throw e;
+ }
+ } finally {
+ if (exceptionOccurred) {
+ drawable.unlockSurface();
+ }
+ }
+ }
+ protected abstract void makeCurrentImpl(boolean newCreatedContext) throws GLException;
+ protected abstract boolean createImpl() throws GLException ;
/**
* Platform dependent but harmonized implementation of the <code>ARB_create_context</code>
@@ -388,14 +449,17 @@ public abstract class GLContextImpl extends GLContext {
* @see #createContextARBImpl
* @see #destroyContextARBImpl
*/
- protected long createContextARB(long share, boolean direct,
- int major[], int minor[], int ctp[])
+ protected final long createContextARB(long share, boolean direct,
+ int major[], int minor[], int ctp[])
{
AbstractGraphicsConfiguration config = drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities();
GLProfile glp = glCaps.getGLProfile();
long _context = 0;
+ if (DEBUG) {
+ System.err.println(getThreadName() + ": !!! createContextARB: mappedVersionsAvailableSet "+ mappedVersionsAvailableSet);
+ }
if( !mappedVersionsAvailableSet ) {
synchronized(mappedVersionsAvailableLock) {
if( !mappedVersionsAvailableSet ) {
@@ -405,6 +469,9 @@ public abstract class GLContextImpl extends GLContext {
createContextARBMapVersionsAvailable(3, true /* compat */); // GL3bc
createContextARBMapVersionsAvailable(2, true /* compat */); // GL2
mappedVersionsAvailableSet=true;
+ if (DEBUG) {
+ System.err.println(getThreadName() + ": !!! createContextARB: SET mappedVersionsAvailableSet "+ mappedVersionsAvailableSet);
+ }
}
}
}
@@ -435,7 +502,7 @@ public abstract class GLContextImpl extends GLContext {
return _ctx;
}
- private void createContextARBMapVersionsAvailable(int reqMajor, boolean compat)
+ private final void createContextARBMapVersionsAvailable(int reqMajor, boolean compat)
{
long _context;
int reqProfile = compat ? CTX_PROFILE_COMPAT : CTX_PROFILE_CORE ;
@@ -497,13 +564,16 @@ public abstract class GLContextImpl extends GLContext {
if(0!=_context) {
destroyContextARBImpl(_context);
mapVersionAvailable(reqMajor, reqProfile, major[0], minor[0], ctp);
+ if (DEBUG) {
+ System.err.println(getThreadName() + ": createContextARBMapVersionsAvailable: "+getGLVersionAvailable(reqMajor, reqProfile));
+ }
}
}
- private long createContextARBVersions(long share, boolean direct, int ctxOptionFlags,
- int majorMax, int minorMax,
- int majorMin, int minorMin,
- int major[], int minor[]) {
+ private final long createContextARBVersions(long share, boolean direct, int ctxOptionFlags,
+ int majorMax, int minorMax,
+ int majorMin, int minorMin,
+ int major[], int minor[]) {
major[0]=majorMax;
minor[0]=minorMax;
long _context=0;
@@ -531,7 +601,7 @@ public abstract class GLContextImpl extends GLContext {
* If major==0 && minor == 0 : Use GL_VERSION
* Otherwise .. don't touch ..
*/
- protected void setContextVersion(int major, int minor, int ctp) {
+ protected final void setContextVersion(int major, int minor, int ctp) {
if (0==ctp) {
throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp));
}
@@ -610,7 +680,7 @@ public abstract class GLContextImpl extends GLContext {
public abstract ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3);
- public void setSwapInterval(final int interval) {
+ public final void setSwapInterval(final int interval) {
GLContext current = getCurrent();
if (current != this) {
throw new GLException("This context is not current. Current context: "+current+
@@ -618,17 +688,12 @@ public abstract class GLContextImpl extends GLContext {
}
setSwapIntervalImpl(interval);
}
-
+ protected void setSwapIntervalImpl(final int interval) { /** nop per default .. **/ }
protected int currentSwapInterval = -1; // default: not set yet ..
-
public int getSwapInterval() {
return currentSwapInterval;
}
- protected void setSwapIntervalImpl(final int interval) {
- // nop per default ..
- }
-
/** Maps the given "platform-independent" function name to a real function
name. Currently this is only used to map "glAllocateMemoryNV" and
associated routines to wglAllocateMemoryNV / glXAllocateMemoryNV. */
@@ -660,7 +725,7 @@ public abstract class GLContextImpl extends GLContext {
/** Helper routine which resets a ProcAddressTable generated by the
GLEmitter by looking up anew all of its function pointers. */
protected void resetProcAddressTable(Object table) {
- ((ProcAddressTable)table).reset(getDrawableImpl().getDynamicLookupHelper() );
+ ((ProcAddressTable)table).reset(getDrawableImpl().getGLDynamicLookupHelper() );
}
/**
@@ -743,7 +808,7 @@ public abstract class GLContextImpl extends GLContext {
} catch (Exception e) {}
}
// dynamic function lookup at last incl name aliasing (not cached)
- DynamicLookupHelper dynLookup = getDrawableImpl().getDynamicLookupHelper();
+ DynamicLookupHelper dynLookup = getDrawableImpl().getGLDynamicLookupHelper();
String tmpBase = GLExtensionNames.normalizeVEN(GLExtensionNames.normalizeARB(glFunctionName, true), true);
long addr = 0;
int variants = GLExtensionNames.getFuncNamePermutationNumber(tmpBase);
@@ -829,10 +894,6 @@ public abstract class GLContextImpl extends GLContext {
// current on the OpenGL worker thread
//
- public boolean isOptimizable() {
- return optimizationEnabled;
- }
-
public boolean hasWaiters() {
return lock.hasWaiters();
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
index 50e2edddb..b13cb44ee 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
@@ -55,6 +55,13 @@ import java.security.*;
public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
protected static final boolean DEBUG = Debug.debug("GLDrawableFactory");
+ /**
+ * Returns the GLDynamicLookupHelper
+ * @param profile if EGL/ES, profile <code>1</code> refers to ES1 and <code>2</code> to ES2,
+ * otherwise the profile is ignored.
+ */
+ public abstract GLDynamicLookupHelper getGLDynamicLookupHelper(int profile);
+
//---------------------------------------------------------------------------
// Dispatching GLDrawable construction in respect to the NativeWindow Capabilities
//
@@ -219,23 +226,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
return (GLDrawableFactoryImpl) getFactory(glp);
}
- // Helper function for more lazily loading the GLU library;
- // apparently can't use System.loadLibrary on UNIX because it uses
- // RTLD_LOCAL and we need to call dlsym(RTLD_DEFAULT)
- public abstract void loadGLULibrary();
-
- //----------------------------------------------------------------------
- // Support for locking and unlocking the toolkit -- needed only on X11 platforms
- //
-
- public void lockToolkit() {
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- }
-
- public void unlockToolkit() {
- NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
- }
-
//---------------------------------------------------------------------------
// Support for Java2D/JOGL bridge on Mac OS X; the external
// GLDrawable mechanism in the public API is sufficient to
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableHelper.java
index 7a4e84081..8cc12ca89 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableHelper.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableHelper.java
@@ -136,6 +136,9 @@ public class GLDrawableHelper {
lastContext.release();
}
+ if(!context.isCreated() && null == initAction) {
+ throw new GLException("Context has to be created, but no initAction is given: "+context);
+ }
int res = 0;
try {
res = context.makeCurrent();
@@ -154,7 +157,7 @@ public class GLDrawableHelper {
System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running runnable");
}
runnable.run();
- if (autoSwapBufferMode) {
+ if (autoSwapBufferMode && null != initAction) {
if (drawable != null) {
drawable.swapBuffers();
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
index 62b89a13e..1270a4545 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableImpl.java
@@ -39,7 +39,6 @@
package com.jogamp.opengl.impl;
-import com.jogamp.common.os.DynamicLookupHelper;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
@@ -58,7 +57,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
/**
* Returns the DynamicLookupHelper
*/
- public abstract DynamicLookupHelper getDynamicLookupHelper();
+ public abstract GLDynamicLookupHelper getGLDynamicLookupHelper();
public GLDrawableFactoryImpl getFactoryImpl() {
return (GLDrawableFactoryImpl) getFactory();
@@ -70,11 +69,23 @@ public abstract class GLDrawableImpl implements GLDrawable {
throw new GLException("Should not call this (should only be called for offscreen GLDrawables)");
}
- public void swapBuffers() throws GLException {
+ public final void swapBuffers() throws GLException {
GLCapabilities caps = (GLCapabilities)component.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
if ( caps.getDoubleBuffered() ) {
if(!component.surfaceSwap()) {
- swapBuffersImpl();
+ int lockRes = lockSurface(); // it's recursive, so it's ok within [makeCurrent .. release]
+ if (NativeWindow.LOCK_SURFACE_NOT_READY == lockRes) {
+ return;
+ }
+ try {
+ AbstractGraphicsDevice aDevice = getNativeWindow().getGraphicsConfiguration().getScreen().getDevice();
+ if (NativeWindow.LOCK_SURFACE_CHANGED == lockRes) {
+ updateHandle();
+ }
+ swapBuffersImpl();
+ } finally {
+ unlockSurface();
+ }
}
} else {
GLContext ctx = GLContext.getCurrent();
@@ -84,7 +95,6 @@ public abstract class GLDrawableImpl implements GLDrawable {
}
component.surfaceUpdated(this, component, System.currentTimeMillis());
}
-
protected abstract void swapBuffersImpl();
public static String toHexString(long hex) {
@@ -107,23 +117,45 @@ public abstract class GLDrawableImpl implements GLDrawable {
return component;
}
+ protected void destroyHandle() {}
+ protected void updateHandle() {}
+
+ public long getHandle() {
+ return component.getSurfaceHandle();
+ }
+
public GLDrawableFactory getFactory() {
return factory;
}
- public void setRealized(boolean realized) {
+ public final void setRealized(boolean realized) {
if ( this.realized != realized ) {
if(DEBUG) {
System.err.println("setRealized: "+getClass().getName()+" "+this.realized+" -> "+realized);
}
this.realized = realized;
- setRealizedImpl();
+ if(realized && NativeWindow.LOCK_SURFACE_NOT_READY == lockSurface()) {
+ throw new GLException("X11GLXDrawable.setRealized(true): lockSurface - surface not ready");
+ }
+ try {
+ AbstractGraphicsDevice aDevice = getNativeWindow().getGraphicsConfiguration().getScreen().getDevice();
+ if(!realized) {
+ destroyHandle();
+ }
+ setRealizedImpl();
+ if(realized) {
+ updateHandle();
+ }
+ } finally {
+ if(realized) {
+ unlockSurface();
+ }
+ }
} else if(DEBUG) {
System.err.println("setRealized: "+getClass().getName()+" "+this.realized+" == "+realized);
}
}
protected abstract void setRealizedImpl();
-
public boolean isRealized() {
return realized;
}
@@ -138,9 +170,6 @@ public abstract class GLDrawableImpl implements GLDrawable {
}
public int lockSurface() throws GLException {
- if (!realized) {
- return NativeWindow.LOCK_SURFACE_NOT_READY;
- }
return component.lockSurface();
}
@@ -155,6 +184,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
public String toString() {
return getClass().getName()+"[Realized "+isRealized()+
",\n\tFactory "+getFactory()+
+ ",\n\thandle "+toHexString(getHandle())+
",\n\tWindow "+getNativeWindow()+"]";
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDynamicLibraryBundleInfo.java
new file mode 100755
index 000000000..dd196c4a1
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDynamicLibraryBundleInfo.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2010, Sven Gothel
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sven Gothel nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Sven Gothel BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.jogamp.opengl.impl;
+
+import com.jogamp.common.os.DynamicLibraryBundleInfo;
+import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.common.os.NativeLibrary;
+import java.util.*;
+import java.security.*;
+import javax.media.opengl.GLException;
+
+public abstract class GLDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
+ static List/*<String>*/ glueLibNamesPreload;
+ static {
+ glueLibNamesPreload = new ArrayList();
+ glueLibNamesPreload.add("nativewindow_x11");
+ }
+
+ protected GLDynamicLibraryBundleInfo() {
+ }
+
+ /** default **/
+ public boolean shallLinkGlobal() { return false; }
+
+ /** default **/
+ public boolean shallLookupGlobal() { return false; }
+
+ public static List/*<String>*/ getGlueLibNamesPreload() {
+ return glueLibNamesPreload;
+ }
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDynamicLookupHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDynamicLookupHelper.java
new file mode 100755
index 000000000..89dbb4a78
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDynamicLookupHelper.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010, Sven Gothel
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sven Gothel nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Sven Gothel BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.jogamp.opengl.impl;
+
+import com.jogamp.common.os.DynamicLibraryBundle;
+import com.jogamp.common.os.DynamicLibraryBundleInfo;
+import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.common.os.NativeLibrary;
+import java.util.*;
+import java.security.*;
+import javax.media.opengl.GLException;
+
+public class GLDynamicLookupHelper extends DynamicLibraryBundle {
+
+ public GLDynamicLookupHelper(GLDynamicLibraryBundleInfo info) {
+ super(info);
+ }
+
+ public GLDynamicLibraryBundleInfo getGLBundleInfo() { return (GLDynamicLibraryBundleInfo) getBundleInfo(); }
+
+ /** NOP per default */
+ public boolean loadGLULibrary() { return false; }
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLJNILibLoader.java b/src/jogl/classes/com/jogamp/opengl/impl/GLJNILibLoader.java
index c3958eedf..1daf3358b 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLJNILibLoader.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLJNILibLoader.java
@@ -58,52 +58,6 @@ public class GLJNILibLoader extends JNILibLoaderBase {
});
}
- public static void loadGLDesktop() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- loadLibrary("jogl_desktop", nativeOSPreload, true);
- return null;
- }
- });
- }
-
- public static void loadGLDesktopES12() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- loadLibrary("jogl_gl2es12", nativeOSPreload, true);
- return null;
- }
- });
- }
-
- public static void loadES2() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- loadLibrary("jogl_es2", nativeOSPreload, true);
- return null;
- }
- });
- }
-
- public static void loadES1() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- loadLibrary("jogl_es1", nativeOSPreload, true);
- return null;
- }
- });
- }
-
- public static void loadCgImpl() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- String[] preload = { "nativewindow", "cg", "cgGL" };
- loadLibrary("jogl_cg", preload, true);
- return null;
- }
- });
- }
-
private static final String[] nativeOSPreload = { "nativewindow_x11" };
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java
index 1da19663a..eb5e09d2f 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLPbufferImpl.java
@@ -48,6 +48,7 @@ import java.beans.PropertyChangeListener;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
+import com.jogamp.nativewindow.impl.RecursiveToolkitLock;
/** Platform-independent class exposing pbuffer functionality to
applications. This class is not exposed in the public API as it
@@ -99,6 +100,10 @@ public class GLPbufferImpl implements GLPbuffer {
return pbufferDrawable.getNativeWindow();
}
+ public long getHandle() {
+ return pbufferDrawable.getHandle();
+ }
+
public GLDrawableFactory getFactory() {
return pbufferDrawable.getFactory();
}
@@ -194,19 +199,23 @@ public class GLPbufferImpl implements GLPbuffer {
return pbufferDrawable.getGLProfile();
}
- private boolean surfaceLocked = false;
+ private RecursiveToolkitLock recurLock = new RecursiveToolkitLock();
public int lockSurface() throws GLException {
- surfaceLocked=true;
+ recurLock.lock();
return NativeWindow.LOCK_SUCCESS;
}
public void unlockSurface() {
- surfaceLocked=false;
+ recurLock.unlock();
}
public boolean isSurfaceLocked() {
- return surfaceLocked;
+ return recurLock.isLocked();
+ }
+
+ public Exception getLockedStack() {
+ return recurLock.getLockedStack();
}
//----------------------------------------------------------------------
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLStateTracker.java b/src/jogl/classes/com/jogamp/opengl/impl/GLStateTracker.java
index 744e7b924..9d896b7f8 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLStateTracker.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLStateTracker.java
@@ -39,8 +39,10 @@
package com.jogamp.opengl.impl;
-import java.util.*;
+import java.util.List;
+import java.util.ArrayList;
import javax.media.opengl.*;
+import com.jogamp.common.util.IntIntHashMap;
/**
* Tracks as closely as possible OpenGL states.
@@ -54,24 +56,27 @@ public class GLStateTracker {
private volatile boolean enabled = true;
- private Map/*<Integer,Integer>*/ pixelStateMap = new HashMap/*<Integer,Integer>*/();
+ private IntIntHashMap pixelStateMap;
static class SavedState {
SavedState() {
this.pixelStateMap = null;
}
- void putPixelStateMap(Map pixelStateMap) {
- this.pixelStateMap = new HashMap();
+ void putPixelStateMap(IntIntHashMap pixelStateMap) {
+ this.pixelStateMap = new IntIntHashMap();
+ this.pixelStateMap.setKeyNotFoundValue(-1);
this.pixelStateMap.putAll(pixelStateMap);
}
- Map getPixelStateMap() { return pixelStateMap; }
+ IntIntHashMap getPixelStateMap() { return pixelStateMap; }
- private Map pixelStateMap;
+ private IntIntHashMap pixelStateMap;
// private Map otherStateMap;
}
private List/*<SavedState>*/ stack = new ArrayList();
public GLStateTracker() {
+ pixelStateMap = new IntIntHashMap();
+ pixelStateMap.setKeyNotFoundValue(-1);
resetStates();
}
@@ -88,34 +93,26 @@ public class GLStateTracker {
return enabled;
}
+ /** @return true if found in our map, otherwise false,
+ * which forces the caller to query GL. */
public boolean getInt(int pname, int[] params, int params_offset) {
if(enabled) {
- Integer key = boxKey(pname);
- if(null!=key) {
- Integer value = (Integer) pixelStateMap.get(key);
- if(null!=value) {
- params[params_offset] = value.intValue();
- } else {
- GLException re = new GLException("Key (0x"+Integer.toHexString(key.intValue())+") is not mapped");
- throw re;
- }
+ int value = pixelStateMap.get(pname);
+ if(0 <= value) {
+ params[params_offset] = value;
return true;
}
}
return false;
}
+ /** @return true if found in our map, otherwise false,
+ * which forces the caller to query GL. */
public boolean getInt(int pname, java.nio.IntBuffer params, int dummy) {
if(enabled) {
- Integer key = boxKey(pname);
- if(null!=key) {
- Integer value = (Integer) pixelStateMap.get(key);
- if(null!=value) {
- params.put(params.position(), value.intValue());
- } else {
- GLException re = new GLException("Key (0x"+Integer.toHexString(key.intValue())+") is not mapped");
- throw re;
- }
+ int value = pixelStateMap.get(pname);
+ if(0 <= value) {
+ params.put(params.position(), value);
return true;
}
}
@@ -124,10 +121,7 @@ public class GLStateTracker {
public void setInt(int pname, int param) {
if(enabled) {
- Integer key = boxKey(pname);
- if(null!=key) {
- pixelStateMap.put(key, boxInt(param));
- }
+ pixelStateMap.put(pname, param);
}
}
@@ -151,7 +145,8 @@ public class GLStateTracker {
throw new GLException("null stack element (remaining stack size "+stack.size()+")");
}
- Map/*<Integer,Integer>*/ pixelStateMapNew = new HashMap/*<Integer,Integer>*/();
+ IntIntHashMap pixelStateMapNew = new IntIntHashMap();
+ pixelStateMapNew.setKeyNotFoundValue(-1);
if ( null != state.getPixelStateMap() ) {
pixelStateMapNew.putAll(state.getPixelStateMap());
}
@@ -159,80 +154,26 @@ public class GLStateTracker {
}
}
- private static final Integer GL_PACK_SWAP_BYTES = new Integer(GL2GL3.GL_PACK_SWAP_BYTES);
- private static final Integer GL_PACK_LSB_FIRST = new Integer(GL2GL3.GL_PACK_LSB_FIRST);
- private static final Integer GL_PACK_ROW_LENGTH = new Integer(GL2GL3.GL_PACK_ROW_LENGTH);
- private static final Integer GL_PACK_SKIP_ROWS = new Integer(GL2GL3.GL_PACK_SKIP_ROWS);
- private static final Integer GL_PACK_SKIP_PIXELS = new Integer(GL2GL3.GL_PACK_SKIP_PIXELS);
- private static final Integer GL_PACK_ALIGNMENT = new Integer(GL.GL_PACK_ALIGNMENT);
- private static final Integer GL_PACK_IMAGE_HEIGHT = new Integer(GL2GL3.GL_PACK_IMAGE_HEIGHT);
- private static final Integer GL_PACK_SKIP_IMAGES = new Integer(GL2GL3.GL_PACK_SKIP_IMAGES);
-
- private static final Integer GL_UNPACK_SWAP_BYTES = new Integer(GL2GL3.GL_UNPACK_SWAP_BYTES);
- private static final Integer GL_UNPACK_LSB_FIRST = new Integer(GL2GL3.GL_UNPACK_LSB_FIRST);
- private static final Integer GL_UNPACK_ROW_LENGTH = new Integer(GL2GL3.GL_UNPACK_ROW_LENGTH);
- private static final Integer GL_UNPACK_SKIP_ROWS = new Integer(GL2GL3.GL_UNPACK_SKIP_ROWS);
- private static final Integer GL_UNPACK_SKIP_PIXELS = new Integer(GL2GL3.GL_UNPACK_SKIP_PIXELS);
- private static final Integer GL_UNPACK_ALIGNMENT = new Integer(GL.GL_UNPACK_ALIGNMENT);
- private static final Integer GL_UNPACK_IMAGE_HEIGHT = new Integer(GL2GL3.GL_UNPACK_IMAGE_HEIGHT);
- private static final Integer GL_UNPACK_SKIP_IMAGES = new Integer(GL2GL3.GL_UNPACK_SKIP_IMAGES);
-
- private static final Integer zero = new Integer(0);
- private static final Integer one = new Integer(1);
-
- private static Integer boxKey(int key) {
- switch (key) {
- case 0: return zero;
- case GL2GL3.GL_PACK_SWAP_BYTES: return GL_PACK_SWAP_BYTES;
- case GL2GL3.GL_PACK_LSB_FIRST: return GL_PACK_LSB_FIRST;
- case GL2GL3.GL_PACK_ROW_LENGTH: return GL_PACK_ROW_LENGTH;
- case GL2GL3.GL_PACK_SKIP_ROWS: return GL_PACK_SKIP_ROWS;
- case GL2GL3.GL_PACK_SKIP_PIXELS: return GL_PACK_SKIP_PIXELS;
- case GL.GL_PACK_ALIGNMENT: return GL_PACK_ALIGNMENT;
- case GL2GL3.GL_PACK_IMAGE_HEIGHT: return GL_PACK_IMAGE_HEIGHT;
- case GL2GL3.GL_PACK_SKIP_IMAGES: return GL_PACK_SKIP_IMAGES;
-
- case GL2GL3.GL_UNPACK_SWAP_BYTES: return GL_UNPACK_SWAP_BYTES;
- case GL2GL3.GL_UNPACK_LSB_FIRST: return GL_UNPACK_LSB_FIRST;
- case GL2GL3.GL_UNPACK_ROW_LENGTH: return GL_UNPACK_ROW_LENGTH;
- case GL2GL3.GL_UNPACK_SKIP_ROWS: return GL_UNPACK_SKIP_ROWS;
- case GL2GL3.GL_UNPACK_SKIP_PIXELS: return GL_UNPACK_SKIP_PIXELS;
- case GL.GL_UNPACK_ALIGNMENT: return GL_UNPACK_ALIGNMENT;
- case GL2GL3.GL_UNPACK_IMAGE_HEIGHT: return GL_UNPACK_IMAGE_HEIGHT;
- case GL2GL3.GL_UNPACK_SKIP_IMAGES: return GL_UNPACK_SKIP_IMAGES;
-
- default: return null;
- }
- }
-
public void resetStates() {
pixelStateMap.clear();
- pixelStateMap.put(GL_PACK_SWAP_BYTES, zero /* GL_FALSE */);
- pixelStateMap.put(GL_PACK_LSB_FIRST, zero /* GL_FALSE */);
- pixelStateMap.put(GL_PACK_ROW_LENGTH, zero);
- pixelStateMap.put(GL_PACK_SKIP_ROWS, zero);
- pixelStateMap.put(GL_PACK_SKIP_PIXELS, zero);
- pixelStateMap.put(GL_PACK_ALIGNMENT, new Integer(4));
- pixelStateMap.put(GL_PACK_IMAGE_HEIGHT, zero);
- pixelStateMap.put(GL_PACK_SKIP_IMAGES, zero);
-
- pixelStateMap.put(GL_UNPACK_SWAP_BYTES, zero /* GL_FALSE */);
- pixelStateMap.put(GL_UNPACK_LSB_FIRST, zero /* GL_FALSE */);
- pixelStateMap.put(GL_UNPACK_ROW_LENGTH, zero);
- pixelStateMap.put(GL_UNPACK_SKIP_ROWS, zero);
- pixelStateMap.put(GL_UNPACK_SKIP_PIXELS, zero);
- pixelStateMap.put(GL_UNPACK_ALIGNMENT, new Integer(4));
- pixelStateMap.put(GL_UNPACK_IMAGE_HEIGHT, zero);
- pixelStateMap.put(GL_UNPACK_SKIP_IMAGES, zero);
- }
-
- private static Integer boxInt(int value) {
- switch (value) {
- case 0: return zero;
- case 1: return one;
-
- default: return new Integer(value);
- }
+ pixelStateMap.put(GL.GL_PACK_ALIGNMENT, 4);
+ pixelStateMap.put(GL2GL3.GL_PACK_SWAP_BYTES, 0 /* GL_FALSE */);
+ pixelStateMap.put(GL2GL3.GL_PACK_LSB_FIRST, 0 /* GL_FALSE */);
+ pixelStateMap.put(GL2GL3.GL_PACK_ROW_LENGTH, 0);
+ pixelStateMap.put(GL2GL3.GL_PACK_SKIP_ROWS, 0);
+ pixelStateMap.put(GL2GL3.GL_PACK_SKIP_PIXELS, 0);
+ pixelStateMap.put(GL2GL3.GL_PACK_IMAGE_HEIGHT, 0);
+ pixelStateMap.put(GL2GL3.GL_PACK_SKIP_IMAGES, 0);
+
+ pixelStateMap.put(GL.GL_UNPACK_ALIGNMENT, 4);
+ pixelStateMap.put(GL2GL3.GL_UNPACK_SWAP_BYTES, 0 /* GL_FALSE */);
+ pixelStateMap.put(GL2GL3.GL_UNPACK_LSB_FIRST, 0 /* GL_FALSE */);
+ pixelStateMap.put(GL2GL3.GL_UNPACK_ROW_LENGTH, 0);
+ pixelStateMap.put(GL2GL3.GL_UNPACK_SKIP_ROWS, 0);
+ pixelStateMap.put(GL2GL3.GL_UNPACK_SKIP_PIXELS, 0);
+ pixelStateMap.put(GL2GL3.GL_UNPACK_IMAGE_HEIGHT, 0);
+ pixelStateMap.put(GL2GL3.GL_UNPACK_SKIP_IMAGES, 0);
}
}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/InternalBufferUtil.java.javame_cdc_fp b/src/jogl/classes/com/jogamp/opengl/impl/InternalBufferUtil.java.javame_cdc_fp
deleted file mode 100644
index 4a0eaa22b..000000000
--- a/src/jogl/classes/com/jogamp/opengl/impl/InternalBufferUtil.java.javame_cdc_fp
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- */
-
-package com.jogamp.opengl.impl;
-
-import java.lang.reflect.*;
-import java.nio.*;
-
-/** Internal copy of selected routines from BufferUtil to avoid
- outward dependencies on com.jogamp.opengl.util package. */
-public class InternalBufferUtil {
- public static final int SIZEOF_BYTE = 1;
- public static final int SIZEOF_SHORT = 2;
- public static final int SIZEOF_INT = 4;
- public static final int SIZEOF_FLOAT = 4;
-
- //----------------------------------------------------------------------
- // Allocation routines
- //
-
- /** Allocates a new direct ByteBuffer with the specified number of
- elements. The returned buffer will have its byte order set to
- the host platform's native byte order. */
- public static ByteBuffer newByteBuffer(int numElements) {
- ByteBuffer bb = ByteBuffer.allocateDirect(numElements);
- nativeOrder(bb);
- return bb;
- }
-
- /** Allocates a new direct IntBuffer with the specified number of
- elements. The returned buffer will have its byte order set to
- the host platform's native byte order. */
- public static IntBuffer newIntBuffer(int numElements) {
- ByteBuffer bb = newByteBuffer(numElements * SIZEOF_INT);
- return bb.asIntBuffer();
- }
-
- /** Allocates a new direct ShortBuffer with the specified number of
- elements. The returned buffer will have its byte order set to
- the host platform's native byte order. */
- public static ShortBuffer newShortBuffer(int numElements) {
- ByteBuffer bb = newByteBuffer(numElements * SIZEOF_SHORT);
- return bb.asShortBuffer();
- }
-
- /** Allocates a new direct FloatBuffer with the specified number of
- elements. The returned buffer will have its byte order set to
- the host platform's native byte order. */
- public static FloatBuffer newFloatBuffer(int numElements) {
- ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT);
- return bb.asFloatBuffer();
- }
-
- //----------------------------------------------------------------------
- // Copy routines (type-to-type)
- //
-
- /** Copies the <i>remaining</i> elements (as defined by
- <code>limit() - position()</code>) in the passed FloatBuffer
- into a newly-allocated direct ByteBuffer. The returned buffer
- will have its byte order set to the host platform's native byte
- order. The position of the newly-allocated buffer will be zero,
- and the position of the passed buffer is unchanged (though its
- mark is changed). */
- public static ByteBuffer copyFloatBufferAsByteBuffer(FloatBuffer orig) {
- ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_FLOAT);
- dest.asFloatBuffer().put(orig);
- dest.rewind();
- return dest;
- }
-
- /** Copies the <i>remaining</i> elements (as defined by
- <code>limit() - position()</code>) in the passed IntBuffer into
- a newly-allocated direct ByteBuffer. The returned buffer will
- have its byte order set to the host platform's native byte
- order. The position of the newly-allocated buffer will be zero,
- and the position of the passed buffer is unchanged (though its
- mark is changed). */
- public static ByteBuffer copyIntBufferAsByteBuffer(IntBuffer orig) {
- ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_INT);
- dest.asIntBuffer().put(orig);
- dest.rewind();
- return dest;
- }
-
- /** Copies the <i>remaining</i> elements (as defined by
- <code>limit() - position()</code>) in the passed ShortBuffer
- into a newly-allocated direct ByteBuffer. The returned buffer
- will have its byte order set to the host platform's native byte
- order. The position of the newly-allocated buffer will be zero,
- and the position of the passed buffer is unchanged (though its
- mark is changed). */
- public static ByteBuffer copyShortBufferAsByteBuffer(ShortBuffer orig) {
- ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_SHORT);
- dest.asShortBuffer().put(orig);
- dest.rewind();
- return dest;
- }
-
- /** Copies the <i>remaining</i> elements (as defined by
- <code>limit() - position()</code>) in the passed ByteBuffer into
- a newly-allocated direct ByteBuffer. The returned buffer will
- have its byte order set to the host platform's native byte
- order. The position of the newly-allocated buffer will be zero,
- and the position of the passed buffer is unchanged (though its
- mark is changed). */
- public static ByteBuffer copyByteBuffer(ByteBuffer orig) {
- ByteBuffer dest = newByteBuffer(orig.remaining());
- dest.put(orig);
- dest.rewind();
- return dest;
- }
-
- //----------------------------------------------------------------------
- // Conversion routines
- //
-
- public static float[] getFloatArray(double[] source) {
- int i=source.length;
- float[] dest = new float[i--];
- while(i>=0) { dest[i]=(float)source[i]; i--; }
- return dest;
- }
-
- public static ByteBuffer nativeOrder(ByteBuffer buf) {
- if (!isCDCFP) {
- try {
- if (byteOrderClass == null) {
- byteOrderClass = Class.forName("java.nio.ByteOrder");
- orderMethod = ByteBuffer.class.getMethod("order", new Class[] { byteOrderClass });
- Method nativeOrderMethod = byteOrderClass.getMethod("nativeOrder", null);
- nativeOrderObject = nativeOrderMethod.invoke(null, null);
- }
- } catch (Throwable t) {
- // Must be running on CDC / FP
- isCDCFP = true;
- }
-
- if (!isCDCFP) {
- try {
- orderMethod.invoke(buf, new Object[] { nativeOrderObject });
- } catch (Throwable t) {
- }
- }
- }
- return buf;
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- // NOTE that this work must be done reflectively at the present time
- // because this code must compile and run correctly on both CDC/FP and J2SE
- private static boolean isCDCFP;
- private static Class byteOrderClass;
- private static Object nativeOrderObject;
- private static Method orderMethod;
-}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/InternalBufferUtil.java.javase b/src/jogl/classes/com/jogamp/opengl/impl/InternalBufferUtil.java.javase
deleted file mode 100644
index 655fa95de..000000000
--- a/src/jogl/classes/com/jogamp/opengl/impl/InternalBufferUtil.java.javase
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- */
-
-package com.jogamp.opengl.impl;
-
-import java.lang.reflect.*;
-import java.nio.*;
-
-/** Internal copy of selected routines from BufferUtil to avoid
- outward dependencies on com.jogamp.opengl.util package. */
-public class InternalBufferUtil {
- public static final int SIZEOF_BYTE = 1;
- public static final int SIZEOF_SHORT = 2;
- public static final int SIZEOF_INT = 4;
- public static final int SIZEOF_FLOAT = 4;
- public static final int SIZEOF_LONG = 8;
- public static final int SIZEOF_DOUBLE = 8;
-
- //----------------------------------------------------------------------
- // Allocation routines
- //
-
- /** Allocates a new direct ByteBuffer with the specified number of
- elements. The returned buffer will have its byte order set to
- the host platform's native byte order. */
- public static ByteBuffer newByteBuffer(int numElements) {
- ByteBuffer bb = ByteBuffer.allocateDirect(numElements);
- nativeOrder(bb);
- return bb;
- }
-
- /** Allocates a new direct DoubleBuffer with the specified number of
- elements. The returned buffer will have its byte order set to
- the host platform's native byte order. */
- public static DoubleBuffer newDoubleBuffer(int numElements) {
- ByteBuffer bb = newByteBuffer(numElements * SIZEOF_DOUBLE);
- return bb.asDoubleBuffer();
- }
-
- /** Allocates a new direct IntBuffer with the specified number of
- elements. The returned buffer will have its byte order set to
- the host platform's native byte order. */
- public static IntBuffer newIntBuffer(int numElements) {
- ByteBuffer bb = newByteBuffer(numElements * SIZEOF_INT);
- return bb.asIntBuffer();
- }
-
- /** Allocates a new direct ShortBuffer with the specified number of
- elements. The returned buffer will have its byte order set to
- the host platform's native byte order. */
- public static ShortBuffer newShortBuffer(int numElements) {
- ByteBuffer bb = newByteBuffer(numElements * SIZEOF_SHORT);
- return bb.asShortBuffer();
- }
-
- /** Allocates a new direct FloatBuffer with the specified number of
- elements. The returned buffer will have its byte order set to
- the host platform's native byte order. */
- public static FloatBuffer newFloatBuffer(int numElements) {
- ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT);
- return bb.asFloatBuffer();
- }
-
- //----------------------------------------------------------------------
- // Copy routines (type-to-ByteBuffer)
- //
-
- /** Copies the <i>remaining</i> elements (as defined by
- <code>limit() - position()</code>) in the passed FloatBuffer
- into a newly-allocated direct ByteBuffer. The returned buffer
- will have its byte order set to the host platform's native byte
- order. The position of the newly-allocated buffer will be zero,
- and the position of the passed buffer is unchanged (though its
- mark is changed). */
- public static ByteBuffer copyFloatBufferAsByteBuffer(FloatBuffer orig) {
- ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_FLOAT);
- dest.asFloatBuffer().put(orig);
- dest.rewind();
- return dest;
- }
-
- /** Copies the <i>remaining</i> elements (as defined by
- <code>limit() - position()</code>) in the passed IntBuffer into
- a newly-allocated direct ByteBuffer. The returned buffer will
- have its byte order set to the host platform's native byte
- order. The position of the newly-allocated buffer will be zero,
- and the position of the passed buffer is unchanged (though its
- mark is changed). */
- public static ByteBuffer copyIntBufferAsByteBuffer(IntBuffer orig) {
- ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_INT);
- dest.asIntBuffer().put(orig);
- dest.rewind();
- return dest;
- }
-
- /** Copies the <i>remaining</i> elements (as defined by
- <code>limit() - position()</code>) in the passed ShortBuffer
- into a newly-allocated direct ByteBuffer. The returned buffer
- will have its byte order set to the host platform's native byte
- order. The position of the newly-allocated buffer will be zero,
- and the position of the passed buffer is unchanged (though its
- mark is changed). */
- public static ByteBuffer copyShortBufferAsByteBuffer(ShortBuffer orig) {
- ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_SHORT);
- dest.asShortBuffer().put(orig);
- dest.rewind();
- return dest;
- }
-
- /** Copies the <i>remaining</i> elements (as defined by
- <code>limit() - position()</code>) in the passed ByteBuffer into
- a newly-allocated direct ByteBuffer. The returned buffer will
- have its byte order set to the host platform's native byte
- order. The position of the newly-allocated buffer will be zero,
- and the position of the passed buffer is unchanged (though its
- mark is changed). */
- public static ByteBuffer copyByteBuffer(ByteBuffer orig) {
- ByteBuffer dest = newByteBuffer(orig.remaining());
- dest.put(orig);
- dest.rewind();
- return dest;
- }
-
- //----------------------------------------------------------------------
- // Conversion routines
- //
-
- public static float[] getFloatArray(double[] source) {
- int i=source.length;
- float[] dest = new float[i--];
- while(i>=0) { dest[i]=(float)source[i]; i--; }
- return dest;
- }
-
- public static ByteBuffer nativeOrder(ByteBuffer buf) {
- if (!isCDCFP) {
- try {
- if (byteOrderClass == null) {
- byteOrderClass = Class.forName("java.nio.ByteOrder");
- orderMethod = ByteBuffer.class.getMethod("order", new Class[] { byteOrderClass });
- Method nativeOrderMethod = byteOrderClass.getMethod("nativeOrder", null);
- nativeOrderObject = nativeOrderMethod.invoke(null, null);
- }
- } catch (Throwable t) {
- // Must be running on CDC / FP
- isCDCFP = true;
- }
-
- if (!isCDCFP) {
- try {
- orderMethod.invoke(buf, new Object[] { nativeOrderObject });
- } catch (Throwable t) {
- }
- }
- }
- return buf;
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- // NOTE that this work must be done reflectively at the present time
- // because this code must compile and run correctly on both CDC/FP and J2SE
- private static boolean isCDCFP;
- private static Class byteOrderClass;
- private static Object nativeOrderObject;
- private static Method orderMethod;
-}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/ProjectFloat.java b/src/jogl/classes/com/jogamp/opengl/impl/ProjectFloat.java
index dbd84c9de..ab277e704 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/ProjectFloat.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/ProjectFloat.java
@@ -118,6 +118,7 @@ import java.nio.*;
import javax.media.opengl.*;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
+import com.jogamp.common.nio.Buffers;
/**
* ProjectFloat.java
@@ -180,7 +181,7 @@ public class ProjectFloat {
// Slice up one big buffer because some NIO implementations
// allocate a huge amount of memory to back even the smallest of
// buffers.
- locbuf = InternalBufferUtil.newFloatBuffer(2*16+2*4+3*3);
+ locbuf = Buffers.newDirectFloatBuffer(2*16+2*4+3*3);
int pos = 0;
int sz = 16;
matrixBuf = slice(locbuf, pos, sz);
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java
index e64b5bcf2..5671b033d 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLContext.java
@@ -84,66 +84,35 @@ public abstract class EGLContext extends GLContextImpl {
protected Map/*<String, String>*/ getExtensionNameMap() { return null; }
- protected int makeCurrentImpl() throws GLException {
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
if(EGL.EGL_NO_DISPLAY==((EGLDrawable)drawable).getDisplay() ) {
throw new GLException("drawable not properly initialized, NO DISPLAY: "+drawable);
}
- if (0 == drawable.getNativeWindow().getSurfaceHandle()) {
- throw new GLException("drawable has invalid surface handle: "+drawable);
- }
- boolean newCreated = false;
- if (!isCreated()) {
- create(); // throws exception if fails!
- newCreated = true;
- if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Created GL context " + toHexString(contextHandle) + " for " + getClass().getName());
- }
- }
if (EGL.eglGetCurrentContext() != contextHandle) {
if (!EGL.eglMakeCurrent(((EGLDrawable)drawable).getDisplay(),
- ((EGLDrawable)drawable).getSurface(),
- ((EGLDrawable)drawableRead).getSurface(),
+ drawable.getHandle(),
+ drawableRead.getHandle(),
contextHandle)) {
throw new GLException("Error making context 0x" +
Long.toHexString(contextHandle) + " current: error code " + EGL.eglGetError());
}
}
-
- if(newCreated) {
- setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_ES|CTX_OPTION_ANY);
- return CONTEXT_CURRENT_NEW;
- }
- return CONTEXT_CURRENT;
}
protected void releaseImpl() throws GLException {
- getDrawableImpl().getFactoryImpl().lockToolkit();
- try {
- if (!EGL.eglMakeCurrent(((EGLDrawable)drawable).getDisplay(),
- EGL.EGL_NO_SURFACE,
- EGL.EGL_NO_SURFACE,
- EGL.EGL_NO_CONTEXT)) {
- throw new GLException("Error freeing OpenGL context 0x" +
- Long.toHexString(contextHandle) + ": error code " + EGL.eglGetError());
- }
- } finally {
- getDrawableImpl().getFactoryImpl().unlockToolkit();
+ if (!EGL.eglMakeCurrent(((EGLDrawable)drawable).getDisplay(),
+ EGL.EGL_NO_SURFACE,
+ EGL.EGL_NO_SURFACE,
+ EGL.EGL_NO_CONTEXT)) {
+ throw new GLException("Error freeing OpenGL context 0x" +
+ Long.toHexString(contextHandle) + ": error code " + EGL.eglGetError());
}
}
protected void destroyImpl() throws GLException {
- getDrawableImpl().getFactoryImpl().lockToolkit();
- try {
- if (contextHandle != 0) {
- if (!EGL.eglDestroyContext(((EGLDrawable)drawable).getDisplay(), contextHandle)) {
- throw new GLException("Error destroying OpenGL context 0x" +
- Long.toHexString(contextHandle) + ": error code " + EGL.eglGetError());
- }
- contextHandle = 0;
- GLContextShareSet.contextDestroyed(this);
- }
- } finally {
- getDrawableImpl().getFactoryImpl().unlockToolkit();
+ if (!EGL.eglDestroyContext(((EGLDrawable)drawable).getDisplay(), contextHandle)) {
+ throw new GLException("Error destroying OpenGL context 0x" +
+ Long.toHexString(contextHandle) + ": error code " + EGL.eglGetError());
}
}
@@ -155,7 +124,7 @@ public abstract class EGLContext extends GLContextImpl {
// FIXME
}
- protected void create() throws GLException {
+ protected boolean createImpl() throws GLException {
long eglDisplay = ((EGLDrawable)drawable).getDisplay();
EGLGraphicsConfiguration config = ((EGLDrawable)drawable).getGraphicsConfiguration();
GLProfile glProfile = drawable.getGLProfile();
@@ -208,19 +177,20 @@ public abstract class EGLContext extends GLContextImpl {
if (DEBUG) {
System.err.println(getThreadName() + ": !!! Created OpenGL context 0x" +
Long.toHexString(contextHandle) +
- ",\n\twrite surface 0x" + Long.toHexString(((EGLDrawable)drawable).getSurface()) +
- ",\n\tread surface 0x" + Long.toHexString(((EGLDrawable)drawableRead).getSurface())+
+ ",\n\twrite surface 0x" + Long.toHexString(drawable.getHandle()) +
+ ",\n\tread surface 0x" + Long.toHexString(drawableRead.getHandle())+
",\n\t"+this+
",\n\tsharing with 0x" + Long.toHexString(shareWith));
}
if (!EGL.eglMakeCurrent(((EGLDrawable)drawable).getDisplay(),
- ((EGLDrawable)drawable).getSurface(),
- ((EGLDrawable)drawableRead).getSurface(),
+ drawable.getHandle(),
+ drawableRead.getHandle(),
contextHandle)) {
throw new GLException("Error making context 0x" +
Long.toHexString(contextHandle) + " current: error code " + EGL.eglGetError());
}
setGLFunctionAvailability(true, glProfile.usesNativeGLES2()?2:1, 0, CTX_PROFILE_ES|CTX_OPTION_ANY);
+ return true;
}
protected void updateGLProcAddressTable(int major, int minor, int ctp) {
@@ -242,22 +212,16 @@ public abstract class EGLContext extends GLContextImpl {
public synchronized String getPlatformExtensionsString() {
if (!eglQueryStringInitialized) {
eglQueryStringAvailable =
- getDrawableImpl().getDynamicLookupHelper().dynamicLookupFunction("eglQueryString") != 0;
+ getDrawableImpl().getGLDynamicLookupHelper().dynamicLookupFunction("eglQueryString") != 0;
eglQueryStringInitialized = true;
}
if (eglQueryStringAvailable) {
- GLDrawableFactoryImpl factory = getDrawableImpl().getFactoryImpl();
- factory.lockToolkit();
- try {
String ret = EGL.eglQueryString(((EGLDrawable)drawable).getDisplay(),
EGL.EGL_EXTENSIONS);
if (DEBUG) {
System.err.println("!!! EGL extensions: " + ret);
}
return ret;
- } finally {
- factory.unlockToolkit();
- }
} else {
return "";
}
@@ -277,7 +241,7 @@ public abstract class EGLContext extends GLContextImpl {
// Currently unimplemented stuff
//
- public void copy(GLContext source, int mask) throws GLException {
+ protected void copyImpl(GLContext source, int mask) throws GLException {
throw new GLException("Not yet implemented");
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java
index 2e24abcec..7eeb19141 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java
@@ -35,7 +35,7 @@
package com.jogamp.opengl.impl.egl;
-import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.opengl.impl.GLDynamicLookupHelper;
import com.jogamp.opengl.impl.GLDrawableImpl;
import javax.media.nativewindow.*;
@@ -60,7 +60,7 @@ public abstract class EGLDrawable extends GLDrawableImpl {
return eglDisplay;
}
- public long getSurface() {
+ public long getHandle() {
return eglSurface;
}
@@ -98,85 +98,83 @@ public abstract class EGLDrawable extends GLDrawableImpl {
protected void setRealizedImpl() {
if (realized) {
- if ( NativeWindow.LOCK_SURFACE_NOT_READY == lockSurface() ) {
- throw new GLException("Couldn't lock surface");
- }
- // lockSurface() also resolved the window/surface handles
- try {
- AbstractGraphicsConfiguration aConfig = component.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice();
- if(aDevice instanceof EGLGraphicsDevice) {
- // just fetch the data .. trust but verify ..
- eglDisplay = aDevice.getHandle();
- if (eglDisplay == EGL.EGL_NO_DISPLAY) {
- throw new GLException("Invalid EGL display in EGLGraphicsDevice from "+aDevice);
+ AbstractGraphicsConfiguration aConfig = component.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice();
+ if(aDevice instanceof EGLGraphicsDevice) {
+ if(DEBUG) {
+ System.err.println("EGLDrawable.setRealized: using existing EGL config: "+this);
+ }
+ // just fetch the data .. trust but verify ..
+ eglDisplay = aDevice.getHandle();
+ if (eglDisplay == EGL.EGL_NO_DISPLAY) {
+ throw new GLException("Invalid EGL display in EGLGraphicsDevice from "+aDevice);
+ }
+ if(aConfig instanceof EGLGraphicsConfiguration) {
+ eglConfig = (EGLGraphicsConfiguration) aConfig; // done ..
+ if (null == eglConfig) {
+ throw new GLException("Null EGLGraphicsConfiguration from "+aConfig);
}
- if(aConfig instanceof EGLGraphicsConfiguration) {
- eglConfig = (EGLGraphicsConfiguration) aConfig; // done ..
- if (null == eglConfig) {
- throw new GLException("Null EGLGraphicsConfiguration from "+aConfig);
- }
- int[] tmp = new int[1];
- if ( 0 != component.getSurfaceHandle() &&
- EGL.eglQuerySurface(eglDisplay, component.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0) ) {
- // component holds static EGLSurface
- eglSurface = component.getSurfaceHandle();
- if(DEBUG) {
- System.err.println("setSurface re-using component's EGLSurface: handle 0x"+Long.toHexString(eglSurface));
- }
- } else {
- // EGLSurface is ours ..
- ownEGLSurface=true;
-
- eglConfig.updateGraphicsConfiguration();
-
- recreateSurface();
+ int[] tmp = new int[1];
+ if ( 0 != component.getSurfaceHandle() &&
+ EGL.eglQuerySurface(eglDisplay, component.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0) ) {
+ // component holds static EGLSurface
+ eglSurface = component.getSurfaceHandle();
+ if(DEBUG) {
+ System.err.println("setSurface re-using component's EGLSurface: handle 0x"+Long.toHexString(eglSurface));
}
} else {
- throw new GLException("EGLGraphicsDevice hold by non EGLGraphicsConfiguration: "+aConfig);
+ // EGLSurface is ours ..
+ ownEGLSurface=true;
+
+ eglConfig.updateGraphicsConfiguration();
+
+ recreateSurface();
}
} else {
- // create a new EGL config ..
- ownEGLDisplay=true;
- // EGLSurface is ours ..
- ownEGLSurface=true;
-
- long nDisplay=0;
- if( NativeWindowFactory.TYPE_WINDOWS.equals(NativeWindowFactory.getNativeWindowType(false)) ) {
- nDisplay = component.getSurfaceHandle(); // don't even ask ..
- } else {
- nDisplay = aDevice.getHandle(); // 0 == EGL.EGL_DEFAULT_DISPLAY
+ throw new GLException("EGLGraphicsDevice hold by non EGLGraphicsConfiguration: "+aConfig);
+ }
+ } else {
+ if(DEBUG) {
+ System.err.println("EGLDrawable.setRealized: creating new EGL config: "+this);
+ }
+ // create a new EGL config ..
+ ownEGLDisplay=true;
+ // EGLSurface is ours ..
+ ownEGLSurface=true;
+
+ long nDisplay=0;
+ if( NativeWindowFactory.TYPE_WINDOWS.equals(NativeWindowFactory.getNativeWindowType(false)) ) {
+ nDisplay = component.getSurfaceHandle(); // don't even ask ..
+ } else {
+ nDisplay = aDevice.getHandle(); // 0 == EGL.EGL_DEFAULT_DISPLAY
+ }
+ eglDisplay = EGL.eglGetDisplay(nDisplay);
+ if (eglDisplay == EGL.EGL_NO_DISPLAY) {
+ if(DEBUG) {
+ System.err.println("eglDisplay("+Long.toHexString(nDisplay)+" <surfaceHandle>): failed, using EGL_DEFAULT_DISPLAY");
}
+ nDisplay = EGL.EGL_DEFAULT_DISPLAY;
eglDisplay = EGL.eglGetDisplay(nDisplay);
- if (eglDisplay == EGL.EGL_NO_DISPLAY) {
- if(DEBUG) {
- System.err.println("eglDisplay("+Long.toHexString(nDisplay)+" <surfaceHandle>): failed, using EGL_DEFAULT_DISPLAY");
- }
- nDisplay = EGL.EGL_DEFAULT_DISPLAY;
- eglDisplay = EGL.eglGetDisplay(nDisplay);
- }
- if (eglDisplay == EGL.EGL_NO_DISPLAY) {
- throw new GLException("Failed to created EGL display: nhandle 0x"+Long.toHexString(nDisplay)+", "+aDevice+", error 0x"+Integer.toHexString(EGL.eglGetError()));
- } else if(DEBUG) {
- System.err.println("eglDisplay("+Long.toHexString(nDisplay)+"): 0x"+Long.toHexString(eglDisplay));
- }
- if (!EGL.eglInitialize(eglDisplay, null, null)) {
- throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError()));
- }
- EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay);
- DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, aConfig.getScreen().getIndex());
- GLCapabilities caps = (GLCapabilities) aConfig.getChosenCapabilities(); // yes, use the already choosen Capabilities (x11,win32,..)
- eglConfig = (EGLGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(e).chooseGraphicsConfiguration(caps, null, s);
- if (null == eglConfig) {
- throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);
- } else if(DEBUG) {
- System.err.println("Chosen eglConfig: "+eglConfig);
- }
- recreateSurface();
}
- } finally {
- unlockSurface();
+ if (eglDisplay == EGL.EGL_NO_DISPLAY) {
+ throw new GLException("Failed to created EGL display: nhandle 0x"+Long.toHexString(nDisplay)+", "+aDevice+", error 0x"+Integer.toHexString(EGL.eglGetError()));
+ } else if(DEBUG) {
+ System.err.println("eglDisplay("+Long.toHexString(nDisplay)+"): 0x"+Long.toHexString(eglDisplay));
+ }
+ if (!EGL.eglInitialize(eglDisplay, null, null)) {
+ throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError()));
+ }
+ EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay);
+ DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, aConfig.getScreen().getIndex());
+ GLCapabilities caps = (GLCapabilities) aConfig.getChosenCapabilities(); // yes, use the already choosen Capabilities (x11,win32,..)
+ eglConfig = (EGLGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(e).chooseGraphicsConfiguration(caps, null, s);
+ if (null == eglConfig) {
+ throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);
+ } else if(DEBUG) {
+ System.err.println("Chosen eglConfig: "+eglConfig);
+ }
+ recreateSurface();
}
} else if (ownEGLSurface && eglSurface != EGL.EGL_NO_SURFACE) {
// Destroy the window surface
@@ -208,8 +206,14 @@ public abstract class EGLDrawable extends GLDrawableImpl {
return tmp[0];
}
- public DynamicLookupHelper getDynamicLookupHelper() {
- return EGLDynamicLookupHelper.getDynamicLookupHelper(getGLProfile());
+ public GLDynamicLookupHelper getGLDynamicLookupHelper() {
+ if (getGLProfile().usesNativeGLES2()) {
+ return getFactoryImpl().getGLDynamicLookupHelper(2);
+ } else if (getGLProfile().usesNativeGLES1()) {
+ return getFactoryImpl().getGLDynamicLookupHelper(1);
+ } else {
+ throw new GLException("Unsupported: "+getGLProfile());
+ }
}
public String toString() {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
index fb0da9c40..935281c6c 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java
@@ -44,6 +44,9 @@ import com.jogamp.nativewindow.impl.NullWindow;
public class EGLDrawableFactory extends GLDrawableFactoryImpl {
+ private static final GLDynamicLookupHelper eglES1DynamicLookupHelper;
+ private static final GLDynamicLookupHelper eglES2DynamicLookupHelper;
+
static {
// Register our GraphicsConfigurationFactory implementations
// The act of constructing them causes them to be registered
@@ -55,12 +58,58 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
ReflectionUtil.createInstance("com.jogamp.opengl.impl.x11.glx.X11GLXGraphicsConfigurationFactory");
} catch (JogampRuntimeException jre) { /* n/a .. */ }
}
+
+ // FIXME: Probably need to move EGL from a static model
+ // to a dynamic one, where there can be 2 instances
+ // for each ES profile with their own ProcAddressTable.
+
+ GLDynamicLookupHelper tmp=null;
+ try {
+ tmp = new GLDynamicLookupHelper(new EGLES1DynamicLibraryBundleInfo());
+ } catch (GLException gle) {
+ if(DEBUG) {
+ gle.printStackTrace();
+ }
+ }
+ eglES1DynamicLookupHelper = tmp;
+ if(null!=eglES1DynamicLookupHelper && eglES1DynamicLookupHelper.isLibComplete()) {
+ EGL.resetProcAddressTable(eglES1DynamicLookupHelper);
+ }
+
+ tmp=null;
+ try {
+ tmp = new GLDynamicLookupHelper(new EGLES2DynamicLibraryBundleInfo());
+ } catch (GLException gle) {
+ if(DEBUG) {
+ gle.printStackTrace();
+ }
+ }
+ eglES2DynamicLookupHelper = tmp;
+ if(null!=eglES2DynamicLookupHelper && eglES2DynamicLookupHelper.isLibComplete()) {
+ EGL.resetProcAddressTable(eglES2DynamicLookupHelper);
+ }
}
public EGLDrawableFactory() {
super();
}
+ public GLDynamicLookupHelper getGLDynamicLookupHelper(int esProfile) {
+ if (2==esProfile) {
+ if(null==eglES2DynamicLookupHelper) {
+ throw new GLException("GLDynamicLookupHelper for ES2 not available");
+ }
+ return eglES2DynamicLookupHelper;
+ } else if (1==esProfile) {
+ if(null==eglES1DynamicLookupHelper) {
+ throw new GLException("GLDynamicLookupHelper for ES1 not available");
+ }
+ return eglES1DynamicLookupHelper;
+ } else {
+ throw new GLException("Unsupported: ES"+esProfile);
+ }
+ }
+
protected void shutdown() {}
protected final GLDrawableImpl getSharedDrawable() { return null; }
protected final GLContextImpl getSharedContext() { return null; }
@@ -103,9 +152,6 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
throw new GLException("Not yet implemented");
}
- public void loadGLULibrary() {
- }
-
public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) {
return false;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLibraryBundleInfo.java
new file mode 100755
index 000000000..675be64b5
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLibraryBundleInfo.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2010, Sven Gothel
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sven Gothel nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Sven Gothel BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.jogamp.opengl.impl.egl;
+
+import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.common.os.NativeLibrary;
+import java.util.*;
+import javax.media.nativewindow.*;
+import javax.media.opengl.*;
+import com.jogamp.opengl.impl.*;
+import java.security.*;
+
+/**
+ * Abstract implementation of the DynamicLookupHelper for EGL,
+ * which decouples it's dependencies to EGLDrawable.
+ *
+ * Currently two implementations exist, one for ES1 and one for ES2.
+ */
+public abstract class EGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundleInfo {
+
+ protected EGLDynamicLibraryBundleInfo() {
+ super();
+ }
+
+ /** Might be a desktop GL library, and might need to allow symbol access to subsequent libs */
+ public boolean shallLinkGlobal() { return true; }
+
+ public final List getToolGetProcAddressFuncNameList() {
+ List res = new ArrayList();
+ res.add("eglGetProcAddress");
+ return res;
+ }
+
+ public final long toolDynamicLookupFunction(long toolGetProcAddressHandle, String funcName) {
+ return EGL.eglGetProcAddress(toolGetProcAddressHandle, funcName);
+ }
+
+ protected List/*<String>*/ getEGLLibNamesList() {
+ List/*<String>*/ eglLibNames = new ArrayList();
+ // EGL
+ eglLibNames.add("EGL");
+ // for windows distributions using the 'unlike' lib prefix,
+ // where our tool does not add it.
+ eglLibNames.add("libEGL");
+ return eglLibNames;
+ }
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLookupHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLookupHelper.java
deleted file mode 100755
index 9e34dc9e9..000000000
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDynamicLookupHelper.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl.impl.egl;
-
-import com.jogamp.common.os.DynamicLookupHelper;
-import com.jogamp.common.os.NativeLibrary;
-import java.util.*;
-import javax.media.nativewindow.*;
-import javax.media.opengl.*;
-import com.jogamp.opengl.impl.*;
-import java.security.*;
-
-/**
- * Abstract implementation of the DynamicLookupHelper for EGL,
- * which decouples it's dependencies to EGLDrawableFactory.
- *
- * Currently two implementations exist, one for ES1 and one for ES2.
- */
-public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper {
- protected static final boolean DEBUG = com.jogamp.opengl.impl.Debug.debug("EGL");
- protected static final boolean DEBUG_LOOKUP;
-
- private static final EGLDynamicLookupHelper eglES1DynamicLookupHelper;
- private static final EGLDynamicLookupHelper eglES2DynamicLookupHelper;
- private List/*<NativeLibrary>*/ glesLibraries;
-
- static {
- AccessControlContext localACC=AccessController.getContext();
- DEBUG_LOOKUP = com.jogamp.opengl.impl.Debug.isPropertyDefined("jogl.debug.DynamicLookup", true, localACC);
-
- EGLDynamicLookupHelper tmp=null;
- try {
- tmp = new EGLES1DynamicLookupHelper();
- } catch (GLException gle) {
- if(DEBUG) {
- gle.printStackTrace();
- }
- }
- eglES1DynamicLookupHelper = tmp;
-
- tmp=null;
- try {
- tmp = new EGLES2DynamicLookupHelper();
- } catch (GLException gle) {
- if(DEBUG) {
- gle.printStackTrace();
- }
- }
- eglES2DynamicLookupHelper = tmp;
- }
-
- public static EGLDynamicLookupHelper getDynamicLookupHelper(GLProfile glp) {
- if (glp.usesNativeGLES2()) {
- if(null==eglES2DynamicLookupHelper) {
- throw new GLException("EGLDynamicLookupHelper for ES2 not available");
- }
- return eglES2DynamicLookupHelper;
- } else if (glp.usesNativeGLES1()) {
- if(null==eglES1DynamicLookupHelper) {
- throw new GLException("EGLDynamicLookupHelper for ES1 not available");
- }
- return eglES1DynamicLookupHelper;
- } else {
- throw new GLException("Unsupported: "+glp);
- }
- }
-
- public static EGLDynamicLookupHelper getDynamicLookupHelper(int esProfile) {
- if (2==esProfile) {
- if(null==eglES2DynamicLookupHelper) {
- throw new GLException("EGLDynamicLookupHelper for ES2 not available");
- }
- return eglES2DynamicLookupHelper;
- } else if (1==esProfile) {
- if(null==eglES1DynamicLookupHelper) {
- throw new GLException("EGLDynamicLookupHelper for ES1 not available");
- }
- return eglES1DynamicLookupHelper;
- } else {
- throw new GLException("Unsupported: ES"+esProfile);
- }
- }
-
- protected EGLDynamicLookupHelper() {
- loadGLESLibrary(getESProfile());
- EGL.resetProcAddressTable(this);
- }
-
- /** Must return the proper ES profile number, 1 for ES1 and 2 for ES2 */
- protected abstract int getESProfile();
-
- /** Must return at least one OpenGL ES library name */
- protected abstract List/*<String>*/ getGLESLibNames();
-
- /** May return OpenGL ES library name(s) */
- protected List/*<String>*/ getEGLLibNames() {
- List/*<String>*/ eglLibNames = new ArrayList();
-
- // EGL
- eglLibNames.add("EGL");
- // for windows distributions using the 'unlike' lib prefix,
- // where our tool does not add it.
- eglLibNames.add("libEGL");
-
- return eglLibNames;
- }
-
- private NativeLibrary loadFirstAvailable(List/*<String>*/ libNames, ClassLoader loader) {
- for (Iterator iter = libNames.iterator(); iter.hasNext(); ) {
- NativeLibrary lib = NativeLibrary.open((String) iter.next(), loader, false /*global*/);
- if (lib != null) {
- return lib;
- }
- }
- return null;
- }
-
- private boolean loadEGLLibrary(ClassLoader loader, List/*<String>*/ eglLibNames) {
- NativeLibrary lib = null;
- if(null!=eglLibNames && eglLibNames.size()>0) {
- // EGL libraries ..
- lib = loadFirstAvailable(eglLibNames, loader);
- if ( null != lib ) {
- glesLibraries.add(lib);
- }
- }
- return null!=lib;
- }
-
- private void loadGLESLibrary(int esProfile) {
- List/*<String>*/ glesLibNames = getGLESLibNames();
- List/*<String>*/ eglLibNames = getEGLLibNames();
- boolean eglLoaded = false;
-
- ClassLoader loader = getClass().getClassLoader();
- NativeLibrary lib = null;
-
- glesLibraries = new ArrayList();
-
- // ES libraries ..
- lib = loadFirstAvailable(glesLibNames, loader);
- if ( null == lib ) {
- /*** FIXME: Have to think about this ..
- // try again with EGL loaded first ..
- if ( !eglLoaded && loadEGLLibrary(loader, eglLibNames) ) {
- eglLoaded = true ;
- lib = loadFirstAvailable(glesLibNames, loader);
- }
- if ( null == lib ) {
- throw new GLException("Unable to dynamically load OpenGL ES library for profile ES" + esProfile);
- } */
- throw new GLException("Unable to dynamically load OpenGL ES library for profile ES" + esProfile);
- }
- glesLibraries.add(lib);
-
- if ( !eglLoaded && !loadEGLLibrary(loader, eglLibNames) ) {
- throw new GLException("Unable to dynamically load EGL library for profile ES" + esProfile);
- }
-
- if (esProfile==2) {
- GLJNILibLoader.loadES2();
- } else if (esProfile==1) {
- GLJNILibLoader.loadES1();
- } else {
- throw new GLException("Unsupported: ES"+esProfile);
- }
- }
-
- private long dynamicLookupFunctionOnLibs(String glFuncName) {
- String funcName=glFuncName;
- long addr = dynamicLookupFunctionOnLibsImpl(funcName);
- if( 0==addr && NativeWindowFactory.TYPE_WINDOWS.equals(NativeWindowFactory.getNativeWindowType(false)) ) {
- // Hack: try some C++ decoration here for Imageon's emulation libraries ..
- final int argAlignment=4; // 4 byte alignment of each argument
- final int maxArguments=12; // experience ..
- for(int arg=0; 0==addr && arg<=maxArguments; arg++) {
- funcName = "_"+glFuncName+"@"+(arg*argAlignment);
- addr = dynamicLookupFunctionOnLibsImpl(funcName);
- }
- }
- if(DEBUG_LOOKUP) {
- if(0!=addr) {
- System.err.println("Lookup-Native: "+glFuncName+" / "+funcName+" 0x"+Long.toHexString(addr));
- } else {
- System.err.println("Lookup-Native: "+glFuncName+" / "+funcName+" ** FAILED ** ");
- }
- }
- return addr;
- }
-
- private long dynamicLookupFunctionOnLibsImpl(String glFuncName) {
- // Look up this function name in all known libraries
- for (Iterator iter = glesLibraries.iterator(); iter.hasNext(); ) {
- NativeLibrary lib = (NativeLibrary) iter.next();
- long addr = lib.dynamicLookupFunction(glFuncName);
- if (addr != 0) {
- return addr;
- }
- }
- return 0;
- }
-
- private long eglGetProcAddressHandle = 0;
-
- public long dynamicLookupFunction(String glFuncName) {
- if(null==glFuncName) {
- return 0;
- }
-
- // bootstrap eglGetProcAddress
- if(0==eglGetProcAddressHandle) {
- eglGetProcAddressHandle = dynamicLookupFunctionOnLibs("eglGetProcAddress");
- if(0==eglGetProcAddressHandle) {
- GLException e = new GLException("Couldn't find eglGetProcAddress function entry");
- if(DEBUG) {
- e.printStackTrace();
- }
- throw e;
- }
- }
-
- if(glFuncName.equals("eglGetProcAddress")) {
- return eglGetProcAddressHandle;
- }
-
- long addr = EGL.eglGetProcAddress(eglGetProcAddressHandle, glFuncName);
- if(DEBUG_LOOKUP) {
- if(0!=addr) {
- System.err.println("Lookup-EGL: <"+glFuncName+"> 0x"+Long.toHexString(addr));
- }
- }
- if(0==addr) {
- addr = dynamicLookupFunctionOnLibs(glFuncName);
- }
- return addr;
- }
-}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES1DynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES1DynamicLibraryBundleInfo.java
new file mode 100755
index 000000000..aad25edc4
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES1DynamicLibraryBundleInfo.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2010, Sven Gothel
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sven Gothel nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Sven Gothel BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.jogamp.opengl.impl.egl;
+
+import java.util.*;
+import com.jogamp.opengl.impl.*;
+
+public class EGLES1DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo {
+ static List/*<String>*/ glueLibNames;
+ static {
+ glueLibNames = new ArrayList();
+ glueLibNames.addAll(GLDynamicLibraryBundleInfo.getGlueLibNamesPreload());
+ glueLibNames.add("jogl_es1");
+ }
+
+ protected EGLES1DynamicLibraryBundleInfo() {
+ super();
+ }
+
+ public List getToolLibNames() {
+ List/*<List>*/ libNames = new ArrayList();
+
+ List/*<String>*/ glesLibNames = new ArrayList();
+ glesLibNames.add("GLES_CM");
+ glesLibNames.add("GLES_CL");
+ glesLibNames.add("GLESv1_CM");
+ // for windows distributions using the 'unlike' lib prefix,
+ // where our tool does not add it.
+ glesLibNames.add("libGLES_CM");
+ glesLibNames.add("libGLES_CL");
+ glesLibNames.add("libGLESv1_CM");
+ // last but not least, we may even use the desktop GL library,
+ // which would be eg Mesa + Gallium EGL ..
+ glesLibNames.add("libGL.so.1");
+ glesLibNames.add("libGL.so");
+ glesLibNames.add("GL");
+
+ libNames.add(glesLibNames);
+ libNames.add(getEGLLibNamesList());
+ return libNames;
+ }
+
+ public List/*<String>*/ getGlueLibNames() {
+ return glueLibNames;
+ }
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES1DynamicLookupHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES1DynamicLookupHelper.java
deleted file mode 100755
index e5740a4f0..000000000
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES1DynamicLookupHelper.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl.impl.egl;
-
-import java.util.*;
-
-/**
- * Implementation of the EGLDynamicLookupHelper for ES1.
- */
-public class EGLES1DynamicLookupHelper extends EGLDynamicLookupHelper {
-
- protected EGLES1DynamicLookupHelper() {
- super();
- }
-
- protected int getESProfile() {
- return 1;
- }
-
- protected List/*<String>*/ getGLESLibNames() {
- List/*<String>*/ glesLibNames = new ArrayList();
-
- glesLibNames.add("GLES_CM");
- glesLibNames.add("GLES_CL");
- glesLibNames.add("GLESv1_CM");
- // for windows distributions using the 'unlike' lib prefix,
- // where our tool does not add it.
- glesLibNames.add("libGLES_CM");
- glesLibNames.add("libGLES_CL");
- glesLibNames.add("libGLESv1_CM");
-
- return glesLibNames;
- }
-}
-
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES2DynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES2DynamicLibraryBundleInfo.java
new file mode 100755
index 000000000..9691b2bd0
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES2DynamicLibraryBundleInfo.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2010, Sven Gothel
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sven Gothel nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Sven Gothel BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.jogamp.opengl.impl.egl;
+
+import java.util.*;
+import com.jogamp.opengl.impl.*;
+
+public class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo {
+ static List/*<String>*/ glueLibNames;
+ static {
+ glueLibNames = new ArrayList();
+ glueLibNames.addAll(GLDynamicLibraryBundleInfo.getGlueLibNamesPreload());
+ glueLibNames.add("jogl_es2");
+ }
+
+ protected EGLES2DynamicLibraryBundleInfo() {
+ super();
+ }
+
+ public List getToolLibNames() {
+ List/*<List>*/ libNames = new ArrayList();
+
+ List/*<String>*/ glesLibNames = new ArrayList();
+ glesLibNames.add("GLES20");
+ glesLibNames.add("GLESv2");
+ glesLibNames.add("GLESv2_CM");
+ // for windows distributions using the 'unlike' lib prefix
+ // where our tool does not add it.
+ glesLibNames.add("libGLES20");
+ glesLibNames.add("libGLESv2");
+ glesLibNames.add("libGLESv2_CM");
+ // last but not least, we may even use the desktop GL library,
+ // which would be eg Mesa + Gallium EGL ..
+ glesLibNames.add("libGL.so.1");
+ glesLibNames.add("libGL.so");
+ glesLibNames.add("GL");
+
+ libNames.add(glesLibNames);
+ libNames.add(getEGLLibNamesList());
+ return libNames;
+ }
+
+ public List/*<String>*/ getGlueLibNames() {
+ return glueLibNames;
+ }
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES2DynamicLookupHelper.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES2DynamicLookupHelper.java
deleted file mode 100755
index c4fc66630..000000000
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLES2DynamicLookupHelper.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl.impl.egl;
-
-import java.util.*;
-
-/**
- * Implementation of the EGLDynamicLookupHelper for ES2.
- */
-public class EGLES2DynamicLookupHelper extends EGLDynamicLookupHelper {
-
- protected EGLES2DynamicLookupHelper() {
- super();
- }
-
- protected int getESProfile() {
- return 2;
- }
-
- protected List/*<String>*/ getGLESLibNames() {
- List/*<String>*/ glesLibNames = new ArrayList();
-
- glesLibNames.add("GLES20");
- glesLibNames.add("GLESv2");
- glesLibNames.add("GLESv2_CM");
- // for windows distributions using the 'unlike' lib prefix
- // where our tool does not add it.
- glesLibNames.add("libGLES20");
- glesLibNames.add("libGLESv2");
- glesLibNames.add("libGLESv2_CM");
-
- return glesLibNames;
- }
-}
-
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLExternalContext.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLExternalContext.java
index f5f027f94..ae8b5bf70 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLExternalContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLExternalContext.java
@@ -67,21 +67,16 @@ public class EGLExternalContext extends EGLContext {
lastContext = null;
}
- protected int makeCurrentImpl() throws GLException {
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
if (firstMakeCurrent) {
firstMakeCurrent = false;
- // FIXME: set contextHandle
- return CONTEXT_CURRENT_NEW;
}
- return CONTEXT_CURRENT;
}
protected void releaseImpl() throws GLException {
}
protected void destroyImpl() throws GLException {
- contextHandle = 0 ;
- GLContextShareSet.contextDestroyed(this);
}
public void bindPbufferToTexture() {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenContext.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenContext.java
index b74991671..cb8b01d8d 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenContext.java
@@ -47,37 +47,6 @@ public class EGLOnscreenContext extends EGLContext {
super(drawable, shareWith);
}
- // Note: Usually the surface shall be locked within [makeCurrent .. swap .. release]
- protected int makeCurrentImpl() throws GLException {
- int lockRes = drawable.lockSurface();
- boolean exceptionOccurred = false;
- try {
- if (lockRes == NativeWindow.LOCK_SURFACE_NOT_READY) {
- return CONTEXT_NOT_CURRENT;
- }
- return super.makeCurrentImpl();
- } catch (RuntimeException e) {
- exceptionOccurred = true;
- throw e;
- } finally {
- if (exceptionOccurred ||
- (isOptimizable() && lockRes != NativeWindow.LOCK_SURFACE_NOT_READY) && drawable.isSurfaceLocked()) {
- drawable.unlockSurface();
- }
- }
- }
-
- // Note: Usually the surface shall be locked within [makeCurrent .. swap .. release]
- protected void releaseImpl() throws GLException {
- try {
- super.releaseImpl();
- } finally {
- if (!isOptimizable() && drawable.isSurfaceLocked()) {
- drawable.unlockSurface();
- }
- }
- }
-
public void bindPbufferToTexture() {
throw new GLException("Should not call this");
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenDrawable.java
index 3864fc39c..551a21ed6 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLOnscreenDrawable.java
@@ -59,21 +59,7 @@ public class EGLOnscreenDrawable extends EGLDrawable {
}
protected void swapBuffersImpl() {
- boolean didLock = false;
- if (!isSurfaceLocked()) {
- // Usually the surface shall be locked within [makeCurrent .. swap .. release]
- if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
- return;
- }
- didLock = true;
- }
- try {
- EGL.eglSwapBuffers(eglDisplay, eglSurface);
- } finally {
- if (didLock) {
- unlockSurface();
- }
- }
+ EGL.eglSwapBuffers(eglDisplay, eglSurface);
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/gl2/ProjectDouble.java b/src/jogl/classes/com/jogamp/opengl/impl/gl2/ProjectDouble.java
index 2eb3ca5df..98cc3f323 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/gl2/ProjectDouble.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/gl2/ProjectDouble.java
@@ -118,6 +118,7 @@ import java.nio.*;
import javax.media.opengl.*;
import com.jogamp.opengl.impl.*;
+import com.jogamp.common.nio.Buffers;
/**
* Project.java
@@ -173,7 +174,7 @@ public class ProjectDouble {
// Slice up one big buffer because some NIO implementations
// allocate a huge amount of memory to back even the smallest of
// buffers.
- DoubleBuffer locbuf = InternalBufferUtil.newDoubleBuffer(128);
+ DoubleBuffer locbuf = Buffers.newDirectDoubleBuffer(128);
int pos = 0;
int sz = 16;
matrixBuf = slice(locbuf, pos, sz);
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/glu/mipmap/BuildMipmap.java b/src/jogl/classes/com/jogamp/opengl/impl/glu/mipmap/BuildMipmap.java
index 501f5f585..42f55f982 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/glu/mipmap/BuildMipmap.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/glu/mipmap/BuildMipmap.java
@@ -48,7 +48,7 @@ import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.glu.GLU;
import com.jogamp.opengl.impl.Debug;
-import com.jogamp.opengl.impl.InternalBufferUtil;
+import com.jogamp.common.nio.Buffers;
import java.nio.*;
import java.io.*;
@@ -89,8 +89,8 @@ public class BuildMipmap {
Mipmap.retrieveStoreModes( gl, psm );
try {
- newImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( Mipmap.image_size( width, 1, format,
- GL2.GL_UNSIGNED_SHORT ) )).asShortBuffer();
+ newImage = Buffers.newDirectByteBuffer( Mipmap.image_size( width, 1, format,
+ GL2.GL_UNSIGNED_SHORT ) ).asShortBuffer();
} catch( OutOfMemoryError ome ) {
return( GLU.GLU_OUT_OF_MEMORY );
}
@@ -117,7 +117,7 @@ public class BuildMipmap {
if( otherImage == null ) {
memReq = Mipmap.image_size( newwidth, 1, format, GL2.GL_UNSIGNED_SHORT );
try {
- otherImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq )).asShortBuffer();
+ otherImage = Buffers.newDirectByteBuffer( memReq ).asShortBuffer();
} catch( OutOfMemoryError ome ) {
gl.glPixelStorei( GL2.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
gl.glPixelStorei( GL2.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
@@ -178,8 +178,8 @@ public class BuildMipmap {
}
try {
- newImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( Mipmap.image_size( width, height,
- format, GL2.GL_UNSIGNED_SHORT ) )).asShortBuffer();
+ newImage = Buffers.newDirectByteBuffer( Mipmap.image_size( width, height,
+ format, GL2.GL_UNSIGNED_SHORT ) ).asShortBuffer();
} catch( OutOfMemoryError ome ) {
return( GLU.GLU_OUT_OF_MEMORY );
}
@@ -206,7 +206,7 @@ public class BuildMipmap {
if( otherImage == null ) {
memReq = Mipmap.image_size( newwidth[0], newheight[0], format, GL2.GL_UNSIGNED_SHORT );
try {
- otherImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq )).asShortBuffer();
+ otherImage = Buffers.newDirectByteBuffer( memReq ).asShortBuffer();
} catch( OutOfMemoryError ome ) {
gl.glPixelStorei( GL2.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
gl.glPixelStorei( GL2.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
@@ -364,7 +364,7 @@ public class BuildMipmap {
case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ):
case( GL2.GL_UNSIGNED_INT_10_10_10_2 ):
case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq ));
+ dstImage = Buffers.newDirectByteBuffer( memReq );
break;
default:
return( GLU.GLU_INVALID_ENUM );
@@ -481,7 +481,7 @@ public class BuildMipmap {
case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ):
case( GL2.GL_UNSIGNED_INT_10_10_10_2 ):
case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq ));
+ dstImage = Buffers.newDirectByteBuffer( memReq );
break;
default:
return( GLU.GLU_INVALID_ENUM );
@@ -519,7 +519,7 @@ public class BuildMipmap {
case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ):
case( GL2.GL_UNSIGNED_INT_10_10_10_2 ):
case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq ));
+ dstImage = Buffers.newDirectByteBuffer( memReq );
break;
default:
return( GLU.GLU_INVALID_ENUM );
@@ -653,7 +653,7 @@ public class BuildMipmap {
case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ):
case( GL2.GL_UNSIGNED_INT_10_10_10_2 ):
case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq ));
+ dstImage = Buffers.newDirectByteBuffer( memReq );
break;
default:
return( GLU.GLU_INVALID_ENUM );
@@ -880,8 +880,7 @@ public class BuildMipmap {
int i, j;
try {
- newImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( Mipmap.image_size(
- width, height, format, GL2.GL_UNSIGNED_BYTE ) ));
+ newImage = Buffers.newDirectByteBuffer( Mipmap.image_size(width, height, format, GL2.GL_UNSIGNED_BYTE ) );
} catch( OutOfMemoryError err ) {
return( GLU.GLU_OUT_OF_MEMORY );
}
@@ -924,7 +923,7 @@ public class BuildMipmap {
if( otherImage == null ) {
memReq = Mipmap.image_size( newwidth[0], newheight[0], format, GL2.GL_UNSIGNED_BYTE );
try {
- otherImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq ));
+ otherImage = Buffers.newDirectByteBuffer( memReq );
} catch( OutOfMemoryError err ) {
gl.glPixelStorei( GL2.GL_UNPACK_ALIGNMENT, psm.getUnpackAlignment() );
gl.glPixelStorei( GL2.GL_UNPACK_SKIP_ROWS, psm.getUnpackSkipRows() );
@@ -1102,7 +1101,7 @@ public class BuildMipmap {
case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ):
case( GL2.GL_UNSIGNED_INT_10_10_10_2 ):
case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq ));
+ dstImage = Buffers.newDirectByteBuffer( memReq );
break;
default:
return( GLU.GLU_INVALID_ENUM );
@@ -1288,7 +1287,7 @@ public class BuildMipmap {
case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ):
case( GL2.GL_UNSIGNED_INT_10_10_10_2 ):
case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq ));
+ dstImage = Buffers.newDirectByteBuffer( memReq );
break;
default:
return( GLU.GLU_INVALID_ENUM );
@@ -1329,7 +1328,7 @@ public class BuildMipmap {
case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ):
case( GL2.GL_UNSIGNED_INT_10_10_10_2 ):
case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq ));
+ dstImage = Buffers.newDirectByteBuffer( memReq );
break;
default:
return( GLU.GLU_INVALID_ENUM );
@@ -1391,7 +1390,7 @@ public class BuildMipmap {
case( GL2.GL_UNSIGNED_INT_8_8_8_8_REV ):
case( GL2.GL_UNSIGNED_INT_10_10_10_2 ):
case( GL2.GL_UNSIGNED_INT_2_10_10_10_REV ):
- dstImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( memReq ));
+ dstImage = Buffers.newDirectByteBuffer( memReq );
break;
default:
return( GLU.GLU_INVALID_ENUM );
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/glu/mipmap/Mipmap.java b/src/jogl/classes/com/jogamp/opengl/impl/glu/mipmap/Mipmap.java
index 1c0707c57..4e3f6c298 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/glu/mipmap/Mipmap.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/glu/mipmap/Mipmap.java
@@ -50,7 +50,7 @@ import javax.media.opengl.GL2GL3;
import javax.media.opengl.glu.GLU;
import javax.media.opengl.GLException;
import java.nio.*;
-import com.jogamp.opengl.impl.InternalBufferUtil;
+import com.jogamp.common.nio.Buffers;
/**
*
@@ -575,8 +575,8 @@ public class Mipmap {
if( !isLegalFormatForPackedPixelType( format, typeout ) ) {
return( GLU.GLU_INVALID_OPERATION );
}
- beforeimage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( image_size( widthin, heightin, format, GL2GL3.GL_UNSIGNED_SHORT ) ));
- afterimage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( image_size( widthout, heightout, format, GL2GL3.GL_UNSIGNED_SHORT ) ));
+ beforeimage = Buffers.newDirectByteBuffer( image_size( widthin, heightin, format, GL2GL3.GL_UNSIGNED_SHORT ) );
+ afterimage = Buffers.newDirectByteBuffer( image_size( widthout, heightout, format, GL2GL3.GL_UNSIGNED_SHORT ) );
if( beforeimage == null || afterimage == null ) {
return( GLU.GLU_OUT_OF_MEMORY );
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/glu/mipmap/ScaleInternal.java b/src/jogl/classes/com/jogamp/opengl/impl/glu/mipmap/ScaleInternal.java
index f0bb7fb33..804845fe2 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/glu/mipmap/ScaleInternal.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/glu/mipmap/ScaleInternal.java
@@ -48,7 +48,7 @@ import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.glu.GLU;
import java.nio.*;
-import com.jogamp.opengl.impl.InternalBufferUtil;
+import com.jogamp.common.nio.Buffers;
/**
*
@@ -2425,10 +2425,10 @@ public class ScaleInternal {
}
try {
- beforeImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( Mipmap.imageSize3D( widthIn,
- heightIn, depthIn, format, GL2.GL_UNSIGNED_SHORT ) )).asShortBuffer();
- afterImage = InternalBufferUtil.nativeOrder(ByteBuffer.allocateDirect( Mipmap.imageSize3D( widthIn,
- heightIn, depthIn, format, GL2.GL_UNSIGNED_SHORT ) )).asShortBuffer();
+ beforeImage = Buffers.newDirectByteBuffer( Mipmap.imageSize3D( widthIn,
+ heightIn, depthIn, format, GL2.GL_UNSIGNED_SHORT ) ).asShortBuffer();
+ afterImage = Buffers.newDirectByteBuffer( Mipmap.imageSize3D( widthIn,
+ heightIn, depthIn, format, GL2.GL_UNSIGNED_SHORT ) ).asShortBuffer();
} catch( OutOfMemoryError err ) {
return( GLU.GLU_OUT_OF_MEMORY );
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java
index 371df1ee5..46b86a557 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java
@@ -134,7 +134,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
int[] viewNotReady = new int[1];
// Try to allocate a context with this
contextHandle = CGL.createContext(share,
- drawable.getNativeWindow().getSurfaceHandle(),
+ drawable.getHandle(),
pixelFormat,
viewNotReady, 0);
if (contextHandle == 0) {
@@ -166,26 +166,8 @@ public abstract class MacOSXCGLContext extends GLContextImpl
GLContextShareSet.contextCreated(this);
return true;
}
-
- protected int makeCurrentImpl() throws GLException {
- if (0 == drawable.getNativeWindow().getSurfaceHandle()) {
- throw new GLException("drawable has invalid surface handle: "+drawable);
- }
- boolean newCreated = false;
- if (!isCreated()) {
- create();
- newCreated = isCreated();
- if(!newCreated) {
- if (DEBUG) {
- System.err.println("!!! GL Context creation failed for " + getClass().getName());
- }
- return CONTEXT_NOT_CURRENT;
- }
- if (DEBUG) {
- System.err.println("!!! Created OpenGL context " + toHexString(contextHandle) + " for " + getClass().getName());
- }
- }
-
+
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
if ( isNSContext ) {
if (!CGL.makeCurrentContext(contextHandle)) {
throw new GLException("Error making Context (NS) current");
@@ -195,12 +177,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl
throw new GLException("Error making Context (CGL) current");
}
}
-
- if (newCreated) {
- setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
- return CONTEXT_CURRENT_NEW;
- }
- return CONTEXT_CURRENT;
}
protected void releaseImpl() throws GLException {
@@ -214,9 +190,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
protected void destroyImpl() throws GLException {
- if( ! isCreated() ) {
- return;
- }
if ( !isNSContext ) {
if (CGL.kCGLNoError != CGL.CGLDestroyContext(contextHandle)) {
throw new GLException("Unable to delete OpenGL Context (CGL)");
@@ -224,8 +197,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl
if (DEBUG) {
System.err.println("!!! Destroyed OpenGL Context (CGL) " + contextHandle);
}
- contextHandle = 0;
- GLContextShareSet.contextDestroyed(this);
} else {
if (!CGL.deleteContext(contextHandle)) {
throw new GLException("Unable to delete OpenGL Context (NS)");
@@ -233,20 +204,12 @@ public abstract class MacOSXCGLContext extends GLContextImpl
if (DEBUG) {
System.err.println("!!! Destroyed OpenGL Context (NS) " + contextHandle);
}
- contextHandle = 0;
}
- GLContextShareSet.contextDestroyed(this);
}
- public void copy(GLContext source, int mask) throws GLException {
+ protected void copyImpl(GLContext source, int mask) throws GLException {
long dst = getHandle();
- if (0 == dst) {
- throw new GLException("Destination OpenGL Context has not been created");
- }
long src = source.getHandle();
- if (0 == src) {
- throw new GLException("Source OpenGL Context has not been created");
- }
if( !isNSContext() ) {
if ( ((MacOSXCGLContext)source).isNSContext() ) {
throw new GLException("Source OpenGL Context is NS ; Destination Context is CGL.");
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
index cf29d214b..23fdcbf6d 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
@@ -42,7 +42,6 @@ package com.jogamp.opengl.impl.macosx.cgl;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.jogamp.opengl.impl.*;
-import com.jogamp.common.os.DynamicLookupHelper;
public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
// The Java2D/OpenGL pipeline on OS X uses low-level CGLContextObjs
@@ -83,17 +82,10 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
}
protected void setRealizedImpl() {
- if(realized) {
- if( NativeWindow.LOCK_SURFACE_NOT_READY == lockSurface() ) {
- throw new GLException("Couldn't lock surface");
- }
- // locking the surface is essential to update surface data
- unlockSurface();
- }
}
- public DynamicLookupHelper getDynamicLookupHelper() {
- return (MacOSXCGLDrawableFactory) getFactoryImpl() ;
+ public GLDynamicLookupHelper getGLDynamicLookupHelper() {
+ return getFactoryImpl().getGLDynamicLookupHelper(0);
}
protected static String getThreadName() {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
index 61d24a106..7f050412d 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -39,7 +39,6 @@
package com.jogamp.opengl.impl.macosx.cgl;
-import com.jogamp.common.os.DynamicLookupHelper;
import java.nio.*;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
@@ -48,7 +47,29 @@ import com.jogamp.common.util.*;
import com.jogamp.opengl.impl.*;
import com.jogamp.nativewindow.impl.NullWindow;
-public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements DynamicLookupHelper {
+public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
+ private static final DesktopGLDynamicLookupHelper macOSXCGLDynamicLookupHelper;
+
+ static {
+ DesktopGLDynamicLookupHelper tmp = null;
+ try {
+ tmp = new DesktopGLDynamicLookupHelper(new MacOSXCGLDynamicLibraryBundleInfo());
+ } catch (GLException gle) {
+ if(DEBUG) {
+ gle.printStackTrace();
+ }
+ }
+ macOSXCGLDynamicLookupHelper = tmp;
+ /** FIXME ??
+ if(null!=macOSXCGLDynamicLookupHelper) {
+ CGL.getCGLProcAddressTable().reset(macOSXCGLDynamicLookupHelper);
+ } */
+ }
+
+ public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
+ return macOSXCGLDynamicLookupHelper;
+ }
+
public MacOSXCGLDrawableFactory() {
super();
@@ -118,15 +139,6 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements D
throw new GLException("Not yet implemented");
}
- public void loadGLULibrary() {
- // Nothing to do; already loaded by native code; not much point in
- // making it lazier on this platform
- }
-
- public long dynamicLookupFunction(String glFuncName) {
- return CGL.getProcAddress(glFuncName);
- }
-
public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) {
return false;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDynamicLibraryBundleInfo.java
new file mode 100644
index 000000000..154cf61b5
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDynamicLibraryBundleInfo.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2010, Sven Gothel
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sven Gothel nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Sven Gothel BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.jogamp.opengl.impl.macosx.cgl;
+
+import com.jogamp.opengl.impl.*;
+import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.common.os.NativeLibrary;
+import com.jogamp.common.os.Platform;
+import java.util.*;
+import java.security.*;
+import javax.media.opengl.GLException;
+
+public class MacOSXCGLDynamicLibraryBundleInfo extends DesktopGLDynamicLibraryBundleInfo {
+ protected MacOSXCGLDynamicLibraryBundleInfo() {
+ super();
+ }
+
+ public List getToolLibNames() {
+ List/*<List>*/ libNamesList = new ArrayList();
+
+ List/*<String>*/ glesLibNames = new ArrayList();
+
+ glesLibNames.add("/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib");
+ glesLibNames.add("GL");
+
+ libNamesList.add(glesLibNames);
+
+ return libNamesList;
+ }
+
+ public final List getToolGetProcAddressFuncNameList() {
+ return null;
+ /** OSX manual says: NSImage use is discouraged
+ List res = new ArrayList();
+ res.add("GetProcAddress"); // dummy
+ return res; */
+ }
+
+ public final long toolDynamicLookupFunction(long toolGetProcAddressHandle, String funcName) {
+ return 0;
+ /** OSX manual says: NSImage use is discouraged
+ return CGL.getProcAddress(glFuncName); // manual implementation
+ */
+ }
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java
index 9865fdfca..e8518925a 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXExternalCGLContext.java
@@ -60,56 +60,52 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext {
}
protected static MacOSXExternalCGLContext create(GLDrawableFactory factory, GLProfile glp) {
- ((GLDrawableFactoryImpl)factory).lockToolkit();
- try {
- long pixelFormat = 0;
- long currentDrawable = 0;
- long contextHandle = CGL.getCurrentContext(); // Check: MacOSX 10.3 ..
- boolean isNSContext = 0 != contextHandle;
- if( isNSContext ) {
- currentDrawable = CGL.getNSView(contextHandle);
- long ctx = CGL.getCGLContext(contextHandle);
- if (ctx == 0) {
- throw new GLException("Error: NULL Context (CGL) of Context (NS) 0x" +Long.toHexString(contextHandle));
- }
- pixelFormat = CGL.CGLGetPixelFormat(ctx);
- if(DEBUG) {
- System.err.println("MacOSXExternalCGLContext Create Context (NS) 0x"+Long.toHexString(contextHandle)+
- ", Context (CGL) 0x"+Long.toHexString(ctx)+
- ", pixelFormat 0x"+Long.toHexString(pixelFormat));
- }
- } else {
- contextHandle = CGL.CGLGetCurrentContext();
- if (contextHandle == 0) {
- throw new GLException("Error: current Context (CGL) null, no Context (NS)");
- }
- pixelFormat = CGL.CGLGetPixelFormat(contextHandle);
- if(DEBUG) {
- System.err.println("MacOSXExternalCGLContext Create Context (CGL) 0x"+Long.toHexString(contextHandle)+
- ", pixelFormat 0x"+Long.toHexString(pixelFormat));
- }
+ long pixelFormat = 0;
+ long currentDrawable = 0;
+ long contextHandle = CGL.getCurrentContext(); // Check: MacOSX 10.3 ..
+ boolean isNSContext = 0 != contextHandle;
+ if( isNSContext ) {
+ currentDrawable = CGL.getNSView(contextHandle);
+ long ctx = CGL.getCGLContext(contextHandle);
+ if (ctx == 0) {
+ throw new GLException("Error: NULL Context (CGL) of Context (NS) 0x" +Long.toHexString(contextHandle));
}
-
- if (0 == pixelFormat) {
- throw new GLException("Error: current pixelformat of current Context 0x"+Long.toHexString(contextHandle)+" is null");
+ pixelFormat = CGL.CGLGetPixelFormat(ctx);
+ if(DEBUG) {
+ System.err.println("MacOSXExternalCGLContext Create Context (NS) 0x"+Long.toHexString(contextHandle)+
+ ", Context (CGL) 0x"+Long.toHexString(ctx)+
+ ", pixelFormat 0x"+Long.toHexString(pixelFormat));
}
- GLCapabilities caps = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(glp, pixelFormat);
+ } else {
+ contextHandle = CGL.CGLGetCurrentContext();
+ if (contextHandle == 0) {
+ throw new GLException("Error: current Context (CGL) null, no Context (NS)");
+ }
+ pixelFormat = CGL.CGLGetPixelFormat(contextHandle);
if(DEBUG) {
- System.err.println("MacOSXExternalCGLContext Create "+caps);
+ System.err.println("MacOSXExternalCGLContext Create Context (CGL) 0x"+Long.toHexString(contextHandle)+
+ ", pixelFormat 0x"+Long.toHexString(pixelFormat));
}
+ }
- AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault();
- MacOSXCGLGraphicsConfiguration cfg = new MacOSXCGLGraphicsConfiguration(aScreen, caps, caps, pixelFormat);
-
- NullWindow nw = new NullWindow(cfg);
- nw.setSurfaceHandle(currentDrawable);
- return new MacOSXExternalCGLContext(new Drawable(factory, nw), isNSContext, contextHandle);
- } finally {
- ((GLDrawableFactoryImpl)factory).unlockToolkit();
+ if (0 == pixelFormat) {
+ throw new GLException("Error: current pixelformat of current Context 0x"+Long.toHexString(contextHandle)+" is null");
+ }
+ GLCapabilities caps = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(glp, pixelFormat);
+ if(DEBUG) {
+ System.err.println("MacOSXExternalCGLContext Create "+caps);
}
+
+ AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault();
+ MacOSXCGLGraphicsConfiguration cfg = new MacOSXCGLGraphicsConfiguration(aScreen, caps, caps, pixelFormat);
+
+ NullWindow nw = new NullWindow(cfg);
+ nw.setSurfaceHandle(currentDrawable);
+ return new MacOSXExternalCGLContext(new Drawable(factory, nw), isNSContext, contextHandle);
}
- protected void create() {
+ protected boolean createImpl() throws GLException {
+ return true;
}
public int makeCurrent() throws GLException {
@@ -129,20 +125,16 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext {
lastContext = null;
}
- protected int makeCurrentImpl() throws GLException {
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
if (firstMakeCurrent) {
firstMakeCurrent = false;
- return CONTEXT_CURRENT_NEW;
}
- return CONTEXT_CURRENT;
}
protected void releaseImpl() throws GLException {
}
protected void destroyImpl() throws GLException {
- contextHandle = 0;
- GLContextShareSet.contextDestroyed(this);
}
public void setOpenGLMode(int mode) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java
index ede0c28eb..568204384 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java
@@ -54,52 +54,13 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
this.drawable = drawable;
}
- protected int makeCurrentImpl() throws GLException {
- int lockRes = drawable.lockSurface();
- boolean exceptionOccurred = false;
- try {
- if (lockRes == NativeWindow.LOCK_SURFACE_NOT_READY) {
- return CONTEXT_NOT_CURRENT;
- }
- int ret = super.makeCurrentImpl();
- if ((ret == CONTEXT_CURRENT) ||
- (ret == CONTEXT_CURRENT_NEW)) {
- // Assume the canvas might have been resized or moved and tell the OpenGL
- // context to update itself. This used to be done only upon receiving a
- // reshape event but that doesn't appear to be sufficient. An experiment
- // was also done to add a HierarchyBoundsListener to the GLCanvas and
- // do this updating only upon reshape of this component or reshape or movement
- // of an ancestor, but this also wasn't sufficient and left garbage on the
- // screen in some situations.
- CGL.updateContext(contextHandle);
- } else {
- if (!isOptimizable()) {
- // This can happen if the window currently is zero-sized, for example.
- // Make sure we don't leave the surface locked in this case.
- drawable.unlockSurface();
- lockRes = NativeWindow.LOCK_SURFACE_NOT_READY;
- }
- }
- return ret;
- } catch (RuntimeException e) {
- exceptionOccurred = true;
- throw e;
- } finally {
- if (exceptionOccurred ||
- (isOptimizable() && lockRes != NativeWindow.LOCK_SURFACE_NOT_READY)) {
- drawable.unlockSurface();
- }
- }
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
+ super.makeCurrentImpl(newCreated);
+ CGL.updateContext(contextHandle);
}
protected void releaseImpl() throws GLException {
- try {
- super.releaseImpl();
- } finally {
- if (!isOptimizable() && drawable.isSurfaceLocked()) {
- drawable.unlockSurface();
- }
- }
+ super.releaseImpl();
}
protected void swapBuffers() {
@@ -115,8 +76,8 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
CGL.updateContext(contextHandle);
}
- protected void create() {
- create(false, false);
+ protected boolean createImpl() {
+ return create(false, false);
}
public void setOpenGLMode(int mode) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
index 391908540..9c630d24b 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
@@ -38,45 +38,22 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
// FIXME: not clear whether this is really necessary, but since
// the API docs seem to imply it is and since it doesn't seem to
// impact performance, leaving it in
- CGL.setContextTextureImageToPBuffer(contextHandle, drawable.getPbuffer(), GL.GL_FRONT);
+ CGL.setContextTextureImageToPBuffer(contextHandle, drawable.getHandle(), GL.GL_FRONT);
}
public void releasePbufferFromTexture() {
}
- protected int makeCurrentImpl() throws GLException {
- if (drawable.getPbuffer() == 0) {
- if (DEBUG) {
- System.err.println("Pbuffer not instantiated yet for " + this);
- }
- // pbuffer not instantiated yet
- return CONTEXT_NOT_CURRENT;
- }
-
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
if (getOpenGLMode() != drawable.getOpenGLMode()) {
setOpenGLMode(drawable.getOpenGLMode());
}
- if (contextHandle == 0) {
- create();
- if(!isCreated()) {
- return CONTEXT_NOT_CURRENT;
- }
- if(!isNSContext()) {
- throw new GLException("Not a NS Context");
- }
- if (DEBUG) {
- System.err.println("!!! Created OpenGL context (NS) " + toHexString(contextHandle) + " for " + getClass().getName());
- }
- }
-
if (!impl.makeCurrent(contextHandle)) {
throw new GLException("Error making Context (NS) current");
}
- if (isCreated()) {
- setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
-
+ if (newCreated) {
// Initialize render-to-texture support if requested
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
@@ -99,10 +76,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
gl.glCopyTexImage2D(textureTarget, 0, GL.GL_RGB, 0, 0, drawable.getWidth(), drawable.getHeight(), 0);
-
- return CONTEXT_CURRENT_NEW;
}
- return CONTEXT_CURRENT;
}
protected void releaseImpl() throws GLException {
@@ -112,22 +86,15 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
}
protected void destroyImpl() throws GLException {
- if (contextHandle != 0) {
if (!impl.destroy(contextHandle)) {
throw new GLException("Unable to delete OpenGL context");
}
if (DEBUG) {
System.err.println("!!! Destroyed OpenGL context " + contextHandle);
}
- contextHandle = 0;
- GLContextShareSet.contextDestroyed(this);
- }
}
protected void setSwapIntervalImpl(int interval) {
- if (contextHandle == 0) {
- throw new GLException("OpenGL context not current");
- }
impl.setSwapInterval(contextHandle, interval);
currentSwapInterval = impl.getSwapInterval() ;
}
@@ -136,7 +103,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
return GLPbuffer.APPLE_FLOAT;
}
- protected void create() {
+ protected boolean createImpl() throws GLException {
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
if (capabilities.getPbufferFloatingPointBuffers() &&
@@ -155,7 +122,11 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
if (!impl.makeCurrent(contextHandle)) {
throw new GLException("Error making Context (NS:"+isNSContext()+") current");
}
+ if(!isNSContext()) { // FIXME: ??
+ throw new GLException("Not a NS Context");
+ }
setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
+ return true;
}
//---------------------------------------------------------------------------
@@ -231,7 +202,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
throw new GLException("Error creating context for pbuffer");
}
// Must now associate the pbuffer with our newly-created context
- CGL.setContextPBuffer(contextHandle, drawable.getPbuffer());
+ CGL.setContextPBuffer(contextHandle, drawable.getHandle());
return contextHandle;
}
@@ -335,7 +306,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
throw new GLException("Error code " + res + " while creating context");
}
// Attach newly-created context to the pbuffer
- res = CGL.CGLSetPBuffer(ctx.get(0), drawable.getPbuffer(), 0, 0, 0);
+ res = CGL.CGLSetPBuffer(ctx.get(0), drawable.getHandle(), 0, 0, 0);
if (res != CGL.kCGLNoError) {
throw new GLException("Error code " + res + " while attaching context to pbuffer");
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
index afdc40dbb..64d646cfb 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
@@ -96,7 +96,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
}
}
- public long getPbuffer() {
+ public long getHandle() {
return pBuffer;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
index 9a90cbdc4..b42f1132c 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/awt/MacOSXJava2DCGLContext.java
@@ -70,29 +70,13 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL
this.graphics = g;
}
- protected int makeCurrentImpl() throws GLException {
- if (contextHandle == 0) {
- create();
- if(!isCreated()) {
- return CONTEXT_NOT_CURRENT;
- }
- if (DEBUG) {
- System.err.println("!!! Created GL Context (NS) for " + getClass().getName());
- }
- }
-
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
if (!Java2D.makeOGLContextCurrentOnSurface(graphics, contextHandle)) {
throw new GLException("Error making context current");
- }
-
- if (isCreated()) {
- setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
- return CONTEXT_CURRENT_NEW;
- }
- return CONTEXT_CURRENT;
+ }
}
- protected void create() {
+ protected boolean createImpl() {
// Find and configure share context
MacOSXCGLContext other = (MacOSXCGLContext) GLContextShareSet.getShareContext(this);
long share = 0;
@@ -118,11 +102,13 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL
long ctx = Java2D.createOGLContextOnSurface(graphics, share);
if (ctx == 0) {
- return;
+ return false;
}
+ setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
// FIXME: think about GLContext sharing
contextHandle = ctx;
isNSContext = true;
+ return true;
}
protected void releaseImpl() throws GLException {
@@ -132,15 +118,10 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL
}
protected void destroyImpl() throws GLException {
- if (contextHandle != 0) {
Java2D.destroyOGLContext(contextHandle);
if (DEBUG) {
System.err.println("!!! Destroyed OpenGL context " + contextHandle);
}
- contextHandle = 0;
- // FIXME
- // GLContextShareSet.contextDestroyed(this);
- }
}
public void setOpenGLMode(int mode) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
index 87a37da04..5e3d55b04 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java
@@ -51,9 +51,9 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
// All entries to CreateDummyWindow must synchronize on one object
// to avoid accidentally registering the dummy window class twice
synchronized (WindowsDummyWGLDrawable.class) {
- hwnd = WGL.CreateDummyWindow(0, 0, 1, 1);
+ hwnd = GDI.CreateDummyWindow(0, 0, 1, 1);
}
- hdc = WGL.GetDC(hwnd);
+ hdc = GDI.GetDC(hwnd);
NullWindow nw = (NullWindow) getNativeWindow();
nw.setSurfaceHandle(hdc);
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)nw.getGraphicsConfiguration().getNativeGraphicsConfiguration();
@@ -61,9 +61,9 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
GLCapabilities caps = (GLCapabilities) config.getChosenCapabilities();
caps.setDepthBits(16);
PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps);
- int pixelFormat = WGL.ChoosePixelFormat(hdc, pfd);
+ int pixelFormat = GDI.ChoosePixelFormat(hdc, pfd);
if ((pixelFormat == 0) ||
- (!WGL.SetPixelFormat(hdc, pixelFormat, pfd))) {
+ (!GDI.SetPixelFormat(hdc, pixelFormat, pfd))) {
destroy();
}
}
@@ -90,12 +90,12 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
public void destroy() {
if (hdc != 0) {
- WGL.ReleaseDC(hwnd, hdc);
+ GDI.ReleaseDC(hwnd, hdc);
hdc = 0;
}
if (hwnd != 0) {
- WGL.ShowWindow(hwnd, WGL.SW_HIDE);
- WGL.DestroyWindow(hwnd);
+ GDI.ShowWindow(hwnd, GDI.SW_HIDE);
+ GDI.DestroyWindow(hwnd);
hwnd = 0;
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
index 55c9dc378..1f1fb0d40 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
@@ -69,7 +69,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext {
if (ctx == 0) {
throw new GLException("Error: attempted to make an external GLContext without a context current");
}
- int pfdID = WGL.GetPixelFormat(hdc);
+ int pfdID = GDI.GetPixelFormat(hdc);
if (pfdID == 0) {
throw new GLException("Error: attempted to make an external GLContext without a valid pixelformat");
}
@@ -100,20 +100,16 @@ public class WindowsExternalWGLContext extends WindowsWGLContext {
lastContext = null;
}
- protected int makeCurrentImpl() throws GLException {
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
if (firstMakeCurrent) {
firstMakeCurrent = false;
- return CONTEXT_CURRENT_NEW;
}
- return CONTEXT_CURRENT;
}
protected void releaseImpl() throws GLException {
}
protected void destroyImpl() throws GLException {
- contextHandle = 0;
- GLContextShareSet.contextDestroyed(this);
}
// Need to provide the display connection to extension querying APIs
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java
index 74db45932..41e469224 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLDrawable.java
@@ -55,7 +55,7 @@ public class WindowsExternalWGLDrawable extends WindowsWGLDrawable {
if (0==hdc) {
throw new GLException("Error: attempted to make an external GLDrawable without a drawable current");
}
- int pfdID = WGL.GetPixelFormat(hdc);
+ int pfdID = GDI.GetPixelFormat(hdc);
if (pfdID == 0) {
throw new GLException("Error: attempted to make an external GLContext without a valid pixelformat");
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
index bf466d455..8079cd42a 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
@@ -89,27 +89,27 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
header.setBiYPelsPerMeter(0);
header.setBiClrUsed(0);
header.setBiClrImportant(0);
- header.setBiCompression(WGL.BI_RGB);
+ header.setBiCompression(GDI.BI_RGB);
header.setBiSizeImage(width * height * bitsPerPixel / 8);
- long hdc = WGL.CreateCompatibleDC(0);
+ long hdc = GDI.CreateCompatibleDC(0);
if (hdc == 0) {
- System.out.println("LastError: " + WGL.GetLastError());
+ System.out.println("LastError: " + GDI.GetLastError());
throw new GLException("Error creating device context for offscreen OpenGL context");
}
((SurfaceChangeable)nw).setSurfaceHandle(hdc);
- hbitmap = WGL.CreateDIBSection(hdc, info, WGL.DIB_RGB_COLORS, null, 0, 0);
+ hbitmap = GDI.CreateDIBSection(hdc, info, GDI.DIB_RGB_COLORS, null, 0, 0);
if (hbitmap == 0) {
- WGL.DeleteDC(hdc);
+ GDI.DeleteDC(hdc);
hdc = 0;
throw new GLException("Error creating offscreen bitmap of width " + width +
", height " + height);
}
- if ((origbitmap = WGL.SelectObject(hdc, hbitmap)) == 0) {
- WGL.DeleteObject(hbitmap);
+ if ((origbitmap = GDI.SelectObject(hdc, hbitmap)) == 0) {
+ GDI.DeleteObject(hbitmap);
hbitmap = 0;
- WGL.DeleteDC(hdc);
+ GDI.DeleteDC(hdc);
hdc = 0;
throw new GLException("Error selecting bitmap into new device context");
}
@@ -121,9 +121,9 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
NativeWindow nw = getNativeWindow();
if (nw.getSurfaceHandle() != 0) {
// Must destroy bitmap and device context
- WGL.SelectObject(nw.getSurfaceHandle(), origbitmap);
- WGL.DeleteObject(hbitmap);
- WGL.DeleteDC(nw.getSurfaceHandle());
+ GDI.SelectObject(nw.getSurfaceHandle(), origbitmap);
+ GDI.DeleteObject(hbitmap);
+ GDI.DeleteDC(nw.getSurfaceHandle());
origbitmap = 0;
hbitmap = 0;
((SurfaceChangeable)nw).setSurfaceHandle(0);
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOnscreenWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOnscreenWGLContext.java
index aeb13110e..475faeecc 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOnscreenWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOnscreenWGLContext.java
@@ -46,43 +46,8 @@ import javax.media.opengl.*;
import com.jogamp.opengl.impl.*;
public class WindowsOnscreenWGLContext extends WindowsWGLContext {
- protected WindowsOnscreenWGLDrawable drawable;
-
public WindowsOnscreenWGLContext(WindowsOnscreenWGLDrawable drawable,
GLContext shareWith) {
super(drawable, shareWith);
- this.drawable = drawable;
- }
-
- // Note: Usually the surface shall be locked within [makeCurrent .. swap .. release]
- protected int makeCurrentImpl() throws GLException {
- int lockRes = drawable.lockSurface();
- boolean exceptionOccurred = false;
- try {
- if (lockRes == NativeWindow.LOCK_SURFACE_NOT_READY) {
- return CONTEXT_NOT_CURRENT;
- }
- int ret = super.makeCurrentImpl();
- return ret;
- } catch (RuntimeException e) {
- exceptionOccurred = true;
- throw e;
- } finally {
- if (exceptionOccurred ||
- (isOptimizable() && lockRes != NativeWindow.LOCK_SURFACE_NOT_READY) && drawable.isSurfaceLocked()) {
- drawable.unlockSurface();
- }
- }
- }
-
- // Note: Usually the surface shall be locked within [makeCurrent .. swap .. release]
- protected void releaseImpl() throws GLException {
- try {
- super.releaseImpl();
- } finally {
- if (!isOptimizable() && drawable.isSurfaceLocked()) {
- drawable.unlockSurface();
- }
- }
- }
+ }
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java
index a9e02e11f..1da5b80c9 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java
@@ -68,7 +68,7 @@ public class WindowsPbufferWGLContext extends WindowsWGLContext {
WGLExt wglExt = getWGLExt();
gl.glBindTexture(textureTarget, texture);
if (rtt && hasRTT) {
- if (!wglExt.wglBindTexImageARB(drawable.getPbuffer(), WGLExt.WGL_FRONT_LEFT_ARB)) {
+ if (!wglExt.wglBindTexImageARB(drawable.getPbufferHandle(), WGLExt.WGL_FRONT_LEFT_ARB)) {
throw new GLException("Binding of pbuffer to texture failed: " + wglGetLastError());
}
}
@@ -84,18 +84,15 @@ public class WindowsPbufferWGLContext extends WindowsWGLContext {
}
if (rtt && hasRTT) {
WGLExt wglExt = getWGLExt();
- if (!wglExt.wglReleaseTexImageARB(drawable.getPbuffer(), WGLExt.WGL_FRONT_LEFT_ARB)) {
+ if (!wglExt.wglReleaseTexImageARB(drawable.getPbufferHandle(), WGLExt.WGL_FRONT_LEFT_ARB)) {
throw new GLException("Releasing of pbuffer from texture failed: " + wglGetLastError());
}
}
}
- protected int makeCurrentImpl() throws GLException {
- int res = super.makeCurrentImpl();
- if (DEBUG && VERBOSE) {
- System.err.println("WindowsPbufferWGLContext: super.makeCurrentImpl() = " + res);
- }
- if (res == CONTEXT_CURRENT_NEW) {
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
+ super.makeCurrentImpl(newCreated);
+ if (newCreated) {
GLCapabilities capabilities = drawable.getChosenGLCapabilities();
// Initialize render-to-texture support if requested
@@ -142,7 +139,6 @@ public class WindowsPbufferWGLContext extends WindowsWGLContext {
}
}
}
- return res;
}
public int getFloatingPointMode() {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
index c7034e93b..c8c62914a 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -89,18 +89,21 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
// not be called here, so we skip the use of any composable
// pipelines (see WindowsOnscreenWGLContext.makeCurrentImpl)
if (wglExt.wglReleasePbufferDCARB(buffer, nw.getSurfaceHandle()) == 0) {
- throw new GLException("Error releasing pbuffer device context: error code " + WGL.GetLastError());
+ throw new GLException("Error releasing pbuffer device context: error code " + GDI.GetLastError());
}
((SurfaceChangeable)nw).setSurfaceHandle(0);
}
if (!wglExt.wglDestroyPbufferARB(buffer)) {
- throw new GLException("Error destroying pbuffer: error code " + WGL.GetLastError());
+ throw new GLException("Error destroying pbuffer: error code " + GDI.GetLastError());
}
buffer = 0;
}
}
- public long getPbuffer() {
+ public long getPbufferHandle() {
+ // The actual to-be-used handle for makeCurrent etc,
+ // is the derived DC, set in the NativeWindow surfaceHandle
+ // returned by getHandle().
return buffer;
}
@@ -293,7 +296,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
if (wglExt.wglGetPixelFormatAttribivARB(parentHdc, pformats[whichFormat], 0, niattribs, iattributes, 0, ivalues, 0)) {
GLCapabilities newCaps = WindowsWGLGraphicsConfiguration.AttribList2GLCapabilities(glProfile, iattributes, niattribs, ivalues, true, false, true);
PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.createPixelFormatDescriptor();
- if (WGL.DescribePixelFormat(parentHdc, pformats[whichFormat], pfd.size(), pfd) == 0) {
+ if (GDI.DescribePixelFormat(parentHdc, pformats[whichFormat], pfd.size(), pfd) == 0) {
if (DEBUG) {
System.err.println("Unable to describe pixel format (Continue: true) " + whichFormat + "/" + nformats + " pfdID " + pformats[whichFormat]+":\n\t"+newCaps);
}
@@ -304,7 +307,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
config.setCapsPFD(newCaps, pfd, pformats[whichFormat], true);
} else {
PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.createPixelFormatDescriptor();
- if (WGL.DescribePixelFormat(parentHdc, pformats[whichFormat], pfd.size(), pfd) == 0) {
+ if (GDI.DescribePixelFormat(parentHdc, pformats[whichFormat], pfd.size(), pfd) == 0) {
throw new GLException("Unable to describe pixel format " + pformats[whichFormat]);
}
GLCapabilities newCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, pfd, false, true);
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
index e52c585de..33f1bc829 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -51,8 +51,7 @@ public class WindowsWGLContext extends GLContextImpl {
private boolean wglGetExtensionsStringEXTInitialized;
private boolean wglGetExtensionsStringEXTAvailable;
private boolean wglMakeContextCurrentInitialized;
- private boolean wglMakeContextCurrentARBAvailable;
- private boolean wglMakeContextCurrentEXTAvailable;
+ private boolean wglMakeContextCurrentAvailable;
private static final Map/*<String, String>*/ functionNameMap;
private static final Map/*<String, String>*/ extensionNameMap;
private WGLExt wglExt;
@@ -95,17 +94,14 @@ public class WindowsWGLContext extends GLContextImpl {
public boolean wglMakeContextCurrent(long hDrawDC, long hReadDC, long ctx) {
WGLExt wglExt = getWGLExt();
if (!wglMakeContextCurrentInitialized) {
- wglMakeContextCurrentARBAvailable = isFunctionAvailable("wglMakeContextCurrentARB");
- wglMakeContextCurrentEXTAvailable = isFunctionAvailable("wglMakeContextCurrentEXT");
+ wglMakeContextCurrentAvailable = isFunctionAvailable("wglMakeContextCurrent");
wglMakeContextCurrentInitialized = true;
if(DEBUG) {
- System.err.println("WindowsWGLContext.wglMakeContextCurrent: ARB "+wglMakeContextCurrentARBAvailable+", EXT "+wglMakeContextCurrentEXTAvailable);
+ System.err.println("WindowsWGLContext.wglMakeContextCurrent: "+wglMakeContextCurrentAvailable);
}
}
- if(wglMakeContextCurrentARBAvailable) {
- return wglExt.wglMakeContextCurrentARB(hDrawDC, hReadDC, ctx);
- } else if(wglMakeContextCurrentEXTAvailable) {
- return wglExt.wglMakeContextCurrentEXT(hDrawDC, hReadDC, ctx);
+ if(wglMakeContextCurrentAvailable) {
+ return wglExt.wglMakeContextCurrent(hDrawDC, hReadDC, ctx);
}
return WGL.wglMakeCurrent(hDrawDC, ctx);
}
@@ -174,7 +170,7 @@ public class WindowsWGLContext extends GLContextImpl {
}
}
- ctx = wglExt.wglCreateContextAttribsARB(drawable.getNativeWindow().getSurfaceHandle(), share, attribs, 0);
+ ctx = wglExt.wglCreateContextAttribsARB(drawable.getHandle(), share, attribs, 0);
if(DEBUG) {
System.err.println("WindowsWGLContext.createContextARB success: "+(0!=ctx)+" - "+getGLVersion(major, minor, ctp, "@creation")+", bwdCompat "+ctBwdCompat+", fwdCompat "+ctFwdCompat);
}
@@ -182,7 +178,7 @@ public class WindowsWGLContext extends GLContextImpl {
// In contrast to GLX no verification with a drawable binding, ie default framebuffer, is necessary,
// if no 3.2 is available creation fails already!
// Nevertheless .. we do it ..
- if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), ctx)) {
+ if (!WGL.wglMakeCurrent(drawable.getHandle(), ctx)) {
if(DEBUG) {
System.err.println("WindowsWGLContext.createContextARB couldn't make current "+getGLVersion(major, minor, ctp, "@creation"));
}
@@ -198,10 +194,7 @@ public class WindowsWGLContext extends GLContextImpl {
* Creates and initializes an appropriate OpenGL context. Should only be
* called by {@link #makeCurrentImpl()}.
*/
- protected void create() {
- if(0!=contextHandle) {
- throw new GLException("context is not null: "+contextHandle);
- }
+ protected boolean createImpl() {
WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl();
GLCapabilities glCaps = drawable.getChosenGLCapabilities();
@@ -233,12 +226,12 @@ public class WindowsWGLContext extends GLContextImpl {
if(0==contextHandle) {
// To use WGL_ARB_create_context, we have to make a temp context current,
// so we are able to use GetProcAddress
- temp_ctx = WGL.wglCreateContext(drawable.getNativeWindow().getSurfaceHandle());
+ temp_ctx = WGL.wglCreateContext(drawable.getHandle());
if (temp_ctx == 0) {
- throw new GLException("Unable to create temp OpenGL context for device context " + toHexString(drawable.getNativeWindow().getSurfaceHandle()));
+ throw new GLException("Unable to create temp OpenGL context for device context " + toHexString(drawable.getHandle()));
}
- if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), temp_ctx)) {
- throw new GLException("Error making temp context current: 0x" + toHexString(temp_ctx) + ", werr: 0x"+Integer.toHexString(WGL.GetLastError()));
+ if (!WGL.wglMakeCurrent(drawable.getHandle(), temp_ctx)) {
+ throw new GLException("Error making temp context current: 0x" + toHexString(temp_ctx) + ", werr: 0x"+Integer.toHexString(GDI.GetLastError()));
}
setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
@@ -253,7 +246,8 @@ public class WindowsWGLContext extends GLContextImpl {
// continue with temp context for GL < 3.0
contextHandle = temp_ctx;
- return;
+ setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
+ return true;
}
contextHandle = createContextARB(share, true, major, minor, ctp);
createContextARBTried=true;
@@ -265,8 +259,8 @@ public class WindowsWGLContext extends GLContextImpl {
WGL.wglMakeCurrent(0, 0);
WGL.wglDeleteContext(temp_ctx);
- if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), contextHandle)) {
- throw new GLException("Cannot make previous verified context current: 0x" + toHexString(contextHandle) + ", werr: 0x" + Integer.toHexString(WGL.GetLastError()));
+ if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
+ throw new GLException("Cannot make previous verified context current: 0x" + toHexString(contextHandle) + ", werr: 0x" + Integer.toHexString(GDI.GetLastError()));
}
} else {
if(glCaps.getGLProfile().isGL3()) {
@@ -280,10 +274,10 @@ public class WindowsWGLContext extends GLContextImpl {
// continue with temp context for GL < 3.0
contextHandle = temp_ctx;
- if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), contextHandle)) {
+ if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
WGL.wglMakeCurrent(0, 0);
WGL.wglDeleteContext(contextHandle);
- throw new GLException("Error making old context current: 0x" + toHexString(contextHandle) + ", werr: 0x" + Integer.toHexString(WGL.GetLastError()));
+ throw new GLException("Error making old context current: 0x" + toHexString(contextHandle) + ", werr: 0x" + Integer.toHexString(GDI.GetLastError()));
}
}
@@ -291,78 +285,47 @@ public class WindowsWGLContext extends GLContextImpl {
if (!WGL.wglShareLists(share, contextHandle)) {
throw new GLException("wglShareLists(" + toHexString(share) +
", " + toHexString(contextHandle) + ") failed: werr 0x" +
- Integer.toHexString(WGL.GetLastError()));
+ Integer.toHexString(GDI.GetLastError()));
}
}
- GLContextShareSet.contextCreated(this);
+ setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
+ return true;
}
- protected int makeCurrentImpl() throws GLException {
- if (0 == drawable.getNativeWindow().getSurfaceHandle()) {
- throw new GLException("drawable has invalid surface handle: "+drawable);
- }
- boolean newCreated = false;
- if (!isCreated()) {
- create(); // throws exception if fails!
- newCreated = true;
- if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Created GL context " + toHexString(contextHandle) + " for " + getClass().getName());
- }
- }
-
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
if (WGL.wglGetCurrentContext() != contextHandle) {
- if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), contextHandle)) {
- throw new GLException("Error making context current: 0x" + toHexString(contextHandle) + ", werr: 0x" + Integer.toHexString(WGL.GetLastError()) + ", " + this);
+ if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
+ throw new GLException("Error making context current: 0x" + toHexString(contextHandle) + ", werr: 0x" + Integer.toHexString(GDI.GetLastError()) + ", " + this);
} else {
if (DEBUG && VERBOSE) {
- System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) +
+ System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + toHexString(drawable.getHandle()) +
", contextHandle " + toHexString(contextHandle) + ") succeeded");
}
}
}
if (newCreated) {
- setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
-
WindowsWGLGraphicsConfiguration config =
(WindowsWGLGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
config.updateCapabilitiesByWGL(this);
-
- return CONTEXT_CURRENT_NEW;
}
- return CONTEXT_CURRENT;
}
protected void releaseImpl() throws GLException {
if (!wglMakeContextCurrent(0, 0, 0)) {
- throw new GLException("Error freeing OpenGL context, werr: 0x" + Integer.toHexString(WGL.GetLastError()));
+ throw new GLException("Error freeing OpenGL context, werr: 0x" + Integer.toHexString(GDI.GetLastError()));
}
}
protected void destroyImpl() throws GLException {
- if (DEBUG) {
- Exception e = new Exception(getThreadName() + ": !!! Destroyed OpenGL context " + toHexString(contextHandle));
- e.printStackTrace();
- }
- if (contextHandle != 0) {
+ WGL.wglMakeCurrent(0, 0);
if (!WGL.wglDeleteContext(contextHandle)) {
throw new GLException("Unable to delete OpenGL context");
}
- contextHandle = 0;
- GLContextShareSet.contextDestroyed(this);
- }
}
- public void copy(GLContext source, int mask) throws GLException {
- long dst = getHandle();
- long src = source.getHandle();
- if (src == 0) {
- throw new GLException("Source OpenGL context has not been created");
- }
- if (dst == 0) {
- throw new GLException("Destination OpenGL context has not been created");
- }
- if (!WGL.wglCopyContext(src, dst, mask)) {
+ protected void copyImpl(GLContext source, int mask) throws GLException {
+ if (!WGL.wglCopyContext(source.getHandle(), getHandle(), mask)) {
throw new GLException("wglCopyContext failed");
}
}
@@ -374,8 +337,7 @@ public class WindowsWGLContext extends GLContextImpl {
wglGetExtensionsStringEXTInitialized=false;
wglGetExtensionsStringEXTAvailable=false;
wglMakeContextCurrentInitialized=false;
- wglMakeContextCurrentARBAvailable=false;
- wglMakeContextCurrentEXTAvailable=false;
+ wglMakeContextCurrentAvailable=false;
if (wglExtProcAddressTable == null) {
// FIXME: cache ProcAddressTables by OpenGL context type bits so we can
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java
index 43c1ff5e0..b1bc9b5ce 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawable.java
@@ -39,7 +39,6 @@
package com.jogamp.opengl.impl.windows.wgl;
-import com.jogamp.common.os.DynamicLookupHelper;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.jogamp.opengl.impl.*;
@@ -65,62 +64,39 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl {
return; // nothing todo ..
}
- if(NativeWindow.LOCK_SURFACE_NOT_READY == lockSurface()) {
- throw new GLException("WindowsWGLDrawable.setRealized(true): lockSurface - surface not ready");
- }
- try {
- NativeWindow nativeWindow = getNativeWindow();
- WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)nativeWindow.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- config.updateGraphicsConfiguration(getFactory(), nativeWindow);
- if (DEBUG) {
- System.err.println("!!! WindowsWGLDrawable.setRealized(true): "+config);
- }
- } finally {
- unlockSurface();
+ NativeWindow nativeWindow = getNativeWindow();
+ WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)nativeWindow.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ config.updateGraphicsConfiguration(getFactory(), nativeWindow);
+ if (DEBUG) {
+ System.err.println("!!! WindowsWGLDrawable.setRealized(true): "+config);
}
}
protected void swapBuffersImpl() {
- boolean didLock = false;
-
- if ( !isSurfaceLocked() ) {
- // Usually the surface shall be locked within [makeCurrent .. swap .. release]
- if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
- return;
- }
- didLock = true;
+ long startTime = 0;
+ if (PROFILING) {
+ startTime = System.currentTimeMillis();
}
- try {
- long startTime = 0;
- if (PROFILING) {
- startTime = System.currentTimeMillis();
- }
-
- if (!WGL.SwapBuffers(getNativeWindow().getSurfaceHandle()) && (WGL.GetLastError() != 0)) {
- throw new GLException("Error swapping buffers");
- }
+ if (!GDI.SwapBuffers(getHandle()) && (GDI.GetLastError() != 0)) {
+ throw new GLException("Error swapping buffers");
+ }
- if (PROFILING) {
- long endTime = System.currentTimeMillis();
- profilingSwapBuffersTime += (endTime - startTime);
- int ticks = PROFILING_TICKS;
- if (++profilingSwapBuffersTicks == ticks) {
- System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + ticks + " calls (" +
- ((float) profilingSwapBuffersTime / (float) ticks) + " ms/call)");
- profilingSwapBuffersTime = 0;
- profilingSwapBuffersTicks = 0;
- }
- }
- } finally {
- if (didLock) {
- unlockSurface();
- }
+ if (PROFILING) {
+ long endTime = System.currentTimeMillis();
+ profilingSwapBuffersTime += (endTime - startTime);
+ int ticks = PROFILING_TICKS;
+ if (++profilingSwapBuffersTicks == ticks) {
+ System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + ticks + " calls (" +
+ ((float) profilingSwapBuffersTime / (float) ticks) + " ms/call)");
+ profilingSwapBuffersTime = 0;
+ profilingSwapBuffersTicks = 0;
+ }
}
}
- public DynamicLookupHelper getDynamicLookupHelper() {
- return (WindowsWGLDrawableFactory) getFactoryImpl() ;
+ public GLDynamicLookupHelper getGLDynamicLookupHelper() {
+ return getFactoryImpl().getGLDynamicLookupHelper(0);
}
protected static String getThreadName() {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
index d2eb98bdf..3fbe769e5 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -39,7 +39,6 @@
package com.jogamp.opengl.impl.windows.wgl;
-import com.jogamp.common.os.DynamicLookupHelper;
import java.nio.*;
import java.util.*;
import javax.media.nativewindow.*;
@@ -50,15 +49,29 @@ import com.jogamp.common.util.*;
import com.jogamp.opengl.impl.*;
import com.jogamp.nativewindow.impl.NullWindow;
-public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements DynamicLookupHelper {
+public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
private static final boolean VERBOSE = Debug.verbose();
- // Handle to GLU32.dll
- // FIXME: this should go away once we delete support for the C GLU library
- private long hglu32;
+ private static final DesktopGLDynamicLookupHelper windowsWGLDynamicLookupHelper;
- // Handle to core OpenGL32.dll
- private long hopengl32;
+ static {
+ DesktopGLDynamicLookupHelper tmp = null;
+ try {
+ tmp = new DesktopGLDynamicLookupHelper(new WindowsWGLDynamicLibraryBundleInfo());
+ } catch (GLException gle) {
+ if(DEBUG) {
+ gle.printStackTrace();
+ }
+ }
+ windowsWGLDynamicLookupHelper = tmp;
+ if(null!=windowsWGLDynamicLookupHelper) {
+ WGL.getWGLProcAddressTable().reset(windowsWGLDynamicLookupHelper);
+ }
+ }
+
+ public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
+ return windowsWGLDynamicLookupHelper;
+ }
public WindowsWGLDrawableFactory() {
super();
@@ -71,8 +84,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
new Object[] {});
} catch (JogampRuntimeException jre) { /* n/a .. */ }
- loadOpenGL32Library();
-
try {
sharedDrawable = new WindowsDummyWGLDrawable(this, null);
WindowsWGLContext ctx = (WindowsWGLContext) sharedDrawable.createContext(null);
@@ -194,53 +205,15 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
return WindowsExternalWGLDrawable.create(this, null);
}
- public void loadOpenGL32Library() {
- if (hopengl32 == 0) {
- hopengl32 = WGL.LoadLibraryA("OpenGL32");
- if (DEBUG) {
- if (hopengl32 == 0) {
- System.err.println("WindowsWGLDrawableFactory: Could not load OpenGL32.dll - maybe an embedded device");
- }
- }
- }
- }
-
- public void loadGLULibrary() {
- if (hglu32 == 0) {
- hglu32 = WGL.LoadLibraryA("GLU32");
- if (hglu32 == 0) {
- throw new GLException("Error loading GLU32.DLL");
- }
- }
- }
-
- public long dynamicLookupFunction(String glFuncName) {
- long res = WGL.wglGetProcAddress(glFuncName);
- if (res == 0) {
- // It may happen that a driver doesn't return the OpenGL32 core function pointer
- // with wglGetProcAddress (e.g. NVidia GL 3.1) - hence we have to look harder.
- if (hopengl32 != 0) {
- res = WGL.GetProcAddress(hopengl32, glFuncName);
- }
- }
- if (res == 0) {
- // GLU routines aren't known to the OpenGL function lookup
- if (hglu32 != 0) {
- res = WGL.GetProcAddress(hglu32, glFuncName);
- }
- }
- return res;
- }
-
static String wglGetLastError() {
- long err = WGL.GetLastError();
+ long err = GDI.GetLastError();
String detail = null;
switch ((int) err) {
- case WGL.ERROR_INVALID_PIXEL_FORMAT: detail = "ERROR_INVALID_PIXEL_FORMAT"; break;
- case WGL.ERROR_NO_SYSTEM_RESOURCES: detail = "ERROR_NO_SYSTEM_RESOURCES"; break;
- case WGL.ERROR_INVALID_DATA: detail = "ERROR_INVALID_DATA"; break;
- case WGL.ERROR_PROC_NOT_FOUND: detail = "ERROR_PROC_NOT_FOUND"; break;
- case WGL.ERROR_INVALID_WINDOW_HANDLE:detail = "ERROR_INVALID_WINDOW_HANDLE"; break;
+ case GDI.ERROR_INVALID_PIXEL_FORMAT: detail = "ERROR_INVALID_PIXEL_FORMAT"; break;
+ case GDI.ERROR_NO_SYSTEM_RESOURCES: detail = "ERROR_NO_SYSTEM_RESOURCES"; break;
+ case GDI.ERROR_INVALID_DATA: detail = "ERROR_INVALID_DATA"; break;
+ case GDI.ERROR_PROC_NOT_FOUND: detail = "ERROR_PROC_NOT_FOUND"; break;
+ case GDI.ERROR_INVALID_WINDOW_HANDLE:detail = "ERROR_INVALID_WINDOW_HANDLE"; break;
default: detail = "(Unknown error code " + err + ")"; break;
}
return detail;
@@ -274,17 +247,17 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
rampData[i + 2 * GAMMA_RAMP_LENGTH] = scaledValue;
}
- long screenDC = WGL.GetDC(0);
- boolean res = WGL.SetDeviceGammaRamp(screenDC, ShortBuffer.wrap(rampData));
- WGL.ReleaseDC(0, screenDC);
+ long screenDC = GDI.GetDC(0);
+ boolean res = GDI.SetDeviceGammaRamp(screenDC, ShortBuffer.wrap(rampData));
+ GDI.ReleaseDC(0, screenDC);
return res;
}
protected Buffer getGammaRamp() {
ShortBuffer rampData = ShortBuffer.wrap(new short[3 * GAMMA_RAMP_LENGTH]);
- long screenDC = WGL.GetDC(0);
- boolean res = WGL.GetDeviceGammaRamp(screenDC, rampData);
- WGL.ReleaseDC(0, screenDC);
+ long screenDC = GDI.GetDC(0);
+ boolean res = GDI.GetDeviceGammaRamp(screenDC, rampData);
+ GDI.ReleaseDC(0, screenDC);
if (!res) {
return null;
}
@@ -296,8 +269,8 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
// getGammaRamp failed earlier
return;
}
- long screenDC = WGL.GetDC(0);
- WGL.SetDeviceGammaRamp(screenDC, originalGammaRamp);
- WGL.ReleaseDC(0, screenDC);
+ long screenDC = GDI.GetDC(0);
+ GDI.SetDeviceGammaRamp(screenDC, originalGammaRamp);
+ GDI.ReleaseDC(0, screenDC);
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDynamicLibraryBundleInfo.java
new file mode 100644
index 000000000..7bff1e3c1
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDynamicLibraryBundleInfo.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2010, Sven Gothel
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sven Gothel nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Sven Gothel BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.jogamp.opengl.impl.windows.wgl;
+
+import com.jogamp.opengl.impl.*;
+import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.common.os.NativeLibrary;
+import com.jogamp.common.os.Platform;
+import java.util.*;
+import java.security.*;
+import javax.media.opengl.GLException;
+
+public class WindowsWGLDynamicLibraryBundleInfo extends DesktopGLDynamicLibraryBundleInfo {
+ protected WindowsWGLDynamicLibraryBundleInfo() {
+ super();
+ }
+
+ public List getToolLibNames() {
+ List/*<String>*/ libNamesList = new ArrayList();
+
+ libNamesList.add("OpenGL32");
+
+ return libNamesList;
+ }
+
+
+ public final List getToolGetProcAddressFuncNameList() {
+ List res = new ArrayList();
+ res.add("wglGetProcAddress");
+ return res;
+ }
+
+ public final long toolDynamicLookupFunction(long toolGetProcAddressHandle, String funcName) {
+ return WGL.wglGetProcAddress(toolGetProcAddressHandle, funcName);
+ }
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index aed4012a4..eb5719566 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -67,7 +67,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
glp = GLProfile.getDefault();
}
PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor();
- if (WGL.DescribePixelFormat(hdc, pfdID, pfd.size(), pfd) == 0) {
+ if (GDI.DescribePixelFormat(hdc, pfdID, pfd.size(), pfd) == 0) {
throw new GLException("Unable to describe pixel format " + pfdID);
}
@@ -215,10 +215,10 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
}
}
} else {
- long lastErr = WGL.GetLastError();
+ long lastErr = GDI.GetLastError();
// Intel Extreme graphics fails with a zero error code
if (lastErr != 0) {
- throw new GLException("Unable to enumerate pixel formats of window using wglGetPixelFormatAttribivARB: error code " + WGL.GetLastError());
+ throw new GLException("Unable to enumerate pixel formats of window using wglGetPixelFormatAttribivARB: error code " + GDI.GetLastError());
}
}
return availableCaps;
@@ -539,7 +539,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
// PIXELFORMAT
public static GLCapabilities PFD2GLCapabilities(GLProfile glp, PIXELFORMATDESCRIPTOR pfd, boolean onscreen, boolean usePBuffer) {
- if ((pfd.getDwFlags() & WGL.PFD_SUPPORT_OPENGL) == 0) {
+ if ((pfd.getDwFlags() & GDI.PFD_SUPPORT_OPENGL) == 0) {
return null;
}
GLCapabilities res = new GLCapabilities(glp);
@@ -553,11 +553,11 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
res.setAccumAlphaBits(pfd.getCAccumAlphaBits());
res.setDepthBits (pfd.getCDepthBits());
res.setStencilBits (pfd.getCStencilBits());
- res.setDoubleBuffered((pfd.getDwFlags() & WGL.PFD_DOUBLEBUFFER) != 0);
- res.setStereo ((pfd.getDwFlags() & WGL.PFD_STEREO) != 0);
- res.setHardwareAccelerated( ((pfd.getDwFlags() & WGL.PFD_GENERIC_FORMAT) == 0) ||
- ((pfd.getDwFlags() & WGL.PFD_GENERIC_ACCELERATED) != 0) );
- res.setOnscreen ( onscreen && ((pfd.getDwFlags() & WGL.PFD_DRAW_TO_WINDOW) != 0) );
+ res.setDoubleBuffered((pfd.getDwFlags() & GDI.PFD_DOUBLEBUFFER) != 0);
+ res.setStereo ((pfd.getDwFlags() & GDI.PFD_STEREO) != 0);
+ res.setHardwareAccelerated( ((pfd.getDwFlags() & GDI.PFD_GENERIC_FORMAT) == 0) ||
+ ((pfd.getDwFlags() & GDI.PFD_GENERIC_ACCELERATED) != 0) );
+ res.setOnscreen ( onscreen && ((pfd.getDwFlags() & GDI.PFD_DRAW_TO_WINDOW) != 0) );
res.setPBuffer ( usePBuffer );
/* FIXME: Missing ??
if (GLXUtil.isMultisampleAvailable()) {
@@ -580,21 +580,21 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
throw new GLException("Bit depths < 15 (i.e., non-true-color) not supported");
}
PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor();
- int pfdFlags = (WGL.PFD_SUPPORT_OPENGL |
- WGL.PFD_GENERIC_ACCELERATED);
+ int pfdFlags = (GDI.PFD_SUPPORT_OPENGL |
+ GDI.PFD_GENERIC_ACCELERATED);
if (caps.getDoubleBuffered()) {
- pfdFlags |= WGL.PFD_DOUBLEBUFFER;
+ pfdFlags |= GDI.PFD_DOUBLEBUFFER;
}
if (caps.isOnscreen()) {
- pfdFlags |= WGL.PFD_DRAW_TO_WINDOW;
+ pfdFlags |= GDI.PFD_DRAW_TO_WINDOW;
} else {
- pfdFlags |= WGL.PFD_DRAW_TO_BITMAP;
+ pfdFlags |= GDI.PFD_DRAW_TO_BITMAP;
}
if (caps.getStereo()) {
- pfdFlags |= WGL.PFD_STEREO;
+ pfdFlags |= GDI.PFD_STEREO;
}
pfd.setDwFlags(pfdFlags);
- pfd.setIPixelType((byte) WGL.PFD_TYPE_RGBA);
+ pfd.setIPixelType((byte) GDI.PFD_TYPE_RGBA);
pfd.setCColorBits((byte) colorDepth);
pfd.setCRedBits ((byte) caps.getRedBits());
pfd.setCGreenBits((byte) caps.getGreenBits());
@@ -610,7 +610,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
pfd.setCAccumAlphaBits((byte) caps.getAccumAlphaBits());
pfd.setCDepthBits((byte) caps.getDepthBits());
pfd.setCStencilBits((byte) caps.getStencilBits());
- pfd.setILayerType((byte) WGL.PFD_MAIN_PLANE);
+ pfd.setILayerType((byte) GDI.PFD_MAIN_PLANE);
/* FIXME: Missing:
caps.getSampleBuffers()
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index ab3227257..e76e63f23 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -118,7 +118,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
GLCapabilities chosenCaps = null;
if (onscreen) {
- if ((pixelFormat = WGL.GetPixelFormat(hdc)) != 0) {
+ if ((pixelFormat = GDI.GetPixelFormat(hdc)) != 0) {
// Pixelformat already set by either
// - a previous updateGraphicsConfiguration() call on the same HDC,
// - the graphics driver, copying the HDC's pixelformat to the new one,
@@ -171,13 +171,13 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
}
} else {
if (DEBUG) {
- System.err.println(getThreadName() + ": wglChoosePixelFormatARB failed: " + WGL.GetLastError() );
+ System.err.println(getThreadName() + ": wglChoosePixelFormatARB failed: " + GDI.GetLastError() );
Thread.dumpStack();
}
}
if (DEBUG) {
if (recommendedPixelFormat <= 0) {
- System.err.print(getThreadName() + ": wglChoosePixelFormatARB didn't recommend a pixel format: "+WGL.GetLastError());
+ System.err.print(getThreadName() + ": wglChoosePixelFormatARB didn't recommend a pixel format: "+GDI.GetLastError());
if (capabilities.getSampleBuffers()) {
System.err.print(" for multisampled GLCapabilities");
}
@@ -200,23 +200,23 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
if (!gotAvailableCaps) {
if (DEBUG) {
- System.err.println(getThreadName() + ": Using ChoosePixelFormat ... (LastError: "+WGL.GetLastError()+")");
+ System.err.println(getThreadName() + ": Using ChoosePixelFormat ... (LastError: "+GDI.GetLastError()+")");
}
pfd = WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(capabilities);
- recommendedPixelFormat = WGL.ChoosePixelFormat(hdc, pfd);
+ recommendedPixelFormat = GDI.ChoosePixelFormat(hdc, pfd);
if (DEBUG) {
- System.err.println(getThreadName() + ": ChoosePixelFormat(HDC "+toHexString(hdc)+") = " + recommendedPixelFormat + " (LastError: "+WGL.GetLastError()+")");
+ System.err.println(getThreadName() + ": ChoosePixelFormat(HDC "+toHexString(hdc)+") = " + recommendedPixelFormat + " (LastError: "+GDI.GetLastError()+")");
System.err.println(getThreadName() + ": Used " + capabilities);
}
- numFormats = WGL.DescribePixelFormat(hdc, 1, 0, null);
+ numFormats = GDI.DescribePixelFormat(hdc, 1, 0, null);
if (numFormats == 0) {
throw new GLException("Unable to enumerate pixel formats of window " +
- toHexString(hdc) + " for GLCapabilitiesChooser (LastError: "+WGL.GetLastError()+")");
+ toHexString(hdc) + " for GLCapabilitiesChooser (LastError: "+GDI.GetLastError()+")");
}
availableCaps = new GLCapabilities[numFormats];
for (int i = 0; i < numFormats; i++) {
- if (WGL.DescribePixelFormat(hdc, 1 + i, pfd.size(), pfd) == 0) {
+ if (GDI.DescribePixelFormat(hdc, 1 + i, pfd.size(), pfd) == 0) {
throw new GLException("Error describing pixel format " + (1 + i) + " of device context");
}
availableCaps[i] = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, pfd, onscreen, usePBuffer);
@@ -261,23 +261,23 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
System.err.println(getThreadName() + ": Chosen pixel format (" + pixelFormat + "):");
System.err.println(chosenCaps);
}
- if (WGL.DescribePixelFormat(hdc, pixelFormat, pfd.size(), pfd) == 0) {
- throw new GLException("Error re-describing the chosen pixel format: " + WGL.GetLastError());
+ if (GDI.DescribePixelFormat(hdc, pixelFormat, pfd.size(), pfd) == 0) {
+ throw new GLException("Error re-describing the chosen pixel format: " + GDI.GetLastError());
}
} else {
// For now, use ChoosePixelFormat for offscreen surfaces until
// we figure out how to properly choose an offscreen-
// compatible pixel format
pfd = WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(capabilities);
- pixelFormat = WGL.ChoosePixelFormat(hdc, pfd);
+ pixelFormat = GDI.ChoosePixelFormat(hdc, pfd);
}
if(!pixelFormatSet) {
- if (!WGL.SetPixelFormat(hdc, pixelFormat, pfd)) {
- long lastError = WGL.GetLastError();
+ if (!GDI.SetPixelFormat(hdc, pixelFormat, pfd)) {
+ long lastError = GDI.GetLastError();
if (DEBUG) {
System.err.println(getThreadName() + ": SetPixelFormat failed: current context = " + WGL.wglGetCurrentContext() +
", current DC = " + WGL.wglGetCurrentDC());
- System.err.println(getThreadName() + ": GetPixelFormat(hdc " + toHexString(hdc) + ") returns " + WGL.GetPixelFormat(hdc));
+ System.err.println(getThreadName() + ": GetPixelFormat(hdc " + toHexString(hdc) + ") returns " + GDI.GetPixelFormat(hdc));
}
throw new GLException("Unable to set pixel format " + pixelFormat + " for device context " + toHexString(hdc) + ": error code " + lastError);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/GLXUtil.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/GLXUtil.java
index 804a262fe..ddcac9628 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/GLXUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/GLXUtil.java
@@ -37,28 +37,25 @@ import javax.media.opengl.*;
import com.jogamp.nativewindow.impl.x11.*;
public class GLXUtil {
- public static boolean isMultisampleAvailable(long display) {
- X11Util.XLockDisplay(display);
- try {
- String exts = GLX.glXGetClientString(display, GLX.GLX_EXTENSIONS);
- if (exts != null) {
- return (exts.indexOf("GLX_ARB_multisample") >= 0);
- }
- return false;
- } finally {
- X11Util.XUnlockDisplay(display);
+ public static String getExtension(long display) {
+ return GLX.glXGetClientString(display, GLX.GLX_EXTENSIONS);
+ }
+
+ public static boolean isMultisampleAvailable(String extensions) {
+ if (extensions != null) {
+ return (extensions.indexOf("GLX_ARB_multisample") >= 0);
}
+ return false;
+ }
+
+ public static boolean isMultisampleAvailable(long display) {
+ return isMultisampleAvailable(getExtension(display));
}
/** Workaround for apparent issue with ATI's proprietary drivers
where direct contexts still send GLX tokens for GL calls */
public static String getVendorName(long display) {
- X11Util.XLockDisplay(display);
- try {
- return GLX.glXGetClientString(display, GLX.GLX_VENDOR);
- } finally {
- X11Util.XUnlockDisplay(display);
- }
+ return GLX.glXGetClientString(display, GLX.GLX_VENDOR);
}
public static boolean isVendorNVIDIA(String vendor) {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java
index 03783f3b9..afd005bb4 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11DummyGLXDrawable.java
@@ -64,13 +64,10 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable {
int scrn = screen.getIndex();
long visualID = config.getVisualID();
- X11Util.XLockDisplay(dpy);
- try{
- dummyWindow = X11Lib.CreateDummyWindow(dpy, scrn, visualID);
- } finally {
- X11Util.XUnlockDisplay(dpy);
- }
+ dummyWindow = X11Lib.CreateDummyWindow(dpy, scrn, visualID);
nw.setSurfaceHandle( dummyWindow );
+
+ updateHandle();
}
public void setSize(int width, int height) {
@@ -86,9 +83,9 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable {
public void destroy() {
if(0!=dummyWindow) {
+ destroyHandle();
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- long dpy = config.getScreen().getDevice().getHandle();
- X11Lib.DestroyDummyWindow(dpy, dummyWindow);
+ X11Lib.DestroyDummyWindow(config.getScreen().getDevice().getHandle(), dummyWindow);
}
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java
index 8792ac08e..a1e4585f7 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXContext.java
@@ -59,36 +59,32 @@ public class X11ExternalGLXContext extends X11GLXContext {
}
protected static X11ExternalGLXContext create(GLDrawableFactory factory, GLProfile glp) {
- ((GLDrawableFactoryImpl)factory).lockToolkit();
- try {
- long ctx = GLX.glXGetCurrentContext();
- if (ctx == 0) {
- throw new GLException("Error: current context null");
- }
- long display = GLX.glXGetCurrentDisplay();
- if (display == 0) {
- throw new GLException("Error: current display null");
- }
- long drawable = GLX.glXGetCurrentDrawable();
- if (drawable == 0) {
- throw new GLException("Error: attempted to make an external GLDrawable without a drawable/context current");
- }
- int[] val = new int[1];
- GLX.glXQueryContext(display, ctx, GLX.GLX_SCREEN, val, 0);
- X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0]);
-
- GLX.glXQueryContext(display, ctx, GLX.GLX_FBCONFIG_ID, val, 0);
- X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]);
-
- NullWindow nw = new NullWindow(cfg);
- nw.setSurfaceHandle(drawable);
- return new X11ExternalGLXContext(new Drawable(factory, nw), ctx);
- } finally {
- ((GLDrawableFactoryImpl)factory).unlockToolkit();
+ long ctx = GLX.glXGetCurrentContext();
+ if (ctx == 0) {
+ throw new GLException("Error: current context null");
}
+ long display = GLX.glXGetCurrentDisplay();
+ if (display == 0) {
+ throw new GLException("Error: current display null");
+ }
+ long drawable = GLX.glXGetCurrentDrawable();
+ if (drawable == 0) {
+ throw new GLException("Error: attempted to make an external GLDrawable without a drawable/context current");
+ }
+ int[] val = new int[1];
+ GLX.glXQueryContext(display, ctx, GLX.GLX_SCREEN, val, 0);
+ X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0]);
+
+ GLX.glXQueryContext(display, ctx, GLX.GLX_FBCONFIG_ID, val, 0);
+ X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]);
+
+ NullWindow nw = new NullWindow(cfg);
+ nw.setSurfaceHandle(drawable);
+ return new X11ExternalGLXContext(new Drawable(factory, nw), ctx);
}
- protected void create() {
+ protected boolean createImpl() {
+ return true;
}
public int makeCurrent() throws GLException {
@@ -108,20 +104,16 @@ public class X11ExternalGLXContext extends X11GLXContext {
lastContext = null;
}
- protected int makeCurrentImpl() throws GLException {
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
if (firstMakeCurrent) {
firstMakeCurrent = false;
- return CONTEXT_CURRENT_NEW;
}
- return CONTEXT_CURRENT;
}
protected void releaseImpl() throws GLException {
}
protected void destroyImpl() throws GLException {
- contextHandle = 0;
- GLContextShareSet.contextDestroyed(this);
}
// Need to provide the display connection to extension querying APIs
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXDrawable.java
index f10bd38c6..8a8702a3e 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11ExternalGLXDrawable.java
@@ -62,46 +62,41 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable {
}
protected static X11ExternalGLXDrawable create(GLDrawableFactory factory, GLProfile glp) {
- ((GLDrawableFactoryImpl)factory).lockToolkit();
- try {
- long context = GLX.glXGetCurrentContext();
- if (context == 0) {
- throw new GLException("Error: current context null");
- }
- long display = GLX.glXGetCurrentDisplay();
- if (display == 0) {
- throw new GLException("Error: current display null");
- }
- long drawable = GLX.glXGetCurrentDrawable();
- if (drawable == 0) {
- throw new GLException("Error: attempted to make an external GLDrawable without a drawable current");
- }
- int[] val = new int[1];
- GLX.glXQueryContext(display, context, GLX.GLX_SCREEN, val, 0);
- X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0]);
-
- GLX.glXQueryContext(display, context, GLX.GLX_FBCONFIG_ID, val, 0);
- X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]);
-
- int w, h;
- GLX.glXQueryDrawable(display, drawable, GLX.GLX_WIDTH, val, 0);
- w=val[0];
- GLX.glXQueryDrawable(display, drawable, GLX.GLX_HEIGHT, val, 0);
- h=val[0];
-
- GLX.glXQueryContext(display, context, GLX.GLX_RENDER_TYPE, val, 0);
- if ((val[0] & GLX.GLX_RGBA_TYPE) == 0) {
- if (DEBUG) {
- System.err.println("X11ExternalGLXDrawable: WARNING: forcing GLX_RGBA_TYPE for newly created contexts (current 0x"+Integer.toHexString(val[0])+")");
- }
- }
- NullWindow nw = new NullWindow(cfg);
- nw.setSurfaceHandle(drawable);
- nw.setSize(w, h);
- return new X11ExternalGLXDrawable(factory, nw, GLX.GLX_RGBA_TYPE);
- } finally {
- ((GLDrawableFactoryImpl)factory).unlockToolkit();
+ long context = GLX.glXGetCurrentContext();
+ if (context == 0) {
+ throw new GLException("Error: current context null");
}
+ long display = GLX.glXGetCurrentDisplay();
+ if (display == 0) {
+ throw new GLException("Error: current display null");
+ }
+ long drawable = GLX.glXGetCurrentDrawable();
+ if (drawable == 0) {
+ throw new GLException("Error: attempted to make an external GLDrawable without a drawable current");
+ }
+ int[] val = new int[1];
+ GLX.glXQueryContext(display, context, GLX.GLX_SCREEN, val, 0);
+ X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0]);
+
+ GLX.glXQueryContext(display, context, GLX.GLX_FBCONFIG_ID, val, 0);
+ X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]);
+
+ int w, h;
+ GLX.glXQueryDrawable(display, drawable, GLX.GLX_WIDTH, val, 0);
+ w=val[0];
+ GLX.glXQueryDrawable(display, drawable, GLX.GLX_HEIGHT, val, 0);
+ h=val[0];
+
+ GLX.glXQueryContext(display, context, GLX.GLX_RENDER_TYPE, val, 0);
+ if ((val[0] & GLX.GLX_RGBA_TYPE) == 0) {
+ if (DEBUG) {
+ System.err.println("X11ExternalGLXDrawable: WARNING: forcing GLX_RGBA_TYPE for newly created contexts (current 0x"+Integer.toHexString(val[0])+")");
+ }
+ }
+ NullWindow nw = new NullWindow(cfg);
+ nw.setSurfaceHandle(drawable);
+ nw.setSize(w, h);
+ return new X11ExternalGLXDrawable(factory, nw, GLX.GLX_RGBA_TYPE);
}
public GLContext createContext(GLContext shareWith) {
@@ -125,8 +120,8 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable {
super(drawable, shareWith);
}
- protected void create() {
- createContext(true);
+ protected boolean createImpl() {
+ return createContext(true);
}
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
index b81521729..baa6ce1aa 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java
@@ -60,6 +60,11 @@ public abstract class X11GLXContext extends GLContextImpl {
// GLX extension functions.
private GLXExtProcAddressTable glXExtProcAddressTable;
+ // This indicates whether the context we have created is indirect
+ // and therefore requires the toolkit to be locked around all GL
+ // calls rather than just all GLX calls
+ protected boolean isDirect;
+
static {
functionNameMap = new HashMap();
functionNameMap.put("glAllocateMemoryNV", "glXAllocateMemoryNV");
@@ -192,14 +197,8 @@ public abstract class X11GLXContext extends GLContextImpl {
re.printStackTrace();
}
}
- if(DEBUG) {
- System.err.println("X11GLXContext.createContextARB success: "+(0!=ctx)+" - "+getGLVersion(major, minor, ctp, "@creation")+", bwdCompat "+ctBwdCompat+", fwdCompat "+ctFwdCompat);
- }
if(0!=ctx) {
- if (!glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- ctx)) {
+ if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), ctx)) {
if(DEBUG) {
System.err.println("X11GLXContext.createContextARB couldn't make current "+getGLVersion(major, minor, ctp, "@creation"));
}
@@ -216,10 +215,8 @@ public abstract class X11GLXContext extends GLContextImpl {
* called by {@link #create()}.
* Note: The direct parameter may be overwritten by the direct state of a shared context.
*/
- protected void createContext(boolean direct) {
- if(0!=contextHandle) {
- throw new GLException("context is not null: "+contextHandle);
- }
+ protected boolean createContext(boolean direct) {
+ isDirect = false; // default
X11GLXDrawableFactory factory = (X11GLXDrawableFactory)drawable.getFactoryImpl();
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
long display = config.getScreen().getDevice().getHandle();
@@ -247,14 +244,12 @@ public abstract class X11GLXContext extends GLContextImpl {
if (contextHandle == 0) {
throw new GLException("Unable to create context(0)");
}
- if (!glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- contextHandle)) {
+ if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
throw new GLException("Error making temp context(0) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable);
}
setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
- return;
+ isDirect = GLX.glXIsDirect(display, contextHandle);
+ return true;
}
int minor[] = new int[1];
@@ -279,26 +274,27 @@ public abstract class X11GLXContext extends GLContextImpl {
if (temp_ctx == 0) {
throw new GLException("Unable to create temp OpenGL context(1)");
}
- if (!glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- temp_ctx)) {
+ if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), temp_ctx)) {
throw new GLException("Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(temp_ctx)+", drawable "+drawable);
}
setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
if( createContextARBTried ||
!isFunctionAvailable("glXCreateContextAttribsARB") ||
- !isExtensionAvailable("GLX_ARB_create_context") ) {
+ !isExtensionAvailable("GLX_ARB_create_context") ) {
if(glp.isGL3()) {
glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_ctx);
throw new GLException("Unable to create OpenGL >= 3.1 context (failed GLX_ARB_create_context), GLProfile "+glp+", Drawable "+drawable);
}
+ if(DEBUG) {
+ System.err.println("X11GLXContext.createContext: createContextARBTried "+createContextARBTried+", hasFunc glXCreateContextAttribsARB: "+isFunctionAvailable("glXCreateContextAttribsARB")+", hasExt GLX_ARB_create_context: "+isExtensionAvailable("GLX_ARB_create_context"));
+ }
// continue with temp context for GL < 3.0
contextHandle = temp_ctx;
- return;
+ isDirect = GLX.glXIsDirect(display, contextHandle);
+ return true;
}
contextHandle = createContextARB(share, direct, major, minor, ctp);
createContextARBTried=true;
@@ -308,10 +304,7 @@ public abstract class X11GLXContext extends GLContextImpl {
if(0!=temp_ctx) {
glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_ctx);
- if (!glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- contextHandle)) {
+ if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
throw new GLException("Cannot make previous verified context current");
}
}
@@ -327,146 +320,63 @@ public abstract class X11GLXContext extends GLContextImpl {
// continue with temp context for GL <= 3.0
contextHandle = temp_ctx;
- if (!glXMakeContextCurrent(display,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- contextHandle)) {
+ if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_ctx);
throw new GLException("Error making context(1) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable);
}
}
+ isDirect = GLX.glXIsDirect(display, contextHandle);
+ return true;
}
- // Note: Usually the surface shall be locked within [makeCurrent .. swap .. release]
- protected int makeCurrentImpl() throws GLException {
- boolean exceptionOccurred = false;
- int lockRes = drawable.lockSurface();
- try {
- if (lockRes == NativeWindow.LOCK_SURFACE_NOT_READY) {
- return CONTEXT_NOT_CURRENT;
- }
- if (0 == drawable.getNativeWindow().getSurfaceHandle()) {
- throw new GLException("drawable has invalid surface handle: "+drawable);
- }
- return makeCurrentImplAfterLock();
- } catch (RuntimeException e) {
- exceptionOccurred = true;
- throw e;
- } finally {
- if (exceptionOccurred ||
- (isOptimizable() && lockRes != NativeWindow.LOCK_SURFACE_NOT_READY) && drawable.isSurfaceLocked()) {
- drawable.unlockSurface();
- }
- }
- }
-
- // Note: Usually the surface shall be locked within [makeCurrent .. swap .. release]
- protected void releaseImpl() throws GLException {
- try {
- releaseImplAfterLock();
- } finally {
- if (!isOptimizable() && drawable.isSurfaceLocked()) {
- drawable.unlockSurface();
- }
- }
- }
-
- protected int makeCurrentImplAfterLock() throws GLException {
+ protected void makeCurrentImpl(boolean newCreated) throws GLException {
long dpy = drawable.getNativeWindow().getDisplayHandle();
- getDrawableImpl().getFactoryImpl().lockToolkit();
- try {
- boolean newCreated = false;
- if (!isCreated()) {
- create(); // throws exception if fails!
- newCreated = true;
- GLContextShareSet.contextCreated(this);
- if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Created GL context " + toHexString(contextHandle) + " for " + getClass().getName());
- }
+ if (GLX.glXGetCurrentContext() != contextHandle) {
+ if (!glXMakeContextCurrent(dpy, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
+ throw new GLException("Error making context current: "+this);
}
-
- if (GLX.glXGetCurrentContext() != contextHandle) {
-
- if (!glXMakeContextCurrent(dpy,
- drawable.getNativeWindow().getSurfaceHandle(),
- drawableRead.getNativeWindow().getSurfaceHandle(),
- contextHandle)) {
- throw new GLException("Error making context current: "+this);
- }
- if (DEBUG && (VERBOSE || isCreated())) {
- System.err.println(getThreadName() + ": glXMakeCurrent(display " +
- toHexString(dpy)+
- ", drawable " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) +
- ", drawableRead " + toHexString(drawableRead.getNativeWindow().getSurfaceHandle()) +
- ", context " + toHexString(contextHandle) + ") succeeded");
- }
- }
-
- if(newCreated) {
- setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
- return CONTEXT_CURRENT_NEW;
+ if (DEBUG && (VERBOSE || isCreated())) {
+ System.err.println(getThreadName() + ": glXMakeCurrent(display " +
+ toHexString(dpy)+
+ ", drawable " + toHexString(drawable.getHandle()) +
+ ", drawableRead " + toHexString(drawableRead.getHandle()) +
+ ", context " + toHexString(contextHandle) + ") succeeded");
}
- return CONTEXT_CURRENT;
- } finally {
- getDrawableImpl().getFactoryImpl().unlockToolkit();
}
}
- protected void releaseImplAfterLock() throws GLException {
- X11GLXDrawableFactory factory = (X11GLXDrawableFactory)drawable.getFactoryImpl();
- factory.lockToolkit();
- try {
- if (!glXMakeContextCurrent(drawable.getNativeWindow().getDisplayHandle(), 0, 0, 0)) {
- throw new GLException("Error freeing OpenGL context");
- }
- } finally {
- factory.unlockToolkit();
+ protected void releaseImpl() throws GLException {
+ long display = drawable.getNativeWindow().getDisplayHandle();
+ if (!glXMakeContextCurrent(display, 0, 0, 0)) {
+ throw new GLException("Error freeing OpenGL context");
}
}
protected void destroyImpl() throws GLException {
- getDrawableImpl().getFactoryImpl().lockToolkit();
- try {
- if (contextHandle != 0) {
- if (DEBUG) {
- System.err.println("glXDestroyContext(" +
- toHexString(drawable.getNativeWindow().getDisplayHandle()) +
- ", " +
- toHexString(contextHandle) + ")");
- }
- GLX.glXDestroyContext(drawable.getNativeWindow().getDisplayHandle(), contextHandle);
- if (DEBUG) {
- System.err.println("!!! Destroyed OpenGL context " + contextHandle);
- }
- contextHandle = 0;
- GLContextShareSet.contextDestroyed(this);
- }
- } finally {
- getDrawableImpl().getFactoryImpl().unlockToolkit();
+ long display = drawable.getNativeWindow().getDisplayHandle();
+ if (DEBUG) {
+ System.err.println("glXDestroyContext(dpy " +
+ toHexString(display)+
+ ", ctx " +
+ toHexString(contextHandle) + ")");
+ }
+ GLX.glXDestroyContext(display, contextHandle);
+ if (DEBUG) {
+ System.err.println("!!! Destroyed OpenGL context " + contextHandle);
}
}
- public void copy(GLContext source, int mask) throws GLException {
+ protected void copyImpl(GLContext source, int mask) throws GLException {
long dst = getHandle();
long src = source.getHandle();
- if (src == 0) {
- throw new GLException("Source OpenGL context has not been created");
- }
- if (dst == 0) {
- throw new GLException("Destination OpenGL context has not been created");
- }
- if (drawable.getNativeWindow().getDisplayHandle() == 0) {
+ long display = drawable.getNativeWindow().getDisplayHandle();
+ if (0 == display) {
throw new GLException("Connection to X display not yet set up");
}
- getDrawableImpl().getFactoryImpl().lockToolkit();
- try {
- GLX.glXCopyContext(drawable.getNativeWindow().getDisplayHandle(), src, dst, mask);
- // Should check for X errors and raise GLException
- } finally {
- getDrawableImpl().getFactoryImpl().unlockToolkit();
- }
+ GLX.glXCopyContext(display, src, dst, mask);
+ // Should check for X errors and raise GLException
}
protected void updateGLProcAddressTable(int major, int minor, int ctp) {
@@ -488,22 +398,17 @@ public abstract class X11GLXContext extends GLContextImpl {
public synchronized String getPlatformExtensionsString() {
if (!glXQueryExtensionsStringInitialized) {
glXQueryExtensionsStringAvailable =
- getDrawableImpl().getDynamicLookupHelper().dynamicLookupFunction("glXQueryExtensionsString") != 0;
+ getDrawableImpl().getGLDynamicLookupHelper().dynamicLookupFunction("glXQueryExtensionsString") != 0;
glXQueryExtensionsStringInitialized = true;
}
if (glXQueryExtensionsStringAvailable) {
- GLDrawableFactoryImpl factory = getDrawableImpl().getFactoryImpl();
- factory.lockToolkit();
- try {
+ long display = drawable.getNativeWindow().getDisplayHandle();
String ret = GLX.glXQueryExtensionsString(drawable.getNativeWindow().getDisplayHandle(),
drawable.getNativeWindow().getScreenIndex());
if (DEBUG) {
System.err.println("!!! GLX extensions: " + ret);
}
return ret;
- } finally {
- factory.unlockToolkit();
- }
} else {
return "";
}
@@ -526,10 +431,9 @@ public abstract class X11GLXContext extends GLContextImpl {
GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities();
if(!glCaps.isOnscreen()) return;
- getDrawableImpl().getFactoryImpl().lockToolkit();
- try {
- GLXExt glXExt = getGLXExt();
- if(0==hasSwapIntervalSGI) {
+ long display = drawable.getNativeWindow().getDisplayHandle();
+ GLXExt glXExt = getGLXExt();
+ if(0==hasSwapIntervalSGI) {
try {
hasSwapIntervalSGI = glXExt.isExtensionAvailable("GLX_SGI_swap_control")?1:-1;
} catch (Throwable t) { hasSwapIntervalSGI=1; }
@@ -540,9 +444,6 @@ public abstract class X11GLXContext extends GLContextImpl {
currentSwapInterval = interval;
}
} catch (Throwable t) { hasSwapIntervalSGI=-1; }
- }
- } finally {
- getDrawableImpl().getFactoryImpl().unlockToolkit();
}
}
@@ -570,8 +471,15 @@ public abstract class X11GLXContext extends GLContextImpl {
throw new GLException("Should not call this");
}
- public boolean isOptimizable() {
- return (super.isOptimizable() && !isVendorATI);
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(getClass().getName());
+ sb.append(" [");
+ super.append(sb);
+ sb.append(", direct ");
+ sb.append(isDirect);
+ sb.append("] ");
+ return sb.toString();
}
//----------------------------------------------------------------------
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawable.java
index 95dfc0a1c..25cfcc723 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawable.java
@@ -42,53 +42,30 @@ package com.jogamp.opengl.impl.x11.glx;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.jogamp.opengl.impl.*;
-import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.nativewindow.impl.x11.*;
public abstract class X11GLXDrawable extends GLDrawableImpl {
protected X11GLXDrawable(GLDrawableFactory factory, NativeWindow comp, boolean realized) {
super(factory, comp, realized);
}
- public DynamicLookupHelper getDynamicLookupHelper() {
- return (X11GLXDrawableFactory) getFactoryImpl() ;
+ public GLDynamicLookupHelper getGLDynamicLookupHelper() {
+ return getFactoryImpl().getGLDynamicLookupHelper(0);
}
protected void setRealizedImpl() {
- if(!realized) {
- return; // nothing to do
- }
-
- if(NativeWindow.LOCK_SURFACE_NOT_READY == lockSurface()) {
- throw new GLException("X11GLXDrawable.setRealized(true): lockSurface - surface not ready");
- }
- try {
+ if(realized) {
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
config.updateGraphicsConfiguration();
if (DEBUG) {
System.err.println("!!! X11GLXDrawable.setRealized(true): "+config);
}
- } finally {
- unlockSurface();
}
}
protected void swapBuffersImpl() {
- boolean didLock = false;
- if (!isSurfaceLocked()) {
- // Usually the surface shall be locked within [makeCurrent .. swap .. release]
- if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
- return;
- }
- didLock = true;
- }
- try {
- GLX.glXSwapBuffers(component.getDisplayHandle(), component.getSurfaceHandle());
- } finally {
- if (didLock) {
- unlockSurface();
- }
- }
+ GLX.glXSwapBuffers(getNativeWindow().getDisplayHandle(), getHandle());
}
//---------------------------------------------------------------------------
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index e2b24f9f0..822a3d0b3 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -36,7 +36,6 @@
package com.jogamp.opengl.impl.x11.glx;
-import com.jogamp.common.os.DynamicLookupHelper;
import java.nio.*;
import javax.media.nativewindow.*;
import javax.media.nativewindow.x11.*;
@@ -48,17 +47,33 @@ import com.jogamp.common.util.*;
import com.jogamp.nativewindow.impl.NullWindow;
import com.jogamp.nativewindow.impl.x11.*;
-public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements DynamicLookupHelper {
+public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
+ private static final DesktopGLDynamicLookupHelper x11GLXDynamicLookupHelper;
+
static {
X11Util.initSingleton(); // ensure it's loaded and setup
+
+ DesktopGLDynamicLookupHelper tmp = null;
+ try {
+ tmp = new DesktopGLDynamicLookupHelper(new X11GLXDynamicLibraryBundleInfo());
+ } catch (GLException gle) {
+ if(DEBUG) {
+ gle.printStackTrace();
+ }
+ }
+ x11GLXDynamicLookupHelper = tmp;
+ if(null!=x11GLXDynamicLookupHelper) {
+ GLX.getGLXProcAddressTable().reset(x11GLXDynamicLookupHelper);
+ }
+ }
+
+ public GLDynamicLookupHelper getGLDynamicLookupHelper(int profile) {
+ return x11GLXDynamicLookupHelper;
}
public X11GLXDrawableFactory() {
super();
- // Must initialize GLX support eagerly in case a pbuffer is the
- // first thing instantiated
- GLX.getGLXProcAddressTable().reset(this);
// Register our GraphicsConfigurationFactory implementations
// The act of constructing them causes them to be registered
new X11GLXGraphicsConfigurationFactory();
@@ -74,12 +89,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
isVendorATI = GLXUtil.isVendorATI(vendorName);
isVendorNVIDIA = GLXUtil.isVendorNVIDIA(vendorName);
sharedScreen = new X11GraphicsScreen(sharedDevice, 0);
- X11Util.XLockDisplay(tlsDisplay);
- try{
- sharedDrawable = new X11DummyGLXDrawable(sharedScreen, X11GLXDrawableFactory.this, GLProfile.getDefault());
- } finally {
- X11Util.XUnlockDisplay(tlsDisplay);
- }
+ sharedDrawable = new X11DummyGLXDrawable(sharedScreen, X11GLXDrawableFactory.this, GLProfile.getDefault());
if(isVendorATI() && GLProfile.isAWTAvailable()) {
X11Util.markThreadLocalDisplayUncloseable(tlsDisplay); // failure to close with ATI and AWT usage
}
@@ -88,7 +98,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
}
// We have to keep this within this thread,
// since we have a 'chicken-and-egg' problem otherwise on the <init> lock of this thread.
- X11Util.XLockDisplay(sharedScreen.getDevice().getHandle());
try{
X11GLXContext ctx = (X11GLXContext) sharedDrawable.createContext(null);
ctx.makeCurrent();
@@ -96,8 +105,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
sharedContext = ctx;
} catch (Throwable t) {
throw new GLException("X11GLXDrawableFactory - Could not initialize shared resources", t);
- } finally {
- X11Util.XUnlockDisplay(sharedScreen.getDevice().getHandle());
}
if(null==sharedContext) {
throw new GLException("X11GLXDrawableFactory - Shared Context is null");
@@ -136,13 +143,15 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
System.err.println("!!! Drawable: "+sharedDrawable);
System.err.println("!!! Screen : "+sharedScreen);
}
+
+ // don't free native resources from this point on,
+ // since we might be in a critical shutdown hook sequence
+
if(null!=sharedContext) {
- sharedContext.destroy(); // implies release, if current
+ // may cause deadlock: sharedContext.destroy();
sharedContext=null;
}
- // don't free native resources from this point on,
- // since we might be in a critical shutdown hook sequence
if(null!=sharedDrawable) {
// may cause deadlock: sharedDrawable.destroy();
sharedDrawable=null;
@@ -151,7 +160,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
// may cause deadlock: X11Util.closeThreadLocalDisplay(null);
sharedScreen = null;
}
- // don't close pending XDisplay, since they might be a different thread as the opener
+ // don't close pending XDisplay, since this might be a different thread as the opener
X11Util.shutdown( false, DEBUG );
}
@@ -230,13 +239,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
- NullWindow nw = null;
- X11Util.XLockDisplay(sharedScreen.getDevice().getHandle());
- try{
- nw = new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, sharedScreen));
- }finally{
- X11Util.XUnlockDisplay(sharedScreen.getDevice().getHandle());
- }
+ NullWindow nw = new NullWindow(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capabilities, chooser, sharedScreen));
if(nw != null) {
nw.setSize(width, height);
}
@@ -255,20 +258,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
return X11ExternalGLXDrawable.create(this, null);
}
- public void loadGLULibrary() {
- X11Lib.dlopen("/usr/lib/libGLU.so");
- }
-
- public long dynamicLookupFunction(String glFuncName) {
- long res = 0;
- res = GLX.glXGetProcAddressARB(glFuncName);
- if (res == 0) {
- // GLU routines aren't known to the OpenGL function lookup
- res = X11Lib.dlsym(glFuncName);
- }
- return res;
- }
-
public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) {
return false;
}
@@ -291,21 +280,16 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
long display = sharedScreen.getDevice().getHandle();
- X11Util.XLockDisplay(display);
- try {
- int[] size = new int[1];
- boolean res = X11Lib.XF86VidModeGetGammaRampSize(display,
- X11Lib.DefaultScreen(display),
- size, 0);
- if (!res) {
- return 0;
- }
- gotGammaRampLength = true;
- gammaRampLength = size[0];
- return gammaRampLength;
- } finally {
- X11Util.XUnlockDisplay(display);
+ int[] size = new int[1];
+ boolean res = X11Lib.XF86VidModeGetGammaRampSize(display,
+ X11Lib.DefaultScreen(display),
+ size, 0);
+ if (!res) {
+ return 0;
}
+ gotGammaRampLength = true;
+ gammaRampLength = size[0];
+ return gammaRampLength;
}
protected boolean setGammaRamp(float[] ramp) {
@@ -316,18 +300,13 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
}
long display = sharedScreen.getDevice().getHandle();
- X11Util.XLockDisplay(display);
- try {
- boolean res = X11Lib.XF86VidModeSetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- rampData.length,
- rampData, 0,
- rampData, 0,
- rampData, 0);
- return res;
- } finally {
- X11Util.XUnlockDisplay(display);
- }
+ boolean res = X11Lib.XF86VidModeSetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ rampData.length,
+ rampData, 0,
+ rampData, 0,
+ rampData, 0);
+ return res;
}
protected Buffer getGammaRamp() {
@@ -343,21 +322,16 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
rampData.limit(3 * size);
ShortBuffer blueRampData = rampData.slice();
long display = sharedScreen.getDevice().getHandle();
- X11Util.XLockDisplay(display);
- try {
- boolean res = X11Lib.XF86VidModeGetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- size,
- redRampData,
- greenRampData,
- blueRampData);
- if (!res) {
- return null;
- }
- return rampData;
- } finally {
- X11Util.XUnlockDisplay(display);
+ boolean res = X11Lib.XF86VidModeGetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ size,
+ redRampData,
+ greenRampData,
+ blueRampData);
+ if (!res) {
+ return null;
}
+ return rampData;
}
protected void resetGammaRamp(Buffer originalGammaRamp) {
@@ -379,16 +353,11 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
rampData.limit(3 * size);
ShortBuffer blueRampData = rampData.slice();
long display = sharedScreen.getDevice().getHandle();
- X11Util.XLockDisplay(display);
- try {
- X11Lib.XF86VidModeSetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- size,
- redRampData,
- greenRampData,
- blueRampData);
- } finally {
- X11Util.XUnlockDisplay(display);
- }
+ X11Lib.XF86VidModeSetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ size,
+ redRampData,
+ greenRampData,
+ blueRampData);
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDynamicLibraryBundleInfo.java
new file mode 100644
index 000000000..d958996a8
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDynamicLibraryBundleInfo.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2010, Sven Gothel
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sven Gothel nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Sven Gothel BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.jogamp.opengl.impl.x11.glx;
+
+import com.jogamp.opengl.impl.*;
+import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.common.os.NativeLibrary;
+import com.jogamp.common.os.Platform;
+import java.util.*;
+import java.security.*;
+import javax.media.opengl.GLException;
+
+public class X11GLXDynamicLibraryBundleInfo extends DesktopGLDynamicLibraryBundleInfo {
+ protected X11GLXDynamicLibraryBundleInfo() {
+ super();
+ }
+
+ public List getToolLibNames() {
+ List/*<List>*/ libNamesList = new ArrayList();
+
+ List/*<String>*/ glesLibNames = new ArrayList();
+
+ // Be aware that on DRI systems, eg ATI fglrx, etc,
+ // you have to set LIBGL_DRIVERS_PATH env variable.
+ // Eg on Ubuntu 64bit systems this is:
+ // export LIBGL_DRIVERS_PATH=/usr/lib/fglrx/dri:/usr/lib32/fglrx/dri
+ //
+
+ // this is the default GL lib name, according to the spec
+ glesLibNames.add("libGL.so.1");
+
+ // try this one as well, if spec fails
+ glesLibNames.add("libGL.so");
+
+ // last but not least .. the generic one
+ glesLibNames.add("GL");
+
+ libNamesList.add(glesLibNames);
+
+ return libNamesList;
+ }
+
+ /**
+ * This respects old DRI requirements:<br>
+ * <pre>
+ * http://dri.sourceforge.net/doc/DRIuserguide.html
+ * </pre>
+ */
+ public boolean shallLinkGlobal() { return true; }
+
+ public final List getToolGetProcAddressFuncNameList() {
+ List res = new ArrayList();
+ res.add("glXGetProcAddressARB");
+ res.add("glXGetProcAddress");
+ return res;
+ }
+
+ public final long toolDynamicLookupFunction(long toolGetProcAddressHandle, String funcName) {
+ return GLX.glXGetProcAddress(toolGetProcAddressHandle, funcName);
+ }
+}
+
+
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
index 35daf0ae0..589d7b2db 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
@@ -73,7 +73,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
if(null==caps) {
throw new GLException("GLCapabilities null of "+toHexString(fbcfg));
}
- XVisualInfo xvi = GLX.glXGetVisualFromFBConfigCopied(display, fbcfg);
+ XVisualInfo xvi = GLX.glXGetVisualFromFBConfig(display, fbcfg);
if(null==xvi) {
throw new GLException("XVisualInfo null of "+toHexString(fbcfg));
}
@@ -326,7 +326,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
public static long glXFBConfigID2FBConfig(long display, int screen, int id) {
int[] attribs = new int[] { GLX.GLX_FBCONFIG_ID, id, 0 };
int[] count = { -1 };
- PointerBuffer fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, attribs, 0, count, 0);
+ PointerBuffer fbcfgsL = GLX.glXChooseFBConfig(display, screen, attribs, 0, count, 0);
if (fbcfgsL == null || fbcfgsL.limit()<1) {
return 0;
}
@@ -336,20 +336,14 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
// Visual Info
public static XVisualInfo XVisualID2XVisualInfo(long display, long visualID) {
- XVisualInfo res = null;
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- try{
- int[] count = new int[1];
- XVisualInfo template = XVisualInfo.create();
- template.setVisualid(visualID);
- XVisualInfo[] infos = X11Lib.XGetVisualInfoCopied(display, X11Lib.VisualIDMask, template, count, 0);
- if (infos == null || infos.length == 0) {
+ int[] count = new int[1];
+ XVisualInfo template = XVisualInfo.create();
+ template.setVisualid(visualID);
+ XVisualInfo[] infos = X11Lib.XGetVisualInfo(display, X11Lib.VisualIDMask, template, count, 0);
+ if (infos == null || infos.length == 0) {
return null;
- }
- res = XVisualInfo.create(infos[0]);
- } finally {
- NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
- }
+ }
+ XVisualInfo res = XVisualInfo.create(infos[0]);
if (DEBUG) {
System.err.println("!!! Fetched XVisualInfo for visual ID " + toHexString(visualID));
System.err.println("!!! Resulting XVisualInfo: visualid = " + toHexString(res.getVisualid()));
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index a160734d3..5c04a29fe 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -80,8 +80,6 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
GLCapabilities capsFB = null;
long display = x11Screen.getDevice().getHandle();
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- X11Util.XLockDisplay(display);
try {
int screen = x11Screen.getIndex();
boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
@@ -92,7 +90,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(caps, true, isMultisampleAvailable, display, screen);
int[] count = { -1 };
- PointerBuffer fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, attribs, 0, count, 0);
+ PointerBuffer fbcfgsL = GLX.glXChooseFBConfig(display, screen, attribs, 0, count, 0);
if (fbcfgsL == null || fbcfgsL.limit()<1) {
throw new Exception("Could not fetch FBConfig for "+caps);
}
@@ -101,14 +99,11 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
fbid = X11GLXGraphicsConfiguration.glXFBConfig2FBConfigID(display, fbcfg);
- xvis = GLX.glXGetVisualFromFBConfigCopied(display, fbcfg);
+ xvis = GLX.glXGetVisualFromFBConfig(display, fbcfg);
if (xvis==null) {
throw new GLException("Error: Choosen FBConfig has no visual");
}
} catch (Throwable t) {
- } finally {
- X11Util.XUnlockDisplay(display);
- NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
return new X11GLXGraphicsConfiguration(x11Screen, (null!=capsFB)?capsFB:caps, caps, null, xvis, fbcfg, fbid);
@@ -189,113 +184,103 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
AbstractGraphicsDevice absDevice = x11Screen.getDevice();
long display = absDevice.getHandle();
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- try {
- X11Util.XLockDisplay(display);
- try{
- int screen = x11Screen.getIndex();
- boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
- int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, true, isMultisampleAvailable, display, screen);
- int[] count = { -1 };
-
- // determine the recommended FBConfig ..
- fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, attribs, 0, count, 0);
- if (fbcfgsL == null || fbcfgsL.limit()<1) {
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXChooseFBConfig ("+x11Screen+","+capabilities+"): "+fbcfgsL+", "+count[0]);
- }
- } else if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(0) ) ) {
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed - GLX FBConfig invalid: ("+x11Screen+","+capabilities+"): "+fbcfgsL+", fbcfg: "+toHexString(fbcfgsL.get(0)));
- }
- } else {
- recommendedFBConfig = fbcfgsL.get(0);
- }
-
- // get all, glXChooseFBConfig(.. attribs==null ..) == glXGetFBConfig(..)
- fbcfgsL = GLX.glXChooseFBConfigCopied(display, screen, null, 0, count, 0);
- if (fbcfgsL == null || fbcfgsL.limit()<1) {
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXGetFBConfig ("+x11Screen+"): "+fbcfgsL+", "+count[0]);
- }
- return null;
- }
+ int screen = x11Screen.getIndex();
+ boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
+ int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, true, isMultisampleAvailable, display, screen);
+ int[] count = { -1 };
- // make GLCapabilities and seek the recommendedIndex
- caps = new GLCapabilities[fbcfgsL.limit()];
- for (int i = 0; i < fbcfgsL.limit(); i++) {
- if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(i) ) ) {
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid: ("+x11Screen+","+capabilities+"): fbcfg: "+toHexString(fbcfgsL.get(i)));
- }
- } else {
- caps[i] = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfgsL.get(i),
- false, onscreen, usePBuffer, isMultisampleAvailable);
- if(caps[i]!=null && recommendedFBConfig==fbcfgsL.get(i)) {
- recommendedIndex=i;
- if (DEBUG) {
- System.err.println("!!! glXChooseFBConfig recommended "+i+", "+caps[i]);
- }
- }
- }
- }
+ // determine the recommended FBConfig ..
+ fbcfgsL = GLX.glXChooseFBConfig(display, screen, attribs, 0, count, 0);
+ if (fbcfgsL == null || fbcfgsL.limit()<1) {
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXChooseFBConfig ("+x11Screen+","+capabilities+"): "+fbcfgsL+", "+count[0]);
+ }
+ } else if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(0) ) ) {
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed - GLX FBConfig invalid: ("+x11Screen+","+capabilities+"): "+fbcfgsL+", fbcfg: "+toHexString(fbcfgsL.get(0)));
+ }
+ } else {
+ recommendedFBConfig = fbcfgsL.get(0);
+ }
- if(null==chooser) {
- chosen = recommendedIndex; // may still be -1 in case nothing was recommended (-1)
- }
+ // get all, glXChooseFBConfig(.. attribs==null ..) == glXGetFBConfig(..)
+ fbcfgsL = GLX.glXChooseFBConfig(display, screen, null, 0, count, 0);
+ if (fbcfgsL == null || fbcfgsL.limit()<1) {
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXGetFBConfig ("+x11Screen+"): "+fbcfgsL+", "+count[0]);
+ }
+ return null;
+ }
- if (chosen < 0) {
- if(null==chooser) {
- // nothing recommended .. so use our default implementation
- chooser = new DefaultGLCapabilitiesChooser();
- }
- try {
- chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
- } catch (NativeWindowException e) {
- if(DEBUG) {
- e.printStackTrace();
- }
- chosen = -1;
- }
+ // make GLCapabilities and seek the recommendedIndex
+ caps = new GLCapabilities[fbcfgsL.limit()];
+ for (int i = 0; i < fbcfgsL.limit(); i++) {
+ if( !X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfgsL.get(i) ) ) {
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid: ("+x11Screen+","+capabilities+"): fbcfg: "+toHexString(fbcfgsL.get(i)));
}
- if (chosen < 0) {
- // keep on going ..
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig Failed .. unable to choose config, using first");
- }
- // seek first available one ..
- for(chosen = 0; chosen < caps.length && caps[chosen]==null; chosen++) ;
- if(chosen==caps.length) {
- // give up ..
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig Failed .. nothing available, bail out");
- }
- return null;
- }
- } else if (chosen >= caps.length) {
- if(DEBUG) {
- System.err.println("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ", got "+chosen+")");
+ } else {
+ caps[i] = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfgsL.get(i),
+ false, onscreen, usePBuffer, isMultisampleAvailable);
+ if(caps[i]!=null && recommendedFBConfig==fbcfgsL.get(i)) {
+ recommendedIndex=i;
+ if (DEBUG) {
+ System.err.println("!!! glXChooseFBConfig recommended "+i+", "+caps[i]);
}
- return null;
}
+ }
+ }
- retFBID = X11GLXGraphicsConfiguration.glXFBConfig2FBConfigID(display, fbcfgsL.get(chosen));
+ if(null==chooser) {
+ chosen = recommendedIndex; // may still be -1 in case nothing was recommended (-1)
+ }
- retXVisualInfo = GLX.glXGetVisualFromFBConfigCopied(display, fbcfgsL.get(chosen));
- if (retXVisualInfo==null) {
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXGetVisualFromFBConfig ("+x11Screen+", "+fbcfgsL.get(chosen) +" (Continue: "+(false==caps[chosen].isOnscreen())+"):\n\t"+caps[chosen]);
- }
- if(caps[chosen].isOnscreen()) {
- // Onscreen drawables shall have a XVisual ..
- return null;
- }
- }
- }finally{
- X11Util.XUnlockDisplay(display);
+ if (chosen < 0) {
+ if(null==chooser) {
+ // nothing recommended .. so use our default implementation
+ chooser = new DefaultGLCapabilitiesChooser();
+ }
+ try {
+ chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
+ } catch (NativeWindowException e) {
+ if(DEBUG) {
+ e.printStackTrace();
+ }
+ chosen = -1;
+ }
+ }
+ if (chosen < 0) {
+ // keep on going ..
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig Failed .. unable to choose config, using first");
+ }
+ // seek first available one ..
+ for(chosen = 0; chosen < caps.length && caps[chosen]==null; chosen++) ;
+ if(chosen==caps.length) {
+ // give up ..
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig Failed .. nothing available, bail out");
+ }
+ return null;
+ }
+ } else if (chosen >= caps.length) {
+ if(DEBUG) {
+ System.err.println("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ", got "+chosen+")");
+ }
+ return null;
+ }
+
+ retFBID = X11GLXGraphicsConfiguration.glXFBConfig2FBConfigID(display, fbcfgsL.get(chosen));
+
+ retXVisualInfo = GLX.glXGetVisualFromFBConfig(display, fbcfgsL.get(chosen));
+ if (retXVisualInfo==null) {
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: Failed glXGetVisualFromFBConfig ("+x11Screen+", "+fbcfgsL.get(chosen) +" (Continue: "+(false==caps[chosen].isOnscreen())+"):\n\t"+caps[chosen]);
+ }
+ if(caps[chosen].isOnscreen()) {
+ // Onscreen drawables shall have a XVisual ..
+ return null;
}
- } finally {
- NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
return new X11GLXGraphicsConfiguration(x11Screen, caps[chosen], capabilities, chooser, retXVisualInfo, fbcfgsL.get(chosen), retFBID);
@@ -322,66 +307,56 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
AbstractGraphicsDevice absDevice = x11Screen.getDevice();
long display = absDevice.getHandle();
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- try {
- X11Util.XLockDisplay(display);
- try{
- int screen = x11Screen.getIndex();
- boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
- int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, isMultisampleAvailable, display, screen);
- XVisualInfo[] infos = null;
-
- XVisualInfo recommendedVis = GLX.glXChooseVisualCopied(display, screen, attribs, 0);
- if (DEBUG) {
- System.err.print("!!! glXChooseVisual recommended ");
- if (recommendedVis == null) {
- System.err.println("null visual");
- } else {
- System.err.println("visual id " + toHexString(recommendedVis.getVisualid()));
- }
- }
- int[] count = new int[1];
- XVisualInfo template = XVisualInfo.create();
- template.setScreen(screen);
- infos = X11Lib.XGetVisualInfoCopied(display, X11Lib.VisualScreenMask, template, count, 0);
- if (infos == null || infos.length<1) {
- throw new GLException("Error while enumerating available XVisualInfos");
- }
- caps = new GLCapabilities[infos.length];
- for (int i = 0; i < infos.length; i++) {
- caps[i] = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, infos[i], onscreen, false, isMultisampleAvailable);
- // Attempt to find the visual chosen by glXChooseVisual
- if (recommendedVis != null && recommendedVis.getVisualid() == infos[i].getVisualid()) {
- recommendedIndex = i;
- }
- }
- try {
- chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
- } catch (NativeWindowException e) {
- if(DEBUG) {
- e.printStackTrace();
- }
- chosen = -1;
- }
- if (chosen < 0) {
- // keep on going ..
- if(DEBUG) {
- System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationXVisual Failed .. unable to choose config, using first");
- }
- chosen = 0; // default ..
- } else if (chosen >= caps.length) {
- throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
- }
- if (infos[chosen] == null) {
- throw new GLException("GLCapabilitiesChooser chose an invalid visual for "+caps[chosen]);
- }
- retXVisualInfo = XVisualInfo.create(infos[chosen]);
- }finally{
- X11Util.XUnlockDisplay(display);
+ int screen = x11Screen.getIndex();
+ boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
+ int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, isMultisampleAvailable, display, screen);
+ XVisualInfo[] infos = null;
+
+ XVisualInfo recommendedVis = GLX.glXChooseVisual(display, screen, attribs, 0);
+ if (DEBUG) {
+ System.err.print("!!! glXChooseVisual recommended ");
+ if (recommendedVis == null) {
+ System.err.println("null visual");
+ } else {
+ System.err.println("visual id " + toHexString(recommendedVis.getVisualid()));
+ }
+ }
+ int[] count = new int[1];
+ XVisualInfo template = XVisualInfo.create();
+ template.setScreen(screen);
+ infos = X11Lib.XGetVisualInfo(display, X11Lib.VisualScreenMask, template, count, 0);
+ if (infos == null || infos.length<1) {
+ throw new GLException("Error while enumerating available XVisualInfos");
+ }
+ caps = new GLCapabilities[infos.length];
+ for (int i = 0; i < infos.length; i++) {
+ caps[i] = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(glProfile, display, infos[i], onscreen, false, isMultisampleAvailable);
+ // Attempt to find the visual chosen by glXChooseVisual
+ if (recommendedVis != null && recommendedVis.getVisualid() == infos[i].getVisualid()) {
+ recommendedIndex = i;
}
- } finally {
- NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
+ try {
+ chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
+ } catch (NativeWindowException e) {
+ if(DEBUG) {
+ e.printStackTrace();
+ }
+ chosen = -1;
+ }
+ if (chosen < 0) {
+ // keep on going ..
+ if(DEBUG) {
+ System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationXVisual Failed .. unable to choose config, using first");
+ }
+ chosen = 0; // default ..
+ } else if (chosen >= caps.length) {
+ throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
+ }
+ if (infos[chosen] == null) {
+ throw new GLException("GLCapabilitiesChooser chose an invalid visual for "+caps[chosen]);
+ }
+ retXVisualInfo = XVisualInfo.create(infos[chosen]);
return new X11GLXGraphicsConfiguration(x11Screen, caps[chosen], capabilities, chooser, retXVisualInfo, 0, -1);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java
index bea953ee9..5482d5566 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXContext.java
@@ -71,7 +71,7 @@ public class X11OffscreenGLXContext extends X11GLXContext {
return true;
}
- protected void create() {
- createContext(false);
+ protected boolean createImpl() {
+ return createContext(false);
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
index 5771e9c42..230387c1c 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
@@ -73,33 +73,22 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
long dpy = aDevice.getHandle();
int screen = aScreen.getIndex();
- getFactoryImpl().lockToolkit();
- try {
- X11Util.XLockDisplay(dpy);
- try{
-
- pixmap = X11Lib.XCreatePixmap(dpy, X11Lib.RootWindow(dpy, screen),
- component.getWidth(), component.getHeight(), bitsPerPixel);
- if (pixmap == 0) {
- throw new GLException("XCreatePixmap failed");
- }
- long drawable = GLX.glXCreateGLXPixmap(dpy, vis, pixmap);
- if (drawable == 0) {
- X11Lib.XFreePixmap(dpy, pixmap);
- pixmap = 0;
- throw new GLException("glXCreateGLXPixmap failed");
- }
- ((SurfaceChangeable)nw).setSurfaceHandle(drawable);
- if (DEBUG) {
- System.err.println("Created pixmap " + toHexString(pixmap) +
- ", GLXPixmap " + toHexString(drawable) +
- ", display " + toHexString(dpy));
- }
- }finally{
- X11Util.XUnlockDisplay(dpy);
- }
- } finally {
- getFactoryImpl().unlockToolkit();
+ pixmap = X11Lib.XCreatePixmap(dpy, X11Lib.RootWindow(dpy, screen),
+ component.getWidth(), component.getHeight(), bitsPerPixel);
+ if (pixmap == 0) {
+ throw new GLException("XCreatePixmap failed");
+ }
+ long drawable = GLX.glXCreateGLXPixmap(dpy, vis, pixmap);
+ if (drawable == 0) {
+ X11Lib.XFreePixmap(dpy, pixmap);
+ pixmap = 0;
+ throw new GLException("glXCreateGLXPixmap failed");
+ }
+ ((SurfaceChangeable)nw).setSurfaceHandle(drawable);
+ if (DEBUG) {
+ System.err.println("Created pixmap " + toHexString(pixmap) +
+ ", GLXPixmap " + toHexString(drawable) +
+ ", display " + toHexString(dpy));
}
}
@@ -109,46 +98,36 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
NativeWindow nw = getNativeWindow();
long display = nw.getDisplayHandle();
- getFactoryImpl().lockToolkit();
- try {
- X11Util.XLockDisplay(display);
- try{
- long drawable = nw.getSurfaceHandle();
- if (DEBUG) {
- System.err.println("Destroying pixmap " + toHexString(pixmap) +
- ", GLXPixmap " + toHexString(drawable) +
- ", display " + toHexString(display));
- }
-
- // Must destroy pixmap and GLXPixmap
-
- if (DEBUG) {
- long cur = GLX.glXGetCurrentContext();
- if (cur != 0) {
- System.err.println("WARNING: found context " + toHexString(cur) + " current during pixmap destruction");
- }
- }
-
- // FIXME: workaround for crashes on NVidia hardware when
- // destroying pixmap (no context is current at the point of the
- // crash, at least from the point of view of
- // glXGetCurrentContext)
- GLX.glXMakeCurrent(display, 0, 0);
+ long drawable = nw.getSurfaceHandle();
+ if (DEBUG) {
+ System.err.println("Destroying pixmap " + toHexString(pixmap) +
+ ", GLXPixmap " + toHexString(drawable) +
+ ", display " + toHexString(display));
+ }
- GLX.glXDestroyGLXPixmap(display, drawable);
- X11Lib.XFreePixmap(display, pixmap);
- drawable = 0;
- pixmap = 0;
- ((SurfaceChangeable)nw).setSurfaceHandle(0);
+ // Must destroy pixmap and GLXPixmap
- }finally{
- X11Util.XUnlockDisplay(display);
+ if (DEBUG) {
+ long cur = GLX.glXGetCurrentContext();
+ if (cur != 0) {
+ System.err.println("WARNING: found context " + toHexString(cur) + " current during pixmap destruction");
}
- } finally {
- getFactoryImpl().unlockToolkit();
- display = 0;
}
+
+ // FIXME: workaround for crashes on NVidia hardware when
+ // destroying pixmap (no context is current at the point of the
+ // crash, at least from the point of view of
+ // glXGetCurrentContext)
+ GLX.glXMakeCurrent(display, 0, 0);
+
+ GLX.glXDestroyGLXPixmap(display, drawable);
+ X11Lib.XFreePixmap(display, pixmap);
+ drawable = 0;
+ pixmap = 0;
+ ((SurfaceChangeable)nw).setSurfaceHandle(0);
+ display = 0;
}
+
protected void swapBuffersImpl() {
if(DEBUG) {
System.err.println("unhandled swapBuffersImpl() called for: "+this);
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXContext.java
index 710f93e98..bb1e2fd4c 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXContext.java
@@ -47,22 +47,12 @@ import com.jogamp.opengl.impl.*;
import com.jogamp.opengl.impl.x11.*;
public class X11OnscreenGLXContext extends X11GLXContext {
- // This indicates whether the context we have created is indirect
- // and therefore requires the toolkit to be locked around all GL
- // calls rather than just all GLX calls
- protected boolean isIndirect;
-
public X11OnscreenGLXContext(X11OnscreenGLXDrawable drawable,
GLContext shareWith) {
super(drawable, shareWith);
}
- public boolean isOptimizable() {
- return super.isOptimizable() && !isIndirect;
- }
-
- protected void create() {
- createContext(true);
- isIndirect = !GLX.glXIsDirect(drawable.getNativeWindow().getDisplayHandle(), contextHandle);
+ protected boolean createImpl() {
+ return createContext(true);
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
index 43468b858..a9aafa5af 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
@@ -43,10 +43,54 @@ import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.jogamp.opengl.impl.*;
import com.jogamp.opengl.impl.x11.*;
+import com.jogamp.nativewindow.impl.x11.*;
public class X11OnscreenGLXDrawable extends X11GLXDrawable {
+ /** GLXWindow can't be made current on AWT with NVidia driver, hence disabled for now */
+ public static final boolean USE_GLXWINDOW = false;
+ long glXWindow; // GLXWindow, a GLXDrawable representation
+ boolean useGLXWindow;
+
protected X11OnscreenGLXDrawable(GLDrawableFactory factory, NativeWindow component) {
super(factory, component, false);
+ glXWindow=0;
+ useGLXWindow=false;
+ }
+
+ public long getHandle() {
+ if(useGLXWindow) {
+ return glXWindow;
+ }
+ return getNativeWindow().getSurfaceHandle();
+ }
+
+ protected void destroyHandle() {
+ if(0!=glXWindow) {
+ GLX.glXDestroyWindow(getNativeWindow().getDisplayHandle(), glXWindow);
+ glXWindow = 0;
+ useGLXWindow=false;
+ }
+ }
+
+ /** must be locked already */
+ protected void updateHandle() {
+ if(USE_GLXWINDOW) {
+ X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ if(config.getFBConfig()>=0) {
+ useGLXWindow=true;
+ long dpy = getNativeWindow().getDisplayHandle();
+ if(0!=glXWindow) {
+ GLX.glXDestroyWindow(dpy, glXWindow);
+ }
+ glXWindow = GLX.glXCreateWindow(dpy, config.getFBConfig(), getNativeWindow().getSurfaceHandle(), null, 0);
+ if (DEBUG) {
+ System.err.println("!!! X11OnscreenGLXDrawable.setRealized(true): glXWindow: "+toHexString(getNativeWindow().getSurfaceHandle())+" -> "+toHexString(glXWindow));
+ }
+ if(0==glXWindow) {
+ throw new GLException("X11OnscreenGLXDrawable.setRealized(true): GLX.glXCreateWindow() failed: "+this);
+ }
+ }
+ }
}
public GLContext createContext(GLContext shareWith) {
@@ -60,5 +104,4 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable {
public int getHeight() {
return component.getHeight();
}
-
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXContext.java
index 1b70adf6b..debf28127 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXContext.java
@@ -67,7 +67,7 @@ public class X11PbufferGLXContext extends X11GLXContext {
return drawable.getFloatingPointMode();
}
- protected void create() {
- createContext(true);
+ protected boolean createImpl() {
+ return createContext(true);
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
index 50b32b9ec..009fa147f 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
@@ -76,21 +76,14 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
}
public void destroy() {
- getFactoryImpl().lockToolkit();
- try {
- NativeWindow nw = getNativeWindow();
- if (nw.getSurfaceHandle() != 0) {
- GLX.glXDestroyPbuffer(nw.getDisplayHandle(), nw.getSurfaceHandle());
- }
- ((SurfaceChangeable)nw).setSurfaceHandle(0);
- } finally {
- getFactoryImpl().unlockToolkit();
+ NativeWindow nw = getNativeWindow();
+ if (nw.getSurfaceHandle() != 0) {
+ GLX.glXDestroyPbuffer(nw.getDisplayHandle(), nw.getSurfaceHandle());
}
+ ((SurfaceChangeable)nw).setSurfaceHandle(0);
}
private void createPbuffer() {
- getFactoryImpl().lockToolkit();
- try {
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
AbstractGraphicsScreen aScreen = config.getScreen();
AbstractGraphicsDevice aDevice = aScreen.getDevice();
@@ -139,9 +132,6 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
GLX.glXQueryDrawable(display, pbuffer, GLX.GLX_HEIGHT, tmp, 0);
int height = tmp[0];
((SurfaceChangeable)nw).setSize(width, height);
- } finally {
- getFactoryImpl().unlockToolkit();
- }
}
public int getFloatingPointMode() {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
index dc6c60664..9e52040cf 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
@@ -87,57 +87,51 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfiguration
GraphicsConfiguration gc;
X11GraphicsConfiguration x11Config;
- // Need the lock here, since it could be an AWT owned display connection
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
- try {
- long displayHandle = X11SunJDKReflection.graphicsDeviceGetDisplay(device);
- if(0==displayHandle) {
- displayHandle = X11Util.createThreadLocalDefaultDisplay();
- if(DEBUG) {
- System.err.println("X11AWTGLXGraphicsConfigurationFactory: using a thread local X11 display");
- }
- } else {
- if(DEBUG) {
- System.err.println("X11AWTGLXGraphicsConfigurationFactory: using AWT X11 display 0x"+Long.toHexString(displayHandle));
- }
- }
- ((AWTGraphicsDevice)awtScreen.getDevice()).setHandle(displayHandle);
- X11GraphicsDevice x11Device = new X11GraphicsDevice(displayHandle);
-
- X11GraphicsScreen x11Screen = new X11GraphicsScreen(x11Device, awtScreen.getIndex());
+ long displayHandle = X11SunJDKReflection.graphicsDeviceGetDisplay(device);
+ if(0==displayHandle) {
+ displayHandle = X11Util.createThreadLocalDisplay(null);
if(DEBUG) {
- System.err.println("X11AWTGLXGraphicsConfigurationFactory: made "+x11Screen);
+ System.err.println("X11AWTGLXGraphicsConfigurationFactory: using a thread local X11 display");
}
-
- gc = device.getDefaultConfiguration();
- AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capabilities, gc);
+ } else {
if(DEBUG) {
- System.err.println("AWT Colormodel compatible: "+capabilities);
+ System.err.println("X11AWTGLXGraphicsConfigurationFactory: using AWT X11 display 0x"+Long.toHexString(displayHandle));
}
+ }
+ ((AWTGraphicsDevice)awtScreen.getDevice()).setHandle(displayHandle);
+ X11GraphicsDevice x11Device = new X11GraphicsDevice(displayHandle);
- x11Config = (X11GraphicsConfiguration)
- GraphicsConfigurationFactory.getFactory(x11Device).chooseGraphicsConfiguration(capabilities,
- chooser,
- x11Screen);
- if (x11Config == null) {
- throw new GLException("Unable to choose a GraphicsConfiguration: "+capabilities+",\n\t"+chooser+"\n\t"+x11Screen);
- }
+ X11GraphicsScreen x11Screen = new X11GraphicsScreen(x11Device, awtScreen.getIndex());
+ if(DEBUG) {
+ System.err.println("X11AWTGLXGraphicsConfigurationFactory: made "+x11Screen);
+ }
+
+ gc = device.getDefaultConfiguration();
+ AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capabilities, gc);
+ if(DEBUG) {
+ System.err.println("AWT Colormodel compatible: "+capabilities);
+ }
+
+ x11Config = (X11GraphicsConfiguration)
+ GraphicsConfigurationFactory.getFactory(x11Device).chooseGraphicsConfiguration(capabilities,
+ chooser,
+ x11Screen);
+ if (x11Config == null) {
+ throw new GLException("Unable to choose a GraphicsConfiguration: "+capabilities+",\n\t"+chooser+"\n\t"+x11Screen);
+ }
- long visualID = x11Config.getVisualID();
- // Now figure out which GraphicsConfiguration corresponds to this
- // visual by matching the visual ID
- GraphicsConfiguration[] configs = device.getConfigurations();
- for (int i = 0; i < configs.length; i++) {
- GraphicsConfiguration config = configs[i];
- if (config != null) {
- if (X11SunJDKReflection.graphicsConfigurationGetVisualID(config) == visualID) {
- return new AWTGraphicsConfiguration(awtScreen, x11Config.getChosenCapabilities(), x11Config.getRequestedCapabilities(),
- config, x11Config);
- }
+ long visualID = x11Config.getVisualID();
+ // Now figure out which GraphicsConfiguration corresponds to this
+ // visual by matching the visual ID
+ GraphicsConfiguration[] configs = device.getConfigurations();
+ for (int i = 0; i < configs.length; i++) {
+ GraphicsConfiguration config = configs[i];
+ if (config != null) {
+ if (X11SunJDKReflection.graphicsConfigurationGetVisualID(config) == visualID) {
+ return new AWTGraphicsConfiguration(awtScreen, x11Config.getChosenCapabilities(), x11Config.getRequestedCapabilities(),
+ config, x11Config);
}
}
- } finally {
- NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
// Either we weren't able to reflectively introspect on the
// X11GraphicsConfig or something went wrong in the steps above;
diff --git a/src/jogl/classes/com/jogamp/openmax/OMXInstance.java b/src/jogl/classes/com/jogamp/openmax/OMXInstance.java
index 2ebae9b58..97f07da1c 100644
--- a/src/jogl/classes/com/jogamp/openmax/OMXInstance.java
+++ b/src/jogl/classes/com/jogamp/openmax/OMXInstance.java
@@ -84,7 +84,7 @@ public class OMXInstance {
}
eglContext = eglCtx.getHandle();
eglDisplay = eglDrawable.getDisplay();
- eglSurface = eglDrawable.getSurface();
+ eglSurface = eglDrawable.getHandle();
eglExt = eglCtx.getEGLExt();
if(null==eglExt) {
throw new RuntimeException("No valid EGLExt");