Accessing contents of ALLEGRO_VERTEX_BUFFER
BitCruncher

Hey,

So after I create a vertex buffer with al_create_vertex_buffer(), assuming I've locked the buffer first, can I just access the verts in the buffer as if it was just an array of ALLEGRO_VERTEXs?

EDIT #1:
Thinking about it, since al_lock_vertex_buffer() would return void*, I would have to cast that to ALLEGRO_VERTEX*... Can this be safely done?

MikiZX

I would think so (on both accounts), if you look at the example https://github.com/liballeg/allegro5/blob/master/examples/ex_vertex_buffer.c
, line 55 does access the VBO memory and copies from ALLEGRO_VERTEX *vertices to it. The copy itself is done using standard memcpy function (as opposed to using some low level graphics driver call) so I think it is safe to assume that poking the VBO memory directly by addressing it using ALLEGRO_VERTEX pointer will work just fine too.

SiegeLord

Yep, casting the return value of al_lock_vertex_buffer is correct.

BitCruncher

Thanks, guys.

Thread #617962. Printed from Allegro.cc