summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLMemory.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-02-27 00:44:33 +0100
committerMichael Bien <[email protected]>2010-02-27 00:44:33 +0100
commit34bb39283a30919212b682c34bb54d8cd3626cbd (patch)
tree5f70f3473cdfffa8562a558cebcec6aa30af8fc7 /src/com/mbien/opencl/CLMemory.java
parent75d392f3fff6d47fdccae9a8915fea61cdbef990 (diff)
refactored CLGLBuffer into seperate OpenGL buffer and image types.
Diffstat (limited to 'src/com/mbien/opencl/CLMemory.java')
-rw-r--r--src/com/mbien/opencl/CLMemory.java51
1 files changed, 48 insertions, 3 deletions
diff --git a/src/com/mbien/opencl/CLMemory.java b/src/com/mbien/opencl/CLMemory.java
index aa65e806..0be1b530 100644
--- a/src/com/mbien/opencl/CLMemory.java
+++ b/src/com/mbien/opencl/CLMemory.java
@@ -10,10 +10,10 @@ import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import static com.mbien.opencl.CLException.*;
-import static com.mbien.opencl.CL.*;
+import static com.mbien.opencl.CLGLI.*;
/**
- *
+ * Common superclass for all OpenCL memory types.
* @author Michael Bien
*/
public abstract class CLMemory <B extends Buffer> extends CLObject implements CLResource {
@@ -101,6 +101,27 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL
checkForError(ret, "can not release mem object");
}
+ // kept only for debugging purposes
+ /**
+ * Returns the OpenGL buffer type of this shared buffer.
+ */
+ /*public*/ GLObjectType getGLObjectType() {
+ int[] array = new int[1];
+ int ret = ((CLGLI)cl).clGetGLObjectInfo(ID, array, 0, null, 0);
+ CLException.checkForError(ret, "error while asking for gl object info");
+ return GLObjectType.valueOf(array[0]);
+ }
+
+ /**
+ * Returns the OpenGL object id of this shared buffer.
+ */
+ /*public*/ int getGLObjectID() {
+ int[] array = new int[1];
+ int ret = ((CLGLI)cl).clGetGLObjectInfo(ID, null, 0, array, 0);
+ CLException.checkForError(ret, "error while asking for gl object info");
+ return array[0];
+ }
+
@Override
public boolean equals(Object obj) {
if (obj == null) {
@@ -276,6 +297,30 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL
}
-
+ public enum GLObjectType {
+
+ GL_OBJECT_BUFFER(CL_GL_OBJECT_BUFFER),
+ GL_OBJECT_TEXTURE2D(CL_GL_OBJECT_TEXTURE2D),
+ GL_OBJECT_TEXTURE3D(CL_GL_OBJECT_TEXTURE3D),
+ GL_OBJECT_RENDERBUFFER(CL_GL_OBJECT_RENDERBUFFER);
+
+ public final int TYPE;
+
+ private GLObjectType(int type) {
+ this.TYPE = type;
+ }
+
+ public static GLObjectType valueOf(int type) {
+ if(type == CL_GL_OBJECT_BUFFER)
+ return GL_OBJECT_BUFFER;
+ else if(type == CL_GL_OBJECT_TEXTURE2D)
+ return GL_OBJECT_TEXTURE2D;
+ else if(type == CL_GL_OBJECT_TEXTURE3D)
+ return GL_OBJECT_TEXTURE3D;
+ else if(type == CL_GL_OBJECT_RENDERBUFFER)
+ return GL_OBJECT_RENDERBUFFER;
+ return null;
+ }
+ }
}