@Override public void write(JmeExporter ex) throws IOException { OutputCapsule oc = ex.getCapsule(this); for (Map.Entry<VertexBuffer.Type, FloatBuffer> entry : buffers.entrySet()) { Buffer roData = entry.getValue().asReadOnlyBuffer(); oc.write((FloatBuffer) roData, entry.getKey().name(),null); } }
result = ((ByteBuffer)data).asReadOnlyBuffer(); } else if( data instanceof FloatBuffer ) { result = ((FloatBuffer)data).asReadOnlyBuffer(); } else if( data instanceof ShortBuffer ) { result = ((ShortBuffer)data).asReadOnlyBuffer();
@Override public FloatBuffer toFloatBuffer() { float[] floatVector = new float[vector.length]; for (int i = 0; i < floatVector.length ; i++) { floatVector[i] = (float) vector[i]; } return FloatBuffer.wrap(floatVector).asReadOnlyBuffer(); }
@Override public FloatBuffer toFloatBuffer() { return FloatBuffer.wrap(vector).asReadOnlyBuffer(); }
public static FloatBuffer readonly( FloatBuffer buffer ) { return buffer.asReadOnlyBuffer( ); }
/** * @return the coordinate buffers as readonly */ public FloatBuffer getReadOnlyCoordBuffer() { return coordBuffer.asReadOnlyBuffer(); }
@Override public FloatBuffer toFloatBuffer() { float[] floatVector = new float[vector.length]; for (int i = 0; i < floatVector.length ; i++) { floatVector[i] = (float) vector[i]; } return FloatBuffer.wrap(floatVector).asReadOnlyBuffer(); }
/** * Creates a new window which will store the sample values in the given {@code data} array. */ FloatWindow(final float[] data, final float[] transfer) { super(FloatBuffer.wrap(data).asReadOnlyBuffer()); this.data = data; this.transfer = transfer; }
@Override public FloatBuffer toFloatBuffer() { return FloatBuffer.wrap(vector).asReadOnlyBuffer(); }
@Override public FloatBuffer toFloatBuffer() { return FloatBuffer.wrap(vector).asReadOnlyBuffer(); }
/** * Get data by position * * @param buffer the {@link FloatBuffer} which should be extracted * @param start the start position of data of {@link FloatBuffer}'s * @param length the length of data of {@link FloatBuffer} * @return the data you want to */ public static float[] getFloats(FloatBuffer buffer , int start , int length) { final FloatBuffer tmp = buffer.asReadOnlyBuffer(); tmp.position(start); tmp.position(start + length); return FloatBufferOperation.usedArray(tmp); }
@Override public FloatBuffer toFloatBuffer() { return FloatBuffer.wrap(toFloatArray()).asReadOnlyBuffer(); }
/** * Find the start point of data which you want to find out. * The searching will start from end to head.<br> * <b>NOTE: Only return the position of the first time find out the data</b> * * @param buffer the {@link FloatBuffer} which should be searched * @param start the start position of {@link FloatBuffer} which should be * searched * @param length the length of {@link FloatBuffer} which should be searched * @param fs the data which should be found out * @return if can't find out then return -1 */ public static int lastIndexOf(FloatBuffer buffer , int start , int length , float... fs) { FloatBuffer tmp = buffer.asReadOnlyBuffer(); tmp.position(start); tmp.limit(start + length); return FloatBufferOperation.lastIndexOf(tmp , fs); }
/** * Find the start point of data which you want to find out. * The searching will start from head to end.<br> * <b>NOTE: Only return the position of the first time find out the data</b> * * @param buffer the {@link FloatBuffer} which should be searched * @param start the start position of {@link FloatBuffer} which should be * searched * @param length the length of {@link FloatBuffer} which should be searched * @param fs the data which should be found out * @return if can't find out then return -1 */ public static int indexOf(FloatBuffer buffer , int start , int length , float... fs) { FloatBuffer tmp = buffer.asReadOnlyBuffer(); tmp.position(start); tmp.limit(start + length); return FloatBufferOperation.indexOf(tmp , fs); }
private void growBuffer(int p_181670_1_) { if (MathHelper.roundUp(p_181670_1_, 4) / 4 > this.rawIntBuffer.remaining() || this.vertexCount * this.vertexFormat.getNextOffset() + p_181670_1_ > this.byteBuffer.capacity()) { int i = this.byteBuffer.capacity(); int j = i + MathHelper.roundUp(p_181670_1_, 2097152); LOGGER.debug("Needed to grow BufferBuilder buffer: Old size {} bytes, new size {} bytes.", Integer.valueOf(i), Integer.valueOf(j)); int k = this.rawIntBuffer.position(); ByteBuffer bytebuffer = GLAllocation.createDirectByteBuffer(j); this.byteBuffer.position(0); bytebuffer.put(this.byteBuffer); bytebuffer.rewind(); this.byteBuffer = bytebuffer; this.rawFloatBuffer = this.byteBuffer.asFloatBuffer().asReadOnlyBuffer(); this.rawIntBuffer = this.byteBuffer.asIntBuffer(); this.rawIntBuffer.position(k); this.rawShortBuffer = this.byteBuffer.asShortBuffer(); this.rawShortBuffer.position(k << 1); } }
/** * @param position * in the normal buffer. * @param limit * the number of ordinates to copy * @return a copy of the direct normal floatbuffer, or <code>null</code> if the position /limit is out of range. */ public FloatBuffer getNormals( int position, int limit ) { if ( position < 0 || position > normalBuffer.capacity() ) { return null; } FloatBuffer fb = normalBuffer.asReadOnlyBuffer(); fb.position( position ); fb.limit( position + limit ); return fb.slice(); }
/** * @param position * in the texture buffer. * @param limit * the number of ordinates to copy * @return a copy of the direct texture floatbuffer, or <code>null</code> if the position/limit is out of range. */ public FloatBuffer getTextureCoordinates( int position, int limit ) { if ( position < 0 || position > textureBuffer.capacity() ) { return null; } FloatBuffer fb = textureBuffer.asReadOnlyBuffer(); fb.position( position ); fb.limit( position + limit ); return fb.slice(); }
public CompressedFloatsIndexedSupplier toCompressedFloatsIndexedSupplier() { final FloatBuffer endBufCopy = endBuffer.asReadOnlyBuffer(); endBufCopy.flip(); return new CompressedFloatsIndexedSupplier( numInserted, sizePer, GenericIndexed.fromIterable( Iterables.<ResourceHolder<FloatBuffer>>concat( Iterables.transform( compressedBuffers, new Function<byte[], ResourceHolder<FloatBuffer>>() { @Override public ResourceHolder<FloatBuffer> apply(byte[] input) { return strategy.fromByteBuffer(ByteBuffer.wrap(input), input.length); } } ), Arrays.<ResourceHolder<FloatBuffer>>asList(StupidResourceHolder.create(endBufCopy)) ), strategy ) ); }
/** * @param position * in the coordinates buffer. * @param limit * the number of ordinates to copy * @return a copy of the direct coordinate floatbuffer, or <code>null</code> if the position /limit is out of range. */ public FloatBuffer getCoords( int position, int limit ) { if ( position < 0 || position > coordBuffer.capacity() ) { return null; } FloatBuffer fb = coordBuffer.asReadOnlyBuffer(); fb.position( position ); fb.limit( position + limit ); return fb.slice(); }
public static void applyGamma(Buffer buffer, int depth, int stride, double gamma) { if (gamma == 1.0) { return; } switch (depth) { case Frame.DEPTH_UBYTE: flipCopyWithGamma(((ByteBuffer)buffer).asReadOnlyBuffer(), stride, (ByteBuffer)buffer, stride, false, gamma, false, 0); break; case Frame.DEPTH_BYTE: flipCopyWithGamma(((ByteBuffer)buffer).asReadOnlyBuffer(), stride, (ByteBuffer)buffer, stride, true, gamma, false, 0); break; case Frame.DEPTH_USHORT: flipCopyWithGamma(((ShortBuffer)buffer).asReadOnlyBuffer(), stride, (ShortBuffer)buffer, stride, false, gamma, false, 0); break; case Frame.DEPTH_SHORT: flipCopyWithGamma(((ShortBuffer)buffer).asReadOnlyBuffer(), stride, (ShortBuffer)buffer, stride, true, gamma, false, 0); break; case Frame.DEPTH_INT: flipCopyWithGamma(((IntBuffer)buffer).asReadOnlyBuffer(), stride, (IntBuffer)buffer, stride, gamma, false, 0); break; case Frame.DEPTH_FLOAT: flipCopyWithGamma(((FloatBuffer)buffer).asReadOnlyBuffer(), stride, (FloatBuffer)buffer, stride, gamma, false, 0); break; case Frame.DEPTH_DOUBLE: flipCopyWithGamma(((DoubleBuffer)buffer).asReadOnlyBuffer(), stride, (DoubleBuffer)buffer, stride, gamma, false, 0); break; default: assert false; } }