Just had some thoughts about better ways of handling media, and here's my idea of a basic media management system:
Media loading is entirely up to the engine, the programmer just requests media and stores a handle to it, like so:
global PlayerObj as Object
function PlayerSetup()
local PlayerSkin as Image
PlayerSkin = Image("gfx\tex\generic.dds")
PlayerObj = Mesh("gfx\mesh\cylinder.x")
SetObjectTexture(PlayerObj, PlayerSkin)
endfunction
If the media requested is already loaded, a handle to the existing resource is returned. Naturally it will be desirable to be able to ask for a copy to be made, in the case of when a programmer wants to alter media on-the-fly.
Media can be precached, meaning any media in the precache list will be loaded when the application starts. When media isn't precached, it'll be loaded on-the-fly.
Media can be loaded in the background, similar to precaching although it happens over time. In order to accomplish this, the engine precaches a low-quality version of all the media when the application starts (this is meant to be very fast), allowing the game to use and display the media until a higher quality version is loaded, which will replace the resource automatically. If a low quality version isn't available or the programmer explicitly wants the media to be loaded at that time (in order to use it immediately), the application will pause while it loads it.
Such a system would eliminate the need to keep track of certain resources that would usually be copied manually (via clone object for meshes, for example) for optimization, as well as allowing the background-loading system to be implemented.
Thoughts?