Example usage for com.google.gwt.typedarrays.client Float32Array getByteLength

List of usage examples for com.google.gwt.typedarrays.client Float32Array getByteLength

Introduction

In this page you can find the example usage for com.google.gwt.typedarrays.client Float32Array getByteLength.

Prototype

public final native int getByteLength() ;

Source Link

Document

The offset of this ArrayBufferView from the start of its ArrayBuffer, in bytes, as fixed at construction time.

Usage

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./* w  ww.  j  a v a 2 s .  co  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();
}