diff options
author | Michael Bien <[email protected]> | 2010-03-16 22:55:32 +0100 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-03-16 22:55:32 +0100 |
commit | 36a289538cdb9373d8eb7700e616f019231ab591 (patch) | |
tree | 6310f16df3195b3d7553dde34ef52bca84270461 /src/com/mbien/opencl/gl | |
parent | 919d8e9f992c07ab18ddd6d192d6747e8d7aa40b (diff) |
get(GL)Context() and getCL() getters.
fix in isGLMemorySharingSupported() on mac.
javadoc fixes.
Diffstat (limited to 'src/com/mbien/opencl/gl')
-rw-r--r-- | src/com/mbien/opencl/gl/CLGLBuffer.java | 10 | ||||
-rw-r--r-- | src/com/mbien/opencl/gl/CLGLContext.java | 27 | ||||
-rw-r--r-- | src/com/mbien/opencl/gl/CLGLImage2d.java | 10 | ||||
-rw-r--r-- | src/com/mbien/opencl/gl/CLGLObject.java | 11 | ||||
-rw-r--r-- | src/com/mbien/opencl/gl/CLGLTexture.java | 2 | ||||
-rw-r--r-- | src/com/mbien/opencl/gl/CLGLTexture2d.java | 1 | ||||
-rw-r--r-- | src/com/mbien/opencl/gl/CLGLTexture3d.java | 14 |
7 files changed, 71 insertions, 4 deletions
diff --git a/src/com/mbien/opencl/gl/CLGLBuffer.java b/src/com/mbien/opencl/gl/CLGLBuffer.java index 1856e2ff..97a25626 100644 --- a/src/com/mbien/opencl/gl/CLGLBuffer.java +++ b/src/com/mbien/opencl/gl/CLGLBuffer.java @@ -5,6 +5,7 @@ import com.mbien.opencl.CLBuffer; import com.mbien.opencl.CLContext; import com.mbien.opencl.CLMemory.GLObjectType; import java.nio.Buffer; +import javax.media.opengl.GLContext; /** @@ -55,6 +56,15 @@ public final class CLGLBuffer<B extends Buffer> extends CLBuffer<B> implements C } @Override + public CLGLContext getContext() { + return (CLGLContext) super.getContext(); + } + + public GLContext getGLContext() { + return getContext().getGLContext(); + } + + @Override public <T extends Buffer> CLGLBuffer<T> cloneWith(T directBuffer) { return new CLGLBuffer<T>(context, directBuffer, ID, GLID, FLAGS); } diff --git a/src/com/mbien/opencl/gl/CLGLContext.java b/src/com/mbien/opencl/gl/CLGLContext.java index 3c6711f5..ec0f909f 100644 --- a/src/com/mbien/opencl/gl/CLGLContext.java +++ b/src/com/mbien/opencl/gl/CLGLContext.java @@ -22,10 +22,12 @@ import static com.mbien.opencl.gl.CLGLI.*; public final class CLGLContext extends CLContext { final long glID; + private final GLContext glContext; - private CLGLContext(CLPlatform platform, long clContextID, long glContextID) { + private CLGLContext(CLPlatform platform, GLContext glContext, long clContextID, long glContextID) { super(platform, clContextID); this.glID = glContextID; + this.glContext = glContext; } /** @@ -72,7 +74,7 @@ public final class CLGLContext extends CLContext { PointerBuffer properties = setupContextProperties(platform, glContext, glID); long clID = createContextFromType(properties, toDeviceBitmap(deviceTypes)); - return new CLGLContext(platform, clID, glID[0]); + return new CLGLContext(platform, glContext, clID, glID[0]); } @@ -90,7 +92,7 @@ public final class CLGLContext extends CLContext { PointerBuffer properties = setupContextProperties(platform, glContext, glID); long clID = createContext(properties, devices); - CLGLContext context = new CLGLContext(platform, clID, glID[0]); + CLGLContext context = new CLGLContext(platform, glContext, clID, glID[0]); if(devices != null) { for (int i = 0; i < devices.length; i++) { context.overrideContext(devices[i]); @@ -225,5 +227,24 @@ public final class CLGLContext extends CLContext { return buffer; } + /** + * Return the low level OpenCL interface with OpenGL interoperability. + */ + @Override + public CLGLI getCL() { + return (CLGLI)super.getCL(); + } + + /** + * Returns the OpenGL context this context was shared with. + */ + public GLContext getGLContext() { + return glContext; + } + + @Override + public CLGLContext getContext() { + return this; + } } diff --git a/src/com/mbien/opencl/gl/CLGLImage2d.java b/src/com/mbien/opencl/gl/CLGLImage2d.java index 0561e757..853c057e 100644 --- a/src/com/mbien/opencl/gl/CLGLImage2d.java +++ b/src/com/mbien/opencl/gl/CLGLImage2d.java @@ -7,6 +7,7 @@ import com.mbien.opencl.CLImageFormat; import com.mbien.opencl.CLMemory.GLObjectType; import com.mbien.opencl.impl.CLImageFormatImpl; import java.nio.Buffer; +import javax.media.opengl.GLContext; import static com.mbien.opencl.CL.*; @@ -61,4 +62,13 @@ public class CLGLImage2d<B extends Buffer> extends CLImage2d<B> implements CLGLO return GLID; } + @Override + public CLGLContext getContext() { + return (CLGLContext) super.getContext(); + } + + public GLContext getGLContext() { + return getContext().getGLContext(); + } + } diff --git a/src/com/mbien/opencl/gl/CLGLObject.java b/src/com/mbien/opencl/gl/CLGLObject.java index 51a730ed..84c3ecef 100644 --- a/src/com/mbien/opencl/gl/CLGLObject.java +++ b/src/com/mbien/opencl/gl/CLGLObject.java @@ -4,6 +4,7 @@ package com.mbien.opencl.gl; import com.mbien.opencl.CLMemory.GLObjectType; +import javax.media.opengl.GLContext; /** * @@ -20,5 +21,15 @@ interface CLGLObject { * Returns the OpenGL buffer type of this shared object. */ public GLObjectType getGLObjectType(); + + /** + * Returns the OpenCL context of this shared object. + */ + public CLGLContext getContext(); + + /** + * Returns the OpenGL context of this shared object. + */ + public GLContext getGLContext(); } diff --git a/src/com/mbien/opencl/gl/CLGLTexture.java b/src/com/mbien/opencl/gl/CLGLTexture.java index 49fe4cb2..246f7d06 100644 --- a/src/com/mbien/opencl/gl/CLGLTexture.java +++ b/src/com/mbien/opencl/gl/CLGLTexture.java @@ -8,7 +8,7 @@ package com.mbien.opencl.gl; * * @author Michael Bien */ -interface CLGLTexture { +interface CLGLTexture extends CLGLObject { /** * Returns the OpenGL texture target of this texture. diff --git a/src/com/mbien/opencl/gl/CLGLTexture2d.java b/src/com/mbien/opencl/gl/CLGLTexture2d.java index eec6127c..37c9a28a 100644 --- a/src/com/mbien/opencl/gl/CLGLTexture2d.java +++ b/src/com/mbien/opencl/gl/CLGLTexture2d.java @@ -6,6 +6,7 @@ import com.mbien.opencl.CLImageFormat; import com.mbien.opencl.CLMemory.GLObjectType; import com.mbien.opencl.impl.CLImageFormatImpl; import java.nio.Buffer; +import javax.media.opengl.GLContext; import static com.mbien.opencl.CL.*; diff --git a/src/com/mbien/opencl/gl/CLGLTexture3d.java b/src/com/mbien/opencl/gl/CLGLTexture3d.java index e1fef3a9..0a25c890 100644 --- a/src/com/mbien/opencl/gl/CLGLTexture3d.java +++ b/src/com/mbien/opencl/gl/CLGLTexture3d.java @@ -7,6 +7,7 @@ import com.mbien.opencl.CLImageFormat; import com.mbien.opencl.CLMemory.GLObjectType; import com.mbien.opencl.impl.CLImageFormatImpl; import java.nio.Buffer; +import javax.media.opengl.GLContext; import static com.mbien.opencl.CL.*; @@ -70,4 +71,17 @@ public class CLGLTexture3d<B extends Buffer> extends CLImage3d<B> implements CLG return GLObjectType.GL_OBJECT_TEXTURE3D; } + /** + * Returns the shared CLGLContext. + */ + @Override + public CLGLContext getContext() { + return (CLGLContext) super.getContext(); + } + + @Override + public GLContext getGLContext() { + return getContext().getGLContext(); + } + } |