如何在 OpenGL 中提供具有大小但没有数据的缓冲区?我尝试过使用
glBufferData(target, 0, nullptr, GL_STATIC_DRAW);
但现在我在绘制调用时遇到访问冲突,可能是其他原因。
这是正确的方法吗?
最佳答案
How do I supply a buffer with a size but no data in OpenGL?
您必须将特定大小(以字节为单位)传递给 size
参数,但将 nullptr
传递给 data
。请参阅glBufferData
:
GLsizeiptr size_in_bytes = ...;
glBufferData(target, size_in_bytes, nullptr, GL_STATIC_DRAW);
关于OpenGL - 如何填充没有数据的缓冲区?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56468987/