CRM32Pro. More...
CRM32Pro.
Main library interface.
Classes | |
| struct | sConfig |
| Main config struct. You can manually fill it or using CRM32Pro.LoadConfig() loading an external XML. More... | |
Public Member Functions | |
| void | AudioInfo () |
| Uses ILogSystem to dump audio subsystem information. | |
| int | Blit (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) |
| Perform a fast blit from source surface to the destination surface. | |
| void | CleanUp (void) |
| Clean up update systems to avoid events and timing propagation. | |
| unsigned int | CRC32 (char *filename) |
| Calculate CRC32 of given file. | |
| unsigned int | CRC32 (char *buffer, int Size) |
| Calculate CRC32 of given buffer with given size. | |
| void | FreeSurface (SDL_Surface *&) |
| Frees a SDL_Surface on a safe way. Use it instead SDL_FreeSurface() to avoid and to be aware of attempts to free a freed surface. | |
| char * | GetCopyright () |
| Get copyright string. | |
| int | GetKeystate (int keysym) |
| Get current state of the given key. | |
| float | GetLogicTime () |
| Get current logic time. | |
| char * | GetVersion () |
| Get version string. | |
| int | Init (unsigned int flags) |
| Initialize all internal systems and call to SDL_Init(flags) Select optimized path depending on the CPU. | |
| int | IsGL () |
| Check if glSDL is enabled and running. | |
| int | LoadConfig (char *fileDPF, char *fileXML, sConfig *conf=NULL) |
| Load the config stored on given XML. | |
| int | MakeDirectory (char *fullpath) |
| Create a directory. | |
| void | PrintVersion () |
| Print version and compiled date to log system(ILogSystem). | |
| void | Quit (void) |
| Close all internal systems and call to SDL_Quit(). | |
| Uint32 | Rand () |
| Generates a random 32bits integer. | |
| double | RandReal () |
| Generates a random 32bits real number. | |
| void | RandSeed (unsigned int seed) |
| Initializes random number generator with a seed. | |
| int | SaveConfig (char *fileDPF, char *fileXML, sConfig *conf=NULL) |
| Save the given config to a DPF/XML. | |
| void | SetRenderCallback (void(*myRenderFunc)(int bLogicUpdate)) |
| Set a callback function to blit your graphics at Rendering Frame Rate. | |
| int | SetVideoMode (void) |
| Setup selected video mode given by Config struct. It also try to assign an icon and a title. | |
| int | Surface2Texture (SDL_Surface *surf) |
| Convert a surface into a texture. For OpenGL modes (glSDL). | |
| void | SurfaceInfo (SDL_Surface *surface) |
| Uses ILogSystem to dump surface information. | |
| int | Update (SDL_Event *ev=NULL) |
| Update all systems: graphics,events,timing... | |
| void | VideoInfo () |
| Uses ILogSystem to dump video subsystem information. | |
| int | XMLAttributeGet (int id, char *name, double *value) |
| Get the double value of the given attribute. | |
| int | XMLAttributeGet (int id, char *name, int *value) |
| Get the integer value of the given attribute. | |
| int | XMLAttributeGet (int id, char *name, char **value) |
| Get the string value of the given attribute. | |
| int | XMLAttributeRemove (int id, char *name) |
| Remove an attribute. | |
| int | XMLAttributeSet (int id, char *name, double value) |
| Set a double value of a given attribute. If that attribute does not exist, a new one is created. | |
| int | XMLAttributeSet (int id, char *name, int value) |
| Set an integer value of a given attribute. If that attribute does not exist, a new one is created. | |
| int | XMLAttributeSet (int id, char *name, char *value) |
| Set a string value of a given attribute. If that attribute does not exist, a new one is created. | |
| void | XMLClose (int id) |
| Close a given XML. | |
| char * | XMLCommentGet (int id) |
| Return the first comment of current node(if any). | |
| int | XMLCommentRemove (int id) |
| Remove the first comment contained on current node. | |
| int | XMLCommentSet (int id, char *value) |
| Add a new comment to current node. | |
| int | XMLCreate (char *mainnode) |
| Create a new XML document. | |
| int | XMLNodeChild (int id) |
| Point to the first child node of the XML. | |
| int | XMLNodeCreate (int id, char *name) |
| Create a new node on current pointer and set it as new current. | |
| int | XMLNodeFirst (int id) |
| Point to the first node of the XML (the root node). | |
| char * | XMLNodeGetName (int id) |
| Get the name of current node. | |
| int | XMLNodeNext (int id) |
| Point to the next node of the XML. | |
| int | XMLNodeParent (int id) |
| Point to the parent node of the XML. | |
| int | XMLNodePointTo (int id, int nparam, char *,...) |
| Search and point to a given node or subnode of any level. | |
| int | XMLNodeRemove (int id) |
| Remove current node pointed to and all its nodes and attributes. | |
| int | XMLNodeRename (int id, char *name) |
| Rename current node pointed to. | |
| int | XMLOpen (int idDPF, char *blockname) |
| Open a XML file stored on a DPF(idDPF). | |
| int | XMLOpen (char *fileDPF, char *blockname) |
| Open a XML file stored on a DPF(using filename). | |
| int | XMLOpen (char *filename) |
| Open a XML file. | |
| int | XMLSave (int id, int idDPF, char *blockname) |
| Save a given XML to a DPF(using idDPF). | |
| int | XMLSave (int id, char *fileDPF, char *blockname) |
| Save a given XML to a DPF(using filename). | |
| int | XMLSave (int id, char *filename) |
| Save a given XML to external file. | |
| char * | XMLTextGet (int id) |
| Return text contained on current node. | |
| int | XMLTextRemove (int id) |
| Remove text contained on current node. | |
| int | XMLTextSet (int id, char *value) |
| Add a new text to the existing text node(if any). | |
Public Attributes | |
| struct CRM32Pro_Main::sConfig | Config |
| Main config struct. You can manually fill it or using CRM32Pro.LoadConfig() loading an external XML. | |
| Uint8 | iAutoSurfRecovery |
| Flag to set on/off auto surface recovery.It is automatically setup in DirectX hardware mode. | |
| Uint32 | iStartTime |
| Store the start ticks(SDL_GetTicks()) when CRM32Pro was initialized. | |
| Uint8 | mouse_buttons |
| Current state of mouse's buttons. Updated automatically in CRM32Pro.Update(). Used as a mask when testing mouse buttons, usually as follow: -Left mouse button (CRM32PRO_BUTTON_LEFT) -Middle mouse button (CRM32PRO_BUTTON_MIDDLE) -Right mouse button (CRM32PRO_BUTTON_RIGHT) It also stores buttons combinations. | |
| Uint8 | mouse_prevbuttons |
| Previous state of mouse's buttons. Updated automatically in CRM32Pro.Update(). | |
| int | mouse_x |
| Mouse X position. Updated automatically. | |
| int | mouse_y |
| Mouse Y position. Updated automatically. | |
| SDL_Surface * | screen |
| Main screen surface. You always have to use it to blit your graphics. | |
| int CRM32Pro_Main::Blit | ( | SDL_Surface * | src, | |
| SDL_Rect * | srcrect, | |||
| SDL_Surface * | dst, | |||
| SDL_Rect * | dstrect | |||
| ) |
Perform a fast blit from source surface to the destination surface.
It can be used instead of SDL_BlitSurface() when your destination surface is CRM32Pro.screen as it supports built-in cursor system.
| src | source surface. | |
| srcrect | pointer to source rect or NULL to copy the entire surface. | |
| dst | destination surface. | |
| dstrect | pointer to destination rect or NULL to copy at (0,0). |
| unsigned int CRM32Pro_Main::CRC32 | ( | char * | fname | ) |
Calculate CRC32 of given file.
| fname | path and filename of the file to calculate its CRC32 |
| unsigned int CRM32Pro_Main::CRC32 | ( | char * | buffer, | |
| int | size | |||
| ) |
Calculate CRC32 of given buffer with given size.
| buffer | pointer to buffer to calculate its CRC32 | |
| size | size in bytes of given buffer |
| void CRM32Pro_Main::FreeSurface | ( | SDL_Surface *& | srf | ) |
Frees a SDL_Surface on a safe way. Use it instead SDL_FreeSurface() to avoid and to be aware of attempts to free a freed surface.
| srf | pointer to surface to be deleted. |
| int CRM32Pro_Main::GetKeystate | ( | int | keysym | ) |
Get current state of the given key.
Update() will automatically get a snapshot of the current keyboard state, and to access to that snapshot you can use this method.
| keysym | Desired key to get its state. Use the SDLK_xxx symbols defined on SDL_keysym.h. |
| float CRM32Pro_Main::GetLogicTime | ( | ) |
Get current logic time.
Internal setting.
| int CRM32Pro_Main::IsGL | ( | ) |
Check if glSDL is enabled and running.
| int CRM32Pro_Main::LoadConfig | ( | char * | fileDPF, | |
| char * | fileXML, | |||
| sConfig * | conf = NULL | |||
| ) |
Load the config stored on given XML.
| fileDPF | DPF with the stored XML. NULL if it is not stored on a DPF(it is an external XML file). Supports optional paths. | |
| fileXML | External XML file name or name of the XML inside the DPF. Supports optional paths with the config settings. | |
| conf | Pointer to sConfig struct to store the settings. By default it is pointed to CRM32Pro.Config. |
| int CRM32Pro_Main::MakeDirectory | ( | char * | fullpath | ) |
Create a directory.
It extract the path discarding the filename and extension.
Supports subdirectories using '\' or '/' as separators.
| fullpath |
| Uint32 CRM32Pro_Main::Rand | ( | ) |
Generates a random 32bits integer.
| double CRM32Pro_Main::RandReal | ( | ) |
Generates a random 32bits real number.
| void CRM32Pro_Main::RandSeed | ( | unsigned int | seed | ) |
Initializes random number generator with a seed.
| seed | any unsigned integer from [0,4294967295] interval |
| int CRM32Pro_Main::SaveConfig | ( | char * | fileDPF, | |
| char * | fileXML, | |||
| sConfig * | conf = NULL | |||
| ) |
Save the given config to a DPF/XML.
| fileDPF | DPF filename to store the XML. NULL if it will store on an external XML file. Supports optional paths. | |
| fileXML | External XML file name or name of the XML to be stored on a DPF. Supports optional paths with the config settings. | |
| conf | Pointer to sConfig struct to read its settings. By default it is pointed to CRM32Pro.Config. |
| void CRM32Pro_Main::SetRenderCallback | ( | void(*)(int bLogicUpdate) | myRenderFunc | ) |
Set a callback function to blit your graphics at Rendering Frame Rate.
Use NULL if you want to remove a previous callback function.
Instead of use this callback,you can also call to your graphics blitting function from loop events when you get an EVENT_LOGICWAIT type.
But you will get the best results using a callback function.
| myRenderFunc | pointer to your graphics blitting function. bLogicUpdate will be 1 after a logic update. |
| int CRM32Pro_Main::SetVideoMode | ( | void | ) |
Setup selected video mode given by Config struct. It also try to assign an icon and a title.
Note that the icon surface used will be internally removed.
| int CRM32Pro_Main::Surface2Texture | ( | SDL_Surface * | surf | ) |
Convert a surface into a texture. For OpenGL modes (glSDL).
If an arbitrary surface is loaded using external methods to CRM32Pro or the colorkey is modified, a good practice is to convert it to a texture at the loading time. Before to call to this method, a call to SDL_DisplayFormat() it is needed.
| void CRM32Pro_Main::SurfaceInfo | ( | SDL_Surface * | surface | ) |
Uses ILogSystem to dump surface information.
| surface | surface to gather and print information |
| int CRM32Pro_Main::Update | ( | SDL_Event * | ev = NULL |
) |
Update all systems: graphics,events,timing...
It replaces to SDL_Flip() and SDL_PollEvent(). It updates cursor,buttons and all internal variables.
You can set Logical and Rendering frames rates using ITimeSystem. This method will delay the program execution to fit the Logical Frame Rate,
in addition, if you want to use the Rendering Frame Rate, you have to use SetRenderCallback() to set your graphics update function.
The right way to use in your code is:
- without events control: while(CRM32Pro.Update());
- with events control: while(CRM32Pro.Update(&event)) { your events handling code }
| ev | pointer to SDL_Event struct, by default is NULL. |
| int CRM32Pro_Main::XMLAttributeGet | ( | int | id, | |
| char * | name, | |||
| double * | value | |||
| ) |
Get the double value of the given attribute.
| id | ID of the XML | |
| name | name of attribute | |
| value | pointer to double to get the value. Null if does not exist. |
| int CRM32Pro_Main::XMLAttributeGet | ( | int | id, | |
| char * | name, | |||
| int * | value | |||
| ) |
Get the integer value of the given attribute.
| id | ID of the XML | |
| name | name of attribute | |
| value | pointer to int to get the value. Null if does not exist. |
| int CRM32Pro_Main::XMLAttributeGet | ( | int | id, | |
| char * | name, | |||
| char ** | value | |||
| ) |
Get the string value of the given attribute.
| id | ID of the XML | |
| name | name of attribute | |
| value | pointer to string to get the value. Null if does not exist. |
| int CRM32Pro_Main::XMLAttributeRemove | ( | int | id, | |
| char * | name | |||
| ) |
Remove an attribute.
| id | ID of the XML | |
| name | name of attribute |
| int CRM32Pro_Main::XMLAttributeSet | ( | int | id, | |
| char * | name, | |||
| double | value | |||
| ) |
Set a double value of a given attribute. If that attribute does not exist, a new one is created.
| id | ID of the XML | |
| name | name of attribute | |
| value | new double value of given attribute |
| int CRM32Pro_Main::XMLAttributeSet | ( | int | id, | |
| char * | name, | |||
| int | value | |||
| ) |
Set an integer value of a given attribute. If that attribute does not exist, a new one is created.
| id | ID of the XML | |
| name | name of attribute | |
| value | new integer value of given attribute |
| int CRM32Pro_Main::XMLAttributeSet | ( | int | id, | |
| char * | name, | |||
| char * | value | |||
| ) |
Set a string value of a given attribute. If that attribute does not exist, a new one is created.
| id | ID of the XML | |
| name | name of attribute | |
| value | new string value of given attribute |
| void CRM32Pro_Main::XMLClose | ( | int | id | ) |
Close a given XML.
| id | ID of the XML |
| char * CRM32Pro_Main::XMLCommentGet | ( | int | id | ) |
Return the first comment of current node(if any).
| id | ID of the XML |
| int CRM32Pro_Main::XMLCommentRemove | ( | int | id | ) |
Remove the first comment contained on current node.
If you want to remove all comments on a given node, call this method while you get 1 as returned value.
| id | ID of the XML |
| int CRM32Pro_Main::XMLCommentSet | ( | int | id, | |
| char * | value | |||
| ) |
Add a new comment to current node.
If a comment already exists, it will be pushed down and the new comment will be the first one.
| id | ID of the XML | |
| value | string with desired comment |
| int CRM32Pro_Main::XMLCreate | ( | char * | mainnode | ) |
Create a new XML document.
| mainnode | string with the name of the main node |
| int CRM32Pro_Main::XMLNodeChild | ( | int | id | ) |
Point to the first child node of the XML.
It only changes the pointer if it can found a valid node.
| id | ID of the XML |
| int CRM32Pro_Main::XMLNodeCreate | ( | int | id, | |
| char * | name | |||
| ) |
Create a new node on current pointer and set it as new current.
| id | ID of the XML | |
| name | string with the name |
| int CRM32Pro_Main::XMLNodeFirst | ( | int | id | ) |
Point to the first node of the XML (the root node).
It only changes the pointer if it can found a valid node.
| id | ID of the XML |
| char * CRM32Pro_Main::XMLNodeGetName | ( | int | id | ) |
Get the name of current node.
| id | ID of the XML |
| int CRM32Pro_Main::XMLNodeNext | ( | int | id | ) |
Point to the next node of the XML.
It only changes the pointer if it can found a valid node.
| id | ID of the XML |
| int CRM32Pro_Main::XMLNodeParent | ( | int | id | ) |
Point to the parent node of the XML.
It only changes the pointer if it can found a valid node.
| id | ID of the XML |
| int CRM32Pro_Main::XMLNodePointTo | ( | int | id, | |
| int | deep, | |||
| char * | element, | |||
| ... | ||||
| ) |
Search and point to a given node or subnode of any level.
It only changes the pointer when all element given point to valid node.
| id | ID of the XML | |
| deep | number of parameters of 'element' given | |
| element | variable number of node/subnode |
| int CRM32Pro_Main::XMLNodeRemove | ( | int | id | ) |
Remove current node pointed to and all its nodes and attributes.
| id | ID of the XML |
| int CRM32Pro_Main::XMLNodeRename | ( | int | id, | |
| char * | name | |||
| ) |
Rename current node pointed to.
| id | ID of the XML | |
| name | string with the new name |
| int CRM32Pro_Main::XMLOpen | ( | int | idDPF, | |
| char * | name | |||
| ) |
Open a XML file stored on a DPF(idDPF).
To open a XML from a DPF, CRM32Pro must be initialized.
| idDPF | ID of the opened DPF | |
| name | name of the stored XML |
| int CRM32Pro_Main::XMLOpen | ( | char * | fileDPF, | |
| char * | name | |||
| ) |
Open a XML file stored on a DPF(using filename).
To open a XML from a DPF, CRM32Pro must be initialized.
| fileDPF | name of DPF file that contains to the XML | |
| name | name of the stored XML |
| int CRM32Pro_Main::XMLOpen | ( | char * | filename | ) |
Open a XML file.
| filename | name of XML file |
| int CRM32Pro_Main::XMLSave | ( | int | id, | |
| int | idDPF, | |||
| char * | blockname | |||
| ) |
Save a given XML to a DPF(using idDPF).
To save a XML in to a DPF, CRM32Pro must be initialized.
If an XML already exists, it will be replaced with the new one.
| id | ID of the XML | |
| idDPF | ID of the opened DPF | |
| blockname | name of the block to store the XML, ideally, it could terminate with .xml |
| int CRM32Pro_Main::XMLSave | ( | int | id, | |
| char * | fileDPF, | |||
| char * | blockname | |||
| ) |
Save a given XML to a DPF(using filename).
To save a XML in to a DPF, CRM32Pro must be initialized.
If an XML already exists, it will be replaced with the new one.
| id | ID of the XML | |
| fileDPF | name of DPF to store the XML | |
| blockname | name of the block to store the XML, ideally, it could terminate with .xml |
| int CRM32Pro_Main::XMLSave | ( | int | id, | |
| char * | filename | |||
| ) |
Save a given XML to external file.
| id | ID of the XML | |
| filename | name of file to store the XML |
| char * CRM32Pro_Main::XMLTextGet | ( | int | id | ) |
Return text contained on current node.
Note that it only works in the first text block found:
<mynode>
Text1 -> First text block
Text2 -> First text block
Text3 -> First text block
<subnode>
Text1 of Subnode
</subnode>
Text4 -> This is a second text block due to exist after a subnode
Text5 -> This is a second text block due to exist after a subnode
</mynode>
| id | ID of the XML |
| int CRM32Pro_Main::XMLTextRemove | ( | int | id | ) |
Remove text contained on current node.
Note that it only works in the first text block found:
<mynode>
Text1 -> First text block
Text2 -> First text block
Text3 -> First text block
<subnode>
Text1 of Subnode
</subnode>
Text4 -> This is a second text block due to exist after a subnode
Text5 -> This is a second text block due to exist after a subnode
</mynode>
| id | ID of the XML |
| int CRM32Pro_Main::XMLTextSet | ( | int | id, | |
| char * | value | |||
| ) |
Add a new text to the existing text node(if any).
Note that it only works in the first text block found:
<mynode>
Text1 -> First text block
Text2 -> First text block
Text3 -> First text block
<subnode>
Text1 of Subnode
</subnode>
Text4 -> This is a second text block due to exist after a subnode
Text5 -> This is a second text block due to exist after a subnode
</mynode>
| id | ID of the XML | |
| value | string with desired text |
1.6.1