annotate Renderer/Test/create_task.cc @ 759:bb47827c04c1

fix create_task
author hiroki@henri.cr.ie.u-ryukyu.ac.jp
date Mon, 01 Feb 2010 17:08:36 +0900
parents e615e552efa5
children 24a37fe8419a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
759
bb47827c04c1 fix create_task
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 758
diff changeset
8 #include "SgChange.h"
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);
758
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
15 static void createSceneGraphFromProperty(SchedTask *s, void *sgroot, void *arg1);
756
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
16
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
17 static void
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
18 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
19 {
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
20 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
21 TaskManager *manager = sgroot->tmanager;
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
22 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
23
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
24 property_task->add_inData(property, sizeof(Property));
757
5238f3e854fc Test/create_task , create SPE task from application.
hiroki
parents: 756
diff changeset
25 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
26 property_task->set_cpu(SPE_ANY);
758
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
27
759
bb47827c04c1 fix create_task
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 758
diff changeset
28 property_task->set_post(createSceneGraphFromProperty, (void *)sgroot, 0);
757
5238f3e854fc Test/create_task , create SPE task from application.
hiroki
parents: 756
diff changeset
29 property_task->spawn();
756
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
30 }
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
31
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
32 static void
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
33 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
34 SceneGraphPtr tree)
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
35 {
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
36 }
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
37
758
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
38 static void
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
39 createSceneGraphFromProperty(SchedTask *s, void *sgroot_, void *arg1)
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
40 {
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
41 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
42 SceneGraphPtr node;
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
43
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
44 node = sgroot->createSceneGraph(update_property->name);
759
bb47827c04c1 fix create_task
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 758
diff changeset
45 //node = sgroot->createSceneGraph("Ball");
758
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
46 node->set_move_collision(move, collision);
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
47 node->xyz[0] = update_property->xyz[0];
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
48 node->xyz[1] = update_property->xyz[1];
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
49 node->xyz[2] = update_property->xyz[2];
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
50 sgroot->setSceneData(node);
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
51
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
52 Property *tmp = property;
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
53 property = update_property;
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
54 update_property = tmp;
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
55
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
56 }
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
57
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
58 static void
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
59 set_property(Property *p, SceneGraphPtr sg)
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
60 {
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
61 p->xyz[0] = sg->xyz[0];
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
62 p->xyz[1] = sg->xyz[1];
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
63 p->xyz[2] = sg->xyz[2];
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
64 p->name = sg->name;
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
65 }
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
66
756
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
67 MainLoopPtr
759
bb47827c04c1 fix create_task
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 758
diff changeset
68 create_task::init(Viewer *viewer, int screen_w, int screen_h)
756
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
69 {
759
bb47827c04c1 fix create_task
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 758
diff changeset
70 // SgChange を使うための2行
bb47827c04c1 fix create_task
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 758
diff changeset
71 SgChange *sgroot = new SgChange(viewer);
bb47827c04c1 fix create_task
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 758
diff changeset
72 sgroot->run_init();
bb47827c04c1 fix create_task
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 758
diff changeset
73
758
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
74 property = (Property *)sgroot->manager->allocate(sizeof(Property));
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
75 update_property = (Property *)sgroot->manager->allocate(sizeof(Property));
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
76
756
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
77 SceneGraphPtr ball;
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
78
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
79 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
80
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
81 ball = sgroot->createSceneGraph("Ball");
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
82 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
83
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
84 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
85 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
86 ball->xyz[2] = 30.0f;
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
87
758
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
88 set_property(property, ball);
e615e552efa5 change Test/create_task
hiroki
parents: 757
diff changeset
89
756
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
90 sgroot->setSceneData(ball);
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
91
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
92 return sgroot;
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
93 }
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
94
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
95 extern Application *
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
96 application() {
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
97 return new create_task();
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
98 }
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
99
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
100 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
101
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
102 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
103 extern void task_initialize();
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
104 static void TMend(TaskManager *manager);
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
105
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
106 int
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
107 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
108 {
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
109 task_initialize();
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
110 manager->set_TMend(TMend);
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
111 return init(manager, argc, argv);
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
112
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
113 }
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
114
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
115 void
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
116 TMend(TaskManager *manager)
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
117 {
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
118 printf("test_nogl end\n");
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
119 }
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
120
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
121 /* end */