yassin
yassin

Reputation: 309

glGenBuffers function usage

For each buffer type, there a special function to generate names for it like glGenFramebuffers for framebuffers, glGenRenderbuffers for render buffers, and glGenTextures for textures.

But there is a function called glGenBuffers. What types of buffers does this function generate? & how these buffers can be used in my program?

Upvotes: 0

Views: 1143

Answers (1)

John Bartholomew
John Bartholomew

Reputation: 6606

glGenBuffers allocates a name for a "Buffer Object". An OpenGL Buffer Object represents a block of memory which can be accessed by both the application and the GPU (though typically not by both at the same time). OpenGL can use the contents of a buffer object for a variety of purposes, and a single buffer object may be used for more than one purpose over its lifetime, though in practice buffer objects are often created exclusively for one type of data.

You can get an idea for the uses that a buffer object has by looking at the list of binding points to which you can attach a buffer object (using the glBindBuffer function). For example:

  • GL_ARRAY_BUFFER​ - OpenGL will read vertex data from the buffer object.
  • GL_ELEMENT_ARRAY_BUFFER​ - OpenGL will read vertex indices (e.g., for glDrawElements) from the buffer object.
  • GL_PIXEL_UNPACK_BUFFER​ - Functions that read pixel data (e.g., glTexImage2D) will read that data from the buffer object.

And many more.

For more information, see the OpenGL wiki page for Buffer Object.

Upvotes: 1

Related Questions