Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of ~archive/ResourceManager


Ignore:
Timestamp:
Nov 27, 2007, 10:04:44 PM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • ~archive/ResourceManager

    v1 v1  
     1= Resource Manager =
     2Resources are Objects, that can be loaded from a harddrive, and then used from memory.
     3Because the loading process is quite Resource-dependable, the loading of each resource (e.g Texture, 3d-model etc.) should be made as little as possible.
     4
     5For this Orxonox provides a Shared Resource System for these time-consuming processes.
     6
     7 1. Resources that are loaded (like a Texture) always have a Data-type (like TextureData) where the data is stored.
     8 2. The Resources have a counted pointer to these Data, so if you copy one Texture to another one, only the pointer will be copied, and the reference-count of the pointer will be automatically increased
     9 3. To Finaly load a Resource from disc, and keep a constant version of the Data in check, the Resource functionality is finally used: for the Resource Texture the coresponding Resourcerer is ResourceTexture.
     10   Resources do:
     11   * locate Files on the disc in a Directoy of your joice
     12   * store a copy of a ResourceData with a Key-Name.
     13
     14In the following document ResourceTexture is only assumed as an Example. This also works with ResourceMD2, ResourceOBJ, ResourceSoundBuffer and so on.
     15== Usage Example ==
     16  * Share a Resource (assumes texutre has some data assigned to it):
     17{{{
     18#!cpp
     19#include "texture.h"
     20...
     21 Texture copy = texture;
     22}}}
     23Here you can see, that copy has _NO_ pointer type, so we can copy one Texture to another one, and both textures share the same data.
     24  * Load a Texture from the disc with ResourceTexture
     25{{{
     26#!cpp
     27#include "texture.h"
     28#include "resource_texture.h"
     29
     30...
     31  Texture storeTex = ResourceTexture("orxonox.png", GL_TEXTURE_2D);
     32}}}
     33As you can see Texture is loaded over ResourceTexture, the data loaded in Resource Texture is assigned as easy from Texture to storeTex as from any other Texture (since ResourceTexture isA Texture :) ).
     34
     35== Behind the scenes ==
     36ResourceTexture is a Handler that is derived from Texture and Resource.
     37  * The Texture part sais, how to load a Texture from a disc.
     38  * The Resource part sais, where the Resource can be found, and to check if the Resource was already loaded