Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: nacltoons/src/main.cc

Issue 12472014: [nacltoons] Remove legacy nacl_mounts support. (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « nacltoons/game.mk ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 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 #include "CCStdC.h" 4 #include "CCStdC.h"
5 #include "cocos2d.h" 5 #include "cocos2d.h"
6 #include "CCInstance.h" 6 #include "CCInstance.h"
7 #include "CCModule.h" 7 #include "CCModule.h"
8 8
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <stdio.h> 10 #include <stdio.h>
11 #include <unistd.h> 11 #include <unistd.h>
12 #include <string> 12 #include <string>
13 #include <fcntl.h> 13 #include <fcntl.h>
14 #include <sys/stat.h> 14 #include <sys/stat.h>
15 #include <AL/alc.h> 15 #include <AL/alc.h>
16 16
17 #include "app_delegate.h" 17 #include "app_delegate.h"
18 18
19 #ifdef OLD_NACL_MOUNTS
20 #include "nacl-mounts/base/UrlLoaderJob.h"
21 #endif
22
23 USING_NS_CC; 19 USING_NS_CC;
24 20
25 AppDelegate g_app; 21 AppDelegate g_app;
26 22
27 #ifdef OLD_NACL_MOUNTS
28 void DownloadFiles(MainThreadRunner* runner,
29 const char** filenames, int num_files) {
30 CCLOG("Downloading %d files...", num_files);
31 for (int i = 0; i < num_files; i++) {
32 std::vector<char> data;
33 const char* filename = filenames[i];
34 std::string url = "res/";
35 url += filename;
36
37 CCLOG("Downloading: %s -> %s", url.c_str(), filename);
38 UrlLoaderJob *job = new UrlLoaderJob;
39 job->set_url(url);
40 job->set_dst(&data);
41 runner->RunJob(job);
42 CCLOG("Got %d bytes", data.size());
43
44 CCLOG("Writing file: %s", filename);
45 int fd = open(filename, O_CREAT | O_WRONLY);
46 if (fd == -1) {
47 CCLOG("Error writing file: %s", filename);
48 continue;
49 }
50 write(fd, &data[0], data.size());
51 close(fd);
52 }
53 }
54 #endif
55
56 void* cocos_main(void* arg) { 23 void* cocos_main(void* arg) {
57 CocosPepperInstance* instance = (CocosPepperInstance*)arg; 24 CocosPepperInstance* instance = (CocosPepperInstance*)arg;
58 fprintf(stderr, "in cocos_main\n"); 25 fprintf(stderr, "in cocos_main\n");
59 26
60 // Any application that uses OpenAL on NaCl needs to call this 27 // Any application that uses OpenAL on NaCl needs to call this
61 // before starting OpenAL. 28 // before starting OpenAL.
62 alSetPpapiInfo(instance->pp_instance(), 29 alSetPpapiInfo(instance->pp_instance(),
63 pp::Module::Get()->get_browser_interface()); 30 pp::Module::Get()->get_browser_interface());
64 31
65 #ifdef OLD_NACL_MOUNTS
66 // TODO(sbc): remove this hack an replace with some kind of URL mount
67 mkdir("fonts", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
68 mkdir("sample_game", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
69 mkdir("sample_game/images", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
70 const char* filenames[] = { "fonts/Marker Felt.ttf",
71 "loader.lua",
72 "sample_game/images/brush.png",
73 "sample_game/images/ball.png",
74 "sample_game/images/goal.png",
75 "sample_game/images/star.png",
76 "sample_game/game.lua",
77 "sample_game/level1.lua",
78 "sample_game/level2.lua" };
79
80 DownloadFiles(instance->m_runner, filenames, sizeof(filenames)/sizeof(char*));
81 #endif
82
83 CCEGLView::g_instance = instance; 32 CCEGLView::g_instance = instance;
84 CCEGLView* eglView = CCEGLView::sharedOpenGLView(); 33 CCEGLView* eglView = CCEGLView::sharedOpenGLView();
85 fprintf(stderr, "calling setFrameSize\n"); 34 fprintf(stderr, "calling setFrameSize\n");
86 eglView->setFrameSize(instance->Size().width(), instance->Size().height()); 35 eglView->setFrameSize(instance->Size().width(), instance->Size().height());
87 fprintf(stderr, "calling application->run\n"); 36 fprintf(stderr, "calling application->run\n");
88 int rtn = CCApplication::sharedApplication()->run(); 37 int rtn = CCApplication::sharedApplication()->run();
89 fprintf(stderr, "app run returned: %d\n", rtn); 38 fprintf(stderr, "app run returned: %d\n", rtn);
90 return NULL; 39 return NULL;
91 } 40 }
92 41
93 namespace pp { 42 namespace pp {
94 Module* CreateModule() { 43 Module* CreateModule() {
95 return new CocosPepperModule(); 44 return new CocosPepperModule();
96 } 45 }
97 } 46 }
OLDNEW
« no previous file with comments | « nacltoons/game.mk ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698