aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-08-30 06:26:29 +0200
committerSven Gothel <[email protected]>2015-08-30 06:26:29 +0200
commit5acb70d3d301fe66e4d03037325a91528e4c2c1d (patch)
tree971c01c0a098b1ad12ea2ac6fecbf3b422ee486c /src
parent18e487fdfe6f27564d976aa3a568d0ddc272d8ba (diff)
Bug 1203: Add missing constraints in desktop *GLContext.create* methods: Bail out if GL ES is requested ; Fix test case
*GLContext.createImpl(..) shall throw an GLException: *GLContext.createContextARBImpl(..) shall return 0: - Desktop implementation: if GL ES is requested - EGL implementation: if GL Desktop is requested, but not available Otherwise GLContextImpl may mistake a desktop context for an ES one. +++ Fix unit test TestGLAutoDrawableFactoryGLProfileDeviceNEWT.test11ES2OnDesktop(): We have to query the factory by desired profile, since the desktop factory cannot produce an GL ES context.
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLContext.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java20
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLProfileDeviceNEWT.java34
5 files changed, 56 insertions, 21 deletions
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
index 1910fbe72..a9d025e01 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
@@ -170,7 +170,7 @@ public class EGLContext extends GLContextImpl {
final boolean hasFullOpenGLAPISupport = factory.hasOpenGLDesktopSupport();
final boolean useKHRCreateContext = factory.hasDefaultDeviceKHRCreateContext();
- final boolean ctDesktopGL = 0 == ( GLContext.CTX_PROFILE_ES & ctp );
+ final boolean ctDesktopGL = 0 == ( CTX_PROFILE_ES & ctp );
final boolean ctBwdCompat = 0 != ( CTX_PROFILE_COMPAT & ctp ) ;
final boolean ctFwdCompat = 0 != ( CTX_OPTION_FORWARD & ctp ) ;
final boolean ctDebug = 0 != ( CTX_OPTION_DEBUG & ctp ) ;
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index 6a042b615..3c76dc212 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -109,6 +109,9 @@ public class MacOSXCGLContext extends GLContextImpl
}
static boolean isGLProfileSupported(final int ctp, final int major, final int minor) {
+ if( 0 != ( CTX_PROFILE_ES & ctp ) ) {
+ return false;
+ }
final boolean ctBwdCompat = 0 != ( CTX_PROFILE_COMPAT & ctp ) ;
final boolean ctCore = 0 != ( CTX_PROFILE_CORE & ctp ) ;
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
index 3d397b893..4c9469f17 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
@@ -55,6 +55,7 @@ import com.jogamp.common.nio.Buffers;
import com.jogamp.gluegen.runtime.ProcAddressTable;
import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
import com.jogamp.opengl.GLExtensions;
+import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.GLRendererQuirks;
import jogamp.nativewindow.windows.GDI;
@@ -206,6 +207,16 @@ public class WindowsWGLContext extends GLContextImpl {
System.err.println(getThreadName()+" - WindowWGLContext.createContextARBImpl: "+getGLVersion(major, minor, ctp, "@creation") +
", handle "+toHexString(drawable.getHandle()) + ", share "+toHexString(share)+", direct "+direct);
}
+ final boolean ctDesktopGL = 0 == ( CTX_PROFILE_ES & ctp );
+ final boolean ctBwdCompat = 0 != ( CTX_PROFILE_COMPAT & ctp ) ;
+ final boolean ctFwdCompat = 0 != ( CTX_OPTION_FORWARD & ctp ) ;
+ final boolean ctDebug = 0 != ( CTX_OPTION_DEBUG & ctp ) ;
+ if( !ctDesktopGL ) {
+ if(DEBUG) {
+ System.err.println(getThreadName() + ": WindowWGLContext.createContextARBImpl: GL ES not avail "+getGLVersion(major, minor, ctp, "@creation"));
+ }
+ return 0; // n/a
+ }
if( null == getWGLExtProcAddressTable()) {
final GLDynamicLookupHelper dlh = getGLDynamicLookupHelper(major, ctp);
if( null == dlh ) {
@@ -223,10 +234,6 @@ public class WindowsWGLContext extends GLContextImpl {
", wglCreateContextAttribsARB: "+toHexString(wglExtProcAddressTable._addressof_wglCreateContextAttribsARB));
}
- final boolean ctBwdCompat = 0 != ( CTX_PROFILE_COMPAT & ctp ) ;
- final boolean ctFwdCompat = 0 != ( CTX_OPTION_FORWARD & ctp ) ;
- final boolean ctDebug = 0 != ( CTX_OPTION_DEBUG & ctp ) ;
-
long ctx=0;
final int idx_flags = 4;
@@ -309,6 +316,11 @@ public class WindowsWGLContext extends GLContextImpl {
"], bitmap "+glCaps.isBitmap()+" -> "+createContextARBAvailable+
"], shared "+sharedCreatedWithARB+"]");
}
+ final GLProfile glp = glCaps.getGLProfile();
+ if( glp.isGLES() ) {
+ throw new GLException(getThreadName()+": Unable to create OpenGL ES context on desktopDevice "+device+
+ ", config "+config+", "+glp+", shareWith "+toHexString(shareWithHandle));
+ }
boolean createContextARBTried = false;
// utilize the shared context's GLXExt in case it was using the ARB method and it already exists
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
index 79768d662..9af534f35 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
@@ -229,6 +229,16 @@ public class X11GLXContext extends GLContextImpl {
System.err.println(getThreadName()+": X11GLXContext.createContextARBImpl: "+getGLVersion(major, minor, ctp, "@creation") +
", handle "+toHexString(drawable.getHandle()) + ", share "+toHexString(share)+", direct "+direct);
}
+ final boolean ctDesktopGL = 0 == ( CTX_PROFILE_ES & ctp );
+ final boolean ctBwdCompat = 0 != ( CTX_PROFILE_COMPAT & ctp ) ;
+ final boolean ctFwdCompat = 0 != ( CTX_OPTION_FORWARD & ctp ) ;
+ final boolean ctDebug = 0 != ( CTX_OPTION_DEBUG & ctp ) ;
+ if( !ctDesktopGL ) {
+ if(DEBUG) {
+ System.err.println(getThreadName() + ": X11GLXContext.createContextARBImpl: GL ES not avail "+getGLVersion(major, minor, ctp, "@creation"));
+ }
+ return 0; // n/a
+ }
final GLDynamicLookupHelper dlh = getGLDynamicLookupHelper(major, ctp);
if( null == dlh ) {
if(DEBUG) {
@@ -244,10 +254,6 @@ public class X11GLXContext extends GLContextImpl {
", glXCreateContextAttribsARB: "+toHexString(glXExtProcAddressTable._addressof_glXCreateContextAttribsARB));
}
- final boolean ctBwdCompat = 0 != ( CTX_PROFILE_COMPAT & ctp ) ;
- final boolean ctFwdCompat = 0 != ( CTX_OPTION_FORWARD & ctp ) ;
- final boolean ctDebug = 0 != ( CTX_OPTION_DEBUG & ctp ) ;
-
final IntBuffer attribs = Buffers.newDirectIntBuffer(ctx_arb_attribs_rom);
attribs.put(ctx_arb_attribs_idx_major + 1, major);
attribs.put(ctx_arb_attribs_idx_minor + 1, minor);
@@ -334,6 +340,10 @@ public class X11GLXContext extends GLContextImpl {
"], fbCfg "+config.hasFBConfig()+" -> "+createContextARBAvailable+
"], shared "+sharedCreatedWithARB+"]");
}
+ if( glp.isGLES() ) {
+ throw new GLException(getThreadName()+": Unable to create OpenGL ES context on desktopDevice "+device+
+ ", config "+config+", "+glp+", shareWith "+toHexString(shareWithHandle));
+ }
if( !config.hasFBConfig() ) {
// not able to use FBConfig -> GLX 1.1
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLProfileDeviceNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLProfileDeviceNEWT.java
index fe3ba91e3..1e264d21a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLProfileDeviceNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLProfileDeviceNEWT.java
@@ -71,7 +71,8 @@ public class TestGLAutoDrawableFactoryGLProfileDeviceNEWT extends UITestCase {
}
}
- void doTest(final boolean isEGL, final GLDrawableFactory factory, final GLCapabilitiesImmutable reqGLCaps, final GLEventListener demo) throws InterruptedException {
+ void doTest(final boolean isEGL, final GLDrawableFactory factory, final AbstractGraphicsDevice device,
+ final GLCapabilitiesImmutable reqGLCaps, final GLEventListener demo) throws InterruptedException {
System.err.println("Factory: "+factory.getClass().getName());
System.err.println("Requested GL Caps: "+reqGLCaps);
@@ -79,7 +80,7 @@ public class TestGLAutoDrawableFactoryGLProfileDeviceNEWT extends UITestCase {
// Create native OpenGL resources .. XGL/WGL/CGL ..
// equivalent to GLAutoDrawable methods: setVisible(true)
//
- final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep);
+ final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(device, reqGLCaps, null, widthStep*szStep, heightStep*szStep);
Assert.assertNotNull(glad);
Assert.assertTrue(glad.isRealized());
@@ -145,7 +146,8 @@ public class TestGLAutoDrawableFactoryGLProfileDeviceNEWT extends UITestCase {
System.err.println("EGL Factory n/a");
return;
}
- final GLProfile glp = getProfile(factory.getDefaultDevice(), GLProfile.GLES2);
+ final AbstractGraphicsDevice prodDevice = factory.getDefaultDevice();
+ final GLProfile glp = getProfile(prodDevice, GLProfile.GLES2);
if(null != glp) {
Assert.assertTrue("Not a GLES2 profile but "+glp, glp.isGLES2());
Assert.assertTrue("Not a GL2ES2 profile but "+glp, glp.isGL2ES2());
@@ -157,7 +159,7 @@ public class TestGLAutoDrawableFactoryGLProfileDeviceNEWT extends UITestCase {
reqGLCaps.setOnscreen(false);
final GearsES2 demo = new GearsES2(1);
demo.setVerbose(false);
- doTest(true /* isEGL */, factory, reqGLCaps, demo);
+ doTest(true /* isEGL */, factory, prodDevice, reqGLCaps, demo);
}
@Test
@@ -167,7 +169,8 @@ public class TestGLAutoDrawableFactoryGLProfileDeviceNEWT extends UITestCase {
System.err.println("EGL Factory n/a");
return;
}
- final GLProfile glp = getProfile(factory.getDefaultDevice(), GLProfile.GL2GL3);
+ final AbstractGraphicsDevice prodDevice = factory.getDefaultDevice();
+ final GLProfile glp = getProfile(prodDevice, GLProfile.GL2GL3);
if(null != glp) {
Assert.assertTrue("Not a GL2GL3 profile but "+glp, glp.isGL2GL3());
}
@@ -181,17 +184,18 @@ public class TestGLAutoDrawableFactoryGLProfileDeviceNEWT extends UITestCase {
reqGLCaps.setOnscreen(false);
final GearsES2 demo = new GearsES2(1);
demo.setVerbose(false);
- doTest(true /* isEGL */, factory, reqGLCaps, demo);
+ doTest(true /* isEGL */, factory, prodDevice, reqGLCaps, demo);
}
@Test
public void test11ES2OnDesktop() throws InterruptedException {
- final GLDrawableFactory factory = GLDrawableFactory.getDesktopFactory();
- if( null == factory ) {
+ final GLDrawableFactory deskFactory = GLDrawableFactory.getDesktopFactory();
+ if( null == deskFactory ) {
System.err.println("Desktop Factory n/a");
return;
}
- final GLProfile glp = getProfile(factory.getDefaultDevice(), GLProfile.GLES2);
+ final AbstractGraphicsDevice prodDevice = deskFactory.getDefaultDevice();
+ final GLProfile glp = getProfile(prodDevice, GLProfile.GLES2);
if(null != glp) {
Assert.assertTrue("Not a GLES2 profile but "+glp, glp.isGLES2());
Assert.assertTrue("Not a GL2ES2 profile but "+glp, glp.isGL2ES2());
@@ -199,11 +203,16 @@ public class TestGLAutoDrawableFactoryGLProfileDeviceNEWT extends UITestCase {
if(null == glp) {
return;
}
+ final GLDrawableFactory prodFactory = GLDrawableFactory.getFactory(glp);
+ if( null == prodFactory ) {
+ System.err.println("Production Factory n/a");
+ return;
+ }
final GLCapabilities reqGLCaps = new GLCapabilities(glp);
reqGLCaps.setOnscreen(false);
final GearsES2 demo = new GearsES2(1);
demo.setVerbose(false);
- doTest(false /* isEGL */, factory, reqGLCaps, demo);
+ doTest(true /* isEGL */, prodFactory, prodDevice, reqGLCaps, demo);
}
@Test
@@ -213,7 +222,8 @@ public class TestGLAutoDrawableFactoryGLProfileDeviceNEWT extends UITestCase {
System.err.println("Desktop Factory n/a");
return;
}
- final GLProfile glp = getProfile(factory.getDefaultDevice(), GLProfile.GL2GL3);
+ final AbstractGraphicsDevice prodDevice = factory.getDefaultDevice();
+ final GLProfile glp = getProfile(prodDevice, GLProfile.GL2GL3);
if(null != glp) {
Assert.assertTrue("Not a GL2GL3 profile but "+glp, glp.isGL2GL3());
}
@@ -227,7 +237,7 @@ public class TestGLAutoDrawableFactoryGLProfileDeviceNEWT extends UITestCase {
reqGLCaps.setOnscreen(false);
final GearsES2 demo = new GearsES2(1);
demo.setVerbose(false);
- doTest(false /* isEGL */, factory, reqGLCaps, demo);
+ doTest(false /* isEGL */, factory, prodDevice, reqGLCaps, demo);
}
public static void main(final String args[]) throws IOException {