[Bf-blender-cvs] [04eada72fac] vamr-openxr-module: Add missing C-API source file
Julian Eisel
noreply at git.blender.org
Sat Aug 31 13:11:28 CEST 2019
Commit: 04eada72fac13c76ec86206ad7a7532579389ecc
Author: Julian Eisel
Date: Sat Aug 31 12:59:18 2019 +0200
Branches: vamr-openxr-module
https://developer.blender.org/rB04eada72fac13c76ec86206ad7a7532579389ecc
Add missing C-API source file
Also add missing license header.
===================================================================
M intern/vamr/CMakeLists.txt
M intern/vamr/VAMR_capi.h
A intern/vamr/intern/VAMR_capi.cc
===================================================================
diff --git a/intern/vamr/CMakeLists.txt b/intern/vamr/CMakeLists.txt
index e7111301d4a..71fc535f2af 100644
--- a/intern/vamr/CMakeLists.txt
+++ b/intern/vamr/CMakeLists.txt
@@ -26,6 +26,7 @@ set(INC_SYS
set(SRC
intern/VAMR.cc
+ intern/VAMR_capi.cc
intern/VAMR_Context.cc
intern/VAMR_Event.cc
intern/VAMR_GraphicsBinding.cc
diff --git a/intern/vamr/VAMR_capi.h b/intern/vamr/VAMR_capi.h
index 796149b8b2f..946757f9593 100644
--- a/intern/vamr/VAMR_capi.h
+++ b/intern/vamr/VAMR_capi.h
@@ -1,3 +1,23 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup VAMR
+ */
+
#ifndef __VAMR_CAPI_H__
#define __VAMR_CAPI_H__
diff --git a/intern/vamr/intern/VAMR_capi.cc b/intern/vamr/intern/VAMR_capi.cc
new file mode 100644
index 00000000000..898c493eca5
--- /dev/null
+++ b/intern/vamr/intern/VAMR_capi.cc
@@ -0,0 +1,80 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup VAMR
+ */
+
+#include "VAMR_Exception.h"
+#include "VAMR_IContext.h"
+#include "VAMR_Types.h"
+#include "VAMR_capi.h"
+
+#define VAMR_CAPI_CALL(call, ctx) \
+ try { \
+ call; \
+ } \
+ catch (VAMR_Exception & e) { \
+ (ctx)->dispatchErrorMessage(&e); \
+ }
+
+#define VAMR_CAPI_CALL_RET(call, ctx) \
+ try { \
+ return call; \
+ } \
+ catch (VAMR_Exception & e) { \
+ (ctx)->dispatchErrorMessage(&e); \
+ }
+
+void VAMR_SessionStart(VAMR_ContextHandle xr_contexthandle,
+ const VAMR_SessionBeginInfo *begin_info)
+{
+ VAMR_IContext *xr_context = (VAMR_IContext *)xr_contexthandle;
+ VAMR_CAPI_CALL(xr_context->startSession(begin_info), xr_context);
+}
+
+void VAMR_SessionEnd(VAMR_ContextHandle xr_contexthandle)
+{
+ VAMR_IContext *xr_context = (VAMR_IContext *)xr_contexthandle;
+ VAMR_CAPI_CALL(xr_context->endSession(), xr_context);
+}
+
+int VAMR_SessionIsRunning(const VAMR_ContextHandle xr_contexthandle)
+{
+ const VAMR_IContext *xr_context = (const VAMR_IContext *)xr_contexthandle;
+ VAMR_CAPI_CALL_RET(xr_context->isSessionRunning(), xr_context);
+ return 0; // Only reached if exception is thrown.
+}
+
+void VAMR_SessionDrawViews(VAMR_ContextHandle xr_contexthandle, void *draw_customdata)
+{
+ VAMR_IContext *xr_context = (VAMR_IContext *)xr_contexthandle;
+ VAMR_CAPI_CALL(xr_context->drawSessionViews(draw_customdata), xr_context);
+}
+
+void VAMR_GraphicsContextBindFuncs(VAMR_ContextHandle xr_contexthandle,
+ VAMR_GraphicsContextBindFn bind_fn,
+ VAMR_GraphicsContextUnbindFn unbind_fn)
+{
+ VAMR_IContext *xr_context = (VAMR_IContext *)xr_contexthandle;
+ VAMR_CAPI_CALL(xr_context->setGraphicsContextBindFuncs(bind_fn, unbind_fn), xr_context);
+}
+
+void VAMR_DrawViewFunc(VAMR_ContextHandle xr_contexthandle, VAMR_DrawViewFn draw_view_fn)
+{
+ VAMR_IContext *xr_context = (VAMR_IContext *)xr_contexthandle;
+ VAMR_CAPI_CALL(xr_context->setDrawViewFunc(draw_view_fn), xr_context);
+}
More information about the Bf-blender-cvs
mailing list