CRM32Pro SDK  v5.22
List of all members | Classes | Public Member Functions | Public Attributes

CRM32Pro. More...

Detailed Description

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. More...
 
void CleanUp (void)
 Clean up update system to avoid events and timing propagation. More...
 
int ConAddCmdHandler (char *cmdname, char *cmdhelp, int(*my_func)(vector< string > *))
 Add a new command handler to the console. More...
 
void ConCmd (char *)
 Send the given command to the console. More...
 
void ConDisable ()
 Disable the console.
 
void ConEnable ()
 Enable the console.
 
int ConFeatures (int features=-1)
 Set/Get advance feature flags for the console system. More...
 
Uint8 ConGetAlpha ()
 Get the alpha value of the console. More...
 
Uint32 ConGetBgColor ()
 Get the background color of the console. More...
 
SDL_Surface * ConGetBgImage ()
 Get the background image of the console. More...
 
CRM32Pro_CFontConGetFont ()
 Get the font of the console. More...
 
SDL_Rect * ConGetRect ()
 Get the console rect. More...
 
Uint8 ConisEnabled ()
 Check if the console is enabled. More...
 
Sint8 ConisVisible ()
 Check if the console is visible. More...
 
void ConMove (Sint16 x, Sint16 y)
 Move the console. More...
 
void ConNewCmdLine ()
 Output a CR/LF into the console.
 
void ConPrint (char *format,...)
 Output a message into the console. More...
 
void ConResize (Sint16 w, Sint16 h)
 Resize the console. More...
 
void ConSetAlpha (Uint8 alpha)
 Set the alpha value for the console. More...
 
void ConSetBgColor (Uint8 red, Uint8 green, Uint8 blue)
 Set the background color of the console. More...
 
void ConSetBgColor (Uint32 rgb)
 Set the background color of the console. More...
 
void ConSetBgImage (char *fileDPF, char *name)
 Set the background image for the console. More...
 
void ConSetBgImage (int idDPF, char *name)
 Set the background image for the console. More...
 
void ConSetFont (char *fileDPF, char *name)
 Set the font for the console. More...
 
void ConSetFont (int idDPF, char *name)
 Set the font for the console. More...
 
void ConSetVisible (Sint8 value)
 Set the visibility of the console. More...
 
void ConTitle (char *)
 Set the console title. More...
 
void ConvPrint (char *format, va_list args)
 Output a message into the console. More...
 
unsigned int CRC32 (char *buffer, int Size)
 Calculate CRC32 of given buffer with given size. More...
 
unsigned int CRC32 (char *filename)
 Calculate CRC32 of given file. More...
 
int DwAddWatch (char *name, int *integervar, double *doublevar=NULL)
 Add a new var watch to the debug window. More...
 
void DwDisable ()
 Disable the debug window.
 
void DwEnable ()
 Enable the debug window.
 
Uint8 DwGetAlpha ()
 Get the alpha value of the debug window. More...
 
Uint32 DwGetBgColor ()
 Get the background color of the debug window. More...
 
SDL_Surface * DwGetBgImage ()
 Get the background image of the debug window. More...
 
CRM32Pro_CFontDwGetFont ()
 Get the font of the debug window. More...
 
SDL_Rect * DwGetRect ()
 Get the debug window rect. More...
 
Uint8 DwisEnabled ()
 Check if the debug window is enabled. More...
 
Sint8 DwisVisible ()
 Check if the debug window is visible. More...
 
void DwMove (Sint16 x, Sint16 y)
 Move the debug window. More...
 
int DwRemoveWatch (char *name)
 Remove a watch from the debug window. More...
 
void DwResize (Sint16 w, Sint16 h)
 Resize the debug window. More...
 
void DwSetAlpha (Uint8 alpha)
 Set the alpha value for the debug window. More...
 
void DwSetBgColor (Uint8 red, Uint8 green, Uint8 blue)
 Set the background color of the debug window. More...
 
void DwSetBgColor (Uint32 rgb)
 Set the background color of the debug window. More...
 
void DwSetBgImage (char *fileDPF, char *name)
 Set the background image for the debug window. More...
 
void DwSetBgImage (int idDPF, char *name)
 Set the background image for the debug window. More...
 
void DwSetFont (char *fileDPF, char *name)
 Set the font for the debug window. More...
 
