The method of drawing point of opengl2d under Delphi _delphi

Source: Internet
Author: User

First, the preface

Delphi Graphics can be drawn in the Glbegin (), Glend () between the completion of the drawing of the frame code can be used under Delphi opengl2d drawing initialization code, specific content can refer to the site http://www.jb51.net/article/52141.htm. The modified part is the content of the Draw function.

Second, draw points

Use the Glpointsize function to specify the diameter of the grid point. The default is 1.0, only under the Gl_points function, about anti-aliasing and other functions after the study. Use Glbegin (gl_points) to tell OpenGL point, parameter gl_points point, there are other parameters, such as painting line Gl_lines, can refer to the OpenGL Unit source code. The Glbegin () and Glend () functions are described as follows:

Function Prototypes:

void Glbegin (Glenum mode)

void Glend (void)

Parameter description:

Mode: Creates the type of the entity. Can be the following values

Gl_points: Each vertex is treated as a point, vertex n is defined as the point N, a total of n points drawn
Gl_lines: Each vertex as a separate segment, vertex 2n-1 and 2n have a total of N to define a line of lines, a total of N/2 line line
Gl_line_strip: Draws a group of segments that are connected sequentially from the first vertex to the last vertex, and the nth and n+1 vertices define the segment N, drawing a total of n-1 line segments
Gl_line_loop: Draws a set of segments that are connected sequentially from the first vertex to the last vertex, then the last vertex is connected to the first vertex, and the nth and n+1 vertices define the segment N and draw n a total of
Gl_triangles: Each vertex as a separate triangle, Vertex 3n-2, 3n-1 and 3n define the nth triangle, a total of n/3 triangles
Gl_triangle_strip: Draw a set of connected triangles, for the odd N, Vertex N, n+1 and n+2 define the nth triangle, for even N, Vertex n+1, N, and n+2 define the nth triangle, draw a total of N-2 triangles
Gl_triangle_fan: Draws a set of connected triangles, which are determined by the first vertex and the given vertex, and vertices 1, n+1, and n+2 define nth triangles, drawing N-2 triangles in total
Gl_quads: Draws a set of individual quadrilateral elements consisting of four vertices. Vertex 4n-3, 4n-2, 4n-1, and 4n define the nth quadrilateral. Draw a total of N/4 quadrilateral
Gl_quad_strip: Draw a set of connected quadrilateral. Each quadrilateral is determined by a pair of vertices together with a given pair of vertices. Vertex 2n-1, 2n, 2n+2, and 2n+1 define the nth quadrilateral, drawing a total of n/2-1 quadrilateral
Gl_polygon: Draw a convex polygon. Vertices 1 through n define this polygon.
Function Description:

The Glbegin and Glend functions define the fixed-point definitions of a set or multiple sets of elements.

To achieve the point of the source code is as follows:

Procedure Tform1.draw;
Begin
 //empty buffer
 glclear (gl_color_buffer_bit or gl_depth_buffer_bit);
 Set point size, can not be glbegin and glend between
 Glpointsize (ten);
 Glbegin (gl_points); Draw dot
 //Set point color
 glcolor3f (1, 0, 0);
 Draw Point
 glvertex2f (m);
 glcolor3f (0, 1, 0);
 GLVERTEX2F (m);
 glcolor3f (0, 0, 1);
 GLVERTEX2F (m);
 Glend;
 Swapbuffers (FDC); Swap double buffer content, which will reprint the newly-drawn graphic to the screen. End
;

GLCOLOR3F () is used to draw the color of the point, glvertex2f the position of the drawing point.

Complete code point this download

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.