GLUT drawing array help.

closed account (2NywAqkS)
I want to draw a map of white squares using glut so I made an array

bool BackArray[10][10] ={
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 1, 0, 0, 0, 0, 0, 0, 1,
1, 0, 1, 0, 1, 0, 0, 0, 0, 1,
1, 0, 1, 0, 1, 0, 0, 0, 0, 1,
1, 0, 1, 0, 1, 0, 0, 0, 0, 1,
1, 0, 1, 0, 1, 0, 0, 0, 0, 1,
1, 0, 0, 0, 1, 0, 0, 0, 0, 1,
1, 0, 1, 1, 1, 1, 1, 1, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1};

and used a FOR loop to display it

void Background(void)
{
for (int ix = 0; ix == 9; ix ++)
{
for (int iy = 0; iy == 9; iy ++)
{
printf ("i");
if (BackArray[ix][iy] == true)
{
glColor3f(1, 1, 1);
glRectf(ix, iy, ix + 10, iy + 10);
}
}
}
}

but nothing except the avatar I made gets displayed in the window. I put in the

printf ("i");

statement to test whether the loop was working but nothing was displayed in the command window. Please help.

I'm only 14 so I've probably made some stupid mistake.
Indeed you did. for loop is written as for(first value of counter(s); loop condition; increment){...}. Your ix==9 is a terminating condition (well, almost. 10 would be). What you need is ix<10 or ix<=9. Same for iy.
closed account (2NywAqkS)
Thank you very much. I thought ix==9 was when the loop terminates but of course its the complete opposite.
Topic archived. No new replies allowed.