hey,
i got a problem, i'm trying to create a 2d map from a 2 dimensional array, with x,y and z in it.
when i add the lines to raise the z he gives a array, i think its somethign in my syntax:
sy1 = sy - map[y][x];
ey1 = sy - map[y][x+1];
sy2 = ey - map[y+1][x];
ey2 = ey - map[y+1][x+1];
can someone help me ?
Code:
int DrawGLScene(GLvoid){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
GLfloat x, y;
int maxX = 10;
int maxY = 10;
int mX,mY,sy,ey,sx1,sx2,ex1,ex2,sy1,sy2,ey1,ey2;
mX = maxX * gridX + maxY * gridX;
mY = maxY * gridX;
for ( y=0; y < maxY; y++ )
{
sy = y * gridY;
ey = sy + gridY;
for (x=0; x < maxX; x++ )
{
sx1 = x - ( ( mX - x ) * gridX + ( y * gridX ) );
ex1 = sx1 + gridX;
sx2 = sx1 - gridX;
ex2 = ex1 - gridX;
sy1 = sy - map[y][x];
ey1 = sy - map[y][x+1];
sy2 = ey - map[y+1][x];
ey2 = ey - map[y+1][x+1];
glColor3f(1.0,0.5f,1.0f);
glBegin(GL_QUADS);
glVertex3f( sx1, sy1, 0.0f);
glVertex3f( ex1, ey1, 0.0f);
glVertex3f( ex2, ey2, 0.0f);
glVertex3f( sx2, sy2, 0.0f);
glEnd();
glLoadIdentity();
}
}
return TRUE; // Keep Going
}
compiling:
Code:
C:\Documents and Settings\Maurad3r\Bureaublad\Lesson04\lesson4.cpp(101) : error C2108: subscript is not of integral type
C:\Documents and Settings\Maurad3r\Bureaublad\Lesson04\lesson4.cpp(101) : error C2108: subscript is not of integral type
C:\Documents and Settings\Maurad3r\Bureaublad\Lesson04\lesson4.cpp(101) : error C2113: pointer can only be subtracted from another pointer
C:\Documents and Settings\Maurad3r\Bureaublad\Lesson04\lesson4.cpp(102) : error C2108: subscript is not of integral type
C:\Documents and Settings\Maurad3r\Bureaublad\Lesson04\lesson4.cpp(102) : error C2108: subscript is not of integral type
C:\Documents and Settings\Maurad3r\Bureaublad\Lesson04\lesson4.cpp(102) : error C2113: pointer can only be subtracted from another pointer
C:\Documents and Settings\Maurad3r\Bureaublad\Lesson04\lesson4.cpp(104) : error C2108: subscript is not of integral type
C:\Documents and Settings\Maurad3r\Bureaublad\Lesson04\lesson4.cpp(104) : error C2108: subscript is not of integral type
C:\Documents and Settings\Maurad3r\Bureaublad\Lesson04\lesson4.cpp(104) : error C2113: pointer can only be subtracted from another pointer
C:\Documents and Settings\Maurad3r\Bureaublad\Lesson04\lesson4.cpp(105) : error C2108: subscript is not of integral type
C:\Documents and Settings\Maurad3r\Bureaublad\Lesson04\lesson4.cpp(105) : error C2108: subscript is not of integral type
C:\Documents and Settings\Maurad3r\Bureaublad\Lesson04\lesson4.cpp(105) : error C2113: pointer can only be subtracted from another pointer