OpenGL Homemade API 1

Source: Internet
Author: User

1, Glutinit, initialize the glut, this function must be called before the other glut use. Its format is more rigid, generally copy this sentence glutinit (&ARGC, argv) on the can.

2, Glutinitdisplaymode, set the display mode, where GLUT_RGB means using RGB color, and corresponding to the Glut_index (indicating the use of indexed colors). The glut_single represents the use of a single buffer, which corresponds to a glut_double (using double buffering). For more information, please Google yourself. Of course, later tutorials will also have some explanation.

3, Glutinitwindowposition, this simple, set the window in the position of the screen.

4, Glutinitwindowsize, this is also simple, set the size of the window.

5, Glutcreatewindow, create a window based on the information set earlier. The parameter is used as the caption of the window. Note: When the window is created, it is not immediately displayed to the screen. You need to call Glutmainloop to see the window.

6, Glutdisplayfunc, set a function that will be called when drawing is required. (This statement is not accurate enough, but the exact statement may not be very good for beginners to understand, for the time being said).

7, Glutmainloop, a message loop. (This may not be easy for beginners to understand, but it's enough to know that the function can show the window and wait for the window to close before it returns.) )

8, Glclear, clear. Gl_color_buffer_bit means clear color, glclear function can also clear other things, but this is not introduced here.

In RGB mode, use Glclearcolor to specify "empty" color, it requires four parameters, its parameter meaning is similar to glcolor4f.

In indexed color mode, use Glclearindex to specify the index of the "empty" color, which requires a parameter that is similar in meaning to Glindexi.

void Mydisplay (void)
{
Glclearcolor (1.0f, 0.0f, 0.0f, 0.0f);
Glclear (Gl_color_buffer_bit);
Glflush ();
}

9, GLRECTF, draw a rectangle. The four parameters represent the horizontal and vertical coordinates of two points located on the diagonal.

10, Glflush, ensure that the previous OpenGL command executes immediately (instead of letting them wait in the buffer). The effect is similar to Fflush (stdout).

11. void Mydisplay (void)
{
Glclear (Gl_color_buffer_bit);
Glbegin (/ * Fill in your desired pattern here * /);
/ * Use the glvertex* series function here * /
/ * Specify the vertex position you want * /
Glend ();
Glflush ();


  

12, void Glpointsize (glfloat size);   size must be greater than 0.0f and the default value is 1.0f, in pixels. The size of the modified point.

13, void Gllinewidth (glfloat width); Modifies the line width. Usage is similar to 12.

14, Glenable (gl_line_stipple); To start the dash mode (use Gldisable (gl_line_stipple) to turn it off).

void Gllinestipple (glint factor, glushort pattern); pattern is a sequence of length 16 consisting of 1 and 0, starting from the lowest bit, and if 1, then the factor points that should be drawn on the line will be painted as real, and if 0, the factor points that should be drawn on the line will be painted as virtual


OpenGL Homemade API 1

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.