// =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== //public synchronized void update(final float pWidth, final float pHeight) { public void Update(float pWidth, float pHeight) { lock (_methodLock) { int x = FLOAT_TO_RAW_INT_BITS_ZERO; int y = FLOAT_TO_RAW_INT_BITS_ZERO; int x2 = Float.FloatToRawIntBits(pWidth); int y2 = Float.FloatToRawIntBits(pHeight); int[] bufferData = this.mBufferData; bufferData[0] = x; bufferData[1] = y; bufferData[2] = x; bufferData[3] = y2; bufferData[4] = x2; bufferData[5] = y; bufferData[6] = x2; bufferData[7] = y2; FastFloatBuffer buffer = this.GetFloatBuffer(); buffer.Position(0); buffer.Put(bufferData); buffer.Position(0); base.SetHardwareBufferNeedsUpdate(); } }
/** * Converts float data to a format that can be quickly added to the buffer * with {@link #put(int[])} * * @param data * @return the int-formatted data */ //public static int[] convert(final float ... data) { public static int[] Convert(params float[] data) { int length = data.Length; int[] id = new int[length]; for (int i = 0; i < length; i++) { id[i] = Float.FloatToRawIntBits(data[i]); } return(id); }
// =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== public /*synchronized*/ void Update(float pX1, float pY1, float pX2, float pY2) { lock (_methodLock) { int[] bufferData = this.mBufferData; bufferData[0] = Float.FloatToRawIntBits(pX1); bufferData[1] = Float.FloatToRawIntBits(pY1); bufferData[2] = Float.FloatToRawIntBits(pX2); bufferData[3] = Float.FloatToRawIntBits(pY2); FastFloatBuffer buffer = this.GetFloatBuffer(); buffer.Position(0); buffer.Put(bufferData); buffer.Position(0); base.SetHardwareBufferNeedsUpdate(); } }
/** * It's like {@link FloatBuffer#put(float[])}, but about 10 times faster */ public void Put(float[] data) { int length = data.Length; int[] ia = sWeakIntArray.Get(); if (ia == null || ia.Length < length) { ia = new int[length]; sWeakIntArray = new SoftReference <int[]>(ia); } for (int i = 0; i < length; i++) { ia[i] = Float.FloatToRawIntBits(data[i]); } ByteBuffer byteBuffer = this.mByteBuffer; byteBuffer.Position(byteBuffer.Position() + GLHelper.BYTES_PER_FLOAT * length); FloatBuffer floatBuffer = this.mFloatBuffer; floatBuffer.Position(floatBuffer.Position() + length); this.mIntBuffer.Put(ia, 0, length); }
// =========================================================== // Methods // =========================================================== //public synchronized void update() { public void Update() { lock (_methodLock) { BaseTextureRegion textureRegion = this.mTextureRegion; Texture texture = textureRegion.GetTexture(); if (texture == null) { return; } int x1 = Float.FloatToRawIntBits(this.GetX1()); int y1 = Float.FloatToRawIntBits(this.GetY1()); int x2 = Float.FloatToRawIntBits(this.GetX2()); int y2 = Float.FloatToRawIntBits(this.GetY2()); int[] bufferData = this.mBufferData; if (this.mFlippedVertical) { if (this.mFlippedHorizontal) { bufferData[0] = x2; bufferData[1] = y2; bufferData[2] = x2; bufferData[3] = y1; bufferData[4] = x1; bufferData[5] = y2; bufferData[6] = x1; bufferData[7] = y1; } else { bufferData[0] = x1; bufferData[1] = y2; bufferData[2] = x1; bufferData[3] = y1; bufferData[4] = x2; bufferData[5] = y2; bufferData[6] = x2; bufferData[7] = y1; } } else { if (this.mFlippedHorizontal) { bufferData[0] = x2; bufferData[1] = y1; bufferData[2] = x2; bufferData[3] = y2; bufferData[4] = x1; bufferData[5] = y1; bufferData[6] = x1; bufferData[7] = y2; } else { bufferData[0] = x1; bufferData[1] = y1; bufferData[2] = x1; bufferData[3] = y2; bufferData[4] = x2; bufferData[5] = y1; bufferData[6] = x2; bufferData[7] = y2; } } FastFloatBuffer buffer = this.GetFloatBuffer(); buffer.Position(0); buffer.Put(bufferData); buffer.Position(0); base.SetHardwareBufferNeedsUpdate(); } }
public static uint FloatToIntColor(float value) { return(Float.FloatToRawIntBits(value)); }