void DwSetFont (int idDPF, char *name)
 Set the font for the debug window. More...
 
void DwSetVisible (Sint8 value)
 Set the visibility of the debug window. More...
 
void DwTitle (char *)
 Set the debug window title. More...
 
void FreeSurface (SDL_Surface *&)
 Frees a SDL_Surface. More...
 
char * GetCopyright ()
 Get copyright string.
 
char * GetKeyName (int iKey)
 Return the name of the pressed key using a single character. More...
 
int GetKeyPressed (int iDelay=SDL_DEFAULT_REPEAT_DELAY)
 Return the first pressed key found. More...
 
int GetKeystate (int keysym)
 Get current state of the given key. More...
 
float GetLogicTime ()
 Get current logic time. More...
 
char * GetVersion ()
 Get version string.
 
int Init (unsigned int flags)
 Initialize all internal systems. More...
 
int IsGL ()
 Check if glSDL is enabled and running. More...
 
int IsRenderNeeded ()
 Query to the engine if a full render is needed on the client side. More...
 
int IsTexture (SDL_Surface *surf)
 Check if the given surface is an OpenGL texture. More...
 
int LoadConfig (char *fileDPF, char *fileXML, sConfig *conf=NULL)
 Load the config stored on given XML. More...
 
int MakeDirectory (char *fullpath)
 Create a directory. More...
 
void PrintVersion ()
 Print version and compiled date to log system(ILogSystem)
 
void Quit (void)
 Close all internal systems. More...
 
Uint32 Rand ()
 Generates a random 32bits integer. More...
 
double RandReal ()
 Generates a random 64bits real number. More...
 
void RandSeed (unsigned int seed)
 Initializes random number generator with a seed. More...
 
void RenderNeeded (int bMode=UPDATEFRAME_NEXT)
 Change the way the render engine works. More...
 
int RequireVersion (int iMajor, int iMinor)
 Check given version against library version. More...
 
int SaveConfig (char *fileDPF, char *fileXML, sConfig *conf=NULL)
 Save the given config to a DPF/XML. More...
 
void SetRenderCallback (void(*myRenderFunc)(int bLogicUpdate))
 Set a callback function to blit your graphics at Rendering Frame Rate. More...
 
int SetVideoMode (void)
 Setup selected video mode given by Config struct. More...
 
int Surface2Texture (SDL_Surface *surf)
 Convert a surface into a texture. For OpenGL modes (glSDL). More...
 
int SurfaceAutomaticConversion (int)
 Manage surface automatic conversion of all CRM32Pro subsystems. More...
 
void SurfaceInfo (SDL_Surface *surface)
 Uses ILogSystem to dump surface information. More...
 
int Update (SDL_Event *ev=NULL)
 Update all systems: graphics,events,timing... More...
 
void VideoInfo ()
 Uses ILogSystem to dump video subsystem information.
 
int XMLAttributeGet (int id, char *name, char **value)
 Get the string value of the given attribute. More...
 
int XMLAttributeGet (int id, char *name, int *value)
 Get the integer value of the given attribute. More...
 
int XMLAttributeGet (int id, char *name, double *value)
 Get the double value of the given attribute. More...
 
int XMLAttributeRemove (int id, char *name)
 Remove an attribute. More...
 
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. More...
 
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. More...
 
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. More...
 
void XMLClose (int id)
 Close a given XML. More...
 
char * XMLCommentGet (int id)
 Return the first comment of current node(if any) More...
 
int XMLCommentRemove (int id)
 Remove the first comment contained on current node. More...
 
int XMLCommentSet (int id, char *value)
 Add a new comment to current node. More...
 
int XMLCreate (char *mainnode)
 Create a new XML document. More...
 
int XMLNodeChild (int id)
 Point to the first child node of the XML. More...
 
int XMLNodeCreate (int id, char *name)
 Create a new node on current pointer and set it as new current. More...
 
int XMLNodeFirst (int id)
 Point to the first node of the XML (the root node). More...
 
char * XMLNodeGetName (int id)
 Get the name of current node. More...
 
int XMLNodeNext (int id)
 Point to the next node of the XML. More...
 
int XMLNodeParent (int id)
 Point to the parent node of the XML. More...
 
