Mercurial > hg > Game > Cerium
annotate Renderer/Engine/viewer.h @ 1405:aafad9d18a2c draft
sepalate light
author | taiki |
---|---|
date | Fri, 17 Feb 2012 15:34:15 +0900 |
parents | 90efd2aac2cb |
children | 3778a1eda68d |
rev | line source |
---|---|
283 | 1 #ifndef INCLUDED_VIEWER |
2 #define INCLUDED_VIEWER | |
3 | |
4 #include <SDL.h> | |
5 | |
539 | 6 #include "viewer_types.h" |
7 #include "TaskManager.h" | |
8 #include "KeyStat.h" | |
542 | 9 #include "MainLoop.h" |
539 | 10 #include "Application.h" |
558 | 11 #include "SceneGraphRoot.h" |
747 | 12 #include "ViewerDevice.h" |
1405 | 13 #include "Light.h" |
539 | 14 |
562 | 15 class SceneGraphRoot; |
16 | |
543 | 17 class Application; |
283 | 18 |
1035 | 19 |
543 | 20 class Viewer : public MainLoop { |
542 | 21 |
283 | 22 public: |
1405 | 23 Light *light; |
24 /* measure for FPS (Frame Per Second) */ | |
25 int start_time; | |
26 int this_time; | |
27 int frames; | |
28 | |
29 typedef struct rendering_data { | |
30 PolygonPack *ppack; | |
31 SpanPackPtr spackList; | |
32 SpanPackPtr *spackList_ptr; | |
33 | |
34 int spackList_length; | |
35 int spackList_length_align; | |
36 } RenderingData ; | |
37 RenderingData r[2]; | |
38 | |
39 int ppi, spi; | |
40 Viewer(){ profile = 0; ppi = spi = 0;}; | |
747 | 41 Viewer(TaskManager *manager, ViewerDevice *dev, int bpp, int width, int height, int spenum); |
283 | 42 |
542 | 43 virtual ~Viewer() {} |
747 | 44 BASE_NEW_DELETE(Viewer); |
283 | 45 |
747 | 46 ViewerDevice *dev; |
539 | 47 Application *app; |
48 | |
49 TaskManager *manager; | |
50 key_stat *keyPtr; | |
51 HTaskPtr draw_dummy; | |
52 | |
283 | 53 /* screen info */ |
54 int bpp; | |
55 | |
747 | 56 int rgb_size[3]; |
283 | 57 int spe_num; |
747 | 58 int width; |
59 int height; | |
283 | 60 |
747 | 61 float *light_xyz; |
62 float *light_xyz_stock; | |
792 | 63 int *light_switch; |
64 int *light_switch_stock; | |
793 | 65 int *light_sysswitch; |
66 int light_sysswitch_stock; | |
747 | 67 |
283 | 68 Uint32 video_flags; |
69 Uint32 *pixels; | |
70 | |
914 | 71 int mem_flag; |
925
292bb8c79cdb
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
922
diff
changeset
|
72 int profile; |
914 | 73 |
1160 | 74 int pp_sum_num; |
75 | |
558 | 76 SceneGraphRoot *sgroot; |
77 | |
747 | 78 //Uint32 *video_init(TaskManager *manager, int bpp, int width, int height); |
283 | 79 void init(); |
80 | |
81 int get_ticks(); | |
82 bool quit_check(); | |
83 void quit(); | |
747 | 84 HTaskPtr initLoop(); |
283 | 85 |
747 | 86 void clean_pixels() {} |
869 | 87 |
927
fada580e4604
remove garbage codes from viewerGL
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
922
diff
changeset
|
88 void run_init(TaskManager *manager, Application *app); |
1112
fa1f4a1c47bf
fix viewer for non screen mode.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1095
diff
changeset
|
89 bool main_exec(HTaskPtr task_next); |
747 | 90 void run_loop(HTaskPtr task_next); |
91 void run_draw(HTaskPtr task_next); | |
927
fada580e4604
remove garbage codes from viewerGL
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
922
diff
changeset
|
92 virtual void run_finish(); |
747 | 93 void run_move(HTaskPtr task_next); |
94 void run_collision(); | |
1131
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1125
diff
changeset
|
95 void create_pp(HTaskPtr task_next); |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1125
diff
changeset
|
96 void create_sp(HTaskPtr task_next); |
747 | 97 void common_draw(HTaskPtr task_next); |
1131
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1125
diff
changeset
|
98 void rendering_pp(HTaskPtr task_next, SceneGraphRoot *sgroot); |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1125
diff
changeset
|
99 void rendering_sp(HTaskPtr task_next, SceneGraphRoot *sgroot); |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1125
diff
changeset
|
100 //void common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot); |
539 | 101 |
747 | 102 // void exchange_sgroot(TaskManager *manager); |
539 | 103 |
792 | 104 HTaskPtr update_task_create(void *data, int size, |
105 int load_id, int spe_id, HTaskPtr wait); | |
106 | |
539 | 107 void getKey(); |
108 void get_send_controll(); | |
543 | 109 |
558 | 110 // void createFromXMLfile(const char *file); |
111 // SceneGraph *createSceneGraph(int id); | |
112 // SceneGraph *createSceneGraph(); | |
113 // void setSceneData(SceneGraph *g); | |
927
fada580e4604
remove garbage codes from viewerGL
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
922
diff
changeset
|
114 virtual void mainLoop(); |
543 | 115 |
1405 | 116 // In Application::init, SceneGraphRoot API is called bia viewer |
117 | |
1211 | 118 void createStringFont(SceneGraphPtr root, const char *string, int pixels, int screen_w, int screen_h, Uint32 color) |
1205
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1160
diff
changeset
|
119 { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1160
diff
changeset
|
120 sgroot -> createStringFont(manager, root, string, pixels, screen_w, screen_h, color); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1160
diff
changeset
|
121 } |
1211 | 122 void createFont(const char *font,int pixels,Uint32 color, const char *filename, int len, char **obj_name) |
1205
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1160
diff
changeset
|
123 { |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1160
diff
changeset
|
124 sgroot -> createFont(manager,font,pixels,color,filename, len, obj_name); |
b8adf4e95e96
add createStringFont()
Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
parents:
1160
diff
changeset
|
125 } |
1002 | 126 void task_array_init(int id, int task_num, int param, int inData_num, int outData_num) |
127 { | |
128 sgroot->task_array_init(id, task_num, param, inData_num, outData_num); | |
129 } | |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1003
diff
changeset
|
130 void set_move_task(SceneGraphPtr node, int move, void *titlep, int size) |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
928
diff
changeset
|
131 { |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1003
diff
changeset
|
132 sgroot->set_move_task(node, move, titlep, size); |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
928
diff
changeset
|
133 } |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1003
diff
changeset
|
134 void set_pad_task(SceneGraphPtr node, int move, void *property, int size) |
886 | 135 { |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1003
diff
changeset
|
136 sgroot->set_pad_task(node, move, property, size); |
869 | 137 } |
138 | |
671
7761ebf9c62a
fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
589
diff
changeset
|
139 void createFromXMLmemory(SceneGraph * node, char *data, int len) |
7761ebf9c62a
fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
589
diff
changeset
|
140 { |
7761ebf9c62a
fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
589
diff
changeset
|
141 sgroot->createFromXMLmemory(manager, node, data, len); |
7761ebf9c62a
fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
589
diff
changeset
|
142 } |
7761ebf9c62a
fix several Renderer/Test with (void*)sgroot.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
589
diff
changeset
|
143 |
558 | 144 void createFromXMLfile(const char *file) |
145 { | |
146 sgroot->createFromXMLfile(manager, file); | |
147 } | |
148 | |
1284
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
149 void createFromCOLLADAfile(const char *file) |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
150 { |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
151 sgroot->createFromCOLLADAfile(manager, file); |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
152 } |
fe598e9b7f0e
improve collada file
Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
parents:
1211
diff
changeset
|
153 |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
928
diff
changeset
|
154 Pad * getController() |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
928
diff
changeset
|
155 { |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
928
diff
changeset
|
156 return sgroot->getController(); |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
928
diff
changeset
|
157 } |
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
928
diff
changeset
|
158 |
558 | 159 SceneGraph * createSceneGraph(int id) |
160 { | |
161 return sgroot->createSceneGraph(id); | |
162 } | |
163 | |
562 | 164 SceneGraph * createSceneGraph(const char *id) |
165 { | |
969
52c4353308e7
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
928
diff
changeset
|
166 return sgroot->createSceneGraph(id); |
562 | 167 } |
168 | |
169 int getSgid(const char *id) | |
170 { | |
171 return sgroot->getSgid(id); | |
172 } | |
173 | |
558 | 174 SceneGraph * createSceneGraph() |
175 { | |
176 return sgroot->createSceneGraph(); | |
177 } | |
178 | |
179 void setSceneData(SceneGraph *g) | |
180 { | |
181 sgroot->setSceneData(g); | |
182 } | |
183 | |
589 | 184 int getLast() |
185 { | |
186 return sgroot->getLast(); | |
187 } | |
188 | |
793 | 189 SceneGraphPtr getLight(int id) |
190 { | |
191 return sgroot->getLight(id); | |
192 } | |
193 | |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
194 CameraPtr getCamera() |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
195 { |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
196 return sgroot->getCamera(); |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
197 } |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
198 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1284
diff
changeset
|
199 |
793 | 200 void OnLightSwitch(int id) |
201 { | |
202 sgroot->OnLightSwitch(id); | |
203 } | |
204 | |
205 void OffLightSwitch(int id) | |
206 { | |
207 sgroot->OffLightSwitch(id); | |
208 } | |
209 | |
210 void OnLightSysSwitch() | |
211 { | |
212 sgroot->OnLightSysSwitch(); | |
213 } | |
214 | |
215 void OffLightSysSwitch() | |
216 { | |
217 sgroot->OffLightSysSwitch(); | |
218 } | |
219 | |
283 | 220 }; |
221 | |
539 | 222 #define default_sdl_flag SDL_INIT_TIMER | SDL_INIT_JOYSTICK |
223 | |
224 | |
283 | 225 #endif |
226 |