获取缓冲区的大小 [英] Get size of Buffer
问题描述
我想使用将数据从一个缓冲区复制到另一个缓冲区glCopyBufferSubData .但是我不知道我要从中复制缓冲区的大小.如何获得尺寸?
为此,您只需要调用glCopyBufferSubData. However I don't know the size of the buffer I'm copying from. How do I get the size?
For this, you simply need to call glGetBufferParameteriv (...)
with the appropriate enum.
In this case, you want the size of the buffer object, so use GL_BUFFER_SIZE
for value
.
You have not mentioned what role the buffer object is serving (e.g. what it is currently bound to), but I am going to assume it is a Vertex Buffer Object for simplicity (so target
is GL_ARRAY_BUFFER
).
Thus we have:
GLint size = 0;
glBindBuffer (GL_ARRAY_BUFFER, buffer_obj);
glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size);
You are limited to a size of 4 GiB prior to GL 3.2, though I doubt this really matters as you would surely hit some other limitation first. Neverthless, glGetBufferParameteri64v (...)
exists for buffers larger than 4 GiB.
这篇关于获取缓冲区的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!