simple problem= for loops

what is wrong with this:

int h = 0;
int i = 0;

for (i = 0; i >= 10; i++)
{
glBegin(GL_QUADS);
	glVertex3f(i, h, i);
	glVertex3f(i, h, i-1);
	glVertex3f(i+1, h, i-1);
	glVertex3f(i+1, h, i);
glEnd();
}

nothing is displayed when i run it… but when i remove the loop and keep i=0 it works once?

The glBegin() and glEnd() should not be put into the loop.
Mabye, it will work well like below.

glBegin(GL_QUADS);
for (i = 0; i >= 10; i++)
{
            glVertex3f(i, h, i);
	glVertex3f(i, h, i-1);
	glVertex3f(i+1, h, i-1);
	glVertex3f(i+1, h, i);

}
glEnd();

nothing is displayed when i run it… but when i remove the loop and keep i=0 it works once?[/QB][/QUOTE]

Cool, a “spot the programming error” question. :slight_smile:

i = 0 is not >= 10. The for-loop is not taken.
You probably wanted < 10 to get 10 iterations.

Rest applies, put the glBegin glEnd outside for performance reasons.
Make sure your projection contains the calculated z-coordinates.
If you look at this in a standard glOrtho projection it’s possible to look directly onto the xz-edge, still nothing displayed.

look at your loop condition it says
for(i = 0; i >= 10; i++)

this not satisfied for the initial value of
i = 0 ; 0 < 10

you probably meant i <= 10;