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

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

Introduction

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

Prototype

public final native void setAntialias(boolean antialias) ;

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 ww  .ja  va  2 s .c  o  m
    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();/*from w w w  . j  a  v  a 2  s . c  o 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);
}

From source file:playn.html.HtmlGraphicsGL.java

License:Apache License

HtmlGraphicsGL(HtmlPlatform platform, HtmlPlatform.Configuration config) throws RuntimeException {
    canvas = Document.get().createCanvasElement();
    rootElement.appendChild(canvas);/*from   www  .  j  a  v  a2 s.c om*/
    try {
        WebGLContextAttributes attrs = WebGLContextAttributes.create();
        attrs.setAlpha(config.transparentCanvas);
        attrs.setAntialias(config.antiAliasing);

        // if this returns null, the browser doesn't support WebGL on this machine
        WebGLRenderingContext gl = WebGLRenderingContext.getContext(canvas, attrs);
        // Some systems seem to have a problem where they return a valid context, but it's in an
        // error state initially. We give up and fall back to Canvas in this case, because nothing
        // seems to work properly.
        if (gl == null || gl.getError() != WebGLRenderingContext.NO_ERROR) {
            throw new RuntimeException(
                    "GL context not created [err=" + (gl == null ? "null" : gl.getError()) + "]");
        }

        ctx = new HtmlGLContext(platform, gl, canvas);
        rootLayer = new GroupLayerGL(ctx);
    } catch (RuntimeException re) {
        // Give up. HtmlPlatform will catch the exception and fall back to dom/canvas.
        rootElement.removeChild(canvas);
        throw re;
    }
}