/** Creates a new float buffer by wrapping the given float array. * <p> * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. * </p> * * @param array the float array which the new buffer will be based on. * @return the created float buffer. * @since Android 1.0 */ public static FloatBuffer wrap (float[] array) { return wrap(array, 0, array.length); }
/** Creates a new float buffer by wrapping the given float array. * <p> * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. * </p> * * @param array the float array which the new buffer will be based on. * @return the created float buffer. * @since Android 1.0 */ public static FloatBuffer wrap (float[] array) { return wrap(array, 0, array.length); }
/** * Creates a new float buffer by wrapping the given float array. * <p> * Calling this method has the same effect as * {@code wrap(array, 0, array.length)}. * * @param array * the float array which the new buffer will be based on. * @return the created float buffer. */ public static FloatBuffer wrap(float[] array) { return wrap(array, 0, array.length); }
@Override public void run() { GLES20.glUniform3fv(location, 1, FloatBuffer.wrap(arrayValue)); } });
@Override public void run() { GLES20.glUniform4fv(location, 1, FloatBuffer.wrap(arrayValue)); } });
@Override public void run() { GLES20.glUniform2fv(location, 1, FloatBuffer.wrap(arrayValue)); } });
@Override public void run() { GLES20.glUniform1fv(location, arrayValue.length, FloatBuffer.wrap(arrayValue)); } });
@Override public FloatBuffer filter(float sx, float sy, float base, FloatBuffer buffer, int size) { float[] data = buffer.array(); float[] retval = new float[data.length]; for (int y = this.radius; y < size - this.radius; y++) { for (int x = this.radius; x < size - this.radius; x++) { int idx = y * size + x; float n = 0; for (int i = -this.radius; i < this.radius + 1; i++) { for (int j = -this.radius; j < this.radius + 1; j++) { n += data[(y + i) * size + x + j]; } } retval[idx] = this.effect * n / (4 * this.radius * (this.radius + 1) + 1) + (1 - this.effect) * data[idx]; } } return FloatBuffer.wrap(retval); } }
@Override public void run() { ifNeedInit(); GLES20.glUniform2fv(location, 1, FloatBuffer.wrap(arrayValue)); } });
@Override public void run() { ifNeedInit(); GLES20.glUniform3fv(location, 1, FloatBuffer.wrap(arrayValue)); } });
@Override public void run() { ifNeedInit(); GLES20.glUniform4fv(location, 1, FloatBuffer.wrap(arrayValue)); } });
@Override public void run() { ifNeedInit(); GLES20.glUniform1fv(location, arrayValue.length, FloatBuffer.wrap(arrayValue)); } });
return FloatBuffer.wrap(retval);
@Override public FloatBuffer filter(float sx, float sy, float base, FloatBuffer data, int workSize) { float[] arr = data.array(); int origSize = (int) Math.ceil(workSize / (2 * this.magnitude + 1)); int offset = (workSize - origSize) / 2; Logger.getLogger(PerturbFilter.class.getCanonicalName()).info( "Found origSize : " + origSize + " and offset: " + offset + " for workSize : " + workSize + " and magnitude : " + this.magnitude); float[] retval = new float[workSize * workSize]; float[] perturbx = new FractalSum().setOctaves(8).setScale(5f).getBuffer(sx, sy, base, workSize).array(); float[] perturby = new FractalSum().setOctaves(8).setScale(5f).getBuffer(sx, sy, base + 1, workSize).array(); for (int y = 0; y < workSize; y++) { for (int x = 0; x < workSize; x++) { // Perturb our coordinates float noisex = perturbx[y * workSize + x]; float noisey = perturby[y * workSize + x]; int px = (int) (origSize * noisex * this.magnitude); int py = (int) (origSize * noisey * this.magnitude); float c00 = arr[this.wrap(y - py, workSize) * workSize + this.wrap(x - px, workSize)]; float c01 = arr[this.wrap(y - py, workSize) * workSize + this.wrap(x + px, workSize)]; float c10 = arr[this.wrap(y + py, workSize) * workSize + this.wrap(x - px, workSize)]; float c11 = arr[this.wrap(y + py, workSize) * workSize + this.wrap(x + px, workSize)]; float c0 = ShaderUtils.mix(c00, c01, noisex); float c1 = ShaderUtils.mix(c10, c11, noisex); retval[y * workSize + x] = ShaderUtils.mix(c0, c1, noisey); } } return FloatBuffer.wrap(retval); }
@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(); }
@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 Pointer to the given values. * The values may not be null. * * @param values The values the pointer should point to * @return The pointer */ public static Pointer to(float values[]) { return new Pointer(FloatBuffer.wrap(values)); }
protected static FloatBuffer allocateFloatBuffer(float[] arr) { if (USE_DIRECT_BUFFERS) { FloatBuffer buf = allocateDirectFloatBuffer(arr.length); buf.put(arr); buf.position(0); return buf; } else { return FloatBuffer.wrap(arr); } }