public SurfaceGL(GLContext ctx, float width, float height) { super(ctx); this.width = width; this.height = height; this.texWidth = ctx.scale.scaledCeil(width); this.texHeight = ctx.scale.scaledCeil(height); createTexture(); scale(ctx.scale.factor, ctx.scale.factor); }
AndroidCanvasImage(AndroidGraphics gfx, float width, float height, Scale scale) { super(gfx.ctx, Bitmap.createBitmap(scale.scaledCeil(width), scale.scaledCeil(height), gfx.preferredBitmapConfig), scale); this.canvas = new AndroidCanvas(bitmap, width, height); this.canvas.scale(scale.factor, scale.factor); }
AndroidCanvasImage(AndroidGraphics gfx, float width, float height, Scale scale) { super(gfx.ctx, Bitmap.createBitmap(scale.scaledCeil(width), scale.scaledCeil(height), gfx.preferredBitmapConfig), scale); this.canvas = new AndroidCanvas(bitmap, width, height); this.canvas.scale(scale.factor, scale.factor); }
public static HtmlCanvas create(Scale scale, float width, float height) { float sw = scale.scaledCeil(width), sh = scale.scaledCeil(height); HtmlCanvas canvas = new HtmlCanvas(sw, sh); canvas.scale(scale.factor, scale.factor); return canvas; }
JavaCanvasImage(GLContext ctx, float width, float height) { super(ctx, new BufferedImage(ctx.scale.scaledCeil(width), ctx.scale.scaledCeil(height), BufferedImage.TYPE_INT_ARGB_PRE), ctx.scale); Graphics2D gfx = img.createGraphics(); gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); gfx.scale(ctx.scale.factor, ctx.scale.factor); canvas = new JavaCanvas(gfx, width(), height()); }
JavaCanvasImage(GLContext ctx, float width, float height) { super(ctx, new BufferedImage(ctx.scale.scaledCeil(width), ctx.scale.scaledCeil(height), BufferedImage.TYPE_INT_ARGB_PRE), ctx.scale); Graphics2D gfx = img.createGraphics(); gfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); gfx.scale(ctx.scale.factor, ctx.scale.factor); canvas = new JavaCanvas(gfx, width(), height()); }
@Override public void setSize(int width, int height, boolean fullscreen) { int rawWidth = ctx.scale.scaledCeil(width), rawHeight = ctx.scale.scaledCeil(height); platform.comp.setSize(rawWidth, rawHeight); platform.shell.setFullScreen(fullscreen); platform.shell.pack(); }
@Override public void setSize(int width, int height) { int swidth = scale.scaledCeil(width), sheight = scale.scaledCeil(height); super.setSize(swidth, sheight); elem.setWidth(swidth); elem.setHeight(sheight); rootWidth = swidth; rootHeight = sheight; }
@Override public void setSize(int width, int height, boolean fullscreen) { int rawWidth = ctx.scale.scaledCeil(width), rawHeight = ctx.scale.scaledCeil(height); platform.comp.setSize(rawWidth, rawHeight); platform.shell.setFullScreen(fullscreen); platform.shell.pack(); }
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); } }
@Override protected Pattern toSubPattern(AbstractImageGL<?> image, boolean repeatX, boolean repeatY, float x, float y, float width, float height) { assert isReady() : "Cannot generate a pattern from unready image."; // we have to account for the scale factor when extracting our subimage BufferedImage subImage = img.getSubimage( scale.scaledFloor(x), scale.scaledFloor(y), scale.scaledCeil(width), scale.scaledCeil(height)); Rectangle2D rect = new Rectangle2D.Float(0, 0, width, height); return new JavaPattern(image, repeatX, repeatY, new TexturePaint(subImage, rect)); }
@Override protected Pattern toSubPattern(AbstractImageGL<?> image, boolean repeatX, boolean repeatY, float x, float y, float width, float height) { assert isReady() : "Cannot generate a pattern from unready image."; // we have to account for the scale factor when extracting our subimage BufferedImage subImage = img.getSubimage( scale.scaledFloor(x), scale.scaledFloor(y), scale.scaledCeil(width), scale.scaledCeil(height)); Rectangle2D rect = new Rectangle2D.Float(0, 0, width, height); return new JavaPattern(image, repeatX, repeatY, new TexturePaint(subImage, rect)); }
public RoboCanvas(RoboGLContext ctx, float width, float height, boolean interpolate) { super(width, height); // if our size is invalid, we'll fail below at CGBitmapContext, so fail here more usefully if (width <= 0 || height <= 0) throw new IllegalArgumentException( "Invalid size " + width + "x" + height); states.addFirst(new RoboCanvasState()); this.ctx = ctx; // create our raw image data texWidth = ctx.scale.scaledCeil(width); texHeight = ctx.scale.scaledCeil(height); // create the bitmap context via which we'll render into it bctx = RoboGraphics.createCGBitmap(texWidth, texHeight); if (!interpolate) { bctx.setInterpolationQuality(CGInterpolationQuality.None); } // clear the canvas before we scale our bitmap context to avoid artifacts bctx.clearRect(new CGRect(0, 0, texWidth, texHeight)); // CG coordinate system is OpenGL-style (0,0 in lower left); so we flip it bctx.translateCTM(0, ctx.scale.scaled(height)); bctx.scaleCTM(ctx.scale.factor, -ctx.scale.factor); }
public SWTGraphics (SWTPlatform platform, JavaPlatform.Config config, final Composite comp) { super(platform, config); this.platform = platform; // create our GLCanvas GLData data = new GLData (); data.doubleBuffer = true; canvas = new GLCanvas(comp, SWT.NONE, data); makeCurrent(); comp.addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { // resize our GLCanvas to fill the window; we do manual layout so that other SWT widgets // can be overlaid on top of our GLCanvas Rectangle bounds = comp.getBounds(); comp.setBounds(bounds); canvas.setBounds(bounds); makeCurrent(); // SWTGraphics.this.platform.log().info("Resized " + bounds.width + "x" + bounds.height); ctx.setSize(ctx.scale.invScaledFloor(bounds.width), ctx.scale.invScaledFloor(bounds.height)); } }); // platform.log().info("Setting size " + config.width + "x" + config.height); platform.comp.setSize(ctx.scale.scaledCeil(config.width), ctx.scale.scaledCeil(config.height)); platform.shell.pack(); }
public SWTGraphics (SWTPlatform platform, JavaPlatform.Config config, final Composite comp) { super(platform, config); this.platform = platform; // create our GLCanvas GLData data = new GLData (); data.doubleBuffer = true; canvas = new GLCanvas(comp, SWT.NONE, data); makeCurrent(); comp.addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { // resize our GLCanvas to fill the window; we do manual layout so that other SWT widgets // can be overlaid on top of our GLCanvas Rectangle bounds = comp.getBounds(); comp.setBounds(bounds); canvas.setBounds(bounds); makeCurrent(); // SWTGraphics.this.platform.log().info("Resized " + bounds.width + "x" + bounds.height); ctx.setSize(ctx.scale.invScaledFloor(bounds.width), ctx.scale.invScaledFloor(bounds.height)); } }); // platform.log().info("Setting size " + config.width + "x" + config.height); platform.comp.setSize(ctx.scale.scaledCeil(config.width), ctx.scale.scaledCeil(config.height)); platform.shell.pack(); }
private int scaleTexture() { int scaledWidth = scale.scaledCeil(width()); int scaledHeight = scale.scaledCeil(height()); // GL requires pow2 on axes that repeat int width = GLUtil.nextPowerOfTwo(scaledWidth), height = GLUtil.nextPowerOfTwo(scaledHeight); // TODO: if width/height > platform_max_size, repeatedly scale by 0.5 until within bounds // platform_max_size = 1024 for iOS, GL10.GL_MAX_TEXTURE_SIZE on android, etc. // no need to scale if our source data is already a power of two if ((width == 0) && (height == 0)) { int reptex = createPow2RepTex(scaledWidth, scaledHeight, repeatX, repeatY, mipmapped); if (mipmapped) ctx.generateMipmap(reptex); return reptex; } // otherwise we need to scale our non-repeated texture, so load that normally int tex = createMainTex(); // width/height == 0 => already a power of two. if (width == 0) width = scaledWidth; if (height == 0) height = scaledHeight; // create our texture and point a new framebuffer at it try { return convertToRepTex(ctx, tex, width, height, repeatX, repeatY, mipmapped); } finally { // delete the non-repeated texture ctx.destroyTexture(tex); } }
private int scaleTexture() { int scaledWidth = scale().scaledCeil(this.width); int scaledHeight = scale().scaledCeil(this.height);