axmol/samples/HelloCpp/proj.linux/main.cpp

35 lines
910 B
C++
Raw Normal View History

2012-08-02 13:02:59 +08:00
#include "main.h"
#include "../Classes/AppDelegate.h"
#include "cocos2d.h"
2012-08-02 13:02:59 +08:00
2012-08-24 17:55:29 +08:00
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string>
2012-08-02 13:02:59 +08:00
USING_NS_CC;
2012-08-24 17:55:29 +08:00
// 500 is enough?
#define MAXPATHLEN 500
int main(int argc, char **argv)
{
2012-08-24 17:55:29 +08:00
// 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/";
2012-08-24 17:55:29 +08:00
2012-08-02 13:02:59 +08:00
// create the application instance
AppDelegate app;
2012-08-24 17:55:29 +08:00
CCApplication::sharedApplication()->setResourceRootPath(resourcePath.c_str());
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
eglView->setFrameSize(960, 640);
return CCApplication::sharedApplication()->run();
2012-08-02 13:02:59 +08:00
}