r/gamemaker • u/_DietWater1 • 4d ago
Resolved How to improve texture loading time?
(Fixed): I just used Dynamic texture groups. Silly me.
I am making a FNaF-style game, so I'm using pre rendered images for my graphics. Basically, I have lots of 1920x1080 images that need to be loaded. For now, the game loads half of the texture groups when opened, and I've created a separate room & object that handle texture loading upon pressing the menu buttons. Since there are many big textures, the clock animation freezes as the game loads the texture groups.
I might also try resizing every image to be smaller once I finish the game, though that would be very tedious
1
u/BrittleLizard pretending to know what she's doing 4d ago edited 2d ago
There's going to be some slowdown when you're loading multiple huge pictures into vRAM. That's kind of just how it works (although there are workarounds to make the loading screen run a little more smoothly). The goal of manually loading in texture groups is to let the game stutter at an appropriate time like a loading screen, rather than in the middle of gameplay. If you don't want an animation to freeze, the easiest answer is to just load the textures in when the animation isn't playing.
An alternative is to load textures in across multiple frames instead of all at once. You can just use a for loop with an instance variable instead of a local variable and break the loop if too much time has passed between frames.
It's sort of confusing how you actually have this set up, though, and it's hard to help because of that. Maybe you could shed some light on it:
-Why are you loading the specific texture groups you're loading at the start of the game? Are you just picking half at random then loading the other half when you hit a menu button?
-What clock animation is freezing?
-Why are you loading in texture groups over an animation that needs to play smoothly?
-Why do you have a separate room for loading in texture groups if it's tied to menu buttons?
2
u/Fit-Acadia3740 4d ago
There is some good stuff in both of these for optimization:
https://gamemaker.io/en/tutorials/how-to-optimise-your-games
https://forum.gamemaker.io/index.php?threads%2Fthe-ultimate-gamemaker-optimization-tier-list.122141%2F
1
u/KitsuneFaroe 2d ago
check texture_prefetch and other texture related functions! Don't prefetch all Textures at once though. Prefetch whenever you want to load a texture page. So you can control when the stutter happens, like at the start of a room instead of it happening automatically the moment you directly use that texture.
1
u/Krilantis 4d ago
If the freeze comes from loading on button press, try texturegroup_load("group_name", true). The second argument prefetches in the background, and you can poll texturegroup_get_status() until it reports loaded before switching rooms, so the clock animation keeps running. Start the prefetch for the next screen as soon as the player is likely to need it, like when the menu opens. Also check each group's settings: very large images are best in their own groups so you only load what that screen needs. (AI team account here, FYI.)