Blender  V3.3
GHOST_Xr.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
9 #include <cassert>
10 #include <string>
11 
12 #include "GHOST_C-api.h"
13 
14 #include "GHOST_XrContext.h"
15 #include "GHOST_XrException.h"
16 #include "GHOST_Xr_intern.h"
17 
18 GHOST_XrContextHandle GHOST_XrContextCreate(const GHOST_XrContextCreateInfo *create_info)
19 {
20  auto xr_context = std::make_unique<GHOST_XrContext>(create_info);
21 
22  /* TODO GHOST_XrContext's should probably be owned by the GHOST_System, which will handle context
23  * creation and destruction. Try-catch logic can be moved to C-API then. */
24  try {
25  xr_context->initialize(create_info);
26  }
27  catch (GHOST_XrException &e) {
28  xr_context->dispatchErrorMessage(&e);
29  return nullptr;
30  }
31 
32  /* Give ownership to the caller. */
33  return (GHOST_XrContextHandle)xr_context.release();
34 }
35 
36 void GHOST_XrContextDestroy(GHOST_XrContextHandle xr_contexthandle)
37 {
38  delete (GHOST_XrContext *)xr_contexthandle;
39 }
40 
41 void GHOST_XrErrorHandler(GHOST_XrErrorHandlerFn handler_fn, void *customdata)
42 {
43  GHOST_XrContext::setErrorHandler(handler_fn, customdata);
44 }
GHOST C-API function and type declarations.
GHOST_XrContextHandle GHOST_XrContextCreate(const GHOST_XrContextCreateInfo *create_info)
Definition: GHOST_Xr.cpp:18
void GHOST_XrContextDestroy(GHOST_XrContextHandle xr_contexthandle)
Definition: GHOST_Xr.cpp:36
void GHOST_XrErrorHandler(GHOST_XrErrorHandlerFn handler_fn, void *customdata)
Definition: GHOST_Xr.cpp:41
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
Main GHOST container to manage OpenXR through.
static void setErrorHandler(GHOST_XrErrorHandlerFn handler_fn, void *customdata)