PDA

View Full Version : how can i design a grid



vanitha
03-17-2006, 02:44 AM
Hi! everyone

i am indeed to develop a application which is used to import some CAD files. i need to display grids in the opengl viewport. please send me some example codes.


thank you

songho
03-17-2006, 09:07 AM
I had really bad experience importing CAD data into OpenGL. CAD data consist of natively lines and arcs, but OpenGL is interested in polygon to render faces. Holes and overlapped surfaces are everywhere after conversion. I spent most of time to fix this problems manually during the project.

Anyway, drawing grid line is very simple in OpenGL, for example:

glBegin(GL_LINES);
glVertex3f(0,0,0); // a pair of vertice (2 end points of line)
glVertex3f(1,1,0);
glEnd();It will draw a line between (0,0,0) and (1,1,0). Since the grid is static, it is a good idea to put it into a display list.