OpenGL Buffer Object

1 Buffer Object

  • Buffer Objects are OpenGL Objects that store an array of unformatted memory allocated by the OpenGL context (AKA(also know as) the GPU). These can be used to store vertex data, pixel data retrieved from images or the framebuffer, and a variety of other things.

  • To create a buffer object, you call glGenBuffers. Deleting them uses glDeleteBuffers.

  • To set up its internal state, you must bind it to the context. You do this using the following API:
    void glBindBuffer(enum target, uint bufferName)


  • Buffer objects hold a linear array of memory of arbitrary size. This memory must be allocated before it can be uploaded to or used.

  • There are two ways to allocate storage for buffer objects: mutable or immutable.

  • The storage for buffer objects can be allocated immutably. When this is done, you will be unable to reallocate that storage.

  • To allocate immutable storage for buffer objects, you call this function:
    void glBufferStorage(GLenum target​, GLsizeiptr size​, const GLvoid * data​, GLbitfield flags​);

  • To create mutable storage for a buffer object, you use this API:
    void glBufferData(enum target, sizeiptr size, const void *data, enum usage)

1.1 Buffer Object Streaming

  • Buffer Object Streaming is the process of updating buffer objects frequently with new data while using those buffers.

1.2 Vertex Buffer Object

  • A Vertex Buffer Object (VBO) is the common term for a normal Buffer Object when it is used as a source for vertex array data.

1.3 Pixel Buffer Object

  • A Buffer Object that is used for asynchronous pixel transfer operations is called a Pixel Buffer Object.
  • PBOs are not connected to textures. They are only used to perform pixel transfers;
  • PBOs are about pixel transfers to/from the user from/to images in OpenGL.

1.4 Shader Storage Buffer Object

  • A Shader Storage Buffer Object is a Buffer Object that is used to store and retrieve data from within the OpenGL Shading Language.

1.5 Uniform Buffer Object

  • A Buffer Object that is used to store uniform data for a shader program is called a Uniform Buffer Object.

1.6 Atomic Counter

An Atomic Counter is a GLSL variable type whose storage comes from a Buffer Object. Atomic counters, as the name suggests, can have atomic memory operations performed on them.

2 Vertex Array Object

  • A Vertex Array Object (VAO) is an OpenGL Object that stores all of the state needed to supply vertex data (with one minor exception noted below).
  • It stores the format of the vertex data as well as the Buffer Objects providing the vertex data arrays.

3 Texture

  • A texture is an OpenGL Object that contains one or more images that all have the same image format.
  • A texture can be used in two ways: it can be the source of a texture access from a Shader, or it can be used as a render target.

  • An image is defined as a single array of pixels of a certain dimensionality (1D, 2D, or 3D), with a particular size, and a specific format.
  • A texture is a container of one or more images.
  • There are three defining characteristics of a texture, each of them defining part of those constraints: the texture type, texture size, and the image format used for images in the texture.

  • GL_TEXTURE_1D: Images in this texture all are 1-dimensional. They have width, but no height or depth.
  • GL_TEXTURE_2D: Images in this texture all are 2-dimensional. They have width and height, but no depth
  • GL_TEXTURE_3D: Images in this texture all are 3-dimensional. They have width, height, and depth.
  • GL_TEXTURE_BUFFER: The image in this texture (only one image. No mipmapping) is 1-dimensional. The storage for this data comes from a Buffer Object.

3.1 Mip maps

  • TODO

3.2 Texture Objects

  • Textures in OpenGL are OpenGL Objects, and they follow the standard conventions of such.
  • Texture objects come in three parts: storage, sampling parameters, and texture parameters. There are numerous functions to create a texture’s storage; so many that the article needs its own page to describe them all.

3.3 Texture completeness

  • TODO

3.2.1 Storage

  • The Texture Storage is the part of Texture objects that contains the actual pixel data stored in the texture.
  • There are three kinds of storage for textures: mutable storage, immutable storage, and buffer storage

3.2.2 Image sizes

  • Each texture type represents images of a certain dimensionality. As such, it is important to know the size of the individual images within a texture.
  • All images that have the same mipmap level in a texture will have the same size.
  • That size depends on the size of the base mipmap level of the texture: level 0. The size of level 0 images defines the texture’s effective size.
  • A texture’s image storage contains one or more images of a certain dimensionality.
  • For every mipmap level past level 0, the size decreases in half, rounded down.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值