int XMLNodePointTo (int id, int nparam, char *,...)
 Search and point to a given node or subnode of any level. More...
 
int XMLNodePrev (int id)
 Point to the previous node of the XML. More...
 
int XMLNodeRemove (int id)
 Remove current node pointed to and all its nodes and attributes. More...
 
int XMLNodeRename (int id, char *name)
 Rename current node pointed to. More...
 
int XMLNodeRestore (int id)
 Restore previously stored node pointer position. More...
 
int XMLNodeStore (int id)
 Store internally current node pointer position. More...
 
int XMLOpen (char *filename)
 Open a XML file. More...
 
int XMLOpen (char *fileDPF, char *blockname)
 Open a XML file stored on a DPF(using filename) More...
 
int XMLOpen (int idDPF, char *blockname)
 Open a XML file stored on a DPF(idDPF) More...
 
int XMLSave (int id, char *filename)
 Save a given XML to external file. More...
 
int XMLSave (int id, char *fileDPF, char *blockname)
 Save a given XML to a DPF(using filename) More...
 
int XMLSave (int id, int idDPF, char *blockname)
 Save a given XML to a DPF(using idDPF) More...
 
char * XMLTextGet (int id)
 Return text contained on current node. More...
 
int XMLTextRemove (int id)
 Remove text contained on current node. More...
 
int XMLTextSet (int id, char *value)
 Add a new text to the existing text node(if any). More...
 

Public Attributes

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.
 

Member Function Documentation

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.

Parameters
srcsource surface.
srcrectpointer to source rect or NULL to copy the entire surface.
dstdestination surface.
dstrectpointer to destination rect or NULL to copy at (0,0).
Returns
0 Error
Other values mean OK. See SDL_BlitSurface() return values to extend info.
Examples:
Example01_BasicCode.cpp, Example03_GUI.cpp, Example12_DRTS.cpp, and SpacePong.cpp.
void CRM32Pro_Main::CleanUp ( void  )

Clean up update system to avoid events and timing propagation.

A good habit is to call it after SetRenderCallback() method and before to enter the loop where CRM32Pro.Update() is called

Examples:
SpacePong.cpp.
int CRM32Pro_Main::ConAddCmdHandler ( char *  cmdname,
char *  cmdhelp,
int(*)(vector< string > *)  my_func 
)

Add a new command handler to the console.

Parameters
cmdnameCommand name
cmdhelpCommand help or brief description
my_funcPointer to your handler. It must accept a pointer to a vector<string> where the parameters will be allocated. It must return 1 if the parameters were Ok, otherwise it must return 0.
Returns
0 Command handler was not added to the console
1 Command handler successfully added
Examples:
Example12_DRTS.cpp.
void CRM32Pro_Main::ConCmd ( char *  scmd)

Send the given command to the console.

If the command exists, it will be processed as it was written in the console

Parameters
scmdCommand with optional parameters to be processed
int CRM32Pro_Main::ConFeatures ( int  newfeatures = -1)

Set/Get advance feature flags for the console system.

Check CONFEATURE_x defines to know which features are currently supported.
To avoid to modify any current flag and just get the current ones, use the value of -1 (default value)

Parameters
newfeaturesInteger with desired flags enabled. It performs a XOR so trying to enable an already enabled flag will disable it.
Returns
Integer with current features
Uint8 CRM32Pro_Main::ConGetAlpha ( )

Get the alpha value of the console.

Returns
Uint8 ranging from 64 (almost-transparent) to 255 (full-opaque)
Examples:
Example12_DRTS.cpp.
Uint32 CRM32Pro_Main::ConGetBgColor ( )

Get the background color of the console.

Returns
Uint32 with the red,green and blue components
SDL_Surface * CRM32Pro_Main::ConGetBgImage ( )

Get the background image of the console.

Returns
NULL no console present
SDL_Surface pointer with the background
CRM32Pro_CFont * CRM32Pro_Main::ConGetFont ( )

Get the font of the console.

Returns
NULL No font assigned
CRM32Pro_CFont pointer to the font
SDL_Rect * CRM32Pro_Main::ConGetRect ( )

Get the console rect.

Returns
NULL No console present
SDL_Rect pointer to the rect
Uint8 CRM32Pro_Main::ConisEnabled ( )

Check if the console is enabled.

