Search in sources :

Example 1 with Float32Array

use of com.google.gwt.typedarrays.shared.Float32Array in project libgdx by libgdx.

the class WebGLRenderingContext method toJsArray.

public final Float32Array toJsArray(float[] values) {
    Float32Array array = TypedArrays.createFloat32Array(values.length);
    array.set(values);
    return array;
}
Also used : Float32Array(com.google.gwt.typedarrays.shared.Float32Array)

Example 2 with Float32Array

use of com.google.gwt.typedarrays.shared.Float32Array 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");
    }
}
Also used : Int32Array(com.google.gwt.typedarrays.shared.Int32Array) Uint16Array(com.google.gwt.typedarrays.shared.Uint16Array) Float32Array(com.google.gwt.typedarrays.shared.Float32Array) Uint8Array(com.google.gwt.typedarrays.shared.Uint8Array)

Aggregations

Float32Array (com.google.gwt.typedarrays.shared.Float32Array)2 Int32Array (com.google.gwt.typedarrays.shared.Int32Array)1 Uint16Array (com.google.gwt.typedarrays.shared.Uint16Array)1 Uint8Array (com.google.gwt.typedarrays.shared.Uint8Array)1