How to setup glOrtho(..) for rendering 2D points

Hi,

I am very new in openGL so I have one question regarding glOrtho(…) and rendering of 2D points.

  1. 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.

  2. 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();

What do you mean by normalizing the points? Here are some thoughts.

First, you can either send your points down in 2D (no Z) as your doing, or send them down in 3D with a glScale(1,1,0) in your modelview matrix. That will flatten out the points to the z=0 plane for you. Probably better to do it the way you’re doing it now. You can do it this way, though, as you can then add a glTranslate to move the points up and down the z axis.

Second, glOrtho is the range you’ll see on your screen. Like specifying the box of your world and it will squish everything in that world down to the edges of the screen. If the x-ranges go from -100 to 100, you’ll see points like 78, 24, -13, but not 121, -178, etc.