• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Reading the contents of a vertex bufferr

P

Prometheus1998_

Guest
I'm planning on creating a vertex buffer-building DLL in C++, to take advantage of multithreading while generating large and dynamic vertex buffers without editing any of GameMaker's source files (technically possible, according to this thread here). To do this, though, I need to know how Game Maker: Studio stores data in vertex buffers.

With that in mind, is there any way to save the contents of a vertex buffer into a human-understandable format? I don't care if the values are visually paired with a descriptor of what it is; that would probably be far too much trouble for what little benefit I would get out of it. But assuming I already know the coordinates of a set of points, the texture coordinates assigned to them, et cetera, is there a way to visually see the order that information is saved in?
 

Binsk

Member
You can create a regular buffer out of a vertex buffer. Look up buffer_create_from_vertex_buffer. You can also go the other way.

When it is in a normal buffer you can use buffer_get_address to retrieve the pointer to the actual array containing the data (which you can pass to your DLL for modification).

In the array itself you need to format the data to match your vertex_format. Take a look at this page to see what kinds of data each type of category needs. You may have to play around with datatype sizes to figure it out but I would assume the data is probably a mix of floats and bytes (floats for things like normals, bytes for color) but, as said, you may have to play with it until you figure out what works.

I did something like this way back but it was long enough ago I can't remember the datatype sizes. I do know you should be able to get it to work, however.
 
Last edited:
Top