List of usage examples for com.google.gwt.typedarrays.client Int32Array create
public static final native Int32Array create(JsArrayInteger data) ;
From source file:com.googlecode.gwtgl.wrapper.IntArray.java
License:Apache License
/** * Create a new Int32Array object of the given length with a new underlying ArrayBuffer large enough to hold length elements of the specific type. Data in the buffer is initialized to 0. * /*from ww w . j av a 2 s. c o m*/ * @param length */ public IntArray(int length) { super(Int32Array.create(length)); }
From source file:com.googlecode.gwtgl.wrapper.IntArray.java
License:Apache License
/** * Create a new Int32Array object with a new underlying ArrayBuffer large enough to hold the given data, then copy the passed data into the buffer. * /*from w w w. j a va 2 s . c om*/ * @param array */ public IntArray(Int32Array array) { super(Int32Array.create(array)); }
From source file:com.googlecode.gwtgl.wrapper.IntArray.java
License:Apache License
/** * Create a new Int32Array object with a new underlying ArrayBuffer large enough to hold the given data, then copy the passed data into the buffer. * /*from w w w . j av a2s . c om*/ * @param array */ public IntArray(int[] array) { super(Int32Array.create(array)); }
From source file:com.googlecode.gwtgl.wrapper.IntArray.java
License:Apache License
/** * Create a new Int32Array object using the passed ArrayBuffer for its storage. * /*from www. j av a 2s .c o m*/ * @param buffer */ public IntArray(ArrayBuffer buffer) { super(Int32Array.create(buffer)); }
From source file:forplay.html.HtmlGraphicsGL.java
License:Apache License
/** * Try basic GL operations to detect failure cases early. * //www .j a va2 s.c o m * @return true if calls succeed, false otherwise. */ private boolean tryBasicGlCalls() { int err; try { // test that our Float32 arrays work (a technique found in other WebGL checks) Float32Array testFloat32Array = Float32Array.create(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 = Int32Array.create(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 = Uint16Array.create(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 = Uint8Array.create(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(); gl.clearColor(1, 1, 1, 1); err = gl.getError(); if (err != NO_ERROR) { throw new RuntimeException("Read back GL test failed to clear color (error " + err + ")"); } updateLayers(); Uint8Array pixelData = Uint8Array.create(4); gl.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"); } } catch (RuntimeException e) { ForPlay.log().info("Basic GL check failed: " + e.getMessage()); return false; } catch (Throwable t) { ForPlay.log().info("Basic GL check failed with an unknown error: " + t.getMessage()); return false; } return true; }
From source file:playn.html.HtmlGLContext.java
License:Apache License
private void tryBasicGLCalls() throws RuntimeException { // test that our Float32 arrays work (a technique found in other WebGL checks) Float32Array testFloat32Array = Float32Array.create(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"); }// ww w .j a va2 s. com // test that our Int32 arrays work Int32Array testInt32Array = Int32Array.create(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 = Uint16Array.create(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 = Uint8Array.create(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 = Uint8Array.create(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"); } }