Example usage for com.google.gwt.webgl.client WebGLContextAttributes setPremultipliedAlpha

List of usage examples for com.google.gwt.webgl.client WebGLContextAttributes setPremultipliedAlpha

Introduction

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

Prototype

public final native void setPremultipliedAlpha(boolean premultipliedAlpha) ;

Source Link

Document

Default: true.

Usage

From source file:com.badlogic.gdx.backends.gwt.GwtGraphics.java

License:Apache License

public GwtGraphics(Panel root, GwtApplicationConfiguration config) {
    Canvas canvasWidget = Canvas.createIfSupported();
    if (canvasWidget == null)
        throw new GdxRuntimeException("Canvas not supported");
    canvas = canvasWidget.getCanvasElement();
    root.add(canvasWidget);// w w  w .  j av a 2  s. c  om
    canvas.setWidth(config.width);
    canvas.setHeight(config.height);
    this.config = config;

    WebGLContextAttributes attributes = WebGLContextAttributes.create();
    attributes.setAntialias(config.antialiasing);
    attributes.setStencil(config.stencil);
    attributes.setAlpha(config.alpha);
    attributes.setPremultipliedAlpha(config.premultipliedAlpha);
    attributes.setPreserveDrawingBuffer(config.preserveDrawingBuffer);

    context = WebGLRenderingContext.getContext(canvas, attributes);
    context.viewport(0, 0, config.width, config.height);
    this.gl = config.useDebugGL ? new GwtGL20Debug(context) : new GwtGL20(context);

    String versionString = gl.glGetString(GL20.GL_VERSION);
    String vendorString = gl.glGetString(GL20.GL_VENDOR);
    String rendererString = gl.glGetString(GL20.GL_RENDERER);
    glVersion = new GLVersion(Application.ApplicationType.WebGL, versionString, vendorString, rendererString);
}

From source file:org.parallax3d.parallax.platforms.gwt.GwtRenderingContext.java

License:Open Source License

public GwtRenderingContext(Panel root, GwtAppConfiguration config) throws ParallaxRuntimeException {
    this.root = root;
    root.clear();//ww  w  .  j  a v  a  2 s. co  m

    Canvas canvasWidget = Canvas.createIfSupported();
    if (canvasWidget == null)
        throw new ParallaxRuntimeException("Canvas not supported");

    int width = root.getOffsetWidth();
    int height = root.getOffsetHeight();

    if (width == 0 || height == 0)
        new ParallaxRuntimeException("Width or Height of the Panel is 0");

    lastWidth = width;
    lastHeight = height;

    canvas = canvasWidget.getCanvasElement();
    root.add(canvasWidget);
    canvas.setWidth(width);
    canvas.setHeight(height);
    this.config = config;

    WebGLContextAttributes attributes = WebGLContextAttributes.create();
    attributes.setAntialias(config.antialiasing);
    attributes.setStencil(config.stencil);
    attributes.setAlpha(config.alpha);
    attributes.setPremultipliedAlpha(config.premultipliedAlpha);
    attributes.setPreserveDrawingBuffer(config.preserveDrawingBuffer);

    context = WebGLRenderingContext.getContext(canvas, attributes);
    context.viewport(0, 0, width, height);

    gl = new GwtGL20(context);

    renderer = new GLRenderer(gl, width, height);

    input = new GwtInput(canvas);

    addEventListeners();

    Window.addResizeHandler(this);
}