Java 类com.badlogic.gdx.graphics.glutils.PixmapTextureData 实例源码

项目:DoubleHelix    文件:PowerLUT.java   
/** W power will be in luminance, and H power will be in alpha**/
public PowerLUT(float powerW, float intensityW, float powerH, float intensityH, int width, int height){

    Pixmap pixmap = new Pixmap(width, height, Format.RGBA8888);
    for (int i=0; i<width; i++){
        float valueW = (float)Math.pow((float)i/width, powerW) * intensityW;
           for (int j = 0; j < height; j++) {
               float valueH = (float)Math.pow((float)j/height, powerH) * intensityH;
               pixmap.setColor(valueW, valueH, 1.0f, 1.0f);
               pixmap.drawPixel(i, j);
           }
    }

    PixmapTextureData data = new PixmapTextureData(pixmap, Format.RGBA8888, false, false, true);

    texture = new Texture(data);
    texture.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
}
项目:swampmachine    文件:HeadlessTextureLoader.java   
@Override
public void loadAsync(AssetManager manager, String fileName, FileHandle file, TextureParameter parameter) {
    info.filename = fileName;
    if (parameter == null || parameter.textureData == null) {
        info.texture = null;

        if (parameter != null) {
            info.texture = parameter.texture;
        }

        info.data = new PixmapTextureData(null, Format.RGB565, false, false);
    } else {
        info.data = parameter.textureData;
        info.texture = parameter.texture;
    }
}
项目:libgdxcn    文件:PixmapPacker.java   
/** Generates a new {@link TextureAtlas} from the {@link Pixmap} instances inserted so far.
 * @param minFilter
 * @param magFilter
 * @return the TextureAtlas */
public synchronized TextureAtlas generateTextureAtlas (TextureFilter minFilter, TextureFilter magFilter, boolean useMipMaps) {
    TextureAtlas atlas = new TextureAtlas();
    for (Page page : pages) {
        if (page.rects.size != 0) {
            Texture texture = new Texture(new PixmapTextureData(page.image, page.image.getFormat(), useMipMaps, false, true)) {
                @Override
                public void dispose () {
                    super.dispose();
                    getTextureData().consumePixmap().dispose();
                }
            };
            texture.setFilter(minFilter, magFilter);

            Keys<String> names = page.rects.keys();
            for (String name : names) {
                Rectangle rect = page.rects.get(name);
                TextureRegion region = new TextureRegion(texture, (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
                atlas.addRegion(name, region);
            }
        }
    }
    return atlas;
}
项目:gdx-proto    文件:SmartFontGenerator.java   
/** Convenience method for generating a font, and then writing the fnt and png files.
 * Writing a generated font to files allows the possibility of only generating the fonts when they are missing, otherwise
 * loading from a previously generated file.
 * @param fontFile
 * @param fontSize
 */
private BitmapFont generateFontWriteFiles(String fontName, FileHandle fontFile, int fontSize, int pageWidth, int pageHeight) {
    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);

    PixmapPacker packer = new PixmapPacker(pageWidth, pageHeight, Pixmap.Format.RGBA8888, 2, false);
    FreeTypeFontGenerator.FreeTypeBitmapFontData fontData = generator.generateData(fontSize, FreeTypeFontGenerator.DEFAULT_CHARS, false, packer);
    Array<PixmapPacker.Page> pages = packer.getPages();
    TextureRegion[] texRegions = new TextureRegion[pages.size];
    for (int i=0; i<pages.size; i++) {
        PixmapPacker.Page p = pages.get(i);
        Texture tex = new Texture(new PixmapTextureData(p.getPixmap(), p.getPixmap().getFormat(), false, false, true)) {
            @Override
            public void dispose () {
                super.dispose();
                getTextureData().consumePixmap().dispose();
            }
        };
        tex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
        texRegions[i] = new TextureRegion(tex);
    }
    BitmapFont font = new BitmapFont(fontData, texRegions, false);
    saveFontToFile(font, fontSize, fontName, packer);
    generator.dispose();
    packer.dispose();
    return font;
}
项目:NoRiskNoFun    文件:LibGdxAssetCache.java   
/**
 * Create 1x1 pixel pixmap texture for given color.
 * @param color The color used to fill the texture with.
 * @return Newly created pixmap texture.
 */
private static Texture createPixMapTexture(Color color) {

    Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
    pixmap.setColor(color);
    pixmap.fill();

    return new Texture(new PixmapTextureData(pixmap, null, false, true));
}
项目:enklave    文件:SmartFontGenerator.java   
/** Convenience method for generating a font, and then writing the fnt and png files.
 * Writing a generated font to files allows the possibility of only generating the fonts when they are missing, otherwise
 * loading from a previously generated file.
 * @param fontFile
 * @param fontSize
 */
private BitmapFont generateFontWriteFiles(String fontName, FileHandle fontFile, int fontSize, int pageWidth, int pageHeight) {
    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);

    PixmapPacker packer = new PixmapPacker(pageWidth, pageHeight, Pixmap.Format.RGBA8888, 2, false);
    FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.size = fontSize;
    parameter.characters = FreeTypeFontGenerator.DEFAULT_CHARS;
    parameter.packer = packer;
    FreeTypeFontGenerator.FreeTypeBitmapFontData fontData = generator.generateData(parameter);//(fontSize, FreeTypeFontGenerator.DEFAULT_CHARS, false, packer);
    Array<PixmapPacker.Page> pages = packer.getPages();
    Array<TextureRegion> texRegions = new Array<TextureRegion>(pageSize);
    for (int i=0; i<pages.size; i++) {
        PixmapPacker.Page p = pages.get(i);
        Texture tex = new Texture(new PixmapTextureData(p.getPixmap(), p.getPixmap().getFormat(), false, false, true)) {
            @Override
            public void dispose () {
                super.dispose();
                getTextureData().consumePixmap().dispose();
            }
        };
        tex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
        texRegions.add(new TextureRegion(tex));
    }
    BitmapFont font = new BitmapFont(fontData,texRegions,false); //fontData, texRegions, false);
    saveFontToFile(font, fontSize, fontName, packer);
    generator.dispose();
    packer.dispose();
    return font;
}
项目:JavityEngine    文件:SmartFontGenerator.java   
/**
 * Convenience method for generating a font, and then writing the fnt and
 * png files. Writing a generated font to files allows the possibility of
 * only generating the fonts when they are missing, otherwise loading from a
 * previously generated file.
 * 
 * @param fontFile
 * @param fontSize
 */
