aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/sun
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-06-05 10:34:15 +0000
committerSven Gothel <[email protected]>2009-06-05 10:34:15 +0000
commitfc45adb6e0f941a19952a790030ca19f80b9605a (patch)
treeb25fbea7ec00e4da279b6f538ade40622175f6e8 /src/jogl/classes/com/sun
parent5be26ee4eec25e04b220ec7610dab1b541dc46f9 (diff)
Win-EGL: Add dll function lookup for C++ decoration (Imageon driver) ; EGL: Some cleanup
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1927 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/jogl/classes/com/sun')
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java5
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java111
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java30
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java8
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java40
5 files changed, 116 insertions, 78 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
index 8253699af..9643a7945 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
@@ -192,6 +192,11 @@ public class EGLContext extends GLContextImpl {
if (eglConfig == null) {
throw new GLException("Error: attempted to create an OpenGL context without a graphics configuration");
}
+
+ if(!EGL.eglBindAPI(EGL.EGL_OPENGL_ES_API)) {
+ throw new GLException("eglBindAPI to ES failed , error 0x"+Integer.toHexString(EGL.eglGetError()));
+ }
+
EGLContext other = (EGLContext) GLContextShareSet.getShareContext(this);
if (other != null) {
shareWith = other.getContext();
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
index 6ffae08b8..b54e52fac 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
@@ -46,7 +46,7 @@ public class EGLDrawable extends GLDrawableImpl {
private long eglDisplay;
private EGLGraphicsConfiguration eglConfig;
private boolean ownEGLDisplay = false;
- private long eglSurface;
+ private long eglSurface = 0;
private int[] tmp = new int[1];
public EGLDrawable(EGLDrawableFactory factory,
@@ -76,10 +76,66 @@ public class EGLDrawable extends GLDrawableImpl {
return (null==eglConfig)?super.getGLCapabilities():(GLCapabilities)eglConfig.getCapabilities();
}
- private void setSurface() {
- if (EGL.EGL_NO_SURFACE==eglSurface) {
+ public GLContext createContext(GLContext shareWith) {
+ return new EGLContext(this, shareWith);
+ }
+
+ public void setRealized(boolean realized) {
+ if (realized) {
lockSurface();
try {
+ AbstractGraphicsConfiguration aConfig = component.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice();
+ if(aDevice instanceof EGLGraphicsDevice) {
+ // just fetch the data .. trust but verify ..
+ eglDisplay = aDevice.getHandle();
+ if (eglDisplay == EGL.EGL_NO_DISPLAY) {
+ throw new GLException("Invalid EGL display in EGLGraphicsDevice from "+aDevice);
+ }
+ if(aConfig instanceof EGLGraphicsConfiguration) {
+ eglConfig = (EGLGraphicsConfiguration) aConfig; // done ..
+ if (null == eglConfig) {
+ throw new GLException("Null EGLGraphicsConfiguration from "+aConfig);
+ }
+ } else {
+ throw new GLException("EGLGraphicsConfiguration doesn't carry a EGLGraphicsDevice: "+aConfig);
+ }
+ } else {
+ // create a new EGL config ..
+ ownEGLDisplay=true;
+ long nDisplay;
+ if( NativeWindowFactory.getNativeWindowType(false)==NativeWindowFactory.TYPE_WINDOWS ) {
+ nDisplay = component.getSurfaceHandle(); // don't even ask ..
+ } else {
+ nDisplay = aDevice.getHandle(); // 0 == EGL.EGL_DEFAULT_DISPLAY
+ }
+ eglDisplay = EGL.eglGetDisplay(nDisplay);
+ if (eglDisplay == EGL.EGL_NO_DISPLAY) {
+ if(DEBUG) {
+ System.err.println("eglDisplay("+Long.toHexString(nDisplay)+" <surfaceHandle>): failed, using EGL_DEFAULT_DISPLAY");
+ }
+ nDisplay = EGL.EGL_DEFAULT_DISPLAY;
+ eglDisplay = EGL.eglGetDisplay(nDisplay);
+ }
+ if (eglDisplay == EGL.EGL_NO_DISPLAY) {
+ throw new GLException("Failed to created EGL display: nhandle 0x"+Long.toHexString(nDisplay)+", "+aDevice+", error 0x"+Integer.toHexString(EGL.eglGetError()));
+ } else if(DEBUG) {
+ System.err.println("eglDisplay("+Long.toHexString(nDisplay)+"): 0x"+Long.toHexString(eglDisplay));
+ }
+ if (!EGL.eglInitialize(eglDisplay, null, null)) {
+ throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError()));
+ }
+ EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay);
+ DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, aConfig.getScreen().getIndex());
+ GLCapabilities caps = (GLCapabilities) aConfig.getCapabilities();
+ eglConfig = (EGLGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(e).chooseGraphicsConfiguration(caps, null, s);
+ if (null == eglConfig) {
+ throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);
+ } else if(DEBUG) {
+ System.err.println("Chosen eglConfig: "+eglConfig);
+ }
+ }
+
if(DEBUG) {
System.err.println("setSurface using component: handle 0x"+Long.toHexString(component.getWindowHandle())+", "+component);
}
@@ -93,55 +149,6 @@ public class EGLDrawable extends GLDrawableImpl {
} finally {
unlockSurface();
}
- }
- }
-
- public GLContext createContext(GLContext shareWith) {
- return new EGLContext(this, shareWith);
- }
-
- public void setRealized(boolean realized) {
- if (realized) {
- AbstractGraphicsConfiguration aConfig = component.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice();
- if(aDevice instanceof EGLGraphicsDevice) {
- // just fetch the data .. trust but verify ..
- eglDisplay = aDevice.getHandle();
- if (eglDisplay == EGL.EGL_NO_DISPLAY) {
- throw new GLException("Invalid EGL display in EGLGraphicsDevice from "+aDevice);
- }
- if(aConfig instanceof EGLGraphicsConfiguration) {
- eglConfig = (EGLGraphicsConfiguration) aConfig; // done ..
- if (null == eglConfig) {
- throw new GLException("Null EGLGraphicsConfiguration from "+aConfig);
- }
- } else {
- throw new GLException("EGLGraphicsConfiguration doesn't carry a EGLGraphicsDevice: "+aConfig);
- }
- } else {
- // create a new EGL config ..
- ownEGLDisplay=true;
- long ndisplay = (0!=aDevice.getHandle())?aDevice.getHandle():EGL.EGL_DEFAULT_DISPLAY;
- eglDisplay = EGL.eglGetDisplay(ndisplay);
- if (eglDisplay == EGL.EGL_NO_DISPLAY) {
- throw new GLException("Failed to created EGL display: nhandle 0x"+Long.toHexString(ndisplay)+", "+aDevice+", error 0x"+Integer.toHexString(EGL.eglGetError()));
- } else if(DEBUG) {
- System.err.println("eglDisplay("+ndisplay+"): 0x"+Long.toHexString(eglDisplay));
- }
- if (!EGL.eglInitialize(eglDisplay, null, null)) {
- throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError()));
- }
- EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay);
- DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, aConfig.getScreen().getIndex());
- GLCapabilities caps = (GLCapabilities) aConfig.getCapabilities();
- eglConfig = (EGLGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(e).chooseGraphicsConfiguration(caps, null, s);
- if (null == eglConfig) {
- throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);
- } else if(DEBUG) {
- System.err.println("Chosen eglConfig: "+eglConfig);
- }
- }
- setSurface();
} else if (eglSurface != EGL.EGL_NO_SURFACE) {
// Destroy the window surface
if (!EGL.eglDestroySurface(eglDisplay, eglSurface)) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
index 3f1fb6435..79c2a83b6 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
@@ -185,20 +185,36 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
private long dynamicLookupFunctionOnLibs(String glFuncName) {
+ String funcName=glFuncName;
+ long addr = dynamicLookupFunctionOnLibsImpl(funcName);
+ if( 0==addr && NativeWindowFactory.getNativeWindowType(false)==NativeWindowFactory.TYPE_WINDOWS ) {
+ // Hack: try some C++ decoration here for Imageon's emulation libraries ..
+ final int argAlignment=4; // 4 byte alignment of each argument
+ final int maxArguments=12; // experience ..
+ for(int arg=0; 0==addr && arg<=maxArguments; arg++) {
+ funcName = "_"+glFuncName+"@"+(arg*argAlignment);
+ addr = dynamicLookupFunctionOnLibsImpl(funcName);
+ }
+ }
+ if(DEBUG) {
+ if(0!=addr) {
+ System.err.println("Lookup-Native: "+glFuncName+" / "+funcName+" 0x"+Long.toHexString(addr));
+ } else {
+ System.err.println("Lookup-Native: "+glFuncName+" / "+funcName+" ** FAILED ** ");
+ }
+ }
+ return addr;
+ }
+
+ private long dynamicLookupFunctionOnLibsImpl(String glFuncName) {
// Look up this function name in all known libraries
for (Iterator iter = glesLibraries.iterator(); iter.hasNext(); ) {
NativeLibrary lib = (NativeLibrary) iter.next();
long addr = lib.lookupFunction(glFuncName);
if (addr != 0) {
- if(DEBUG) {
- System.err.println("Lookup-Native: <"+glFuncName+"> 0x"+Long.toHexString(addr));
- }
return addr;
}
}
- if(DEBUG) {
- System.err.println("Lookup-Native: <*"+glFuncName+"> ** FAILED ** ");
- }
return 0;
}
@@ -229,8 +245,6 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
if(DEBUG) {
if(0!=addr) {
System.err.println("Lookup-EGL: <"+glFuncName+"> 0x"+Long.toHexString(addr));
- } else {
- System.err.println("Lookup-EGL: <"+glFuncName+"> ** FAILED ** ");
}
}
if(0==addr) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
index 14e91bef1..c6d60190c 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
@@ -63,17 +63,9 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
public static _EGLConfig EGLConfigId2EGLConfig(GLProfile glp, long display, int configID) {
int[] attrs = new int[] {
- EGL.EGL_RENDERABLE_TYPE, -1,
EGL.EGL_CONFIG_ID, configID,
EGL.EGL_NONE
};
- if (glp.usesNativeGLES2()) {
- attrs[1] = EGL.EGL_OPENGL_ES2_BIT;
- } else if (glp.usesNativeGLES1()) {
- attrs[1] = EGL.EGL_OPENGL_ES_BIT;
- } else {
- attrs[1] = EGL.EGL_OPENGL_BIT;
- }
_EGLConfig[] configs = new _EGLConfig[1];
int[] numConfigs = new int[1];
if (!EGL.eglChooseConfig(display,
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
index 8fa086d85..fd59ccdbc 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
@@ -32,6 +32,7 @@
package com.sun.opengl.impl.egl;
+import java.io.PrintStream;
import javax.media.nativewindow.*;
import javax.media.nativewindow.egl.*;
import com.sun.nativewindow.impl.*;
@@ -118,12 +119,9 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
if (numConfigs[0] == 0) {
throw new GLException("Graphics configuration fetch (eglGetConfigs) - no EGLConfig found");
}
- GLCapabilities[] caps = new GLCapabilities[numConfigs[0]];
- for(int i=0; i<caps.length; i++) {
- caps[i] = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[i]);
- if(DEBUG) {
- System.err.println("caps["+i+"] "+caps[i]);
- }
+ GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0]);
+ if(DEBUG) {
+ printCaps("eglGetConfigs", caps, System.err);
}
int chosen = -1;
try {
@@ -172,23 +170,45 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
attrs, 0,
configs, 1,
numConfigs, 0)) {
- throw new GLException("Graphics configuration selection (eglChooseConfig) failed");
+ throw new GLException("Graphics configuration selection (eglChooseConfig) failed for "+capabilities);
}
if (numConfigs[0] > 0) {
+ if(DEBUG) {
+ GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0]);
+ printCaps("eglChooseConfig", caps, System.err);
+ }
int[] val = new int[1];
// get the configID
if(!EGL.eglGetConfigAttrib(eglDisplay, configs[0], EGL.EGL_CONFIG_ID, val, 0)) {
if(DEBUG) {
// FIXME: this happens on a ATI PC Emulation ..
- System.err.println("EGL couldn't retrieve ConfigID for already chosen eglConfig "+capabilities+", use 0");
+ System.err.println("EGL couldn't retrieve ConfigID for already chosen eglConfig "+capabilities+" fake 0");
}
val[0]=0;
}
+ GLCapabilities resCaps = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[0]);
+ if(DEBUG) {
+ System.err.println("eglChooseConfig found: "+capabilities+" -> "+resCaps);
+ }
- return new EGLGraphicsConfiguration(absScreen,
- EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[0]), configs[0], val[0]);
+ return new EGLGraphicsConfiguration(absScreen, resCaps, configs[0], val[0]);
}
return null;
}
+
+ protected static GLCapabilities[] eglConfigs2GLCaps(GLProfile glp, long eglDisplay, _EGLConfig[] configs, int num)
+ {
+ GLCapabilities[] caps = new GLCapabilities[num];
+ for(int i=0; i<num; i++) {
+ caps[i] = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[i]);
+ }
+ return caps;
+ }
+
+ protected static void printCaps(String prefix, GLCapabilities[] caps, PrintStream out) {
+ for(int i=0; i<caps.length; i++) {
+ out.println(prefix+"["+i+"] "+caps[i]);
+ }
+ }
}