5Points
The Glide function grDrawPoint() renders a single point to the screen. The point will be treated as a triangle with nearly coincident vertices (that is, a very small triangle) for rendering purposes. If many points will be rendered, noticeable performance improvement can be achieved by writing pixels directly to the frame buffer. (grDrawPoint() sends three vertices per point to the hardware and iterates along three edges; only one linear frame buffer write per point is required.)
void grDrawPoint( const GrVertex *a )
Example Rendering Primitives.1 A thousand points of light.
This code fragment clears the screen to black and then draws a thousand random points. By default, the rendering buffer is set to GR_BUFFER_BACKBUFFER and the color buffer is writable. The color white is made by specifying maximal values for red, green, and blue, and a quick way to do that is ~0. Some of the points will be clipped out: the random number generator selects point with coordinates in the range [0..1024); the screen resolution is less than that. By default, the clipping window is set to the screen size.
int n;
GrVertex p;
/* clear the back buffer to black */
grBufferClear(0, 0, 0);
/* set color to white */
grColorCombine( GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE,
GR_COMBINE_LOCAL_CONSTANT, GR_COMBINE_OTHER_NONE,FXFALSE );
grConstantColorValue(~0)
/* generate and draw 1000 random points */
for (n=0; n<1000; n++) {
p.x = (float) (rand() % 1024);
p.y = (float) (rand() % 1024);
grDrawPoint(p);
}
6Lines
The Glide function grDrawLine() renders an arbitrarily oriented line segment. Enabled special effects (e.g. fog, blending, chroma-key, dithering, etc.) will affect a line’s appearance.
void grDrawLine( const GrVertex *a, const GrVertex *b )
Share with your friends: |