private void ensureBufferCapacity (int numBytes) { if (buffer == null || buffer.capacity() < numBytes) { buffer = com.badlogic.gdx.utils.BufferUtils.newByteBuffer(numBytes); floatBuffer = buffer.asFloatBuffer(); intBuffer = buffer.asIntBuffer(); } }
private void ensureBufferCapacity (int numBytes) { if (buffer == null || buffer.capacity() < numBytes) { buffer = com.badlogic.gdx.utils.BufferUtils.newByteBuffer(numBytes); floatBuffer = buffer.asFloatBuffer(); intBuffer = buffer.asIntBuffer(); } }
private void ensureBufferCapacity (int numBytes) { if (buffer == null || buffer.capacity() < numBytes) { buffer = com.badlogic.gdx.utils.BufferUtils.newByteBuffer(numBytes); floatBuffer = buffer.asFloatBuffer(); intBuffer = buffer.asIntBuffer(); } }
private void ensureBufferCapacity (int numBytes) { if (buffer == null || buffer.capacity() < numBytes) { buffer = com.badlogic.gdx.utils.BufferUtils.newByteBuffer(numBytes); floatBuffer = buffer.asFloatBuffer(); intBuffer = buffer.asIntBuffer(); } }
/** Creates a new IndexBufferObject to be used with vertex arrays. * * @param maxIndices the maximum number of indices this buffer can hold */ public IndexBufferObjectSubData (int maxIndices) { byteBuffer = BufferUtils.newByteBuffer(maxIndices * 2); this.isDirect = true; usage = GL20.GL_STATIC_DRAW; buffer = byteBuffer.asShortBuffer(); buffer.flip(); byteBuffer.flip(); bufferHandle = createBufferObject(); }
/** Creates a new IndexBufferObject to be used with vertex arrays. * * @param maxIndices the maximum number of indices this buffer can hold */ public IndexBufferObjectSubData (int maxIndices) { byteBuffer = BufferUtils.newByteBuffer(maxIndices * 2); this.isDirect = true; usage = GL20.GL_STATIC_DRAW; buffer = byteBuffer.asShortBuffer(); buffer.flip(); byteBuffer.flip(); bufferHandle = createBufferObject(); }
/** Creates a new IndexBufferObject. * * @param isStatic whether the index buffer is static * @param maxIndices the maximum number of indices this buffer can hold */ public IndexBufferObjectSubData (boolean isStatic, int maxIndices) { byteBuffer = BufferUtils.newByteBuffer(maxIndices * 2); isDirect = true; usage = isStatic ? GL20.GL_STATIC_DRAW : GL20.GL_DYNAMIC_DRAW; buffer = byteBuffer.asShortBuffer(); buffer.flip(); byteBuffer.flip(); bufferHandle = createBufferObject(); }
/** Creates a new IndexBufferObject. * * @param isStatic whether the index buffer is static * @param maxIndices the maximum number of indices this buffer can hold */ public IndexBufferObjectSubData (boolean isStatic, int maxIndices) { byteBuffer = BufferUtils.newByteBuffer(maxIndices * 2); isDirect = true; usage = isStatic ? GL20.GL_STATIC_DRAW : GL20.GL_DYNAMIC_DRAW; buffer = byteBuffer.asShortBuffer(); buffer.flip(); byteBuffer.flip(); bufferHandle = createBufferObject(); }
public ByteBuffer getBuffer() { if (getRows() == 0) // Issue #768 - CheckJNI frowns upon env->NewDirectByteBuffer with NULL buffer or capacity 0 // "JNI WARNING: invalid values for address (0x0) or capacity (0)" // FreeType sets FT_Bitmap::buffer to NULL when the bitmap is empty (e.g. for ' ') // JNICheck is on by default on emulators and might have a point anyway... // So let's avoid this and just return a dummy non-null non-zero buffer return BufferUtils.newByteBuffer(1); return getBuffer(address); }
/** Constructs a new interleaved VertexBufferObject. * * @param isStatic whether the vertex data is static. * @param numVertices the maximum number of vertices * @param attributes the {@link VertexAttribute}s. */ public VertexBufferObjectSubData (boolean isStatic, int numVertices, VertexAttributes attributes) { this.isStatic = isStatic; this.attributes = attributes; byteBuffer = BufferUtils.newByteBuffer(this.attributes.vertexSize * numVertices); isDirect = true; usage = isStatic ? GL20.GL_STATIC_DRAW : GL20.GL_DYNAMIC_DRAW; buffer = byteBuffer.asFloatBuffer(); bufferHandle = createBufferObject(); buffer.flip(); byteBuffer.flip(); }
/** Constructs a new interleaved VertexBufferObject. * * @param isStatic whether the vertex data is static. * @param numVertices the maximum number of vertices * @param attributes the {@link VertexAttribute}s. */ public VertexBufferObjectSubData (boolean isStatic, int numVertices, VertexAttributes attributes) { this.isStatic = isStatic; this.attributes = attributes; byteBuffer = BufferUtils.newByteBuffer(this.attributes.vertexSize * numVertices); isDirect = true; usage = isStatic ? GL20.GL_STATIC_DRAW : GL20.GL_DYNAMIC_DRAW; buffer = byteBuffer.asFloatBuffer(); bufferHandle = createBufferObject(); buffer.flip(); byteBuffer.flip(); }
public ByteBuffer getBuffer() { if (getRows() == 0) // Issue #768 - CheckJNI frowns upon env->NewDirectByteBuffer with NULL buffer or capacity 0 // "JNI WARNING: invalid values for address (0x0) or capacity (0)" // FreeType sets FT_Bitmap::buffer to NULL when the bitmap is empty (e.g. for ' ') // JNICheck is on by default on emulators and might have a point anyway... // So let's avoid this and just return a dummy non-null non-zero buffer return BufferUtils.newByteBuffer(1); return getBuffer(address); }
/** Returns a portion of the default framebuffer contents specified by x, y, width and height, as a byte[] array with a length * equal to the specified width * height * 4. The byte[] will always contain RGBA8888 data. If the width and height specified * are larger than the framebuffer dimensions, the Texture will be padded accordingly. Pixels that fall outside of the current * screen will have RGBA values of 0. Because of differences in screen and image origins the framebuffer contents should be * flipped along the Y axis if you intend save them to disk as a bitmap. Flipping is not a cheap operation, so use this * functionality wisely. * * @param flipY whether to flip pixels along Y axis */ public static byte[] getFrameBufferPixels (int x, int y, int w, int h, boolean flipY) { Gdx.gl.glPixelStorei(GL20.GL_PACK_ALIGNMENT, 1); final ByteBuffer pixels = BufferUtils.newByteBuffer(w * h * 4); Gdx.gl.glReadPixels(x, y, w, h, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixels); final int numBytes = w * h * 4; byte[] lines = new byte[numBytes]; if (flipY) { final int numBytesPerLine = w * 4; for (int i = 0; i < h; i++) { pixels.position((h - i - 1) * numBytesPerLine); pixels.get(lines, i * numBytesPerLine, numBytesPerLine); } } else { pixels.clear(); pixels.get(lines); } return lines; } }
/** Returns a portion of the default framebuffer contents specified by x, y, width and height, as a byte[] array with a length * equal to the specified width * height * 4. The byte[] will always contain RGBA8888 data. If the width and height specified * are larger than the framebuffer dimensions, the Texture will be padded accordingly. Pixels that fall outside of the current * screen will have RGBA values of 0. Because of differences in screen and image origins the framebuffer contents should be * flipped along the Y axis if you intend save them to disk as a bitmap. Flipping is not a cheap operation, so use this * functionality wisely. * * @param flipY whether to flip pixels along Y axis */ public static byte[] getFrameBufferPixels (int x, int y, int w, int h, boolean flipY) { Gdx.gl.glPixelStorei(GL20.GL_PACK_ALIGNMENT, 1); final ByteBuffer pixels = BufferUtils.newByteBuffer(w * h * 4); Gdx.gl.glReadPixels(x, y, w, h, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixels); final int numBytes = w * h * 4; byte[] lines = new byte[numBytes]; if (flipY) { final int numBytesPerLine = w * 4; for (int i = 0; i < h; i++) { pixels.position((h - i - 1) * numBytesPerLine); pixels.get(lines, i * numBytesPerLine, numBytesPerLine); } } else { pixels.clear(); pixels.get(lines); } return lines; } }
private void benchByte () { ByteBuffer bb = BufferUtils.newByteBuffer(1024 * 1024); byte[] bytes = new byte[1024 * 1024]; int len = bytes.length;
ByteBuffer bb = BufferUtils.newByteBuffer(8); CharBuffer cb = BufferUtils.newCharBuffer(8); ShortBuffer sb = BufferUtils.newShortBuffer(8); ByteBuffer bb2 = BufferUtils.newByteBuffer(4); bb.position(4); BufferUtils.copy(bb, bb2, 4);
@Nonnull @Override public ByteBuffer createNativeOrderedByteBuffer(final int numBytes) { return BufferUtils.newByteBuffer(numBytes); }
private void ensureBufferCapacity (int numBytes) { if (buffer == null || buffer.capacity() < numBytes) { buffer = com.badlogic.gdx.utils.BufferUtils.newByteBuffer(numBytes); floatBuffer = buffer.asFloatBuffer(); intBuffer = buffer.asIntBuffer(); } }
private void ensureBufferCapacity (int numBytes) { if (buffer == null || buffer.capacity() < numBytes) { buffer = com.badlogic.gdx.utils.BufferUtils.newByteBuffer(numBytes); floatBuffer = buffer.asFloatBuffer(); intBuffer = buffer.asIntBuffer(); } }
/** Creates a new IndexBufferObject to be used with vertex arrays. * * @param maxIndices the maximum number of indices this buffer can hold */ public IndexBufferObjectSubData (int maxIndices) { byteBuffer = BufferUtils.newByteBuffer(maxIndices * 2); this.isDirect = true; usage = GL20.GL_STATIC_DRAW; buffer = byteBuffer.asShortBuffer(); buffer.flip(); byteBuffer.flip(); bufferHandle = createBufferObject(); }