glVertexAttribPointer casting to GLvoid (Pointer)

Hi,

I am trying to parse this OpenGL line into Xojo:

glVertexAttribPointer(6, 4, GL_FLOAT, GL_FALSE, 4 * vec4Size, (GLvoid*)(4 * 4));

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.

Any thoughts? Many thanks in advance!

After try and fails since yesterday evening, I finally got it working. The glVertexAttribPointer takes an integer (UInt32) as well as last parameter.

Here is the code for future reference:

glVertexAttribPointer 6, 4, GL_FLOAT, false, 64, 16

And the API call:

#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 :wink: