Jump to content
  • Advertisement
Sign in to follow this  
Schinizer

OpenGL Loading textures, model files etc..

This topic is 3081 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

Hi all. I usually code openGL demos by loading all required stuff at the start of the program. But this way of doing things start to get bad when I am coding something bigger, like a game for example. As the program is loading files or textures, you do not have control of the program. So the OS would probably say that your program is not responding. I was wondering how do game programmers make the "Now Loading" screen, rendering something onscreen and loading files and textures in the background. I thought of using threading to manage this. However I've read that you cannot call gl functions from 2 different threads. Any experts care to share some tips? Or guide me? Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
I've seen professional games that use a single thread to load resources so it is not a big deal.

You can of course load resources with a second thread. When I say load, I mean load from disk and use the CPU to decompress your png file or whatever file. Do not make any GL calls in the second thread. Use thread 2 to signal the primary thread that it needs to call glTexImage2D or glBufferData or whatever.

Share this post


Link to post
Share on other sites
A single-threaded solution would be to first load some essential display files (like a loading bar or fonts or something), then load the rest of the required files in a loop; in each loop iteration, you would update the screen after loading a single file (for example advancing a loading bar, etc).

Probably most games do this; it seems kind of a waste of effort to multithread this. In some games (Doom 3 and Quake 3 come to mind all though they are somewhat old), you see the fps dropping to 1-2 in the loading screens so it seems like they do this too.

Finally, the "not responding" message is heuristic... if a program loops for a certain number of times it will display this. It's provably undecidable whether a program will halt or not. So don't worry about that :P.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!