Code: Select all
IrrlichtDevice* device = createDevice(video::EDT_SOFTWARE, dimension2d<u32>(800, 600), 16, false, false, true);
if (!device) return -1;
device->setWindowCaption(L"New Irrlicht Project!");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* scenemgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
IMesh* mesh = scenemgr->getMesh("media/grassblock.obj");
if (!mesh) return -1;
IMeshSceneNode* node = scenemgr->addMeshSceneNode(mesh);
if (!node) return -1;
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMaterialTexture(0, driver->getTexture("media/grass01.bmp"));
SKeyMap keymap[4];
keymap[0].Action = EKA_MOVE_FORWARD;
keymap[0].KeyCode = KEY_KEY_W;
keymap[1].Action = EKA_STRAFE_LEFT;
keymap[1].KeyCode = KEY_KEY_A;
keymap[2].Action = EKA_MOVE_BACKWARD;
keymap[2].KeyCode = KEY_KEY_S;
keymap[3].Action = EKA_STRAFE_RIGHT;
keymap[3].KeyCode = KEY_KEY_D;
ICameraSceneNode* cam = scenemgr->addCameraSceneNodeFPS(0, 50.0f, 0.01f, -1, keymap, 4, false);
cam->setNearValue(0.01f);
while (device->run())
{
driver->beginScene(true, true, SColor(255, 100, 110, 170));
scenemgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();