problem with using glPointSize...

Started by
5 comments, last by Nathan Baum 17 years, 1 month ago
I tried to display 3 red points, but they are too small to see, so I tried to use glPointSize() to make them bigger, and I set the size to 3.0, but somehow, it doesn't work. Here's my code: (Can anyone help me, thank you.) #include <windows.h> #include <GL/glut.h> void init() { glClearColor(1.0, 1.0, 1.0, 1.0); glShadeModel(GL_FLAT); } void display() { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 0.0, 0.0); glPointSize(3.0); glBegin(GL_POINT); glVertex2f(10.0, 10.0); glVertex2f(350.0, 300.0); glVertex2f(100.0, 300.0); glEnd(); glFlush(); } void reshape(int w, int h) { glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0,w,0.0,h); } int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(400, 400); glutInitWindowPosition(0, 0); glutCreateWindow("graph"); init(); glutReshapeFunc(reshape); glutDisplayFunc(display); glutMainLoop(); return 0; }
Advertisement
Have you tried setting the point size to something much higher, like 20 or 30? A point size of 3 is still very small, and might even be smaller than the default point size.
thank you for replying, i did tried some bigger numbers, but it still won't work.
maybe it's the problem of my computer, does anyone know how to fix it?
This example needs glBegin(GL_POINTS), not glBegin(GL_POINT).

You may also want to try glEnable(GL_POINT_SMOOTH) to make your points look nicer.
Thank you, Nathan Baum, I can see the points now.
You know that beginner like me always make stupid mistakes...
Quote:Original post by Nathan Baum
This example needs glBegin(GL_POINTS), not glBegin(GL_POINT).


that's another nail in the coffin lid of the "legacy" OpenGL without strict types. function proto of glBegin should use the second parameter type strictly distinguishable from other types, not just everywhere-fitting uint.
Quote:Original post by mbaitoff
Quote:Original post by Nathan Baum
This example needs glBegin(GL_POINTS), not glBegin(GL_POINT).

that's another nail in the coffin lid of the "legacy" OpenGL without strict types. function proto of glBegin should use the second parameter type strictly distinguishable from other types, not just everywhere-fitting uint.

Although strict types would be a good solution here, I think a more significant general flaw is the lack of flexibility in handling errors in OpenGL. For example, no kind of strict typing in C or C++ could prevent nested calls to glBegin().

Checking glGetError() after glBegin() would have revealed that there was an error in the function call, but who calls glGetError() after every GL call? It would be useful if there was a standard way to get more assertive error detection:

Something like:

GLvoid handle_error (GLenum error){  throw GLError(error);}...  glErrorCallback(&handle_error);  glEnableClientState(GL_ERROR_CALLBACK);  try {    glBegin(GL_POINT);    ...    glEnd();  } catch (GLError e) {    ...  }

This topic is closed to new replies.

Advertisement