com.badlogic.gdx.graphics.TextureData Java Examples

The following examples show how to use com.badlogic.gdx.graphics.TextureData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FacedMultiCubemapData.java    From gdx-gltf with Apache License 2.0 6 votes vote down vote up
@Override
public void consumeCubemapData () {
	for(int level = 0 ; level<levels ; level++){
		for (int i = 0; i < 6; i++) {
			int index = level * 6 + i;
			if (data[index].getType() == TextureData.TextureDataType.Custom) {
				data[index].consumeCustomData(GL20.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i);
			} else {
				Pixmap pixmap = data[index].consumePixmap();
				boolean disposePixmap = data[index].disposePixmap();
				if (data[index].getFormat() != pixmap.getFormat()) {
					Pixmap tmp = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), data[index].getFormat());
					tmp.setBlending(Blending.None);
					tmp.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight());
					if (data[index].disposePixmap()) pixmap.dispose();
					pixmap = tmp;
					disposePixmap = true;
				}
				Gdx.gl.glPixelStorei(GL20.GL_UNPACK_ALIGNMENT, 1);
				Gdx.gl.glTexImage2D(GL20.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, level, pixmap.getGLInternalFormat(), pixmap.getWidth(),
					pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels());
				if (disposePixmap) pixmap.dispose();
			}
		}
	}
}
 
Example #2
Source File: FacedMultiCubemapData.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
/**
 * Construct Cubemap data for MipMap cubemap.
 * @param files texture files in following order : 
 * level 0 (positive X, negative X, positive Y, negative Y, positive Z, negative Z)
 * level 1 (positive X, negative X, positive Y, negative Y, positive Z, negative Z)
 * and so on. Where level 0 is the biggest texture. Expected levels x 6 files.
 * @param levels mipmap levels
 */
public FacedMultiCubemapData(FileHandle[] files, int levels)
{
	this.levels = levels;
	data = new TextureData[6 * levels];
	for(int level = 0 ; level<levels ; level++){
		for(int face = 0 ; face < 6 ; face++){
			int index = level*6+face;
			FileHandle file = files[index];
			data[index] = new PixmapTextureData(new Pixmap(file), null, false, true);
		}
	}
}
 
Example #3
Source File: FacedMultiCubemapData.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
public FacedMultiCubemapData(Pixmap[] pixmaps, int levels)
{
	this.levels = levels;
	data = new TextureData[6 * levels];
	for(int level = 0 ; level<levels ; level++){
		for(int face = 0 ; face < 6 ; face++){
			int index = level*6+face;
			Pixmap pixmap = pixmaps[index];
			data[index] = new PixmapTextureData(pixmap, null, false, true);
		}
	}
}
 
Example #4
Source File: FacedMultiCubemapData.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isManaged () {
	for (TextureData data : this.data)
		if (!data.isManaged()) return false;
	return true;
}
 
Example #5
Source File: FacedMultiCubemapData.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
/** @return The {@link TextureData} for the specified side, can be null if the cubemap is incomplete. */
public TextureData getTextureData (CubemapSide side) {
	return data[side.index];
}
 
Example #6
Source File: AsyncTextureLoader.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
private void startLoadingProcess() {
    new Thread(new Runnable() {
        @Override
        public void run() {
            if (disposed) {
                reportListenerError(null);
                return;
            }

            final TextureData textureData;

            try {
                textureData = TextureData.Factory
                        .loadFromFile(textureFile, Pixmap.Format.RGBA8888, false);

                if (!textureData.isPrepared()) textureData.prepare();
            } catch (Exception e) {
                reportListenerError(e);
                return;
            }

            if (disposed) {
                textureData.disposePixmap();
                reportListenerError(null);
                return;
            }

            Gdx.app.postRunnable(new Runnable() {
                @Override
                public void run() {
                    if (disposed) {
                        textureData.disposePixmap();
                        listener.onTextureLoadFailed(null);
                        return;
                    }

                    Texture texture = new Texture(textureData);
                    texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
                    texture.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge);

                    listener.onTextureLoaded(texture);
                }
            });
        }
    }).start();
}
 
Example #7
Source File: LibgdxTexture.java    From mini2Dx with Apache License 2.0 4 votes vote down vote up
public LibgdxTexture(TextureData data) {
	super(data);
}
 
Example #8
Source File: LibgdxTexture.java    From mini2Dx with Apache License 2.0 4 votes vote down vote up
protected LibgdxTexture(int glTarget, int glHandle, TextureData data) {
	super(glTarget, glHandle, data);
}