glNamedBufferData 触发 GL_INVALID_OPERATION

glNamedBufferData fires GL_INVALID_OPERATION

当我尝试为 gound 分配几何图形时,我在示例的最开始遇到异常,here and here:

此时

gl4.glNamedBufferData(vertexBuffer[0], Vertex.size() * vertices.size(),
                floatBuffer, GL4.GL_STATIC_DRAW);

异常:

Caused by: com.jogamp.opengl.GLException: GL-Error 0x502 while creating mutable storage for buffer 1 of size 512 with data java.nio.DirectFloatBufferU[pos=0 lim=128 cap=128]

我有对象 Vertex,它有 128 个浮点数,我有 4 个顶点,这意味着 512 字节

一切似乎都是对的

无论如何,error 0x502GL_INVALID_OPERATION 并且 glNamedBufferData 触发 only 如果:

- GL_INVALID_OPERATION is generated by glNamedBufferData if buffer is not the name of an existing buffer object.

- GL_INVALID_OPERATION is generated if the GL_BUFFER_IMMUTABLE_STORAGE flag of the buffer object is GL_TRUE. 

既然buffer存在(!=0,1),那么肯定是第二个

但是 我无法查询任何 GL_BUFFER_IMMUTABLE_STORAGE 标志,因为 glGetBufferParameter requires 由于 [=18= 而我没有提供的目标],

并查看 here,如果 mutableUsage 为假,我会发现内部错误,但我没有,所以..

有什么想法吗?

gl4.glBindBuffer(GL4.GL_ARRAY_BUFFER, vertexBuffer[0]);
gl4.glBufferData(GL4.GL_ARRAY_BUFFER, Vertex.size() * vertices.size(), floatBuffer, GL4.GL_STATIC_DRAW);
gl4.glBindBuffer(GL4.GL_ARRAY_BUFFER, 0);

它就像一个魅力,我确信我有 GL 4.5

gl4.glGetString(GL4.GL_VERSION) 4.5.0 NVIDIA 347.88

gl4.isExtensionAvailable("GL_ARB_direct_state_access" true

OpenGL 4.5 规范 - 6.1 创建和绑定缓冲区对象:

A buffer object is created by binding a name returned by GenBuffers to a buffer target. The binding is effected by calling

void BindBuffer( enum target, uint buffer );

target must be one of the targets listed in table 6.1. If the buffer object named buffer has not been previously bound, the GL creates a new state vector, initialized with a zero-sized memory buffer and comprising all the state and with the same initial values listed in table 6.2.

所以 glGenBuffers 和 glCreateBuffers 的区别在于,glGenBuffers 只是 returns 一个未使用的名称,而 glCreateBuffers 也会创建并初始化上述状态向量。