opengl_on_vs_2_ Vertex Cache Object

Source: Internet
Author: User

1. View current OpenGL version


2,glew
The OpenGL Extension Wrangler Library. Glew helps you deal with the headache so can accompany the management of extensions in OpenGL. Once initialized It queries for all the available extensions on your platform, dynamically loads them and provides easy AC Cess via a single header file.
If you include other OpenGL headers must is careful to include this file before the others else Glew would complain tha T about it.

3,
the gl_arb_vertex_buffer_object extension is dedicated to providing the benefits of vertex arrays and display lists to improve OpenGL efficiency while avoiding their implementation deficiencies.
The Vertex cache object (VBO) allows vertex array data to be stored in high-performance graphics memory on the server side and provides efficient data transfer . If the cached object is used to hold pixel data, it is called a pixel cache object (PBO).
using vertex arrays can reduce the number of function calls and reduce the reuse of shared vertices.
You can share cached data across multiple clients. Because VBO is on the server side, multiple clients can access the same cache through the corresponding identifiers.


4, creating a VBO requires 3 steps:
Use Glgenbuffers () to generate a new cache object.
Use Glbindbuffer () to connect the cache object to the appropriate cache.
Use Glbufferdata () to copy the vertex data into the cache object.

void Glgenbuffers (Glsizei N, gluint* buffers);
void Glbindbuffer (glenum target, gluint buffer);
void Glbufferdata (glenum target,glsizeiptr size, const glvoid* data, glenum usage);

void Glbuffersubdata (glenum target, glintptr offset, glsizeiptr size, const glvoid* data);
Similar to Glbufferdata (), Glbuffersubdata () is used to copy data to VBO, but it replaces only a certain range of data starting at the given offset into the existing cache. (Before using Glbuffersubdata (), the entire cache must be specified by Glbufferdata ().) )

void Gldeletebuffers (Glsizei n, const glenum* BUFS);





glenablevertexattribarray (0); The vertex position
loaded into buffer is considered to be a vertex property of index 0 in the fixed functional pipeline (when no shader binding is enabled). The
must turn on the properties of each vertex, or the rendering pipeline cannot get the data.

Glbindbuffer (Gl_array_buffer, VBO);
Here we bind our buffer again ready to start the draw call callback.
In this applet we call this callback every frame is very redundant, in more complex programs, there will be a lot of buffer buffer to store different models, you need bind to call buffer to constantly update the state of the pipeline.

Glvertexattribpointer (0, 3, gl_float, Gl_false, 0, 0);
This callback tells the pipeline how to parse the data in the Bufer.
The 1th parameter defines the index of the property, and in this case we know that the index is 0 by default, but when we start using the shader shader, we need to explicitly set the property index in the shader and retrieve it as well;
The 2nd parameter refers to the number of elements in the attribute (3 indicates: x, y, z coordinates);
The 3rd parameter refers to the data type of each element;
The 4th parameter indicates whether we want our properties to be flat before being used by the pipeline, and in this case we want our data to be transmitted unchanged;
The 5th parameter (called ' stride ') refers to the distance of bits between the two instances of that attribute in the buffer. Set this parameter value to 0 when there is only one property (for example: buffer contains only one vertex of the location data) and the data is tightly arranged. If we have an array of data structures containing the position and the normal vector (all three floating-point vector vectors, altogether 6 floating-point numbers) Two attributes, we will set the parameter value to the bit size of this data structure (6*4=24);
The last parameter is useful in the previous example. We need to define the memory offset values in the data structure where the pipeline finds our properties. In structures with positional and normal vector data, the offset of the position is 0, while the offset of the normal vector is 12.


5,
The visible points must be inside the box so that they can be mapped to the visible coordinates of the window through the transformation of the windows. When looking down the negative direction of the z axis, this flat box looks like this:

opengl_on_vs_2_ Vertex Cache Object

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.