Java Code Examples for org.lwjgl.system.MemoryUtil#memASCII()

The following examples show how to use org.lwjgl.system.MemoryUtil#memASCII() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: APIBuffer.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * ASCII encodes the specified strings and ensures space for two additional
 * buffers filled with the lengths and memory addresses of the encoded
 * strings, respectively. The lengths are 4-bytes integers and the memory
 * address buffer starts immediately after the lengths buffer.
 *
 * <p>
 * The encoded buffers must be later freed with
 * {@link #pointerArrayFree(int, int)}.</p>
 *
 * @return the offset to the lengths buffer
 */
public int pointerArrayParamASCIIi(CharSequence... strings) {
    int buffersAddress = bufferParam(strings.length << POINTER_SHIFT);
    int lengthsAddress = bufferParam(strings.length << 2);

    for (int i = 0; i < strings.length; i++) {
        ByteBuffer buffer = MemoryUtil.memASCII(strings[i]);

        pointerParam(buffersAddress, i, memAddress(buffer));
        intParam(lengthsAddress, i, buffer.remaining());
    }

    return buffersAddress;
}
 
Example 2
Source File: APIBuffer.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * ASCII encodes the specified strings and ensures space for two additional
 * buffers filled with the lengths and memory addresses of the encoded
 * strings, respectively. The lengths are pointer-sized integers and the
 * memory address buffer starts immediately after the lengths buffer.
 *
 * <p>
 * The encoded buffers must be later freed with
 * {@link #pointerArrayFree(int, int)}.</p>
 *
 * @return the offset to the lengths buffer
 */
public int pointerArrayParamASCIIp(CharSequence... strings) {
    int buffersAddress = bufferParam(strings.length << POINTER_SHIFT);
    int lengthsAddress = bufferParam(strings.length << POINTER_SHIFT);

    for (int i = 0; i < strings.length; i++) {
        ByteBuffer buffer = MemoryUtil.memASCII(strings[i]);

        pointerParam(buffersAddress, i, memAddress(buffer));
        pointerParam(lengthsAddress, i, buffer.remaining());
    }

    return buffersAddress;
}
 
Example 3
Source File: APIBuffer.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Ensures space for the specified string encoded in ASCII, encodes the
 * string at the allocated offset and returns that offset.
 */
public int stringParamASCII(CharSequence value, boolean nullTerminated) {
    if (value == null) {
        return -1;
    }

    int offset = bufferParam(value.length() + (nullTerminated ? 1 : 0));
    MemoryUtil.memASCII(value, nullTerminated, buffer, offset);
    return offset;
}
 
Example 4
Source File: APIBuffer.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Returns the ASCII string value at the specified byte range.
 */
public String stringValueASCII(int offset, int limit) {
    buffer.position(offset);
    buffer.limit(limit);
    try {
        return MemoryUtil.memASCII(buffer);
    } finally {
        buffer.clear();
    }
}
 
Example 5
Source File: LwjglProgram.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private String Log(long device) {
    Utils.pointerBuffers[0].rewind();
    int ret = CL10.clGetProgramBuildInfo(program, device, CL10.CL_PROGRAM_BUILD_LOG, (ByteBuffer) null, Utils.pointerBuffers[0]);
    Utils.checkError(ret, "clGetProgramBuildInfo");
    int count = (int) Utils.pointerBuffers[0].get(0);
    final ByteBuffer buffer = BufferUtils.createByteBuffer(count);
    ret = CL10.clGetProgramBuildInfo(program, device, CL10.CL_PROGRAM_BUILD_LOG, buffer, null);
    Utils.checkError(ret, "clGetProgramBuildInfo");
    return MemoryUtil.memASCII(buffer);
}
 
Example 6
Source File: APIBuffer.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * ASCII encodes the specified strings with a null-terminator and ensures
 * space for a buffer filled with the memory addresses of the encoded
 * strings.
 *
 * <p>
 * The encoded buffers must be later freed with
 * {@link #pointerArrayFree(int, int)}.</p>
 *
 * @return the offset to the memory address buffer
 */
public int pointerArrayParamASCII(CharSequence... strings) {
    int buffersAddress = bufferParam(strings.length << POINTER_SHIFT);
    for (int i = 0; i < strings.length; i++) {
        ByteBuffer buffer = MemoryUtil.memASCII(strings[i]);

        pointerParam(buffersAddress, i, memAddress(buffer));
    }

    return buffersAddress;
}