3

I get an exception at the very begin of my sample, when I try to allocate geometry for the gound, here and here:

at this point

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]

I have the object Vertex that takes 128 floats, I have 4 vertices, this means 512 Byte

Everything seems right

Anyway, error 0x502 is GL_INVALID_OPERATION and glNamedBufferData fires that only if:

- 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. 

Since buffer exist (!= 0, 1), it must be the second one

But I cant query any GL_BUFFER_IMMUTABLE_STORAGE flag, since glGetBufferParameter requires a target which I didnt provide because of glNamedBufferData,

and looking here, if mutableUsage was false, I would have catched the internal error, which I didnt, so..

Any idea?

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);

it works like a charm and I am sure I have GL 4.5

gl4.glGetString(GL4.GL_VERSION) 4.5.0 NVIDIA 347.88

gl4.isExtensionAvailable("GL_ARB_direct_state_access" true
elect
  • 6,765
  • 10
  • 53
  • 119

1 Answers1

4

OpenGL 4.5 Specification - 6.1 Creating and Binding Buffer Objects:

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.

So the difference between glGenBuffers and glCreateBuffers is, that glGenBuffers only returns an unused name, while glCreateBuffers also creates and initializes the state vector described above.

elect
  • 6,765
  • 10
  • 53
  • 119
  • 1
    Rather use GL4.glCreateBuffers: http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/GL4.html#glCreateBuffers(int,%20java.nio.IntBuffer) http://www.opengl.org/sdk/docs/man/html/glCreateBuffers.xhtml glCreateBuffer doesn't exist in JOGL. – gouessej Apr 21 '15 at 08:40
  • You're welcome. I rarely use WebGL and the names I use are exactly those of the OpenGL/JOGL methods, it's helpful to find the official documentation. – gouessej Apr 21 '15 at 09:12
  • @elect Can you edit your answer to include the "Further" bit as code? I'm not sure exactly what you mean by "or switching to `glCreateBuffers`". Does that mean you don't need `glNamedBufferData` anymore? P.S. The first two links are broken. – Tek May 14 '16 at 09:18
  • Hi Tek, I improved the answer, let me know if it still unclear :). Regarding the links, I switched back to non DSA function, that is `glBufferData` – elect May 14 '16 at 10:12