Search in sources :

Example 46 with ByteBuffer

use of java.nio.ByteBuffer in project titan by thinkaurelius.

the class BufferUtil method getLongBuffer.

public static final StaticBuffer getLongBuffer(long id) {
    ByteBuffer buffer = ByteBuffer.allocate(longSize);
    buffer.putLong(id);
    byte[] arr = buffer.array();
    Preconditions.checkArgument(arr.length == longSize);
    return StaticArrayBuffer.of(arr);
}
Also used : ByteBuffer(java.nio.ByteBuffer)

Example 47 with ByteBuffer

use of java.nio.ByteBuffer in project titan by thinkaurelius.

the class BufferUtil method getIntBuffer.

public static final StaticBuffer getIntBuffer(int[] ids) {
    ByteBuffer buffer = ByteBuffer.allocate(intSize * ids.length);
    for (int i = 0; i < ids.length; i++) buffer.putInt(ids[i]);
    byte[] arr = buffer.array();
    Preconditions.checkArgument(arr.length == intSize * ids.length);
    return StaticArrayBuffer.of(arr);
}
Also used : ByteBuffer(java.nio.ByteBuffer)

Example 48 with ByteBuffer

use of java.nio.ByteBuffer in project playn by threerings.

the class JavaGL20 method glGetShaderInfoLog.

@Override
public String glGetShaderInfoLog(int shader) {
    ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 10);
    buffer.order(ByteOrder.nativeOrder());
    ByteBuffer tmp = ByteBuffer.allocateDirect(4);
    tmp.order(ByteOrder.nativeOrder());
    IntBuffer intBuffer = tmp.asIntBuffer();
    GL20.glGetShaderInfoLog(shader, intBuffer, buffer);
    int numBytes = intBuffer.get(0);
    byte[] bytes = new byte[numBytes];
    buffer.get(bytes);
    return new String(bytes);
}
Also used : IntBuffer(java.nio.IntBuffer) ByteBuffer(java.nio.ByteBuffer)

Example 49 with ByteBuffer

use of java.nio.ByteBuffer in project playn by threerings.

the class JavaGL20 method glTexSubImage3D.

@Override
public void glTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, int format, int type, int pixels) {
    final ByteBuffer byteBuffer = BufferUtils.createByteBuffer(1);
    byteBuffer.putInt(pixels);
    byteBuffer.rewind();
    GL12.glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, byteBuffer);
}
Also used : ByteBuffer(java.nio.ByteBuffer)

Example 50 with ByteBuffer

use of java.nio.ByteBuffer in project playn by threerings.

the class RoboGL20 method glGetShaderInfoLog.

public String glGetShaderInfoLog(int shader) {
    ByteBuffer bbuf = bufs.createByteBuffer(MAX_LOG_SIZE);
    glGetShaderInfoLog(shader, MAX_LOG_SIZE, bufs.intBuffer, bbuf);
    return toString(bbuf, bufs.intBuffer.get(0));
}
Also used : ByteBuffer(java.nio.ByteBuffer)

Aggregations

ByteBuffer (java.nio.ByteBuffer)8919 Test (org.junit.Test)1965 IOException (java.io.IOException)1022 ArrayList (java.util.ArrayList)450 File (java.io.File)224 FileChannel (java.nio.channels.FileChannel)214 MappedByteBuffer (java.nio.MappedByteBuffer)196 HashMap (java.util.HashMap)177 CharBuffer (java.nio.CharBuffer)153 ByteArrayOutputStream (java.io.ByteArrayOutputStream)146 InetSocketAddress (java.net.InetSocketAddress)143 Random (java.util.Random)127 InputStream (java.io.InputStream)125 Map (java.util.Map)119 FileInputStream (java.io.FileInputStream)116 WebSocketFrame (org.eclipse.jetty.websocket.common.WebSocketFrame)99 Test (org.testng.annotations.Test)98 IntBuffer (java.nio.IntBuffer)95 SocketChannel (java.nio.channels.SocketChannel)94 FileOutputStream (java.io.FileOutputStream)93