public static void glDrawElements(
int mode, int count, int type, int offset)
VBO.
offset - indexVBO ;
, VBO:
import static android.opengl.GLES20.*;
private static final int SIZEOF_SHORT = 2;
void fillIndices() {
int indexAmount = ...;
int sizeBytes = indexAmount * SIZEOF_SHORT;
ShortBuffer indicesS = ByteBuffer.allocateDirect(sizeBytes).order(ByteOrder.nativeOrder()).asShortBuffer();
indicesS.put(getShortIndices(indexAmount));
indicesS.position(0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexVBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeBytes, indicesS, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
short[] getShortIndices(int indexAmount) {
short[] indices = new short[indexAmount];
return indices;
}
glDrawElements()
public void draw(){
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexVBO);
glDrawElements(GL_TRIANGLE_STRIP, indexCount, GL_UNSIGNED_SHORT, firstIndex * SIZEOF_SHORT);}
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT GL_UNSIGNED_INT .