monado/src/xrt/state_trackers/oxr/oxr_api_space.c

140 lines
3.8 KiB
C
Raw Normal View History

2019-03-18 05:52:32 +00:00
// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Space, space, space, SPAAAAAAAAAAAAAAAAAAAAAAAAAACE!
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup oxr_api
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "xrt/xrt_compiler.h"
#include "math/m_api.h"
2019-03-18 05:52:32 +00:00
#include "util/u_debug.h"
#include "oxr_objects.h"
#include "oxr_logger.h"
#include "oxr_two_call.h"
#include "oxr_api_funcs.h"
#include "oxr_api_verify.h"
XrResult
2019-07-13 16:17:57 +00:00
oxr_xrCreateActionSpace(XrSession session,
const XrActionSpaceCreateInfo *createInfo,
XrSpace *space)
2019-03-18 05:52:32 +00:00
{
struct oxr_session *sess;
struct oxr_action *act;
2019-03-18 05:52:32 +00:00
struct oxr_logger log;
2019-07-13 16:17:57 +00:00
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
"xrCreateActionSpace");
2019-03-18 05:52:32 +00:00
OXR_VERIFY_ARG_TYPE_AND_NULL(&log, createInfo,
XR_TYPE_ACTION_SPACE_CREATE_INFO);
OXR_VERIFY_POSE(&log, createInfo->poseInActionSpace);
2019-07-13 16:17:57 +00:00
OXR_VERIFY_ACTION_NOT_NULL(&log, createInfo->action, act);
2019-04-05 22:28:36 +00:00
struct oxr_space *spc;
2019-07-13 16:17:57 +00:00
XrResult ret =
oxr_space_action_create(&log, sess, act->key, createInfo, &spc);
2019-04-05 22:28:36 +00:00
if (ret != XR_SUCCESS) {
return ret;
}
*space = oxr_space_to_openxr(spc);
return XR_SUCCESS;
2019-03-18 05:52:32 +00:00
}
static const XrReferenceSpaceType session_spaces[] = {
XR_REFERENCE_SPACE_TYPE_VIEW,
XR_REFERENCE_SPACE_TYPE_LOCAL,
XR_REFERENCE_SPACE_TYPE_STAGE,
};
XrResult
oxr_xrEnumerateReferenceSpaces(XrSession session,
uint32_t spaceCapacityInput,
uint32_t *spaceCountOutput,
XrReferenceSpaceType *spaces)
2019-03-18 05:52:32 +00:00
{
struct oxr_session *sess;
2019-03-18 05:52:32 +00:00
struct oxr_logger log;
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
"xrEnumerateReferenceSpaces");
OXR_TWO_CALL_HELPER(&log, spaceCapacityInput, spaceCountOutput, spaces,
ARRAY_SIZE(session_spaces), session_spaces);
}
XrResult
oxr_xrGetReferenceSpaceBoundsRect(XrSession session,
XrReferenceSpaceType referenceSpaceType,
XrExtent2Df *bounds)
2019-03-18 05:52:32 +00:00
{
struct oxr_session *sess;
2019-03-18 05:52:32 +00:00
struct oxr_logger log;
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
"xrGetReferenceSpaceBoundsRect");
//! @todo Implement
2019-03-27 13:35:15 +00:00
return oxr_error(&log, XR_ERROR_FUNCTION_UNSUPPORTED,
" not implemented");
2019-03-18 05:52:32 +00:00
}
XrResult
oxr_xrCreateReferenceSpace(XrSession session,
const XrReferenceSpaceCreateInfo *createInfo,
XrSpace *out_space)
2019-03-18 05:52:32 +00:00
{
XrResult ret;
struct oxr_session *sess;
struct oxr_space *spc;
2019-03-18 05:52:32 +00:00
struct oxr_logger log;
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
"xrCreateReferenceSpace");
OXR_VERIFY_ARG_TYPE_AND_NULL(&log, createInfo,
XR_TYPE_REFERENCE_SPACE_CREATE_INFO);
OXR_VERIFY_POSE(&log, createInfo->poseInReferenceSpace);
2019-03-18 05:52:32 +00:00
ret = oxr_space_reference_create(&log, sess, createInfo, &spc);
if (ret != XR_SUCCESS) {
return ret;
}
*out_space = oxr_space_to_openxr(spc);
return XR_SUCCESS;
}
XrResult
oxr_xrLocateSpace(XrSpace space,
XrSpace baseSpace,
XrTime time,
XrSpaceLocation *location)
2019-03-18 05:52:32 +00:00
{
struct oxr_space *spc;
struct oxr_space *baseSpc;
2019-03-18 05:52:32 +00:00
struct oxr_logger log;
OXR_VERIFY_SPACE_AND_INIT_LOG(&log, space, spc, "xrLocateSpace");
OXR_VERIFY_SPACE_NOT_NULL(&log, baseSpace, baseSpc);
2019-07-13 16:17:57 +00:00
OXR_VERIFY_ARG_TYPE_AND_NULL(&log, location, XR_TYPE_SPACE_LOCATION);
2019-03-18 05:52:32 +00:00
2019-07-13 16:17:57 +00:00
return oxr_space_locate(&log, spc, baseSpc, time, location);
2019-03-18 05:52:32 +00:00
}
XrResult
oxr_xrDestroySpace(XrSpace space)
{
struct oxr_space *spc;
2019-03-18 05:52:32 +00:00
struct oxr_logger log;
OXR_VERIFY_SPACE_AND_INIT_LOG(&log, space, spc, "xrDestroySpace");
return oxr_handle_destroy(&log, &spc->handle);
2019-03-18 05:52:32 +00:00
}