gpt4 book ai didi

buffer - glNamedBufferData 触发 GL_INVALID_OPERATION

转载 作者:行者123 更新时间:2023-12-04 02:20:49 28 4
gpt4 key购买 nike

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

此时

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

异常(exception):

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 个 float ,我有 4 个顶点,这意味着 512 字节

一切似乎都是对的

无论如何,错误 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由于 glNamedBufferData,我没有提供的目标,

正在寻找here ,如果 mutableUsage 为 false,我会发现内部错误,但我没有,所以..

有什么想法吗?

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 创建和绑定(bind)缓冲区对象:

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 只返回一个未使用的名称,而 glCreateBuffers 还创建并初始化上述状态向量。

关于buffer - glNamedBufferData 触发 GL_INVALID_OPERATION,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29743881/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com