I declared an array and pass a 2D array as a parameter. However I keep getting the same error: subscripted value is neither array nor pointer nor vector. for this line: vertex[i][j-1] = shape[i][j];
How can I solve it?
header file:
GLfloat mijnplayer [][4] ={
{0,-0.091057,0.198079,0.084590},
{0,-0.158043,0.158043,0.071039},
{0,-0.071039,0.158043,0.158043}};
function call:
int main(void)
{
drawVertex(mijnplayer,3,1);
}
void drawVertex(GLfloat shape[][4], int numberVertex, int shape)
{
int i,j;
GLfloat vertex[][3]={0};
//convert 4element array to 3 element array
for(i=0;i<numberVertex;i++)
{
for(j=1;j<4;j++)
{
vertex[i][j-1] = shape[i][j];
}
}
for(i=0;i<numberVertex;i++)
{
glVertex3fv(vertex[i]);
}
}
EDIT:
the complete compiler output:
cc -c -o mijnTest.o mijnTest.c
mijnTest.c:23:59: error: conflicting types for ‘shape’
void drawVertex(GLfloat shape[][4], int numberVertex, int shape) ^
mijnTest.c:23:25: note: previous definition of ‘shape’ was here
void drawVertex(GLfloat shape[][4], int numberVertex, int shape) ^
mijnTest.c: In function ‘drawVertex’:
mijnTest.c:43:26: error: subscripted value is neither array nor pointer nor vector
vertex[i][j-1] = shape[i][j]; ^
mijnTest.c: In function ‘drawScene’:
mijnTest.c:69:2: warning: passing argument 1 of ‘drawVertex’ from incompatible pointer type [enabled by default]
drawVertex(assen,6,0); ^
mijnTest.c:23:6: note: expected ‘GLfloat ()[4]’ but argument is of type ‘GLfloat ()[3]’
void drawVertex(GLfloat shape[][4], int numberVertex, int shape) ^
make: *** [mijnTest.o] Error 1
mijnTest.c:23:59: error: conflicting types for ‘shape’. That should lead you to take a close look at the function declaration and its arguments.drawVertex()that are both named `shape'