1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#include <cstdint>
#include <exception>
#include <irrlicht/irrlicht.h>
#include <memory>
#include <stdexcept>
#include <string>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
int main()
{
std::unique_ptr<IrrlichtDevice> device(createDevice(video::EDT_OPENGL, dimension2d<u32>(800, 600), 32, false, false, false, 0));
if (!(device.get()))
throw std::runtime_error("Error creating Irrlicht device");
device.get()->setWindowCaption(L"DemonGame");
device.get()->getGUIEnvironment()->addStaticText(L"DemonGame using Irrlicht OpenGL", rect<s32>(10, 10, 260, 22), true);
std::unique_ptr<IAnimatedMesh> mesh(device->getSceneManager()->getMesh("assets/sydney.md2"));
if (!(mesh.get()))
throw std::runtime_error("Error loading mesh");
std::unique_ptr<IAnimatedMeshSceneNode> node(device.get()->getSceneManager()->addAnimatedMeshSceneNode(mesh.get()));
if (node.get()) {
node.get()->setMaterialFlag(EMF_LIGHTING, false);
node.get()->setMD2Animation(scene::EMAT_STAND);
node.get()->setMaterialTexture(0, device.get()->getVideoDriver()->getTexture("assets/sydney.bmp"));
}
device.get()->getSceneManager()->addCameraSceneNode(0, vector3df(0, 30, -40), vector3df(0, 5, 0));
while (device.get()->run()) {
device.get()->getVideoDriver()->beginScene(true, true, SColor(255, 100, 101, 140));
device.get()->getSceneManager()->drawAll();
device.get()->getGUIEnvironment()->drawAll();
device.get()->getVideoDriver()->endScene();
}
device.get()->drop();
return 0;
}
|