aboutsummaryrefslogtreecommitdiff
path: root/api_example.c
diff options
context:
space:
mode:
authorCNLohr <charles@cnlohr.com>2018-04-15 20:41:22 -0400
committerGitHub <noreply@github.com>2018-04-15 20:41:22 -0400
commit69b31d3c3b1957e59d7962722a4145bfb0db16f9 (patch)
tree927d843a553ef53217c283f19f16728b0ca51c50 /api_example.c
parentc73823e20c9ed2f2f8f6a13c2031971d8b7d7be2 (diff)
parent39a63badbb5864314a9d9e18c0871718ac5d2912 (diff)
downloadlibsurvive-69b31d3c3b1957e59d7962722a4145bfb0db16f9.tar.gz
libsurvive-69b31d3c3b1957e59d7962722a4145bfb0db16f9.tar.bz2
Merge branch 'master' into tcc_build
Diffstat (limited to 'api_example.c')
-rw-r--r--api_example.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/api_example.c b/api_example.c
new file mode 100644
index 0000000..1f06740
--- /dev/null
+++ b/api_example.c
@@ -0,0 +1,35 @@
+#include <stdio.h>
+#include <string.h>
+#include <survive_api.h>
+#include <os_generic.h>
+
+int main(int argc, char **argv) {
+ SurviveSimpleContext *actx = survive_simple_init(argc, argv);
+ if (actx == 0) // implies -help or similiar
+ return 0;
+
+ survive_simple_start_thread(actx);
+
+ while (survive_simple_is_running(actx)) {
+ OGUSleep(30000);
+
+ SurvivePose pose;
+
+ for (const SurviveSimpleObject *it = survive_simple_get_first_object(actx); it != 0;
+ it = survive_simple_get_next_object(actx, it)) {
+ uint32_t timecode = survive_simple_object_get_latest_pose(it, &pose);
+ printf("%s (%u): %f %f %f %f %f %f %f\n", survive_simple_object_name(it), timecode, pose.Pos[0],
+ pose.Pos[1], pose.Pos[2], pose.Rot[0], pose.Rot[1], pose.Rot[2], pose.Rot[3]);
+ }
+
+ OGUSleep(30000);
+ for (const SurviveSimpleObject *it = survive_simple_get_next_updated(actx); it != 0;
+ it = survive_simple_get_next_updated(actx)) {
+ printf("%s changed since last checked\n", survive_simple_object_name(it));
+ }
+
+ }
+
+ survive_simple_close(actx);
+ return 0;
+}