当前位置: 首页>>代码示例>>Java>>正文


Java PixmapTextureData类代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.glutils.PixmapTextureData的典型用法代码示例。如果您正苦于以下问题:Java PixmapTextureData类的具体用法?Java PixmapTextureData怎么用?Java PixmapTextureData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PixmapTextureData类属于com.badlogic.gdx.graphics.glutils包,在下文中一共展示了PixmapTextureData类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PowerLUT

import com.badlogic.gdx.graphics.glutils.PixmapTextureData; //导入依赖的package包/类
/** 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);
}
 
开发者ID:CypherCove,项目名称:DoubleHelix,代码行数:20,代码来源:PowerLUT.java

示例2: loadAsync

import com.badlogic.gdx.graphics.glutils.PixmapTextureData; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:kibertoad,项目名称:swampmachine,代码行数:17,代码来源:HeadlessTextureLoader.java

示例3: generateTextureAtlas

import com.badlogic.gdx.graphics.glutils.PixmapTextureData; //导入依赖的package包/类
/** 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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:28,代码来源:PixmapPacker.java

示例4: generateFontWriteFiles

import com.badlogic.gdx.graphics.glutils.PixmapTextureData; //导入依赖的package包/类
/** 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;
}
 
开发者ID:jrenner,项目名称:gdx-proto,代码行数:32,代码来源:SmartFontGenerator.java

示例5: createPixMapTexture

import com.badlogic.gdx.graphics.glutils.PixmapTextureData; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:cpppwner,项目名称:NoRiskNoFun,代码行数:14,代码来源:LibGdxAssetCache.java

示例6: generateFontWriteFiles

import com.badlogic.gdx.graphics.glutils.PixmapTextureData; //导入依赖的package包/类
/** 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;
}
 
开发者ID:TudorRosca,项目名称:enklave,代码行数:36,代码来源:SmartFontGenerator.java

示例7: generateFontWriteFiles

import com.badlogic.gdx.graphics.glutils.PixmapTextureData; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:Radomiej,项目名称:JavityEngine,代码行数:43,代码来源:SmartFontGenerator.java

示例8: Cubemap

import com.badlogic.gdx.graphics.glutils.PixmapTextureData; //导入依赖的package包/类
/** 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));
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:10,代码来源:Cubemap.java

示例9: create

import com.badlogic.gdx.graphics.glutils.PixmapTextureData; //导入依赖的package包/类
@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");
		}
	});
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:32,代码来源:DownloadTest.java

示例10: generateFontWriteFiles

import com.badlogic.gdx.graphics.glutils.PixmapTextureData; //导入依赖的package包/类
/** 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;
}
 
开发者ID:jrenner,项目名称:gdx-smart-font,代码行数:38,代码来源:SmartFontGenerator.java

示例11: loadRenderModel

import com.badlogic.gdx.graphics.glutils.PixmapTextureData; //导入依赖的package包/类
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;
}
 
开发者ID:justinmarentette11,项目名称:Tower-Defense-Galaxy,代码行数:79,代码来源:VRContext.java

示例12: Texture

import com.badlogic.gdx.graphics.glutils.PixmapTextureData; //导入依赖的package包/类
public Texture (Pixmap pixmap) {
	this(new PixmapTextureData(pixmap, null, false, false));
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:4,代码来源:Texture.java

示例13: Texture

import com.badlogic.gdx.graphics.glutils.PixmapTextureData; //导入依赖的package包/类
public Texture(int paramInt1, int paramInt2, Pixmap.Format paramFormat)
{
  this(new PixmapTextureData(new Pixmap(paramInt1, paramInt2, paramFormat), null, false, true));
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:5,代码来源:Texture.java


注:本文中的com.badlogic.gdx.graphics.glutils.PixmapTextureData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。