Returns
0 Disabled
1 Enabled
Sint8 CRM32Pro_Main::ConisVisible ( )

Check if the console is visible.

Returns
0 Hidden
1 Visible
void CRM32Pro_Main::ConMove ( Sint16  x,
Sint16  y 
)

Move the console.

Parameters
xnew x position on screen
ynew y position on screen
void CRM32Pro_Main::ConPrint ( char *  format,
  ... 
)

Output a message into the console.

Parameters
formatformat parameter as printf function
Examples:
Example12_DRTS.cpp.
void CRM32Pro_Main::ConResize ( Sint16  w,
Sint16  h 
)

Resize the console.

Parameters
wwidth of the console. Minimum of 150
hheight of the console. Minimum of 100
void CRM32Pro_Main::ConSetAlpha ( Uint8  alpha)

Set the alpha value for the console.

Parameters
alphaa value ranging from 64 (almost-transparent) to 255 (full-opaque)
void CRM32Pro_Main::ConSetBgColor ( Uint8  red,
Uint8  green,
Uint8  blue 
)

Set the background color of the console.

Parameters
redRed component value(0-255)
greenGreen component value(0-255)
blueBlue component value(0-255)
void CRM32Pro_Main::ConSetBgColor ( Uint32  rgb)

Set the background color of the console.

Parameters
rgbUin32 with the red,green and blue components
void CRM32Pro_Main::ConSetBgImage ( char *  fileDPF,
char *  name 
)

Set the background image for the console.

Parameters
fileDPFDPF filename that contains the image
namename of the image stored on the DPF
void CRM32Pro_Main::ConSetBgImage ( int  idDPF,
char *  name 
)

Set the background image for the console.

Parameters
idDPFvalid idDPF that contains the image
namename of the image stored on the DPF
void CRM32Pro_Main::ConSetFont ( char *  fileDPF,
char *  name 
)

Set the font for the console.

Parameters
fileDPFDPF filename that contains the font
namename of the font stored on the DPF
void CRM32Pro_Main::ConSetFont ( int  idDPF,
char *  name 
)

Set the font for the console.

Parameters
idDPFvalid idDPF that contains the font
namename of the font stored on the DPF
void CRM32Pro_Main::ConSetVisible ( Sint8  value)

Set the visibility of the console.

This will cause the rendering of the console. It must be enabled first.

Parameters
value0 hide the console or 1 to show it
void CRM32Pro_Main::ConTitle ( char *  title)

Set the console title.

In order to override the default title, call this method before ConEnable().

Parameters
titlepointer to the title string
Examples:
Example12_DRTS.cpp.
void CRM32Pro_Main::ConvPrint ( char *  format,
va_list  args 
)

Output a message into the console.

Parameters
formatpointer to string with format parameters. Same as printf() function
argspointer to the va_list. Same as vprintf() function
unsigned int CRM32Pro_Main::CRC32 ( char *  buffer,
int  size 
)

Calculate CRC32 of given buffer with given size.

Parameters
bufferpointer to buffer to calculate its CRC32
sizesize in bytes of given buffer
Returns
CRC32 of given buffer
unsigned int CRM32Pro_Main::CRC32 ( char *  fname)

Calculate CRC32 of given file.

Parameters
fnamepath and filename of the file to calculate its CRC32
Returns
CRC32 of given file
int CRM32Pro_Main::DwAddWatch ( char *  name,
int *  integervar,
double *  doublevar = NULL 
)

Add a new var watch to the debug window.

Parameters
nameA pointer to the name of the watch. It will works also as an identifier.
integervarA pointer to an integer var
doublevarA pointer to a double var
Returns
0 The watch was not added
1 The watch was added
Examples:
Example12_DRTS.cpp.
Uint8 CRM32Pro_Main::DwGetAlpha ( )

Get the alpha value of the debug window.

Returns
Uint8 ranging from 64 (almost-transparent) to 255 (full-opaque)
Uint32 CRM32Pro_Main::DwGetBgColor ( )

Get the background color of the debug window.

Returns
Uint32 with the red,green and blue components
SDL_Surface * CRM32Pro_Main::DwGetBgImage ( )

Get the background image of the debug window.

Returns
NULL no debug window present
SDL_Surface pointer with the background
CRM32Pro_CFont * CRM32Pro_Main::DwGetFont ( )

