本文介绍了glBindBuffer和glBindBufferBase之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为 glBindBuffer(target,buffer)的作用是将缓冲区的地址存储在目标上,这是一个特殊的地址。

但是我找到了 glBindBufferBase(目标,索引,缓冲区)。我认为目标应该是一个数组,该操作根据索引将缓冲区地址存储到数组。

如果我认为正确,则 glBindBuffer 等同于 glBindBufferBase(target,someindex,buffer)

也许 someindex 是0?

I think what glBindBuffer(target, buffer) do is to store the buffer's address on the target, which is a special address.
But I found the glBindBufferBase(target, index, buffer). I think target should be a array, this operation stores the buffer address to the array according to the index.
If what I thought is right, then the glBindBuffer is equivalent to glBindBufferBase(target, someindex, buffer)?
Maybe someindex is 0?

推荐答案

它们不是用于同一目的。

They're not used for the same purpose.

glBindBuffer 用于将缓冲区绑定到特定目标,以便随后将修改该目标的所有操作映射到该缓冲区。

glBindBuffer is used to bind a buffer to a specific target so that all operations which modify that target are mapped to that buffer afterwards.

glBindBufferBase 用于完全不同的目的,它用于将缓冲区绑定到索引数组中的特定绑定点(当不应直接修改数据时)而是使用)。尽管这看起来有些令人费解,但确实很容易看到。假设您要将统一块传递给着色器,那么您有一个表,该表将命名缓冲区映射到数组中的特定索引,然后将其映射到着色器中的绑定,如下图所示:

glBindBufferBase is used for a totally different purpose, it's used bind a buffer to a specific binding point in an indexed array (when data is not supposed to be directly modified but rather used). While this may seem convoluted it's really easy to see. Assume you want to pass an uniform block to your shader, then you have a table which maps named buffers to specific indices in an array which are then mapped to bindings in a shader like in the following figure:

因此 glBindBufferBase 正在创建 glBindBuffer 只是将缓冲区绑定到特定目标。

so glBindBufferBase is creating the arrows on the right in which you specify the index, while glBindBuffer is just binding the buffer to the specific target.

然后您将使用 glGetUniformBlockIndex 在着色器中获取正确的索引,然后通过 glUniformBlockBinding 。

You would then use glGetUniformBlockIndex to get the correct index in the shader which is then linked to the binding point (the left arrows) through glUniformBlockBinding.

这篇关于glBindBuffer和glBindBufferBase之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 06:28