Search in sources :

Example 1 with TextureData

use of com.badlogic.gdx.graphics.TextureData in project libgdx by libgdx.

the class FileTextureArrayData method consumeTextureArrayData.

@Override
public void consumeTextureArrayData() {
    for (int i = 0; i < textureDatas.length; i++) {
        if (textureDatas[i].getType() == TextureData.TextureDataType.Custom) {
            textureDatas[i].consumeCustomData(GL30.GL_TEXTURE_2D_ARRAY);
        } else {
            TextureData texData = textureDatas[i];
            Pixmap pixmap = texData.consumePixmap();
            boolean disposePixmap = texData.disposePixmap();
            if (texData.getFormat() != pixmap.getFormat()) {
                Pixmap temp = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), texData.getFormat());
                temp.setBlending(Pixmap.Blending.None);
                temp.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight());
                if (texData.disposePixmap()) {
                    pixmap.dispose();
                }
                pixmap = temp;
                disposePixmap = true;
            }
            Gdx.gl30.glTexSubImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, 0, 0, i, pixmap.getWidth(), pixmap.getHeight(), 1, pixmap.getGLInternalFormat(), pixmap.getGLType(), pixmap.getPixels());
            if (disposePixmap)
                pixmap.dispose();
        }
    }
}
Also used : TextureData(com.badlogic.gdx.graphics.TextureData) Pixmap(com.badlogic.gdx.graphics.Pixmap)

Example 2 with TextureData

use of com.badlogic.gdx.graphics.TextureData in project libgdx by libgdx.

the class FileTextureArrayData method 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;
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) TextureData(com.badlogic.gdx.graphics.TextureData)

Example 3 with TextureData

use of com.badlogic.gdx.graphics.TextureData in project commons-gdx by gemserk.

the class GpuMemUtils method getFilePath.

private static String getFilePath(Texture texture) {
    String path = null;
    TextureData textureData = texture.getTextureData();
    if (textureData instanceof FileTextureData) {
        FileTextureData fileTextureData = (FileTextureData) textureData;
        path = fileTextureData.getFileHandle().path();
    }
    return path;
}
Also used : FileTextureData(com.badlogic.gdx.graphics.glutils.FileTextureData) TextureData(com.badlogic.gdx.graphics.TextureData) FileTextureData(com.badlogic.gdx.graphics.glutils.FileTextureData)

Aggregations

TextureData (com.badlogic.gdx.graphics.TextureData)3 Pixmap (com.badlogic.gdx.graphics.Pixmap)1 FileTextureData (com.badlogic.gdx.graphics.glutils.FileTextureData)1 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)1