• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Legacy GM Error: Vertex buffer of size 0 bytes

C

Cristiander

Guest
I am getting this error when i create an object.
When I place the object in the room normally nothing happens, it works fine, but when i create it using instance_create i get this message
I don't understand what this means or how to fix it, any help?

Code:
FATAL ERROR in
action number 1
of Create Event
for object obj_juju_silhouette:

Fatal Error: Can not create vertex buffer of size 0 bytes
5 vertex buffers allocated with total size of 1920 KB
at gml_Object_obj_juju_silhouette_CreateEvent_1 (line 65) - vertex_freeze( vbuff );
 

Bingdom

Googledom
Show us relevant code, we cannot help you unless you tell us your code. I don't know how to use vertex buffers yet but im sure someone in this forum will know ;)
 
C

Cristiander

Guest
This is the creation code that is mentioned in the error
Code:
///Create

//
//Copyright (c) 2016 Julian T. Adams / @jujuadams
//
//Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

global.silhouetteActive = true;

prevViewX = view_xview[0];
prevViewY = view_yview[0];

sur_silhouette = noone;

//Create vertex format for the occluder geometry (100% standard vertex format)
vertex_format_begin();
vertex_format_add_position();
vertex_format_add_colour();
vertex_format_add_textcoord();
vft_silhouette = vertex_format_end();

//Create depth-ordered priority queue to draw occluders in the correct order
var pri = ds_priority_create();
with( obj_sil_occluder ) ds_priority_add( pri, id, y );

//Create occluder vertex buffer
tex_silhouette = sprite_get_texture( spr_sil_occluder, 0 );
vbf_silhouette = vertex_create_buffer();
var vbuff = vbf_silhouette;
vertex_begin( vbf_silhouette, vft_silhouette );

while( !ds_priority_empty( pri ) ) {

    //Using the scope of the next occluder in the queue...
    with( ds_priority_delete_min( pri ) ) {
    
        //Work out the graphical limits of the instance
        var instL = x - sprite_get_xoffset( sprite_index );
        var instT = y - sprite_get_yoffset( sprite_index );
        var instR = instL + sprite_get_width( sprite_index );
        var instB = instT + sprite_get_height( sprite_index );
    
        //Set the blend colour for the top (lowest y-value) of the occluder mask
        var c_blend = make_colour_rgb( min( 255, sprite_get_height( sprite_index ) ), 0, 0 );
    
        var sprUVs = sprite_get_uvs( sprite_index, 1 );
    
        //TL tri
        vertex_position( vbuff, instL, instT ); vertex_colour( vbuff, c_blend, 1 ); vertex_texcoord( vbuff, sprUVs[0], sprUVs[1] );
        vertex_position( vbuff, instL, instB ); vertex_colour( vbuff, c_black, 1 ); vertex_texcoord( vbuff, sprUVs[0], sprUVs[3] );
        vertex_position( vbuff, instR, instT ); vertex_colour( vbuff, c_blend, 1 ); vertex_texcoord( vbuff, sprUVs[2], sprUVs[1] );

        //BR tri
        vertex_position( vbuff, instL, instB ); vertex_colour( vbuff, c_black, 1 ); vertex_texcoord( vbuff, sprUVs[0], sprUVs[3] );
        vertex_position( vbuff, instR, instT ); vertex_colour( vbuff, c_blend, 1 ); vertex_texcoord( vbuff, sprUVs[2], sprUVs[1] );
        vertex_position( vbuff, instR, instB ); vertex_colour( vbuff, c_black, 1 ); vertex_texcoord( vbuff, sprUVs[2], sprUVs[3] );
    
    }
}

vertex_end( vbuff );
vertex_freeze( vbuff );

ds_priority_destroy( pri );


line 65:
Code:
vertex_freeze( vbuff );

The object and the script was taken from here:
http://ruinofthereckless.com/ruin-of-the-reckless-5-silhouettes-in-game-maker/
 

Mike

nobody important
GMC Elder
You probably haven't added any data to the vertex buffer. My guess would be one of your while()s are failing and your falling out without running through the vertex construction code.

Also... vertex formats should be a global resource. Don't make them for each model you create - that's a total waste of memory.
 
Top