Search in sources :

Example 16 with PointerBuffer

use of org.lwjgl.PointerBuffer in project jmonkeyengine by jMonkeyEngine.

the class LwjglProgram method createAllKernels.

@Override
public Kernel[] createAllKernels() {
    Utils.tempBuffers[0].b16i.rewind();
    int ret = CL10.clCreateKernelsInProgram(program, null, Utils.tempBuffers[0].b16i);
    Utils.checkError(ret, "clCreateKernelsInProgram");
    int count = Utils.tempBuffers[0].b16i.get(0);
    PointerBuffer buf = PointerBuffer.allocateDirect(count);
    ret = CL10.clCreateKernelsInProgram(program, buf, (IntBuffer) null);
    Utils.checkError(ret, "clCreateKernelsInProgram");
    Kernel[] kx = new Kernel[count];
    for (int i = 0; i < count; ++i) {
        kx[i] = new LwjglKernel(buf.get());
    }
    return kx;
}
Also used : IntBuffer(java.nio.IntBuffer) PointerBuffer(org.lwjgl.PointerBuffer)

Example 17 with PointerBuffer

use of org.lwjgl.PointerBuffer in project jmonkeyengine by jMonkeyEngine.

the class LwjglContext method getPlatforms.

/**
     * Returns a list of the available platforms, filtered by the specified
     * filter.
     *
     * Copied from the old release
     *
     * @return the available platforms
     */
private static long[] getPlatforms() {
    int[] count = new int[1];
    int errcode = CL10.clGetPlatformIDs(null, count);
    Utils.checkError(errcode, "clGetDeviceIDs");
    int num_platforms = count[0];
    if (num_platforms == 0) {
        return new long[0];
    }
    PointerBuffer platforms = PointerBuffer.allocateDirect(num_platforms);
    errcode = CL10.clGetPlatformIDs(platforms, (IntBuffer) null);
    Utils.checkError(errcode, "clGetDeviceIDs");
    platforms.rewind();
    long[] platformIDs = new long[num_platforms];
    for (int i = 0; i < num_platforms; i++) {
        platformIDs[i] = platforms.get();
    }
    return platformIDs;
}
Also used : IntBuffer(java.nio.IntBuffer) PointerBuffer(org.lwjgl.PointerBuffer)

Example 18 with PointerBuffer

use of org.lwjgl.PointerBuffer in project lwjgl by LWJGL.

the class EGL method eglGetConfigs.

/**
	 * Returns the available EGLConfigs on the speficied display. The number of available EGLConfigs
	 * is returned in the num_config parameter. The configs array may be null. If it is null, a new
	 * array will be allocated, with size equal to the result of {@link #eglGetConfigsNum(EGLDisplay)}  eglGetConfigsNum}.
	 * If it is not null, no more than {@code configs.length} EGLConfigs will be returned. If the array is bigger
	 * than the number of available EGLConfigs, the remaining array elements will not be affected.
	 *
	 * @param dpy        the EGLDisplay
	 * @param configs    the EGLConfigs array
	 * @param num_config the number of available EGLConfigs returned
	 *
	 * @return the available EGLConfigs
	 *
	 * @throws org.lwjgl.LWJGLException if an EGL error occurs
	 */
static EGLConfig[] eglGetConfigs(EGLDisplay dpy, EGLConfig[] configs, IntBuffer num_config) throws LWJGLException {
    //LWJGLUtil.log("eglGetConfigs");
    BufferChecks.checkBuffer(num_config, 1);
    if (configs == null) {
        if (!neglGetConfigs(dpy.getPointer(), 0L, 0, MemoryUtil.getAddress(num_config)))
            throwEGLError("Failed to get number of available EGL configs.");
        configs = new EGLConfig[num_config.get(num_config.position())];
    }
    final PointerBuffer configs_buffer = APIUtil.getBufferPointer(configs.length);
    if (!neglGetConfigs(dpy.getPointer(), MemoryUtil.getAddress0(configs_buffer), configs.length, MemoryUtil.getAddress(num_config)))
        throwEGLError("Failed to get EGL configs.");
    final int config_size = num_config.get(num_config.position());
    for (int i = 0; i < config_size; i++) configs[i] = new EGLConfig(dpy, configs_buffer.get(i));
    return configs;
}
Also used : PointerBuffer(org.lwjgl.PointerBuffer)

Example 19 with PointerBuffer

use of org.lwjgl.PointerBuffer in project lwjgl by LWJGL.

the class APIUtil method getBufferPointer.

static PointerBuffer getBufferPointer(final int size) {
    PointerBuffer buffer = bufferPointerTL.get();
    if (buffer.capacity() < size) {
        int sizeNew = buffer.capacity() << 1;
        while (sizeNew < size) sizeNew <<= 1;
        buffer = BufferUtils.createPointerBuffer(size);
        bufferPointerTL.set(buffer);
    } else
        buffer.clear();
    return buffer;
}
Also used : PointerBuffer(org.lwjgl.PointerBuffer)

Example 20 with PointerBuffer

use of org.lwjgl.PointerBuffer in project lwjgl by LWJGL.

the class InfoUtilAbstract method getInfoSize.

public long getInfoSize(final T object, final int param_name) {
    object.checkValid();
    final PointerBuffer buffer = APIUtil.getBufferPointer();
    getInfo(object, param_name, buffer.getBuffer(), null);
    return buffer.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