annotate Renderer/Engine/main.cc @ 1127:c4287bf771a0 draft

CreatePolygonFromSceneGraph can work on Mac OSX.
author Yutaka_Kinjyo
date Sun, 13 Feb 2011 23:27:22 +0900
parents 19bfb73617ad
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include "TaskManager.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include "viewer.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include "viewerSDL.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "viewerFB.h"
922
cb1023423861 moving OpenGL mode now!
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 914
diff changeset
5 #include "viewerGL.h"
981
fdb36a9c5030 add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 944
diff changeset
6 #include "viewerPS3.h"
1111
c9d0683c9b39 add non screen mode.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 985
diff changeset
7 #include "viewerNONE.h"
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
8 #include "Application.h"
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 /* prototype */
556
12135dde3b87 Cerium no error.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 541
diff changeset
11 extern int init(TaskManager *manager, int argc, char *argv[]);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 extern void task_initialize();
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
14 extern Application *application();
556
12135dde3b87 Cerium no error.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 541
diff changeset
15 extern int init(TaskManager *manager, int argc, char *argv[]);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
556
12135dde3b87 Cerium no error.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 541
diff changeset
17 // 大域変数は禁止
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 //static Viewer *screen;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
556
12135dde3b87 Cerium no error.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 541
diff changeset
20 /*
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n\
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 -cpu Number of SPE (default 1)\n\
895
b662e9dd26b0 add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 728
diff changeset
23 -width, -height window size (default 640x480), -bpp bits per pixcel\n\
b662e9dd26b0 add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 728
diff changeset
24 -video {sdl|fb} in case of frame buffer, width,height,bpp is automatically set\n\
b662e9dd26b0 add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 728
diff changeset
25 \n";
556
12135dde3b87 Cerium no error.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 541
diff changeset
26 */
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 int
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 init(TaskManager *manager, int argc, char *argv[])
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 int bpp = 32;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 int width = 640;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 int height = 480;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 int spenum = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 video_type vtype = VTYPE_SDL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
914
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 895
diff changeset
37 int mem_flag = 0;
925
292bb8c79cdb add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 922
diff changeset
38 int profile = 0;
914
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 895
diff changeset
39
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 for(int i = 1; argv[i]; ++i)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 if (strcmp(argv[i], "-bpp") == 0) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 bpp = atoi(argv[++i]);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 if (strcmp(argv[i], "-width") == 0) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 width = atoi(argv[++i]);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 if (strcmp(argv[i], "-height") == 0) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 height = atoi(argv[++i]);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 if (strcmp(argv[i], "-cpu") == 0) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 spenum = atoi(argv[++i]);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 }
925
292bb8c79cdb add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 922
diff changeset
54 if (strcmp(argv[i], "-p") == 0) {
1117
19bfb73617ad debug option "-p" fix.
tkaito@henri
parents: 1111
diff changeset
55 profile = 1;
19bfb73617ad debug option "-p" fix.
tkaito@henri
parents: 1111
diff changeset
56 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 if (strcmp(argv[i], "-video") == 0) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 if (strcmp(argv[i+1], "sdl") == 0) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 vtype = VTYPE_SDL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 } else if (strcmp(argv[i+1], "fb") == 0) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 vtype = VTYPE_FB;
922
cb1023423861 moving OpenGL mode now!
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 914
diff changeset
62 } else if (strcmp(argv[i+1], "gl") == 0) {
cb1023423861 moving OpenGL mode now!
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 914
diff changeset
63 vtype = VTYPE_GL;
981
fdb36a9c5030 add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 944
diff changeset
64 } else if (strcmp(argv[i+1], "ps3") == 0) {
fdb36a9c5030 add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 944
diff changeset
65 vtype = VTYPE_PS3;
985
37bd2b0694e2 fix light data update
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 981
diff changeset
66 } else if (strcmp(argv[i+1], "sdl") == 0) {
37bd2b0694e2 fix light data update
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 981
diff changeset
67 vtype = VTYPE_SDL;
1111
c9d0683c9b39 add non screen mode.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 985
diff changeset
68 } else if (strcmp(argv[i+1], "none") == 0) {
c9d0683c9b39 add non screen mode.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 985
diff changeset
69 vtype = VTYPE_NONE;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 i++;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 }
914
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 895
diff changeset
73 if (strcmp(argv[i], "-mem") == 0) {
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 895
diff changeset
74 mem_flag = 1;
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 895
diff changeset
75 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 Viewer *screen;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 if (vtype == VTYPE_SDL) {
728
c7afc21e448d add Engine/ViewerDevice , SgRootChange not work
aaa
parents: 606
diff changeset
80 ViewerDevice *dev = new ViewerSDL(manager);
c7afc21e448d add Engine/ViewerDevice , SgRootChange not work
aaa
parents: 606
diff changeset
81 screen = new Viewer(manager, dev, bpp, width, height, spenum);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 } else if (vtype == VTYPE_FB) {
728
c7afc21e448d add Engine/ViewerDevice , SgRootChange not work
aaa
parents: 606
diff changeset
83 ViewerDevice *dev = new ViewerFB(manager);
c7afc21e448d add Engine/ViewerDevice , SgRootChange not work
aaa
parents: 606
diff changeset
84 screen = new Viewer(manager, dev, bpp, width, height, spenum);
922
cb1023423861 moving OpenGL mode now!
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 914
diff changeset
85 } else if (vtype == VTYPE_GL) {
944
0ab84d4c689a rename viewerGL
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 925
diff changeset
86 screen = new ViewerGL(manager, bpp, width, height, spenum);
981
fdb36a9c5030 add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 944
diff changeset
87 } else if (vtype == VTYPE_PS3) {
fdb36a9c5030 add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 944
diff changeset
88 ViewerDevice *dev = new ViewerPS3();
fdb36a9c5030 add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 944
diff changeset
89 screen = new Viewer(manager, dev, bpp, width, height, spenum);
1111
c9d0683c9b39 add non screen mode.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 985
diff changeset
90 } else if (vtype == VTYPE_NONE) {
c9d0683c9b39 add non screen mode.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 985
diff changeset
91 ViewerDevice *dev = new ViewerNONE(manager);
c9d0683c9b39 add non screen mode.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 985
diff changeset
92 screen = new Viewer(manager, dev, bpp, width, height, spenum);
922
cb1023423861 moving OpenGL mode now!
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 914
diff changeset
93 } else {
728
c7afc21e448d add Engine/ViewerDevice , SgRootChange not work
aaa
parents: 606
diff changeset
94 ViewerDevice *dev = new ViewerSDL(manager);
c7afc21e448d add Engine/ViewerDevice , SgRootChange not work
aaa
parents: 606
diff changeset
95 screen = new Viewer(manager, dev, bpp, width, height, spenum);
1117
19bfb73617ad debug option "-p" fix.
tkaito@henri
parents: 1111
diff changeset
96 }
914
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 895
diff changeset
97 screen->mem_flag = mem_flag;
1117
19bfb73617ad debug option "-p" fix.
tkaito@henri
parents: 1111
diff changeset
98 screen->profile = profile;
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
99 screen->run_init(manager, application());
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 return 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103
556
12135dde3b87 Cerium no error.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 541
diff changeset
104 #if 0
606
242a9db53612 32bit/64bit ABI (64 bit is not tested yet).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
105
242a9db53612 32bit/64bit ABI (64 bit is not tested yet).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
106 // These are defined in Application
242a9db53612 32bit/64bit ABI (64 bit is not tested yet).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
107
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 int
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 TMmain(TaskManager *manager, int argc, char *argv[])
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 task_initialize();
556
12135dde3b87 Cerium no error.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 541
diff changeset
112 manager->set_TMend(TMend);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 return init(manager, argc, argv);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
116
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 TMend(TaskManager *manager)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 }
556
12135dde3b87 Cerium no error.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 541
diff changeset
121
12135dde3b87 Cerium no error.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 541
diff changeset
122 #endif
606
242a9db53612 32bit/64bit ABI (64 bit is not tested yet).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
123
242a9db53612 32bit/64bit ABI (64 bit is not tested yet).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
124 /* end */