aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/sun
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-10-04 13:04:42 -0700
committerSven Gothel <[email protected]>2009-10-04 13:04:42 -0700
commit5cd7e4fab47996eddf1a2798215fb975fe32b4bf (patch)
treed27b28ffbd985079fe33e1c4ae9166fd88bd0dd4 /src/jogl/classes/com/sun
parent14a2ea2a7eb093ff3fb5322ace1a6f8767401f3d (diff)
Fix EGL SurfaceType query/setup [on-/offscreen, pbuffer] using EGLConfig/GLCapabilities
Diffstat (limited to 'src/jogl/classes/com/sun')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java42
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java46
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java8
3 files changed, 54 insertions, 42 deletions
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 cde826c1b..9d337a207 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
@@ -73,7 +73,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
}
GLProfile glp = capsRequested.getGLProfile();
_EGLConfig _cfg = EGLConfigId2EGLConfig(glp, dpy, cfgID);
- GLCapabilities caps = EGLConfig2Capabilities(glp, dpy, _cfg, capsRequested.isOnscreen(), capsRequested.isPBuffer());
+ GLCapabilities caps = EGLConfig2Capabilities(glp, dpy, _cfg);
return new EGLGraphicsConfiguration(absScreen, caps, capsRequested, new DefaultGLCapabilitiesChooser(), _cfg, cfgID);
}
@@ -116,8 +116,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
return configs[0];
}
- public static GLCapabilities EGLConfig2Capabilities(GLProfile glp, long display, _EGLConfig _config,
- boolean onscreen, boolean pbuffer) {
+ public static GLCapabilities EGLConfig2Capabilities(GLProfile glp, long display, _EGLConfig _config) {
GLCapabilities caps = new GLCapabilities(glp);
int[] val = new int[1];
@@ -162,27 +161,36 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
caps.setTransparentAlphaValue(val[0]==EGL.EGL_DONT_CARE?-1:val[0]);
} */
}
- caps.setOnscreen(onscreen);
- caps.setDoubleBuffered(onscreen);
- caps.setPBuffer(pbuffer);
+ if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_SURFACE_TYPE, val, 0)) {
+ switch(val[0]) {
+ case EGL.EGL_WINDOW_BIT:
+ caps.setOnscreen(true);
+ caps.setPBuffer(false);
+ break;
+ case EGL.EGL_PBUFFER_BIT:
+ caps.setOnscreen(false);
+ caps.setPBuffer(true);
+ break;
+ case EGL.EGL_PIXMAP_BIT:
+ caps.setOnscreen(false);
+ caps.setPBuffer(false);
+ break;
+ default:
+ throw new GLException("Invalid EGL_SURFACE_TYPE 0x"+Integer.toHexString(val[0]));
+ }
+ } else {
+ throw new GLException("Could not determine EGL_SURFACE_TYPE");
+ }
+
return caps;
}
- public static int[] GLCapabilities2AttribList(GLCapabilities caps, int eglSurfaceType) {
+ public static int[] GLCapabilities2AttribList(GLCapabilities caps) {
int[] attrs = new int[32];
int idx=0;
- switch(eglSurfaceType) {
- case EGL.EGL_WINDOW_BIT:
- case EGL.EGL_PBUFFER_BIT:
- case EGL.EGL_PIXMAP_BIT:
- break;
- default:
- throw new GLException("Invalid EGL_SURFACE_TYPE 0x"+Integer.toHexString(eglSurfaceType));
- }
-
attrs[idx++] = EGL.EGL_SURFACE_TYPE;
- attrs[idx++] = eglSurfaceType;
+ attrs[idx++] = caps.isOnscreen() ? ( EGL.EGL_WINDOW_BIT ) : ( caps.isPBuffer() ? EGL.EGL_PBUFFER_BIT : EGL.EGL_PIXMAP_BIT ) ;
attrs[idx++] = EGL.EGL_RED_SIZE;
attrs[idx++] = caps.getRedBits();
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 861a89a75..4c6ff314d 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
@@ -72,12 +72,12 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
return chooseGraphicsConfigurationStatic((GLCapabilities) capabilities,
(GLCapabilitiesChooser) chooser,
- absScreen, EGL.EGL_WINDOW_BIT);
+ absScreen);
}
public static EGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilities capabilities,
GLCapabilitiesChooser chooser,
- AbstractGraphicsScreen absScreen, int eglSurfaceType) {
+ AbstractGraphicsScreen absScreen) {
if (capabilities == null) {
capabilities = new GLCapabilities(null);
}
@@ -103,12 +103,12 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
caps2.setDoubleBuffered(false);
}
- EGLGraphicsConfiguration res = eglChooseConfig(eglDisplay, caps2, capabilities, chooser, absScreen, eglSurfaceType);
+ EGLGraphicsConfiguration res = eglChooseConfig(eglDisplay, caps2, capabilities, chooser, absScreen);
if(null!=res) {
return res;
}
if(DEBUG) {
- System.err.println("eglChooseConfig failed with given capabilities surfaceType 0x"+Integer.toHexString(eglSurfaceType)+", "+caps2);
+ System.err.println("eglChooseConfig failed with given capabilities "+caps2);
}
if (chooser == null) {
@@ -124,8 +124,7 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
if (numConfigs[0] == 0) {
throw new GLException("Graphics configuration fetch (eglGetConfigs) - no EGLConfig found");
}
- GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0],
- caps2.isOnscreen(), caps2.isPBuffer());
+ GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0]);
if(DEBUG) {
System.err.println("EGL Get Configs: "+numConfigs[0]+", Caps "+caps.length);
printCaps("eglGetConfigs", caps, System.err);
@@ -140,12 +139,12 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
if(DEBUG) {
System.err.println("Chosen "+caps[chosen]);
}
- res = eglChooseConfig(eglDisplay, caps[chosen], capabilities, chooser, absScreen, eglSurfaceType);
+ res = eglChooseConfig(eglDisplay, caps[chosen], capabilities, chooser, absScreen);
if(null!=res) {
return res;
}
if(DEBUG) {
- System.err.println("eglChooseConfig failed with eglGetConfig/choosen capabilities surfaceType 0x"+Integer.toHexString(eglSurfaceType));
+ System.err.println("eglChooseConfig failed with eglGetConfig/choosen capabilities "+caps[chosen]);
}
// Last try .. add a fixed embedded profile [ATI, Nokia, Intel, ..]
@@ -161,7 +160,7 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
if(DEBUG) {
System.err.println("trying fixed caps (1): "+fixedCaps);
}
- res = eglChooseConfig(eglDisplay, fixedCaps, capabilities, chooser, absScreen, eglSurfaceType);
+ res = eglChooseConfig(eglDisplay, fixedCaps, capabilities, chooser, absScreen);
if(null!=res) {
return res;
}
@@ -176,19 +175,24 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
if(DEBUG) {
System.err.println("trying fixed caps (2): "+fixedCaps);
}
- res = eglChooseConfig(eglDisplay, fixedCaps, capabilities, chooser, absScreen, eglSurfaceType);
+ res = eglChooseConfig(eglDisplay, fixedCaps, capabilities, chooser, absScreen);
if(null!=res) {
return res;
}
//
// rgb565 - d16, s4
+ fixedCaps = new GLCapabilities(glp);
+ fixedCaps.setRedBits(5);
+ fixedCaps.setGreenBits(6);
+ fixedCaps.setBlueBits(5);
+ fixedCaps.setDepthBits(16);
fixedCaps.setSampleBuffers(true);
fixedCaps.setNumSamples(4);
if(DEBUG) {
System.err.println("trying fixed caps (3): "+fixedCaps);
}
- res = eglChooseConfig(eglDisplay, fixedCaps, capabilities, chooser, absScreen, eglSurfaceType);
+ res = eglChooseConfig(eglDisplay, fixedCaps, capabilities, chooser, absScreen);
if(null!=res) {
return res;
}
@@ -197,21 +201,20 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
protected static EGLGraphicsConfiguration eglChooseConfig(long eglDisplay,
GLCapabilities capsChosen0, GLCapabilities capsRequested, GLCapabilitiesChooser chooser,
- AbstractGraphicsScreen absScreen, int eglSurfaceType) {
+ AbstractGraphicsScreen absScreen) {
GLProfile glp = capsChosen0.getGLProfile();
- int[] attrs = EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChosen0, eglSurfaceType);
+ int[] attrs = EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChosen0);
_EGLConfig[] configs = new _EGLConfig[1];
int[] numConfigs = new int[1];
if (!EGL.eglChooseConfig(eglDisplay,
attrs, 0,
configs, configs.length,
numConfigs, 0)) {
- throw new GLException("Graphics configuration selection (eglChooseConfig) failed for surfaceType 0x"+Integer.toHexString(eglSurfaceType)+", "+capsChosen0);
+ throw new GLException("Graphics configuration selection (eglChooseConfig) failed for "+capsChosen0);
}
if (numConfigs[0] > 0) {
if(DEBUG) {
- GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0],
- capsChosen0.isOnscreen(), capsChosen0.isPBuffer());
+ GLCapabilities[] caps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs[0]);
System.err.println("EGL Choose Configs: "+numConfigs[0]+", Caps "+caps.length);
printCaps("eglChooseConfig", caps, System.err);
}
@@ -224,11 +227,9 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
}
val[0]=0;
}
- GLCapabilities capsChosen1 = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[0],
- capsChosen0.isOnscreen(), capsChosen0.isPBuffer());
+ GLCapabilities capsChosen1 = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[0]);
if(DEBUG) {
System.err.println("eglChooseConfig found: eglDisplay 0x"+Long.toHexString(eglDisplay)+
- ", surfaceType 0x"+Integer.toHexString(eglSurfaceType)+
", eglConfig ID 0x"+Integer.toHexString(val[0])+
", "+capsChosen0+" -> "+capsChosen1);
}
@@ -237,19 +238,16 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
} else {
if(DEBUG) {
System.err.println("EGL Choose Configs: None using eglDisplay 0x"+Long.toHexString(eglDisplay)+
- ", surfaceType 0x"+Integer.toHexString(eglSurfaceType)+
", "+capsChosen0);
}
}
return null;
}
- protected static GLCapabilities[] eglConfigs2GLCaps(GLProfile glp, long eglDisplay, _EGLConfig[] configs, int num,
- boolean onscreen, boolean pbuffer)
- {
+ 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], onscreen, pbuffer);
+ caps[i] = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[i]);
}
return caps;
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java
index 498372e55..09dbbeee6 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java
@@ -82,6 +82,12 @@ public class EGLPbufferDrawable extends EGLDrawable {
}
protected static EGLGraphicsConfiguration createEGLGraphicsConfiguration(GLCapabilities caps, GLCapabilitiesChooser chooser) {
+ if(caps.isOnscreen()) {
+ throw new GLException("Error: Onscreen set: "+caps);
+ }
+ if(!caps.isPBuffer()) {
+ throw new GLException("Error: PBuffer not set: "+caps);
+ }
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()));
@@ -93,7 +99,7 @@ public class EGLPbufferDrawable extends EGLDrawable {
}
EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay);
DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, 0);
- EGLGraphicsConfiguration eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, s, EGL.EGL_PBUFFER_BIT);
+ EGLGraphicsConfiguration eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, s);
if (null == eglConfig) {
EGL.eglTerminate(eglDisplay);
throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);