ptr to glmapbuffer

I’m a little confused about setting the right data when mapping a buffer.

if I have a vertex structure:

struct custom_vertex
vector3 position;
vector3 normal;

when I go to get a pointer to the vbo using glMapBuffer it should be:

custom_vertex * buffer_ptr = (custom_vertex*)glmapbuffer(GL_ARRAY_BUFFER, GL_WRITE);

and I should be able to change the value in that buffer like so:

buffer_ptr[0].position = vector3(5.0, 0.0, -1.0);



If you are working on OpenGL 3 hardware have a look at glMapBufferRange which is really well designed and I think a lot less confusing. In practice glMapBuffer isn’t really efficient or practical anyway…

thanks, I just wanted to be sure since I usually work with an array of floats instead of structures.

thanks Groovounet and V-man.