diff options
author | Justin Berger <j.david.berger@gmail.com> | 2018-04-03 16:08:00 -0600 |
---|---|---|
committer | Justin Berger <j.david.berger@gmail.com> | 2018-04-04 00:40:21 -0600 |
commit | 7d1d930dcb99559eee95fc8a94cc68d12a968353 (patch) | |
tree | a7b4884ffc54c74e27b6369d93f70500f6043ee5 /api_example.c | |
parent | ce6322b6b604b12018a2daf427dbd36afc5fbda2 (diff) | |
download | libsurvive-7d1d930dcb99559eee95fc8a94cc68d12a968353.tar.gz libsurvive-7d1d930dcb99559eee95fc8a94cc68d12a968353.tar.bz2 |
Added simple API
Diffstat (limited to 'api_example.c')
-rw-r--r-- | api_example.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/api_example.c b/api_example.c new file mode 100644 index 0000000..f2d9bd6 --- /dev/null +++ b/api_example.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <string.h> +#include <survive_api.h> +#include <os_generic.h> + +int main(int argc, char **argv) { + SurviveAsyncContext *actx = survive_asyc_init(argc, argv); + if (actx == 0) // implies -help or similiar + return 0; + + survive_async_start_thread(actx); + + while (survive_async_is_running(actx)) { + OGUSleep(30000); + + SurvivePose pose; + + for (const SurviveAsyncObject* it = survive_async_get_first_tracked(actx); it != 0; it = survive_async_get_next_tracked(actx, it)) { + uint32_t timecode = survive_async_object_get_latest_pose(it, &pose); + printf("%s (%u): %f %f %f %f %f %f %f\n", survive_async_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 SurviveAsyncObject* it = survive_async_get_next_updated(actx); it != 0; it = survive_async_get_next_updated(actx)) { + printf("%s changed since last checked\n", survive_async_object_name(it)); + } + + } + + survive_async_close(actx); + return 0; +} |