Code:
main.cpp:
Code: Select all
#include "Device.h"
int main()
{
Device * D = new Device(dimension2du(800,600), L"My Render Window", EDT_DIRECT3D9, 4U);
if(D)
D->BeginLoop();
return 0;
}
Code: Select all
#pragma once
#include <irrlicht.h>
#include <Windows.h>
using namespace irr;
using namespace io;
using namespace core;
using namespace gui;
using namespace video;
using namespace scene;
#pragma comment(lib, "Irrlicht.lib")
class Device
{
private:
IrrlichtDevice * App;
bool Running;
public:
void Stop();
void BeginLoop();
Device(dimension2du WinSize, wchar_t *, E_DRIVER_TYPE DriverType, unsigned int AntiAliasing);
};
/* Event Handler */
class EventReceiver : public IEventReceiver
{
public:
EventReceiver(Device * d) : Dev(d){};
virtual bool OnEvent(const SEvent & event)
{
switch(event.EventType)
{
case EET_KEY_INPUT_EVENT:
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
Dev->Stop();
break;
default:
break;
}
break;
default:
break;
}
return false;
}
private:
Device * Dev;
};
Code: Select all
#include "Device.h"
Device::Device(dimension2du WinSize = dimension2du(800,600), wchar_t * WindowTitle = L"REngine Window", E_DRIVER_TYPE DriverType = EDT_DIRECT3D9, unsigned int AntiAliasing = 4U)
{
EventReceiver Events(this);
SIrrlichtCreationParameters Params;
Params.AntiAlias = AntiAliasing;
Params.DriverType = DriverType;
Params.WindowSize = WinSize;
Params.Bits = 16U;
Params.LoggingLevel = ELL_INFORMATION;
Params.EventReceiver = &Events;
App = createDeviceEx(Params);
if(App)
Running = true;
}
void Device::Stop()
{
Running = false;
}
void Device::BeginLoop()
{
while(App->run())
{
App->getVideoDriver()->beginScene();
App->getVideoDriver()->endScene();
}
}