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

36 lines
931 B
C++
Raw Normal View History

2012-08-02 13:02:59 +08:00
#include "main.h"
#include "../Classes/AppDelegate.h"
#include "cocos2d.h"
#include "CCEGLView.h"
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("/"));
2012-08-27 16:43:02 +08:00
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
}