OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | |
5 #include "CCStdC.h" | 4 #include "CCStdC.h" |
6 #include "AppDelegate.h" | 5 #include "AppDelegate.h" |
7 #include "cocos2d.h" | 6 #include "cocos2d.h" |
8 #include "CCInstance.h" | 7 #include "CCInstance.h" |
9 #include "CCModule.h" | 8 #include "CCModule.h" |
10 | 9 |
11 #include <stdlib.h> | 10 #include <stdlib.h> |
12 #include <stdio.h> | 11 #include <stdio.h> |
13 #include <unistd.h> | 12 #include <unistd.h> |
14 #include <string> | 13 #include <string> |
15 #include <fcntl.h> | 14 #include <fcntl.h> |
16 #include <sys/stat.h> | 15 #include <sys/stat.h> |
17 #include <AL/alc.h> | 16 #include <AL/alc.h> |
18 | 17 |
19 #include "nacl-mounts/base/UrlLoaderJob.h" | 18 #include "nacl-mounts/base/UrlLoaderJob.h" |
20 | 19 |
21 USING_NS_CC; | 20 USING_NS_CC; |
22 | 21 |
23 AppDelegate g_app; | 22 AppDelegate g_app; |
24 | 23 |
25 void downloadFiles(MainThreadRunner* runner, | 24 void DownloadFiles(MainThreadRunner* runner, |
26 const char** filenames, int num_files) { | 25 const char** filenames, int num_files) { |
27 CCLOG("Downloading %d files...", num_files); | 26 CCLOG("Downloading %d files...", num_files); |
28 for (int i = 0; i < num_files; i++) { | 27 for (int i = 0; i < num_files; i++) { |
29 std::vector<char> data; | 28 std::vector<char> data; |
30 const char* filename = filenames[i]; | 29 const char* filename = filenames[i]; |
31 std::string url = "res/"; | 30 std::string url = "res/"; |
32 url += filename; | 31 url += filename; |
33 | 32 |
34 CCLOG("Downloading: %s -> %s", url.c_str(), filename); | 33 CCLOG("Downloading: %s -> %s", url.c_str(), filename); |
35 UrlLoaderJob *job = new UrlLoaderJob; | 34 UrlLoaderJob *job = new UrlLoaderJob; |
(...skipping 16 matching lines...) Expand all Loading... |
52 void* cocos_main(void* arg) { | 51 void* cocos_main(void* arg) { |
53 CocosPepperInstance* instance = (CocosPepperInstance*)arg; | 52 CocosPepperInstance* instance = (CocosPepperInstance*)arg; |
54 fprintf(stderr, "in cocos_main\n"); | 53 fprintf(stderr, "in cocos_main\n"); |
55 | 54 |
56 // Any application that uses OpenAL on NaCl needs to call this | 55 // Any application that uses OpenAL on NaCl needs to call this |
57 // before starting OpenAL. | 56 // before starting OpenAL. |
58 alSetPpapiInfo(instance->pp_instance(), | 57 alSetPpapiInfo(instance->pp_instance(), |
59 pp::Module::Get()->get_browser_interface()); | 58 pp::Module::Get()->get_browser_interface()); |
60 | 59 |
61 // TODO(sbc): remove this hack an replace with some kind of URL mount | 60 // TODO(sbc): remove this hack an replace with some kind of URL mount |
62 mkdir("hd", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); | |
63 mkdir("sd", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); | |
64 mkdir("fonts", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); | 61 mkdir("fonts", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); |
65 const char* filenames[] = { "fonts/Marker Felt.ttf" }; | 62 const char* filenames[] = { "fonts/Marker Felt.ttf", "blocks.png" }; |
66 | 63 |
67 downloadFiles(instance->m_runner, filenames, sizeof(filenames)/sizeof(char*)); | 64 DownloadFiles(instance->m_runner, filenames, sizeof(filenames)/sizeof(char*)); |
68 | 65 |
69 CCEGLView::g_instance = instance; | 66 CCEGLView::g_instance = instance; |
70 CCEGLView* eglView = CCEGLView::sharedOpenGLView(); | 67 CCEGLView* eglView = CCEGLView::sharedOpenGLView(); |
71 fprintf(stderr, "calling setFrameSize\n"); | 68 fprintf(stderr, "calling setFrameSize\n"); |
72 eglView->setFrameSize(instance->Size().width(), instance->Size().height()); | 69 eglView->setFrameSize(instance->Size().width(), instance->Size().height()); |
73 fprintf(stderr, "calling application->run\n"); | 70 fprintf(stderr, "calling application->run\n"); |
74 int rtn = CCApplication::sharedApplication()->run(); | 71 int rtn = CCApplication::sharedApplication()->run(); |
75 fprintf(stderr, "app run returned: %d\n", rtn); | 72 fprintf(stderr, "app run returned: %d\n", rtn); |
76 return NULL; | 73 return NULL; |
77 } | 74 } |
78 | 75 |
79 namespace pp { | 76 namespace pp { |
80 Module* CreateModule() { | 77 Module* CreateModule() { |
81 return new CocosPepperModule(); | 78 return new CocosPepperModule(); |
82 } | 79 } |
83 } | 80 } |
OLD | NEW |