I have recently started doing some things in my iOS app using OpenGL.
I found this tutorial which has been a tremendous help:
www.raywenderlich.com/3664/opengl-es-2-0-for-iphone-tutorial .
typedef struct
{
float Position[3];
float Color[4];
} Vertex;
const Vertex Vertices[] = { ... };
const GLubyte Indices[] = { ... };
glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices), Indices, GL_STATIC_DRAW);
I need an array of variables/structs since the content is dependent on what happens at runtime and is not static.
How do I define and create a dynamic array when I don't know the number of elements in the array until runtime?
Do I need to use malloc or something like that? I haven't come across any examples of allocating memory for an iPhone app before so I'm a little wary. Any advice or direction would be appreciated.
GLFloat vertices[someVariable];