I'm trying to make a simple game, and I'm starting out with simple things and building up as I get stuff to work. First on the list is a skybox. Here is my code:
Code: Select all
#include <irrlicht.h>
#include <wchar.h>
#include <windows.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")
ICameraSceneNode* camera = 0;
class MyEventReceiver : public IEventReceiver{
public:
virtual bool OnEvent(SEvent event) {
if (camera)
return camera->OnEvent(event);
return false;
}//end method
};//end class
long WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd) {
MyEventReceiver receiver;
IrrlichtDevice *device = createDevice(DT_OPENGL, dimension2d<s32>(800,600), 16, false, true, &receiver);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
ISceneNode* node = 0;
node = smgr->addSkyBoxSceneNode(
driver->getTexture("../media/up.bmp"),
driver->getTexture("../media/down.bmp"),
driver->getTexture("../media/left.bmp"),
driver->getTexture("../media/right.bmp"),
driver->getTexture("../media/front.bmp"),
driver->getTexture("../media/back.bmp"));
device->getCursorControl()->setVisible(false);
camera = smgr->addCameraSceneNodeFPS();
camera->setPosition(core::vector3df(-50,50,-150));
int lastFPS = -1;
while(device->run()) {
driver->beginScene(true,true,SColor(0,100,100,100));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
int fps = driver->getFPS();
if(lastFPS != fps) {
wchar_t tmp[1024];
swprintf(tmp, 1024,
L"Stuff... (fps:%d) Triangles:%d",
fps, driver->getPrimitiveCountDrawn());
device->setWindowCaption(tmp);
lastFPS = fps;
}//end if
}//end while
device->drop();
return 0;
}//end main
Thanx,
Me.[/code]