- Real-Time 3D Graphics with WebGL 2
- Farhad Ghayour Diego Cantor
- 214字
- 2021-06-10 19:42:58
WebGL as a State Machine: Buffer Manipulation
When dealing with buffers for the getParameter, getBufferParameter, and isBuffer functions, new information about the state of the rendering pipeline becomes available to us.
Similar to Chapter 1, Getting Started, we will use getParameter(parameter), where parameter can have the following values:
- ARRAY_BUFFER_BINDING: Retrieves a reference to the currently-bound VBO
- ELEMENT_ARRAY_BUFFER_BINDING: Retrieves a reference to the currently-bound IBO
We can also query the size and the usage of the currently-bound VBO and IBO using getBufferParameter(type, parameter), where type can have the following values:
- ARRAY_BUFFER: To refer to the currently-bound VBO
- ELEMENT_ARRAY_BUFFER: To refer to the currently-bound IBO
And parameter can have the following values:
- BUFFER_SIZE: Returns the size of the requested buffer
- BUFFER_USAGE: Returns the usage of the requested buffer
Binding Buffers
Your VBO and/or IBO needs to be bound when you inspect the state of the currently-bound VBO and/or IBO with getParameter and getBufferParameter.
Your VBO and/or IBO needs to be bound when you inspect the state of the currently-bound VBO and/or IBO with getParameter and getBufferParameter.
Finally, isBuffer(object) will return true if the object is a WebGL buffer, or false with an error when the buffer is invalid. Unlike getParameter and getBufferParameter, isBuffer does not require any VBO or IBO to be bound.