![opengl cygwin tutorial opengl cygwin tutorial](http://www.inf.ufsc.br/~aldo.vw/grafica/lesson04.jpg)
If you know that a quadrilateral is actually drawn, you must add four points after the first four points to a vertex group of a set. There will be no extra points between them, that is, the points between (gl_triangles) and glend () are all set by three points.
#Opengl cygwin tutorial code#
All the six-point code should be included between glbegin (gl_triangles) and glend. If you want to draw a second triangle, you can add three lines of code (3 points) after the three points ). In this simple example, we draw only one triangle. Finally, use gl_polygon if you want to draw more vertices. But as far as I know, most video cards use triangles to color objects. If you want to draw four vertices, it is more convenient to use gl_quads. On the vast majority of graphics cards, it is quite fast to draw triangles. Glbegin (gl_triangles) means to start to draw a triangle, and glend () tells OpenGL that the triangle has been created. Now we have moved to the left half of the screen and pushed the view to the back of the screen, so that we can see all the scenes-create a triangle. Gltranslatef (-1.5f, 0.0f,-6.0f) // move 1.5 units left and 6.0 to the screen Note that when you move in gltranslatef (x, y, z), you do not move relative to the center of the screen, but to the current position of the screen.
![opengl cygwin tutorial opengl cygwin tutorial](https://i.ytimg.com/vi/8Qkpaewj-7Y/hqdefault.jpg)
According to the preceding order, the following code shifts 1.5 units to the left of the X axis, the Y axis does not move (0.0f), and finally moves to the 6.0f unit of the screen. Gltranslatef (x, y, z) moves along the X, Y, and Z axes. Moving to the depth of the screen is a negative value, and moving out of the screen is a positive value. Moving to the top of the screen is positive, and moving to the bottom of the screen is negative. The coordinate value on the left of the center is a negative value, and the right is a positive value. The coordinates of the OpenGL screen center are 0.0f points on the X and Y axes. The X axis is from left to right, the Y axis is from bottom to top, and the Z axis is from inside to outside. Glclear (gl_color_buffer_bit | gl_depth_buffer_bit) // clear the screen and depth CacheĪfter you call glloadidentity (), the current point is actually moved to the center of the screen. Int drawglscene (glvoid) // This process includes all the drawing code If you plan to modify the code of the previous lesson, you only need to overwrite the original drawglscene () with the following code. We will use it to create a gl_triangles triangle and gl_quads to create a quadrilateral.īased on the code of Lesson 1, we only need to add the Code during the drawglscene () process.
#Opengl cygwin tutorial how to#
In this lesson, I will teach you how to create a triangle and a quadrilateral. In Lesson 1, I teach you how to create an OpenGL window.