OpenGL SuperBible学习
第五章
Data
1. void glCreateBuffers(GLsizei n, GLuint* buffers);
buffers is the address of the variable or variables that will be used to store the names of the buffer objects.
2. void glBindBuffer(GLenum target, GLuint buffer);
3. The functions that are used to allocate memory using a buffer object are glBufferStorage() and glNamedBufferStorage(). Their protetypes are
void glBufferStorage(GLenum target, GLsizeptr size, const void* data, GLbitfield flags);
void glNamedBufferStorage(GLuint uffer, GLsizeptr size, const void* data, GLbitfield flags);
4. To be clear, the contents of the buffer object's data store can be changed, but its size or usage flags may not.
5. There are a handful of ways to get dat into the buffer object.
6. Had we instead supplied a pointer to some data, that data would have been used to initialize the buffer object. Using this pointer ,however, allow us to set only the initial data to be stored in the buffer.
7. void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
void glNameBufferSubData(Gluint buffer, GLintptr offset, GLsizeiptr size, const void* data);
8. void* glMapBuffer(GLenum target, GLenum usage);
void* glMapNamedBuffer(GLuint buffer, GLenum usage);
one that affects the buffer bound to one fo the targets of the current context, and one that operates directly on a buffer whose name you specify.
9. If you map a buffer, you can simply read the contents of the file directly into the mapped buffer.
10. void* glMapBufferRange(GLenum target, GLintptr offset, GLsizeptr length, GLbitfield access);
void* glMapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);
These functions, rather than mapping the entire buffer object map only a specific range of the buffer object.
11. However, because of the additional control and stronger contract provided by glMapBufferRange() and glMapNamedBufferRange(), it is generally preferred to call these functions rather than glMapNamedBuffer().
12. glClearBufferSubData -- glClearNamedBufferSubData
glCopyBufferSubData -- glCopyNamedBufferSubData
13. To tell OpenGL which buffer object our data is in and where in that buffer object the data resides, we use the glVertexArrayVertexBuffer() function to bind a buffer to one of the vertex buffer bindings. We use the glVertexArrayAttribFormat() function to describe the layout and format of the data, and finally we enable automatic filling of the attribute by calling glEnableVertexAttribArray().
14. OpenGL allows you to combine a group of uniforms into a uniform block and store the whole block in a