- Online Community Forums » Programming Questions » Accessing contents of ALLEGRO_VERTEX_BUFFER

Credits go to MikiZX and SiegeLord for helping out!
This thread is locked; no one can reply to it. rss feed Print
Accessing contents of ALLEGRO_VERTEX_BUFFER
Member #11,279
August 2009


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?

Member #17,092
June 2019

I would think so (on both accounts), if you look at the example
, 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.

Member #7,827
October 2006

Yep, casting the return value of al_lock_vertex_buffer is correct.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Member #11,279
August 2009

Thanks, guys.

Go to: