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); 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); }
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); 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); }
HtmlGraphicsGL(HtmlPlatform platform, HtmlPlatform.Config config) throws RuntimeException { super(config); canvas = Document.get().createCanvasElement(); canvas.setWidth(rootElement.getOffsetWidth()); canvas.setHeight(rootElement.getOffsetHeight()); rootElement.appendChild(canvas); 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); if (gl == null) throw new RuntimeException("Unable to create GL context"); // Some systems seem to have a problem where they return a non-null 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. int error = gl.getError(); if (error != WebGLRenderingContext.NO_ERROR) throw new RuntimeException("GL context started with errors [err=" + error + "]"); ctx = new HtmlGLContext(platform, config.scaleFactor, 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; } }
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); 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); }
attributes.setAntialias(config.isAntialiasing()); attributes.setStencil(config.isStencil()); attributes.setAlpha(config.isAlpha());
attrs.setAntialias(config.antiAliasing);
attrs.setAntialias(config.antiAliasing);