OpenGL - 如何填充没有数据的缓冲区?

OpenGL - How do I fill a buffer with no data?

如何在 OpenGL 中提供具有大小但没有数据的缓冲区?我试过使用

glBufferData(target, 0, nullptr, GL_STATIC_DRAW);

但现在我在 drawcall 上遇到访问冲突,可能是其他原因。

这样做正确吗?

How do I supply a buffer with a size but no data in OpenGL?

您必须将特定大小传递给 size 参数,但将 nullptr 传递给 data。见 glBufferData:

GLsizeiptr size_in_btes = ...;
glBufferData(target, size_in_btes, nullptr, GL_STATIC_DRAW);