Code: Select all
//h18.h
#include <irrlicht.h>
#include <wchar.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")
class h18 : public IEventReceiver
{
public:
h18(int width, int height, int bpp, bool fullscreen, bool shadows); //Contructor
~h18(); //Deconstructor
void run(); //run();
virtual bool OnEvent(SEvent event); //OnEvent();
private:
/*-- Private Functions --*/
void loadSceneData(); //loadSceneData();
/* -- Variables -- */
//Video Options
bool shadows;
bool fullscreen;
int width;
int height;
int bpp;
//Other Video
IrrlichtDevice *device;
//Scene & mesh nodes
ISceneNode* quakeLevelNode;
ISceneNode* skyboxNode;
ICameraSceneNode* camera;
//Meshes
IAnimatedMesh* quakeLevelMesh;
};
Code: Select all
//h18.cpp
#include "h18.h"
#include <stdio.h>
h18::h18(int w, int h, int b, bool f, bool s) //Constructor
: shadows(s), width(w), height(h), bpp(b), fullscreen(f), camera(0)
{
}
h18::~h18() //Decontructor
{
;
}
void h18::run() { //run();
device = createDevice(DT_DIRECTX8, dimension2d<s32>(width, height), bpp, fullscreen, shadows, 0);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
device->setWindowCaption(L"Hanger 18 - Powered by Irrlicht");
loadSceneData();
camera = smgr->addCameraSceneNodeFPS();
wchar_t tmp[255];
while(device->run() && driver)
{
if (device->isWindowActive())
{
driver->beginScene(true, true, SColor(0,100,100,100));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
}
device->drop();
}
bool h18::OnEvent(SEvent event) //OnEvent();
{
if (event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_ESCAPE &&
event.KeyInput.PressedDown == false)
{
// user wants to quit.
device->closeDevice();
}
else if (device->getSceneManager()->getActiveCamera())
{
device->getSceneManager()->getActiveCamera()->OnEvent(event);
return true;
}
return false;
}
void h18::loadSceneData() { //loadSceneData();
IVideoDriver* driver = device->getVideoDriver(); //Set up Pointer
ISceneManager* sm = device->getSceneManager(); //Set up Pointer
quakeLevelMesh = sm->getMesh("maps/testing.bsp"); //Load Mesh
quakeLevelNode = sm->addOctTreeSceneNode(quakeLevelMesh->getMesh(0)); //Add OcTree
/*-- SKYBOX --*/
skyboxNode = sm->addSkyBoxSceneNode(
driver->getTexture("skybox/greysky_up.jpg"),
driver->getTexture("skybox/greysky_dn.jpg"),
driver->getTexture("skybox/greysky_lf.jpg"),
driver->getTexture("skybox/greysky_rt.jpg"),
driver->getTexture("skybox/greysky_ft.jpg"),
driver->getTexture("skybox/greysky_bk.jpg"));
//
}
Code: Select all
//main.cpp
#include <windows.h>
#include "h18.h"
int main()
{
h18 hanger18(1024, 768, 16, true, true);
hanger18.run();
return 0;
}