OpenGL Study Notes (3)

Source: Internet
Author: User
1. Basic State management of OpenGL
Void glable (glenum CAP );
Void gldisable (glenum CAP );
These two functions are used to enable and disable certain states. The enumerated values in more than 60 States can be used as the CAP parameter.
Glboolean glisenabled (glenum capability); queries whether the capability status is enabled.
Void glgetbooleanv (glenum pname, glboolean * Params );
Void glgetintergerv (glenum pname, glint * Params );
Void glgetfloatv (glenum pname, glfloat * Params );
Void glgetdoublev( glenum pname, gldouble * Params );
Void glgetpointerv (glenum pname, glvoid ** Params );
The above four functions use the bool, Int, float, double, and pointer types to obtain the pname value of the state variable.
OpenGL divides related state variables into an attribute group. The glpushattrib () and glpopattrib () functions can be used to restore and store all state variables of this attribute group at one time. Note that some status variables can belong to multiple attribute groups (for example, gl_cull_face belongs to Polygon attribute groups and enables attribute groups ). In OpenGL, there are two different attribute stacks: The Matrix stack (storing the value of the server state variable) and the customer attribute stack (using the glpushclientattrib () and glpopclientattrib () functions for access ), using Attribute groups to perform Attribute-related operations is usually faster than the functions you write. There are about 20 different attribute groups. attributes are stored in the stack on both the client and server,

2. Normal Vector
The normal vector (or normal) is a vector perpendicular to the surface. In the plane, the vertical directions of all points are the same, but the normal directions of each point in the surface may be different. In OpenGL, you can specify the normal of each vertex of a polygon. The normal vector of an object defines its surface orientation. Specifically, it is relative to the orientation of the light source. OpenGL uses these vectors to determine how much light the object vertex will accept. Use glnormal * () to set the normal vector. When the glvertex * () function is called, the current normal will be assigned to the specified vertex.

3. vertex Array
Vertex arrays are used to improve the rendering speed and performance of OpenGL. Using a vertex array to render a ry involves three steps:
(1) Enable array. Up to 8 Arrays can be enabled, which are used to store different types of data: vertex coordinate, plane normal, rgba color, secondary color, color index, fog coordinate, texture coordinate, and multilateral Line Edge mark. Glenableclientstate (glenum array) enables the specified array. Gldisableclientstate (glenum array) function to disable the specified array.
(2) Add data to the array. The access to arrays is based on their memory unit addresses (pointers to memory units. In Client/Server mode, data is stored in the customer's address space. There are also eight functions used to specify the array data, glvertexpointer (), glcolorpointer (), glsecondarycolorpointer (), glindexpointer, glnormalpointer (), vertex (), gltexcoordpointer (), gledgeflagpointer ().
(3) Use Data to draw the ry. OpenGL obtains the data in the enabled array by unreferencing the pointer. The array is stored on the client. In this step, the array content is obtained, sent to the server, and then transmitted along the graphic processing pipeline for rendering. You can read data from a single array element (index position), a series of array elements (a subset of the vertex array), or a series of adjacent array elements. Glarrayelement (glint I); obtain the data of the I vertex in all enabled arrays. Gldrawelements (), glmaltidrawelements (), and gldrawrangeelements () are used to randomly read a series of random elements. Gldrawarrays () is used to access a series of Adjacent Elements in the array.

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.