use of org.lwjgl.PointerBuffer in project jmonkeyengine by jMonkeyEngine.
the class LwjglContext method createContext.
private long createContext(final long platform, final List<Long> devices, long window) throws Exception {
final int propertyCount = 2 + 4 + 1;
final PointerBuffer properties = PointerBuffer.allocateDirect(propertyCount + devices.size());
//TODO: test on Linus and MacOSX
switch(Platform.get()) {
case WINDOWS:
properties.put(KHRGLSharing.CL_GL_CONTEXT_KHR).put(org.lwjgl.glfw.GLFWNativeWGL.glfwGetWGLContext(window)).put(KHRGLSharing.CL_WGL_HDC_KHR).put(org.lwjgl.opengl.WGL.wglGetCurrentDC());
break;
case LINUX:
properties.put(KHRGLSharing.CL_GL_CONTEXT_KHR).put(org.lwjgl.glfw.GLFWNativeGLX.glfwGetGLXContext(window)).put(KHRGLSharing.CL_GLX_DISPLAY_KHR).put(org.lwjgl.glfw.GLFWNativeX11.glfwGetX11Display());
break;
case MACOSX:
properties.put(APPLEGLSharing.CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE).put(org.lwjgl.opengl.CGL.CGLGetShareGroup(org.lwjgl.opengl.CGL.CGLGetCurrentContext()));
}
properties.put(CL_CONTEXT_PLATFORM).put(platform);
properties.put(0);
properties.flip();
Utils.errorBuffer.rewind();
PointerBuffer deviceBuffer = PointerBuffer.allocateDirect(devices.size());
for (long d : devices) {
deviceBuffer.put(d);
}
deviceBuffer.flip();
long context = CL10.clCreateContext(properties, deviceBuffer, null, 0, Utils.errorBuffer);
Utils.checkError(Utils.errorBuffer, "clCreateContext");
return context;
}
use of org.lwjgl.PointerBuffer in project jmonkeyengine by jMonkeyEngine.
the class LwjglDevice method getMaximumWorkItemSizes.
@Override
public long[] getMaximumWorkItemSizes() {
int dim = (int) getMaximumWorkItemDimensions();
PointerBuffer sizes = PointerBuffer.allocateDirect(dim);
Info.clGetDeviceInfoPointers(device, CL10.CL_DEVICE_MAX_WORK_ITEM_SIZES, sizes);
long[] sx = new long[dim];
sizes.get(sx);
return sx;
}
use of org.lwjgl.PointerBuffer in project lwjgl by LWJGL.
the class InfoUtilAbstract method getInfoSizeArray.
public long[] getInfoSizeArray(final T object, final int param_name) {
object.checkValid();
final int size = getInfoSizeArraySize(object, param_name);
final PointerBuffer buffer = APIUtil.getBufferPointer(size);
getInfo(object, param_name, buffer.getBuffer(), null);
final long[] array = new long[size];
for (int i = 0; i < size; i++) array[i] = buffer.get(i);
return array;
}
use of org.lwjgl.PointerBuffer in project lwjgl by LWJGL.
the class InfoUtilAbstract method getSizesBuffer.
protected PointerBuffer getSizesBuffer(final T object, final int param_name) {
final int size = getInfoSizeArraySize(object, param_name);
final PointerBuffer buffer = APIUtil.getBufferPointer(size);
buffer.limit(size);
getInfo(object, param_name, buffer.getBuffer(), null);
return buffer;
}
use of org.lwjgl.PointerBuffer in project lwjgl by LWJGL.
the class InfoUtilAbstract method getSizeRet.
protected final int getSizeRet(final T object, final int param_name) {
final PointerBuffer bytes = APIUtil.getBufferPointer();
final int errcode = getInfo(object, param_name, null, bytes);
if (errcode != CL_SUCCESS)
throw new IllegalArgumentException("Invalid parameter specified: " + LWJGLUtil.toHexString(param_name));
return (int) bytes.get(0);
}
Aggregations