Example usage for com.google.gwt.corp.webgl.client WebGL getContext

List of usage examples for com.google.gwt.corp.webgl.client WebGL getContext

Introduction

In this page you can find the example usage for com.google.gwt.corp.webgl.client WebGL getContext.

Prototype

public static native WebGL getContext(Element canvas, JavaScriptObject options) ;

Source Link

Document

Returns a WebGL context for the given canvas element.

Usage

From source file:jake2.gwt.client.WebGLAdapter.java

License:Open Source License

public WebGLAdapter(CanvasElement canvas) {
    super(canvas.getWidth(), canvas.getHeight());

    this.canvas = canvas;
    gl = WebGL.getContext(canvas, JavaScriptObject.createObject());

    if (gl == null) {
        throw new UnsupportedOperationException("WebGL N/A");
    }//from www .ja  v a  2s.  co m

    initShader();
    checkError("initShader");

    elementBuffer = gl.glCreateBuffer();
    checkError("createBuffer f. elements");

    for (int i = 0; i < bufferData.length; i++) {
        BufferData bd = new BufferData();
        bd.buffer = gl.glCreateBuffer();
        checkError("createBuffer" + i);
        bufferData[i] = bd;
    }

}