PDA

View Full Version : ptr to glmapbuffer



ravage
01-10-2011, 06:23 PM
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);

right?

V-man
01-11-2011, 06:50 AM
ok.

Groovounet
01-11-2011, 07:24 AM
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...

ravage
01-11-2011, 08:41 AM
thanks, I just wanted to be sure since I usually work with an array of floats instead of structures.

thanks Groovounet and V-man.