My projects: SUGG (M, KS), SYNONS, URLS, SIMILAR, Misc: 3Dengine, UniteHowTo, FliCC, TripIdeas, My blog.
Old/abandoned: TheRarestWords (TcCrnch).
Hi, I'm Slava V. and I develop those projects in free time. rarestwords@mail.ru
To main page | 3dengine.org

Draw a grid (OpenGL)


Example of drawing a 0 to 10 units grid in XZ (terrain) plane.
glColor3f(.3,.3,.3);
glBegin(GL_QUADS);
glVertex3f( 0,-0.001, 0);
glVertex3f( 0,-0.001,10);
glVertex3f(10,-0.001,10);
glVertex3f(10,-0.001, 0);
glEnd();

glBegin(GL_LINES);
for(int i=0;i<=10;i++) {
    if (i==0) { glColor3f(.6,.3,.3); } else { glColor3f(.25,.25,.25); };
    glVertex3f(i,0,0);
    glVertex3f(i,0,10);
    if (i==0) { glColor3f(.3,.3,.6); } else { glColor3f(.25,.25,.25); };
    glVertex3f(0,0,i);
    glVertex3f(10,0,i);
};
glEnd();