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 'source/blender/python/gpu/gpu_py.c')
-rw-r--r--source/blender/python/gpu/gpu_py.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/python/gpu/gpu_py.c b/source/blender/python/gpu/gpu_py.c
index 2c5daaf1962..7aea940da94 100644
--- a/source/blender/python/gpu/gpu_py.c
+++ b/source/blender/python/gpu/gpu_py.c
@@ -23,6 +23,7 @@
#include <Python.h>
+#include "GPU_init_exit.h"
#include "GPU_primitive.h"
#include "GPU_texture.h"
@@ -58,3 +59,21 @@ struct PyC_StringEnumItems bpygpu_dataformat_items[] = {
{0, NULL},
};
/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Utilities
+ * \{ */
+
+bool bpygpu_is_init_or_error(void)
+{
+ if (!GPU_is_init()) {
+ PyErr_SetString(PyExc_SystemError,
+ "GPU functions for drawing are not available in background mode");
+
+ return false;
+ }
+
+ return true;
+}
+
+/** \} */