Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pixel width using glPointSize - no effect

I have this code for dropping points. I want to increase the point size. Right now I use this command glPointSize but nothing happens. The point size is default. It does not increase.
How can I increase my point size?

glBegin(GL_POINTS);

glColor3f (a, b, c);
glPointSize(20.0f); 

glVertex2i(px, py);
glEnd();
like image 274
user1733735 Avatar asked Feb 10 '13 09:02

user1733735


People also ask

What does glPointSize do?

The glPointSize function specifies the rasterized diameter of both aliased and antialiased points. Using a point size other than 1.0 has different effects, depending on whether point antialiasing is enabled. Point antialiasing is controlled by calling glEnable and glDisable with argument GL_POINT_SMOOTH.

How do I change the size of my GL point?

You can change this size with the function glPointSize: void glPointSize(GLfloat size); The glPointSize function takes a single parameter that specifies the approximate diameter in pixels of the point drawn. Not all point sizes are supported, however, and you should make sure the point size you specify is available.


1 Answers

glPointSize(20.0f); has to be put before glBegin(), otherwise it won't have any effect. Do it like this:

glPointSize(20.0f); 

glBegin(GL_POINTS);
   glColor3f (a, b, c);
   glVertex2i(px, py);
glEnd();

In OpenGL documentation, you can read that:

Only a subset of GL commands can be used between glBegin and glEnd. The commands are glVertex, glColor, glIndex, glNormal, glTexCoord, glEvalCoord, glEvalPoint, glArrayElement, glMaterial, and glEdgeFlag. Also, it is acceptable to use glCallList or glCallLists to execute display lists that include only the preceding commands. If any other GL command is executed between glBegin and glEnd, the error flag is set and the command is ignored.

like image 184
Piotr Chojnacki Avatar answered Oct 16 '22 16:10

Piotr Chojnacki