/* gcc -Wall -o test test.c -lGL -lglut */ #include #include void render() { GLfloat x, y, z; glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0f, 1.0f, 1.0f); glBegin(GL_LINES); for (z=0.0f; z <= 100.0f; z += 1.0f) { for (y=0.0f; y <= 100.0f; y += 1.0f) { for (x=0.0f; x <= 100.0f; x += 1.0f) { glVertex3f(-x, -y, -z); glVertex3f(x, y, z); } } } glEnd(); glutSwapBuffers(); } void changesize(GLsizei w, GLsizei h) { glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-100.0f, 100.0f, -100.0f, 100.0f, -100.0f, 100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } int main(int argc, char *argv[]) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize(800,800); glutCreateWindow("Test"); glutDisplayFunc(render); glutReshapeFunc(changesize); glutMainLoop(); return 0; }