获取缓冲区的大小 [英] Get size of Buffer

查看:128
本文介绍了获取缓冲区的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用将数据从一个缓冲区复制到另一个缓冲区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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