Ok…here’s some simplified source code.(It draws a grid of lines. Notice the clipping on the front and back of the surface.
I’m not sure if this is Linux specific, but after comparing with some other platform code, I feel it might be.
Also, I’ve tried things like gluOrtho and tried a bunch of other random stuff, and ju
st can’t figure out what I need to adjusting the clipping bounds.
/************************ clippingprob.c **
*******************************************/
#include <GL/gl.h>
#include <GL/glut.h>
void display(void);
void Line(GLfloat, GLfloat, GLfloat, GLfloat);
int main(int argc, char** argv)
{
glutInit (&argc, argv) ;
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB) ;
glutInitWindowSize (500, 500) ;
glutInitWindowPosition (100, 100) ;
glutCreateWindow (“OpenGL Display Window”) ;
glClearColor(0.0, 0.0, 0.0, 0.0) ;
glMatrixMode(GL_PROJECTION);
glutDisplayFunc (display) ;
glutMainLoop () ;
return 0 ;
}
void display(void)
{
int idx;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ;
glLoadIdentity();
glRotatef(80.0, 1.5f, 0.7f, 0.0f);
//Draw a 20x20 line grid from (-1.0,-1.0,0.0) through (1.0,1.0,0.0);
glColor3f(1.0f,1.0f,1.0f);
for(idx = 0; idx <= 20; idx++)
Line(1.0f, (-1.0f) + (GLfloat)idx / 10.0f,
-1.0f, (-1.0f) + (GLfloat)idx / 10.0f);
for(idx = 0; idx <= 20; idx++)
Line((-1.0f) + (GLfloat)idx / 10.0f, -1.0f,
(-1.0f) + (GLfloat)idx / 10.0f, 1.0f);
glutSwapBuffers();
}
void Line(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) {
glBegin(GL_LINES);
glVertex2f(x1,y1);
glVertex2f(x2,y2);
glEnd();
}
/********************* EOF *****************/
compilation: gcc clippingprob.c -lGL -lGLU -lglut -lm -o clippingprob
Thanks