Hi,
Below is all the code applicable
int numberRectangles;
int numberTriangles;
GLfloat rectangles[MAX_SIZE];
GLfloat triangles[MAX_SIZE];
GLfloat quadColours[MAX_SIZE];
GLfloat triColours[MAX_SIZE];
void init (void)
{
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnableClientState(GL_VERTEX_ARRAY);
//glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
}
void OpenMapAndParse ()
{
ifstream fin; //FILE POINTER TO MAP FILE
// float rectangles[MAX_SIZE];
int i;
fin.open("map1.map"); //OPEN THE FILE
//GET WORLD DATA
fin >> worldWidth;
fin >> worldDepth;
fin >> numberRectangles;
fin >> numberTriangles;
//READ RECTANGLE VERTEX DATA
for(i = 0; i < (12 * numberRectangles); i++)
fin >> rectangles[i];
//READ TRIANGLE VERTEX DATA
for(i = 0; i < (9 * numberTriangles); i++)
fin >> triangles[i];
//READ QUAD COLOURS DATA
for(i = 0; i < (12 * numberRectangles); i++)
fin >> quadColours[i];
for(i = 0; i < (9 * numberRectangles); i++)
fin >> triColours[i];
fin.close(); //CLOSE THE FILE
}
int main(int argc, char** argv)
{
//C++ STUFF 1ST
OpenMapAndParse ();
if (worldWidth > worldDepth)
visabilityRange = worldWidth + 10;
if (worldDepth > worldWidth)
visabilityRange = worldDepth + 10;
//OPENGL STUFF 2ND
glutInit ( &argc, argv );
glutInitDisplayMode ( GLUT_DOUBLE | GLUT_RGB );
glutInitWindowSize ( 700, 700 );
glutInitWindowPosition ( 100, 100 );
glutCreateWindow ( "hello" );
init ();
glutDisplayFunc ( display );
glutReshapeFunc ( reshape );
glutKeyboardFunc ( keyboard );
glutSpecialFunc ( keyboardSpecial );
glutMainLoop ();
return 0;
}
That is a large part of my code, It appears to be working now though, I think it may have something to do with the leaving out of the glColorPointer, i had not placed that line in at the time. The map data is as follows now:
60
40
7
4
-25.0 6.0 -5.0 -25.0 6.0 -35.0 -25.0 -1.0 -35.0 -25.0 -1.0 -5.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