annotate Renderer/Test/create_task.cc @ 756:2575791a333a

add Test/create_task {spe, task}/Property
author hiroki@henri.cr.ie.u-ryukyu.ac.jp
date Fri, 29 Jan 2010 11:34:43 +0900
parents
children 5238f3e854fc
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"
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
6 #include "sys.h"
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
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
9 // prototype
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
10 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
11 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
12
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
13 static void
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
14 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
15 {
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
16 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
17 TaskManager *manager = sgroot->tmanager;
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
18 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
19
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
20 Property *property = (Property *)manager->allocate(sizeof(Property));
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
21 Property *property_update = (Property *)manager->allocate(sizeof(Property));
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
22
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
23 property_task->add_inData(property, sizeof(Property));
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
24 property_task->add_outData(property_update, sizeof(Property));
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
25 property_task->set_cpu(SPE_ANY);
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
26
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
27 property_task->spawn();
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
28 }
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
29
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
30 static void
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
31 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
32 SceneGraphPtr tree)
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
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
36 MainLoopPtr
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
37 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
38 {
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
39 SceneGraphPtr ball;
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 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
42
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
43 ball = sgroot->createSceneGraph("Ball");
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
44 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
45
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
46 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
47 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
48 ball->xyz[2] = 30.0f;
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
49
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
50 sgroot->setSceneData(ball);
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
51
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
52 return sgroot;
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
53 }
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 extern Application *
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
56 application() {
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
57 return new create_task();
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
58 }
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
59
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
60 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
61
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
62 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
63 extern void task_initialize();
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
64 static void TMend(TaskManager *manager);
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
65
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
66 int
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
67 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
68 {
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
69 task_initialize();
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
70 manager->set_TMend(TMend);
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
71 return init(manager, argc, argv);
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
72
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
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
75 void
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
76 TMend(TaskManager *manager)
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
77 {
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
78 printf("test_nogl end\n");
2575791a333a add Test/create_task {spe, task}/Property
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
79 }
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 /* end */