Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/ghost/intern/GHOST_C-api.cpp')
-rw-r--r--intern/ghost/intern/GHOST_C-api.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 9a7e3da828b..60d20474a5a 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -30,7 +30,11 @@
#include "GHOST_ISystem.h"
#include "GHOST_IEvent.h"
#include "GHOST_IEventConsumer.h"
+#ifdef WITH_XR_OPENXR
+# include "GHOST_IXrContext.h"
+#endif
#include "intern/GHOST_CallbackEventConsumer.h"
+#include "intern/GHOST_XrException.h"
GHOST_SystemHandle GHOST_CreateSystem(void)
{
@@ -914,3 +918,63 @@ void GHOST_EndIME(GHOST_WindowHandle windowhandle)
}
#endif /* WITH_INPUT_IME */
+
+#ifdef WITH_XR_OPENXR
+
+# define GHOST_XR_CAPI_CALL(call, ctx) \
+ try { \
+ call; \
+ } \
+ catch (GHOST_XrException & e) { \
+ (ctx)->dispatchErrorMessage(&e); \
+ }
+
+# define GHOST_XR_CAPI_CALL_RET(call, ctx) \
+ try { \
+ return call; \
+ } \
+ catch (GHOST_XrException & e) { \
+ (ctx)->dispatchErrorMessage(&e); \
+ }
+
+void GHOST_XrSessionStart(GHOST_XrContextHandle xr_contexthandle,
+ const GHOST_XrSessionBeginInfo *begin_info)
+{
+ GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
+ GHOST_XR_CAPI_CALL(xr_context->startSession(begin_info), xr_context);
+}
+
+void GHOST_XrSessionEnd(GHOST_XrContextHandle xr_contexthandle)
+{
+ GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
+ GHOST_XR_CAPI_CALL(xr_context->endSession(), xr_context);
+}
+
+void GHOST_XrSessionDrawViews(GHOST_XrContextHandle xr_contexthandle, void *draw_customdata)
+{
+ GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
+ GHOST_XR_CAPI_CALL(xr_context->drawSessionViews(draw_customdata), xr_context);
+}
+
+int GHOST_XrSessionIsRunning(const GHOST_XrContextHandle xr_contexthandle)
+{
+ const GHOST_IXrContext *xr_context = (const GHOST_IXrContext *)xr_contexthandle;
+ GHOST_XR_CAPI_CALL_RET(xr_context->isSessionRunning(), xr_context);
+ return 0; /* Only reached if exception is thrown. */
+}
+
+void GHOST_XrGraphicsContextBindFuncs(GHOST_XrContextHandle xr_contexthandle,
+ GHOST_XrGraphicsContextBindFn bind_fn,
+ GHOST_XrGraphicsContextUnbindFn unbind_fn)
+{
+ GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
+ GHOST_XR_CAPI_CALL(xr_context->setGraphicsContextBindFuncs(bind_fn, unbind_fn), xr_context);
+}
+
+void GHOST_XrDrawViewFunc(GHOST_XrContextHandle xr_contexthandle, GHOST_XrDrawViewFn draw_view_fn)
+{
+ GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
+ GHOST_XR_CAPI_CALL(xr_context->setDrawViewFunc(draw_view_fn), xr_context);
+}
+
+#endif