Example usage for com.google.gwt.webgl.client WebGLRenderingContext texImage2D

List of usage examples for com.google.gwt.webgl.client WebGLRenderingContext texImage2D

Introduction

In this page you can find the example usage for com.google.gwt.webgl.client WebGLRenderingContext texImage2D.

Prototype

public final native void texImage2D(int target, int level, int internalformat, int width, int height,
            int border, int format, int type, ArrayBufferView pixels) ;

Source Link

Usage

From source file:forplay.html.HtmlSurfaceLayerGL.java

License:Apache License

HtmlSurfaceLayerGL(HtmlGraphicsGL gfx, int width, int height) {
    super(gfx);/* w w  w. ja  v a  2 s .com*/

    this.width = width;
    this.height = height;
    gfx.flush();

    WebGLRenderingContext gl = gfx.gl;
    tex = gfx.createTexture(false, false);
    gl.texImage2D(TEXTURE_2D, 0, RGBA, width, height, 0, RGBA, UNSIGNED_BYTE, null);

    fbuf = gl.createFramebuffer();
    gl.bindFramebuffer(FRAMEBUFFER, fbuf);
    gl.framebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0, TEXTURE_2D, tex, 0);

    gl.bindTexture(TEXTURE_2D, null);
    gfx.bindFramebuffer();

    surface = new HtmlSurfaceGL(gfx, fbuf, width, height);
}