本文整理汇总了C++中MEngine类的典型用法代码示例。如果您正苦于以下问题:C++ MEngine类的具体用法?C++ MEngine怎么用?C++ MEngine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MEngine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clear
void MSoundRef::clear(void)
{
MEngine * engine = MEngine::getInstance();
MSoundContext * soundContext = engine->getSoundContext();
soundContext->deleteBuffer(&m_bufferId);
}
示例2: Save
void Atlas::Save()
{
MEngine* engine = MEngine::getInstance();
std::string imgName = (std::string("atlases/") + m_Name + ".png");
engine->getImageSaver()->loadData(imgName.c_str(), &m_Atlas);
if(m_ConfigFile)
{
m_ConfigFile->Write("atlas.filename", imgName);
m_ConfigFile->Write("atlas.images", m_Images.size());
int i = 0;
for(imageMapIter iImage = m_Images.begin(); iImage != m_Images.end(); iImage++)
{
std::string root = "atlas.image";
char num[32];
snprintf(num, 32, "%d.", i);
root += num;
++i;
m_ConfigFile->Write((root + "name").c_str(), iImage->first);
m_ConfigFile->Write((root + "pos").c_str(), iImage->second.uv);
m_ConfigFile->Write((root + "w").c_str(), iImage->second.width);
m_ConfigFile->Write((root + "h").c_str(), iImage->second.height);
}
m_ConfigFile->Save();
}
}
示例3: changeCurrentScene
void MLevel::changeCurrentScene(unsigned int id)
{
if(id == m_currentSceneId)
return;
MEngine * engine = MEngine::getInstance();
if(id < getScenesNumber())
{
MScene * scene = getCurrentScene();
// onEndScene
MGame * game = engine->getGame();
if(game)
game->onEndScene();
// change scene
setCurrentSceneId(id);
scene = getCurrentScene();
// onBeginScene
if(game)
game->onBeginScene();
}
}
示例4: getRepertory
void MaratisPlayer::loadProject(MProject* proj, const char * filename)
{
MWindow * window = MWindow::getInstance();
MEngine * engine = MEngine::getInstance();
// working directory
char workingDir[256];
getRepertory(workingDir, filename);
window->setWorkingDirectory(workingDir);
// restart
restart();
loadGamePlugin();
// renderer
changeRenderer(proj->renderer.c_str());
// if we have a package manager, try to load the package
if(MPackageManager* pPackMan = MEngine::getInstance()->getPackageManager())
{
char projName[256];
getLocalFilename(projName, workingDir, filename);
if(char* ext = strstr(projName, ".mproj"))
{
sprintf(ext, ".npk");
char packageFile[256];
getGlobalFilename(packageFile, workingDir, projName);
pPackMan->loadPackage(packageFile);
}
}
// load start level
engine->loadLevel(proj->startLevel.c_str());
}
示例5: draw
void MScene::draw(MOCamera * camera)
{
MEngine * engine = MEngine::getInstance();
MRenderer * renderer = engine->getRenderer();
if(renderer)
renderer->drawScene(this, camera);
}
示例6: graphicLoop
void MaratisPlayer::graphicLoop(void)
{
MWindow * window = MWindow::getInstance();
MEngine * engine = MEngine::getInstance();
MRenderingContext * render = engine->getRenderingContext();
// game
MGame * game = engine->getGame();
if(game)
{
if(game->isRunning())
{
render->disableScissorTest();
render->setViewport(0, 0, window->getWidth(), window->getHeight());
game->draw();
}
else
{
render->clear(M_BUFFER_COLOR);
}
}
else
{
render->clear(M_BUFFER_COLOR);
}
}
示例7: WriteImage
void Atlas::Generate(bool clear)
{
m_Atlas.create(M_UBYTE, m_Width, m_Height, m_BPP);
unsigned char col[]= {255, 255, 255, 0};
for(uint32 x = 0; x < m_Width; ++x)
for(uint32 y = 0; y < m_Height; ++y)
m_Atlas.writePixel(x, y, col);
for(imageMapIter iImage = m_Images.begin();
iImage != m_Images.end();
iImage++)
WriteImage(iImage->second);
MEngine* engine = MEngine::getInstance();
MRenderingContext* render = engine->getRenderingContext();
if(m_TextureID == 0)
render->createTexture(&m_TextureID);
render->bindTexture(m_TextureID);
render->sendTextureImage(&m_Atlas, false, 1, 0);
if(clear)
{
// remove images
delete [] m_Layout;
m_Layout = NULL;
}
}
示例8: onBeginScene
void MGame::onBeginScene(void)
{
MEngine * engine = MEngine::getInstance();
// get level
MLevel * level = MEngine::getInstance()->getLevel();
if(! level)
return;
// get current scene
MScene * scene = level->getCurrentScene();
if(! scene)
return;
// update objects
scene->updateObjectsMatrices();
// start sound
scene->playLoopSounds();
// prepare physics
scene->preparePhysics();
// run script
if(engine->getScriptContext())
engine->getScriptContext()->runScript(scene->getScriptFilename());
}
示例9: update
void MFontRef::update(void * arg)
{
MEngine * engine = MEngine::getInstance();
if(! m_font)
m_font = MFont::getNew();
engine->getFontLoader()->loadData(getFilename(), m_font, arg);
}
示例10: ScriptAtlasSelect
int ScriptAtlasSelect()
{
MEngine* engine = MEngine::getInstance();
MScriptContext* script = engine->getScriptContext();
if(Atlas* atlas = (Atlas*)script->getPointer(0))
atlas->Select();
return 0;
}
示例11: MPluginEnd
void MPluginEnd(MScriptExt)
{
MResource::unregisterFactory("MScriptExt", MScriptExtGetter);
MEngine* engine = MEngine::getInstance();
if(engine->getScriptContext() == s_script)
engine->setScriptContext(NULL);
delete s_script;
}
示例12: update
void MMaterialsAnimRef::update(void * arg)
{
MEngine * engine = MEngine::getInstance();
if(! m_materialsAnim)
m_materialsAnim = MMaterialsAnim::getNew();
engine->getMaterialsAnimLoader()->loadData(getFilename(), m_materialsAnim, arg);
}
示例13: update
void MTexturesAnimRef::update(void)
{
MEngine * engine = MEngine::getInstance();
if(! m_texturesAnim)
m_texturesAnim = MTexturesAnim::getNew();
engine->getTexturesAnimLoader()->loadData(getFilename(), m_texturesAnim);
}
示例14: ScriptAtlasWrite
int ScriptAtlasWrite()
{
MEngine* engine = MEngine::getInstance();
MScriptContext* script = engine->getScriptContext();
Atlas* atlas = (Atlas*)script->getPointer(0);
atlas->Save();
return 0;
}
示例15: M_PROFILE_SCOPE
void MMaterialsAnimRef::update(void)
{
M_PROFILE_SCOPE(MMaterialsAnimRef::update);
MEngine * engine = MEngine::getInstance();
if(! m_materialsAnim)
m_materialsAnim = MMaterialsAnim::getNew();
engine->getMaterialsAnimLoader()->loadData(getFilename(), m_materialsAnim);
}