use of com.google.gwt.typedarrays.shared.Int32Array in project libgdx by libgdx.
the class WebGLRenderingContext method toJsArray.
public final Int32Array toJsArray(int[] values) {
Int32Array array = TypedArrays.createInt32Array(values.length);
array.set(values);
return array;
}
use of com.google.gwt.typedarrays.shared.Int32Array in project playn by threerings.
the class HtmlGL20 method glGetIntegerv.
@Override
public void glGetIntegerv(int pname, IntBuffer params) {
Int32Array result = (Int32Array) gl.getParameterv(pname);
int pos = params.position();
int len = result.length();
for (int i = 0; i < len; i++) {
params.put(pos + i, result.get(i));
}
}
use of com.google.gwt.typedarrays.shared.Int32Array in project playn by threerings.
the class HtmlGLContext method tryBasicGLCalls.
private void tryBasicGLCalls() throws RuntimeException {
// test that our Float32 arrays work (a technique found in other WebGL checks)
Float32Array testFloat32Array = ArrayUtils.createFloat32Array(new float[] { 0.0f, 1.0f, 2.0f });
if (testFloat32Array.get(0) != 0.0f || testFloat32Array.get(1) != 1.0f || testFloat32Array.get(2) != 2.0f) {
throw new RuntimeException("Typed Float32Array check failed");
}
// test that our Int32 arrays work
Int32Array testInt32Array = ArrayUtils.createInt32Array(new int[] { 0, 1, 2 });
if (testInt32Array.get(0) != 0 || testInt32Array.get(1) != 1 || testInt32Array.get(2) != 2) {
throw new RuntimeException("Typed Int32Array check failed");
}
// test that our Uint16 arrays work
Uint16Array testUint16Array = ArrayUtils.createUint16Array(new int[] { 0, 1, 2 });
if (testUint16Array.get(0) != 0 || testUint16Array.get(1) != 1 || testUint16Array.get(2) != 2) {
throw new RuntimeException("Typed Uint16Array check failed");
}
// test that our Uint8 arrays work
Uint8Array testUint8Array = ArrayUtils.createUint8Array(new int[] { 0, 1, 2 });
if (testUint8Array.get(0) != 0 || testUint8Array.get(1) != 1 || testUint8Array.get(2) != 2) {
throw new RuntimeException("Typed Uint8Array check failed");
}
// Perform GL read back test where we paint rgba(1, 1, 1, 1) and then read back that data.
// (should be 100% opaque white).
bindFramebuffer();
clear(1, 1, 1, 1);
int err = glc.getError();
if (err != NO_ERROR) {
throw new RuntimeException("Read back GL test failed to clear color (error " + err + ")");
}
Uint8Array pixelData = TypedArrays.createUint8Array(4);
glc.readPixels(0, 0, 1, 1, RGBA, UNSIGNED_BYTE, pixelData);
if (pixelData.get(0) != 255 || pixelData.get(1) != 255 || pixelData.get(2) != 255) {
throw new RuntimeException("Read back GL test failed to read back correct color");
}
}
Aggregations