/** * Returns a {@link FloatBuffer} which reads and writes to the same memory * location pointed to by this {@link FloatPtr}. * * @param n the maximum number of floats the {@link FloatBuffer} can * read/write. This will be the {@link FloatBuffer}'s * <code>capacity</code>. * @return the {@link FloatBuffer}. */ public FloatBuffer asFloatBuffer(int n) { return as(BytePtr.class).asByteBuffer(n << 2).order(ByteOrder.nativeOrder()).asFloatBuffer(); }
/** * Copies {@code count} floats from {@code src} starting at offset {@code offset} * to the memory pointed to by this {@link FloatPtr}. * * @param src the source. * @param offset the offset within the source array to start copying from. * @param count the number of elements to copy. */ public void set(float[] src, int offset, int count) { asFloatBuffer(count).put(src, offset, count); } }
/** * @since Available in iOS 8.0 and later. */ public float[] getCleanTexCoords() { FloatPtr lowerLeft = new FloatPtr(); FloatPtr lowerRight = new FloatPtr(); FloatPtr upperRight = new FloatPtr(); FloatPtr upperLeft = new FloatPtr(); getCleanTexCoords(lowerLeft, lowerRight, upperRight, upperLeft); float[] coords = {lowerLeft.get(), lowerRight.get(), upperRight.get(), upperLeft.get()}; return coords; } /*<methods>*/
public void setFragmentSamplerStates(MTLSamplerState[] samplers, float[] lodMinClamps, float[] lodMaxClamps, NSRange range) { MTLSamplerState.MTLSamplerStatePtr sptr = new MTLSamplerState.MTLSamplerStatePtr(); sptr.set(samplers); FloatPtr minptr = new FloatPtr(); minptr.set(lodMinClamps); FloatPtr maxptr = new FloatPtr(); maxptr.set(lodMaxClamps); setFragmentSamplerStates(sptr, minptr, maxptr, range); }
/** * Copies {@code n} floats from the memory pointed to by this {@link FloatPtr} * to a new {@code float[]} instance. * * @param n the number of floats to copy. * @return the {@code float[]}. */ public float[] toFloatArray(int n) { float[] result = new float[n]; get(result); return result; }
/** * Creates a new {@link FloatPtr} and initializes it with the specified value. * * @param value the value. */ public FloatPtr(float value) { set(value); }
@Callback private static void cbEvaluate(@Pointer long infoId, FloatPtr inDataPtr, FloatPtr outDataPtr) { Info info = null; synchronized (infos) { info = infos.get(infoId); } float[] inData = inDataPtr.toFloatArray((int) info.domainDimension); float[] outData = new float[(int) info.rangeDimension]; info.evaluate.evaluate(inData, outData); outDataPtr.set(outData); } @Callback
@Deprecated public static void setProperty(AudioSessionProperty id, float value) throws OSStatusException { setProperty(id, new FloatPtr(value)); } @Deprecated
public float[] getOutputDataAsFloatArray() { FloatPtr ptr = getOutputDataPointer().as(FloatPtr.class); return ptr.toFloatArray(getOutputDataSize()); } public double[] getOutputDataAsDoubleArray() {
/** * Copies {@code dst.length} floats from the memory pointed to by this * {@link FloatPtr} to {@code dst}. * * @param dst the destination. */ public void get(float[] dst) { get(dst, 0, dst.length); }
public void setVertexSamplerStates(MTLSamplerState[] samplers, float[] lodMinClamps, float[] lodMaxClamps, NSRange range) { MTLSamplerState.MTLSamplerStatePtr sptr = new MTLSamplerState.MTLSamplerStatePtr(); sptr.set(samplers); FloatPtr minptr = new FloatPtr(); minptr.set(lodMinClamps); FloatPtr maxptr = new FloatPtr(); maxptr.set(lodMaxClamps); setVertexSamplerStates(sptr, minptr, maxptr, range); } /**
/** * Copies {@code src.length} floats from {@code src} to the memory pointed to by * this {@link FloatPtr}. * * @param src the source. */ public void set(float[] src) { set(src, 0, src.length); }
@Callback private static void cbEvaluate(@Pointer long infoId, FloatPtr inDataPtr, FloatPtr outDataPtr) { Info info = null; synchronized (infos) { info = infos.get(infoId); } float[] inData = inDataPtr.toFloatArray((int) info.domainDimension); float[] outData = new float[(int) info.rangeDimension]; info.evaluate.evaluate(inData, outData); outDataPtr.set(outData); } @Callback
public void setProperty(AudioFileProperty id, float value) throws OSStatusException { setProperty(id, new FloatPtr(value)); } public void setProperty(AudioFileProperty id, double value) throws OSStatusException {
public float[] getOutputDataAsFloatArray() { FloatPtr ptr = getOutputDataPointer().as(FloatPtr.class); return ptr.toFloatArray(getOutputDataSize()); } public double[] getOutputDataAsDoubleArray() {
/** * @since Available in iOS 5.0 and later. */ public float[] getCleanTexCoords() { FloatPtr lowerLeft = new FloatPtr(); FloatPtr lowerRight = new FloatPtr(); FloatPtr upperRight = new FloatPtr(); FloatPtr upperLeft = new FloatPtr(); getCleanTexCoords(lowerLeft, lowerRight, upperRight, upperLeft); float[] coords = {lowerLeft.get(), lowerRight.get(), upperRight.get(), upperLeft.get()}; return coords; } /*<methods>*/
public float getPropertyAsFloat(AudioFileStreamProperty id) throws OSStatusException { FloatPtr ptr = getProperty(id, FloatPtr.class); return ptr.get(); } public double getPropertyAsDouble(AudioFileStreamProperty id) throws OSStatusException {
public void setSamplerStates(MTLSamplerState[] samplers, float[] lodMinClamps, float[] lodMaxClamps, @ByVal NSRange range) { MTLSamplerState.MTLSamplerStatePtr sptr = new MTLSamplerState.MTLSamplerStatePtr(); sptr.set(samplers); FloatPtr minptr = new FloatPtr(); minptr.set(lodMinClamps); FloatPtr maxptr = new FloatPtr(); maxptr.set(lodMaxClamps); setSamplerStates(sptr, minptr, maxptr, range); }