I keep getting "open file failed". I've tried putting the "dino.dat" file in the same folder as the run code. I've tried dropping it into the project itself. Tried "Build Phases" tab under project- copied file there.(????)
void ShowDino()
{
glColor3f(0,0,0); //set the drawing color
glLineWidth(3); //set the point size
//glBegin(GL_POLYGON);
//glVertex2d(randomPx,randomPy); //Set the position of the vertex
ifstream infile;
infile.open ("dino.dat");
if(!infile)
{
cout << "open file failed\n";
exit(0);
}
N_MAP_POINTS=0;
while(!infile.eof())
{
infile >> polylines; //read how many polylines
for(int i = 0; i<polylines; i++)
{
infile>>line;
glBegin(GL_LINE_STRIP);
for(int j = 0;j<line;j++) //read each lines
{
infile >> x >> y;
glVertex2d(x, y);
}
glEnd();
}
I thought I copied the "dino.dat" into the folder where the code resides. In Visual Studio, that's how it works. Thought Xcode might be similar. So, are you telling me I should read the full path kind of like:
infile.open ("/Users/me/Desktop/dino.dat")