com.badlogic.gdx.graphics.glutils.PixmapTextureData Java Examples

The following examples show how to use com.badlogic.gdx.graphics.glutils.PixmapTextureData. 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: DC6.java    From riiablo with Apache License 2.0 6 votes vote down vote up
@Override
public void loadDirection(int d, boolean combineFrames) {
  if (textures == null) textures = new Texture[header.directions][];
  else if (textures[d] != null) return;
  preloadDirection(d, combineFrames);

  Pixmap[] pixmaps = this.pixmaps[d];
  textures[d] = new Texture[pixmaps.length];
  for (int p = 0; p < pixmaps.length; p++) {
    Pixmap pixmap = pixmaps[p];
    Texture texture = new Texture(new PixmapTextureData(pixmap, null, false, false, false));
    //texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    texture.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge);
    textures[d][p] = texture;
  }

  regions[d] = new TextureRegion[pixmaps.length];
  for (int p = 0; p < pixmaps.length; p++) {
    regions[d][p] = new TextureRegion(textures[d][p]);
  }
}
 
Example #2
Source File: DCC.java    From riiablo with Apache License 2.0 6 votes vote down vote up
@Override
public void loadDirection(int d, boolean combineFrames) {
  if (textures == null) textures = new Texture[header.directions][];
  else if (textures[d] != null) return;
  preloadDirection(d);

  textures[d] = new Texture[header.framesPerDir];
  for (int f = 0; f < header.framesPerDir; f++) {
    Pixmap pixmap = frames[d][f].pixmap;
    Texture texture = new Texture(new PixmapTextureData(pixmap, null, false, false, false));
    //texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    texture.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge);
    textures[d][f] = texture;
  }

  regions[d] = new TextureRegion[header.framesPerDir];
  for (int f = 0; f < header.framesPerDir; f++) {
    regions[d][f] = new TextureRegion(textures[d][f]);
  }
}
 
Example #3
Source File: SmartFontGenerator.java    From gdx-proto with Apache License 2.0 6 votes vote down vote up
/** 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;
}
 
Example #4
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 #5
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 #6
Source File: DT1.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public void prepareTextures() {
  if (!loadData) return;
  Validate.validState(textures == null, "textures have already been prepared");
  textures = new Texture[header.numTiles];
  for (int i = 0; i < header.numTiles; i++) {
    Texture texture = new Texture(new PixmapTextureData(tiles[i].pixmap, null, false, false, false));
    //texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    texture.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge);
    tiles[i].texture = new TextureRegion(textures[i] = texture);
  }
}
 
Example #7
Source File: SmartFontGenerator.java    From gdx-smart-font with MIT License 5 votes vote down vote up
/** 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;
}
 
Example #8
Source File: FontTBL.java    From riiablo with Apache License 2.0 4 votes vote down vote up
public BitmapFont(FontTBL.BitmapFontData data) {
  super(data, new TextureRegion(new Texture(new PixmapTextureData(data.fontSheet, null, false, true, false))), true);
  blendMode = data.blendMode;
  setOwnsTexture(true);
}