mirror of https://github.com/axmolengine/axmol.git
Merge branch 'gles20' of https://github.com/cocos2d/cocos2d-x into gles20
This commit is contained in:
commit
6c4bdc238f
|
@ -12,6 +12,9 @@
|
|||
#include "CCApplication.h"
|
||||
#include "cocoa/CCString.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -45,13 +48,17 @@ void CCFileUtils::purgeCachedEntries()
|
|||
|
||||
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
||||
{
|
||||
if (pszRelativePath && pszRelativePath[0] == '/')
|
||||
{
|
||||
return pszRelativePath;
|
||||
}
|
||||
|
||||
const char* pszRootPath = CCApplication::sharedApplication()->getResourceRootPath();
|
||||
|
||||
CCString* pRet = CCString::create(pszRootPath);
|
||||
const char* resDir = CCFileUtils::sharedFileUtils()->getResourceDirectory();
|
||||
if (resDir != NULL)
|
||||
if (m_obDirectory.size() > 0)
|
||||
{
|
||||
pRet->m_sString += resDir;
|
||||
pRet->m_sString += m_obDirectory.c_str();
|
||||
}
|
||||
|
||||
if (pszRelativePath != NULL)
|
||||
|
@ -59,6 +66,20 @@ const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
|||
pRet->m_sString += pszRelativePath;
|
||||
}
|
||||
|
||||
// check if file or path exist
|
||||
struct stat sts;
|
||||
if (stat(pRet->getCString(), &sts) == -1 && errno == ENOENT)
|
||||
{
|
||||
// find from "Resources/"
|
||||
pRet->m_sString.clear();
|
||||
pRet->m_sString = CCApplication::sharedApplication()->getResourceRootPath();
|
||||
pRet->m_sString += pszRelativePath;
|
||||
if (stat(pRet->getCString(), &sts) == -1 && errno == ENOENT)
|
||||
{
|
||||
return pszRelativePath;
|
||||
}
|
||||
}
|
||||
|
||||
return pRet->getCString();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,12 +4,31 @@
|
|||
#include "cocos2d.h"
|
||||
#include "CCEGLView.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string>
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
// 500 is enough?
|
||||
#define MAXPATHLEN 500
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// get application path
|
||||
int length;
|
||||
char fullpath[MAXPATHLEN];
|
||||
length = readlink("/proc/self/exe", fullpath, sizeof(fullpath));
|
||||
fullpath[length] = '\0';
|
||||
|
||||
std::string resourcePath = fullpath;
|
||||
resourcePath = resourcePath.substr(0, resourcePath.find_last_of("/"));
|
||||
resourcePath += "/../Resources/";
|
||||
|
||||
// create the application instance
|
||||
AppDelegate app;
|
||||
CCApplication::sharedApplication()->setResourceRootPath("../Resources/");
|
||||
CCApplication::sharedApplication()->setResourceRootPath(resourcePath.c_str());
|
||||
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||
eglView->setFrameSize(960, 640);
|
||||
return CCApplication::sharedApplication()->run();
|
||||
|
|
|
@ -1,14 +1,35 @@
|
|||
#include "main.h"
|
||||
#include "cocos2d.h"
|
||||
|
||||
#include "../Classes/AppDelegate.h"
|
||||
#include "cocos2d.h"
|
||||
#include "CCEGLView.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string>
|
||||
|
||||
USING_NS_CC;
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
// 500 is enough?
|
||||
#define MAXPATHLEN 500
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// get application path
|
||||
int length;
|
||||
char fullpath[MAXPATHLEN];
|
||||
length = readlink("/proc/self/exe", fullpath, sizeof(fullpath));
|
||||
fullpath[length] = '\0';
|
||||
|
||||
std::string resourcePath = fullpath;
|
||||
resourcePath = resourcePath.substr(0, resourcePath.find_last_of("/"));
|
||||
resourcePath += "/../Resources/";
|
||||
|
||||
// create the application instance
|
||||
AppDelegate app;
|
||||
CCApplication::sharedApplication()->setResourceRootPath("../Resources/");
|
||||
CCApplication::sharedApplication()->setResourceRootPath(resourcePath.c_str());
|
||||
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||
eglView->setFrameSize(480, 320);
|
||||
|
||||
return CCApplication::sharedApplication()->run();
|
||||
}
|
||||
|
|
|
@ -4,12 +4,31 @@
|
|||
#include "cocos2d.h"
|
||||
#include "CCEGLView.h"
|
||||
|
||||
USING_NS_CC;
|
||||
int main(int argc, char **argv) {
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string>
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
// 500 is enough?
|
||||
#define MAXPATHLEN 500
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// get application path
|
||||
int length;
|
||||
char fullpath[MAXPATHLEN];
|
||||
length = readlink("/proc/self/exe", fullpath, sizeof(fullpath));
|
||||
fullpath[length] = '\0';
|
||||
|
||||
std::string resourcePath = fullpath;
|
||||
resourcePath = resourcePath.substr(0, resourcePath.find_last_of("/"));
|
||||
resourcePath += "/../Resources/";
|
||||
|
||||
// create the application instance
|
||||
AppDelegate app;
|
||||
CCApplication::sharedApplication()->setResourceRootPath("../Resources/");
|
||||
CCApplication::sharedApplication()->setResourceRootPath(resourcePath.c_str());
|
||||
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||
eglView->setFrameSize(480, 320);
|
||||
return CCApplication::sharedApplication()->run();
|
||||
|
|
Loading…
Reference in New Issue