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.
This commit is contained in:
Sybren A. Stüvel 2019-01-04 16:25:50 +01:00
parent bc864737ae
commit 0caf761863

View File

@ -11,6 +11,10 @@ import bpy
import gpu import gpu
from gpu_extras.batch import batch_for_shader from gpu_extras.batch import batch_for_shader
if bpy.app.background:
shader = None
texture_shader = None
else:
shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
texture_shader = gpu.shader.from_builtin('2D_IMAGE') texture_shader = gpu.shader.from_builtin('2D_IMAGE')