In my application, I'm having to draw multiple elements with OpenGL, some are Triangles and others are Line Strips. I'm putting my vertices into multiple float[] and my indices into multiple short[] whenever I am to draw a new shape. I also have to create a new FloatBuffer, ShortBuffer and ByteBuffer for each new array in order to make it work.
How could I more efficiently draw the multiple elements? I was thinking of putting all of the vertices into a single float[] and creating a new short[] for each element to remove excess arrays, but is it possible to use one FloatBuffer, ShortBuffer and put all of the arrays into a single ByteBuffer such as this:
float[] vertices = { -3, -3, -3, 2, 3, 0, 2, -1, 0, 0, 5, 2, 3, 1 };
short[] indItemA = { 0, 1, 2, 0, 2, 3 };
short[] indItemB = { 4, 5, 6 };
FloatBuffer fBuff;
ShortBuffer sBuff;
ByteBuffer bBuff = ByteBuffer.allocateDirect(vertices.length * 4);
fbBuff.order(ByteOrder.nativeOrder());
fBuff = bBuff.asFloatBuffer();
fBuff.put(vertices);
fBuff.position(0);
sBuff = bBuff.asShortBuffer();
sBuff.put(indItemA);
sBuff.position(0);
sBuff.put(indItemB);
sBuff.position(0);