@Override public GroupLayer createGroupLayer() { return new GroupLayerGL(ctx); }
@Override public void paint(InternalTransform curTransform, int curTint, GLShader curShader) { if (!visible()) return; if (tint != Tint.NOOP_TINT) curTint = Tint.combine(curTint, tint); render(localTransform(curTransform), curTint, (shader == null) ? curShader : shader); }
@Deprecated @Override public void clear() { removeAll(); }
public void paint(GroupLayerGL rootLayer) { if (rootLayer.size() > 0) { checkGLError("paint"); bindFramebuffer(); gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear to transparent rootLayer.paint(rootXform, Tint.NOOP_TINT, null); // paint all the layers useShader(null); // flush any pending shader } if (STATS_ENABLED) stats.frames++; }
@Override protected void render(InternalTransform xform, int curTint, GLShader shader) { xform.translate(originX, originY); xform.transform(pos.set(-originX, -originY), pos); xform.transform(size.set(width, height), size); xform.translate(-originX, -originY); boolean nonEmpty = ctx.startClipped((int) pos.x, (int) pos.y, Math.round(Math.abs(size.x)), Math.round(Math.abs(size.y))); try { if (nonEmpty) { super.render(xform, curTint, shader); } } finally { ctx.endClipped(); } } }
public AndroidGraphics(AndroidPlatform platform, AndroidGL20 gfx, Bitmap.Config bitmapConfig) { this.platform = platform; this.preferredBitmapConfig = bitmapConfig; ctx = new AndroidGLContext(platform, gfx); rootLayer = new GroupLayerGL(ctx); }
public AndroidGraphics(AndroidPlatform platform, AndroidGL20 gfx, Bitmap.Config bitmapConfig) { this.platform = platform; this.preferredBitmapConfig = bitmapConfig; ctx = new AndroidGLContext(platform, gfx); rootLayer = new GroupLayerGL(ctx); }
@Override public GroupLayer createGroupLayer() { return new GroupLayerGL(ctx()); }
public JavaGraphics(JavaPlatform platform, JavaPlatform.Config config) { this.platform = platform; // if we're being run in headless mode, create a stub GL context which does not trigger the // initialization of LWJGL; this allows tests to run against non-graphics services without // needing to configure LWJGL native libraries this.ctx = config.headless ? new GL20Context(platform, null, config.scaleFactor, false) : new JavaGLContext(platform, config.scaleFactor); this.rootLayer = new GroupLayerGL(ctx); // set up the dummy font contexts Graphics2D aaGfx = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics(); aaGfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); aaFontContext = aaGfx.getFontRenderContext(); Graphics2D aGfx = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics(); aGfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); aFontContext = aGfx.getFontRenderContext(); if (!config.headless) { setDisplayMode(ctx.scale.scaledCeil(config.width), ctx.scale.scaledCeil(config.height), config.fullscreen); } }
public JavaGraphics(JavaPlatform platform, JavaPlatform.Config config) { this.platform = platform; // if we're being run in headless mode, create a stub GL context which does not trigger the // initialization of LWJGL; this allows tests to run against non-graphics services without // needing to configure LWJGL native libraries this.ctx = config.headless ? new GL20Context(platform, null, config.scaleFactor, false) : new JavaGLContext(platform, config.scaleFactor); this.rootLayer = new GroupLayerGL(ctx); // set up the dummy font contexts Graphics2D aaGfx = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics(); aaGfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); aaFontContext = aaGfx.getFontRenderContext(); Graphics2D aGfx = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics(); aGfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); aFontContext = aGfx.getFontRenderContext(); if (!config.headless) { setDisplayMode(ctx.scale.scaledCeil(config.width), ctx.scale.scaledCeil(config.height), config.fullscreen); } }
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 RoboGraphics(RoboPlatform platform, CGRect bounds) { this.platform = platform; float deviceScale = (float)((platform.osVersion >= 8) ? UIScreen.getMainScreen().getNativeScale() : UIScreen.getMainScreen().getScale()); boolean isPad = UIDevice.getCurrentDevice().getUserInterfaceIdiom() == UIUserInterfaceIdiom.Pad; boolean useHalfSize = isPad && platform.config.iPadLikePhone; float viewScale = (useHalfSize ? 2 : 1) * deviceScale; this.deviceScale = deviceScale; ctx = new RoboGLContext(platform, new RoboGL20(), viewScale); setSize(bounds); rootLayer = new GroupLayerGL(ctx); }