Well, I got the VA and VBO working and didn't gain any performance improvements over my Display List.
Below is my VBO test
Code:
float[] xyz;
float[] rgb;
FloatBuffer f;
FloatBuffer c;
void initEdges(){
int count = 0;
xyz=new float[2*3*Edges.length];
rgb=new float[2*4*Edges.length];
Edge e1;
Node n1, n2;
float z1,z2;
for (int i = 0; i < Edges.length; i++) {
e1 = Edges[i];
n1 = e1.n1;
n2 = e1.n2;
xyz[count*3]=n1.x;
xyz[count*3+1]=n1.y;
xyz[count*3+2]=n1.z;
rgb[count*4]=e1.c.c1;
rgb[count*4+1]=e1.c.c2;
rgb[count*4+2]=e1.c.c3;
rgb[count*4+3]=linealpha;
count++;
xyz[count*3]=n2.x;
xyz[count*3+1]=n2.y;
xyz[count*3+2]=n2.z;
rgb[count*4]=e1.c.c1;
rgb[count*4+1]=e1.c.c2;
rgb[count*4+2]=e1.c.c3;
rgb[count*4+3]=linealpha;
count++;
}
f = ByteBuffer.allocateDirect(8 * xyz.length).order(ByteOrder.nativeOrder()).asFloatBuffer();
f.put(xyz);
f.rewind();
c = ByteBuffer.allocateDirect(4 * rgb.length).order(ByteOrder.nativeOrder()).asFloatBuffer();
c.put(rgb);
c.rewind();
}
Code:
gl.glLineWidth(2.0);
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL.GL_COLOR_ARRAY);
gl.glVertexPointer(3,GL.GL_FLOAT,0,f);
gl.glColorPointer(4,GL.GL_FLOAT,0,c);
gl.glDrawArrays(GL.GL_LINES,0,f.capacity()/6);
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
gl.glDisableClientState(GL.GL_COLOR_ARRAY);
Here is my VA
Code:
FloatBuffer vbuffer;
FloatBuffer cbuffer;
int edgeList;
void initEdges(){
int count = 0;
for (int i = 0; i < Edges.length; i++) {
if (Edges[i].enablecat == true) {
count++;
}
}
edgepointer = new int[count*2][3];
Edge e1;
Node n1, n2;
int z1,z2;
count = 0;
vbuffer = BufferUtil.newFloatBuffer(Edges.length * 8);
cbuffer = BufferUtil.newFloatBuffer(Edges.length * 4);
for (int i = 0; i < Edges.length; i++) {
e1 = Edges[i];
n1 = e1.n1;
n2 = e1.n2;
vbuffer.put(n1.x);
vbuffer.put(n1.y);
vbuffer.put(n1.z);
vbuffer.put(n2.x);
vbuffer.put(n2.y);
vbuffer.put(n2.z);
cbuffer.put(e1.c.c1);
cbuffer.put(e1.c.c2);
cbuffer.put(e1.c.c3);
cbuffer.put(linealpha);
}
vbuffer.rewind();
cbuffer.rewind();
gl.glLineWidth(2);
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glVertexPointer(3, GL.GL_FLOAT, 0, vbuffer);
gl.glEnableClientState(GL.GL_COLOR_ARRAY);
gl.glColorPointer(4, GL.GL_FLOAT, 0, cbuffer);
}
Code:
gl.glDrawArrays(GL.GL_LINES, 0, Edges.length);