Marking points in space

I have drawn a grid and i’d like to somehow mark some 3d points. I have tried to draw spheres centered in these points, but a sphere that is closer will be larger than a sphere that is further away from the eye. I would like them all to be the same size when seen from any point.

I have also tried to draw them in 2D by using glRasterPos3f and glDrawPixels, but if I use this approach, how can I center the bitmap (or whatever I draw with glDrawPixels) in a point?

Hope I’ve made myself clear. Thank you in advance!

glBegin(GL_POINTS);

You didn’t understand what I want.
How can I use GL_POINTS?
A point is very small. I have to use something that can be seen and has the same size no matter how far the eye point is.

Sektor, you didn’t understood.

Just draw your points using:

glBegin(GL_POINTS);
glVertex…

glVertex
glEnd();

And the points will all have the same size.

The points will indeed have the same size if I use GL_POINTS, but you see, a single point is not visible! I want something bigger, that can be seen.

Then have a look at glPointSize()

Now you’re talking! Thanks a lot.

But now I see the “big” point as a square. Any way to make it a circle?

You could try:

glEnable(GL_POINT_SMOOTH);

for starters.

I already tried that, because I read about it at the glPointSize man page, but it’s still a square.

Done! Blending was not enabled. Thanks a lot!

You are welcome.

Why not just go for a:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-windowWidth / 2, windowWidth / 2,
-windowHeight / 2, windowHeight / 2,
-100.0, 100.0);

The last two values, resize at your desire.
This would create a good orthographic volume where everything would be of the same size (as long as it is the same size) regardless of the distance. Also try looking up ways to use gluUnproject. This should help you “pointing” point in 3d space. If you don’t want an orthographic projection, try scaling the object according to depth. I mean the further away, the bigger they get so to the eye its the same size. Hope I helped!

I used glBegin( GL_POINTS ) and glPointSize to do what I wanted. It’s great, but I have another question now: how can I select the points? I mean, when the user clicks on the screen, I want to be able to know if he clicked on a point and if so, on which one?

Any help will be appreciated.
Thanks!

[This message has been edited by Sektor (edited 02-18-2004).]

No ideas? Please, I really must have this ready by the end of the week. If you have any suggestions at all, I would be grateful.

I’m gonna rephrase the question:
I have drawn a point (using GL_POINTS), but have used glPointSize to modify its size. Is there a way to know the location of the point in screen coordinates and the side of the square (also in screen coordinates)? (Because if you don’t use antialiasing and increase the point size, it will look like a square.)

[This message has been edited by Sektor (edited 02-18-2004).]

Look at OpenGL selection/picking (e.g. RedBook examples select.c, picksquare.c, and pickdepth.c).

Note, I often use the address of the object I’m picking (e.g. pointer to F16 class instance) as the name that I load. This makes determining what’s selected explicit rather than using some sort of mapping.

Originally posted by Sektor:
Is there a way to know the location of the point in screen coordinates )?

You can try gluProject. However, I would recommend picking mechanism instead.

[This message has been edited by brcain (edited 02-18-2004).]

Originally posted by brcain:
[b]Look at OpenGL selection/picking (e.g. RedBook examples select.c, picksquare.c, and pickdepth.c).

Note, I often use the address of the object I’m picking (e.g. pointer to F16 class instance) as the name that I load. This makes determining what’s selected explicit rather than using some sort of mapping.[/b]

Thanks a lot! I read the chapter in the Red book and it worked just fine!