How to modify an instance of gpu.types.GPUVertBuf?


#1

Hi,
in the GPU drawing examples (/doc/python_api/examples/), they all create static batches. You create it and then render it forever.
But in some cases you want to draw something that changes with time.

The only sample I could find that draws dynamic geometry does it by recreating a new GPUVertBuf on every frame (https://developer.blender.org/F4765373).

How can you modify the contents of a preexisting GPUVertBuf object? Do you have to call attr_fill again, with different data? I guess what I’m looking for is functions that represent glBufferData or glMapBuffer.


#2

I’m not very familiar with this API, but have you tried just calling attr_fill with different data?


#3

Hi @brecht, if you do that you get a “Can’t fill, static buffer already in use” error message, from this line: https://developer.blender.org/diffusion/B/browse/master/source/blender/python/gpu/gpu_py_vertex_buffer.c;87786566929610e8717b859cc6e61637d70a9ab0$203

So while looking for other ways I noticed that the BGL module is still around 2.80 (I thought it was going to be removed), so we can manually create VBOs for dynamic use, using OpenGL examples around the web as reference. It takes more code but then you have absolute control.