2
\$\begingroup\$

I am curious as to what technique(s) are used to load files in while a game is running. For example, Minecraft will load chunks as you get within a certain range of them. How is this achieved without producing lag? Is multithreading involved?

\$\endgroup\$
3
\$\begingroup\$

Yes, this can be solved with multithreading. Either explicitly by creating a new thread which reads and interprets a file, or implicitly by using an asynchronous file access API which calls a callback function when a file finished loading.

The biggest problem with loading assets on demand is what to do when an asset is needed immediately, but it hasn't loaded yet. You can either pause the game until the asset is loaded (which is annoying), or replace it with a temporary placeholder (which can break immersion).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.