Get the font of the debug window.

Returns
NULL No font assigned
CRM32Pro_CFont pointer to the font
SDL_Rect * CRM32Pro_Main::DwGetRect ( )

Get the debug window rect.

Returns
NULL No debug window present
SDL_Rect pointer to the rect
Uint8 CRM32Pro_Main::DwisEnabled ( )

Check if the debug window is enabled.

Returns
0 Disabled
1 Enabled
Sint8 CRM32Pro_Main::DwisVisible ( )

Check if the debug window is visible.

Returns
0 Hidden
1 Visible
void CRM32Pro_Main::DwMove ( Sint16  x,
Sint16  y 
)

Move the debug window.

Parameters
xnew x position on screen
ynew y position on screen
int CRM32Pro_Main::DwRemoveWatch ( char *  name)

Remove a watch from the debug window.

Parameters
nameA pointer to the name of the watch.
Returns
0 The watch was not removed
1 The watch was removed
void CRM32Pro_Main::DwResize ( Sint16  w,
Sint16  h 
)

Resize the debug window.

Parameters
wwidth of the debug window. Minimum of 150
hheight of the debug window. Minimum of 150
void CRM32Pro_Main::DwSetAlpha ( Uint8  alpha)

Set the alpha value for the debug window.

Parameters
alphaa value ranging from 64 (almost-transparent) to 255 (full-opaque)
void CRM32Pro_Main::DwSetBgColor ( Uint8  red,
Uint8  green,
Uint8  blue 
)

Set the background color of the debug window.

Parameters
redRed component value(0-255)
greenGreen component value(0-255)
blueBlue component value(0-255)
void CRM32Pro_Main::DwSetBgColor ( Uint32  rgb)

Set the background color of the debug window.

Parameters
rgbUin32 with the red,green and blue components
void CRM32Pro_Main::DwSetBgImage ( char *  fileDPF,
char *  name 
)

Set the background image for the debug window.

Parameters
fileDPFDPF filename that contains the image
namename of the image stored on the DPF
void CRM32Pro_Main::DwSetBgImage ( int  idDPF,
char *  name 
)

Set the background image for the debug window.

Parameters
idDPFvalid idDPF that contains the image
namename of the image stored on the DPF
void CRM32Pro_Main::DwSetFont ( char *  fileDPF,
char *  name 
)

Set the font for the debug window.

Parameters
fileDPFDPF filename that contains the font
namename of the font stored on the DPF
void CRM32Pro_Main::DwSetFont ( int  idDPF,
char *  name 
)

Set the font for the debug window.

Parameters
idDPFvalid idDPF that contains the font
namename of the font stored on the DPF
void CRM32Pro_Main::DwSetVisible ( Sint8  value)

Set the visibility of the debug window.

This will cause the rendering of the debug window. It must be enabled first.

Parameters
value0 hide the debug window or 1 to show it
void CRM32Pro_Main::DwTitle ( char *  title)

Set the debug window title.

Parameters
titlepointer to the title string
Examples:
Example12_DRTS.cpp.
void CRM32Pro_Main::FreeSurface ( SDL_Surface *&  srf)

Frees a SDL_Surface.

Use it instead SDL_FreeSurface() to be informed of attempts to free a NULL surface.

Parameters
srfpointer to the surface to delete.
Examples:
Example01_BasicCode.cpp, Example03_GUI.cpp, Example08_SpriteCollision.cpp, Example09_LogicRenderRates.cpp, and Example12_DRTS.cpp.
char * CRM32Pro_Main::GetKeyName ( int  iKey)

Return the name of the pressed key using a single character.

It improves a bit the output of SDL_GetKeyName() taking into account special characters and capital letters
In order to get proper output of some symbols (%,{, |, } and ~), capital letters and numeric keypad, is better to use together with the output of GetKeyPressed()

Parameters
iKeyASCII code of a key
Returns
NULL there is not a possible translation (special keys as ENTER,CTRL or SHIFT?)
pointer to a single character
int CRM32Pro_Main::GetKeyPressed ( int  iDelay = SDL_DEFAULT_REPEAT_DELAY)

Return the first pressed key found.

