I’m playing around with OpenGL ES 2.0 in Android, and looking through the docs for GLES20 I came across the following methods:
public static void glDrawElements(
int mode, int count, int type, Buffer indices)
public static void glDrawElements(
int mode, int count, int type, int offset)
public static void glVertexAttribPointer(
int indx, int size, int type, boolean normalized, int stride, Buffer ptr)
public static void glVertexAttribPointer(
int indx, int size, int type, boolean normalized, int stride, int offset)
The two methods that take Buffer objects make sense to me, but the other two don’t. Where do they get the indices/attibute-values (respectively), and what is offset an offset into? (I assume these two questions have the same answer.)
Offset in the prototype means that you are submitting the INDEX array in prior to this call.That should be used if you are using VBO’s(Vertex Buffer Objects).Use glBindBuffer to bind the index buffer and specify an offset if needed in the next call.
First you need to bind the buffer(Index buffer here) and you can specify from where your elements start with an ‘offset’.
for
This means that you are submitting vertex buffer in prior to this call and you can specify the offset from where it should take with in the buffer.
Please check the following link for additional help.
http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Chapter-2.3:-Rendering.html
As you expected, The both have the same reason 🙂 .Hope this helps!
Update: you need to create a buffer to bind it.This can be done by the following steps.
Check this link for creating a VBO. http://www.opengl.org/wiki/Vertex_Buffer_Object
Regarding the Offset type: The offset is passed as a pointer, but the parameter is used for its integer value, so we pass an integer cast to void*.