本文整理汇总了C++中MEngine::getSystemContext方法的典型用法代码示例。如果您正苦于以下问题:C++ MEngine::getSystemContext方法的具体用法?C++ MEngine::getSystemContext怎么用?C++ MEngine::getSystemContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MEngine
的用法示例。
在下文中一共展示了MEngine::getSystemContext方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsFile
bool MEmbedFile::IsFile(const char* name)
{
M_PROFILE_SCOPE(MEmbedFile::IsFile);
MEngine* engine = MEngine::getInstance();
MSystemContext* system = engine->getSystemContext();
char localFilename[256];
getLocalFilename(localFilename, system->getWorkingDirectory(), name);
return strcmp(localFilename, m_Filename) == 0;
}
示例2: getPubDir
const char* getPubDir()
{
MEngine* engine = MEngine::getInstance();
MSystemContext* system = engine->getSystemContext();
char dir[256];
getGlobalFilename(dir, system->getWorkingDirectory(), "published");
s_pubDir = dir;
return s_pubDir.c_str();
}
示例3: copySysOSX
void copySysOSX(const char* projName)
{
#ifdef _DEBUG
const char * appName = "MaratisPlayerDebug";
#else
const char * appName = "MaratisPlayer";
#endif
MWindow * window = MWindow::getInstance();
MEngine* engine = MEngine::getInstance();
MSystemContext* system = engine->getSystemContext();
char filename[256];
getLocalFilename(filename, system->getWorkingDirectory(), projName);
if(char* ext = strstr(filename, ".mproj"))
{
MProject proj;
if(proj.loadXML(projName))
{
strcpy(ext, ".app");
char path[256];
char srcName[256];
char destName[256];
char appPath[256];
char level[256];
getLocalFilename(level, system->getWorkingDirectory(), proj.startLevel.c_str());
getGlobalFilename(appPath, getPubDir(), filename);
sprintf(path, "../../../%s.app", appName);
getGlobalFilename(srcName, window->getCurrentDirectory(), path);
copyDirectory(srcName, appPath);
strcpy(ext, "");
sprintf(srcName, "%s/Contents/MacOS/%s", appPath, appName);
strcpy(ext, ".mproj");
embedProject(srcName, srcName, filename, level, proj.renderer.c_str());
chmod(srcName, 0777);
// we need to put all data in app/Contents/Resources/
sprintf(destName, "%s/Contents/Resources", appPath);
createDirectory(destName);
s_dataDir = destName;
}
}
}
示例4: open
/*--------------------------------------------------------------------------------
* MPackageFileOpenHook::open
* File open callback
*-------------------------------------------------------------------------------*/
MFile* MPackageFileOpenHook::open(const char* path, const char* mode)
{
MEngine* engine = MEngine::getInstance();
MSystemContext * system = engine->getSystemContext();
char localFilename[256];
getLocalFilename(localFilename, system->getWorkingDirectory(), path);
if(strstr(mode, "w") != 0)
return MStdFile::getNew(path, mode);
// look within the package for a file with the requested name
if(MPackageEnt ent = engine->getPackageManager()->findEntity(localFilename))
return MPackageFile::getNew(ent);
// give up, just look for a new file using stdio
return MStdFile::getNew(path, mode);
}
示例5: Flush
void Flush()
{
g_CurrentColour.set(255, 255, 255, 255);
if(g_Cnt == 0) return;
MEngine* engine = MEngine::getInstance();
MRenderingContext* render = engine->getRenderingContext();
MSystemContext* system = engine->getSystemContext();
unsigned int w, h;
system->getScreenSize(&w, &h);
// set up the "camera"
render->setViewport(0, 0, w, h);
render->setMatrixMode(M_MATRIX_PROJECTION);
render->loadIdentity();
render->setOrthoView(0, w, h, 0, 1.0f, -1.0f);
render->setMatrixMode(M_MATRIX_MODELVIEW);
render->loadIdentity();
// set up arrays
render->enableVertexArray();
render->enableTexCoordArray();
render->enableColorArray();
render->setVertexPointer(M_FLOAT, 3, g_Vertices);
render->setTexCoordPointer(M_FLOAT, 2, g_UVs);
render->setColorPointer(M_UBYTE, 4, g_Colours);
render->disableCullFace();
render->disableDepthTest();
render->drawArray(M_PRIMITIVE_TRIANGLES, 0, g_Cnt * 6);
g_Cnt = 0;
g_Selected = NULL;
}
示例6: openProjectPackage
MPackage openProjectPackage(const char* projName)
{
MEngine* engine = MEngine::getInstance();
MSystemContext* system = engine->getSystemContext();
char projFile[256];
getLocalFilename(projFile, system->getWorkingDirectory(), projName);
char* ext = strstr(projFile, ".mproj");
if(ext == 0)
{
return 0;
}
sprintf(ext, ".npk");
char packFile[256];
getGlobalFilename(packFile, getDataDir(), projFile);
MPackageManager* packageManager = engine->getPackageManager();
MPackage package = packageManager->openPackage(packFile);
return package;
}
示例7: getDataDir
void execute(const char* projName)
{
MEngine* engine = MEngine::getInstance();
MSystemContext* system = engine->getSystemContext();
char filename[256];
char destFilename[256];
#ifdef WIN32
const char* pluginName = "Game.dll";
#elif __APPLE__
const char* pluginName = "Game.dylib";
#elif linux
const char* pluginName = "Game.so";
#endif
getGlobalFilename(filename, system->getWorkingDirectory(), pluginName);
getGlobalFilename(destFilename, getDataDir(), pluginName);
if(isFileExist(filename))
{
copyFile(filename, destFilename);
}
}
示例8: copySysLinux
void copySysLinux(const char* projName)
{
#ifdef _DEBUG
const char * appName = "MaratisPlayerDebug";
#else
const char * appName = "MaratisPlayer";
#endif
MEngine* engine = MEngine::getInstance();
MSystemContext* system = engine->getSystemContext();
char filename[256];
getLocalFilename(filename, system->getWorkingDirectory(), projName);
if(char* ext = strstr(filename, ".mproj"))
{
*ext = 0;
MProject proj;
if(proj.loadXML(projName))
{
char destName[256];
getGlobalFilename(destName, getPubDir(), filename);
char level[256];
getLocalFilename(level, system->getWorkingDirectory(), proj.startLevel.c_str());
strcpy(ext, ".mproj");
embedProject(appName, destName, filename, level, proj.renderer.c_str());
chmod(destName, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
// find all dynamic libraries
copyDirFiles(".", getPubDir(), ".so");
}
}
}
示例9: copySysWindows
void copySysWindows(const char* projName)
{
#ifdef _DEBUG
const char * appName = "MaratisPlayerDebug.exe";
#else
const char * appName = "MaratisPlayer.exe";
#endif
MEngine* engine = MEngine::getInstance();
MSystemContext* system = engine->getSystemContext();
char filename[256];
getLocalFilename(filename, system->getWorkingDirectory(), projName);
if(char* ext = strstr(filename, ".mproj"))
{
MProject proj;
if(proj.loadXML(projName))
{
strcpy(ext, ".exe");
char destName[256];
getGlobalFilename(destName, getPubDir(), filename);
char level[256];
getLocalFilename(level, system->getWorkingDirectory(), proj.startLevel.c_str());
// we need the project "filename" to still be a .mproj for MaratisPlayer to behave
// correctly
strcpy(ext, ".mproj");
embedProject(appName, destName, filename, level, proj.renderer.c_str());
// find all dynamic libraries
copyDirFiles(".", getPubDir(), ".dll");
}
}
}
示例10: execute
void execute(const char* projName)
{
MEngine* engine = MEngine::getInstance();
MSystemContext* system = engine->getSystemContext();
MPackageManager* packageManager = engine->getPackageManager();
char directory[256], localFilename[256];
getGlobalFilename(directory, system->getWorkingDirectory(), "meshs");
vector<string> files;
readDirectory(directory, &files, 1, 1);
MLevel* currentLevel = engine->getLevel();
MLevel* tempLevel = new MLevel();
engine->setLevel(tempLevel);
MMesh* mesh = MMesh::getNew();
MArmatureAnim* armAnim = MArmatureAnim::getNew();
MTexturesAnim* texAnim = MTexturesAnim::getNew();
MMaterialsAnim* matAnim = MMaterialsAnim::getNew();
// open package and scan meshes
MPackage package = openProjectPackage(projName);
for(int i = 0; i < files.size(); ++i)
{
bool binarized = false;
if(strstr(files[i].c_str(), "._bin") != 0)
continue;
// export bin
if(strstr(files[i].c_str(), ".mesh") != 0)
{
if(engine->getMeshLoader()->loadData(files[i].c_str(), mesh))
binarized = exportMeshBin((files[i] + "._bin").c_str(), mesh);
}
else if (strstr(files[i].c_str(), ".maa") != 0)
{
if(engine->getArmatureAnimLoader()->loadData(files[i].c_str(), armAnim))
binarized = exportArmatureAnimBin((files[i] + "._bin").c_str(), armAnim);
}
else if (strstr(files[i].c_str(), ".mma") != 0)
{
if(engine->getMaterialsAnimLoader()->loadData(files[i].c_str(), matAnim))
binarized = exportMaterialsAnimBin((files[i] + "._bin").c_str(), matAnim);
}
else if (strstr(files[i].c_str(), ".mta") != 0)
{
if(engine->getTexturesAnimLoader()->loadData(files[i].c_str(), texAnim))
binarized = exportTexturesAnimBin((files[i] + "._bin").c_str(), texAnim);
}
else
{
// try to export unknow format
if(engine->getMeshLoader()->loadData(files[i].c_str(), mesh))
{
binarized = exportMeshBin((files[i] + "._bin").c_str(), mesh);
// try to export animation
MArmatureAnimRef * maaRef = mesh->getArmatureAnimRef();
if(maaRef)
{
exportArmatureAnimBin((files[i] + ".maa._bin").c_str(), maaRef->getArmatureAnim());
getLocalFilename(localFilename, system->getWorkingDirectory(), (files[i] + ".maa").c_str());
packageManager->addFileToPackage((files[i] + ".maa._bin").c_str(), package, localFilename);
}
}
}
tempLevel->clear();
// pack file
getLocalFilename(localFilename, system->getWorkingDirectory(), files[i].c_str());
if(binarized)
packageManager->addFileToPackage((files[i] + "._bin").c_str(), package, localFilename); // pack bin file
else
packageManager->addFileToPackage(files[i].c_str(), package, localFilename); // pack original file
}
packageManager->closePackage(package);
// clear mesh
mesh->destroy();
armAnim->destroy();
texAnim->destroy();
matAnim->destroy();
// remove bin
for(int i = 0; i < files.size(); ++i)
{
remove((files[i] + "._bin").c_str());
remove((files[i] + ".maa._bin").c_str());
}
// restore level
engine->setLevel(currentLevel);
SAFE_DELETE(tempLevel);
}