In my OpenGL ES 2.0 project I have the following code in an object which initialises a Vertice and an Indice c-Struct array :
Vertex Vertices [] = {
{{0.0, 0.0, 0}, {0.9, 0.9, 0.9, 1}},
{{0.0 , 0.0 , 0}, {0.9, 0.9, 0.9, 1}},
{{0.0, 0.0, 0}, {0.9, 0.9, 0.9, 1}},
{{0.0, 0.0, 0}, {0.9, 0.9, 0.9, 1}},
};
static GLubyte Indices []= {
0, 0, 0,
0, 0, 0,
0, 0, 0,
0, 0, 0,
};
As I have different polygons that I want to render, I want to be able to set the Vertices and Indices dynamically from the calling class. I have tried just putting :
Vertex Vertices [] = {
};
static GLubyte Indices []= {
};
This is where I set the vertices to my verticeArray (this is the array which is set from the calling class).
- (void)setupMesh {
int count = 0;
for (VerticeObject * object in verticesArray) {
Vertices[count].Position[0] = object.x;
Vertices[count].Position[1] = object.y;
Vertices[count].Position[2] = object.z;
count ++;
}
}
However this causes a crash, I assume because the array is never alloced / memory allocated. Can anyone suggest how I can achieve this ?