Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opengl - How to draw square pixel with GL_POINTS

Tags:

opengl

I try to use the following code to draw a square-shaped pixel with opengl

glPointSize(5.0f);
glBegin(GL_POINTS);
glVertex3f(1.0f, 1.0f, 1.0f);
glEnd();

However, the final result is a circle-shaped pixel.

Please take a look the reference http://risknfun.com/compform/w1.html See the "Problem 4. A Grid". On the right side, the display image has square-shaped pixel.

like image 234
q0987 Avatar asked Nov 12 '10 16:11

q0987


2 Answers

It's partly up to the OpenGL implementation (i.e., it can vary with your graphics driver), but with a bit of luck, you can turn this on or off with glEnable(GL_POINT_SMOOTH); or glDisable(GL_POINT_SMOOTH); With point smoothing turned on, you'll normally get round points, but with it turned off you'll get square points.

like image 104
Jerry Coffin Avatar answered Sep 19 '22 15:09

Jerry Coffin


You can also try to tell OpenGL not to spend time making GL_POINTS nice and round by calling:

glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);

But keep in mind that's just an hint. The OpenGL driver has ultimately the last word.

like image 43
Stringer Avatar answered Sep 17 '22 15:09

Stringer