Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Dear Yal,

Few of the players of my game have found next bug:



When I removed all the hedge-objects from the level, another object has triggered this message:




Do you know, what could be the problem? Could you help?

(3 edits)

I did some googling and it looks like the issue is that the batch of trianges becomes so big the players' graphics cards can't handle it. (800 MB VRAM sound very small these days but ah well...) 

So we need to reset the drawing batch every 1000 triangles. I tried to figure out the easiest way to do that and here's my idea.

1) Create a new script with the following function:

function triangles_break_batch(quads=6){
     global.triangles_so_far += 2*quads
     if(global.triangles_so_far >= 1000){
         global.triangles_so_far -= 1000
         draw_flush()
     }
}

2) Init global.triangles_so_far to 0 somewhere before any 3D drawing, e.g. In CONTROL's create event.

3) Put this new triangles_break_batch function at the start of the Draw event of all terrain objects. You'd compute "quads" like so,

//For a block or wall
triangles_break_batch((image_xscale + image_yscale + image_xscale*image_yscale)*2)
//For a floor or slope
triangles_break_batch(image_xscale*image_yscale*2)

I am using GM:S 1.4, which does not have functions. I can change your code into script-like, but just to be sure: I shall change the "draw_flush()", and calling the new scipt I shall set the "quads" equal to 

(image_xscale + image_yscale + image_xscale*image_yscale)*2

for blocks and walls?

(2 edits)

Yes, just having a script asset with the same name should work too

  • change "quads" to "argument0" in the script
  • if draw_flush doesn't exist (it was added late in 1.4) overwriting the world matrix (e.g. by d3d_transform_set_identity or matrix_set) should also force a flush of the geometry buffer

Blocks/walls should use that formula, yes (they do indeed add that many triangles). Maybe slap a ceil() around the expression for stability so it always becomes an integer even if a block is e.g. 1.5x its base size. (If you never stretch things out in the room editor it gets easier, then you can just use the hardcoded number 12 for blocks and 4 for floors)

hey! didn't help :[

What exactly does the updated code look like? Are you using draw_flush or d3d_set_identity?

I find it a bit weird that it still tries to allocate a giant buffer of 1/6th of everything else it's rendering when it's totally fine with thousands of smaller ones, are you sure you didn't miss adding the safety code anywhere?

Perhaps it was an error on my side; then I need your help with the code.

I've added this line in the beginning of draw event in every wall or block:

triangles_break_batch((image_xscale + image_yscale + image_xscale*image_yscale)*2)

And this line in the beginning of draw event in every floor and ramp:

triangles_break_batch(image_xscale*image_yscale*2)

Then, I've created a script (still uisng gms 1.4) named "triangles_break_batch" containing this code:

global.triangles_so_far += 2*argument0
       if(global.triangles_so_far >= 1000)
            {
              global.triangles_so_far -= 1000 
              d3d_transform_set_identity();       
            }

Finally, I've added this to the create event of CONTROL object:

global.triangles_so_far = 0

Weird, everything looks like it should... does draw_flush exist in your version of GM? If it exists you should call that alongside d3d_transform_set_identity in triangles_break_batch (and maybe in draw_self_enemy as well) just to make sure the draw pipeline gets flushed.

my version does not have draw_flush. is there anything else I could do, or should I try to get the greater version of GMS?

I would recommend looking into it if it's an option, GMS1 hasn't had official support in years and it's only a matter of time before its old graphics APIs will stop working entirely... :(

Currently the free license lets you export games to desktop platforms if the game's not sold, so there's basically nothing to lose just trying it out. (And I'd recommend getting GMS2 from the official download page since it's literally free)