Sometimes you can’t get some things, it happens. For example, I couldn’t learn how to set the parameters related to the count and indices of elements of glDrawElements function correctly until… today:

void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);

You can read the description from Khronos website:

http://www.khronos.org/opengles/documentation/opengles1_0/html/glVertexPointer.html

First of all you should set the vertex pointer array that you are gonna draw. Set the size parameter to specify how many coordinates define a vertex. For my case this is 2. – I’m not gonna explain other parameters –

Then you are gonna draw these vertices using,

void glDrawArrays(GLenum mode, GLint first, GLsizei count);

http://www.khronos.org/opengles/documentation/opengles1_0/html/glDrawArrays.html

I’m always mistaken by the count and indices parameters. first parameter should be set to the starting index of the vertex – not the starting index of the coordinate in the array. count parameter should be set to the number of vertices that you are gonna draw – not to the number of coordinates that represent the number of vertices you are drawing.

This is kind of a “note to self”. Hope it is also useful for you 🙂

Advertisements