package org.glscene.util;
import java.io.IOException;
import java.io.Serializable;
import javax.microedition.khronos.opengles.GL10;
import org.glscene.geometry.Vectors2f;
public class DirectFloatBuffer extends DirectBuffer implements Serializable {
public static final long serialVersionUID = 1L;
public DirectFloatBuffer(Vectors2f vecCoords) {
fGLSize = 2;
if (vecCoords == null) {
allocate(0);
} else {
allocate(vecCoords.size()*2*4);
put(vecCoords);
}
}
@Override
public int GLType() { return GL10.GL_FLOAT; }
private void writeObject(java.io.ObjectOutputStream out) throws IOException {
if (fBuffer == null) {
out.writeInt(0);
} else {
int n = fBuffer.capacity() >> 2;
out.writeInt(n);
for (int i=0; i<n; i++) {
out.writeFloat(fBuffer.getFloat(i));
}
}
}
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
int n = in.readInt();
allocate(n);
if (n > 0) {
n >>= 2;
for (int i=0; i<n; i++) {
fBuffer.putFloat(i, in.readFloat());
}
}
}
}
|