List of usage examples for com.google.gwt.typedarrays.client Float32Array create
public static final native Float32Array create(JsArrayNumber data) ;
From source file:com.googlecode.gwtgl.example.client.examples.coloredtriangle.binding.ColoredTriangleBindingExample.java
License:Apache License
/** * Initializes the buffer containing the vertex and color coordinates. *//* w ww. j av a 2s . com*/ private void initBuffers() { // create the vertexBuffer // One Triangle with 3 Points 3 coordinates vertexBuffer = glContext.createBuffer(); glContext.bindBuffer(WebGLRenderingContext.ARRAY_BUFFER, vertexBuffer); float[] vertices = new float[] { 0.0f, 1.0f, -5.0f, // x y z des ersten Dreieckpunktes -1.0f, -1.0f, -5.0f, // x y z des zweiten Dreieckpunktes 1.0f, -1.0f, -5.0f // x y z des dritten Dreieckpunktes }; glContext.bufferData(WebGLRenderingContext.ARRAY_BUFFER, Float32Array.create(vertices), WebGLRenderingContext.STATIC_DRAW); // create the colorBuffer colorBuffer = glContext.createBuffer(); glContext.bindBuffer(WebGLRenderingContext.ARRAY_BUFFER, colorBuffer); float[] colors = new float[] { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f }; glContext.bufferData(WebGLRenderingContext.ARRAY_BUFFER, Float32Array.create(colors), WebGLRenderingContext.STATIC_DRAW); // create the indexBuffer indexBuffer = glContext.createBuffer(); glContext.bindBuffer(WebGLRenderingContext.ELEMENT_ARRAY_BUFFER, indexBuffer); int[] indices = new int[] { 0, 1, 2 }; glContext.bufferData(WebGLRenderingContext.ELEMENT_ARRAY_BUFFER, Uint16Array.create(indices), WebGLRenderingContext.STATIC_DRAW); checkErrors(); }
From source file:com.googlecode.gwtgl.example.client.examples.skybox.SkyboxExample.java
License:Apache License
/** * Initializes the buffers for vertex coordinates, normals and texture * coordinates./*from w w w .j a va 2 s. c o m*/ */ private void initBuffers() { buffer = glContext.createBuffer(); glContext.bindBuffer(WebGLRenderingContext.ARRAY_BUFFER, buffer); Float32Array vertices = Float32Array.create(cube.getVertices()); texCoordsOffset = vertices.getByteLength(); Float32Array texCoords = Float32Array.create(cube.getTexCoords()); glContext.bufferData(WebGLRenderingContext.ARRAY_BUFFER, vertices.getByteLength() + texCoords.getByteLength(), WebGLRenderingContext.STATIC_DRAW); glContext.bufferSubData(WebGLRenderingContext.ARRAY_BUFFER, 0, vertices); glContext.bufferSubData(WebGLRenderingContext.ARRAY_BUFFER, texCoordsOffset, texCoords); checkErrors(); }
From source file:com.googlecode.gwtgl.example.client.examples.texturedcube.binding.TexturedCubeBindingExample.java
License:Apache License
/** * Initializes the buffers for vertex coordinates, normals and texture * coordinates./* ww w . ja v a 2s. com*/ */ private void initBuffers() { vertexBuffer = glContext.createBuffer(); glContext.bindBuffer(WebGLRenderingContext.ARRAY_BUFFER, vertexBuffer); glContext.bufferData(WebGLRenderingContext.ARRAY_BUFFER, Float32Array.create(cube.getVertices()), WebGLRenderingContext.STATIC_DRAW); vertexTextureCoordBuffer = glContext.createBuffer(); glContext.bindBuffer(WebGLRenderingContext.ARRAY_BUFFER, vertexTextureCoordBuffer); glContext.bufferData(WebGLRenderingContext.ARRAY_BUFFER, Float32Array.create(cube.getTexCoords()), WebGLRenderingContext.STATIC_DRAW); checkErrors(); }
From source file:com.googlecode.gwtgl.example.client.examples.whitetriangle.WhiteTriangleExample.java
License:Apache License
/** * Initializes the buffer containing the vertex coordinates. *//*from w ww.j ava 2 s . com*/ private void initVertexBuffer() { // One Triangle with 3 Points 3 coordinates vertexBuffer = glContext.createBuffer(); glContext.bindBuffer(WebGLRenderingContext.ARRAY_BUFFER, vertexBuffer); float[] vertices = new float[] { 0.0f, 1.0f, -5.0f, // x y z des ersten // Dreieckpunktes -1.0f, -1.0f, -5.0f, // x y z des zweiten Dreieckpunktes 1.0f, -1.0f, -5.0f // x y z des dritten Dreieckpunktes }; glContext.bufferData(WebGLRenderingContext.ARRAY_BUFFER, Float32Array.create(vertices), WebGLRenderingContext.STATIC_DRAW); }
From source file:com.googlecode.gwtgl.wrapper.FloatArray.java
License:Apache License
/** * Create a new Float32Array 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 w ww . j a v a 2 s. c om * @param length */ public FloatArray(int length) { super(Float32Array.create(length)); }
From source file:com.googlecode.gwtgl.wrapper.FloatArray.java
License:Apache License
/** * Create a new Float32Array object with a new underlying ArrayBuffer large enough to hold the given data, then copy the passed data into the buffer. * /* www. j a v a 2s . c om*/ * @param array */ public FloatArray(Float32Array array) { super(Float32Array.create(array)); }
From source file:com.googlecode.gwtgl.wrapper.FloatArray.java
License:Apache License
/** * Create a new Float32Array object with a new underlying ArrayBuffer large enough to hold the given data, then copy the passed data into the buffer. * /*from ww w. j a v a 2 s . c o m*/ * @param array */ public FloatArray(float[] array) { super(Float32Array.create(array)); }
From source file:com.googlecode.gwtgl.wrapper.FloatArray.java
License:Apache License
/** * Create a new Float32Array object using the passed ArrayBuffer for its storage. * // ww w.j a v a 2s . co m * @param buffer */ public FloatArray(ArrayBuffer buffer) { super(Float32Array.create(buffer)); }
From source file:com.googlecode.gwtgl.wrapper.WebGLWrapper.java
License:Apache License
/** * Wrapps {@link com.googlecode.gwtgl.binding.WebGLRenderingContext#uniformMatrix2fv(WebGLUniformLocation location, boolean transpose, Float32Array value)} * @param location Specifies the location of the uniform value to be modified * @param transpose Specifies whether to transpose the matrix as the values are loaded into the uniform variable * @param values Specifies an array of values that will be used to update the specified uniform variable */// w w w .ja v a 2 s . c om public void uniformMatrix2fv(WebGLUniformLocation location, boolean transpose, float[] values) { glContext.uniformMatrix2fv(location, transpose, Float32Array.create(values)); }
From source file:com.googlecode.gwtgl.wrapper.WebGLWrapper.java
License:Apache License
/** * wrapps {@link com.googlecode.gwtgl.binding.WebGLRenderingContext#uniformMatrix3fv(WebGLUniformLocation location, boolean transpose, Float32Array value)} * @param location Specifies the location of the uniform value to be modified * @param transpose Specifies whether to transpose the matrix as the values are loaded into the uniform variable * @param values Specifies an array of values that will be used to update the specified uniform variable *//*w w w .j a va 2 s . c o m*/ public void uniformMatrix3fv(WebGLUniformLocation location, boolean transpose, float[] values) { glContext.uniformMatrix3fv(location, transpose, Float32Array.create(values)); }