本文整理汇总了C++中MEngine::setSystemContext方法的典型用法代码示例。如果您正苦于以下问题:C++ MEngine::setSystemContext方法的具体用法?C++ MEngine::setSystemContext怎么用?C++ MEngine::setSystemContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MEngine
的用法示例。
在下文中一共展示了MEngine::setSystemContext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
void MaratisPlayer::start(void)
{
// MEngine
{
MEngine * engine = MEngine::getInstance();
// package manager
engine->setPackageManager(m_packageManager);
m_packageManager->init();
// contexts
engine->setSoundContext(m_soundContext); // sound context
engine->setRenderingContext(m_render); // rendering context
engine->setPhysicsContext(m_physics); // physics context
engine->setScriptContext(m_script); // script context
engine->setInputContext(m_input); // input context
engine->setSystemContext(m_system); // system context
// loaders
engine->getImageLoader()->addLoader(M_loadImage); // image loader
engine->getSoundLoader()->addLoader(M_loadSound); // sound loader
engine->getLevelLoader()->addLoader(xmlLevelLoad); // level loader
engine->getFontLoader()->addLoader(M_loadFont); // font loader
engine->getFontLoader()->addLoader(M_loadBinFont); // bin font loader
// add behaviors
engine->getBehaviorManager()->addBehavior(MBLookAt::getStaticName(), M_OBJECT3D_CAMERA, MBLookAt::getNew);
engine->getBehaviorManager()->addBehavior(MBFollow::getStaticName(), M_OBJECT3D, MBFollow::getNew);
// add renderers
engine->getRendererManager()->addRenderer(MStandardRenderer::getStaticName(), MStandardRenderer::getNew);
engine->getRendererManager()->addRenderer(MFixedRenderer::getStaticName(), MFixedRenderer::getNew);
// mesh loader
engine->getMeshLoader()->addLoader(xmlMeshLoad);
engine->getMeshLoader()->addLoader(M_loadBinMesh);
engine->getArmatureAnimLoader()->addLoader(xmlArmatureAnimLoad);
engine->getArmatureAnimLoader()->addLoader(M_loadBinArmatureAnim);
engine->getTexturesAnimLoader()->addLoader(xmlTextureAnimLoad);
engine->getTexturesAnimLoader()->addLoader(M_loadBinTexturesAnim);
engine->getMaterialsAnimLoader()->addLoader(xmlMaterialAnimLoad);
engine->getMaterialsAnimLoader()->addLoader(M_loadBinMaterialsAnim);
// level
engine->setLevel(m_level);
// game
engine->setGame(m_game);
// set default renderer (standard)
if(m_renderer == NULL)
m_renderer = new MStandardRenderer();
engine->setRenderer(m_renderer);
engine->setSaveFileFactory(MSaveFileImpl::getNew);
}
}
示例2: main
// main
int main(int argc, char **argv)
{
setlocale(LC_NUMERIC, "C");
unsigned int width = 800;
unsigned int height = 400;
bool fullscreen = false;
// get engine
MEngine* engine = MEngine::getInstance();
// get window
MWindow* window = MWindow::getInstance();
window->setPointerEvent(windowEvents); // window events
// create window
if(! window->create("Maratis - ManualUse example", width, height, 32, fullscreen))
{
MLOG(4, "window create failed");
return 0;
}
if(fullscreen)
window->hideCursor();
// set current directory
{
char rep[256];
getRepertory(rep, argv[0]);
window->setCurrentDirectory(rep);
}
// create virtual contexts
MSoundContext * soundContext = new MALContext();
MRenderingContext * render = new MGLContext();
MPhysicsContext * physics = new MBulletContext();
MScriptContext * script = new MScript();
MInputContext * input = new MInput();
MSystemContext * system = new MWinContext();
MLOG(5, "Render version: " << render->getRendererVersion());
// create default Level and Game
MLevel * level = new MLevel();
MGame * game = new MyGame(); // MyGame
// init MEngine (you can replace all contexts by others and add or use different data loaders)
engine->setSoundContext(soundContext); // sound context
engine->setRenderingContext(render); // rendering context
engine->setPhysicsContext(physics); // physics context
engine->setScriptContext(script); // script context
engine->setInputContext(input); // input context
engine->setSystemContext(system); // system context
engine->getImageLoader()->addLoader(M_loadImage); // image loader
engine->getSoundLoader()->addLoader(M_loadSound); // sound loader
// engine->getLevelLoader()->addLoader(xmlLevelLoad); // level loader : uncomment if wanted
engine->getFontLoader()->addLoader(M_loadFont); // font loader
// engine->getFontLoader()->addLoader(M_loadBinFont); // bin font loader : uncomment if wanted
// add some default "Maratis" behaviors : uncomment if wanted or add custom
// engine->getBehaviorManager()->addBehavior(MBLookAt::getStaticName(), M_OBJECT3D_CAMERA, MBLookAt::getNew);
// engine->getBehaviorManager()->addBehavior(MBFollow::getStaticName(), M_OBJECT3D, MBFollow::getNew);
// add renderers
engine->getRendererManager()->addRenderer(MStandardRenderer::getStaticName(), MStandardRenderer::getNew);
engine->getRendererManager()->addRenderer(MFixedRenderer::getStaticName(), MFixedRenderer::getNew);
// mesh loader
engine->getMeshLoader()->addLoader(xmlMeshLoad);
engine->getArmatureAnimLoader()->addLoader(xmlArmatureAnimLoad);
engine->getTexturesAnimLoader()->addLoader(xmlTextureAnimLoad);
engine->getMaterialsAnimLoader()->addLoader(xmlMaterialAnimLoad);
// set level
engine->setLevel(level);
// set game
engine->setGame(game);
// set renderer (standard)
MRenderer * renderer = engine->getRendererManager()->getRendererByName("StandardRenderer")->getNewRenderer();
engine->setRenderer(renderer);
// begin game
game->begin();
// time
unsigned int frequency = 60;
unsigned long previousFrame = 0;
unsigned long startTick = window->getSystemTick();
// on events
while(window->isActive())
{
// on events
if(window->onEvents())
{
// compute target tick
//.........这里部分代码省略.........
示例3: winEvents
// window events
void winEvents(MWindow *rootWindow, MWIN_EVENT_TYPE event)
{
//MLOG(6, "Window Event : " << event);
MEngine *engine = MEngine::getInstance();
switch (event)
{
case MWIN_EVENT_CREATE:
{
sys = new MGUIContext();
engine->setSystemContext(sys);
// create a rendering context
render = new MGLContext();
engine->setRenderingContext(render);
// create a input context
input = new MInput();
engine->setInputContext(input);
// create a physics context
physics = new MBulletContext();
engine->setPhysicsContext(physics);
// create a renderer
renderer = new MStandardRenderer();
engine->setRenderer(renderer);
// create a level
level = new MLevel();
engine->setLevel(level);
// create a game
game = new MyGame(); // MyGame
engine->setGame(game);
game->begin();
}
break;
case MWIN_EVENT_CLOSE:
{
MGUI_closeWindow(rootWindow);
}
break;
case MWIN_EVENT_DESTROY:
{
game->end();
SAFE_DELETE(level);
SAFE_DELETE(game);
SAFE_DELETE(renderer);
SAFE_DELETE(render);
SAFE_DELETE(input);
SAFE_DELETE(physics);
SAFE_DELETE(sys);
}
break;
default:
break;
}
}