/** * 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)); }
/** * Creates a texture with this image's bitmap data using {@code config}. NOTE: this creates a new * texture with every call. This is generally only needed if you plan to create multiple textures * from the same bitmap, with different configurations. Otherwise just use {@link #texture} to * create the image's "default" texture which will be shared by all callers. */ public Texture createTexture (Texture.Config config) { if (!isLoaded()) throw new IllegalStateException( "Cannot create texture from unready image: " + this); int texWidth = config.toTexWidth(pixelWidth()); int texHeight = config.toTexHeight(pixelHeight()); if (texWidth <= 0 || texHeight <= 0) throw new IllegalArgumentException( "Invalid texture size: " + texWidth + "x" + texHeight + " from: " + this); Texture tex = new Texture(gfx, gfx.createTexture(config), config, texWidth, texHeight, scale(), width(), height()); tex.update(this); // this will handle non-POT source image conversion return tex; }
/** * Creates a texture with this image's bitmap data using {@code config}. NOTE: this creates a new * texture with every call. This is generally only needed if you plan to create multiple textures * from the same bitmap, with different configurations. Otherwise just use {@link #texture} to * create the image's "default" texture which will be shared by all callers. */ public Texture createTexture (Texture.Config config) { if (!isLoaded()) throw new IllegalStateException( "Cannot create texture from unready image: " + this); int texWidth = config.toTexWidth(pixelWidth()); int texHeight = config.toTexHeight(pixelHeight()); if (texWidth <= 0 || texHeight <= 0) throw new IllegalArgumentException( "Invalid texture size: " + texWidth + "x" + texHeight + " from: " + this); Texture tex = new Texture(gfx, gfx.createTexture(config), config, texWidth, texHeight, scale(), width(), height()); tex.update(this); // this will handle non-POT source image conversion return tex; }