Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit)

So the ability to 'remove' mesh data from a static buffer is a bit complex and not a feature I have implemented. This is because I do not have anything implemented that keeps track of not only where things are stored in the static buffer, but also how many bytes are stored for 1 particular instance, since all that building a static buffer does is add vertex positions on the fly. 

This is an intentional design decision because they are meant to be static, and thus not modified. You must build them when you create them or you will get an empty vertex buffer (the error you receive). 

This could also negatively impact performance because it would require re-creating the buffer without the element, and then re-building it from scratch as GM doesn't have a way to directly modify vertex buffers since vertex buffers are stored in GPU memory (this is why they are so efficient, because you don't modify them. haha). 

That said, you are free to add this functionality yourself if you wish! The __FauxtingWrite* functions are what is used to add data to vertex buffers. You could add some way to keep track of the byte position within a buffer and how many bytes the object adds to the buffer, and then use buffer_create_from_vertex_buffer(), copy the buffer up to that positions using buffer_copy, skip the number of bytes for a specific object, and append the copied buffer with another buffer_copy from that positions to the end of the buffer. 

Hopefully that makes sense. haha. Unfortunately there just isn't a simple way to handle doing something like this and the likelihood is that you would get massive frame drops while you wait for the program to de-build the vertex buffer, remove elements, and then re-build the buffer. haha.

 I hope this helps!