From 0caf761863c3f3fe0b68e820efbc89c2fb663325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 4 Jan 2019 16:25:50 +0100 Subject: [PATCH] Prevent error when running Blender in background mode We shouldn't call any `gpu` functions in background mode. Since the texture browser will never run when Blender is in background mode anyway, we can simply assign `None` instead. --- blender_cloud/texture_browser/draw.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/blender_cloud/texture_browser/draw.py b/blender_cloud/texture_browser/draw.py index d4bc906..339e1fb 100644 --- a/blender_cloud/texture_browser/draw.py +++ b/blender_cloud/texture_browser/draw.py @@ -11,8 +11,12 @@ import bpy import gpu from gpu_extras.batch import batch_for_shader -shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') -texture_shader = gpu.shader.from_builtin('2D_IMAGE') +if bpy.app.background: + shader = None + texture_shader = None +else: + shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') + texture_shader = gpu.shader.from_builtin('2D_IMAGE') Float2 = typing.Tuple[float, float] Float3 = typing.Tuple[float, float, float]