aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/jogamp/opencl/gl/CLGLContext.java5
-rw-r--r--test/com/jogamp/opencl/gl/CLGLTest.java22
2 files changed, 13 insertions, 14 deletions
diff --git a/src/com/jogamp/opencl/gl/CLGLContext.java b/src/com/jogamp/opencl/gl/CLGLContext.java
index ac1e5da7..1c6069b9 100644
--- a/src/com/jogamp/opencl/gl/CLGLContext.java
+++ b/src/com/jogamp/opencl/gl/CLGLContext.java
@@ -120,7 +120,10 @@ public final class CLGLContext extends CLContext {
}
// context must be current
- glContext.makeCurrent();
+ if(!glContext.isCurrent()) {
+ throw new IllegalArgumentException("OpenGL context is not current,\n"+
+ " creating a OpenCL context for context sharing is not allowed in this situation.");
+ }
GLContextImpl ctxImpl = (GLContextImpl)glContext;
glID[0] = glContext.getHandle();
diff --git a/test/com/jogamp/opencl/gl/CLGLTest.java b/test/com/jogamp/opencl/gl/CLGLTest.java
index a647c19f..27c2425c 100644
--- a/test/com/jogamp/opencl/gl/CLGLTest.java
+++ b/test/com/jogamp/opencl/gl/CLGLTest.java
@@ -68,16 +68,6 @@ public class CLGLTest {
out.println(glcontext);
}
-// @AfterClass
- public static void release() {
- if(glcontext != null) {
- glcontext.destroy();
- glcontext = null;
- }
- glWindow.destroy();
-// window.destroy();
- }
-
@Test
public void createContextTest() {
@@ -101,11 +91,14 @@ public class CLGLTest {
out.println("isGLMemorySharingSupported==true on: \n "+device);
}
- assertNotNull(glcontext);
out.println(device.getPlatform());
+
+ assertNotNull(glcontext);
+ glcontext.makeCurrent();
+ assertTrue(glcontext.isCurrent());
+
CLContext context = CLGLContext.create(glcontext, device);
assertNotNull(context);
- assertTrue(glcontext.isCurrent());
try{
out.println(context);
@@ -115,10 +108,13 @@ public class CLGLTest {
out.println(currentDevice);
*/
}finally{
+ // destroy cl context, gl context still current
context.release();
+
+ glcontext.release();
+ glWindow.destroy();
}
- release();
}