namespace RSRC
Everything related to loading and mantaining a resource is in this namespace
RSRC | Everything related to loading and mantaining a resource is in this namespace |
Functions | |
Init | Initializes the resource interfaces to use the specified mode |
Shutdown | Shuts down the resource interface |
CompleteUnload | Unloads all resources regardless of flags. |
ResetUnload | Unloads all resource that have RSRC_RESET set. |
Reload | Reloads all resources that have are in state RSRC_STATE_PENDING. |
Enumerations | |
RSRC_INTERFACE_TYP | Identifies what kind of interface a resource is using. |
RSRC_FLAG_TYP | Used by the Resource to describe the needs of the lock or the resource |
RSRC_STATE_TYP | Describes the state of a resource |
RSRC_TYPE_TYP | Identifies that type of Resource that was created. |
IMAGE_FLAGS_TYP | Helps specify loading options for IMAGE_OPTIONS_TYP |
VERTEX_TYPE_TYP | Helps describe a VertexBufferResource. |
Types | |
VERTEX_OPTIONS | Alias for VERTEX_OPTIONS_TYP |
VERTEX_OPTIONS_PTR | Alias for a pointer to a VERTEX_OPTIONS_TYP |
RSRC_LOCKINFO | Alias for RSRC_LOCKINFO_TYP |
RSRC_LOCKINFO_PTR | Alias for a pointer to RSRC_LOCKINFO_TYP |
IMAGE_OPTIONS | Alias for IMAGE_OPTIONS_TYP |
IMAGE_OPTIONS_PTR | Alias for a pointer to IMAGE_OPTIONS_TYP |
RSRC_LOCKINFO_TYP | This structure is used to request and to process locks made on resources. |
Variables | |
Flags | DWORD This is a RSRC::RSRC_FLAG_TYP |
pDest | VOID* Points to the beginning of the memory block |
Pitch | INT The amount of bytes between “lines” in the Resource |
width | INT Width of the Resource |
Stride | INT The amount of bytes between objects (ie. |
Size | INT Size of the resource in number of strides |
Valid | INT Wether the lock is valid or not |
height | INT Height of the resource. |
bpp | INT The bits per pxiel. |
IMAGE_OPTIONS_TYP | Used to describe how to open and load an image from disk. |
Variables | |
Image_Flags | DWORD RSRC::IMAGE_FLAGS_TYP that help setup options for loading the image |
pFilename | char* Null terminated filename to load |
LoadRect | RECT Size of the image or surface to create |
SrcKeyColor | DWORD Color for SrcKeying |
Bpp | INT Specifies a different bpp to convert the image to |
numMipMaps | INT Specifies the mipmap level if MIPMAP flag is set (0 for maximum) |
LoadFunc | *(LoadFunc)(RSRC::RSRC_LOCKINFO_PTR) Pointer to a function to load data to. |
VERTEX_OPTIONS_TYP | Structure used to create a VertexBufferResource |
Variables | |
Size | INT The size of the vertex buffer |
Vertex_Type | DWORD RSRC::VERTEX_TYPE_TYP used to descrive the vertex buffer |
Object | Our abstact geralized object class. |
Resource | Our top level resource class. |
Constructors | |
Resource | Creates an empty resource class. |
Resource | Copy Constructor. |
Resource | Assignment Constructor. |
Destructor | |
~Resource | Detaches itself with the Object. |
Virtual Object Functions | |
AquireAndLoad | The Object its attached to aquires any needed interfaces and loads the data into memory based on the initialization settings. |
Lock | Locks a resource and locks the objects mutex. |
Unlock | Unlocks a resource that was Lock’d. |
UnloadAndRelease | Unloads the Object the resource is pointing to from memory and releases it’s interfaces. |
Detach | Detaches itself from the Object it was pointing to. |
TestState | Tests the state of the Object and copies over all its state information into the resource. |
Accessor Functions | |
getFlags | Gets the current flags of the resource. |
getState | Gets the current state of the resource. |
getType | Gets the current type of the object the resource is connected to. |
SurfaceResource | Allows access to creation of SurfaceResources and provides the neccessary functions to create SurfaceObjects of various types. |
Creation Functions | |
CreateFromFile | Uses provided options to create an object. |
CreateFromFile | Uses the filename to create a generalized IMAGE_OPTIONS_TYP and runs CreateFromFile with the created settings. |
CreateBlankSurface | Uses parameters to create a blank surface and optionally allows to fill the surface using a fuction pointer. |
VertexBufferResource | Inherits from Resource. |
Creation Functions | |
Create | Creates a vertex buffer with the specified parameters |
int Init( MODE_TYP Interface )
Initializes the resource interfaces to use the specified mode
Interface | MODE_TYP Specifies what type of interface to use |
False if succeeded, or false otherwise.
void CompleteUnload()
Unloads all resources regardless of flags. Puts them into state RSRC_STATE_PENDING
void ResetUnload()
Unloads all resource that have RSRC_RESET set. Puts them into state RSRC_STATE_PENDING
int Reload()
Reloads all resources that have are in state RSRC_STATE_PENDING.
False if successful, error code otherwise.
Identifies what kind of interface a resource is using. This is useful when users of the resource have a special need to know. It does not change during the life of the resource
RSRC_INVALID | This is the default type to signal errors if it stays at this value |
RSRC_D3D | Indicates that this resource is using the D3DInterface |
RSRC_DDRAW | Indicates that this resource is using the DDrawInterface |
RSRC_GDI | Indicates that this resource is using the GDIInterface |
RSRC_MANUAL | Indicates that this resource is not using any interface and created manually |
Used by the Resource to describe the needs of the lock or the resource
RSRC_SYSMEM | Create the resource in system memory |
RSRC_VIDMEM | Create the resource in video(device) memory |
RSRC_STICKY | Do not unload the resource until Shutdown |
RSRC_WRITEONLY | Will not need to read the resource |
RSRC_READONLY | Will not need to write to the resource |
RSRC_SOFTWARE | Do not use hardware resources |
RSRC_RESET | Set by object to signal a reload required at device reset |
RSRC_RESIZE | Set by object to signal a resize needs to be reset and resized |
RSRC_NOOVERWRITE | Data will be added, but existing data will not be touched. Only implemented for D3DVertexBuffers. No manual implementation is attempted. |
RSRC_DISCARD | Data will be completely written over, existing data should be used then discarded when its been used. Only implemented for D3DVertexBuffers. No manual implementation is attempted. |
RSRC_RNDR_LOCK | Uses the RSRC_LOCKINFO_TYP::pDest to point to a shared_ptr to the actual resource. GDI::Graphic, DirectDrawSurface7, etc. Manual objects will still fill in the structure normally. Implies RSRC_READONLY and will allow multiple locks. |
At the moment, only the VertexBuffer in D3D Mode can use RSRC_NOOVERWRITE and RSRC_DISCARD. I would like to try implementing it into the others, but... its tricky since I didn’t anticipate the need.
Describes the state of a resource
Identifies that type of Resource that was created.
RSRC_TYPE_NONE | Indicates that the resource has no object created |
RSRC_TYPE_SURFACE | Indicates that the resource is a SurfaceResource |
RSRC_TYPE_VERTEXBUFFER | Indicates that the resource is a VertexBufferResource |
RSRC_TYPE_DATABUFFER | Indicates that the resource is a <DataBufferResource> |
RSRC_TYPE_RENDERTARGET | Indicates that the resource is a <RenderTargetResource> |
Helps specify loading options for IMAGE_OPTIONS_TYP
Helps describe a VertexBufferResource. It specifies the details of the vertices.
VERTEX_3D and VERTEX_NORMAL cannot be used with VERTEX_2D
VERTEX_2D | Specifies pre-transformed vertices |
VERTEX_3D | Specifies untransformed vertices. Cannot be used with VERTEX_2D |
VERTEX_NORMAL | Specifies that a normal will be used. Cannot be used with VERTEX_2D |
VERTEX_TEXTURE | Specifies texture coordinates |
VERTEX_DIFFUSE | Specifies diffuse information |
VERTEX_SPECULAR | Specifies specular information |
Alias for VERTEX_OPTIONS_TYP
Alias for a pointer to a VERTEX_OPTIONS_TYP
Alias for RSRC_LOCKINFO_TYP
Alias for a pointer to RSRC_LOCKINFO_TYP
Alias for IMAGE_OPTIONS_TYP
Alias for a pointer to IMAGE_OPTIONS_TYP
typedef struct RSRC_LOCKINFO_TYP
This structure is used to request and to process locks made on resources.
Pitch and width are mutually exclusive with Stride and Size
Union { struct { Pitch, width }; struct { Stride, Size }; };
Variables | |
Flags | DWORD This is a RSRC::RSRC_FLAG_TYP |
pDest | VOID* Points to the beginning of the memory block |
Pitch | INT The amount of bytes between “lines” in the Resource |
width | INT Width of the Resource |
Stride | INT The amount of bytes between objects (ie. |
Size | INT Size of the resource in number of strides |
Valid | INT Wether the lock is valid or not |
height | INT Height of the resource. |
bpp | INT The bits per pxiel. |
DWORD Flags
DWORD This is a RSRC::RSRC_FLAG_TYP
int Pitch
INT The amount of bytes between “lines” in the Resource
int width
INT Width of the Resource
typedef struct IMAGE_OPTIONS_TYP
Used to describe how to open and load an image from disk.
Variables | |
Image_Flags | DWORD RSRC::IMAGE_FLAGS_TYP that help setup options for loading the image |
pFilename | char* Null terminated filename to load |
LoadRect | RECT Size of the image or surface to create |
SrcKeyColor | DWORD Color for SrcKeying |
Bpp | INT Specifies a different bpp to convert the image to |
numMipMaps | INT Specifies the mipmap level if MIPMAP flag is set (0 for maximum) |
LoadFunc | *(LoadFunc)(RSRC::RSRC_LOCKINFO_PTR) Pointer to a function to load data to. |
DWORD Image_Flags
DWORD RSRC::IMAGE_FLAGS_TYP that help setup options for loading the image
int ( * LoadFunc )(RSRC_LOCKINFO_PTR)
*(LoadFunc)(RSRC::RSRC_LOCKINFO_PTR) Pointer to a function to load data to.
typedef struct VERTEX_OPTIONS_TYP
Structure used to create a VertexBufferResource
Variables | |
Size | INT The size of the vertex buffer |
Vertex_Type | DWORD RSRC::VERTEX_TYPE_TYP used to descrive the vertex buffer |
DWORD Vertex_Type
DWORD RSRC::VERTEX_TYPE_TYP used to descrive the vertex buffer
class Object
Our abstact geralized object class. Should not be created by anyone using the Resource Interface. Only used by the Resource classes themselves.
class Resource
Our top level resource class. It is used as an interface for the object classes and should be the only way users of the resource namespace use and create objects.
Constructors | |
Resource | Creates an empty resource class. |
Resource | Copy Constructor. |
Resource | Assignment Constructor. |
Destructor | |
~Resource | Detaches itself with the Object. |
Virtual Object Functions | |
AquireAndLoad | The Object its attached to aquires any needed interfaces and loads the data into memory based on the initialization settings. |
Lock | Locks a resource and locks the objects mutex. |
Unlock | Unlocks a resource that was Lock’d. |
UnloadAndRelease | Unloads the Object the resource is pointing to from memory and releases it’s interfaces. |
Detach | Detaches itself from the Object it was pointing to. |
TestState | Tests the state of the Object and copies over all its state information into the resource. |
Accessor Functions | |
getFlags | Gets the current flags of the resource. |
getState | Gets the current state of the resource. |
getType | Gets the current type of the object the resource is connected to. |
virtual ~Resource()
Detaches itself with the Object.
int AquireAndLoad()
The Object its attached to aquires any needed interfaces and loads the data into memory based on the initialization settings. Puts the resource and the object into state RSRC::RSRC_STATE_LOAD.
False if successful, error code otherwise.
int Lock( RSRC_LOCKINFO_PTR LockInfo )
Locks a resource and locks the objects mutex. Puts the resource and the object into state RSRC::RSRC_STATE_LOCK
LockInfo | RSRC::RSRC_LOCKINFO_PTR Describes how to lock them resource as well as provide information about how to access the data after a successful lock. Check the RSRC_LOCKINFO_TYP::Valid flag to see if the data is valid or not. |
False if successful, error code otherwise.
void Unlock()
Unlocks a resource that was Lock’d. Puts the resource and the object into state RSRC::RSRC_STATE_LOAD
void UnloadAndRelease()
Unloads the Object the resource is pointing to from memory and releases it’s interfaces. Puts the object into RSRC::RSRC_STATE_INIT
void Detach()
Detaches itself from the Object it was pointing to. Will put the resource into RSRC::RSRC_STATE_CLEAN, while the Object determines wether to destroy itself based on how many references it still has to itself
RSRC_STATE_TYP TestState()
Tests the state of the Object and copies over all its state information into the resource. Not all objects implement TestState, in those case it will return the current RSRC::RSRC_STATE_TYP
DWORD getFlags()
Gets the current flags of the resource. Note: Does not poll the object for current flag information. Use TestState for that purpose.
DWORD RSRC::RSRC_FLAG_TYP describing the object
RSRC_STATE_TYP getState()
Gets the current state of the resource. Note: Does not poll the object for current state information. Use TestState for that purpose.
RSRC::RSRC_STATE_TYP with the current state of the object
RSRC_TYPE_TYP getType()
Gets the current type of the object the resource is connected to. Note: Does not poll the object for the current type. Use TestState for that purpose.
RSRC::RSRC_TYPE_TYP with the current type of the object.
class SurfaceResource : public Resource
Allows access to creation of SurfaceResources and provides the neccessary functions to create SurfaceObjects of various types. Inherits from Resource.
|----------| |-----------------| | Resource |<-----| SurfaceResource | |----------| |-----------------|
Creation Functions | |
CreateFromFile | Uses provided options to create an object. |
CreateFromFile | Uses the filename to create a generalized IMAGE_OPTIONS_TYP and runs CreateFromFile with the created settings. |
CreateBlankSurface | Uses parameters to create a blank surface and optionally allows to fill the surface using a fuction pointer. |
int CreateFromFile( IMAGE_OPTIONS_PTR Options, DWORD RSrc_Flags )
Uses provided options to create an object. Runs Initialize for the object and puts the resource into RSRC::RSRC_STATE_INIT if there are no errors
Options | <IMAGE_OPTIONS_PTR> Describes how to load the file |
RSrc_Flags | DWORD Describes how to load the file into memory |
False if successful, error code otherwise
int CreateFromFile( char * filename, DWORD RSrc_Flags )
Uses the filename to create a generalized IMAGE_OPTIONS_TYP and runs CreateFromFile with the created settings.
filename | CHAR* Null terminated filename to load into an object. Settings are completely determined by default assumptions and file settings |
RSrc_Flags | DWORD Describes how to load the file into memory |
False if successful, error code otherwise.
int CreateBlankSurface( LPRECT rcSize, DWORD RSrc_Flags, int (*Reset_Func)(RSRC_LOCKINFO_PTR LockInfo) = NULL, int AlphaEnabled = true, int NewBpp = 0 )
Uses parameters to create a blank surface and optionally allows to fill the surface using a fuction pointer. Will run objects initialize and put the resource into RSRC::RSRC_STATE_INIT.
rcSize | LPRECT The size of the surface to create |
RSrc_flags | DWORD Where to put it in memory |
Reset_Func | *(Reset_Func)(RSRC::RSRC_LOCKINFO_PTR LockInfo) Defaults to NULL. Ran each time the surface needs to be redrawn. |
AlphaEnabled | INT Defaults to true. Determines if an alpha channel is needed on the surface or not |
NewBpp | INT Defaults to 0. Creates the surface in a different Bpp than the back buffer |
False if successful, error code otherwise.
class VertexBufferResource : public Resource
Inherits from Resource. Allow the creation of VertexBufferObjects. These are used to store vertices in D3D Mode. Currently implementation for the other interfaces in manual mode has not been completed.
|----------| |----------------------| | Resource |<-----| VertexBufferResource | |----------| |----------------------|
Creation Functions | |
Create | Creates a vertex buffer with the specified parameters |
int Create( int size, DWORD vertex_type, DWORD RSrc_Flags )
Creates a vertex buffer with the specified parameters
size | INT The number of vertices requested |
vertex_type | DWORD RSRC::VERTEX_TYPE_TYP that describes how the buffer should be setup |
RSrc_Flags | DWORD RSRC::RSRC_FLAG_TYP that decides how the object should be loaded into memory |
False if successful, error code otherwise.
Everything related to loading and mantaining a resource is in this namespace
namespace RSRC
Initializes the resource interfaces to use the specified mode
int Init( MODE_TYP Interface )
Shuts down the resource interface
void Shutdown()
Unloads all resources regardless of flags.
void CompleteUnload()
Unloads all resource that have RSRC_RESET set.
void ResetUnload()
Reloads all resources that have are in state RSRC_STATE_PENDING.
int Reload()
Our top level resource class.
class Resource
Used to describe how to open and load an image from disk.
typedef struct IMAGE_OPTIONS_TYP
Inherits from Resource.
class VertexBufferResource : public Resource
Structure used to create a VertexBufferResource
typedef struct VERTEX_OPTIONS_TYP
This structure is used to request and to process locks made on resources.
typedef struct RSRC_LOCKINFO_TYP
DWORD This is a RSRC::RSRC_FLAG_TYP
DWORD Flags
VOID* Points to the beginning of the memory block
void* pDest
INT The amount of bytes between “lines” in the Resource
int Pitch
INT Width of the Resource
int width
INT The amount of bytes between objects (ie.
int Stride
INT Size of the resource in number of strides
int Size
INT Wether the lock is valid or not
int Valid
INT Height of the resource.
int height
INT The bits per pxiel.
int bpp
DWORD RSRC::IMAGE_FLAGS_TYP that help setup options for loading the image
DWORD Image_Flags
char* Null terminated filename to load
char *pFilename
RECT Size of the image or surface to create
RECT LoadRect
DWORD Color for SrcKeying
DWORD SrcKeyColor
INT Specifies a different bpp to convert the image to
int Bpp
INT Specifies the mipmap level if MIPMAP flag is set (0 for maximum)
int numMipMaps
*(LoadFunc)(RSRC::RSRC_LOCKINFO_PTR) Pointer to a function to load data to.
int ( * LoadFunc )(RSRC_LOCKINFO_PTR)
INT The size of the vertex buffer
int Size
DWORD RSRC::VERTEX_TYPE_TYP used to descrive the vertex buffer
DWORD Vertex_Type
Our abstact geralized object class.
class Object
Creates an empty resource class.
Resource( ) : Flags(0), State(RSRC_STATE_CLEAN), Type(RSRC_TYPE_NONE), pObject(NULL)
Detaches itself with the Object.
virtual ~Resource()
The Object its attached to aquires any needed interfaces and loads the data into memory based on the initialization settings.
int AquireAndLoad()
Locks a resource and locks the objects mutex.
int Lock( RSRC_LOCKINFO_PTR LockInfo )
Unlocks a resource that was Lock’d.
void Unlock()
Unloads the Object the resource is pointing to from memory and releases it’s interfaces.
void UnloadAndRelease()
Detaches itself from the Object it was pointing to.
void Detach()
Tests the state of the Object and copies over all its state information into the resource.
RSRC_STATE_TYP TestState()
Gets the current flags of the resource.
DWORD getFlags()
Gets the current state of the resource.
RSRC_STATE_TYP getState()
Gets the current type of the object the resource is connected to.
RSRC_TYPE_TYP getType()
Allows access to creation of SurfaceResources and provides the neccessary functions to create SurfaceObjects of various types.
class SurfaceResource : public Resource
Uses provided options to create an object.
int CreateFromFile( IMAGE_OPTIONS_PTR Options, DWORD RSrc_Flags )
Uses parameters to create a blank surface and optionally allows to fill the surface using a fuction pointer.
int CreateBlankSurface( LPRECT rcSize, DWORD RSrc_Flags, int (*Reset_Func)(RSRC_LOCKINFO_PTR LockInfo) = NULL, int AlphaEnabled = true, int NewBpp = 0 )
Creates a vertex buffer with the specified parameters
int Create( int size, DWORD vertex_type, DWORD RSrc_Flags )
This is the main interface into Direct3D.
class D3DInterface
Controls DirectDraw and provides a common interface to all of its functions.
class DDrawInterface
Provides an interface to startup and shutdown the GDI+ Interface
class GDIInterface