Resource management is key regardless of what platform you’re developing with, and is especially important on a mobile platform like the iPhone where memory is limited. Consequently, I’ve been working on a resource manager for my engine.
The resource manager is designed to not only handle file-based resources, such as images, shaders, models and other art assets, but GL resources as well such as vertex buffers and compiled shaders.
Resources are split into two different class trees: InternalResource objects and ExternalResource objects. When a resource is loaded for the first time a key-value pair is stored in a dictionary, where the key is a unique identifier for that specific resource. If the same resource is needed again, it is loaded from the dictionary. For example, the first time a mesh file named “FancyCar.obj” is loaded it is parsed by ObjMeshParser that produces a vertex/index buffer pair for rendering. The vertex buffer would be stored under the name “int_vbuff_fancycarobj.” Any subsequent attempts to load that .obj file would return the existing resources rather than re-parsing it from the file.
On another note, as I mentioned in the last post I’m looking for an ideal model format. The Obj format is quick and easy to use, however it lacks support for animations. For the time being it’s sufficient, but I would like to move to something more flexible later on. I did look into the .blend format, but it includes too much extra data such as cameras, lights and rendering settings. Collada does sound like it would work well, but I’ve never used it or done any XML parsing before. The other option would be to design a model format that’s compatible with my engine. This would make it easier to have precise control over the data that’s included in a the model, and would also allow for storing compatible material properties directly in the files. It would require additional coding and research though, so I’ll have to think on this one.