A downloadable GameMaker Code Asset

Download NowName your own price

This is a thing designed to make building vertex buffers manually a bit less tedious, by letting you switch between primitive types during a build (at least for triangles). It mostly exists to simplify code.

I made it because I was building a vertex buffer and was like "this is really tedious. If only I could mix primtive types so I didn't need to repeat so much code or build many buffers, thus slowing down rendering". Or something to that effect.

So I took a couple of days and I made it work.

Types allowed are:

  • pr_trianglelist (default - this actually makes the buffer behave like normal)
  • pr_trianglefan
  • pr_trianglestrip
  • pr_quadlist (this one's custom! Defined clockwise)

Then, you just gotta submit as a pr_trianglelist when vertex_submit-ing (because we aren't really changing primitive type, I just emulated them with triangle lists)

Cool Thing? It's plug-n-play. You can add it to any project and it will (should?) not break it. You build vertex buffers in the exact same way with the exact same functions too, thanks to function substitution using macros. Just slap in the vertex_buffer_set_buildmode function when you wish to change type, and you're good to go. 

Also included is a vertex_buffer_macros script that allows some user configuration.

It also fixes vertex_argb on Windows. I'll remove that fix if/when that gets fixed in GameMaker (Here's the bug report), since it would re-break it in that case (there's a macro to disable the fix though in the meantime)

I've included a demo project (the one used to generate the image) so you can see how it works and play with it a little. It does use the vertex() function instead of all the individual vertex_* functions though, just because I felt like it. Still fully compatible with those though,

How's it work?

Check out the post on my Website, where I go into more detail about how this actually works.

Some warnings:

  • The overrides change how formats and vbuffers are handled slightly, meaning invalid vert entries may not give warnings that are as helpful as GameMaker normally provides. Everything is broken down into floatX, color or ubyte4, instead of the original functions. Their usages and types should still be mapped correctly though.
  • If two scripts attempt to override the same function, macro re-definition errors will probably occur, so this is not compatible with other assets that also override vertex buffer functions. 
  • Buffer building is probably a bit slower at runtime with this, as there are more checks to make stuff work right. It shouldn't cause too many problems, unless you build a lot of big buffers every frame.

There are a few other functions too!

  • vertex_buffer_is_frozen(vbuff)
  • vertex_format_exists(vformat)
  • vertex_buffer_exists(vbuffer)
  • vertex_format_typesize(vertex_type_*) (returns the size in bytes of the format type)
  • (there's also another few things possible to do, since I needed to do them to make this work - like getting the format a vbuffer is using, the types a format is using etc, I just haven't added the scripts yet!)
  • I haven't tested this as thoroughly as much of my other stuff, and I don't plan on expanding the feature set more. There should be no memory leaks or crashes (if used properly)  So, it is what it is. I will fix bugs though. After all, I made it so I can use it.



Download

Download NowName your own price

Click download now to get access to the following files:

[GMS2] Importable Project File (.yyz) 51 kB
[GMS2] Local Asset Package (.yymp) 26 kB

Leave a comment

Log in with itch.io to leave a comment.