Search in sources :

Example 1 with Format

use of com.badlogic.gdx.graphics.Pixmap.Format in project libgdx by libgdx.

the class CubemapLoader method loadAsync.

@Override
public void loadAsync(AssetManager manager, String fileName, FileHandle file, CubemapParameter parameter) {
    info.filename = fileName;
    if (parameter == null || parameter.cubemapData == null) {
        Pixmap pixmap = null;
        Format format = null;
        boolean genMipMaps = false;
        info.cubemap = null;
        if (parameter != null) {
            format = parameter.format;
            info.cubemap = parameter.cubemap;
        }
        if (fileName.contains(".ktx") || fileName.contains(".zktx")) {
            info.data = new KTXTextureData(file, genMipMaps);
        }
    } else {
        info.data = parameter.cubemapData;
        info.cubemap = parameter.cubemap;
    }
    if (!info.data.isPrepared())
        info.data.prepare();
}
Also used : Format(com.badlogic.gdx.graphics.Pixmap.Format) KTXTextureData(com.badlogic.gdx.graphics.glutils.KTXTextureData) Pixmap(com.badlogic.gdx.graphics.Pixmap)

Example 2 with Format

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

the class GpuMemUtils method getTextureGpuSize.

public static GpuMemInfo getTextureGpuSize() {
    try {
        List<Texture> managedTextures = getTextures();
        int totalTextureSize = 0;
        for (Texture texture : managedTextures) {
            int width = texture.getWidth();
            int height = texture.getHeight();
            Format format = texture.getTextureData().getFormat();
            boolean useMipMaps = texture.getTextureData().useMipMaps();
            int bytesPerPixel = getBytesPerPixel(format);
            int textureSize = (int) (width * height * bytesPerPixel * (useMipMaps ? 1.33333f : 1));
            totalTextureSize += textureSize;
        }
        GpuMemInfo gpuMemInfo = new GpuMemInfo();
        gpuMemInfo.totalTextures = managedTextures.size();
        gpuMemInfo.gpuMemSize = totalTextureSize;
        return gpuMemInfo;
    } catch (Exception e) {
        throw new RuntimeException("Error while getting textures gpu memory use", e);
    }
}
Also used : Format(com.badlogic.gdx.graphics.Pixmap.Format) Texture(com.badlogic.gdx.graphics.Texture)

Example 3 with Format

use of com.badlogic.gdx.graphics.Pixmap.Format in project libgdx by libgdx.

the class TextureLoader method loadAsync.

@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();
}
Also used : Format(com.badlogic.gdx.graphics.Pixmap.Format) Pixmap(com.badlogic.gdx.graphics.Pixmap)

Aggregations

Format (com.badlogic.gdx.graphics.Pixmap.Format)3 Pixmap (com.badlogic.gdx.graphics.Pixmap)2 Texture (com.badlogic.gdx.graphics.Texture)1 KTXTextureData (com.badlogic.gdx.graphics.glutils.KTXTextureData)1