/** Returns a WebGL context for the given canvas element. Returns null if no 3d context is available. */ public static native WebGLRenderingContext getContext (CanvasElement canvas, WebGLContextAttributes attributes) /*-{ var names = [ "experimental-webgl", "webgl", "moz-webgl", "webkit-webgl", "webkit-3d" ]; for ( var i = 0; i < names.length; i++) { try { var ctx = canvas.getContext(names[i], attributes); if (ctx != null) { // Hook for the semi-standard WebGLDebugUtils script. if ($wnd.WebGLDebugUtils) { if ($wnd.console && $wnd.console.log) console.log('WebGL debugging enabled'); return $wnd.WebGLDebugUtils.makeDebugContext(ctx); } return ctx; } } catch (e) { } } return null; }-*/;
/** Returns a WebGL context for the given canvas element. Returns null if no 3d context is available. */ public static native WebGLRenderingContext getContext (CanvasElement canvas, WebGLContextAttributes attributes) /*-{ var names = [ "experimental-webgl", "webgl", "moz-webgl", "webkit-webgl", "webkit-3d" ]; for ( var i = 0; i < names.length; i++) { try { var ctx = canvas.getContext(names[i], attributes); if (ctx != null) { // Hook for the semi-standard WebGLDebugUtils script. if ($wnd.WebGLDebugUtils) { if ($wnd.console && $wnd.console.log) console.log('WebGL debugging enabled'); return $wnd.WebGLDebugUtils.makeDebugContext(ctx); } return ctx; } } catch (e) { } } return null; }-*/;
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); }
/** Returns a WebGL context for the given canvas element. Returns null if no 3d context is available. */ public static native WebGLRenderingContext getContext (CanvasElement canvas, WebGLContextAttributes attributes) /*-{ var names = ["experimental-webgl", "webgl", "moz-webgl", "webkit-webgl", "webkit-3d"]; for (var i = 0; i < names.length; i++) { try { var ctx = canvas.getContext(names[i], attributes); if (ctx != null) { // Hook for the semi-standard WebGLDebugUtils script. if ($wnd.WebGLDebugUtils) { if ($wnd.console && $wnd.console.log) console.log('WebGL debugging enabled'); return $wnd.WebGLDebugUtils.makeDebugContext(ctx); } return ctx; } } catch(e) { } } return null; }-*/;
/** Returns a WebGL context for the given canvas element. Returns null if no 3d context is available. */ public static native WebGLRenderingContext getContext (CanvasElement canvas, WebGLContextAttributes attributes) /*-{ var names = [ "experimental-webgl", "webgl", "moz-webgl", "webkit-webgl", "webkit-3d" ]; for ( var i = 0; i < names.length; i++) { try { var ctx = canvas.getContext(names[i], attributes); if (ctx != null) { // Hook for the semi-standard WebGLDebugUtils script. if ($wnd.WebGLDebugUtils) { if ($wnd.console && $wnd.console.log) console.log('WebGL debugging enabled'); return $wnd.WebGLDebugUtils.makeDebugContext(ctx); } return ctx; } } catch (e) { } } return null; }-*/;
/** * Returns a WebGL context for the given canvas element. Returns null if no 3d * context is available. */ public static native WebGLRenderingContext getContext(CanvasElement canvas, WebGLContextAttributes attributes) /*-{ var names = ["webgl", "experimental-webgl", "moz-webgl", "webkit-webgl", "webkit-3d"]; for (var i = 0; i < names.length; i++) { try { var ctx = canvas.getContext(names[i], attributes); if (ctx != null) { // Hook for the semi-standard WebGLDebugUtils script. if ($wnd.WebGLDebugUtils) { if ($wnd.console && $wnd.console.log) console.log('WebGL debugging enabled'); return $wnd.WebGLDebugUtils.makeDebugContext(ctx); } return ctx; } } catch(e) { } } return null; }-*/;
/** * Returns a WebGL context for the given canvas element. Returns null if no 3d * context is available. */ public static native WebGLRenderingContext getContext(CanvasElement canvas, WebGLContextAttributes attributes) /*-{ var names = ["webgl", "experimental-webgl", "moz-webgl", "webkit-webgl", "webkit-3d"]; for (var i = 0; i < names.length; i++) { try { var ctx = canvas.getContext(names[i], attributes); if (ctx != null) { // Hook for the semi-standard WebGLDebugUtils script. if ($wnd.WebGLDebugUtils) { if ($wnd.console && $wnd.console.log) console.log('WebGL debugging enabled'); return $wnd.WebGLDebugUtils.makeDebugContext(ctx); } return ctx; } } catch(e) { } } return null; }-*/;
/** * Returns a WebGL context for the given canvas element. Returns null if no 3d * context is available. */ public static native WebGLRenderingContext getContext(CanvasElement canvas, WebGLContextAttributes attributes) /*-{ var names = ["webgl", "experimental-webgl", "moz-webgl", "webkit-webgl", "webkit-3d"]; for (var i = 0; i < names.length; i++) { try { var ctx = canvas.getContext(names[i], attributes); if (ctx != null) { // Hook for the semi-standard WebGLDebugUtils script. if ($wnd.WebGLDebugUtils) { if ($wnd.console && $wnd.console.log) console.log('WebGL debugging enabled'); return $wnd.WebGLDebugUtils.makeDebugContext(ctx); } return ctx; } } catch(e) { } } return null; }-*/;
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); }
this.config = config; WebGLContextAttributes attributes = WebGLContextAttributes.create(); attributes.setAntialias(config.isAntialiasing()); attributes.setStencil(config.isStencil());
setSize(root.getOffsetWidth(), root.getOffsetHeight()); WebGLContextAttributes attrs = WebGLContextAttributes.create(); attrs.setAlpha(config.transparentCanvas); attrs.setAntialias(config.antiAliasing);
setSize(root.getOffsetWidth(), root.getOffsetHeight()); WebGLContextAttributes attrs = WebGLContextAttributes.create(); attrs.setAlpha(config.transparentCanvas); attrs.setAntialias(config.antiAliasing);