aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/opencl/gl/CLGLContext.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-05-18 03:51:10 +0200
committerSven Gothel <[email protected]>2011-05-18 03:51:10 +0200
commit773060662ef81707f70c447b71e664635ac45e2a (patch)
treef52c9e24b80902b08422005192df5b525f85489b /src/com/jogamp/opencl/gl/CLGLContext.java
parenteceed6e10c7d6cb19e8ad3c1bf5ea20450d6fae1 (diff)
parentf12e3a9d7ac644abc98a51dc51786cf7c5b67851 (diff)
resolve conflicts
Diffstat (limited to 'src/com/jogamp/opencl/gl/CLGLContext.java')
-rw-r--r--src/com/jogamp/opencl/gl/CLGLContext.java66
1 files changed, 47 insertions, 19 deletions
diff --git a/src/com/jogamp/opencl/gl/CLGLContext.java b/src/com/jogamp/opencl/gl/CLGLContext.java
index c220fcfc..ee6c2108 100644
--- a/src/com/jogamp/opencl/gl/CLGLContext.java
+++ b/src/com/jogamp/opencl/gl/CLGLContext.java
@@ -33,10 +33,11 @@ import com.jogamp.opencl.CLDevice;
import java.nio.Buffer;
import com.jogamp.opencl.CLMemory.Mem;
import com.jogamp.opencl.CLPlatform;
-import com.jogamp.common.nio.PointerBuffer;
+import com.jogamp.common.nio.NativeSizeBuffer;
import jogamp.opengl.GLContextImpl;
import jogamp.opengl.egl.EGLContext;
import jogamp.opengl.macosx.cgl.MacOSXCGLContext;
+import jogamp.opengl.macosx.cgl.CGL;
import jogamp.opengl.windows.wgl.WindowsWGLContext;
import jogamp.opengl.x11.glx.X11GLXContext;
import javax.media.opengl.GLContext;
@@ -95,7 +96,7 @@ public final class CLGLContext extends CLContext {
}
long[] glID = new long[1];
- PointerBuffer properties = setupContextProperties(platform, glContext, glID);
+ NativeSizeBuffer properties = setupContextProperties(platform, glContext, glID);
ErrorDispatcher dispatcher = createErrorHandler();
long clID = createContextFromType(dispatcher, properties, toDeviceBitmap(deviceTypes));
@@ -119,7 +120,7 @@ public final class CLGLContext extends CLContext {
CLPlatform platform = devices[0].getPlatform();
long[] glID = new long[1];
- PointerBuffer properties = setupContextProperties(platform, glContext, glID);
+ NativeSizeBuffer properties = setupContextProperties(platform, glContext, glID);
ErrorDispatcher dispatcher = createErrorHandler();
long clID = createContext(dispatcher, properties, devices);
@@ -133,7 +134,7 @@ public final class CLGLContext extends CLContext {
}
- private static PointerBuffer setupContextProperties(CLPlatform platform, GLContext glContext, long[] glID) {
+ private static NativeSizeBuffer setupContextProperties(CLPlatform platform, GLContext glContext, long[] glID) {
if(platform == null) {
throw new RuntimeException("no OpenCL installation found");
@@ -151,14 +152,14 @@ public final class CLGLContext extends CLContext {
GLContextImpl ctxImpl = (GLContextImpl)glContext;
glID[0] = glContext.getHandle();
- PointerBuffer properties;
+ NativeSizeBuffer properties;
if(glContext instanceof X11GLXContext) {
// spec: "When the GLX binding API is supported, the attribute
// CL_GL_CONTEXT_KHR should be set to a GLXContext handle to an
// OpenGL context, and the attribute CL_GLX_DISPLAY_KHR should be
// set to the Display handle of the X Window System display used to
// create the OpenGL context."
- properties = PointerBuffer.allocateDirect(7);
+ properties = NativeSizeBuffer.allocateDirect(7);
long displayHandle = ctxImpl.getDrawableImpl().getNativeSurface().getDisplayHandle();
properties.put(CL_GL_CONTEXT_KHR).put(glID[0])
.put(CL_GLX_DISPLAY_KHR).put(displayHandle)
@@ -168,18 +169,19 @@ public final class CLGLContext extends CLContext {
// CL_GL_CONTEXT_KHR should be set to an HGLRC handle to an OpenGL
// context, and the attribute CL_WGL_HDC_KHR should be set to the
// HDC handle of the display used to create the OpenGL context."
- properties = PointerBuffer.allocateDirect(7);
+ properties = NativeSizeBuffer.allocateDirect(7);
long surfaceHandle = ctxImpl.getDrawableImpl().getNativeSurface().getSurfaceHandle();
properties.put(CL_GL_CONTEXT_KHR).put(glID[0])
.put(CL_WGL_HDC_KHR).put(surfaceHandle)
.put(CL_CONTEXT_PLATFORM).put(platform.ID);
}else if(glContext instanceof MacOSXCGLContext) {
-// TODO test on mac
// spec: "When the CGL binding API is supported, the attribute
// CL_CGL_SHAREGROUP_KHR should be set to a CGLShareGroup handle to
// a CGL share group object."
- properties = PointerBuffer.allocateDirect(5);
- properties.put(CL_CGL_SHAREGROUP_KHR).put(glID[0])
+ long cgl = CGL.getCGLContext(glID[0]);
+ long group = CGL.CGLGetShareGroup(cgl);
+ properties = NativeSizeBuffer.allocateDirect(5);
+ properties.put(CL_CGL_SHAREGROUP_KHR).put(group)
.put(CL_CONTEXT_PLATFORM).put(platform.ID);
}else if(glContext instanceof EGLContext) {
// TODO test EGL
@@ -188,7 +190,7 @@ public final class CLGLContext extends CLContext {
// OpenGL ES or OpenGL context, and the attribute
// CL_EGL_DISPLAY_KHR should be set to the EGLDisplay handle of the
// display used to create the OpenGL ES or OpenGL context."
- properties = PointerBuffer.allocateDirect(7);
+ properties = NativeSizeBuffer.allocateDirect(7);
long displayHandle = ctxImpl.getDrawableImpl().getNativeSurface().getDisplayHandle();
properties.put(CL_GL_CONTEXT_KHR).put(glID[0])
.put(CL_EGL_DISPLAY_KHR).put(displayHandle)
@@ -201,20 +203,46 @@ public final class CLGLContext extends CLContext {
}
// Buffers
- public final CLGLBuffer<?> createFromGLBuffer(int glBuffer, Mem... flags) {
- return createFromGLBuffer(null, glBuffer, Mem.flagsToInt(flags));
+ /**
+ * Creates a CLGLBuffer for memory sharing with the specified OpenGL buffer.
+ * @param glBuffer The OpenGL buffer handle like a vertex buffer or pixel buffer object.
+ * @param glBufferSize The size of the OpenGL buffer in bytes
+ * @param flags optional flags.
+ */
+ public final CLGLBuffer<?> createFromGLBuffer(int glBuffer, long glBufferSize, Mem... flags) {
+ return createFromGLBuffer(null, glBuffer, glBufferSize, Mem.flagsToInt(flags));
}
- public final CLGLBuffer<?> createFromGLBuffer(int glBuffer, int flags) {
- return createFromGLBuffer(null, glBuffer, flags);
+ /**
+ * Creates a CLGLBuffer for memory sharing with the specified OpenGL buffer.
+ * @param glBuffer The OpenGL buffer handle like a vertex buffer or pixel buffer object.
+ * @param glBufferSize The size of the OpenGL buffer in bytes
+ * @param flags optional flags.
+ */
+ public final CLGLBuffer<?> createFromGLBuffer(int glBuffer, long glBufferSize, int flags) {
+ return createFromGLBuffer(null, glBuffer, glBufferSize, flags);
}
- public final <B extends Buffer> CLGLBuffer<B> createFromGLBuffer(B directBuffer, int glBuffer, Mem... flags) {
- return createFromGLBuffer(directBuffer, glBuffer, Mem.flagsToInt(flags));
+ /**
+ * Creates a CLGLBuffer for memory sharing with the specified OpenGL buffer.
+ * @param directBuffer A direct allocated NIO buffer for data transfers between java and OpenCL.
+ * @param glBuffer The OpenGL buffer handle like a vertex buffer or pixel buffer object.
+ * @param glBufferSize The size of the OpenGL buffer in bytes
+ * @param flags optional flags.
+ */
+ public final <B extends Buffer> CLGLBuffer<B> createFromGLBuffer(B directBuffer, int glBuffer, long glBufferSize, Mem... flags) {
+ return createFromGLBuffer(directBuffer, glBuffer, glBufferSize, Mem.flagsToInt(flags));
}
- public final <B extends Buffer> CLGLBuffer<B> createFromGLBuffer(B directBuffer, int glBuffer, int flags) {
- CLGLBuffer<B> buffer = CLGLBuffer.create(this, directBuffer, flags, glBuffer);
+ /**
+ * Creates a CLGLBuffer for memory sharing with the specified OpenGL buffer.
+ * @param directBuffer A direct allocated NIO buffer for data transfers between java and OpenCL.
+ * @param glBuffer The OpenGL buffer handle like a vertex buffer or pixel buffer object.
+ * @param glBufferSize The size of the OpenGL buffer in bytes
+ * @param flags optional flags.
+ */
+ public final <B extends Buffer> CLGLBuffer<B> createFromGLBuffer(B directBuffer, int glBuffer, long glBufferSize, int flags) {
+ CLGLBuffer<B> buffer = CLGLBuffer.create(this, directBuffer, glBufferSize, flags, glBuffer);
memoryObjects.add(buffer);
return buffer;
}