0
$\begingroup$

In Blender2.79 (Windows10/64bit-Exe application)

On running the sample Opengl/Gpu script - 3D Lines with Single Color on a Gpu which supports Opengl 3.1,Blender doesn't recognise the builtin Opengl modules and gives the following errors-

ImportError: No module named 'gpu_extras'  

&

AttributeError: module 'gpu' has no attribute 'shader'  

Also ,in ProgramFiles/Blender2.79/Scripts the gpu/bgl modules were not found .How to get Blender to run Opengl Scripts ?

3D Lines with Single Color

import bpy
import gpu
from gpu_extras.batch import batch_for_shader

coords = [(1, 1, 1), (-2, 0, 0), (-2, -1, 3), (0, 1, 1)]
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
batch = batch_for_shader(shader, 'LINES', {"pos": coords})


def draw():
    shader.bind()
    shader.uniform_float("color", (1, 1, 0, 1))
    batch.draw(shader)


bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW')
$\endgroup$
  • 1
    $\begingroup$ You're referencing the most recent version of API docs which are written for Blender 2.81. For Blender 2.79 you will have to check the matching version of the API docs or switch to the newest version of Blender. $\endgroup$ – Robert Gützkow Dec 29 '19 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.