This method is also updated internally by Update() following the same way as GetKeystate().
It converts a pressed key to a plain format: shift+number, shift+character and numeric keypad are converted to the ASCII code
If no conversion is needed, it return the normal SDLK_xxx symbol. It checks from SDLK_BACKSPACE to SDLK_F15,
basically all the available key symbols on SDL.

Parameters
iDelayminimum delay in milliseconds to specify how long a key must be pressed before it repeats again. By default it is SDL_DEFAULT_REPEAT_DELAY
Returns
0 No key pressed
ASCII code of the pressed key. Quite similar to SDLK_xxx symbol defined on SDL_keysym.h but with some changes
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 raw snapshot you can use this method.

Parameters
keysymDesired key to get its state. Use the SDLK_xxx symbols defined on SDL_keysym.h.
Returns
0 Key not pressed
1 Key pressed
Examples:
SpacePong.cpp.
float CRM32Pro_Main::GetLogicTime ( )

Get current logic time.

Internal setting.

int CRM32Pro_Main::Init ( unsigned int  flags)

Initialize all internal systems.

It replaces to SDL_Init() although internally it does a call to SDL_Init(flags)
Select optimized path depending on the CPU.

Examples:
Example01_BasicCode.cpp, Example03_GUI.cpp, Example05_VideoPlayer.cpp, Example08_SpriteCollision.cpp, Example09_LogicRenderRates.cpp, Example10_NetChat.cpp, Example11_NetChat2.cpp, Example12_DRTS.cpp, and SpacePong.cpp.
int CRM32Pro_Main::IsGL ( )

Check if glSDL is enabled and running.

Returns
0 glSDL disabled
1 glSDL enabled
Examples:
Example05_VideoPlayer.cpp, Example08_SpriteCollision.cpp, and Example09_LogicRenderRates.cpp.
int CRM32Pro_Main::IsRenderNeeded ( )

Query to the engine if a full render is needed on the client side.

Returns
0 No full render is needed
1 Full render is needed. It could be due to screen using a double buffer or an internal subsystem (console, debug window, buttons) that require a full redraw
Examples:
Example08_SpriteCollision.cpp, Example09_LogicRenderRates.cpp, Example12_DRTS.cpp, and SpacePong.cpp.
int CRM32Pro_Main::IsTexture ( SDL_Surface *  surf)

Check if the given surface is an OpenGL texture.

Parameters
surfSurface to be checked
Returns
0 standard surface
1 OpenGL texture surface (glSDL)
int CRM32Pro_Main::LoadConfig ( char *  fileDPF,
char *  fileXML,
sConfig conf = NULL 
)

Load the config stored on given XML.

Parameters
fileDPFDPF with the stored XML. NULL if it is not stored on a DPF(it is an external XML file). Supports optional paths.
fileXMLExternal XML file name or name of the XML inside the DPF. Supports optional paths with the config settings.
confPointer to sConfig struct to store the settings. By default it is pointed to CRM32Pro.Config.
Returns
0 Failed
1 Ok
Examples:
SpacePong.cpp.
int CRM32Pro_Main::MakeDirectory ( char *  fullpath)

Create a directory.

It extract the path discarding the filename and extension.
Supports subdirectories using '\' or '/' as separators.

Parameters
fullpath
Returns
0 Failed
1 Created or already existing
void CRM32Pro_Main::Quit ( void  )
Uint32 CRM32Pro_Main::Rand ( )

Generates a random 32bits integer.

Returns
random integer from [0,4294967295] interval
double CRM32Pro_Main::RandReal ( )

Generates a random 64bits real number.

Returns
random real from [0,1] interval
void CRM32Pro_Main::RandSeed ( unsigned int  seed)

Initializes random number generator with a seed.

Parameters
seedany unsigned integer from [0,4294967295] interval
void CRM32Pro_Main::RenderNeeded ( int  bMode = UPDATEFRAME_NEXT)

Change the way the render engine works.

Note that if the screen has SDL_DOUBLEBUFFER feature enabled, the render mode will be fixed to UPDATEFRAME_ALWAYS

Parameters
bModeUPDATEFRAME_NONE Disable previous mode and avoid to render next frame
bModeUPDATEFRAME_NEXT Enable the render of the next frame
bModeUPDATEFRAME_ALWAYS Disable previous mode and enable full render on all frames
Examples:
Example01_BasicCode.cpp, Example03_GUI.cpp, Example08_SpriteCollision.cpp, Example09_LogicRenderRates.cpp, and SpacePong.cpp.
int CRM32Pro_Main::RequireVersion ( int  iMajor,
int  iMinor 
)

