Imiglikos
Member
Okay, so, when you add a sprite into GMS, it will by default be packed onto a texture page. If you don't tell GMS how to pack them, then it will just stuff everything onto as many texture pages as you require in any old way, which means that you may have a situation where you have five things being drawn on screen, and all five come from a different texture page. This then means that you are getting excessive texture swaps, which in turn affect performance.
To resolve this you need to create texture groups. this can be done from the Texture Group editor: http://docs2.yoyogames.com/index.html?page=source/_build/2_interface/3_settings/textures.html
Here you simply create groups for your sprites to later be assigned to. For example, if you have a bunch of stuff that is only used as an introduction or splash screen, then you'd create a texture group "tp_Intro" for them, or if you have a series of levels that each use a different tileset and sprites for enemies, then you'd have "tp_Level1" and then "tp_Level2" etc... (you can name them whatever you want, these are just examples).
Once you have the texture pages set up you can then assign sprites to them, either directly from the texture group editor or from the sprite resources themselves. You may get a small boost in performance just from doing this, but for full control, you then need to enable the "load textures on demand" option, and load/flush textures as required.
To load a texture into memory, you can call the functions sprite_prefetch or sprite_prefetch_multi. Note that you do not need to do this for every sprite in the game! Only for a single sprite from each texture group that you want to load into memory. When you no longer need these sprites they can then be flushed from memory using the equivalent flush functions.
Hope that helps!
Hi,
I Refresh the topic a bit .. (split from this ~Tsuk)
My game currently runs at 60fps. It also works on a variety of better, worse computers.
Currently, the game has a volume of 140mb and I have several rooms with graphics
13 rooms including game menu and side rooms plus intro room, and game over room and logo room
and 5 rooms with game gameplay which gives a total of 18 rooms
I created a texture group for several groups to further optimize the game
I split it like this
group 1
game menu - here are all boards only from the game menu and the intro board, the end of the game and the logo board
group 2
objects - that is, enemies, traps and the hero that can repeat more often in the game.hud bar
group 3
scenery 1 -the first gameplay room in which I placed the backgrounds from this board and cut the scenery into tiles
group 4
scenery 2 -the second gameplay room in which I placed the backgrounds from this board and cut the scenery into tiles
group 5
scenery 3 -the third gameplay room in which I placed the backgrounds from this board and cut the scenery into tiles
group 6
scenery 4 -the fourth gameplay room in which I placed the backgrounds from this board and cut the scenery into tiles
group 7
scenery 5 -the fifth gameplay room in which I placed the backgrounds from this board and cut the scenery into tiles
And now I would like it to be able to deleted graphics from gpu's memory if not in use ... because now it's loaded once and it's still in gpu
I read this whole tutorial, but I don't quite understand how to do it ... a specific comprehensive example is missing here ...
I only know one thing, so I understood that I have to use such a solution in every room in the creacion code and then load the sprite or background
e.g. I'm in the game menu, so in every room of the game menu I have to use such a solution, right?
that is, remove graphics from memory and then load it
example menu rooms
main menu
creacion code
GML:
draw_texture_flush();
sprite_prefetch(spr_logo_game);//that is, I remove the logo that appeared at the start of the game and does not appear in other rooms anymore
sprite_prefetch(spr_main_menu); //this is an image from the main menu
option menu
creacion code
GML:
draw_texture_flush();
sprite_prefetch(spr_option_menu);//this is an image from the options menu
highscore menu
creacion code
GML:
draw_texture_flush();
sprite_prefetch(spr_highscore_menu);//this is an image from the highscore menu
room stage 1 gameplay
creacion code
GML:
draw_texture_flush();
//scenery sprites divided into smaller fragments
sprite_prefetch(spr_scenery part1);
sprite_prefetch(spr_scenery part2);
sprite_prefetch(spr_scenery part3);
sprite_prefetch(spr_scenery part4);
is it supposed to look like this? I don't know how to implement it properly ..
what about removing the background from the memory? will it work the same as for sprites?
Is there another way to remove sprites and backgrounds from gpu memory? e.g. the script that does this?
I am asking you for help ... thank you
Last edited by a moderator: