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


Java BufferUtils.newUnsafeByteBuffer方法代码示例

本文整理汇总了Java中com.badlogic.gdx.utils.BufferUtils.newUnsafeByteBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java BufferUtils.newUnsafeByteBuffer方法的具体用法?Java BufferUtils.newUnsafeByteBuffer怎么用?Java BufferUtils.newUnsafeByteBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.utils.BufferUtils的用法示例。


在下文中一共展示了BufferUtils.newUnsafeByteBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ETC1Data

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
public ETC1Data (FileHandle pkmFile) {
	byte[] buffer = new byte[1024 * 10];
	DataInputStream in = null;
	try {
		in = new DataInputStream(new BufferedInputStream(new GZIPInputStream(pkmFile.read())));
		int fileSize = in.readInt();
		compressedData = BufferUtils.newUnsafeByteBuffer(fileSize);
		int readBytes = 0;
		while ((readBytes = in.read(buffer)) != -1) {
			compressedData.put(buffer, 0, readBytes);
		}
		compressedData.position(0);
		compressedData.limit(compressedData.capacity());
	} catch (Exception e) {
		throw new GdxRuntimeException("Couldn't load pkm file '" + pkmFile + "'", e);
	} finally {
		StreamUtils.closeQuietly(in);
	}

	width = getWidthPKM(compressedData, 0);
	height = getHeightPKM(compressedData, 0);
	dataOffset = PKM_HEADER_SIZE;
	compressedData.position(dataOffset);
	checkNPOT();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:26,代码来源:ETC1.java

示例2: VertexBufferObject

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
public VertexBufferObject(boolean paramBoolean, int paramInt, VertexAttributes paramVertexAttributes)
{
  this.isStatic = paramBoolean;
  this.attributes = paramVertexAttributes;
  this.attributeIndexCache = new int[paramVertexAttributes.size()];
  this.byteBuffer = BufferUtils.newUnsafeByteBuffer(paramInt * this.attributes.vertexSize);
  this.buffer = this.byteBuffer.asFloatBuffer();
  this.buffer.flip();
  this.byteBuffer.flip();
  if (paramBoolean);
  for (int i = 35044; ; i = 35048)
  {
    this.usage = i;
    this.bufferHandle = createBufferObject();
    return;
  }
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:18,代码来源:VertexBufferObject.java

示例3: VertexArray

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/** Constructs a new interleaved VertexArray
 * 
 * @param numVertices the maximum number of vertices
 * @param attributes the {@link VertexAttributes} */
public VertexArray (int numVertices, VertexAttributes attributes) {
	this.attributes = attributes;
	byteBuffer = BufferUtils.newUnsafeByteBuffer(this.attributes.vertexSize * numVertices);
	buffer = byteBuffer.asFloatBuffer();
	buffer.flip();
	byteBuffer.flip();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:12,代码来源:VertexArray.java

示例4: encodeImage

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/** Encodes the image via the ETC1 compression scheme. Only {@link Format#RGB565} and {@link Format#RGB888} are supported.
 * @param pixmap the {@link Pixmap}
 * @return the {@link ETC1Data} */
public static ETC1Data encodeImage (Pixmap pixmap) {
	int pixelSize = getPixelSize(pixmap.getFormat());
	ByteBuffer compressedData = encodeImage(pixmap.getPixels(), 0, pixmap.getWidth(), pixmap.getHeight(), pixelSize);
	BufferUtils.newUnsafeByteBuffer(compressedData);
	return new ETC1Data(pixmap.getWidth(), pixmap.getHeight(), compressedData, 0);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:10,代码来源:ETC1.java

示例5: encodeImagePKM

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/** Encodes the image via the ETC1 compression scheme. Only {@link Format#RGB565} and {@link Format#RGB888} are supported. Adds
 * a PKM header in front of the compressed image data.
 * @param pixmap the {@link Pixmap}
 * @return the {@link ETC1Data} */
public static ETC1Data encodeImagePKM (Pixmap pixmap) {
	int pixelSize = getPixelSize(pixmap.getFormat());
	ByteBuffer compressedData = encodeImagePKM(pixmap.getPixels(), 0, pixmap.getWidth(), pixmap.getHeight(), pixelSize);
	BufferUtils.newUnsafeByteBuffer(compressedData);
	return new ETC1Data(pixmap.getWidth(), pixmap.getHeight(), compressedData, 16);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:11,代码来源:ETC1.java

示例6: IndexArray

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/** Creates a new IndexArray to be used with vertex arrays.
 * 
 * @param maxIndices the maximum number of indices this buffer can hold */
public IndexArray (int maxIndices) {
	byteBuffer = BufferUtils.newUnsafeByteBuffer(maxIndices * 2);
	buffer = byteBuffer.asShortBuffer();
	buffer.flip();
	byteBuffer.flip();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:10,代码来源:IndexArray.java

示例7: VertexBufferObject

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/** Constructs a new interleaved VertexBufferObject.
 * 
 * @param isStatic whether the vertex data is static.
 * @param numVertices the maximum number of vertices
 * @param attributes the {@link VertexAttributes}. */
public VertexBufferObject (boolean isStatic, int numVertices, VertexAttributes attributes) {
	this.isStatic = isStatic;
	this.attributes = attributes;

	byteBuffer = BufferUtils.newUnsafeByteBuffer(this.attributes.vertexSize * numVertices);
	buffer = byteBuffer.asFloatBuffer();
	buffer.flip();
	byteBuffer.flip();
	bufferHandle = Gdx.gl20.glGenBuffer();
	usage = isStatic ? GL20.GL_STATIC_DRAW : GL20.GL_DYNAMIC_DRAW;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:17,代码来源:VertexBufferObject.java

示例8: IndexBufferObject

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/** Creates a new IndexBufferObject.
 * 
 * @param isStatic whether the index buffer is static
 * @param maxIndices the maximum number of indices this buffer can hold */
public IndexBufferObject (boolean isStatic, int maxIndices) {
	byteBuffer = BufferUtils.newUnsafeByteBuffer(maxIndices * 2);
	isDirect = true;

	buffer = byteBuffer.asShortBuffer();
	buffer.flip();
	byteBuffer.flip();
	bufferHandle = Gdx.gl20.glGenBuffer();
	usage = isStatic ? GL20.GL_STATIC_DRAW : GL20.GL_DYNAMIC_DRAW;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:15,代码来源:IndexBufferObject.java

示例9: newMemoryFace

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
public static Face newMemoryFace(Library library, byte[] data, int dataSize, int faceIndex) {
	ByteBuffer buffer = BufferUtils.newUnsafeByteBuffer(data.length);
	BufferUtils.copy(data, 0, buffer, data.length);
	long address = newMemoryFace(library.address, buffer, dataSize, faceIndex);
	if(address == 0) {
		BufferUtils.disposeUnsafeByteBuffer(buffer);
		throw new GdxRuntimeException("Couldn't load font");
	}
	else {
		library.fontData.put(address, buffer);
		return new Face(address, library);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:14,代码来源:FreeType.java

示例10: DynamicVertexBufferObject

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
/** Constructs a new interleaved VertexBufferObject.
 * 
 * @param isStatic whether the vertex data is static.
 * @param numVertices the maximum number of vertices
 * @param attributes the {@link VertexAttributes}. */
public DynamicVertexBufferObject (int numVertices, VertexAttributes attributes)
{
	this.attributes = attributes;

	byteBuffer = BufferUtils.newUnsafeByteBuffer(this.attributes.vertexSize * numVertices);
	buffer = byteBuffer.asFloatBuffer();
	buffer.flip();
	byteBuffer.flip();
	bufferHandle = createBufferObject();
	usage = GL20.GL_DYNAMIC_DRAW;
}
 
开发者ID:kennux,项目名称:libgdx-opencl,代码行数:17,代码来源:DynamicVertexBufferObject.java

示例11: VertexArray

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
public VertexArray(int paramInt, VertexAttributes paramVertexAttributes)
{
  this.attributes = paramVertexAttributes;
  this.byteBuffer = BufferUtils.newUnsafeByteBuffer(paramInt * this.attributes.vertexSize);
  this.buffer = this.byteBuffer.asFloatBuffer();
  this.buffer.flip();
  this.byteBuffer.flip();
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:9,代码来源:VertexArray.java

示例12: IndexArray

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
public IndexArray(int paramInt)
{
  this.byteBuffer = BufferUtils.newUnsafeByteBuffer(paramInt * 2);
  this.buffer = this.byteBuffer.asShortBuffer();
  this.buffer.flip();
  this.byteBuffer.flip();
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:8,代码来源:IndexArray.java

示例13: IndexBufferObject

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
public IndexBufferObject(int paramInt)
{
  this.byteBuffer = BufferUtils.newUnsafeByteBuffer(paramInt * 2);
  this.isDirect = true;
  this.buffer = this.byteBuffer.asShortBuffer();
  this.buffer.flip();
  this.byteBuffer.flip();
  this.bufferHandle = createBufferObject();
  this.usage = 35044;
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:11,代码来源:IndexBufferObject.java

示例14: prepare

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
@Override
public void prepare () {
	if (compressedData != null) throw new GdxRuntimeException("Already prepared");
	if (file == null) throw new GdxRuntimeException("Need a file to load from");
	// We support normal ktx files as well as 'zktx' which are gzip ktx file with an int length at the beginning (like ETC1).
	if (file.name().endsWith(".zktx")) {
		byte[] buffer = new byte[1024 * 10];
		DataInputStream in = null;
		try {
			in = new DataInputStream(new BufferedInputStream(new GZIPInputStream(file.read())));
			int fileSize = in.readInt();
			compressedData = BufferUtils.newUnsafeByteBuffer(fileSize);
			int readBytes = 0;
			while ((readBytes = in.read(buffer)) != -1)
				compressedData.put(buffer, 0, readBytes);
			compressedData.position(0);
			compressedData.limit(compressedData.capacity());
		} catch (Exception e) {
			throw new GdxRuntimeException("Couldn't load zktx file '" + file + "'", e);
		} finally {
			StreamUtils.closeQuietly(in);
		}
	} else {
		compressedData = ByteBuffer.wrap(file.readBytes());
	}
	if (compressedData.get() != (byte)0x0AB) throw new GdxRuntimeException("Invalid KTX Header");
	if (compressedData.get() != (byte)0x04B) throw new GdxRuntimeException("Invalid KTX Header");
	if (compressedData.get() != (byte)0x054) throw new GdxRuntimeException("Invalid KTX Header");
	if (compressedData.get() != (byte)0x058) throw new GdxRuntimeException("Invalid KTX Header");
	if (compressedData.get() != (byte)0x020) throw new GdxRuntimeException("Invalid KTX Header");
	if (compressedData.get() != (byte)0x031) throw new GdxRuntimeException("Invalid KTX Header");
	if (compressedData.get() != (byte)0x031) throw new GdxRuntimeException("Invalid KTX Header");
	if (compressedData.get() != (byte)0x0BB) throw new GdxRuntimeException("Invalid KTX Header");
	if (compressedData.get() != (byte)0x00D) throw new GdxRuntimeException("Invalid KTX Header");
	if (compressedData.get() != (byte)0x00A) throw new GdxRuntimeException("Invalid KTX Header");
	if (compressedData.get() != (byte)0x01A) throw new GdxRuntimeException("Invalid KTX Header");
	if (compressedData.get() != (byte)0x00A) throw new GdxRuntimeException("Invalid KTX Header");
	int endianTag = compressedData.getInt();
	if (endianTag != 0x04030201 && endianTag != 0x01020304) throw new GdxRuntimeException("Invalid KTX Header");
	if (endianTag != 0x04030201)
		compressedData.order(compressedData.order() == ByteOrder.BIG_ENDIAN ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
	glType = compressedData.getInt();
	glTypeSize = compressedData.getInt();
	glFormat = compressedData.getInt();
	glInternalFormat = compressedData.getInt();
	glBaseInternalFormat = compressedData.getInt();
	pixelWidth = compressedData.getInt();
	pixelHeight = compressedData.getInt();
	pixelDepth = compressedData.getInt();
	numberOfArrayElements = compressedData.getInt();
	numberOfFaces = compressedData.getInt();
	numberOfMipmapLevels = compressedData.getInt();
	int bytesOfKeyValueData = compressedData.getInt();
	imagePos = compressedData.position() + bytesOfKeyValueData;
	if (!compressedData.isDirect()) {
		int pos = imagePos;
		for (int level = 0; level < numberOfMipmapLevels; level++) {
			int faceLodSize = compressedData.getInt(pos);
			int faceLodSizeRounded = (faceLodSize + 3) & ~3;
			pos += faceLodSizeRounded * numberOfFaces + 4;
		}
		compressedData.limit(pos);
		compressedData.position(0);
		ByteBuffer directBuffer = BufferUtils.newUnsafeByteBuffer(pos);
		directBuffer.order(compressedData.order());
		directBuffer.put(compressedData);
		compressedData = directBuffer;
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:70,代码来源:KTXTextureData.java

示例15: GLBufferObject

import com.badlogic.gdx.utils.BufferUtils; //导入方法依赖的package包/类
GLBufferObject(int target, boolean isStatic, int numElements, int elementSize) {

		handle = gl20.glGenBuffer();

		this.target = target;
		usage = isStatic ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW;

		this.elementSize = elementSize;
		byteBuffer = BufferUtils.newUnsafeByteBuffer(numElements * elementSize);

		createElementBuffer(byteBuffer);

		byteBuffer.flip();
	}
 
开发者ID:code-disaster,项目名称:libgdx-snippets,代码行数:15,代码来源:GLBufferObject.java


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