drawing verticle lines

Hi
I have drawn verticle lines for a grid
glVertex3d(-30.0, -3.0, -16.0);
glVertex3d(-30.0, -3.0, 16.0);
.
.
glVertex3d(30.0, -3.0, -16.0);
glVertex3d(30.0, -3.0, 16.0);

how could I code it more efficiently I thought of doing it in a for-loop but the program hangs up
int vertx, vertz;
for (vertx=-30,vertz=-16; vertx<=30; vertx+2)
for(vertx=-30, vertz=16; vertx<=30;vertx+2)
glMaterialfv(GL_FRONT, GL_AMBIENT, GreenSurface);
glBegin(GL_LINES);
glVertex3d(vertx, -3.0, vertz);
glEnd();

With those two loops, the param vertz is always set to 16 no ???

U should also (that’s not a bug) put the loop between ur glBegin()-glEnd();

if i were you, i would try:

glBegin(GL_LINES);
for (vertx = -30 ; vertx <= 30 ; vertx +=2)
{
glVertex3d(vertx, -3.0, -16);
glVertex3d(vertx, -3.0, 16);
}

for (vertz = -16 ; vertz <= 16 ; vertz +=2)
{
glVertex3d(-30.0, -3.0, vertz);
glVertex3d(30.0, -3.0, vertz);
}
glEnd();

Hope it will help you

Hi,
If this is an actual snipet from your code, then it simply never gets to glMaterial, as there is a problem with the loop.
The inner loop resets the variable of the outer one making it an endless one.
Try something like this:
int vertx;
glMaterialfv(GL_FROMT, GL_AMBIENT, GreenSurface);
glBegin(GL_LINES);
for (vertx=-30; vertx<=30; vertx+=2)
{
glVertex3d(vertx, -3.0, -16);
glVertex3d(vertx, -3.0, 16);

}
glEnd();

thanx, that works!!