Mercurial > hg > Members > kono > Cerium
annotate Renderer/Test/create_task.cc @ 757:5238f3e854fc
Test/create_task , create SPE task from application.
author | hiroki |
---|---|
date | Fri, 29 Jan 2010 14:34:30 +0900 |
parents | 2575791a333a |
children | e615e552efa5 |
rev | line source |
---|---|
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
1 #include <math.h> |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
2 #include <stdlib.h> |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
3 #include "SceneGraphRoot.h" |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
4 #include "MainLoop.h" |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
5 #include "create_task.h" |
757
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
6 #include "types.h" |
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
7 #include "Func.h" |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
8 |
757
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
9 |
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
10 Property *property, *update_property; |
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
11 |
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
12 // prototype |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
13 static void move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
14 static void collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, SceneGraphPtr tree); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
15 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
16 static void |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
17 move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
18 { |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
19 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
20 TaskManager *manager = sgroot->tmanager; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
21 HTaskPtr property_task = manager->create_task(PropertyTask); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
22 |
757
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
23 printf("%f, %f, %f\n", update_property->x, update_property->y, update_property->z); |
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
24 property->x = update_property->x; |
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
25 property->y = update_property->y; |
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
26 property->z = update_property->z; |
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
27 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
28 property_task->add_inData(property, sizeof(Property)); |
757
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
29 property_task->add_outData(update_property, sizeof(Property)); |
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
30 property_task->set_cpu(SPE_ANY); |
757
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
31 property_task->spawn(); |
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
32 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
33 } |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
34 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
35 static void |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
36 collision(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h, |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
37 SceneGraphPtr tree) |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
38 { |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
39 } |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
40 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
41 MainLoopPtr |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
42 create_task::init(Viewer *sgroot, int screen_w, int screen_h) |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
43 { |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
44 SceneGraphPtr ball; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
45 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
46 sgroot->createFromXMLfile("xml_file/Ball.xml"); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
47 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
48 ball = sgroot->createSceneGraph("Ball"); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
49 ball->set_move_collision(move, collision); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
50 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
51 ball->xyz[0] = screen_w/2; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
52 ball->xyz[1] = screen_h/2; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
53 ball->xyz[2] = 30.0f; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
54 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
55 sgroot->setSceneData(ball); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
56 |
757
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
57 property = (Property *)sgroot->manager->allocate(sizeof(Property)); |
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
58 update_property = (Property *)sgroot->manager->allocate(sizeof(Property)); |
5238f3e854fc
Test/create_task , create SPE task from application.
hiroki
parents:
756
diff
changeset
|
59 |
756
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
60 return sgroot; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
61 } |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
62 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
63 extern Application * |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
64 application() { |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
65 return new create_task(); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
66 } |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
67 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
68 const char *usr_help_str = "Usage: ./test_nogl [OPTION]\n"; |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
69 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
70 extern int init(TaskManager *manager, int argc, char *argv[]); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
71 extern void task_initialize(); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
72 static void TMend(TaskManager *manager); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
73 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
74 int |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
75 TMmain(TaskManager *manager, int argc, char *argv[]) |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
76 { |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
77 task_initialize(); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
78 manager->set_TMend(TMend); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
79 return init(manager, argc, argv); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
80 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
81 } |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
82 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
83 void |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
84 TMend(TaskManager *manager) |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
85 { |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
86 printf("test_nogl end\n"); |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
87 } |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
88 |
2575791a333a
add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
89 /* end */ |