• Advertisement
Sign in to follow this  

Load all textures at once, or as needed?

This topic is 448 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

 

This is my first post. I'm also teaching myself everything with regards to game development, so I apologise if I seem a little naive.

 

I'm currently programming a rendering function for my game and I'm trying to work out what is the best way to load textures into the game.

The game world is a voxel grid, where each voxel is a pointer to a predefined block struct.

Said struct contains the SDL_Texture pointer along with other data.

What is rendered to the screen is a small window of blocks, say 21x15 blocks with each block having a resolution of 16x16 pixels.

Not really mega stuff.

So should I set every pointer at startup or should I load everything into the game as the renderer needs it and then delete it.

Like I say I'm not to knowledgable here, so which is more efficient or what have you.

 

Thank you.

Share this post


Link to post
Share on other sites
Advertisement

As Kylotan says, you start by just loading everything up at program start. Caveman 3.0 does this.  I believe Rome II Toal War does as well.  if that starts taking forever, you go to loading a level at a time, like dungeons in Skyrim.  If that's too big and will take too long, you switch to loading levels / areas / chunks in the background, like skyrim when out in the wilderness.

 

demand load paging of assets is another option. can work well with predictive background loading. but occasionally you get a cache (texture memory pool) miss, and your render speed drops to that of your hard drive as Kylotan says. this can mean the difference between playable on a bleeding edge PC, and unplayable on a low end rig.

 

load at program start. if it gets slow, try optimizing it first.  binary fread_nolock() is VERY fast.  slow load times are often the result of inefficient file formats. that's why many games use their own custom formats with just what they need and nothing more. some of those custom formats have gone on to become de-facto industry standard formats.

Share this post


Link to post
Share on other sites

I'm also teaching myself everything with regards to game development

 

If you're at a point where you're mostly learning, or it's a game that doesn't have a lot of textures to begin with, then it makes perfect sense to load up all your textures as soon as your app start, so you're ready to use them as soon as you need them.  A bigger and more complicated project might delay loading assets until they're needed to save memory, but it's the kind of thing that only makes sense to do if you're trying to solve a specific problem.

Share this post


Link to post
Share on other sites

Do you have any source material for this?

 

based on program behavior.  

 

there is a load screen at program start, then a main menu, then a loading game screen, and your in.    since its not a level based game, you need more or less all the graphics at once.   also, come to think of it, when i would run it on my old PC, it would page assets off the hard drive.  so it probably reverts to demand load paging if there's not enough ram to load all the assets upfront.    it was so slow on the old PC, i gave up and bought shogun2.        

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement