//
// Irrlicht Wrapper for Imperative Languages
// Frank Dodd (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
//

#ifdef BUILD_DLL
    #define DLL_EXPORT
    #define STATIC_EXPORT __declspec(dllexport)
#else
    #define DLL_EXPORT
    #define STATIC_EXPORT
#endif
/*
#ifdef STATIC_LIB
    #define STATIC_EXPORT static
#else
    #define STATIC_EXPORT

#endif
*/

#pragma comment(lib, "Irrlicht.lib")

/* ////////////////////////////////////////////////////////////////////////////
includes
*/
#ifndef IRRLICHTWRAPPER_H_INCLUDED
#define IRRLICHTWRAPPER_H_INCLUDED

#include <irrlicht.h>
#include <IMeshCache.h>
#include "Random.h"

namespace irr
{
//__declspec(dllimport) IrrlichtDevice* IRRCALLCONV createDevice(
extern IrrlichtDevice* IRRCALLCONV createDevice(
		video::E_DRIVER_TYPE deviceType,
		const core::dimension2d<s32>& windowSize,
		u32 bits,
		bool fullscreen ,
		bool stencilbuffer,
		bool vsync,
		IEventReceiver* receiver,
		const c8* sdk_version_do_not_use );

extern IrrlichtDevice* IRRCALLCONV createDeviceEx(
		const SIrrlichtCreationParameters& parameters);

	namespace os
	{
	}

}

/* ////////////////////////////////////////////////////////////////////////////
irrlicht namespaces
*/
using namespace irr;
using namespace os;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

/* ////////////////////////////////////////////////////////////////////////////
structure declarations
*/
#define MAX_ARCHIVED_EVENTS 256
typedef struct tag_ARCHIVED_MOUSE_EVENT
{
    unsigned int uiaction;
    f32 wheel;
    int ix;
    int iy;
}
ARCHIVED_MOUSE_EVENT;

typedef struct tag_ARCHIVED_KEY_EVENT
{
    unsigned int uikey;
    unsigned int uidirection;
    unsigned int uiflags;
}
ARCHIVED_KEY_EVENT;

typedef struct tag_ARCHIVED_GUI_EVENT
{
    gui::IGUIElement* Caller;
    gui::EGUI_EVENT_TYPE EventType;
    s32  ItemId;
}
ARCHIVED_GUI_EVENT;



typedef struct tag_IRR_PARTICLE_EMITTER
{
    float min_box_x;
    float min_box_y;
    float min_box_z;

    float max_box_x;
    float max_box_y;
    float max_box_z;

    float direction_x;
    float direction_y;
    float direction_z;

    unsigned int min_paritlcles_per_second;
    unsigned int max_paritlcles_per_second;

    int min_start_color_red;
    int min_start_color_green;
    int min_start_color_blue;

    int max_start_color_red;
    int max_start_color_green;
    int max_start_color_blue;

    unsigned int min_lifetime;
    unsigned int max_lifetime;

    int max_angle_degrees;
}
IRR_PARTICLE_EMITTER;

// a vertex used in creating custom static mesh objects
typedef struct tag_IRR_VERT
{
    float x;                // The x position of the vertex
    float y;                // The y position of the vertex
    float z;                // The z position of the vertex
    float normal_x;         // The x normal of the vertex
    float normal_y;         // The y normal of the vertex
    float normal_z;         // The z normal of the vertex
    unsigned int vcolor;     // The 32bit ARGB color of the vertex
    float texture_x;        // the x co-ordinate of the vertex on the texture (0 to 1)
    float texture_y;        // the y co-ordinate of the vertex on the texture (0 to 1)
}
IRR_VERT;

typedef struct tag_IRR_VECTOR
{
    float x;
    float y;
    float z;
}
IRR_VECTOR;


typedef struct tag_IRR_POS2D
{
    int x;
    int y;
}
IRR_POS2D;

typedef struct tag_IRR_POS2DF
{
    float x;
    float y;
}
IRR_POS2DF;

typedef struct tag_IRR_DIM2D
{
    int width;
    int height;
}
IRR_DIM2D;

typedef struct tag_IRR_TRIANGLE
{
    IRR_VECTOR pointA;
    IRR_VECTOR pointB;
    IRR_VECTOR pointC;
}
IRR_TRIANGLE;



/* ////////////////////////////////////////////////////////////////////////////
class declarations
*/
/*
This implementation of the Irrlicht event receiver receives events as they
happen and stores them in a circular buffer. the caller can then pop the
events out of the buffer at their convienence. if the events are unattended
and the buffer filled the oldest event is discarded
*/

class StackedEventReceiver : public IEventReceiver
{
public:
	virtual bool OnEvent(const SEvent& event);
};

#endif

