/** 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(); }
/** 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(); }
/** <p> * Sets the indices of this IndexArray, discarding the old indices. The count must equal the number of indices to be copied to * this IndexArray. * </p> * * <p> * This can be called in between calls to {@link #bind()} and {@link #unbind()}. The index data will be updated instantly. * </p> * * @param indices the vertex data * @param offset the offset to start copying the data from * @param count the number of shorts to copy */ public void setIndices (short[] indices, int offset, int count) { buffer.clear(); buffer.put(indices, offset, count); buffer.flip(); byteBuffer.position(0); byteBuffer.limit(count << 1); }
/** <p> * Sets the indices of this IndexArray, discarding the old indices. The count must equal the number of indices to be copied to * this IndexArray. * </p> * * <p> * This can be called in between calls to {@link #bind()} and {@link #unbind()}. The index data will be updated instantly. * </p> * * @param indices the vertex data * @param offset the offset to start copying the data from * @param count the number of shorts to copy */ public void setIndices (short[] indices, int offset, int count) { buffer.clear(); buffer.put(indices, offset, count); buffer.flip(); byteBuffer.position(0); byteBuffer.limit(count << 1); }
/** 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(); }
/** 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; }
/** <p> * Sets the indices of this IndexBufferObject, discarding the old indices. The count must equal the number of indices to be * copied to this IndexBufferObject. * </p> * * <p> * This can be called in between calls to {@link #bind()} and {@link #unbind()}. The index data will be updated instantly. * </p> * * @param indices the vertex data * @param offset the offset to start copying the data from * @param count the number of floats to copy */ public void setIndices (short[] indices, int offset, int count) { isDirty = true; buffer.clear(); buffer.put(indices, offset, count); buffer.flip(); byteBuffer.position(0); byteBuffer.limit(count << 1); if (isBound) { Gdx.gl20.glBufferSubData(GL20.GL_ELEMENT_ARRAY_BUFFER, 0, byteBuffer.limit(), byteBuffer); isDirty = false; } }
/** <p> * Sets the indices of this IndexBufferObject, discarding the old indices. The count must equal the number of indices to be * copied to this IndexBufferObject. * </p> * * <p> * This can be called in between calls to {@link #bind()} and {@link #unbind()}. The index data will be updated instantly. * </p> * * @param indices the vertex data * @param offset the offset to start copying the data from * @param count the number of floats to copy */ public void setIndices (short[] indices, int offset, int count) { isDirty = true; buffer.clear(); buffer.put(indices, offset, count); buffer.flip(); byteBuffer.position(0); byteBuffer.limit(count << 1); if (isBound) { Gdx.gl20.glBufferSubData(GL20.GL_ELEMENT_ARRAY_BUFFER, 0, byteBuffer.limit(), byteBuffer); isDirty = false; } }
/** <p> * Sets the indices of this IndexBufferObject, discarding the old indices. The count must equal the number of indices to be * copied to this IndexBufferObject. * </p> * * <p> * This can be called in between calls to {@link #bind()} and {@link #unbind()}. The index data will be updated instantly. * </p> * * @param indices the vertex data * @param offset the offset to start copying the data from * @param count the number of shorts to copy */ public void setIndices (short[] indices, int offset, int count) { isDirty = true; buffer.clear(); buffer.put(indices, offset, count); buffer.flip(); byteBuffer.position(0); byteBuffer.limit(count << 1); if (isBound) { Gdx.gl20.glBufferData(GL20.GL_ELEMENT_ARRAY_BUFFER, byteBuffer.limit(), byteBuffer, usage); isDirty = false; } }
public void setIndices (ShortBuffer indices) { int pos = indices.position(); isDirty = true; buffer.clear(); buffer.put(indices); buffer.flip(); indices.position(pos); byteBuffer.position(0); byteBuffer.limit(buffer.limit() << 1); if (isBound) { Gdx.gl20.glBufferSubData(GL20.GL_ELEMENT_ARRAY_BUFFER, 0, byteBuffer.limit(), byteBuffer); isDirty = false; } }
public void setIndices (ShortBuffer indices) { isDirty = true; int pos = indices.position(); buffer.clear(); buffer.put(indices); buffer.flip(); indices.position(pos); byteBuffer.position(0); byteBuffer.limit(buffer.limit() << 1); if (isBound) { Gdx.gl20.glBufferData(GL20.GL_ELEMENT_ARRAY_BUFFER, byteBuffer.limit(), byteBuffer, usage); isDirty = false; } }
public void setIndices (ShortBuffer indices) { isDirty = true; int pos = indices.position(); buffer.clear(); buffer.put(indices); buffer.flip(); indices.position(pos); byteBuffer.position(0); byteBuffer.limit(buffer.limit() << 1); if (isBound) { Gdx.gl20.glBufferData(GL20.GL_ELEMENT_ARRAY_BUFFER, byteBuffer.limit(), byteBuffer, usage); isDirty = false; } }
public void setIndices (ShortBuffer indices) { int pos = indices.position(); isDirty = true; buffer.clear(); buffer.put(indices); buffer.flip(); indices.position(pos); byteBuffer.position(0); byteBuffer.limit(buffer.limit() << 1); if (isBound) { Gdx.gl20.glBufferSubData(GL20.GL_ELEMENT_ARRAY_BUFFER, 0, byteBuffer.limit(), byteBuffer); isDirty = false; } }
public void setIndices (ShortBuffer indices) { int pos = indices.position(); buffer.clear(); buffer.limit(indices.remaining()); buffer.put(indices); buffer.flip(); indices.position(pos); byteBuffer.position(0); byteBuffer.limit(buffer.limit() << 1); }
public void setIndices (ShortBuffer indices) { int pos = indices.position(); buffer.clear(); buffer.limit(indices.remaining()); buffer.put(indices); buffer.flip(); indices.position(pos); byteBuffer.position(0); byteBuffer.limit(buffer.limit() << 1); }
/** Returns the built buffer. After calling this method the builder should not be reused. */ public ShortBuffer build() { Assertions.checkState(!built); built = true; buffer.flip(); return buffer; } }