Check given version against library version.

Parameters
iMajorrequired major version
iMinorrequired minor version
Returns
0 Library version is lesser than requested
1 Library version is equal or greater than requested
int CRM32Pro_Main::SaveConfig ( char *  fileDPF,
char *  fileXML,
sConfig conf = NULL 
)

Save the given config to a DPF/XML.

Parameters
fileDPFDPF filename to store the XML. NULL if it will store on an external XML file. Supports optional paths.
fileXMLExternal XML file name or name of the XML to be stored on a DPF. Supports optional paths with the config settings.
confPointer to sConfig struct to read its settings. By default it is pointed to CRM32Pro.Config.
Returns
0 Failed
1 Ok
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.

Parameters
myRenderFuncpointer to your graphics blitting function. bLogicUpdate will be 1 after a logic update.
Examples:
Example08_SpriteCollision.cpp, Example09_LogicRenderRates.cpp, Example12_DRTS.cpp, and SpacePong.cpp.
int CRM32Pro_Main::SetVideoMode ( void  )

Setup selected video mode given by Config struct.

It tries to assign an icon and a title (the icon surface will be internally removed).
In addition, it creates the Integrated Console and the Debug Window objects.
If CRM32Pro.screen is already present, before to set it again, it removes previous screen if the new set worked.
It replaces to SDL_SetVideoMode() function.

Returns
0 Error
1 OK and CRM32Pro.screen ready to use.
Examples:
Example01_BasicCode.cpp, Example03_GUI.cpp, Example05_VideoPlayer.cpp, Example08_SpriteCollision.cpp, Example09_LogicRenderRates.cpp, Example12_DRTS.cpp, and SpacePong.cpp.
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() is needed.

Parameters
surfSurface to be converted to a texture
Returns
0 No glSDL mode
1 Surface converted successfully
int CRM32Pro_Main::SurfaceAutomaticConversion ( int  iMode)

Manage surface automatic conversion of all CRM32Pro subsystems.

By default, it should be always enabled but in same specific cases (working with SDL_SWSURFACE), could be useful to disable it but do not forget to enable it as soon as you did your task.
This is an important and internal setting and some subsystems may not work or crash if it is disabled.

Parameters
iMode0 for disabling it and 1 for enabling it
Returns
0 Failed
1 Succeed
void CRM32Pro_Main::SurfaceInfo ( SDL_Surface *  surface)

Uses ILogSystem to dump surface information.

Parameters
surfacesurface 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 }

Parameters
evpointer to SDL_Event struct, by default is NULL.
Returns
1 if there is a pending event
0 if there is not a pending event.
Examples:
Example01_BasicCode.cpp, Example03_GUI.cpp, Example08_SpriteCollision.cpp, Example09_LogicRenderRates.cpp, Example12_DRTS.cpp, and SpacePong.cpp.
int CRM32Pro_Main::XMLAttributeGet ( int  id,
char *  name,
char **  value 
)

Get the string value of the given attribute.

Parameters
idID of the XML
namename of attribute
valuepointer to string to get the value. Null if does not exist.
Returns
0 Failed
1 Ok
int CRM32Pro_Main::XMLAttributeGet ( int  id,
char *  name,
int *  value 
)

Get the integer value of the given attribute.

Parameters
idID of the XML
namename of attribute
valuepointer to int to get the value. Null if does not exist.
Returns
0 Failed
1 Ok
int CRM32Pro_Main::XMLAttributeGet ( int  id,
char *  name,
double *  value 
)

Get the double value of the given attribute.

Parameters
idID of the XML
namename of attribute
valuepointer to double to get the value. Null if does not exist.
Returns
0 Failed
1 Ok
int CRM32Pro_Main::XMLAttributeRemove ( int  id,
char *  name 
)

Remove an attribute.

Parameters
idID of the XML
namename of attribute
Returns
0 Failed
1 Ok
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.

Parameters
idID of the XML
namename of attribute
valuenew string value of given attribute
Returns
0 Failed
1 Ok
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.

