/** Writes shorts from the given short array to the current position and increases the position by the number of shorts written. * <p> * Calling this method has the same effect as {@code put(src, 0, src.length)}. * </p> * * @param src the source short array. * @return this buffer. * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public final ShortBuffer put (short[] src) { return put(src, 0, src.length); }
/** Writes shorts from the given short array to the current position and increases the position by the number of shorts written. * <p> * Calling this method has the same effect as {@code put(src, 0, src.length)}. * </p> * * @param src the source short array. * @return this buffer. * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public final ShortBuffer put (short[] src) { return put(src, 0, src.length); }
/** <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); }
/** Writes shorts from the given short array, starting from the specified offset, to the current position and increases the * position by the number of shorts written. * * @param src the source short array. * @param off the offset of short array, must not be negative and not greater than {@code src.length}. * @param len the number of shorts to write, must be no less than zero and not greater than {@code src.length - off}. * @return this buffer. * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public ShortBuffer put (short[] src, int off, int len) { int length = src.length; if (off < 0 || len < 0 || (long)off + (long)len > length) { throw new IndexOutOfBoundsException(); } if (len > remaining()) { throw new BufferOverflowException(); } for (int i = off; i < off + len; i++) { put(src[i]); } return this; }
/** Writes shorts from the given short array, starting from the specified offset, to the current position and increases the * position by the number of shorts written. * * @param src the source short array. * @param off the offset of short array, must not be negative and not greater than {@code src.length}. * @param len the number of shorts to write, must be no less than zero and not greater than {@code src.length - off}. * @return this buffer. * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public ShortBuffer put (short[] src, int off, int len) { int length = src.length; if (off < 0 || len < 0 || (long)off + (long)len > length) { throw new IndexOutOfBoundsException(); } if (len > remaining()) { throw new BufferOverflowException(); } for (int i = off; i < off + len; i++) { put(src[i]); } return this; }
/** <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; } }
/** <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) { 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; } }
/** Writes all the remaining shorts of the {@code src} short buffer to this buffer's current position, and increases both * buffers' position by the number of shorts copied. * * @param src the source short buffer. * @return this buffer. * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. * @exception IllegalArgumentException if {@code src} is this buffer. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public ShortBuffer put (ShortBuffer src) { if (src == this) { throw new IllegalArgumentException(); } if (src.remaining() > remaining()) { throw new BufferOverflowException(); } short[] contents = new short[src.remaining()]; src.get(contents); put(contents); return this; }
/** Writes all the remaining shorts of the {@code src} short buffer to this buffer's current position, and increases both * buffers' position by the number of shorts copied. * * @param src the source short buffer. * @return this buffer. * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. * @exception IllegalArgumentException if {@code src} is this buffer. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public ShortBuffer put (ShortBuffer src) { if (src == this) { throw new IllegalArgumentException(); } if (src.remaining() > remaining()) { throw new BufferOverflowException(); } short[] contents = new short[src.remaining()]; src.get(contents); put(contents); return this; }
/** * Appends {@code count} audio frames, using the specified {@code channelLevels} in each frame. */ public void appendFrames(int count, short... channelLevels) { Assertions.checkState(!built); for (int i = 0; i < count; i += channelCount) { for (short channelLevel : channelLevels) { buffer.put(channelLevel); } } }
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 next buffer with size up to {@code sizeBytes}. */ public ByteBuffer getNextInputBuffer(int sizeBytes) { ByteBuffer inputBuffer = ByteBuffer.allocate(sizeBytes).order(ByteOrder.nativeOrder()); ShortBuffer inputBufferAsShortBuffer = inputBuffer.asShortBuffer(); int limit = buffer.limit(); buffer.limit(Math.min(buffer.position() + sizeBytes / 2, limit)); inputBufferAsShortBuffer.put(buffer); buffer.limit(limit); inputBuffer.limit(inputBufferAsShortBuffer.position() * 2); return inputBuffer; }