@Override public void loadAsync (AssetManager manager, String fileName, FileHandle file, TextureParameter parameter) { info.filename = fileName; if (parameter == null || parameter.textureData == null) { Format format = null; boolean genMipMaps = false; info.texture = null; if (parameter != null) { format = parameter.format; genMipMaps = parameter.genMipMaps; info.texture = parameter.texture; } info.data = TextureData.Factory.loadFromFile(file, format, genMipMaps); } else { info.data = parameter.textureData; info.texture = parameter.texture; } if (!info.data.isPrepared()) info.data.prepare(); }
@Override public void loadAsync (AssetManager manager, String fileName, FileHandle file, TextureParameter parameter) { info.filename = fileName; if (parameter == null || parameter.textureData == null) { Format format = null; boolean genMipMaps = false; info.texture = null; if (parameter != null) { format = parameter.format; genMipMaps = parameter.genMipMaps; info.texture = parameter.texture; } info.data = TextureData.Factory.loadFromFile(file, format, genMipMaps); } else { info.data = parameter.textureData; info.texture = parameter.texture; } if (!info.data.isPrepared()) info.data.prepare(); }
@Override public void prepare () { if (!isComplete()) throw new GdxRuntimeException("You need to complete your cubemap data before using it"); for (int i = 0; i < data.length; i++) if (!data[i].isPrepared()) data[i].prepare(); }
@Override public void prepare () { if (!isComplete()) throw new GdxRuntimeException("You need to complete your cubemap data before using it"); for (int i = 0; i < data.length; i++) if (!data[i].isPrepared()) data[i].prepare(); }
@Override public void prepare () { int width = -1; int height = -1; for (TextureData data : textureDatas) { data.prepare(); if (width == -1) { width = data.getWidth(); height = data.getHeight(); continue; } if (width != data.getWidth() || height != data.getHeight()) { throw new GdxRuntimeException("Error whilst preparing TextureArray: TextureArray Textures must have equal dimensions."); } } prepared = true; }
@Override public void prepare () { int width = -1; int height = -1; for (TextureData data : textureDatas) { data.prepare(); if (width == -1) { width = data.getWidth(); height = data.getHeight(); continue; } if (width != data.getWidth() || height != data.getHeight()) { throw new GdxRuntimeException("Error whilst preparing TextureArray: TextureArray Textures must have equal dimensions."); } } prepared = true; }
public void load (TextureData data) { if (this.data != null && data.isManaged() != this.data.isManaged()) throw new GdxRuntimeException("New data must have the same managed status as the old data"); this.data = data; if (!data.isPrepared()) data.prepare(); bind(); uploadImageData(GL20.GL_TEXTURE_2D, data); unsafeSetFilter(minFilter, magFilter, true); unsafeSetWrap(uWrap, vWrap, true); Gdx.gl.glBindTexture(glTarget, 0); }
public void load (TextureData data) { if (this.data != null && data.isManaged() != this.data.isManaged()) throw new GdxRuntimeException("New data must have the same managed status as the old data"); this.data = data; if (!data.isPrepared()) data.prepare(); bind(); uploadImageData(GL20.GL_TEXTURE_2D, data); unsafeSetFilter(minFilter, magFilter, true); unsafeSetWrap(uWrap, vWrap, true); Gdx.gl.glBindTexture(glTarget, 0); }
if (!data.isPrepared()) data.prepare();
if (!data.isPrepared()) data.prepare();
TextureData textureData = texture.getTextureData(); textureData.prepare(); Pixmap pixmap = textureData.consumePixmap();
@Override public void loadAsync (AssetManager manager, String fileName, FileHandle file, TextureParameter parameter) { info.filename = fileName; if (parameter == null || parameter.textureData == null) { Pixmap pixmap = null; Format format = null; boolean genMipMaps = false; info.texture = null; if (parameter != null) { format = parameter.format; genMipMaps = parameter.genMipMaps; info.texture = parameter.texture; } info.data = TextureData.Factory.loadFromFile(file, format, genMipMaps); } else { info.data = parameter.textureData; info.texture = parameter.texture; } if (!info.data.isPrepared()) info.data.prepare(); }
@Override public void prepare () { if (!isComplete()) throw new GdxRuntimeException("You need to complete your cubemap data before using it"); for (int i = 0; i < data.length; i++) if (!data[i].isPrepared()) data[i].prepare(); }
@Override public void prepare () { int width = -1; int height = -1; for (TextureData data : textureDatas) { data.prepare(); if (width == -1) { width = data.getWidth(); height = data.getHeight(); continue; } if (width != data.getWidth() || height != data.getHeight()) { throw new GdxRuntimeException("Error whilst preparing TextureArray: TextureArray Textures must have equal dimensions."); } } prepared = true; }
.loadFromFile(textureFile, Pixmap.Format.RGBA8888, false); if (!textureData.isPrepared()) textureData.prepare(); } catch (Exception e) { reportListenerError(e);
public void load (TextureData data) { if (this.data != null && data.isManaged() != this.data.isManaged()) throw new GdxRuntimeException("New data must have the same managed status as the old data"); this.data = data; if (!data.isPrepared()) data.prepare(); bind(); uploadImageData(GL20.GL_TEXTURE_2D, data); unsafeSetFilter(minFilter, magFilter, true); unsafeSetWrap(uWrap, vWrap, true); Gdx.gl.glBindTexture(glTarget, 0); }
textureData.prepare();
/** * Calculates the average color of a texture region. * * @param region The texture region * @return The average color */ public static Color getAverageColorFor(TextureRegion region) { region.getTexture().getTextureData().prepare(); final Pixmap pixmap = region.getTexture().getTextureData().consumePixmap(); float total = region.getRegionHeight() * region.getRegionWidth(); float r = 0, g = 0, b = 0; for (int y = region.getRegionY(), yMax = region.getRegionY() + region.getRegionHeight(); y < yMax; y++) { for (int x = region.getRegionX(), xMax = region.getRegionX() + region.getRegionWidth(); x < xMax; x++) { int pixel = pixmap.getPixel(x, y); // Ignore certain alpha colors if (((pixel & 0x000000ff)) / 255f < 0.0625f) { total--; continue; } r += ((pixel & 0xff000000) >>> 24) / 255f; g += ((pixel & 0x00ff0000) >>> 16) / 255f; b += ((pixel & 0x0000ff00) >>> 8) / 255f; } } if (region.getTexture().getTextureData().disposePixmap()) { pixmap.dispose(); } return new Color(r / total, g / total, b / total, 1f); }
if (!data.isPrepared()) data.prepare();