Scene
When rendering a point, if the size is larger, it is actually a rectangle, which requires an anti-aliasing technique. Use anti-aliasing to enable blending operations, make sure that the anti-aliasing settings for the video card are user-controlled or open.
Code
#include <GL/glut.h>
void Mydisplay (void)
{
Glclearcolor (1.0f, 1.0f, 1.0f, 0.0f);
Glclear (Gl_color_buffer_bit);
Glenable (Gl_point_smooth);
Glenable (Gl_blend);
Glblendfunc (Gl_src_alpha, Gl_one_minus_src_alpha);
Glhint (Gl_point_smooth_hint, gl_nicest);
Glpointsize (10.0f);
Glbegin (gl_points);
glcolor3f (0.0, 1.0, 0.0);
glvertex2f (0.0, 0.0);
Glend ();
Glflush ();
Return
}
int main (int argc, char *argv[])
{
Glutinit (&ARGC, argv);
Glutinitdisplaymode (Glut_rgb | Glut_single);
Glutinitwindowposition (100, 100);
Glutinitwindowsize (400, 400);
Glutcreatewindow ("First OpenGL program");
Glutdisplayfunc (&mydisplay);
Glutmainloop ();
return 0;
}
Suggestions
Generally to draw a better effect of the dot, it is best to use the texture.
Anti-aliasing Ideas
Sets the pixel color between adjacent steps to a transition color, making it soft, so that the object appears smooth
Problem
1) Parameter interpretation of function glpointsize in OpenGL is the diameter of the specified rasterized point
When actually set to 10.0f, the point has been set to the maximum value and cannot continue to expand
2) Glbegin (gl_points); The parameter value of the function is gl_points, not gl_point, remember
3) glpointsize (10.0f); Call to function must precede glbegin (gl_points)
4) Glblendfunc (Gl_src_alpha, Gl_one_minus_src_alpha); the second parameter value of the function specifies that the Gl_one is invalid, and that the value is valid for the intersection of a line
5) Draw the line (even if only draw a line) should pass Gl_lines, accidentally passed Gl_line, compile will not error
, but it is not effective. Draw points gl_points, quadrilateral gl_quads. Accidentally wrote a Gl_quad compile error using an undefined enumeration variable. Gl_line,gl_point,opengl is used to define the drawing mode of the polygon, as well as the Gl_fill mode.
Render anti-aliasing points