private BitmapFont generateFontWriteFiles(String fontName, FileHandle fontFile, int fontSize, int pageWidth,
        int pageHeight) {
    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);

    PixmapPacker packer = new PixmapPacker(pageWidth, pageHeight, Pixmap.Format.RGBA8888, 2, false);

    FreeTypeFontParameter freeTypeFontParameter = new FreeTypeFontParameter();
    freeTypeFontParameter.size = fontSize;
    freeTypeFontParameter.packer = packer;

    FreeTypeFontGenerator.FreeTypeBitmapFontData fontData = generator.generateData(freeTypeFontParameter);
    Array<PixmapPacker.Page> pages = packer.getPages();
    Array<TextureRegion> texRegions = new Array<TextureRegion>();
    for (int i = 0; i < pages.size; i++) {
        PixmapPacker.Page p = pages.get(i);
        Texture tex = new Texture(
                new PixmapTextureData(p.getPixmap(), p.getPixmap().getFormat(), false, false, true)) {
            @Override
            public void dispose() {
                super.dispose();
                getTextureData().consumePixmap().dispose();
            }
        };
        tex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
        texRegions.add(new TextureRegion(tex));
    }

    BitmapFont font = new BitmapFont(fontData, texRegions, false);
    saveFontToFile(font, fontSize, fontName, packer);
    generator.dispose();
    packer.dispose();
    return font;
}
项目:libgdxcn    文件:Cubemap.java   
/** Construct a Cubemap with the specified {@link Pixmap}s for the sides, optionally generating mipmaps. */
public Cubemap (Pixmap positiveX, Pixmap negativeX, Pixmap positiveY, Pixmap negativeY, Pixmap positiveZ, Pixmap negativeZ,
    boolean useMipMaps) {
    this(positiveX == null ? null : new PixmapTextureData(positiveX, null, useMipMaps, false), negativeX == null ? null
        : new PixmapTextureData(negativeX, null, useMipMaps, false), positiveY == null ? null : new PixmapTextureData(positiveY,
        null, useMipMaps, false), negativeY == null ? null : new PixmapTextureData(negativeY, null, useMipMaps, false),
        positiveZ == null ? null : new PixmapTextureData(positiveZ, null, useMipMaps, false), negativeZ == null ? null
            : new PixmapTextureData(negativeZ, null, useMipMaps, false));
}
项目:libgdxcn    文件:Cubemap.java   
/** Construct a Cubemap with {@link Pixmap}s for each side of the specified size. */
public Cubemap (int width, int height, int depth, Format format) {
    this(new PixmapTextureData(new Pixmap(depth, height, format), null, false, true), new PixmapTextureData(new Pixmap(depth,
        height, format), null, false, true), new PixmapTextureData(new Pixmap(width, depth, format), null, false, true),
        new PixmapTextureData(new Pixmap(width, depth, format), null, false, true), new PixmapTextureData(new Pixmap(width,
            height, format), null, false, true), new PixmapTextureData(new Pixmap(width, height, format), null, false, true));
}
项目:libgdxcn    文件:DownloadTest.java   
@Override
public void create () {
    batch = new SpriteBatch();
    HttpRequest request = new HttpRequest(HttpMethods.GET);
    request.setUrl("https://www.google.at/images/srpr/logo11w.png");
    Gdx.net.sendHttpRequest(request, new HttpResponseListener() {
        @Override
        public void handleHttpResponse (HttpResponse httpResponse) {
            final byte[] bytes = httpResponse.getResult();

            Gdx.app.postRunnable(new Runnable() {
                @Override
                public void run () {
                    Pixmap pixmap = new Pixmap(bytes, 0, bytes.length);
                    texture = new Texture(new PixmapTextureData(pixmap, pixmap.getFormat(), false, false, true));   
                }
            });     
        }

        @Override
        public void failed (Throwable t) {
            t.printStackTrace();
            Gdx.app.log("EmptyDownloadTest", "Failed", t);
        }

        @Override
        public void cancelled () {
            Gdx.app.log("EmptyDownloadTest", "Cancelled");
        }
    });
}
项目:gdx-smart-font    文件:SmartFontGenerator.java   
/** Convenience method for generating a font, and then writing the fnt and png files.
 * Writing a generated font to files allows the possibility of only generating the fonts when they are missing, otherwise
 * loading from a previously generated file.
 * @param fontFile
 * @param fontSize
 */
