List of usage examples for com.google.gwt.corp.webgl.client WebGLUnsignedByteArray create
public static final native WebGLUnsignedByteArray create(WebGLArrayBuffer buffer, int byteOffset, int length) ;
From source file:jake2.gwt.client.WebGLAdapter.java
License:Open Source License
private WebGLArray<?> getWebGLArray(Buffer buffer, int type) { int elementSize; HasWebGLArray arrayHolder;/*from ww w .j a v a 2 s . co m*/ if (!(buffer instanceof HasWebGLArray)) { if (type != GL_BYTE && type != GL_UNSIGNED_BYTE) { log("buffer byte order problem"); throw new RuntimeException("Buffer byte order problem"); } if (buffer instanceof IntBuffer) { elementSize = 4; } else { throw new RuntimeException("NYI"); } arrayHolder = (HasWebGLArray) ((ByteBufferWrapper) buffer).getByteBuffer(); } else { arrayHolder = (HasWebGLArray) buffer; elementSize = arrayHolder.getElementSize(); } WebGLArray<?> webGLArray = arrayHolder.getWebGLArray(); int remainingBytes = buffer.remaining() * elementSize; int byteOffset = webGLArray.getByteOffset() + buffer.position() * elementSize; switch (type) { case WebGL.GL_FLOAT: return WebGLFloatArray.create(webGLArray.getBuffer(), byteOffset, remainingBytes / 4); case WebGL.GL_UNSIGNED_BYTE: return WebGLUnsignedByteArray.create(webGLArray.getBuffer(), byteOffset, remainingBytes); case WebGL.GL_UNSIGNED_SHORT: return WebGLUnsignedShortArray.create(webGLArray.getBuffer(), byteOffset, remainingBytes / 2); case WebGL.GL_INT: return WebGLIntArray.create(webGLArray.getBuffer(), byteOffset, remainingBytes / 4); case WebGL.GL_SHORT: return WebGLShortArray.create(webGLArray.getBuffer(), byteOffset, remainingBytes / 2); case WebGL.GL_BYTE: return WebGLByteArray.create(webGLArray.getBuffer(), byteOffset, remainingBytes); } throw new IllegalArgumentException(); }