i m new to irrlicht. i want to implement a small skybox with stars and i want to get an input from the user to end the programm. according to a tutorial from the site i've implemented this:
Code: Select all
#include <irrlicht.h>
#include <stdio.h>
#include <wchar.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
ISceneNode* node = 0;
IrrlichtDevice *device = 0;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (node != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT &&
!event.KeyInput.PressedDown)
{
switch(event.KeyInput.Key)
{
case KEY_KEY_W:
case KEY_KEY_S:
{
device->drop();
}
return true;
}
}
return false;
}
};
int main()
{
MyEventReceiver receiver;
device = createDevice(EDT_OPENGL, dimension2d<s32>(800, 600), 32, false, false, false, &receiver);
device->setWindowCaption(L"Lostsignal v0.1");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
guienv->addStaticText(L"Hello World!", rect<int>(10,10,200,22), false);
smgr->addSkyBoxSceneNode(driver->getTexture("nightsky.jpg"),
driver->getTexture("nightsky.jpg"),
driver->getTexture("nightsky.jpg"),
driver->getTexture("nightsky.jpg"),
driver->getTexture("nightsky.jpg"),
driver->getTexture("nightsky.jpg"), 0, 0);
smgr->addSphereSceneNode(3.0f, 32, 0, -1, vector3df(2.0f, 2.0f, 2.0f),
vector3df(0.0f, 0.0f, 0.0f),
vector3df(1.0f, 1.0f, 1.0f));
smgr->addCameraSceneNodeFPS();
device->getCursorControl()->setVisible(false);
int lastFPS = -1;
while(device->run())
{
driver->beginScene(true, true, SColor(0,0,0,0));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
int fps = driver->getFPS();
if(lastFPS != fps)
{
wchar_t tmp[1024];
swprintf(tmp, 1024, L"Lostsignal FPS: (%d),(%s)",
driver->getName(), fps);
device->setWindowCaption(tmp);
lastFPS = fps;
}
}
device->drop();
return 0;
}
here is the link to the screenshot: http://img229.imageshack.us/my.php?imag ... otoks6.png
