Search in sources :

Example 1 with PointerBuffer

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;
}
Also used : PointerBuffer(org.lwjgl.PointerBuffer)

Example 2 with PointerBuffer

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;
}
Also used : PointerBuffer(org.lwjgl.PointerBuffer)

Example 3 with PointerBuffer

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;
}
Also used : PointerBuffer(org.lwjgl.PointerBuffer)

Example 4 with PointerBuffer

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;
}
Also used : PointerBuffer(org.lwjgl.PointerBuffer)

Example 5 with PointerBuffer

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);
}
Also used : PointerBuffer(org.lwjgl.PointerBuffer)

Aggregations

PointerBuffer (org.lwjgl.PointerBuffer)20 IntBuffer (java.nio.IntBuffer)3 ByteBuffer (java.nio.ByteBuffer)2 Monitor (com.badlogic.gdx.Graphics.Monitor)1 Lwjgl3Monitor (com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics.Lwjgl3Monitor)1 LWJGLException (org.lwjgl.LWJGLException)1 CLBufferRegion (org.lwjgl.opencl.api.CLBufferRegion)1