Here is the project or code below
Thanks in advance))
MAIN
Code: Select all
#include "C_Engine.h"
int main()
{
if ( !CEngine::reset() ) return 0;
device->getFileSystem()->addFileArchive("Data");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
rect<s32>(10,10,260,22), true);
/*IAnimatedMesh* mesh = smgr->getMesh("zombie.b3d");
if (!mesh)
{
device->drop();
return 1;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("ZOMBIE.jpg") );
}*/
smgr->addCameraSceneNode(0, vector3df(0,20,-25), vector3df(0,10,0));
int lastFPS = -1;
///////////////////////Игровой цикл////////////////////////////////
while(device->run())
{
now = device->getTimer()->getTime();
if (now - sceneStartTime > sceneSkipTime)
{
sceneStartTime = device->getTimer()->getTime();
////////////////Игровой Движек/////////////////////////
////////////////Конец игрового движка//////////////////
driver->beginScene(true, true, video::SColor(255,200,200,200));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Demo Game [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
}
device->drop();
return 0;
}
Code: Select all
#ifndef C_ENGINE_H
#define C_ENGINE_H
#include "A_Header.h"
/// СПИСОК ОСНОВНЫХ УСТРОЙСТВ ИРРЛИХТА
irr::IrrlichtDevice * device = 0; // 1
irr::video::IVideoDriver * driver = 0; // 2
irr::scene::ISceneManager * smgr = 0; // 3
irr::gui::IGUIEnvironment * guienv = 0; // 4
irr::scene::ISceneCollisionManager * cmgr = 0; // 5
irr::gui::ICursorControl * cControl = 0; // 6
irr::io::IFileSystem * fSys = 0; // 7
irr::IOSOperator * OS = 0; // 8
irr::ITimer * timer = 0; // 9
irr::ILogger * logger = 0; // 10
irr::IRandomizer * rzer = 0; // 11
/// Загружаются TLoaderFont.h
irr::gui::IGUIFont * font = 0,
* font_bold = 0,
* font_italic = 0;
///
int Height = 512;
int Width = 1024;
s32 framelimit = 120,
now = 0;
u32 sceneStartTime = 0,
sceneSkipTime = 1000 / framelimit;
/// 2 приватные служебные ф-ции
/// и только 1 рабочая - доступна
class CEngine
{
///
static void initAll()
{
driver = device->getVideoDriver();
cControl = device->getCursorControl();
smgr = device->getSceneManager();
cmgr = smgr->getSceneCollisionManager(); // менеджер коллизий
guienv = device->getGUIEnvironment();
fSys = device->getFileSystem();
OS = device->getOSOperator();
timer = device->getTimer();
logger = device->getLogger();
rzer = device->createDefaultRandomizer();
}
static void initDev ( irr::SIrrlichtCreationParameters _dcparams_= irr::SIrrlichtCreationParameters() )
{
device = createDeviceEx( _dcparams_ );
if ( device ) initAll();
}
public:
///
static irr::IrrlichtDevice * reset( irr::video::E_DRIVER_TYPE _driverType_ = irr::video::EDT_OPENGL,
//irr::core::dimension2di _newScrExt_ = irr::core::dimension2di(800,600),
irr::SIrrlichtCreationParameters _dcparams_ = irr::SIrrlichtCreationParameters() )
{
_dcparams_.DriverType = _driverType_;
//_dcparams_.WindowSize = _newScrExt_;
_dcparams_.WindowSize.Height = Height;
_dcparams_.WindowSize.Width = Width;
if ( !device ) initDev ( _dcparams_ );
else /// если устройство уже сущестует, значит его нужно "перезагрузить"
{
device->closeDevice();
device->run();
device->drop();
device = NULL;
initDev ( _dcparams_ );
}
///
return device;
}
}; /// end class C_ENGINE_H
#endif // C_ENGINE_H
Code: Select all
// include this file only once
//#pragma once
#include "Irrlicht.h"
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace std;