Because the computer generates images from discrete points, there must be a gap between the generated images and the real scenes. This gap is manifested in: straight line or smooth curved surface, pattern loss of the original color shape, the disappearance of small objects in the screen, etc. All are called examples ). Reverse sampling can reduce this situation. A rough assumption is to fill the Sawtooth part of the original boundary with a low saturation point, which does not affect the overall contour and achieves better smoothing effect.
The anti-sample method is used to reduce and eliminate various out-of-sample phenomena. Generally, the anti-sample method includes the resolution improvement method, the non-weighted area sampling method, and the weighted area sampling method. However, it is much easier to implement the anti-sample method in OpenGL.
A "prompt" is provided before the anti-sample is used:
Void glhint (glenum target, glenum hint );
The hint can be:
Gl_fastest provides the most effective options
Gl_nicest provides the highest quality options
Gl_dont_care not selected
Target
Gl_point_smooth_hint specifies the vertex,
Gl_line_smooth_hint,
Sample Quality of gl_polygon_smooth_hint Polygon
Gl_fog_hint indicates whether the atomization calculation is performed by each pixel (gl_nicest) or by each vertex (gl_fastest)
Gl_perspective_correction_hint specifies the quality of color texture interpolation.
Gl_perspective_correction_hint is used to correct observation errors caused by pure linear interpolation.
Two conditions must be met to implement anti-Image Processing in OpenGL. One is to enable mixing, and the other is to enable anti-Image Processing for geometric elements.
As mentioned earlier, the glable (gl_blend) starts the hybrid mode, while the glable (mode) enables the reverse sample of the geometric elements. The mode value is gl_point_smooth, gl_line_smooth, or gl_polygon_smooth.
Next, we implement a grid-like sphere reverse processing. For ease of observation, we do not use effects such as fog, light, and texture.
Int glinit ()
{
// Enable smooth shading ).
Glshademodel (gl_smooth );
Glclearcolor (1.0f, 1.0f, 1.0f, 1.0f );
// Set the depth buffer
Glcleardepth (1.0f );
// Start the deep Test
Glenable (gl_depth_test );
// Type of deep Test
Gldepthfunc (gl_lequal );
// Perform perspective correction
Glhint (gl_perspective_correction_hint, gl_nicest );
Return true;
}
Void glmain ()
{
Glclear (gl_color_buffer_bit | gl_depth_buffer_bit );
Glloadidentity (); // loads the unit matrix.
Gltranslatef (-1.5f, 0.0f,-5.0f );
// The Color of the sphere is black.
Glcolor3f (0.0f, 0.0f, 0.0f );
// No reverse sample is used
Gldisable (gl_blend );
Gldisable (gl_line_smooth );
Gldisable (gl_polygon_smooth );
Auxwiresphere (1.0 );
// Enable reverse sample processing
Glable (gl_blend );
Glable (gl_line_smooth );
Glable (gl_polygon_smooth );
Gltranslatef (3.0f, 0.0f, 0.0f );
Auxwiresphere (1.0 );
Swapbuffers (g_hdc); // The buffer before and after the switch.
}
The program running effect is 9-7, and the two sphere is obviously different.