mirror of https://github.com/axmolengine/axmol.git
[NaCl] Remove legacy nacl_mounts usage.
Also add nacl SDK version check to ensure the SDK contains a recent version of nacl_io.
This commit is contained in:
parent
203d2e4559
commit
47878c1855
|
@ -9,8 +9,9 @@
|
||||||
# and add the NaCl compiler bin folder to your path.
|
# and add the NaCl compiler bin folder to your path.
|
||||||
#
|
#
|
||||||
# There are several libraries from naclports that are
|
# There are several libraries from naclports that are
|
||||||
# prerequisite for building cocos2dx on NaCl. The simplest
|
# prerequisite for building cocos2dx on NaCl. These ship
|
||||||
# way to build them is to checkout naclports and run:
|
# with recent versions of the NaCl SDK or you can build
|
||||||
|
# them yourself by checking out naclports and running:
|
||||||
# $ make png tiff freetype xml2 freealut jpeg vorbis ogg
|
# $ make png tiff freetype xml2 freealut jpeg vorbis ogg
|
||||||
|
|
||||||
if [ -z "$NACL_SDK_ROOT" ]; then
|
if [ -z "$NACL_SDK_ROOT" ]; then
|
||||||
|
|
|
@ -26,11 +26,10 @@ THE SOFTWARE.
|
||||||
#include "CCInstance.h"
|
#include "CCInstance.h"
|
||||||
#include "CCApplication.h"
|
#include "CCApplication.h"
|
||||||
#include "CCEGLView.h"
|
#include "CCEGLView.h"
|
||||||
|
|
||||||
#include <ppapi/cpp/instance.h>
|
#include <ppapi/cpp/instance.h>
|
||||||
#include <ppapi/cpp/module.h>
|
#include <ppapi/cpp/module.h>
|
||||||
#ifndef OLD_NACL_MOUNTS
|
#include <nacl_io/nacl_io.h>
|
||||||
#include "nacl_io/nacl_io.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -42,9 +41,6 @@ THE SOFTWARE.
|
||||||
USING_NS_CC;
|
USING_NS_CC;
|
||||||
|
|
||||||
CocosPepperInstance::CocosPepperInstance(PP_Instance instance) : pp::Instance(instance),
|
CocosPepperInstance::CocosPepperInstance(PP_Instance instance) : pp::Instance(instance),
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
_runner(NULL),
|
|
||||||
#endif
|
|
||||||
_running(false)
|
_running(false)
|
||||||
{
|
{
|
||||||
RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
|
RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
|
||||||
|
@ -78,14 +74,10 @@ void CocosPepperInstance::DidChangeView(const pp::View& view)
|
||||||
|
|
||||||
bool CocosPepperInstance::Init(uint32_t argc, const char* argn[], const char* argv[])
|
bool CocosPepperInstance::Init(uint32_t argc, const char* argn[], const char* argv[])
|
||||||
{
|
{
|
||||||
CCLog("CocosPepperInstance::Init");
|
CCLog("CocosPepperInstance::Init: %x %p", pp_instance(),
|
||||||
#ifdef OLD_NACL_MOUNTS
|
pp::Module::Get()->get_browser_interface());
|
||||||
_runner = new MainThreadRunner(this);
|
nacl_io_init_ppapi(pp_instance(),
|
||||||
#else
|
pp::Module::Get()->get_browser_interface());
|
||||||
CCLOG("%p %p", (void*)pp_instance(), (void*)pp::Module::Get()->get_browser_interface());
|
|
||||||
nacl_io_init_ppapi(pp_instance(), pp::Module::Get()->get_browser_interface());
|
|
||||||
CCLOG("done nacl_mounts_init_ppapi");
|
|
||||||
|
|
||||||
|
|
||||||
umount("/");
|
umount("/");
|
||||||
int rtn = mount("Resources", /* source. Use relative URL */
|
int rtn = mount("Resources", /* source. Use relative URL */
|
||||||
|
@ -100,7 +92,6 @@ bool CocosPepperInstance::Init(uint32_t argc, const char* argn[], const char* ar
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,23 +29,13 @@ THE SOFTWARE.
|
||||||
#include <ppapi/cpp/input_event.h>
|
#include <ppapi/cpp/input_event.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
#include "nacl-mounts/base/MainThreadRunner.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern "C" void* cocos_main(void* arg);
|
extern "C" void* cocos_main(void* arg);
|
||||||
|
|
||||||
class CocosPepperInstance : public pp::Instance {
|
class CocosPepperInstance : public pp::Instance {
|
||||||
public:
|
public:
|
||||||
explicit CocosPepperInstance(PP_Instance instance);
|
explicit CocosPepperInstance(PP_Instance instance);
|
||||||
|
|
||||||
virtual ~CocosPepperInstance()
|
virtual ~CocosPepperInstance() {}
|
||||||
{
|
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
if (_runner)
|
|
||||||
delete _runner;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]);
|
virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]);
|
||||||
|
|
||||||
|
@ -55,9 +45,6 @@ public:
|
||||||
|
|
||||||
pp::Size Size() { return _size; }
|
pp::Size Size() { return _size; }
|
||||||
|
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
MainThreadRunner* _runner;
|
|
||||||
#endif
|
|
||||||
private:
|
private:
|
||||||
pp::Size _size;
|
pp::Size _size;
|
||||||
pthread_t _cocos_thread;
|
pthread_t _cocos_thread;
|
||||||
|
|
|
@ -2,6 +2,16 @@
|
||||||
# when building for Native Client. It defines a set of variables that all
|
# when building for Native Client. It defines a set of variables that all
|
||||||
# cocos2dx projects have in common.
|
# cocos2dx projects have in common.
|
||||||
|
|
||||||
|
ifeq ($(NACL_SDK_ROOT),)
|
||||||
|
$(error $$NACL_SDK_ROOT not set)
|
||||||
|
endif
|
||||||
|
|
||||||
|
NACL_SDK_VERSION_MIN=27.186236
|
||||||
|
VERSION_CHECK:=$(shell $(NACL_SDK_ROOT)/tools/getos.py --check-version=$(NACL_SDK_VERSION_MIN) 2>&1)
|
||||||
|
ifneq ($(VERSION_CHECK),)
|
||||||
|
$(error $(VERSION_CHECK))
|
||||||
|
endif
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
|
||||||
NACL_LIBC = newlib
|
NACL_LIBC = newlib
|
||||||
|
@ -95,16 +105,9 @@ CCFLAGS += -Wno-psabi
|
||||||
CXXFLAGS += -Wno-psabi
|
CXXFLAGS += -Wno-psabi
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef NACL_MOUNTS
|
|
||||||
DEFINES += -DOLD_NACL_MOUNTS
|
|
||||||
STATICLIBS += -lnacl-mounts
|
|
||||||
else
|
|
||||||
STATICLIBS += -lnacl_io
|
|
||||||
endif
|
|
||||||
|
|
||||||
SOUNDLIBS := -lalut -lopenal -lvorbisfile -lvorbis -logg
|
SOUNDLIBS := -lalut -lopenal -lvorbisfile -lvorbis -logg
|
||||||
STATICLIBS += $(SOUNDLIBS) -lfreetype -lxml2 -lwebp -lpng -ljpeg -ltiff -llua -lchipmunk
|
STATICLIBS += $(SOUNDLIBS) -lfreetype -lxml2 -lwebp -lpng -ljpeg -ltiff -llua -lchipmunk
|
||||||
STATICLIBS += -lppapi_gles2 -lppapi -lppapi_cpp -lnosys
|
STATICLIBS += -lnacl_io -lppapi_gles2 -lppapi -lppapi_cpp -lnosys
|
||||||
SHAREDLIBS += -lpthread -lcocosdenshion -lcocos2d -lz
|
SHAREDLIBS += -lpthread -lcocosdenshion -lcocos2d -lz
|
||||||
|
|
||||||
OBJECTS := $(SOURCES:.cpp=.o)
|
OBJECTS := $(SOURCES:.cpp=.o)
|
||||||
|
|
|
@ -9,70 +9,13 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
#include "nacl-mounts/base/UrlLoaderJob.h"
|
|
||||||
#endif
|
|
||||||
#include "fcntl.h"
|
|
||||||
#include "sys/stat.h"
|
|
||||||
|
|
||||||
USING_NS_CC;
|
USING_NS_CC;
|
||||||
|
|
||||||
AppDelegate g_app;
|
AppDelegate g_app;
|
||||||
|
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
void downloadFiles(MainThreadRunner* runner, const char** filenames, int num_files)
|
|
||||||
{
|
|
||||||
CCLOG("Downloading %d files...", num_files);
|
|
||||||
for (int i = 0; i < num_files; i++)
|
|
||||||
{
|
|
||||||
std::vector<char> data;
|
|
||||||
const char* filename = filenames[i];
|
|
||||||
std::string url = "Resources/";
|
|
||||||
url += filename;
|
|
||||||
|
|
||||||
CCLOG("Downloading: %s -> %s", url.c_str(), filename);
|
|
||||||
UrlLoaderJob *job = new UrlLoaderJob;
|
|
||||||
job->set_url(url);
|
|
||||||
job->set_dst(&data);
|
|
||||||
runner->RunJob(job);
|
|
||||||
CCLOG("Got %d bytes", data.size());
|
|
||||||
|
|
||||||
CCLOG("Writing file: %s", filename);
|
|
||||||
int fd = open(filename, O_CREAT | O_WRONLY);
|
|
||||||
if (fd == -1)
|
|
||||||
{
|
|
||||||
CCLOG("Error writing file: %s", filename);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
write(fd, &data[0], data.size());
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void* cocos_main(void* arg)
|
void* cocos_main(void* arg)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "in cocos_main\n");
|
fprintf(stderr, "in cocos_main\n");
|
||||||
|
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
// TODO(sbc): remove this hack an replace with some kind of URL mount
|
|
||||||
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
|
|
||||||
|
|
||||||
mkdir("ipad", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
|
||||||
mkdir("iphone", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
|
||||||
mkdir("fonts", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
|
||||||
const char* filenames[] = { "ipad/HelloWorld.png",
|
|
||||||
"ipad/CloseSelected.png",
|
|
||||||
"ipad/CloseNormal.png",
|
|
||||||
"iphone/HelloWorld.png",
|
|
||||||
"iphone/CloseSelected.png",
|
|
||||||
"iphone/CloseNormal.png",
|
|
||||||
"fonts/Marker Felt.ttf" };
|
|
||||||
|
|
||||||
downloadFiles(instance->_runner, filenames, sizeof(filenames)/sizeof(char*));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fprintf(stderr, "calling application->run\n");
|
|
||||||
int rtn = Application::sharedApplication()->run();
|
int rtn = Application::sharedApplication()->run();
|
||||||
fprintf(stderr, "app run returned: %d\n", rtn);
|
fprintf(stderr, "app run returned: %d\n", rtn);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -10,73 +10,15 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "AL/alc.h"
|
#include "AL/alc.h"
|
||||||
|
|
||||||
#include "fcntl.h"
|
|
||||||
#include "sys/stat.h"
|
|
||||||
|
|
||||||
USING_NS_CC;
|
USING_NS_CC;
|
||||||
|
|
||||||
AppDelegate g_app;
|
AppDelegate g_app;
|
||||||
|
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
#include "nacl-mounts/base/UrlLoaderJob.h"
|
|
||||||
void downloadFiles(MainThreadRunner* runner, const char** filenames, int num_files)
|
|
||||||
{
|
|
||||||
CCLOG("Downloading %d files...", num_files);
|
|
||||||
for (int i = 0; i < num_files; i++)
|
|
||||||
{
|
|
||||||
std::vector<char> data;
|
|
||||||
const char* filename = filenames[i];
|
|
||||||
std::string url = "Resources/";
|
|
||||||
url += filename;
|
|
||||||
|
|
||||||
CCLOG("Downloading: %s -> %s", url.c_str(), filename);
|
|
||||||
UrlLoaderJob *job = new UrlLoaderJob;
|
|
||||||
job->set_url(url);
|
|
||||||
job->set_dst(&data);
|
|
||||||
runner->RunJob(job);
|
|
||||||
CCLOG("Got %d bytes", data.size());
|
|
||||||
|
|
||||||
CCLOG("Writing file: %s", filename);
|
|
||||||
int fd = open(filename, O_CREAT | O_WRONLY);
|
|
||||||
if (fd == -1)
|
|
||||||
{
|
|
||||||
CCLOG("Error writing file: %s", filename);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
write(fd, &data[0], data.size());
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void* cocos_main(void* arg)
|
void* cocos_main(void* arg)
|
||||||
{
|
{
|
||||||
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
|
|
||||||
fprintf(stderr, "in cocos_main\n");
|
fprintf(stderr, "in cocos_main\n");
|
||||||
|
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
|
||||||
alSetPpapiInfo(instance->pp_instance(), pp::Module::Get()->get_browser_interface());
|
alSetPpapiInfo(instance->pp_instance(), pp::Module::Get()->get_browser_interface());
|
||||||
|
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
// TODO(sbc): remove this hack an replace with some kind of URL mount
|
|
||||||
mkdir("hd", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
|
||||||
mkdir("sd", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
|
||||||
mkdir("fonts", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
|
||||||
const char* filenames[] = { "hd/CloseNormal.png",
|
|
||||||
"sd/CloseNormal.png",
|
|
||||||
"hd/CloseSelected.png",
|
|
||||||
"sd/CloseSelected.png",
|
|
||||||
"hd/Target.png",
|
|
||||||
"sd/Target.png",
|
|
||||||
"hd/Player.png",
|
|
||||||
"sd/Player.png",
|
|
||||||
"hd/Projectile.png",
|
|
||||||
"sd/Projectile.png",
|
|
||||||
"pew-pew-lei.wav",
|
|
||||||
"fonts/Marker Felt.ttf" };
|
|
||||||
|
|
||||||
downloadFiles(instance->_runner, filenames, sizeof(filenames)/sizeof(char*));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fprintf(stderr, "calling application->run\n");
|
fprintf(stderr, "calling application->run\n");
|
||||||
int rtn = Application::sharedApplication()->run();
|
int rtn = Application::sharedApplication()->run();
|
||||||
fprintf(stderr, "app run returned: %d\n", rtn);
|
fprintf(stderr, "app run returned: %d\n", rtn);
|
||||||
|
|
|
@ -8,129 +8,17 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <AL/alc.h>
|
#include <AL/alc.h>
|
||||||
|
|
||||||
|
|
||||||
USING_NS_CC;
|
USING_NS_CC;
|
||||||
|
|
||||||
AppDelegate g_app;
|
AppDelegate g_app;
|
||||||
|
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
#include "nacl-mounts/base/UrlLoaderJob.h"
|
|
||||||
void downloadFiles(MainThreadRunner* runner, const char** filenames, int num_files)
|
|
||||||
{
|
|
||||||
CCLOG("Downloading %d files...", num_files);
|
|
||||||
for (int i = 0; i < num_files; i++)
|
|
||||||
{
|
|
||||||
std::vector<char> data;
|
|
||||||
const char* filename = filenames[i];
|
|
||||||
std::string url = "Resources/";
|
|
||||||
url += filename;
|
|
||||||
|
|
||||||
CCLOG("Downloading: %s -> %s", url.c_str(), filename);
|
|
||||||
UrlLoaderJob *job = new UrlLoaderJob;
|
|
||||||
job->set_url(url);
|
|
||||||
job->set_dst(&data);
|
|
||||||
runner->RunJob(job);
|
|
||||||
CCLOG("Got %d bytes", data.size());
|
|
||||||
|
|
||||||
CCLOG("Writing file: %s", filename);
|
|
||||||
int fd = open(filename, O_CREAT | O_WRONLY);
|
|
||||||
if (fd == -1)
|
|
||||||
{
|
|
||||||
assert("error writing file");
|
|
||||||
CCLOG("Error writing file: %s", filename);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
write(fd, &data[0], data.size());
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void* cocos_main(void* arg)
|
void* cocos_main(void* arg)
|
||||||
{
|
{
|
||||||
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
|
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
|
||||||
fprintf(stderr, "in cocos_main %p\n", instance);
|
fprintf(stderr, "in cocos_main: %p\n", instance);
|
||||||
|
|
||||||
alSetPpapiInfo(instance->pp_instance(), pp::Module::Get()->get_browser_interface());
|
alSetPpapiInfo(instance->pp_instance(), pp::Module::Get()->get_browser_interface());
|
||||||
|
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
// TODO(sbc): remove this hack an replace with some kind of URL mount
|
|
||||||
const char* dirnames[] = { "Images", "extensions", "fonts", "ccb",
|
|
||||||
"zwoptex", "Particles", "Shaders", "TileMaps" };
|
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof(dirnames)/sizeof(char*); i++)
|
|
||||||
mkdir(dirnames[i], S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
|
||||||
|
|
||||||
const char* filenames[] = { "Images/grossini.png",
|
|
||||||
"Images/close.png",
|
|
||||||
"Images/ball.png",
|
|
||||||
"Images/paddle.png",
|
|
||||||
"Images/grossinis_sister1.png",
|
|
||||||
"Images/grossinis_sister2.png",
|
|
||||||
"Images/grossini_dance_01.png",
|
|
||||||
"Images/background1.png",
|
|
||||||
"Images/background2.png",
|
|
||||||
"Images/background3.png",
|
|
||||||
"Images/f1.png",
|
|
||||||
"Images/f2.png",
|
|
||||||
"Images/r1.png",
|
|
||||||
"Images/r2.png",
|
|
||||||
"Images/b1.png",
|
|
||||||
"Images/b2.png",
|
|
||||||
"Images/blocks.png",
|
|
||||||
"Images/Icon.png",
|
|
||||||
"Images/streak.png",
|
|
||||||
"Images/fire.png",
|
|
||||||
"Images/white-512x512.png",
|
|
||||||
"Images/test_1021x1024_rgb888.pvr.gz",
|
|
||||||
"Images/test_1021x1024.png",
|
|
||||||
"Images/grossini_dance_atlas.png",
|
|
||||||
"Images/powered.png",
|
|
||||||
"Images/background.png",
|
|
||||||
"TileMaps/levelmap.tga",
|
|
||||||
"TileMaps/tiles.png",
|
|
||||||
"fps_images.png",
|
|
||||||
"Shaders/example_Monjori.vsh",
|
|
||||||
"Shaders/example_Monjori.fsh",
|
|
||||||
"Shaders/example_Mandelbrot.vsh",
|
|
||||||
"Shaders/example_Mandelbrot.fsh",
|
|
||||||
"Shaders/example_Julia.vsh",
|
|
||||||
"Shaders/example_Julia.fsh",
|
|
||||||
"Shaders/example_Plasma.vsh",
|
|
||||||
"Shaders/example_Plasma.fsh",
|
|
||||||
"Shaders/example_Heart.vsh",
|
|
||||||
"Shaders/example_Heart.fsh",
|
|
||||||
"Shaders/example_Flower.vsh",
|
|
||||||
"Shaders/example_Flower.fsh",
|
|
||||||
"Shaders/example_Blur.fsh",
|
|
||||||
"Shaders/example_HorizontalColor.vsh",
|
|
||||||
"Shaders/example_HorizontalColor.fsh",
|
|
||||||
"Particles/SmallSun.plist",
|
|
||||||
"Particles/LavaFlow.plist",
|
|
||||||
"fonts/arial.ttf",
|
|
||||||
"fonts/west_england-64.fnt",
|
|
||||||
"fonts/west_england-64.png",
|
|
||||||
"fonts/Thonburi.ttf",
|
|
||||||
"fonts/Marker Felt.ttf",
|
|
||||||
"ccb/HelloCocosBuilder.ccbi",
|
|
||||||
"ccb/burst.png",
|
|
||||||
"effect1.wav",
|
|
||||||
"background.mp3",
|
|
||||||
"extensions/sliderTrack.png",
|
|
||||||
"extensions/sliderProgress.png",
|
|
||||||
"extensions/sliderThumb.png",
|
|
||||||
"extensions/background.png",
|
|
||||||
"extensions/ribbon.png",
|
|
||||||
"zwoptex/grossini.plist",
|
|
||||||
"zwoptex/grossini.png" };
|
|
||||||
|
|
||||||
downloadFiles(instance->_runner, filenames, sizeof(filenames)/sizeof(char*));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fprintf(stderr, "calling application->run\n");
|
fprintf(stderr, "calling application->run\n");
|
||||||
int rtn = Application::sharedApplication()->run();
|
int rtn = Application::sharedApplication()->run();
|
||||||
fprintf(stderr, "app run returned: %d\n", rtn);
|
fprintf(stderr, "app run returned: %d\n", rtn);
|
||||||
|
|
|
@ -17,62 +17,11 @@ USING_NS_CC;
|
||||||
|
|
||||||
AppDelegate g_app;
|
AppDelegate g_app;
|
||||||
|
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
#include "nacl-mounts/base/UrlLoaderJob.h"
|
|
||||||
void downloadFiles(MainThreadRunner* runner, const char** filenames, int num_files)
|
|
||||||
{
|
|
||||||
CCLOG("Downloading %d files...", num_files);
|
|
||||||
for (int i = 0; i < num_files; i++)
|
|
||||||
{
|
|
||||||
std::vector<char> data;
|
|
||||||
const char* filename = filenames[i];
|
|
||||||
std::string url = "Resources/";
|
|
||||||
url += filename;
|
|
||||||
|
|
||||||
CCLOG("Downloading: %s -> %s", url.c_str(), filename);
|
|
||||||
UrlLoaderJob *job = new UrlLoaderJob;
|
|
||||||
job->set_url(url);
|
|
||||||
job->set_dst(&data);
|
|
||||||
runner->RunJob(job);
|
|
||||||
CCLOG("Got %d bytes", data.size());
|
|
||||||
|
|
||||||
CCLOG("Writing file: %s", filename);
|
|
||||||
int fd = open(filename, O_CREAT | O_WRONLY);
|
|
||||||
if (fd == -1)
|
|
||||||
{
|
|
||||||
CCLOG("Error writing file: %s", filename);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
write(fd, &data[0], data.size());
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void* cocos_main(void* arg)
|
void* cocos_main(void* arg)
|
||||||
{
|
{
|
||||||
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
|
|
||||||
fprintf(stderr, "in cocos_main\n");
|
fprintf(stderr, "in cocos_main\n");
|
||||||
|
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
|
||||||
alSetPpapiInfo(instance->pp_instance(), pp::Module::Get()->get_browser_interface());
|
alSetPpapiInfo(instance->pp_instance(), pp::Module::Get()->get_browser_interface());
|
||||||
|
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
// TODO(sbc): remove this hack an replace with some kind of URL mount
|
|
||||||
mkdir("fonts", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
|
||||||
const char* filenames[] = { "hello.lua",
|
|
||||||
"hello2.lua",
|
|
||||||
"farm.jpg",
|
|
||||||
"land.png",
|
|
||||||
"menu1.png",
|
|
||||||
"menu2.png",
|
|
||||||
"crop.png",
|
|
||||||
"dog.png",
|
|
||||||
"effect1.wav",
|
|
||||||
"background.ogg",
|
|
||||||
"fonts/Marker Felt.ttf" };
|
|
||||||
|
|
||||||
downloadFiles(instance->_runner, filenames, sizeof(filenames)/sizeof(char*));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fprintf(stderr, "calling application->run\n");
|
fprintf(stderr, "calling application->run\n");
|
||||||
int rtn = Application::sharedApplication()->run();
|
int rtn = Application::sharedApplication()->run();
|
||||||
fprintf(stderr, "app run returned: %d\n", rtn);
|
fprintf(stderr, "app run returned: %d\n", rtn);
|
||||||
|
|
|
@ -10,128 +10,15 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <AL/alc.h>
|
#include <AL/alc.h>
|
||||||
|
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
#include "nacl-mounts/base/UrlLoaderJob.h"
|
|
||||||
#include "fcntl.h"
|
|
||||||
#include "sys/stat.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
USING_NS_CC;
|
USING_NS_CC;
|
||||||
|
|
||||||
AppDelegate g_app;
|
AppDelegate g_app;
|
||||||
|
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
void downloadFiles(MainThreadRunner* runner, const char** filenames, int num_files)
|
|
||||||
{
|
|
||||||
CCLOG("Downloading %d files...", num_files);
|
|
||||||
for (int i = 0; i < num_files; i++)
|
|
||||||
{
|
|
||||||
std::vector<char> data;
|
|
||||||
const char* filename = filenames[i];
|
|
||||||
std::string url = "Resources/";
|
|
||||||
url += filename;
|
|
||||||
|
|
||||||
CCLOG("Downloading: %s -> %s", url.c_str(), filename);
|
|
||||||
UrlLoaderJob *job = new UrlLoaderJob;
|
|
||||||
job->set_url(url);
|
|
||||||
job->set_dst(&data);
|
|
||||||
runner->RunJob(job);
|
|
||||||
CCLOG("Got %d bytes", data.size());
|
|
||||||
|
|
||||||
CCLOG("Writing file: %s", filename);
|
|
||||||
int fd = open(filename, O_CREAT | O_WRONLY);
|
|
||||||
if (fd == -1)
|
|
||||||
{
|
|
||||||
CCLOG("Error writing file: %s", filename);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
write(fd, &data[0], data.size());
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void* cocos_main(void* arg)
|
void* cocos_main(void* arg)
|
||||||
{
|
{
|
||||||
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
|
|
||||||
fprintf(stderr, "in cocos_main\n");
|
fprintf(stderr, "in cocos_main\n");
|
||||||
|
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
|
||||||
alSetPpapiInfo(instance->pp_instance(), pp::Module::Get()->get_browser_interface());
|
alSetPpapiInfo(instance->pp_instance(), pp::Module::Get()->get_browser_interface());
|
||||||
|
|
||||||
#ifdef OLD_NACL_MOUNTS
|
|
||||||
// TODO(sbc): remove this hack an replace with some kind of URL mount
|
|
||||||
const char* dirnames[] = { "Images", "extensions", "fonts", "ccb",
|
|
||||||
"zwoptex", "Particles", "Shaders", "luaScript",
|
|
||||||
"luaScript/ActionsTest" };
|
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof(dirnames)/sizeof(char*); i++)
|
|
||||||
mkdir(dirnames[i], S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
|
||||||
|
|
||||||
const char* filenames[] = { "Images/grossini.png",
|
|
||||||
"Images/close.png",
|
|
||||||
"Images/grossinis_sister1.png",
|
|
||||||
"Images/grossinis_sister2.png",
|
|
||||||
"Images/grossini_dance_01.png",
|
|
||||||
"Images/background1.png",
|
|
||||||
"Images/background2.png",
|
|
||||||
"Images/background3.png",
|
|
||||||
"Images/f1.png",
|
|
||||||
"Images/f2.png",
|
|
||||||
"Images/r1.png",
|
|
||||||
"Images/r2.png",
|
|
||||||
"Images/b1.png",
|
|
||||||
"Images/b2.png",
|
|
||||||
"Images/blocks.png",
|
|
||||||
"Images/Icon.png",
|
|
||||||
"Images/streak.png",
|
|
||||||
"Images/fire.png",
|
|
||||||
"Images/white-512x512.png",
|
|
||||||
"Images/test_1021x1024_rgb888.pvr.gz",
|
|
||||||
"Images/test_1021x1024.png",
|
|
||||||
"Images/grossini_dance_atlas.png",
|
|
||||||
"fps_images.png",
|
|
||||||
"Shaders/example_Monjori.vsh",
|
|
||||||
"Shaders/example_Monjori.fsh",
|
|
||||||
"Shaders/example_Mandelbrot.vsh",
|
|
||||||
"Shaders/example_Mandelbrot.fsh",
|
|
||||||
"Shaders/example_Julia.vsh",
|
|
||||||
"Shaders/example_Julia.fsh",
|
|
||||||
"Shaders/example_Plasma.vsh",
|
|
||||||
"Shaders/example_Plasma.fsh",
|
|
||||||
"Shaders/example_Heart.vsh",
|
|
||||||
"Shaders/example_Heart.fsh",
|
|
||||||
"Shaders/example_Flower.vsh",
|
|
||||||
"Shaders/example_Flower.fsh",
|
|
||||||
"Shaders/example_Blur.fsh",
|
|
||||||
"Shaders/example_HorizontalColor.vsh",
|
|
||||||
"Shaders/example_HorizontalColor.fsh",
|
|
||||||
"Particles/SmallSun.plist",
|
|
||||||
"Particles/LavaFlow.plist",
|
|
||||||
"fonts/arial.ttf",
|
|
||||||
"fonts/west_england-64.fnt",
|
|
||||||
"fonts/west_england-64.png",
|
|
||||||
"fonts/Thonburi.ttf",
|
|
||||||
"fonts/Marker Felt.ttf",
|
|
||||||
"ccb/HelloCocosBuilder.ccbi",
|
|
||||||
"ccb/burst.png",
|
|
||||||
"effect1.wav",
|
|
||||||
"background.mp3",
|
|
||||||
"extensions/sliderTrack.png",
|
|
||||||
"extensions/sliderProgress.png",
|
|
||||||
"extensions/sliderThumb.png",
|
|
||||||
"extensions/background.png",
|
|
||||||
"extensions/ribbon.png",
|
|
||||||
"zwoptex/grossini.plist",
|
|
||||||
"zwoptex/grossini.png",
|
|
||||||
"luaScript/mainMenu.lua",
|
|
||||||
"luaScript/helper.lua",
|
|
||||||
"luaScript/testResource.lua",
|
|
||||||
"luaScript/ActionsTest/ActionsTest.lua",
|
|
||||||
"luaScript/ActionsTest/ActionsName.lua",
|
|
||||||
"luaScript/controller.lua" };
|
|
||||||
|
|
||||||
downloadFiles(instance->_runner, filenames, sizeof(filenames)/sizeof(char*));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fprintf(stderr, "calling application->run\n");
|
fprintf(stderr, "calling application->run\n");
|
||||||
int rtn = Application::sharedApplication()->run();
|
int rtn = Application::sharedApplication()->run();
|
||||||
fprintf(stderr, "app run returned: %d\n", rtn);
|
fprintf(stderr, "app run returned: %d\n", rtn);
|
||||||
|
|
Loading…
Reference in New Issue