Last active
March 21, 2021 15:58
-
-
Save katsaii/61fe203e7b59fa4cbebd82886c1e7268 to your computer and use it in GitHub Desktop.
Returns the size (in bytes) of a Game Maker vertex format.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// @desc Returns the size (in bytes) of a vertex format. | |
/// @param vformat {Integer} The vertex format to inspect. | |
/// @author Kat @katsaii | |
var max_size = 256; | |
/* 32 bytes is a realistic size. | |
* 256 is an, unrealistic, finite upper limit. | |
*/ | |
var buff = buffer_create(max_size, buffer_grow, 1); | |
var vbuff = vertex_create_buffer_from_buffer(buff, argument0); | |
var vbuff_buff = buffer_create_from_vertex_buffer(vbuff, buffer_grow, 1); | |
var vcount = vertex_get_number(vbuff); | |
var size = vcount > 0 ? floor(buffer_get_size(vbuff_buff) / vcount) : -1; | |
buffer_delete(buff); | |
vertex_delete_buffer(vbuff); | |
buffer_delete(vbuff_buff); | |
return size; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think that it's worth it! It's definitely something that is useful for writing code that doesn't assume a certain vertex format.