List of usage examples for com.google.gwt.typedarrays.client Int32Array create
public static final native Int32Array create(ArrayBuffer buffer, int byteOffset, int length) ;
From source file:com.googlecode.gwtgl.wrapper.IntArray.java
License:Apache License
/** * Create a new Int32Array object using the passed ArrayBuffer for its storage. Optional byteOffset and length can be used to limit the section of the buffer referenced. The byteOffset indicates the offset in bytes from the start of the ArrayBuffer, and the length is the count of elements from the offset that this WebGLByteArray will reference. If both byteOffset and length are omitted, the WebGLTypeNameArray spans the entire ArrayBuffer range. If the length is omitted, the WebGLTypeNameArray extends from the given byteOffset until the end of the ArrayBuffer. * /*ww w. j a v a 2 s . co m*/ * The given byteOffset must be a multiple of the element size of the specific type, otherwise an exception is raised. * * If a given byteOffset and length references an area beyond the end of the ArrayBuffer an exception is raised.Create a new WebGLTypeNameArray object using the passed ArrayBuffer for its storage. Optional byteOffset and length can be used to limit the section of the buffer referenced. The byteOffset indicates the offset in bytes from the start of the ArrayBuffer, and the length is the count of elements from the offset that this WebGLByteArray will reference. If both byteOffset and length are omitted, the WebGLTypeNameArray spans the entire ArrayBuffer range. If the length is omitted, the WebGLTypeNameArray extends from the given byteOffset until the end of the ArrayBuffer. * * The given byteOffset must be a multiple of the element size of the specific type, otherwise an exception is raised. * * If a given byteOffset and length references an area beyond the end of the ArrayBuffer an exception is raised. * * @param buffer * @param byteOffset * @param length */ public IntArray(ArrayBuffer buffer, int byteOffset, int length) { super(Int32Array.create(buffer, byteOffset, length)); }
From source file:java.nio.IntBuffer.java
License:Apache License
IntBuffer(ByteBuffer byteBuffer) {
super((byteBuffer.capacity() >> 2));
this.byteBuffer = byteBuffer;
this.byteBuffer.clear();
this.intArray = Int32Array.create(byteBuffer.byteArray.getBuffer(), byteBuffer.byteArray.getByteOffset(),
capacity);/* w ww . j a va 2s .c o m*/
}
From source file:playn.html.HtmlGL20.java
License:Apache License
/** * Returns the typed array of the given native buffer. * Set byteSize to -1 to use remaining() *///from w w w. ja v a 2 s. com protected ArrayBufferView getTypedArray(Buffer buffer, int type, int byteSize) { if (!(buffer instanceof HasArrayBufferView)) { throw new RuntimeException("Native buffer required " + buffer); } HasArrayBufferView arrayHolder = (HasArrayBufferView) buffer; int bufferElementSize = arrayHolder.getElementSize(); ArrayBufferView webGLArray = arrayHolder.getTypedArray(); if (byteSize == -1) { byteSize = buffer.remaining() * bufferElementSize; } if (byteSize == buffer.capacity() * bufferElementSize && type == arrayHolder.getElementType()) { return webGLArray; } int byteOffset = webGLArray.getByteOffset() + buffer.position() * bufferElementSize; switch (type) { case FLOAT: return Float32Array.create(webGLArray.getBuffer(), byteOffset, byteSize / 4); case UNSIGNED_BYTE: return Uint8Array.create(webGLArray.getBuffer(), byteOffset, byteSize); case UNSIGNED_SHORT: return Uint16Array.create(webGLArray.getBuffer(), byteOffset, byteSize / 2); case INT: return Int32Array.create(webGLArray.getBuffer(), byteOffset, byteSize / 4); case SHORT: return Int16Array.create(webGLArray.getBuffer(), byteOffset, byteSize / 2); case BYTE: return Int8Array.create(webGLArray.getBuffer(), byteOffset, byteSize); default: throw new IllegalArgumentException("Type: " + type); } }