I would like to pass a 2D array as a parameter. The issue is that the size of the 2d array always varies. So I can't write something like myfunction(int a[2][5]);
I have a header file containing a lot of 3D-coordinates. e.g.:
float someArray[][3] = {{0.0,1.0,-2.0},{-1.0,1.0,-2.0},{-1.0,1.0,0.0},{0.0,1.0,0.0},
{-1.0,0.75,-2.0},{-1.0,1.0,-2.0},{-1.0,1.0,0.0},{-1.0,0.75,0.0},
{0.0,0.75,-2.0},{0.0,1.0,-2.0},{0.0,1.0,0.0},{0.0,0.75,0.0},
{0.0,0.75,-2.0},{-1.0,0.75,-2.0},{-1.0,0.75,0.0},{0.0,0.75,0.0},
{0.0,0.75,-2.0},{-1.0,0.75,-2.0},{-1.0,1.0,-2.0},{0.0,1.0,-2.0},
};
void drawVertex(const float **vertex, int numberVertex, int shape)
{
int i;
glPushMatrix();
switch(shape)
{
case 0: glBegin(GL_LINES); break;
case 1: glBegin(GL_POLYGON); break;
default: break;
}
for(i=0;i<numberVertex;i++)
{
glVertex3fv(vertex[i]);
}
glEnd();
glPopMatrix();
}
the function calls I tried:
these just crash (core dump)
drawVertex(someArray, 6,1);
drawVertex(*someArray, 6,1);
Should I modify the parameters of the function drawVertex() ? I've tried many things but nothing seems work.