Hi,
I am very new in openGL so I have one question regarding glOrtho(…) and rendering of 2D points.
-
I have 3D points and I project them onto a plane and I remove the z-coordinate so I consider them as 2D points. So here is the question: Did someone know a better way of getting 2D points out of 3D points.
-
After projecting them to a plane I wand to visualize them and have written some code for that. However, the problem is the glOrtho which is at the moment defined as
glOrtho(-1,1, -1,1, -1,1) and when the points are between 0.0 and 1.0 they are visualized fine, but this is not the case the are somewhere in the 3D space and have values different values.
So, can any one help me on this. How can I set up the glOrtho(…) or should I normalize the points?
Thanks
Padre
P.S The code looks like this:
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_DEPTH_TEST);
glDisable(GL_POINT_SMOOTH);
GLint vp[4];
glGetIntegerv(GL_VIEWPORT, vp);
glPushAttrib(GL_LIGHTING_BIT);
glDisable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-1,1, -1,1, -1,1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glPointSize(10);
//some points for testing purposes. Here should come my points!!!
glBegin(GL_POINTS);
{
glColor3f(1.0F,0.0F,0.0F); glVertex2f(2.25F,0.25F);
glColor3f(0.0F,1.0F,0.0F); glVertex2f(-0.25F,-0.25F);
glColor3f(0.0F,0.0F,1.0F); glVertex2f(-0.5F,-0.5F);
}
glEnd();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPopAttrib();
glPopAttrib();