It connects a vertex attribute with a prior bound buffer. My problem is the b(4 * 4)[/b] part. Since I am trying to pass matrices (mat4) via a vertex buffer object, I need to split it up into 4 vertex attribute streams (mat4 = 4 vec4). The last part of the glVertexAttribPointer should tell OpenGL the offset via a pointer (the proper matrix column). I simply don’t know what to pass here. I’ve read that the b(4 * 4)[/b] expression does an Integer to GLvoid cast.
I’ve tried:
dim mb1 as new MemoryBlock(4)
mb1.Long(0) = 4 * 4
glVertexAttribPointer 6, 4, GL_FLOAT, false, 64, mb1
Sadly, this doesn’t work. As long as the offset parameter of glVertexAttribPointer is nil, it works just fine, but since I need a matrix buffer (4 glVertexAttribPointers), this isn’t possible.
#pragma DisableBackgroundTasks
Soft Declare Sub callGL Lib “OpenGL.Framework” Alias “glVertexAttribPointer” (index as integer, size as integer, type as integer, normalized as boolean, stride as integer, pointer as UInt32)
callGL index, size, type, normalized, stride, pointer
OpenGL is tricky - there’s at least one situation where a Pointer is interpreted differently, depending on whether the target it is bound to is a texture or a PBO. In one case it’s a pointer, in the other it’s an integer offset into the buffer. This has bit me before.
Yes I found few information about this old fashioned pointer/integer thing (build on top of the legacy pipeline).
Here, I am working with VBOs (into an VAO) and the VBO matrices are for instanced rendering. Now it seems to work, at least for some meshes