aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/android/com/jogamp/android/launcher/ClassLoaderUtil.java82
-rw-r--r--src/android/com/jogamp/android/launcher/NEWTLauncherVersionActivity.java40
-rw-r--r--src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java6
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java13
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java12
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java25
-rw-r--r--src/jogl/classes/jogamp/opengl/DesktopGLDynamicLibraryBundleInfo.java12
-rw-r--r--src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java18
-rw-r--r--src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java1
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLContext.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java19
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java102
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java25
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java15
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java15
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java93
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java45
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java9
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDynamicLibraryBundleInfo.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDynamicLibraryBundleInfo.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java9
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDynamicLibraryBundleInfo.java2
-rw-r--r--src/newt/classes/jogamp/newt/DisplayImpl.java2
-rw-r--r--src/newt/classes/jogamp/newt/ScreenImpl.java2
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java28
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java (renamed from src/newt/classes/jogamp/newt/driver/android/Display.java)51
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java133
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java (renamed from src/newt/classes/jogamp/newt/driver/android/Window.java)0
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/MD.java29
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/NEWTSurfaceView.java45
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java56
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/Screen.java59
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/SurfaceCallback.java54
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java12
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/test/GearsGL2ES1.java422
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/OneTriangle.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/swt/OneTriangle.java)16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug463ScaleImageMemoryAWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT01GLn.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java7
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java5
46 files changed, 1097 insertions, 415 deletions
diff --git a/src/android/com/jogamp/android/launcher/ClassLoaderUtil.java b/src/android/com/jogamp/android/launcher/ClassLoaderUtil.java
new file mode 100644
index 000000000..746fad745
--- /dev/null
+++ b/src/android/com/jogamp/android/launcher/ClassLoaderUtil.java
@@ -0,0 +1,82 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR
+ * CONTRIBUTORS 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.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.android.launcher;
+
+import java.io.File;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.util.Log;
+import dalvik.system.DexClassLoader;
+
+public class ClassLoaderUtil {
+ private static final String TAG = "JogampClassLoader";
+
+ public static final String packageGlueGen = "com.jogamp.common";
+ public static final String packageJogl = "javax.media.opengl";
+
+ public static final String dexPathName= "jogampDex";
+ public static final String libPathName = "/data/data/com.jogamp.common/lib/:/data/data/javax.media.opengl/lib/";
+
+ public static synchronized ClassLoader createJogampClassLoaderSingleton(Context ctx, boolean debugOn) {
+ Log.d(TAG, "S");
+
+ if(debugOn) {
+ System.setProperty("jogl.debug", "all");
+ System.setProperty("jogamp.debug.JNILibLoader", "true");
+ System.setProperty("jogamp.debug.NativeLibrary", "true");
+ }
+
+ String apkGlueGen = null;
+ String apkJogl = null;
+
+ try {
+ apkGlueGen = ctx.getPackageManager().getApplicationInfo(packageGlueGen,0).sourceDir;
+ apkJogl = ctx.getPackageManager().getApplicationInfo(packageJogl,0).sourceDir;
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.d(TAG, "error: "+e, e);
+ }
+ if(null == apkGlueGen || null == apkJogl) {
+ Log.d(TAG, "not found: gluegen <"+apkGlueGen+">, jogl <"+apkJogl+">");
+ return null;
+ }
+
+ final String cp = apkGlueGen + ":" + apkJogl ;
+ Log.d(TAG, "cp: " + cp);
+
+ final File dexPath = ctx.getDir(dexPathName, Context.MODE_WORLD_READABLE);
+
+ ClassLoader cl = new DexClassLoader(cp, dexPath.getAbsolutePath(), libPathName, ctx.getClassLoader());
+ Log.d(TAG, "cl: " + cl);
+ // setAPKClassLoader(dexLoader);
+
+ return cl;
+ }
+
+}
diff --git a/src/android/com/jogamp/android/launcher/NEWTLauncherVersionActivity.java b/src/android/com/jogamp/android/launcher/NEWTLauncherVersionActivity.java
index 468beed0b..c07b502fb 100644
--- a/src/android/com/jogamp/android/launcher/NEWTLauncherVersionActivity.java
+++ b/src/android/com/jogamp/android/launcher/NEWTLauncherVersionActivity.java
@@ -29,6 +29,7 @@ package com.jogamp.android.launcher;
import java.lang.reflect.Method;
+import dalvik.system.DexClassLoader;
import dalvik.system.PathClassLoader;
import android.app.Activity;
@@ -46,46 +47,21 @@ public class NEWTLauncherVersionActivity extends Activity {
Log.d(TAG, "onCreate - S");
super.onCreate(savedInstanceState);
- String packageGlueGen = "com.jogamp.common";
- String apkGlueGen = null;
- String packageJogl = "javax.media.opengl";
- String apkJogl = null;
-
String clazzMDName= "jogamp.newt.driver.android.MD";
- Method mdGetInfo = null;
-
- try {
- apkGlueGen = getPackageManager().getApplicationInfo(packageGlueGen,0).sourceDir;
- apkJogl = getPackageManager().getApplicationInfo(packageJogl,0).sourceDir;
- } catch (PackageManager.NameNotFoundException e) {
- Log.d(TAG, "error: "+e, e);
- }
- if(null == apkGlueGen || null == apkJogl) {
- Log.d(TAG, "not found: gluegen <"+apkGlueGen+">, jogl <"+apkJogl+">");
- } else {
- String cp = apkGlueGen + ":" + apkJogl ;
- Log.d(TAG, "cp: " + cp);
-
- // add path to apk that contains classes you wish to load
- PathClassLoader pathClassLoader = new dalvik.system.PathClassLoader(
- cp,
- ClassLoader.getSystemClassLoader());
-
+ String mdInfo = null;
+
+ ClassLoader cl = ClassLoaderUtil.createJogampClassLoaderSingleton(this, true);
+ if(null != cl) {
try {
- Class clazzMD= Class.forName(clazzMDName, true, pathClassLoader);
+ Class clazzMD= Class.forName(clazzMDName, true, cl);
Log.d(TAG, "MD: "+clazzMD);
- mdGetInfo = clazzMD.getMethod("getInfo");
+ Method mdGetInfo = clazzMD.getMethod("getInfo");
+ mdInfo = (String) mdGetInfo.invoke(null);
} catch (Exception e) {
Log.d(TAG, "error: "+e, e);
}
}
- String mdInfo = null;
- try {
- mdInfo = (String) mdGetInfo.invoke(null);
- } catch (Exception e) {
- Log.d(TAG, "error: "+e, e);
- }
tv = new TextView(this);
if(null != mdInfo) {
tv.setText(mdInfo);
diff --git a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java
index 5655d1a7a..08c755cd3 100644
--- a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java
@@ -59,9 +59,13 @@ public class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
}
/** Tool has none **/
- public final long toolDynamicLookupFunction(long toolGetProcAddressHandle, String funcName) {
+ public final long toolGetProcAddress(long toolGetProcAddressHandle, String funcName) {
return 0;
}
+
+ public boolean useToolGetProcAdressFirst(String funcName) {
+ return false;
+ }
public List/*<List<String>>*/ getToolLibNames() {
List/*<List>*/ libNamesList = new ArrayList();
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 766533aab..0bf4abab6 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -41,6 +41,8 @@
package javax.media.opengl;
import java.nio.IntBuffer;
+import java.security.AccessControlContext;
+import java.security.AccessController;
import java.util.HashMap;
import java.util.HashSet;
import javax.media.nativewindow.AbstractGraphicsDevice;
@@ -63,10 +65,17 @@ import jogamp.opengl.GLContextImpl;
abstraction provides a stable object which clients can use to
refer to a given context. */
public abstract class GLContext {
+
/** Reflects property jogl.debug.DebugGL. If true, the debug pipeline is enabled at context creation. */
- public final static boolean DEBUG_GL = Debug.debug("DebugGL");
+ public final static boolean DEBUG_GL;
/** Reflects property jogl.debug.TraceGL. If true, the trace pipeline is enabled at context creation. */
- public final static boolean TRACE_GL = Debug.debug("TraceGL");
+ public final static boolean TRACE_GL;
+
+ static {
+ final AccessControlContext acl = AccessController.getContext();
+ DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true, acl);
+ TRACE_GL = Debug.isPropertyDefined("jogl.debug.TraceGL", true, acl);
+ }
/** Indicates that the context was not made current during the last call to {@link #makeCurrent makeCurrent}. */
public static final int CONTEXT_NOT_CURRENT = 0;
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index 5fc977581..1340b661d 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -260,19 +260,17 @@ public abstract class GLDrawableFactory {
}
/**
- * Returns true if a shared context is already mapped to the <code>device</code> {@link AbstractGraphicsDevice#getConnection()},
- * or if a new shared context could be created and mapped. Otherwise return false.<br>
- * Creation of the shared context is tried only once.
+ * Returns true if a shared context could be created while initialization
+ * of shared resources for <code>device</code> {@link AbstractGraphicsDevice#getConnection()}.<br>
+ * This does not imply a shared context is mapped, but was available<br>.
*
* @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be <code>null</code> for the platform's default device.
*/
- public final boolean getIsSharedContextAvailable(AbstractGraphicsDevice device) {
- return null != getOrCreateSharedContext(device);
- }
+ public abstract boolean getWasSharedContextCreated(AbstractGraphicsDevice device);
/**
* Returns the shared context mapped to the <code>device</code> {@link AbstractGraphicsDevice#getConnection()},
- * either a preexisting or newly created, or <code>null</code> if creation failed or not supported.<br>
+ * either a pre-existing or newly created, or <code>null</code> if creation failed or not supported.<br>
* Creation of the shared context is tried only once.
*
* @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be <code>null</code> for the platform's default device.
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index f5f2e5389..0f502ce32 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -1202,7 +1202,7 @@ public class GLProfile {
if(null != desktopFactory) {
DesktopGLDynamicLookupHelper glLookupHelper = (DesktopGLDynamicLookupHelper) desktopFactory.getGLDynamicLookupHelper(0);
if(null!=glLookupHelper) {
- hasDesktopGLFactory = glLookupHelper.hasGLBinding();
+ hasDesktopGLFactory = glLookupHelper.isLibComplete() && hasGL234Impl;
}
}
} catch (LinkageError le) {
@@ -1279,7 +1279,7 @@ public class GLProfile {
final boolean addedAnyProfile = addedDesktopProfile || addedEGLProfile ;
if(DEBUG) {
- System.err.println("GLProfile.init addedAnyProfile(e/d) "+addedAnyProfile+" ("+addedDesktopProfile+"/"+addedEGLProfile+")");
+ System.err.println("GLProfile.init addedAnyProfile(d/e) "+addedAnyProfile+" ("+addedDesktopProfile+"/"+addedEGLProfile+")");
System.err.println("GLProfile.init isAWTAvailable "+isAWTAvailable);
System.err.println("GLProfile.init hasDesktopGLFactory "+hasDesktopGLFactory);
System.err.println("GLProfile.init hasGL234Impl "+hasGL234Impl);
@@ -1324,14 +1324,16 @@ public class GLProfile {
boolean addedDesktopProfile = false;
boolean addedEGLProfile = false;
-
- if( hasDesktopGLFactory && desktopFactory.getIsDeviceCompatible(device)) {
+ boolean deviceIsDesktopCompatible = false;
+ boolean deviceIsEGLCompatible = false;
+
+ if( hasDesktopGLFactory && ( deviceIsDesktopCompatible = desktopFactory.getIsDeviceCompatible(device)) ) {
// 1st pretend we have all Desktop and EGL profiles ..
computeProfileMap(device, true /* desktopCtxUndef*/, true /* esCtxUndef */);
// Triggers eager initialization of share context in GLDrawableFactory for the device,
// hence querying all available GLProfiles
- boolean desktopSharedCtxAvail = desktopFactory.getIsSharedContextAvailable(device);
+ boolean desktopSharedCtxAvail = desktopFactory.getWasSharedContextCreated(device);
if (DEBUG) {
System.err.println("GLProfile.initProfilesForDevice: "+device+": desktop Shared Ctx "+desktopSharedCtxAvail);
}
@@ -1343,13 +1345,14 @@ public class GLProfile {
1, 5, GLContext.CTX_PROFILE_COMPAT|GLContext.CTX_OPTION_ANY);
}
addedDesktopProfile = computeProfileMap(device, false /* desktopCtxUndef*/, false /* esCtxUndef */);
- } else if( null!=eglFactory && ( hasGLES2Impl || hasGLES1Impl ) && eglFactory.getIsDeviceCompatible(device)) {
+ } else if( hasEGLFactory && ( hasGLES2Impl || hasGLES1Impl ) &&
+ ( deviceIsEGLCompatible = eglFactory.getIsDeviceCompatible(device)) ) {
// 1st pretend we have all EGL profiles ..
computeProfileMap(device, false /* desktopCtxUndef*/, true /* esCtxUndef */);
// Triggers eager initialization of share context in GLDrawableFactory for the device,
// hence querying all available GLProfiles
- boolean eglSharedCtxAvail = eglFactory.getIsSharedContextAvailable(device);
+ boolean eglSharedCtxAvail = eglFactory.getWasSharedContextCreated(device);
if (DEBUG) {
System.err.println("GLProfile.initProfilesForDevice: "+device+": egl Shared Ctx "+eglSharedCtxAvail);
}
@@ -1371,7 +1374,13 @@ public class GLProfile {
} else {
setProfileMap(device, new HashMap()); // empty
if(DEBUG) {
- System.err.println("GLProfile: EGLFactory - Device is not available: "+device);
+ System.err.println("GLProfile: device could not be initialized: "+device);
+ System.err.println("GLProfile: compatible w/ desktop: "+deviceIsDesktopCompatible+
+ ", egl "+deviceIsEGLCompatible);
+ System.err.println("GLProfile: desktoplFactory "+desktopFactory);
+ System.err.println("GLProfile: eglFactory "+eglFactory);
+ System.err.println("GLProfile: hasGLES1Impl "+hasGLES1Impl);
+ System.err.println("GLProfile: hasGLES2Impl "+hasGLES2Impl);
}
}
diff --git a/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLibraryBundleInfo.java
index dc33541e6..1b8c3c1e5 100644
--- a/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLibraryBundleInfo.java
@@ -32,21 +32,14 @@ import java.util.List;
import java.util.ArrayList;
public abstract class DesktopGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundleInfo {
- private static int posGlueLibGLDESKTOP;
private static List/*<String>*/ glueLibNames;
static {
glueLibNames = new ArrayList();
glueLibNames.addAll(getGlueLibNamesPreload());
-
- posGlueLibGLDESKTOP = glueLibNames.size();
glueLibNames.add("jogl_desktop");
}
- public static final int getGlueLibPosGLDESKTOP() {
- return posGlueLibGLDESKTOP;
- }
-
public DesktopGLDynamicLibraryBundleInfo() {
super();
}
@@ -54,5 +47,10 @@ public abstract class DesktopGLDynamicLibraryBundleInfo extends GLDynamicLibrary
public final List/*<String>*/ getGlueLibNames() {
return glueLibNames;
}
+
+ public boolean useToolGetProcAdressFirst(String funcName) {
+ return true;
+ }
+
}
diff --git a/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java b/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java
index 4879c617e..2d2d1c536 100644
--- a/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java
+++ b/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java
@@ -39,10 +39,6 @@ public class DesktopGLDynamicLookupHelper extends GLDynamicLookupHelper {
public DesktopGLDynamicLibraryBundleInfo getDesktopGLBundleInfo() { return (DesktopGLDynamicLibraryBundleInfo) getBundleInfo(); }
- public boolean hasGLBinding() {
- return isToolLibLoaded() && isGlueLibLoaded(DesktopGLDynamicLibraryBundleInfo.getGlueLibPosGLDESKTOP());
- }
-
public synchronized boolean loadGLULibrary() {
/** hacky code .. where all platform GLU libs are tried ..*/
if(null==gluLib) {
diff --git a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java
index b5223a5b6..971b32d47 100644
--- a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java
+++ b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java
@@ -173,14 +173,16 @@ final class ExtensionAvailabilityCache {
System.err.println(getThreadName() + ":ExtensionAvailabilityCache: ALL EXTENSIONS: "+availableExtensionCache.size());
}
- int major[] = new int[] { context.getGLVersionMajor() };
- int minor[] = new int[] { context.getGLVersionMinor() };
- while (GLContext.isValidGLVersion(major[0], minor[0])) {
- availableExtensionCache.add("GL_VERSION_" + major[0] + "_" + minor[0]);
- if (DEBUG) {
- System.err.println(getThreadName() + ":ExtensionAvailabilityCache: Added GL_VERSION_" + major[0] + "_" + minor[0] + " to known extensions");
- }
- if(!GLContext.decrementGLVersion(major, minor)) break;
+ if(!context.isGLES()) {
+ int major[] = new int[] { context.getGLVersionMajor() };
+ int minor[] = new int[] { context.getGLVersionMinor() };
+ while (GLContext.isValidGLVersion(major[0], minor[0])) {
+ availableExtensionCache.add("GL_VERSION_" + major[0] + "_" + minor[0]);
+ if (DEBUG) {
+ System.err.println(getThreadName() + ":ExtensionAvailabilityCache: Added GL_VERSION_" + major[0] + "_" + minor[0] + " to known extensions");
+ }
+ if(!GLContext.decrementGLVersion(major, minor)) break;
+ }
}
// put a dummy var in here so that the cache is no longer empty even if
diff --git a/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java
index dc121323e..78ab7cc93 100644
--- a/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java
+++ b/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java
@@ -95,8 +95,7 @@ public class GLBufferSizeTracker {
// pattern of buffer objects indicates that the fact that this map
// never shrinks is probably not that bad.
private IntLongHashMap bufferSizeMap;
-
- protected static final boolean DEBUG = Debug.debug("GLStatusTracker");
+ protected static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.GLBufferSizeTracker", true);
public GLBufferSizeTracker() {
bufferSizeMap = new IntLongHashMap();
diff --git a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
index 1e5dc6069..92e27cbd4 100644
--- a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
+++ b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java
@@ -76,8 +76,7 @@ import com.jogamp.common.util.IntIntHashMap;
*/
public class GLBufferStateTracker {
- protected static final boolean DEBUG = GLBufferSizeTracker.DEBUG;
-
+ protected static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.GLBufferStateTracker", true);
// 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, according to the
diff --git a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
index 066ea8120..19a664071 100644
--- a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
+++ b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
@@ -138,6 +138,7 @@ public class GLGraphicsConfigurationUtil {
// fix caps ..
GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable();
caps2.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN
+ caps2.setOnscreen(false);
caps2.setPBuffer(true);
return caps2;
}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
index 07cf512f8..49b3556c0 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
@@ -172,7 +172,7 @@ public abstract class EGLContext extends GLContextImpl {
contextHandle = EGL.eglCreateContext(eglDisplay, eglConfig, shareWith, contextAttrs, 0);
if (contextHandle == 0) {
throw new GLException("Error creating OpenGL context: eglDisplay "+toHexString(eglDisplay)+
- ", eglConfig "+toHexString(eglConfig)+", "+glProfile+", error "+toHexString(EGL.eglGetError()));
+ ", eglConfig "+config+", "+glProfile+", shareWith "+toHexString(shareWith)+", error "+toHexString(EGL.eglGetError()));
}
GLContextShareSet.contextCreated(this);
if (DEBUG) {
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
index 3cc273966..a9cc40335 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
@@ -103,7 +103,7 @@ public abstract class EGLDrawable extends GLDrawableImpl {
AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice();
if(aDevice instanceof EGLGraphicsDevice) {
if(DEBUG) {
- System.err.println("EGLDrawable.setRealized: using existing EGL config - START");
+ System.err.println("EGLDrawable.setRealized(true): using existing EGL config - START");
}
// just fetch the data .. trust but verify ..
eglDisplay = aDevice.getHandle();
@@ -127,20 +127,14 @@ public abstract class EGLDrawable extends GLDrawableImpl {
} else {
// EGLSurface is ours ..
ownEGLSurface=true;
-
- eglConfig.updateGraphicsConfiguration();
-
recreateSurface();
}
} else {
throw new GLException("EGLGraphicsDevice hold by non EGLGraphicsConfiguration: "+aConfig);
}
- if(DEBUG) {
- System.err.println("EGLDrawable.setRealized: using existing EGL config - END: "+this);
- }
} else {
if(DEBUG) {
- System.err.println("EGLDrawable.setRealized: creating new EGL config - START");
+ System.err.println("EGLDrawable.setRealized(true): creating new EGL config - START");
}
// create a new EGL config ..
ownEGLDisplay=true;
@@ -182,11 +176,14 @@ public abstract class EGLDrawable extends GLDrawableImpl {
System.err.println("Chosen eglConfig: "+eglConfig);
}
recreateSurface();
- if(DEBUG) {
- System.err.println("EGLDrawable.setRealized: creating new EGL config - END: "+this);
- }
+ }
+ if(DEBUG) {
+ System.err.println("EGLDrawable.setRealized(true): END: ownDisplay "+ownEGLDisplay+", ownSurface "+ownEGLSurface+" - "+this);
}
} else if (ownEGLSurface && eglSurface != EGL.EGL_NO_SURFACE) {
+ if(DEBUG) {
+ System.err.println("EGLDrawable.setRealized(false): ownDisplay "+ownEGLDisplay+", ownSurface "+ownEGLSurface);
+ }
// Destroy the window surface
if (!EGL.eglDestroySurface(eglDisplay, eglSurface)) {
throw new GLException("Error destroying window surface (eglDestroySurface)");
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
index 45d286da3..e0283abd7 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
@@ -42,6 +42,7 @@ import javax.media.opengl.*;
import com.jogamp.common.JogampRuntimeException;
import com.jogamp.common.util.*;
+
import jogamp.opengl.*;
import jogamp.nativewindow.WrappedSurface;
@@ -102,15 +103,27 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
static class SharedResource {
private EGLGraphicsDevice device;
- //private EGLDrawable drawable;
- //private EGLContext context;
-
- SharedResource(EGLGraphicsDevice dev /*, EGLDrawable draw, EGLContext ctx */) {
+ // private EGLDrawable drawable;
+ // private EGLContext contextES1;
+ // private EGLContext contextES2;
+ private boolean wasES1ContextCreated;
+ private boolean wasES2ContextCreated;
+
+ SharedResource(EGLGraphicsDevice dev, boolean wasContextES1Created, boolean wasContextES2Created
+ /*EGLDrawable draw, EGLContext ctxES1, EGLContext ctxES2 */) {
device = dev;
// drawable = draw;
- // context = ctx;
+ // contextES1 = ctxES1;
+ // contextES2 = ctxES2;
+ this.wasES1ContextCreated = wasContextES1Created;
+ this.wasES2ContextCreated = wasContextES2Created;
}
- EGLGraphicsDevice getDevice() { return device; }
+ final EGLGraphicsDevice getDevice() { return device; }
+ // final EGLDrawable getDrawable() { return drawable; }
+ // final EGLContext getContextES1() { return contextES1; }
+ // final EGLContext getContextES2() { return contextES2; }
+ final boolean wasES1ContextAvailable() { return wasES1ContextCreated; }
+ final boolean wasES2ContextAvailable() { return wasES2ContextCreated; }
}
HashMap/*<connection, SharedResource>*/ sharedMap = new HashMap();
EGLGraphicsDevice defaultDevice;
@@ -123,40 +136,81 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
return true; // via mappings (X11/WGL/.. -> EGL) we shall be able to handle all types.
}
- private SharedResource getOrCreateShared(AbstractGraphicsDevice device) {
- String connection = device.getConnection();
+ private boolean isEGLContextAvailable(EGLGraphicsDevice sharedDevice, String profile) {
+ boolean madeCurrent = false;
+ final GLCapabilities caps = new GLCapabilities(GLProfile.get(profile));
+ caps.setRedBits(5); caps.setGreenBits(5); caps.setBlueBits(5); caps.setAlphaBits(0);
+ caps.setDoubleBuffered(false);
+ caps.setOnscreen(false);
+ caps.setPBuffer(true);
+ final EGLDrawable drawable = (EGLDrawable) createGLDrawable( createOffscreenSurfaceImpl(sharedDevice, caps, caps, null, 64, 64) );
+ if(null!=drawable) {
+ final EGLContext context = (EGLContext) drawable.createContext(null);
+ if (null != context) {
+ context.setSynchronized(true);
+ try {
+ context.makeCurrent(); // could cause exception
+ madeCurrent = context.isCurrent();
+ } catch (GLException gle) {
+ if (DEBUG) {
+ System.err.println("EGLDrawableFactory.createShared: INFO: makeCurrent failed");
+ gle.printStackTrace();
+ }
+ } finally {
+ context.destroy();
+ }
+ }
+ drawable.destroy();
+ }
+ return madeCurrent;
+ }
+
+ private SharedResource getOrCreateShared(AbstractGraphicsDevice adevice) {
+ String connection = adevice.getConnection();
SharedResource sr;
synchronized(sharedMap) {
sr = (SharedResource) sharedMap.get(connection);
}
- if(null==sr) {
+ if(null==sr) {
long eglDisplay = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
if (eglDisplay == EGL.EGL_NO_DISPLAY) {
throw new GLException("Failed to created EGL default display: error 0x"+Integer.toHexString(EGL.eglGetError()));
} else if(DEBUG) {
- System.err.println("eglDisplay(EGL_DEFAULT_DISPLAY): 0x"+Long.toHexString(eglDisplay));
+ System.err.println("EGLDrawableFactory.createShared: eglDisplay(EGL_DEFAULT_DISPLAY): 0x"+Long.toHexString(eglDisplay));
}
if (!EGL.eglInitialize(eglDisplay, null, null)) {
throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError()));
}
- EGLGraphicsDevice sharedDevice = new EGLGraphicsDevice(eglDisplay, connection, device.getUnitID());
- sr = new SharedResource(sharedDevice);
+ final EGLGraphicsDevice sharedDevice = new EGLGraphicsDevice(eglDisplay, connection, adevice.getUnitID());
+ // final boolean madeCurrentES1 = isEGLContextAvailable(sharedDevice, GLProfile.GLES1);
+ // final boolean madeCurrentES2 = isEGLContextAvailable(sharedDevice, GLProfile.GLES2);
+ final boolean madeCurrentES1 = true; // FIXME
+ final boolean madeCurrentES2 = true; // FIXME
+ sr = new SharedResource(sharedDevice, madeCurrentES1, madeCurrentES2);
synchronized(sharedMap) {
sharedMap.put(connection, sr);
}
if (DEBUG) {
- System.err.println("!!! SharedDevice: "+sharedDevice);
- }
+ System.err.println("EGLDrawableFactory.createShared: device: " + sharedDevice);
+ System.err.println("EGLDrawableFactory.createShared: context ES1: " + madeCurrentES1);
+ System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2);
+ }
}
return sr;
}
-
+ public final boolean getWasSharedContextCreated(AbstractGraphicsDevice device) {
+ SharedResource sr = getOrCreateShared(device);
+ if(null!=sr) {
+ return sr.wasES1ContextAvailable() || sr.wasES2ContextAvailable();
+ }
+ return false;
+ }
+
protected final GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device) {
- // FIXME: not implemented .. needs a dummy EGL surface - NEEDED ?
- return null;
+ return null; // n/a for EGL .. since we don't keep the resources
}
-
+
protected AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device) {
SharedResource sr = getOrCreateShared(device);
if(null!=sr) {
@@ -205,7 +259,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
if(!caps.isPBuffer()) {
- throw new GLException("Not yet implemented");
+ throw new GLException("Non pbuffer not yet implemented");
}
// PBuffer GLDrawable Creation
return new EGLPbufferDrawable(this, target);
@@ -221,10 +275,14 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
return ns;
}
- protected ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice device, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) {
- WrappedSurface ns = new WrappedSurface(EGLGraphicsConfigurationFactory.createOffscreenGraphicsConfiguration(device, capsRequested, capsRequested, chooser), windowHandle);
+ protected ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice adevice, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) {
+ // FIXME device/windowHandle -> screen ?!
+ EGLGraphicsDevice device = (EGLGraphicsDevice) adevice;
+ DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, 0);
+ EGLGraphicsConfiguration cfg = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen);
+ WrappedSurface ns = new WrappedSurface(cfg, windowHandle);
return ns;
- }
+ }
protected GLContext createExternalGLContextImpl() {
AbstractGraphicsScreen absScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_EGL);
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java
index 6fd3ecf1c..4182c4666 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java
@@ -30,10 +30,14 @@ package jogamp.opengl.egl;
import com.jogamp.common.os.DynamicLookupHelper;
import com.jogamp.common.os.NativeLibrary;
+import com.jogamp.common.os.Platform;
+
import java.util.*;
+
import javax.media.nativewindow.*;
import javax.media.opengl.*;
import jogamp.opengl.*;
+
import java.security.*;
/**
@@ -43,6 +47,12 @@ import java.security.*;
* Currently two implementations exist, one for ES1 and one for ES2.
*/
public abstract class EGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundleInfo {
+ static List/*<String>*/ glueLibNames;
+ static {
+ glueLibNames = new ArrayList();
+ glueLibNames.addAll(GLDynamicLibraryBundleInfo.getGlueLibNamesPreload());
+ glueLibNames.add("jogl_mobile");
+ }
protected EGLDynamicLibraryBundleInfo() {
super();
@@ -50,21 +60,30 @@ public abstract class EGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundle
/** Might be a desktop GL library, and might need to allow symbol access to subsequent libs */
public boolean shallLinkGlobal() { return true; }
+
+ public boolean shallLookupGlobal() { return true; }
+
public final List getToolGetProcAddressFuncNameList() {
List res = new ArrayList();
res.add("eglGetProcAddress");
return res;
}
- public final long toolDynamicLookupFunction(long toolGetProcAddressHandle, String funcName) {
+ public final long toolGetProcAddress(long toolGetProcAddressHandle, String funcName) {
return EGL.eglGetProcAddress(toolGetProcAddressHandle, funcName);
}
+ public final boolean useToolGetProcAdressFirst(String funcName) {
+ return false; // JAU / FIXME funcName.startsWith("egl");
+ }
+
protected List/*<String>*/ getEGLLibNamesList() {
List/*<String>*/ eglLibNames = new ArrayList();
+
// try default generic names first
eglLibNames.add("EGL");
+
// for windows distributions using the 'unlike' lib prefix,
// where our tool does not add it.
eglLibNames.add("libEGL");
@@ -72,4 +91,8 @@ public abstract class EGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundle
eglLibNames.add("libEGL.so.1");
return eglLibNames;
}
+
+ public final List/*<String>*/ getGlueLibNames() {
+ return glueLibNames;
+ }
}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java
index 13da8d3d4..4c38a29b1 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java
@@ -29,16 +29,12 @@
package jogamp.opengl.egl;
import java.util.*;
+
+import com.jogamp.common.os.Platform;
+
import jogamp.opengl.*;
public class EGLES1DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo {
- static List/*<String>*/ glueLibNames;
- static {
- glueLibNames = new ArrayList();
- glueLibNames.addAll(GLDynamicLibraryBundleInfo.getGlueLibNamesPreload());
- glueLibNames.add("jogl_es1");
- }
-
protected EGLES1DynamicLibraryBundleInfo() {
super();
}
@@ -47,6 +43,7 @@ public class EGLES1DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo
List/*<List>*/ libNames = new ArrayList();
List/*<String>*/ glesLibNames = new ArrayList();
+
// try default generic names first
glesLibNames.add("GLES_CM");
glesLibNames.add("GLES_CL");
@@ -63,9 +60,5 @@ public class EGLES1DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo
libNames.add(getEGLLibNamesList());
return libNames;
}
-
- public List/*<String>*/ getGlueLibNames() {
- return glueLibNames;
- }
}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java
index 361f0148e..7943e1946 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java
@@ -29,16 +29,12 @@
package jogamp.opengl.egl;
import java.util.*;
+
+import com.jogamp.common.os.Platform;
+
import jogamp.opengl.*;
public class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo {
- static List/*<String>*/ glueLibNames;
- static {
- glueLibNames = new ArrayList();
- glueLibNames.addAll(GLDynamicLibraryBundleInfo.getGlueLibNamesPreload());
- glueLibNames.add("jogl_es2");
- }
-
protected EGLES2DynamicLibraryBundleInfo() {
super();
}
@@ -47,6 +43,7 @@ public class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo
List/*<List>*/ libNames = new ArrayList();
List/*<String>*/ glesLibNames = new ArrayList();
+
// try default generic names first
glesLibNames.add("GLES20");
glesLibNames.add("GLESv2");
@@ -63,9 +60,5 @@ public class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo
libNames.add(getEGLLibNamesList());
return libNames;
}
-
- public List/*<String>*/ getGlueLibNames() {
- return glueLibNames;
- }
}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
index 6c4901de8..ab332e659 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
@@ -37,7 +37,8 @@ public class EGLGLCapabilities extends GLCapabilities {
final long eglcfg;
final int eglcfgid;
final int renderableType;
-
+ int nativeVisualID;
+
/** Comparing EGLConfig ID only */
public static class EglCfgIDComparator implements Comparator {
@@ -101,6 +102,8 @@ public class EGLGLCapabilities extends GLCapabilities {
final public long getEGLConfig() { return eglcfg; }
final public int getEGLConfigID() { return eglcfgid; }
final public int getRenderableType() { return renderableType; }
+ final public void setNativeVisualID(int vid) { nativeVisualID=vid; }
+ final public int getNativeVisualID() { return nativeVisualID; }
public static boolean isCompatible(GLProfile glp, int renderableType) {
if(null == glp) {
@@ -155,8 +158,9 @@ public class EGLGLCapabilities extends GLCapabilities {
if(null == sink) {
sink = new StringBuffer();
}
- sink.append("0x").append(Long.toHexString(eglcfg)).append(", ");
+ // sink.append("0x").append(Long.toHexString(eglcfg)).append(", ");
sink.append("0x").append(Long.toHexString(eglcfgid)).append(": ");
+ sink.append("vid 0x").append(Integer.toHexString(nativeVisualID)).append(", ");
super.toString(sink);
sink.append(", [");
renderableTypeToString(sink, renderableType);
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
index 8de590879..1eda2fb7a 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
@@ -36,10 +36,13 @@
package jogamp.opengl.egl;
+import java.nio.IntBuffer;
import java.util.ArrayList;
import javax.media.nativewindow.*;
import javax.media.nativewindow.egl.*;
import javax.media.opengl.*;
+
+import com.jogamp.common.nio.Buffers;
import com.jogamp.common.nio.PointerBuffer;
import jogamp.opengl.*;
@@ -149,80 +152,100 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
GLProfile glp, long display, long config,
int winattrmask) {
final int allDrawableTypeBits = EGLConfigDrawableTypeBits(display, config);
- final int drawableTypeBits = winattrmask & allDrawableTypeBits;
+ int drawableTypeBits = winattrmask & allDrawableTypeBits;
if( 0 == drawableTypeBits ) {
return false;
}
- int[] val = new int[1];
-
+ final IntBuffer val = Buffers.newDirectIntBuffer(1);
+ int cfgID;
+ int rType;
+
// get the configID
- if(!EGL.eglGetConfigAttrib(display, config, EGL.EGL_CONFIG_ID, val, 0)) {
+ if(!EGL.eglGetConfigAttrib(display, config, EGL.EGL_CONFIG_ID, val)) {
if(DEBUG) {
// FIXME: this happens on a ATI PC Emulation ..
System.err.println("EGL couldn't retrieve ConfigID for config "+toHexString(config)+", error "+toHexString(EGL.eglGetError()));
}
return false;
}
+ cfgID = val.get(0);
- if(!EGL.eglGetConfigAttrib(display, config, EGL.EGL_RENDERABLE_TYPE, val, 0)) {
+ if(!EGL.eglGetConfigAttrib(display, config, EGL.EGL_RENDERABLE_TYPE, val)) {
if(DEBUG) {
System.err.println("EGL couldn't retrieve EGL_RENDERABLE_TYPE for config "+toHexString(config)+", error "+toHexString(EGL.eglGetError()));
}
return false;
}
+ rType = val.get(0);
+
EGLGLCapabilities caps = null;
try {
- caps = new EGLGLCapabilities(config, val[0], glp, val[0]);
+ caps = new EGLGLCapabilities(config, cfgID, glp, rType);
} catch (GLException gle) {
if(DEBUG) {
System.err.println("config "+toHexString(config)+": "+gle);
}
return false;
- }
-
+ }
+
// Read the actual configuration into the chosen caps
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_RED_SIZE, val, 0)) {
- caps.setRedBits(val[0]);
+ if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_NATIVE_VISUAL_ID, val)) {
+ caps.setNativeVisualID(val.get(0));
+ }
+ if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_RED_SIZE, val)) {
+ caps.setRedBits(val.get(0));
}
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_GREEN_SIZE, val, 0)) {
- caps.setGreenBits(val[0]);
+ if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_GREEN_SIZE, val)) {
+ caps.setGreenBits(val.get(0));
}
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_BLUE_SIZE, val, 0)) {
- caps.setBlueBits(val[0]);
+ if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_BLUE_SIZE, val)) {
+ caps.setBlueBits(val.get(0));
}
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_ALPHA_SIZE, val, 0)) {
- caps.setAlphaBits(val[0]);
+ if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_ALPHA_SIZE, val)) {
+ caps.setAlphaBits(val.get(0));
}
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_STENCIL_SIZE, val, 0)) {
- caps.setStencilBits(val[0]);
+ if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_STENCIL_SIZE, val)) {
+ caps.setStencilBits(val.get(0));
}
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_DEPTH_SIZE, val, 0)) {
- caps.setDepthBits(val[0]);
+ if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_DEPTH_SIZE, val)) {
+ caps.setDepthBits(val.get(0));
}
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_SAMPLES, val, 0)) {
- caps.setSampleBuffers(val[0]>0?true:false);
- caps.setNumSamples(val[0]);
+ if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_SAMPLES, val)) {
+ caps.setSampleBuffers(val.get(0)>0?true:false);
+ caps.setNumSamples(val.get(0));
}
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_TYPE, val, 0)) {
- caps.setBackgroundOpaque(val[0] != EGL.EGL_TRANSPARENT_RGB);
+ if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_TYPE, val)) {
+ caps.setBackgroundOpaque(val.get(0) != EGL.EGL_TRANSPARENT_RGB);
}
if(!caps.isBackgroundOpaque()) {
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_RED_VALUE, val, 0)) {
- caps.setTransparentRedValue(val[0]==EGL.EGL_DONT_CARE?-1:val[0]);
+ if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_RED_VALUE, val)) {
+ caps.setTransparentRedValue(val.get(0)==EGL.EGL_DONT_CARE?-1:val.get(0));
}
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_GREEN_VALUE, val, 0)) {
- caps.setTransparentGreenValue(val[0]==EGL.EGL_DONT_CARE?-1:val[0]);
+ if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_GREEN_VALUE, val)) {
+ caps.setTransparentGreenValue(val.get(0)==EGL.EGL_DONT_CARE?-1:val.get(0));
}
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_BLUE_VALUE, val, 0)) {
- caps.setTransparentBlueValue(val[0]==EGL.EGL_DONT_CARE?-1:val[0]);
+ if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_BLUE_VALUE, val)) {
+ caps.setTransparentBlueValue(val.get(0)==EGL.EGL_DONT_CARE?-1:val.get(0));
}
/** Not defined in EGL
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_ALPHA_VALUE, val, 0)) {
- caps.setTransparentAlphaValue(val[0]==EGL.EGL_DONT_CARE?-1:val[0]);
+ if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_ALPHA_VALUE, val)) {
+ caps.setTransparentAlphaValue(val.get(0)==EGL.EGL_DONT_CARE?-1:val.get(0));
} */
}
+ /**
+ if(caps.getNativeVisualID() == 0) {
+ boolean isWindowBit = 0 != ( drawableTypeBits & GLGraphicsConfigurationUtil.WINDOW_BIT );
+ drawableTypeBits &= ~GLGraphicsConfigurationUtil.WINDOW_BIT;
+ if( 0 == drawableTypeBits ) {
+ if(DEBUG) {
+ System.err.println("EGL_NATIVE_VISUAL_ID: 0, windowBit removed: "+isWindowBit+
+ ", no drawable bits left, bail out for: "+ caps);
+ }
+ return false;
+ }
+ } */
return GLGraphicsConfigurationUtil.addGLCapabilitiesPermutations(capsBucket, caps, drawableTypeBits );
}
@@ -275,12 +298,10 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
}
// 26
-
attrs[idx++] = EGL.EGL_RENDERABLE_TYPE;
if(caps.getGLProfile().usesNativeGLES1()) {
attrs[idx++] = EGL.EGL_OPENGL_ES_BIT;
- }
- else if(caps.getGLProfile().usesNativeGLES2()) {
+ } else if(caps.getGLProfile().usesNativeGLES2()) {
attrs[idx++] = EGL.EGL_OPENGL_ES2_BIT;
} else {
attrs[idx++] = EGL.EGL_OPENGL_BIT;
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
index 70ad842f8..3154818db 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
@@ -49,13 +49,16 @@ import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLDrawableFactory;
+import com.jogamp.common.nio.Buffers;
import com.jogamp.common.nio.PointerBuffer;
+
import jogamp.opengl.GLGraphicsConfigurationFactory;
import jogamp.opengl.GLGraphicsConfigurationUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.io.PrintStream;
+import java.nio.IntBuffer;
/** Subclass of GraphicsConfigurationFactory used when non-AWT tookits
@@ -106,23 +109,22 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
long eglDisplay = eglDevice.getHandle();
List/*<EGLGLCapabilities>*/ availableCaps = null;
- int[] maxConfigs = new int[1];
+ IntBuffer numConfigs = Buffers.newDirectIntBuffer(1);
- if(!EGL.eglGetConfigs(eglDisplay, null, 0, maxConfigs, 0)) {
+ if(!EGL.eglGetConfigs(eglDisplay, null, 0, numConfigs)) {
throw new GLException("Graphics configuration get maxConfigs (eglGetConfigs) call failed, error "+toHexString(EGL.eglGetError()));
}
- if(0 == maxConfigs[0]) {
+ if(0 == numConfigs.get(0)) {
throw new GLException("Graphics configuration get maxConfigs (eglGetConfigs) no configs");
}
- PointerBuffer configs = PointerBuffer.allocateDirect(maxConfigs[0]);
- int[] numConfigs = new int[1];
+ PointerBuffer configs = PointerBuffer.allocateDirect(numConfigs.get(0));
- if(!EGL.eglGetConfigs(eglDisplay, configs, configs.capacity(), numConfigs, 0)) {
+ if(!EGL.eglGetConfigs(eglDisplay, configs, configs.capacity(), numConfigs)) {
throw new GLException("Graphics configuration get all configs (eglGetConfigs) call failed, error "+toHexString(EGL.eglGetError()));
}
- if (numConfigs[0] > 0) {
- availableCaps = eglConfigs2GLCaps(null, eglDisplay, configs, numConfigs[0], GLGraphicsConfigurationUtil.ALL_BITS);
+ if (numConfigs.get(0) > 0) {
+ availableCaps = eglConfigs2GLCaps(null, eglDisplay, configs, numConfigs.get(0), GLGraphicsConfigurationUtil.ALL_BITS);
if( null != availableCaps && availableCaps.size() > 1) {
Collections.sort(availableCaps, EglCfgIDComparator);
}
@@ -131,7 +133,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
return availableCaps;
}
- private static EGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilitiesImmutable capsChosen,
+ /*package*/ static EGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilitiesImmutable capsChosen,
GLCapabilitiesImmutable capsReq,
GLCapabilitiesChooser chooser,
AbstractGraphicsScreen absScreen) {
@@ -229,30 +231,29 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
List/*<EGLGLCapabilities>*/ availableCaps = null;
int recommendedIndex = -1;
long recommendedEGLConfig = -1;
- int[] maxConfigs = new int[1];
+ IntBuffer numConfigs = Buffers.newDirectIntBuffer(1);
- if(!EGL.eglGetConfigs(eglDisplay, null, 0, maxConfigs, 0)) {
+ if(!EGL.eglGetConfigs(eglDisplay, null, 0, numConfigs)) {
throw new GLException("EGLGraphicsConfiguration.eglChooseConfig: Get maxConfigs (eglGetConfigs) call failed, error "+toHexString(EGL.eglGetError()));
}
- if(0 == maxConfigs[0]) {
+ if(0 == numConfigs.get(0)) {
throw new GLException("EGLGraphicsConfiguration.eglChooseConfig: Get maxConfigs (eglGetConfigs) no configs");
}
if (DEBUG) {
- System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglChooseConfig maxConfigs: "+maxConfigs[0]);
+ System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglChooseConfig maxConfigs: "+numConfigs.get(0));
System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglDisplay "+toHexString(eglDisplay)+", "+capsChosen);
}
- final int[] attrs = EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChosen);
- PointerBuffer configs = PointerBuffer.allocateDirect(maxConfigs[0]);
- int[] numConfigs = new int[1];
+ final IntBuffer attrs = Buffers.newDirectIntBuffer(EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChosen));
+ PointerBuffer configs = PointerBuffer.allocateDirect(numConfigs.get(0));
// 1st choice: get GLCapabilities based on users GLCapabilities setting recommendedIndex as preferred choice
- if( ! EGL.eglChooseConfig(eglDisplay, attrs, 0, configs, configs.capacity(), numConfigs, 0) ) {
+ if( ! EGL.eglChooseConfig(eglDisplay, attrs, configs, configs.capacity(), numConfigs) ) {
if(DEBUG) {
System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: false");
}
- } else if (numConfigs[0] > 0) {
- availableCaps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0], winattrmask);
+ } else if (numConfigs.get(0) > 0) {
+ availableCaps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs.get(0), winattrmask);
if(availableCaps.size() > 0) {
recommendedEGLConfig = configs.get(0);
recommendedIndex = 0;
@@ -273,11 +274,11 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
recommendedEGLConfig = -1;
recommendedIndex = -1;
- if(!EGL.eglGetConfigs(eglDisplay, configs, configs.capacity(), numConfigs, 0)) {
+ if(!EGL.eglGetConfigs(eglDisplay, configs, configs.capacity(), numConfigs)) {
throw new GLException("EGLGraphicsConfiguration.eglChooseConfig: #2 Get all configs (eglGetConfigs) call failed, error "+toHexString(EGL.eglGetError()));
}
- if (numConfigs[0] > 0) {
- availableCaps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0], winattrmask);
+ if (numConfigs.get(0) > 0) {
+ availableCaps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs.get(0), winattrmask);
}
}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java
index 6cbd1ee6a..5fb32e6cd 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java
@@ -46,13 +46,14 @@ import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLException;
+import jogamp.opengl.x11.glx.GLX;
+
public class EGLPbufferDrawable extends EGLDrawable {
private int texFormat;
protected static final boolean useTexture = false; // No yet ..
protected EGLPbufferDrawable(EGLDrawableFactory factory, NativeSurface target) {
super(factory, target);
- ownEGLDisplay = true;
// get choosen ones ..
GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)
@@ -76,6 +77,10 @@ public class EGLPbufferDrawable extends EGLDrawable {
}
+ protected void destroyImpl() {
+ setRealized(false);
+ }
+
protected long createSurface(long eglDpy, long eglNativeCfg, long surfaceHandle) {
NativeSurface nw = getNativeSurface();
int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(nw.getWidth(), nw.getHeight(), texFormat);
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
index 6ce793490..3a0f28352 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -116,9 +116,14 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
return false;
}
+ public final boolean getWasSharedContextCreated(AbstractGraphicsDevice device) {
+ // FIXME: not implemented .. needs a dummy OSX surface
+ return false;
+ }
+
protected final GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device) {
- // FIXME: not implemented .. needs a dummy OSX surface
- return null;
+ // FIXME: not implemented .. needs a dummy OSX surface
+ return null;
}
protected AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device) {
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDynamicLibraryBundleInfo.java
index 94d790cee..e81a9f4c5 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDynamicLibraryBundleInfo.java
@@ -62,7 +62,7 @@ public class MacOSXCGLDynamicLibraryBundleInfo extends DesktopGLDynamicLibraryBu
return res; */
}
- public final long toolDynamicLookupFunction(long toolGetProcAddressHandle, String funcName) {
+ public final long toolGetProcAddress(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/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
index 13bb24237..f8ba8d277 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -373,6 +373,14 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
final static String WGL_ARB_make_current_read = "WGL_ARB_make_current_read";
final static String wglMakeContextCurrent = "wglMakeContextCurrent";
+ public final boolean getWasSharedContextCreated(AbstractGraphicsDevice device) {
+ SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
+ if(null!=sr) {
+ return null != sr.getContext();
+ }
+ return false;
+ }
+
protected final GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device) {
SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
if(null!=sr) {
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDynamicLibraryBundleInfo.java
index 0fb7f4510..c7feb83c7 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDynamicLibraryBundleInfo.java
@@ -51,7 +51,7 @@ public class WindowsWGLDynamicLibraryBundleInfo extends DesktopGLDynamicLibraryB
return res;
}
- public final long toolDynamicLookupFunction(long toolGetProcAddressHandle, String funcName) {
+ public final long toolGetProcAddress(long toolGetProcAddressHandle, String funcName) {
return WGL.wglGetProcAddress(toolGetProcAddressHandle, funcName);
}
}
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
index 14f2a28f1..1caf1e24b 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
@@ -47,6 +47,7 @@ import javax.media.nativewindow.x11.*;
import javax.media.opengl.*;
import jogamp.opengl.*;
+
import com.jogamp.common.JogampRuntimeException;
import com.jogamp.common.util.*;
import jogamp.nativewindow.WrappedSurface;
@@ -260,6 +261,14 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
return false;
}
+ public final boolean getWasSharedContextCreated(AbstractGraphicsDevice device) {
+ SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
+ if(null!=sr) {
+ return null != sr.getContext();
+ }
+ return false;
+ }
+
protected final GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device) {
SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(device);
if(null!=sr) {
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDynamicLibraryBundleInfo.java
index 60e163c46..aa6e3e849 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDynamicLibraryBundleInfo.java
@@ -76,7 +76,7 @@ public class X11GLXDynamicLibraryBundleInfo extends DesktopGLDynamicLibraryBundl
return res;
}
- public final long toolDynamicLookupFunction(long toolGetProcAddressHandle, String funcName) {
+ public final long toolGetProcAddress(long toolGetProcAddressHandle, String funcName) {
return GLX.glXGetProcAddress(toolGetProcAddressHandle, funcName);
}
}
diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java
index d98e55bd8..dc07bd180 100644
--- a/src/newt/classes/jogamp/newt/DisplayImpl.java
+++ b/src/newt/classes/jogamp/newt/DisplayImpl.java
@@ -57,7 +57,7 @@ public abstract class DisplayImpl extends Display {
Class displayClass = NewtFactory.getCustomClass(type, "Display");
if(null==displayClass) {
if (NativeWindowFactory.TYPE_ANDROID.equals(type)) {
- displayClass = Class.forName("jogamp.newt.driver.android.Display");
+ displayClass = Class.forName("jogamp.newt.driver.android.AndroidDisplay");
} else if (NativeWindowFactory.TYPE_EGL.equals(type)) {
displayClass = Class.forName("jogamp.newt.driver.kd.KDDisplay");
} else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index d1ed10aaf..45899f08d 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -70,7 +70,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
Class screenClass = NewtFactory.getCustomClass(type, "Screen");
if(null==screenClass) {
if (NativeWindowFactory.TYPE_ANDROID.equals(type)) {
- screenClass = Class.forName("jogamp.newt.driver.android.Screen");
+ screenClass = Class.forName("jogamp.newt.driver.android.AndroidScreen");
} else if (NativeWindowFactory.TYPE_EGL.equals(type)) {
screenClass = Class.forName("jogamp.newt.driver.kd.KDScreen");
} else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 71d36e905..e03c4553e 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -141,7 +141,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
Class windowClass = NewtFactory.getCustomClass(type, "Window");
if(null==windowClass) {
if (NativeWindowFactory.TYPE_ANDROID.equals(type)) {
- windowClass = Class.forName("jogamp.newt.driver.android.Window");
+ windowClass = Class.forName("jogamp.newt.driver.android.AndroidWindow");
} else if (NativeWindowFactory.TYPE_EGL.equals(type)) {
windowClass = Class.forName("jogamp.newt.driver.kd.KDWindow");
} else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) {
@@ -262,12 +262,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if(screenReferenceAdded) {
throw new InternalError("XXX");
}
- screen.addReference();
- screenReferenceAdded = true;
- createNativeImpl();
+ if(canCreateNativeImpl()) {
+ screen.addReference();
+ screenReferenceAdded = true;
+ createNativeImpl();
+ screen.addScreenModeListener(screenModeListenerImpl);
+ setTitleImpl(title);
+ }
+ // always flag visible,
+ // allowing to retry if visible && 0 == windowHandle
setVisibleImpl(true, x, y, width, height);
- screen.addScreenModeListener(screenModeListenerImpl);
- setTitleImpl(title);
}
} finally {
if(null!=parentWindow) {
@@ -357,6 +361,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// Window: Native implementation
//
+ protected boolean canCreateNativeImpl() {
+ return true; // default: always able to be created
+ }
+
/**
* The native implementation must set the native windowHandle.<br>
*
@@ -595,8 +603,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if(0==windowHandle && visible) {
if( 0<width*height ) {
nativeWindowCreated = createNative();
- WindowImpl.this.waitForVisible(visible, true);
- madeVisible = visible;
+ if(nativeWindowCreated) {
+ WindowImpl.this.waitForVisible(visible, true);
+ madeVisible = visible;
+ }
}
} else if(WindowImpl.this.visible != visible) {
if(0 != windowHandle) {
@@ -2077,7 +2087,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// ee.printStackTrace();
}
- if(isNativeValid()) {
+ if(isValid()) {
if(0>width) {
width=this.width;
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/Display.java b/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java
index e1944276f..1ba40f189 100644
--- a/src/newt/classes/jogamp/newt/driver/android/Display.java
+++ b/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java
@@ -30,19 +30,20 @@ package jogamp.newt.driver.android;
import jogamp.newt.*;
import jogamp.opengl.egl.*;
+
import javax.media.nativewindow.*;
import javax.media.nativewindow.egl.*;
-import android.content.Context;
+import javax.media.opengl.GLException;
-public class Display extends jogamp.newt.DisplayImpl {
+import android.content.Context;
+import android.view.Surface;
- /*package*/ Context appContext;
-
+public class AndroidDisplay extends jogamp.newt.DisplayImpl {
static {
NEWTJNILibLoader.loadNEWT();
- if (!Window.initIDs()) {
- throw new NativeWindowException("Failed to initialize BCEGL Window jmethodIDs");
+ if (!AndroidWindow.initIDs()) {
+ throw new NativeWindowException("Failed to initialize Android NEWT Windowing library");
}
}
@@ -51,29 +52,47 @@ public class Display extends jogamp.newt.DisplayImpl {
}
- public Display() {
+ public AndroidDisplay() {
}
protected void createNativeImpl() {
- long handle = CreateDisplay(Screen.fixedWidth, Screen.fixedHeight);
- if (handle == EGL.EGL_NO_DISPLAY) {
- throw new NativeWindowException("BC EGL CreateDisplay failed");
+ // EGL Device
+ // final long eglDisplay = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
+ final long eglDisplay = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
+ if (eglDisplay == EGL.EGL_NO_DISPLAY) {
+ throw new GLException("Failed to created EGL default display: error 0x"+Integer.toHexString(EGL.eglGetError()));
+ } else if(DEBUG) {
+ System.err.println("Android Display.createNativeImpl: eglDisplay(EGL_DEFAULT_DISPLAY): 0x"+Long.toHexString(eglDisplay));
+ }
+ if (!EGL.eglInitialize(eglDisplay, null, null)) {
+ throw new GLException("eglInitialize failed eglDisplay 0x"+Long.toHexString(eglDisplay)+", error 0x"+Integer.toHexString(EGL.eglGetError()));
}
- aDevice = new EGLGraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
+ aDevice = new EGLGraphicsDevice(eglDisplay, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
}
protected void closeNativeImpl() {
if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) {
- DestroyDisplay(aDevice.getHandle());
+ EGL.eglTerminate(aDevice.getHandle());
}
}
protected void dispatchMessagesNative() {
// n/a .. DispatchMessages();
}
-
- private native long CreateDisplay(int width, int height);
- private native void DestroyDisplay(long dpy);
- private native void DispatchMessages();
+
+ public synchronized boolean setAppContext(Context ctx) {
+ if(null == appContext) {
+ appContext = ctx;
+ return true;
+ } else if(appContext != ctx) {
+ throw new RuntimeException("AppContext already set to "+appContext+", can't override w/ "+ctx);
+ }
+ return false;
+ }
+ public synchronized Context getAppContext() {
+ return appContext;
+ }
+
+ private Context appContext;
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java b/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java
new file mode 100644
index 000000000..34092e885
--- /dev/null
+++ b/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java
@@ -0,0 +1,133 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR
+ * CONTRIBUTORS 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.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package jogamp.newt.driver.android;
+
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.util.Dimension;
+import javax.media.nativewindow.util.DimensionReadOnly;
+import javax.media.nativewindow.util.SurfaceSize;
+
+import com.jogamp.newt.ScreenMode;
+import com.jogamp.newt.util.MonitorMode;
+
+import android.content.Context;
+import android.graphics.PixelFormat;
+import android.util.DisplayMetrics;
+import android.view.Surface;
+import android.view.WindowManager;
+
+public class AndroidScreen extends jogamp.newt.ScreenImpl {
+
+ static {
+ AndroidDisplay.initSingleton();
+ }
+
+ public AndroidScreen() {
+ }
+
+ protected void createNativeImpl() {
+ aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx);
+ }
+
+ protected void closeNativeImpl() { }
+
+ public synchronized boolean setAppContext(Context ctx) {
+ if(!((AndroidDisplay) getDisplay()).setAppContext(ctx)) {
+ return false;
+ }
+ final WindowManager wmgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
+ sm = getScreenMode(wmgr.getDefaultDisplay());
+ setScreenSize(sm.getMonitorMode().getSurfaceSize().getResolution().getWidth(),
+ sm.getMonitorMode().getSurfaceSize().getResolution().getHeight());
+ return true;
+ }
+ public synchronized Context getAppContext() {
+ return ((AndroidDisplay) getDisplay()).getAppContext();
+ }
+
+ protected ScreenMode getCurrentScreenModeImpl() {
+ return sm;
+ }
+
+ ScreenMode sm = null;
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+ static DimensionReadOnly getScreenSize(DisplayMetrics outMetrics) {
+ return new Dimension(outMetrics.widthPixels, outMetrics.heightPixels);
+ }
+ static SurfaceSize getSurfaceSize(android.view.Display aDisplay, DimensionReadOnly dim) {
+ int bpp;
+ switch(aDisplay.getPixelFormat()) {
+ case PixelFormat.RGBA_8888: bpp=32; break;
+ case PixelFormat.RGBX_8888: bpp=32; break;
+ case PixelFormat.RGB_888: bpp=24; break;
+ case PixelFormat.RGB_565: bpp=16; break;
+ case PixelFormat.RGBA_5551: bpp=16; break;
+ case PixelFormat.RGBA_4444: bpp=16; break;
+ case PixelFormat.RGB_332: bpp= 8; break;
+ default: bpp=32;
+ }
+ return new SurfaceSize(dim, bpp);
+ }
+ static DimensionReadOnly getScreenSizeMM(DisplayMetrics outMetrics) {
+ final float iw = (float) outMetrics.widthPixels / outMetrics.xdpi;
+ final float ih = (float) outMetrics.heightPixels / outMetrics.xdpi;
+ final float mmpi = 25.4f;
+ return new Dimension((int) ((iw * mmpi)+0.5), (int) ((ih * mmpi)+0.5));
+ }
+ static int getRotation(int androidRotation) {
+ int nrot;
+ switch(androidRotation) {
+ case Surface.ROTATION_270: nrot = ScreenMode.ROTATE_270; break;
+ case Surface.ROTATION_180: nrot = ScreenMode.ROTATE_180; break;
+ case Surface.ROTATION_90: nrot = ScreenMode.ROTATE_90; break;
+ case Surface.ROTATION_0:
+ default: nrot = ScreenMode.ROTATE_0;
+ }
+ return nrot;
+ }
+ static ScreenMode getScreenMode(android.view.Display aDisplay) {
+ final DisplayMetrics outMetrics = new DisplayMetrics();
+ aDisplay.getMetrics(outMetrics);
+
+ final DimensionReadOnly screenSize = getScreenSize(outMetrics);
+ final SurfaceSize surfaceSize = getSurfaceSize(aDisplay, screenSize);
+ final DimensionReadOnly screenSizeMM = getScreenSizeMM(outMetrics);
+ final int refreshRate = (int) aDisplay.getRefreshRate();
+ final MonitorMode mm = new MonitorMode(surfaceSize, screenSizeMM, refreshRate);
+
+ final int rotation = getRotation(aDisplay.getRotation());
+ return new ScreenMode(mm, rotation);
+ }
+
+
+}
+
diff --git a/src/newt/classes/jogamp/newt/driver/android/Window.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
index 4d66debef..4d66debef 100644
--- a/src/newt/classes/jogamp/newt/driver/android/Window.java
+++ b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
diff --git a/src/newt/classes/jogamp/newt/driver/android/MD.java b/src/newt/classes/jogamp/newt/driver/android/MD.java
index 9a2ed9824..06f787233 100644
--- a/src/newt/classes/jogamp/newt/driver/android/MD.java
+++ b/src/newt/classes/jogamp/newt/driver/android/MD.java
@@ -27,6 +27,11 @@
*/
package jogamp.newt.driver.android;
+import java.util.List;
+
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLProfile;
+
import com.jogamp.common.GlueGenVersion;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.VersionUtil;
@@ -36,9 +41,25 @@ public class MD {
public static final String TAG = "JogAmp.NEWT";
public static String getInfo() {
- return VersionUtil.getPlatformInfo()+Platform.NEWLINE+
- GlueGenVersion.getInstance()+Platform.NEWLINE+
- JoglVersion.getInstance()+Platform.NEWLINE+
- Platform.NEWLINE;
+
+ StringBuffer sb = new StringBuffer();
+
+ sb.append(VersionUtil.getPlatformInfo()).append(Platform.NEWLINE)
+ .append(GlueGenVersion.getInstance()).append(Platform.NEWLINE)
+ .append(JoglVersion.getInstance()).append(Platform.NEWLINE)
+ .append(Platform.NEWLINE);
+
+ final GLDrawableFactory factory = GLDrawableFactory.getEGLFactory();
+ final List/*<GLCapabilitiesImmutable>*/ availCaps = factory.getAvailableCapabilities(null);
+ for(int i=0; i<availCaps.size(); i++) {
+ sb.append(availCaps.get(i)).append(Platform.NEWLINE);
+ }
+
+ return sb.toString();
}
+
+ public static void main(String args[]) {
+
+ System.err.println(getInfo());
+ }
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/NEWTSurfaceView.java b/src/newt/classes/jogamp/newt/driver/android/NEWTSurfaceView.java
deleted file mode 100644
index 0a2cfcf05..000000000
--- a/src/newt/classes/jogamp/newt/driver/android/NEWTSurfaceView.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR
- * CONTRIBUTORS 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.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package jogamp.newt.driver.android;
-
-import android.content.Context;
-import android.view.SurfaceView;
-
-public class NEWTSurfaceView extends SurfaceView {
-
- SurfaceCallback scb;
-
- public NEWTSurfaceView(Context context) {
- super(context);
- scb = new SurfaceCallback();
- this.getHolder().addCallback(scb);
- }
-
- public void doSomething() {
- }
-}
diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java
index b9452e44b..96ca8514f 100644
--- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java
+++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java
@@ -27,21 +27,55 @@
*/
package jogamp.newt.driver.android;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+
+import com.jogamp.newt.NewtFactory;
+import com.jogamp.newt.Display;
+import com.jogamp.newt.Screen;
+import com.jogamp.newt.opengl.GLWindow;
+import jogamp.newt.driver.android.test.GearsGL2ES1;
+import com.jogamp.opengl.util.Animator;
+
+import jogamp.newt.driver.android.AndroidWindow;
+
import android.app.Activity;
import android.os.Bundle;
-import android.widget.TextView;
import android.util.Log;
public class NewtVersionActivity extends Activity {
- TextView tv = null;
-
+ AndroidWindow window = null;
+ GLWindow glWindow = null;
+ Animator animator = null;
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d(MD.TAG, "onCreate - S");
super.onCreate(savedInstanceState);
- tv = new TextView(this);
- tv.setText("need launcher");
- setContentView(tv);
+
+ System.setProperty("nativewindow.debug", "all");
+ System.setProperty("jogl.debug", "all");
+ System.setProperty("newt.debug", "all");
+ System.setProperty("jogamp.debug.JNILibLoader", "true");
+ System.setProperty("jogamp.debug.NativeLibrary", "true");
+ // System.setProperty("jogamp.debug.NativeLibrary.Lookup", "true");
+
+ GLProfile.initSingleton(true);
+
+ GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1));
+ // caps.setRedBits(5); caps.setGreenBits(6); caps.setBlueBits(5);
+ AndroidDisplay display = (AndroidDisplay) NewtFactory.createDisplay(null);
+ AndroidScreen screen = (AndroidScreen) NewtFactory.createScreen(display, 0);
+ screen.setAppContext(this.getApplicationContext());
+
+ window = (AndroidWindow) NewtFactory.createWindow(new Object[] { this }, screen, caps);
+ setContentView(window.getView());
+
+ glWindow = GLWindow.create(window);
+ glWindow.addGLEventListener(new GearsGL2ES1(1));
+ glWindow.setVisible(true);
+ animator = new Animator(glWindow);
+ animator.setUpdateFPSFrames(1, null);
+
Log.d(MD.TAG, "onCreate - X");
}
@@ -63,6 +97,9 @@ public class NewtVersionActivity extends Activity {
public void onResume() {
Log.d(MD.TAG, "onResume - S");
super.onResume();
+ if(null != animator) {
+ animator.start();
+ }
Log.d(MD.TAG, "onResume - X");
}
@@ -70,6 +107,9 @@ public class NewtVersionActivity extends Activity {
public void onPause() {
Log.d(MD.TAG, "onPause - S");
super.onPause();
+ if(null != animator) {
+ animator.pause();
+ }
Log.d(MD.TAG, "onPause - X");
}
@@ -83,7 +123,9 @@ public class NewtVersionActivity extends Activity {
@Override
public void onDestroy() {
Log.d(MD.TAG, "onDestroy - S");
- super.onDestroy();
+ super.onDestroy();
+ glWindow.destroy();
+ window.destroy();
Log.d(MD.TAG, "onDestroy - X");
}
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/Screen.java b/src/newt/classes/jogamp/newt/driver/android/Screen.java
deleted file mode 100644
index 44c7ca95f..000000000
--- a/src/newt/classes/jogamp/newt/driver/android/Screen.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR
- * CONTRIBUTORS 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.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package jogamp.newt.driver.android;
-
-import javax.media.nativewindow.*;
-import android.content.Context;
-
-public class Screen extends jogamp.newt.ScreenImpl {
-
- static {
- Display.initSingleton();
- }
-
-
- public Screen() {
- }
-
- protected void createNativeImpl() {
- aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx);
- // WINDOW_SERVICEUse with getSystemService(String) to retrieve a WindowManager for accessing
- setScreenSize(fixedWidth, fixedHeight);
- }
-
- protected void closeNativeImpl() { }
-
- //----------------------------------------------------------------------
- // Internals only
- //
-
- static final int fixedWidth = 1920;
- static final int fixedHeight = 1080;
-}
-
diff --git a/src/newt/classes/jogamp/newt/driver/android/SurfaceCallback.java b/src/newt/classes/jogamp/newt/driver/android/SurfaceCallback.java
deleted file mode 100644
index f953fe41d..000000000
--- a/src/newt/classes/jogamp/newt/driver/android/SurfaceCallback.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``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 JogAmp Community OR
- * CONTRIBUTORS 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.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package jogamp.newt.driver.android;
-
-import jogamp.common.os.android.MD;
-import android.view.SurfaceHolder;
-import android.view.SurfaceHolder.Callback2;
-import android.util.Log;
-
-public class SurfaceCallback implements Callback2 {
-
- public void surfaceCreated(SurfaceHolder holder) {
- Log.d(MD.TAG, "surfaceCreated");
- }
-
- public void surfaceChanged(SurfaceHolder holder, int format, int width,
- int height) {
- Log.d(MD.TAG, "surfaceChanged: f "+Integer.toString(format)+", "+width+"x"+height);
- }
-
- public void surfaceDestroyed(SurfaceHolder holder) {
- Log.d(MD.TAG, "surfaceDestroyed");
- }
-
- public void surfaceRedrawNeeded(SurfaceHolder holder) {
- Log.d(MD.TAG, "surfaceRedrawNeeded");
- }
-
-}
diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
index ef59cd4ad..75b9f8642 100644
--- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java
@@ -30,7 +30,7 @@ package jogamp.newt.driver.android.event;
import com.jogamp.common.util.IntIntHashMap;
-class AndroidNewtEventFactory {
+public class AndroidNewtEventFactory {
protected static final IntIntHashMap eventTypeANDROID2NEWT;
@@ -56,7 +56,7 @@ class AndroidNewtEventFactory {
eventTypeANDROID2NEWT = map;
}
- public static final int androidKeyCode2Newt(int androidKeyCode) {
+ static final int androidKeyCode2Newt(int androidKeyCode) {
//safest ...but ugly
if (android.view.KeyEvent.KEYCODE_0 == androidKeyCode) return com.jogamp.newt.event.KeyEvent.VK_0;
if (android.view.KeyEvent.KEYCODE_1 == androidKeyCode) return com.jogamp.newt.event.KeyEvent.VK_1;
@@ -100,7 +100,7 @@ class AndroidNewtEventFactory {
return 0;
}
- static final com.jogamp.newt.event.WindowEvent createWindowEvent(android.view.accessibility.AccessibilityEvent event, com.jogamp.newt.Window newtSource) {
+ public static final com.jogamp.newt.event.WindowEvent createWindowEvent(android.view.accessibility.AccessibilityEvent event, com.jogamp.newt.Window newtSource) {
int type = eventTypeANDROID2NEWT.get(event.getEventType());
if(0xFFFFFFFF != type) {
return new com.jogamp.newt.event.WindowEvent(type, ((null==newtSource)?null:(Object)newtSource), event.getEventTime());
@@ -108,7 +108,7 @@ class AndroidNewtEventFactory {
return null; // no mapping ..
}
- public static final int androidKeyModifiers2Newt(int androidMods) {
+ static final int androidKeyModifiers2Newt(int androidMods) {
int newtMods = 0;
if ((androidMods & android.view.KeyEvent.META_SYM_ON) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK;
if ((androidMods & android.view.KeyEvent.META_SHIFT_ON) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK;
@@ -117,7 +117,7 @@ class AndroidNewtEventFactory {
return newtMods;
}
- static final com.jogamp.newt.event.KeyEvent createKeyEvent(android.view.KeyEvent event, com.jogamp.newt.Window newtSource) {
+ public static final com.jogamp.newt.event.KeyEvent createKeyEvent(android.view.KeyEvent event, com.jogamp.newt.Window newtSource) {
int type = eventTypeANDROID2NEWT.get(event.getAction());
if(0xFFFFFFFF != type) {
return new com.jogamp.newt.event.KeyEvent(
@@ -128,7 +128,7 @@ class AndroidNewtEventFactory {
return null;
}
- static final com.jogamp.newt.event.MouseEvent createMouseEvent(android.view.MotionEvent event, com.jogamp.newt.Window newtSource) {
+ public static final com.jogamp.newt.event.MouseEvent createMouseEvent(android.view.MotionEvent event, com.jogamp.newt.Window newtSource) {
int type = eventTypeANDROID2NEWT.get(event.getAction());
if(0xFFFFFFFF != type) {
int rotation = 0;
diff --git a/src/newt/classes/jogamp/newt/driver/android/test/GearsGL2ES1.java b/src/newt/classes/jogamp/newt/driver/android/test/GearsGL2ES1.java
new file mode 100644
index 000000000..1a4e16112
--- /dev/null
+++ b/src/newt/classes/jogamp/newt/driver/android/test/GearsGL2ES1.java
@@ -0,0 +1,422 @@
+
+package jogamp.newt.driver.android.test;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES1;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+import com.jogamp.opengl.util.ImmModeSink;
+
+import com.jogamp.newt.Window;
+import com.jogamp.newt.event.KeyAdapter;
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.KeyListener;
+import com.jogamp.newt.event.MouseAdapter;
+import com.jogamp.newt.event.MouseEvent;
+import com.jogamp.newt.event.MouseListener;
+
+/**
+ * Gears.java <BR>
+ * author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel) <P>
+ *
+ * This version is equal to Brian Paul's version 1.2 1999/10/21
+ */
+
+public class GearsGL2ES1 implements GLEventListener {
+ private final float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
+ private final float red[] = { 0.8f, 0.1f, 0.0f, 0.7f };
+ private final float green[] = { 0.0f, 0.8f, 0.2f, 0.7f };
+ private final float blue[] = { 0.2f, 0.2f, 1.0f, 0.7f };
+
+ private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
+ private GearBuffers gear1=null, gear2=null, gear3=null;
+ private float angle = 0.0f;
+ private int swapInterval;
+
+ private int prevMouseX, prevMouseY;
+
+ public GearsGL2ES1(int swapInterval) {
+ this.swapInterval = swapInterval;
+ }
+
+ public GearsGL2ES1() {
+ this.swapInterval = 1;
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ System.err.println("Gears: Init: "+drawable);
+ // Use debug pipeline
+ // drawable.setGL(new DebugGL(drawable.getGL()));
+
+ GL _gl = drawable.getGL();
+ // GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl /*, true*/);
+ GL2ES1 gl = _gl.getGL2ES1();
+
+ System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
+ System.err.println("INIT GL IS: " + gl.getClass().getName());
+ System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
+ System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
+ System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
+
+ gl.glLightfv(GL2ES1.GL_LIGHT0, GL2ES1.GL_POSITION, pos, 0);
+ gl.glEnable(GL.GL_CULL_FACE);
+ gl.glEnable(GL2ES1.GL_LIGHTING);
+ gl.glEnable(GL2ES1.GL_LIGHT0);
+ gl.glEnable(GL2ES1.GL_DEPTH_TEST);
+
+ /* make the gears */
+ if(null == gear1) {
+ gear1 = gear(gl, 1.0f, 4.0f, 1.0f, 20, 0.7f);
+ System.err.println("gear1 created: "+gear1);
+ } else {
+ System.err.println("gear1 reused: "+gear1);
+ }
+
+ if(null == gear2) {
+ gear2 = gear(gl, 0.5f, 2.0f, 2.0f, 10, 0.7f);
+ System.err.println("gear2 created: "+gear2);
+ } else {
+ System.err.println("gear2 reused: "+gear2);
+ }
+
+ if(null == gear3) {
+ gear3 = gear(gl, 1.3f, 2.0f, 0.5f, 10, 0.7f);
+ System.err.println("gear3 created: "+gear3);
+ } else {
+ System.err.println("gear3 reused: "+gear3);
+ }
+
+ gl.glEnable(GL2ES1.GL_NORMALIZE);
+
+ // MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter());
+ MouseListener gearsMouse = new GearsMouseAdapter();
+ KeyListener gearsKeys = new GearsKeyAdapter();
+
+ if (drawable instanceof Window) {
+ Window window = (Window) drawable;
+ window.addMouseListener(gearsMouse);
+ window.addKeyListener(gearsKeys);
+ } /* else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) {
+ java.awt.Component comp = (java.awt.Component) drawable;
+ new AWTMouseAdapter(gearsMouse).addTo(comp);
+ new AWTKeyAdapter(gearsKeys).addTo(comp);
+ } */
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height);
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
+
+ gl.setSwapInterval(swapInterval);
+
+ float h = (float)height / (float)width;
+
+ gl.glMatrixMode(GL2ES1.GL_PROJECTION);
+
+ gl.glLoadIdentity();
+ gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
+ gl.glMatrixMode(GL2ES1.GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glTranslatef(0.0f, 0.0f, -40.0f);
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ System.err.println("Gears: Dispose");
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ // Turn the gears' teeth
+ angle += 2.0f;
+
+ // Get the GL corresponding to the drawable we are animating
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
+
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ gl.glClear(GL2ES1.GL_COLOR_BUFFER_BIT | GL2ES1.GL_DEPTH_BUFFER_BIT);
+
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+
+ // Rotate the entire assembly of gears based on how the user
+ // dragged the mouse around
+ gl.glPushMatrix();
+ gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
+ gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
+ gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
+
+ final boolean disableBufferAfterDraw = true;
+
+ // Place the first gear and call its display list
+ gl.glPushMatrix();
+ gl.glTranslatef(-3.0f, -2.0f, 0.0f);
+ gl.glRotatef(angle, 0.0f, 0.0f, 1.0f);
+ gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, red, 0);
+ gear1.draw(gl, disableBufferAfterDraw);
+ gl.glPopMatrix();
+
+ // Place the second gear and call its display list
+ gl.glPushMatrix();
+ gl.glTranslatef(3.1f, -2.0f, 0.0f);
+ gl.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
+ gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, green, 0);
+ gear2.draw(gl, disableBufferAfterDraw);
+ gl.glPopMatrix();
+
+ // Place the third gear and call its display list
+ gl.glPushMatrix();
+ gl.glTranslatef(-3.1f, 4.2f, 0.0f);
+ gl.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
+ gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, blue, 0);
+ gear3.draw(gl, disableBufferAfterDraw);
+ gl.glPopMatrix();
+
+ // Remember that every push needs a pop; this one is paired with
+ // rotating the entire gear assembly
+ gl.glPopMatrix();
+ }
+
+ static class GearBuffers {
+ public final ImmModeSink frontFace;
+ public final ImmModeSink frontSide;
+ public final ImmModeSink backFace;
+ public final ImmModeSink backSide;
+ public final ImmModeSink outwardFace;
+ public final ImmModeSink insideRadiusCyl;
+
+ public GearBuffers(
+ ImmModeSink frontFace,
+ ImmModeSink frontSide,
+ ImmModeSink backFace,
+ ImmModeSink backSide,
+ ImmModeSink outwardFace,
+ ImmModeSink insideRadiusCyl) {
+ this.frontFace = frontFace;
+ this.frontSide = frontSide;
+ this.backFace = backFace;
+ this.backSide = backSide;
+ this.outwardFace = outwardFace;
+ this.insideRadiusCyl = insideRadiusCyl;
+ }
+
+ public void draw(GL2ES1 gl, boolean disableBufferAfterDraw) {
+ gl.glShadeModel(GL2ES1.GL_FLAT);
+ frontFace.draw(gl, disableBufferAfterDraw);
+ frontSide.draw(gl, disableBufferAfterDraw);
+ backFace.draw(gl, disableBufferAfterDraw);
+ backSide.draw(gl, disableBufferAfterDraw);
+ outwardFace.draw(gl, disableBufferAfterDraw);
+ gl.glShadeModel(GL2ES1.GL_SMOOTH);
+ insideRadiusCyl.draw(gl, disableBufferAfterDraw);
+ }
+ }
+
+ public static GearBuffers gear(GL2ES1 gl,
+ float inner_radius,
+ float outer_radius,
+ float width,
+ int teeth,
+ float tooth_depth)
+ {
+ final float dz = width * 0.5f;
+ int i;
+ float r0, r1, r2;
+ float angle, da;
+ float u, v, len;
+
+ r0 = inner_radius;
+ r1 = outer_radius - tooth_depth / 2.0f;
+ r2 = outer_radius + tooth_depth / 2.0f;
+
+ da = 2.0f * (float) Math.PI / teeth / 4.0f;
+
+ /* draw front face */
+ ImmModeSink vboFrontFace = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 4*teeth+2,
+ /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
+ /* normal */ 0, GL.GL_BYTE, /* texture */ 0, GL.GL_FLOAT);
+ vboFrontFace.glBegin(GL.GL_TRIANGLE_STRIP);
+ for (i = 0; i < teeth; i++) {
+ angle = i * 2.0f * (float) Math.PI / teeth;
+ vboFrontFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), dz);
+ vboFrontFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz);
+ vboFrontFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), dz);
+ vboFrontFace.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), dz);
+ }
+ vboFrontFace.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), dz);
+ vboFrontFace.glVertex3f(r1 * (float)Math.cos(0f), r1 * (float)Math.sin(0f), dz);
+ vboFrontFace.glEnd(gl, false /* immediate */);
+
+ /* draw front sides of teeth */
+ ImmModeSink vboFrontSide = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 6*teeth,
+ /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
+ /* normal */ 0, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT);
+ vboFrontSide.glBegin(GL.GL_TRIANGLES);
+ for (i = 0; i < teeth; i++) {
+ // QUAD [s0..s3] -> 2x TRIs
+ angle = i * 2.0f * (float) Math.PI / teeth;
+ // s0
+ vboFrontSide.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz);
+ // s1
+ vboFrontSide.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), dz);
+ // s2
+ vboFrontSide.glVertex3f(r2 * (float)Math.cos(angle + 2.0f * da), r2 * (float)Math.sin(angle + 2.0f * da), dz);
+
+ // s0
+ vboFrontSide.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz);
+ // s2
+ vboFrontSide.glVertex3f(r2 * (float)Math.cos(angle + 2.0f * da), r2 * (float)Math.sin(angle + 2.0f * da), dz);
+ // s3
+ vboFrontSide.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), dz);
+ }
+ vboFrontSide.glEnd(gl, false /* immediate */);
+
+ /* draw back face */
+ ImmModeSink vboBackFace = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 4*teeth+2,
+ /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
+ /* normal */ 0, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT);
+ vboBackFace.glBegin(GL.GL_TRIANGLE_STRIP);
+ for (i = 0; i < teeth; i++) {
+ angle = i * 2.0f * (float) Math.PI / teeth;
+ vboBackFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz);
+ vboBackFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -dz);
+ vboBackFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz);
+ vboBackFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -dz);
+ }
+ vboBackFace.glVertex3f(r1 * (float)Math.cos(0f), r1 * (float)Math.sin(0f), -dz);
+ vboBackFace.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), -dz);
+ vboBackFace.glEnd(gl, false /* immediate */);
+
+ /* draw back sides of teeth */
+ ImmModeSink vboBackSide = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 6*teeth,
+ /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
+ /* normal */ 0, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT);
+ vboBackSide.glBegin(GL.GL_TRIANGLES);
+ for (i = 0; i < teeth; i++) {
+ // QUAD [s0..s3] -> 2x TRIs
+ angle = i * 2.0f * (float) Math.PI / teeth;
+ // s0
+ vboBackSide.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz);
+ // s1
+ vboBackSide.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -dz);
+ // s2
+ vboBackSide.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -dz);
+
+ // s0
+ vboBackSide.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz);
+ // s2
+ vboBackSide.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -dz);
+ // s3
+ vboBackSide.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz);
+ }
+ vboBackSide.glEnd(gl, false /* immediate */);
+
+ /* draw outward faces of teeth */
+ ImmModeSink vboOutwardFace = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 4*4*teeth,
+ /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
+ /* normal */ 3, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT);
+ vboOutwardFace.glBegin(GL.GL_TRIANGLE_STRIP);
+ for (i = 0; i < teeth; i++) {
+ angle = i * 2.0f * (float) Math.PI / teeth;
+ u = r2 * (float)Math.cos(angle + da) - r1 * (float)Math.cos(angle);
+ v = r2 * (float)Math.sin(angle + da) - r1 * (float)Math.sin(angle);
+ len = (float)Math.sqrt(u * u + v * v);
+ u /= len;
+ v /= len;
+
+ vboOutwardFace.glNormal3f(v, -u, 0.0f);
+ vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz);
+ vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz);
+ vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), dz);
+ vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), -dz);
+
+ vboOutwardFace.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f);
+ vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), dz);
+ vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), -dz);
+ vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), dz);
+ vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -dz);
+
+ u = r1 * (float)Math.cos(angle + 3 * da) - r2 * (float)Math.cos(angle + 2 * da);
+ v = r1 * (float)Math.sin(angle + 3 * da) - r2 * (float)Math.sin(angle + 2 * da);
+ vboOutwardFace.glNormal3f(v, -u, 0.0f);
+ vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), dz);
+ vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -dz);
+ vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), dz);
+ vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz);
+
+ vboOutwardFace.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f);
+ vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), dz);
+ vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz);
+ vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz);
+ vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz);
+ }
+ vboOutwardFace.glEnd(gl, false /* immediate */);
+
+ /* draw inside radius cylinder */
+ ImmModeSink vboInsideRadiusCyl = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 2*teeth+2,
+ /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
+ /* normal */ 3, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT);
+ vboInsideRadiusCyl.glBegin(GL.GL_TRIANGLE_STRIP);
+ for (i = 0; i < teeth; i++) {
+ angle = i * 2.0f * (float) Math.PI / teeth;
+ vboInsideRadiusCyl.glNormal3f(-(float)Math.cos(angle), -(float)Math.sin(angle), 0.0f);
+ vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -dz);
+ vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), dz);
+ }
+ vboInsideRadiusCyl.glNormal3f(-(float)Math.cos(0f), -(float)Math.sin(0f), 0.0f);
+ vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), -dz);
+ vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), dz);
+ vboInsideRadiusCyl.glEnd(gl, false /* immediate */);
+ return new GearBuffers(vboFrontFace, vboFrontSide, vboBackFace, vboBackSide, vboOutwardFace, vboInsideRadiusCyl);
+ }
+
+ class GearsKeyAdapter extends KeyAdapter {
+ public void keyPressed(KeyEvent e) {
+ int kc = e.getKeyCode();
+ if(KeyEvent.VK_LEFT == kc) {
+ view_roty -= 1;
+ } else if(KeyEvent.VK_RIGHT == kc) {
+ view_roty += 1;
+ } else if(KeyEvent.VK_UP == kc) {
+ view_rotx -= 1;
+ } else if(KeyEvent.VK_DOWN == kc) {
+ view_rotx += 1;
+ }
+ }
+ }
+
+ class GearsMouseAdapter extends MouseAdapter {
+ public void mousePressed(MouseEvent e) {
+ prevMouseX = e.getX();
+ prevMouseY = e.getY();
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ }
+
+ public void mouseDragged(MouseEvent e) {
+ int x = e.getX();
+ int y = e.getY();
+ int width=0, height=0;
+ Object source = e.getSource();
+ if(source instanceof Window) {
+ Window window = (Window) source;
+ width=window.getWidth();
+ height=window.getHeight();
+ } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) {
+ java.awt.Component comp = (java.awt.Component) source;
+ width=comp.getWidth();
+ height=comp.getHeight();
+ } else {
+ throw new RuntimeException("Event source neither Window nor Component: "+source);
+ }
+ float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width);
+ float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height);
+
+ prevMouseX = x;
+ prevMouseY = y;
+
+ view_rotx += thetaX;
+ view_roty += thetaY;
+ }
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/OneTriangle.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/OneTriangle.java
index 655e590a3..fa4d8190e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/OneTriangle.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/OneTriangle.java
@@ -26,35 +26,33 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.jogl.swt;
+package com.jogamp.opengl.test.junit.jogl.demos.gl2;
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.glu.GLU;
-import org.eclipse.swt.graphics.Rectangle;
-
/**
* A utility class to encapsulate drawing a single triangle for unit tests.
* @author Wade Walker
*/
public class OneTriangle {
- public static void setup( GL2 gl, Rectangle rectangle ) {
+ public static void setup( GL2 gl, int width, int height ) {
gl.glMatrixMode( GL2.GL_PROJECTION );
gl.glLoadIdentity();
// coordinate system origin at lower left with width and height same as the window
GLU glu = new GLU();
- glu.gluOrtho2D( 0.0f, rectangle.width, 0.0f, rectangle.height );
+ glu.gluOrtho2D( 0.0f, width, 0.0f, height );
gl.glMatrixMode( GL2.GL_MODELVIEW );
gl.glLoadIdentity();
- gl.glViewport( 0, 0, rectangle.width, rectangle.height );
+ gl.glViewport( 0, 0, width, height );
}
- public static void render( GL2 gl, Rectangle rectangle ) {
+ public static void render( GL2 gl, int width, int height) {
gl.glClear( GL.GL_COLOR_BUFFER_BIT );
// draw a triangle filling the window
@@ -63,9 +61,9 @@ public class OneTriangle {
gl.glColor3f( 1, 0, 0 );
gl.glVertex2f( 0, 0 );
gl.glColor3f( 0, 1, 0 );
- gl.glVertex2f( rectangle.width, 0 );
+ gl.glVertex2f( width, 0 );
gl.glColor3f( 0, 0, 1 );
- gl.glVertex2f( rectangle.width / 2, rectangle.height );
+ gl.glVertex2f( width / 2, height );
gl.glEnd();
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug463ScaleImageMemoryAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug463ScaleImageMemoryAWT.java
index 1f525a643..c5d3389f1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug463ScaleImageMemoryAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug463ScaleImageMemoryAWT.java
@@ -40,6 +40,7 @@ import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.glu.gl2.GLUgl2;
+import javax.media.opengl.glu.gl2es1.GLUgl2es1;
import org.junit.Test;
@@ -73,7 +74,8 @@ public class TestBug463ScaleImageMemoryAWT implements GLEventListener {
ByteBuffer bufferIn = ByteBuffer.wrap(datain);
ByteBuffer bufferOut = ByteBuffer.wrap(dataout);
- GLUgl2 glu = new GLUgl2();
+ // GLUgl2 glu = new GLUgl2();
+ GLUgl2es1 glu = new GLUgl2es1();
// in the failing case, the system would run out of memory in here
glu.gluScaleImage( GL.GL_RGBA,
widthin, heightin, GL.GL_UNSIGNED_BYTE, bufferIn,
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT01GLn.java
index af125d4df..2fe99eaab 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT01GLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT01GLn.java
@@ -53,6 +53,7 @@ import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Test;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.OneTriangle;
import com.jogamp.opengl.test.junit.util.UITestCase;
/**
@@ -125,7 +126,7 @@ public class TestSWT01GLn extends UITestCase {
glcanvas.setCurrent();
glcontext.makeCurrent();
GL2 gl = glcontext.getGL().getGL2();
- OneTriangle.setup( gl, rectangle );
+ OneTriangle.setup( gl, rectangle.width, rectangle.height );
glcontext.release();
System.err.println("resize");
}
@@ -138,7 +139,7 @@ public class TestSWT01GLn extends UITestCase {
glcanvas.setCurrent();
glcontext.makeCurrent();
GL2 gl = glcontext.getGL().getGL2();
- OneTriangle.render( gl, rectangle );
+ OneTriangle.render( gl, rectangle.width, rectangle.height );
glcanvas.swapBuffers();
glcontext.release();
System.err.println("paint");
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java
index b3d167b80..1ee374895 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWT02GLn.java
@@ -51,6 +51,7 @@ import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Test;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.OneTriangle;
import com.jogamp.opengl.test.junit.util.UITestCase;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.ProxySurface;
@@ -151,7 +152,7 @@ public class TestSWT02GLn extends UITestCase {
if( GLContext.CONTEXT_NOT_CURRENT < glcontext.makeCurrent() ) {
glok=true;
GL2 gl = glcontext.getGL().getGL2();
- OneTriangle.setup( gl, rectangle );
+ OneTriangle.setup( gl, rectangle.width, rectangle.height );
glcontext.release();
} else {
sizeMissing[0] = true;
@@ -169,10 +170,10 @@ public class TestSWT02GLn extends UITestCase {
glok=true;
GL2 gl = glcontext.getGL().getGL2();
if(sizeMissing[0]) {
- OneTriangle.setup( gl, rectangle );
+ OneTriangle.setup( gl, rectangle.width, rectangle.height);
sizeMissing[0] = false;
}
- OneTriangle.render( gl, rectangle );
+ OneTriangle.render( gl, rectangle.width, rectangle.height);
drawable.swapBuffers();
glcontext.release();
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java
index 25653ab21..db95f9660 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java
@@ -52,6 +52,7 @@ import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Test;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.OneTriangle;
import com.jogamp.opengl.test.junit.util.UITestCase;
/**
@@ -133,14 +134,14 @@ public class TestSWTAWT01GLn extends UITestCase {
public void display( GLAutoDrawable glautodrawable ) {
Rectangle rectangle = new Rectangle( 0, 0, glautodrawable.getWidth(), glautodrawable.getHeight() );
GL2 gl = glautodrawable.getGL().getGL2();
- OneTriangle.render( gl, rectangle );
+ OneTriangle.render( gl, rectangle.width, rectangle.height );
}
/* @Override */
public void reshape( GLAutoDrawable glautodrawable, int x, int y, int width, int height ) {
Rectangle rectangle = new Rectangle( 0, 0, glautodrawable.getWidth(), glautodrawable.getHeight() );
GL2 gl = glautodrawable.getGL().getGL2();
- OneTriangle.setup( gl, rectangle );
+ OneTriangle.setup( gl, rectangle.width, rectangle.height );
}
});