Jump to content
  • Advertisement
  • entries
  • comments
  • views

Integration Day

Sign in to follow this  
Mike Bossy


This morning I worked on integrating my resource manager into my game. The good news is that I didn't have any problems with the new code. It all ran flawlessly thanks to getting most of the bugs ironed out with unit tests. The tricky part was getting my game to use it properly. Up until now I've just had my scene classes loading up the textures it wanted, when it wanted it. Being on the multi-threaded kick I wanted to make my resource manager run on it's own thread. This actually has some good uses beyond just being fun.

One of the problems with D3D on a PC is losing a device. This can happen when someone changes resolution or when the stars become misalligned. When this happens you have to release all your textures, reset the device and reload your textures. When this becomes trickier is when you start throwing multiple threads into the mix. What I found out in the early work on my engine is that you need to use the same thread that creates the textures to release the textures. Depending on how you have your threads working this can actually be a bit tricky. Having a resource manager running on it's own thread solves this problem. Since it handles all loading and releasing of textures you always have the same thread doing that work. Good stuff.

Of course life isn't always simple. My scene objects now have to ask the resource manager to load something. This is done by sending a message to the manager. Not wanting to create any blocks on my threads I made this an asyncronous action. So the scene makes the request and then just goes on it's merry way doing whatever other work it wants. When the resource manager is done loading things it sends a message back to the scene along with a pointer to the new texture object. Add a message handling function to the scene and everything is working. Next step is handling the loading of audio resources this way as well.
Sign in to follow this  

1 Comment

Recommended Comments

Threads are evil!

(oh, and thanks for reminding me about unit testing :D)

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!