/** A helper function for creating a texture from this canvas's image, and then disposing this * canvas. This is useful for situations where you create a canvas, draw something in it, turn * it into a texture and then never use the canvas again. */ public Texture toTexture (Texture.Config config) { try { return image.createTexture(config); } finally { close(); } }
/** A helper function for creating a texture from this canvas's image, and then disposing this * canvas. This is useful for situations where you create a canvas, draw something in it, turn * it into a texture and then never use the canvas again. */ public Texture toTexture (Texture.Config config) { try { return image.createTexture(config); } finally { close(); } }
/** * Returns, creating if necessary, this image's default texture. When the texture is created, it * will use the {@link Texture.Config} set via {@link #setConfig}. If an image's default texture * is {@link Texture#close}d, a subsequent call to this method will create a new default texture. */ public Texture texture () { if (texture == null || texture.disposed()) texture = createTexture(texconf); return texture; }
/** * Returns, creating if necessary, this image's default texture. When the texture is created, it * will use the {@link Texture.Config} set via {@link #setConfig}. If an image's default texture * is {@link Texture#close}d, a subsequent call to this method will create a new default texture. */ public Texture texture () { if (texture == null || texture.disposed()) texture = createTexture(texconf); return texture; }
/** * Creates a canvas layer with the supplied backing canvas. The canvas will immediately be * uploaded to the GPU for display. */ public CanvasLayer (Graphics gfx, Canvas canvas) { this.gfx = gfx; this.canvas = canvas; super.setTile(canvas.image.createTexture(Texture.Config.DEFAULT)); }
/** * Updates this image's default texture with the current contents of the image, and returns the * texture. If the texture has not yet been created, then this simply creates it. This is only * necessary if you want to update the default texture for an image associated with a {@link * Canvas}, or if you have used {@link #setRgb} to change the contents of this image. */ public Texture updateTexture () { if (texture == null || texture.disposed()) texture = createTexture(texconf); else texture.update(this); return texture; }
/** * Updates this image's default texture with the current contents of the image, and returns the * texture. If the texture has not yet been created, then this simply creates it. This is only * necessary if you want to update the default texture for an image associated with a {@link * Canvas}, or if you have used {@link #setRgb} to change the contents of this image. */ public Texture updateTexture () { if (texture == null || texture.disposed()) texture = createTexture(texconf); else texture.update(this); return texture; }
/** Informs this layer that a drawing operation has just completed. The backing canvas image data * is uploaded to the GPU. */ public void end () { Texture tex = (Texture)tile(); Image image = canvas.image; // if our texture is already the right size, just update it if (tex != null && tex.pixelWidth == image.pixelWidth() && tex.pixelHeight == image.pixelHeight()) tex.update(image); // otherwise we need to create a new texture (setTexture will unreference the old texture which // will cause it to be destroyed) else super.setTile(canvas.image.createTexture(Texture.Config.DEFAULT)); }
player1.setOrigin(phwidth, phheight); game.rootLayer.addAt(player1, 100, 100); ImageLayer player2 = new ImageLayer(princess.createTexture(MIPMAPPED)); player2.setOrigin(phwidth, phheight); game.rootLayer.addAt(player2, 250, 100); slayer1.setOrigin(shwidth, shheight); game.rootLayer.addAt(slayer1, 100, 250); ImageLayer slayer2 = new ImageLayer(star.createTexture(MIPMAPPED)); slayer2.setOrigin(shwidth, shheight); game.rootLayer.addAt(slayer2, 250, 250);
protected void addTests (final Image orange, Image tile) { final Texture otex = orange.texture(); final Texture ttex = tile.createTexture(Texture.Config.DEFAULT.repeat(true, true));