use of com.google.gwt.webgl.client.WebGLTexture in project playn by threerings.
the class WebGLDemo method createTexture.
private WebGLTexture createTexture(String url) {
// Create the texture object.
final WebGLTexture tex = gl.createTexture();
// Load the image.
final ImageElement img = createImage();
img.setSrc(url);
hookOnLoad(img, new EventHandler() {
@Override
public void onEvent(NativeEvent e) {
// Load image data into the texture object once it's loaded.
gl.bindTexture(TEXTURE_2D, tex);
gl.texImage2D(TEXTURE_2D, 0, RGBA, RGBA, UNSIGNED_BYTE, img);
gl.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, LINEAR);
gl.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, LINEAR);
gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);
gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);
gl.bindTexture(TEXTURE_2D, null);
}
});
return tex;
}
Aggregations