private BitmapFont generateFontWriteFiles(String fontName, FileHandle fontFile, int fontSize, int pageWidth, int pageHeight) {
    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);

    PixmapPacker packer = new PixmapPacker(pageWidth, pageHeight, Pixmap.Format.RGBA8888, 2, false);
    FreeTypeFontParameter parameter = new FreeTypeFontParameter();
    parameter.size = fontSize;
    parameter.characters = FreeTypeFontGenerator.DEFAULT_CHARS;
    parameter.flip = false;
    parameter.packer = packer;
    FreeTypeFontGenerator.FreeTypeBitmapFontData fontData = generator.generateData(parameter);
    Array<PixmapPacker.Page> pages = packer.getPages();
    Array<TextureRegion> texRegions = new Array<>();
    for (int i = 0; i < pages.size; i++) {
        PixmapPacker.Page p = pages.get(i);
        Texture tex = new Texture(
                new PixmapTextureData(p.getPixmap(), p.getPixmap().getFormat(), false, false, true)) {
            @Override
            public void dispose() {
                super.dispose();
                getTextureData().consumePixmap().dispose();
            }
        };
        tex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
        texRegions.add(new TextureRegion(tex));
    }
    BitmapFont font = new BitmapFont((BitmapFont.BitmapFontData) fontData, texRegions, false);
    saveFontToFile(font, fontSize, fontName, packer);
    generator.dispose();
    packer.dispose();
    return font;
}
项目:Tower-Defense-Galaxy    文件:VRContext.java   
private Model loadRenderModel(String name) {
    if (models.containsKey(name)) return models.get(name);                      

    // FIXME we load the models synchronously cause we are lazy
    int error = 0;
    PointerBuffer modelPointer = PointerBuffer.allocateDirect(1);
    while (true) {
        error = VRRenderModels.VRRenderModels_LoadRenderModel_Async(name, modelPointer);
        if (error != VR.EVRRenderModelError_VRRenderModelError_Loading) break;
    }

    if (error != VR.EVRRenderModelError_VRRenderModelError_None) return null;       
    RenderModel renderModel = new RenderModel(modelPointer.getByteBuffer(RenderModel.SIZEOF));

    error = 0;
    PointerBuffer texturePointer = PointerBuffer.allocateDirect(1);
    while (true) {
        error = VRRenderModels.VRRenderModels_LoadTexture_Async(renderModel.diffuseTextureId(), texturePointer);
        if (error != VR.EVRRenderModelError_VRRenderModelError_Loading) break;
    }

    if (error != VR.EVRRenderModelError_VRRenderModelError_None) {
        VRRenderModels.VRRenderModels_FreeRenderModel(renderModel);
        return null;
    }

    RenderModelTextureMap renderModelTexture = new RenderModelTextureMap(texturePointer.getByteBuffer(RenderModelTextureMap.SIZEOF));

    // convert to a Model               
    Mesh mesh = new Mesh(true, renderModel.unVertexCount(), renderModel.unTriangleCount() * 3, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.TexCoords(0));
    MeshPart meshPart = new MeshPart(name, mesh, 0, renderModel.unTriangleCount() * 3, GL20.GL_TRIANGLES);
    RenderModelVertex.Buffer vertices = renderModel.rVertexData();
    float[] packedVertices = new float[8 * renderModel.unVertexCount()];
    int i = 0;
    while(vertices.remaining() > 0) {
        RenderModelVertex v = vertices.get();           
        packedVertices[i++] = v.vPosition().v(0);
        packedVertices[i++] = v.vPosition().v(1);
        packedVertices[i++] = v.vPosition().v(2);

        packedVertices[i++] = v.vNormal().v(0);
        packedVertices[i++] = v.vNormal().v(1);
        packedVertices[i++] = v.vNormal().v(2);

        packedVertices[i++] = v.rfTextureCoord().get(0);
        packedVertices[i++] = v.rfTextureCoord().get(1);
    }
    mesh.setVertices(packedVertices);
    short[] indices = new short[renderModel.unTriangleCount() * 3];
    renderModel.IndexData().get(indices);       
    mesh.setIndices(indices);

    Pixmap pixmap = new Pixmap(renderModelTexture.unWidth(), renderModelTexture.unHeight(), Format.RGBA8888);
    byte[] pixels = new byte[renderModelTexture.unWidth() * renderModelTexture.unHeight() * 4];
    renderModelTexture.rubTextureMapData(pixels.length).get(pixels);
    pixmap.getPixels().put(pixels);
    pixmap.getPixels().position(0);
    Texture texture = new Texture(new PixmapTextureData(pixmap, pixmap.getFormat(), true, true));
    Material material = new Material(new TextureAttribute(TextureAttribute.Diffuse, texture));      

    Model model = new Model();
    model.meshes.add(mesh);
    model.meshParts.add(meshPart);
    model.materials.add(material);
    Node node = new Node();
    node.id = name;     
    node.parts.add(new NodePart(meshPart, material));
    model.nodes.add(node);
    model.manageDisposable(mesh);
    model.manageDisposable(texture);

    VRRenderModels.VRRenderModels_FreeRenderModel(renderModel);
    VRRenderModels.VRRenderModels_FreeTexture(renderModelTexture);

    models.put(name, model);

    return model;
}
项目:libgdxcn    文件:Texture.java   
public Texture (Pixmap pixmap) {
    this(new PixmapTextureData(pixmap, null, false, false));
}
项目:libgdxcn    文件:Texture.java   
public Texture (Pixmap pixmap, boolean useMipMaps) {
    this(new PixmapTextureData(pixmap, null, useMipMaps, false));
}
项目:libgdxcn    文件:Texture.java   
public Texture (Pixmap pixmap, Format format, boolean useMipMaps) {
    this(new PixmapTextureData(pixmap, format, useMipMaps, false));
}
项目:libgdxcn    文件:Texture.java   
public Texture (int width, int height, Format format) {
    this(new PixmapTextureData(new Pixmap(width, height, format), null, false, true));
}
项目:ingress-indonesia-dev    文件:Texture.java   
public Texture(int paramInt1, int paramInt2, Pixmap.Format paramFormat)
{
  this(new PixmapTextureData(new Pixmap(paramInt1, paramInt2, paramFormat), null, false, true));
}
项目:ingress-indonesia-dev    文件:Texture.java   
public Texture(Pixmap paramPixmap)
{
  this(new PixmapTextureData(paramPixmap, null, false, false));
}
项目:ingress-indonesia-dev    文件:Texture.java   
public Texture(Pixmap paramPixmap, Pixmap.Format paramFormat, boolean paramBoolean)
{
  this(new PixmapTextureData(paramPixmap, paramFormat, paramBoolean, false));
}
项目:ingress-indonesia-dev    文件:Texture.java   
public Texture(Pixmap paramPixmap, boolean paramBoolean)
{
  this(new PixmapTextureData(paramPixmap, null, paramBoolean, false));
}