Parameters
idID of the XML
namename of attribute
valuenew integer value of given attribute
Returns
0 Failed
1 Ok
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.

Parameters
idID of the XML
namename of attribute
valuenew double value of given attribute
Returns
0 Failed
1 Ok
void CRM32Pro_Main::XMLClose ( int  id)

Close a given XML.

Parameters
idID of the XML
char * CRM32Pro_Main::XMLCommentGet ( int  id)

Return the first comment of current node(if any)

Parameters
idID of the XML
Returns
pointer to the comment or null if there is not any.
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.

Parameters
idID of the XML
Returns
0 Failed
1 Ok
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.

Parameters
idID of the XML
valuestring with desired comment
Returns
0 Failed
1 Ok
int CRM32Pro_Main::XMLCreate ( char *  mainnode)

Create a new XML document.

Parameters
mainnodestring with the name of the main node
Returns
0 Error
any other value, the ID of the created XML
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.

Parameters
idID of the XML
Returns
0 Failed
1 OK
int CRM32Pro_Main::XMLNodeCreate ( int  id,
char *  name 
)

Create a new node on current pointer and set it as new current.

Parameters
idID of the XML
namestring with the name
Returns
0 Failed
1 Ok
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.

Parameters
idID of the XML
Returns
0 Failed
1 OK
char * CRM32Pro_Main::XMLNodeGetName ( int  id)

Get the name of current node.

Parameters
idID of the XML
Returns
name or null if there is not node selected.
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.

Parameters
idID of the XML
Returns
0 Failed
1 OK
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.

Parameters
idID of the XML
Returns
0 Failed
1 OK
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.

Parameters
idID of the XML
deepnumber of parameters of 'element' given
elementvariable number of node/subnode
Returns
0 Failed
1 OK
int CRM32Pro_Main::XMLNodePrev ( int  id)

Point to the previous node of the XML.

It only changes the pointer if it can found a valid node.

Parameters
idID of the XML
Returns
0 Failed
1 OK
int CRM32Pro_Main::XMLNodeRemove ( int  id)

Remove current node pointed to and all its nodes and attributes.

Parameters
idID of the XML
Returns
0 Failed
1 Ok
int CRM32Pro_Main::XMLNodeRename ( int  id,
char *  name 
)

Rename current node pointed to.

Parameters
idID of the XML
namestring with the new name
Returns
0 Failed
1 Ok
int CRM32Pro_Main::XMLNodeRestore ( int  id)

Restore previously stored node pointer position.

There is only one slot per each XML

Parameters
idID of the XML
Returns
0 Failed
1 OK
int CRM32Pro_Main::XMLNodeStore ( int  id)

Store internally current node pointer position.

There is only one slot per each XML so it only keeps the node pointer of the last time we call this method

Parameters
idID of the XML
Returns
0 Failed
1 OK
int CRM32Pro_Main::XMLOpen ( char *  filename)

Open a XML file.

Parameters
filenamename of XML file
Returns
0 Error
any other value, the ID of the opened 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.

Parameters
fileDPFname of DPF file that contains to the XML
namename of the stored XML
Returns
0 Error
any other value, the ID of the opened XML
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.

Parameters
idDPFID of the opened DPF
namename of the stored XML
Returns
0 Error
any other value, the ID of the opened XML
int CRM32Pro_Main::XMLSave ( int  id,
char *  filename 
)

Save a given XML to external file.

Parameters
idID of the XML
filenamename of file to store the XML
Returns
0 Error
1 File saved successfully
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.

Parameters
idID of the XML
fileDPFname of DPF to store the XML
blocknamename of the block to store the XML, ideally, it could terminate with .xml
Returns
-1 XML already exists.
0 Failed.
any other positive value, Ok and packed size of the added XML
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.

Parameters
idID of the XML
idDPFID of the opened DPF
blocknamename of the block to store the XML, ideally, it could terminate with .xml
Returns
-1 XML already exists.
0 Failed.
any other positive value, Ok and packed size of the added 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>

Parameters
idID of the XML
Returns
pointer to text or null if there is not text.
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>

Parameters
idID of the XML
Returns
0 Failed
1 Ok
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>

Parameters
idID of the XML
valuestring with desired text
Returns
0 Failed
1 Ok

The documentation for this class was generated from the following files: