/** 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(); }
/** 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) { empty = maxIndices == 0; if (empty) { maxIndices = 1; // avoid allocating a zero-sized buffer because of bug in Android's ART < Android 5.0 } byteBuffer = BufferUtils.newUnsafeByteBuffer(maxIndices * 2); buffer = byteBuffer.asShortBuffer(); buffer.flip(); byteBuffer.flip(); }
/** 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(); }
/** 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) { empty = maxIndices == 0; if (empty) { maxIndices = 1; // avoid allocating a zero-sized buffer because of bug in Android's ART < Android 5.0 } byteBuffer = BufferUtils.newUnsafeByteBuffer(maxIndices * 2); buffer = byteBuffer.asShortBuffer(); buffer.flip(); byteBuffer.flip(); }
public OldVertexBufferObjectWithVAO (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; }
public Face newMemoryFace(byte[] data, int dataSize, int faceIndex) { ByteBuffer buffer = BufferUtils.newUnsafeByteBuffer(data.length); BufferUtils.copy(data, 0, buffer, data.length); return newMemoryFace(buffer, faceIndex); }
/** 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) { empty = maxIndices == 0; if (empty) { maxIndices = 1; // avoid allocating a zero-sized buffer because of bug in Android's ART < Android 5.0 } 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; }
/** 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) { empty = maxIndices == 0; if (empty) { maxIndices = 1; // avoid allocating a zero-sized buffer because of bug in Android's ART < Android 5.0 } 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; }
public Face newMemoryFace(byte[] data, int dataSize, int faceIndex) { ByteBuffer buffer = BufferUtils.newUnsafeByteBuffer(data.length); BufferUtils.copy(data, 0, buffer, data.length); return newMemoryFace(buffer, faceIndex); }
/** 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) { bufferHandle = Gdx.gl20.glGenBuffer(); ByteBuffer data = BufferUtils.newUnsafeByteBuffer(attributes.vertexSize * numVertices); data.limit(0); setBuffer(data, true, attributes); setUsage(isStatic ? GL20.GL_STATIC_DRAW : GL20.GL_DYNAMIC_DRAW); }
/** 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) { bufferHandle = Gdx.gl20.glGenBuffer(); ByteBuffer data = BufferUtils.newUnsafeByteBuffer(attributes.vertexSize * numVertices); data.limit(0); setBuffer(data, true, attributes); setUsage(isStatic ? GL20.GL_STATIC_DRAW : GL20.GL_DYNAMIC_DRAW); }
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(); }
/** * Constructs a new interleaved VertexBufferObjectWithVAO. * * @param isStatic whether the vertex data is static. * @param numVertices the maximum number of vertices * @param attributes the {@link VertexAttributes}. */ public VertexBufferObjectWithVAO (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; createVAO(); }
/** * Constructs a new interleaved VertexBufferObjectWithVAO. * * @param isStatic whether the vertex data is static. * @param numVertices the maximum number of vertices * @param attributes the {@link VertexAttributes}. */ public VertexBufferObjectWithVAO (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; createVAO(); }
public boolean loadFile(final com.badlogic.gdx.files.FileHandle fileHandle) { final int len = (int)fileHandle.length(); if (len <= 0) throw new com.badlogic.gdx.utils.GdxRuntimeException("Incorrect file specified"); java.nio.ByteBuffer buff = com.badlogic.gdx.utils.BufferUtils.newUnsafeByteBuffer(len); buff.put(fileHandle.readBytes()); buff.position(0); boolean result = loadFileFromMemory(buff, len); com.badlogic.gdx.utils.BufferUtils.disposeUnsafeByteBuffer(buff); return result; }
public boolean loadFile(final com.badlogic.gdx.files.FileHandle fileHandle) { final int len = (int)fileHandle.length(); if (len <= 0) throw new com.badlogic.gdx.utils.GdxRuntimeException("Incorrect file specified"); java.nio.ByteBuffer buff = com.badlogic.gdx.utils.BufferUtils.newUnsafeByteBuffer(len); buff.put(fileHandle.readBytes()); buff.position(0); boolean result = loadFileFromMemory(buff, len); com.badlogic.gdx.utils.BufferUtils.disposeUnsafeByteBuffer(buff); return result; }
/** 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); }
/** 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); }
/** 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); }
/** 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); }