Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Dear Yal! Its all nice working but im facing some issue with terraincontrol object, when i click Play button my game freezing for 10 sec :(( I'll try compile with YYC but it didnt help. In the debug screen i saw just
"Pause event has been registered for this frame"
and "Pause event has been unregistered" after that
Please, how can i fix this? Thanks!

gms2 (ide 2.2.4.474, runtime 2.2.4.374)

For some reason d3d_model generation is a lot slower in GMS2 than it is in GMS1. The easiest workaround would be to just add a loading screen and display that for the first step as the model is being built, a harder one would be do change the generation code to use vertex buffers instead.

(+1)

I looked into how the vertex buffer system works (I try to avoid everything that has a scary name :P) and it seems to not be super difficult to convert the game to use it. Sorry about the delay with the code fixes, it took some time to research it. Based on the example code on the GMS2 manual page on building primitives...

1) Define a vertex format (you'll need position data, texture data, and normal data - you should add them in the same order they're provided as arguments in the d3d_model_vertex/.../ functions)

2) Find the compatibility scripts for the various d3d_model scripts. If you've done any changes to the project, make a backup now, because we'll hack the compatibility scripts.

3) Change d3d_model_create() so it will create a vertex buffer and start a primitive using your custom format:

v_buff = vertex_create_buffer();
vertex_begin(v_buff, global.my_format);
return v_buff;

4) Change d3d_model_vertex_normal_texture() so that it will add vertex data. It's important you add this data in the same order you defined the different data in the vertex format.

vertex_position_3d(v_buff, xx, yy, zz);
vertex_texcoord(v_buff, tx, ty);

5) Change d3d_model_draw() so it will submit the vertex buffer to the pipeline (using a texture):

var tex = background_get_texture(selected_background);
shader_set(shader_prim);
vertex_submit(v_buff, pr_trianglelist, tex);
shader_reset();
6) d3d_model_primitive_begin() now would have no effect, so delete all code in that script.

7) d3d_model_primitive_end() could be emptied, or just use vertex_freeze() to make the vertex buffer read-only (which speeds up drawing it)


Hope this helps! Let me know if there's any problems.