//
// Irrlicht Wrapper for Imperative Languages
// Frank Dodd (2006)
//
// Additional Work
// Michael Taupitz (2006)
//
// This wrapper DLL encapsulates a sub-set of the features of the powerful
// Irrlicht 3D Graphics Engine exposing the Object Oriented architecture and
// providing a functional 3D SDK for languages that are not object oriented.
//
// This source was created with the help of the great examples in the Irrlicht
// SDK and the excellent Irrlicht documentation. This software was developed
// using the GCC compiler and Code::Blocks IDE
//

/* ////////////////////////////////////////////////////////////////////////////
includes
*/
#include "irrlichtwrapper.h"


/* ////////////////////////////////////////////////////////////////////////////
global variables
*/

/* ////////////////////////////////////////////////////////////////////////////
external variables
*/
extern IrrlichtDevice *device;
extern IVideoDriver* driver;
extern ISceneManager* smgr;
extern IGUIEnvironment* guienv;


/* ////////////////////////////////////////////////////////////////////////////
Global Function Declarations

all of the below functions are declared as C functions and are exposed without
any mangled names so that they can be easily imported into imperative
languages like FreeBasic
*/
extern "C"
{
// Function to Wrap the VideoModes.....

/****f* Irrlicht/IrrGetDesktopDepth
* NAME
*    IrrGetDesktopDepth - Return the Desktop-Depth
* SYNOPSIS
*    result.l = IrrGetDesktopDepth()
* INPUTS
* FUNCTION
*   Returns the pixel depth of a video mode in bits.
* RESULT
*    depth of a video mode in bits.
****
* This is for creating the PB-Importfile, and avoiding to make everything manual
#PBIMPORT:IrrGetDesktopDepth()
*/
STATIC_EXPORT s32 DLL_EXPORT IrrGetDesktopDepth()
{
    return device->getVideoModeList()->getDesktopDepth();
}

/****f* Irrlicht/IrrGetDesktopResolution
* NAME
*    IrrGetDesktopResolution - Return the Desktop-Resolution
* SYNOPSIS
*    IrrGetDesktopResolution(*resol.IRR_DIM2D)
* INPUTS
*   *resol.IRR_DIM2D    - pointer to a IRR_DIM2D-Structure.
* FUNCTION
*   Returns size of screen in pixels of the current desktop video mode
* EXAMPLE
*   IrrGetDesktopResolution(@myRes.IRR_DIM2D)
*   Debug("Screen-Resolution:"+Str(myRes\width)+" x "+Str(myRes\height) )
* RESULT
*    size of screen in pixels.
****
* This is for creating the PB-Importfile, and avoiding to make everything manual
#PBIMPORT:IrrGetDesktopResolution(*resol.IRR_DIM2D)
*/
STATIC_EXPORT void DLL_EXPORT IrrGetDesktopResolution(IRR_DIM2D* resol)
{
    dimension2d<s32> r = device->getVideoModeList()->getDesktopResolution ();
    resol->width = r.Width;
    resol->height = r.Height;
}

/****f* Irrlicht/IrrGetVideoModeCount
* NAME
*    IrrGetVideoModeCount - Returns amount of video modes.
* SYNOPSIS
*    result.l = IrrGetVideoModeCount()
* INPUTS
* FUNCTION
*   Returns amount of video modes.
* EXAMPLE
*   videoModes.l = IrrGetVideoModeCount()
* RESULT
*   amount of video modes. .
****
* This is for creating the PB-Importfile, and avoiding to make everything manual
#PBIMPORT:IrrGetVideoModeCount()
*/
STATIC_EXPORT s32 DLL_EXPORT IrrGetVideoModeCount()
{
    return device->getVideoModeList()->getVideoModeCount();
}

/****f* Irrlicht/IrrGetVideoModeDepth
* NAME
*    IrrGetVideoModeDepth - Returns the depth of a video mode.
* SYNOPSIS
*    result.l = IrrGetVideoModeDepth(mode.l)
* INPUTS
*   mode.l  - number of the mode. Use IrrGetVideoModeCount() to get the count of available modes.
* FUNCTION
*   Returns the depth of a video mode
* EXAMPLE
*   videoModeDepth.l = IrrGetVideoModeDepth(mode)
* RESULT
*   depth of a video mode.
****
* This is for creating the PB-Importfile, and avoiding to make everything manual
#PBIMPORT:IrrGetVideoModeDepth(mode.l)
*/
STATIC_EXPORT s32 DLL_EXPORT IrrGetVideoModeDepth(s32 mode)
{
    return device->getVideoModeList()->getVideoModeDepth(mode);
}

/****f* Irrlicht/IrrGetVideoModeResolution
* NAME
*    IrrGetVideoModeResolution - Returns the depth of a video mode.
* SYNOPSIS
*    IrrGetVideoModeResolution(mode.l,*resolution.IDRR_DIM2D)
* INPUTS
*   mode.l                  - number of the mode. Use IrrGetVideoModeCount() to get the count of available modes.
*   *resolution.IRR_DIM2D   - pointer to a IRR_DIM2D-Structure.
* FUNCTION
*   Returns the Resolution of a video mode
* EXAMPLE
*   IrrGetVideoModeResolution(mode,@reso.IRR_DIM2D)
*   Debug("mode="+Str(mode)+" - Screen-Resolution:"+Str(reso\width)+" x "+Str(reso\height) )
* RESULT
*   Resolution of a video mode.
****
* This is for creating the PB-Importfile, and avoiding to make everything manual
#PBIMPORT:IrrGetVideoModeResolution(mode.l,*resolution.IRR_DIM2D)
*/
STATIC_EXPORT void DLL_EXPORT IrrGetVideoModeResolution(s32 mode, IRR_DIM2D* resol )
{
    dimension2d<s32> r = device->getVideoModeList()->getVideoModeResolution (mode);
    resol->width = r.Width;
    resol->height = r.Height;
}


/* ////////////////////////////////////////////////////////////////////////////
all of the above functions are declared as C functions and are exposed without
any mangled names
*/
}
