[Bf-blender-cvs] [ca8fee62abc] blender2.8: Update gpu offscreen PyAPI example

Campbell Barton noreply at git.blender.org
Fri Oct 26 03:13:49 CEST 2018


Commit: ca8fee62abc17fd514994c1c0bf34a3234be902a
Author: Campbell Barton
Date:   Fri Oct 26 12:13:03 2018 +1100
Branches: blender2.8
https://developer.blender.org/rBca8fee62abc17fd514994c1c0bf34a3234be902a

Update gpu offscreen PyAPI example

===================================================================

M	doc/python_api/examples/gpu.types.GPUOffScreen.py

===================================================================

diff --git a/doc/python_api/examples/gpu.types.GPUOffScreen.py b/doc/python_api/examples/gpu.types.GPUOffScreen.py
index aa9514d11b2..ee0b6759f13 100644
--- a/doc/python_api/examples/gpu.types.GPUOffScreen.py
+++ b/doc/python_api/examples/gpu.types.GPUOffScreen.py
@@ -84,8 +84,8 @@ class VIEW3D_OT_draw_offscreen(bpy.types.Operator):
 
         try:
             offscreen = gpu.types.GPUOffScreen(512, int(512 / aspect_ratio))
-        except Exception as e:
-            print(e)
+        except Exception as ex:
+            print(ex)
             offscreen = None
 
         return offscreen
@@ -145,7 +145,9 @@ class VIEW3D_OT_draw_offscreen(bpy.types.Operator):
         bgl.glActiveTexture(bgl.GL_TEXTURE0)
         bgl.glBindTexture(bgl.GL_TEXTURE_2D, texture)
 
-        shader.uniform_int(VIEW3D_OT_draw_offscreen.uniform_image, 0)
+        # # TODO, support passing ints
+        # shader.uniform_int(VIEW3D_OT_draw_offscreen.uniform_image, 0)
+        shader.uniform_int("image", 0)
         batch_plane.draw()
 
         # restoring settings
@@ -163,22 +165,23 @@ class VIEW3D_OT_draw_offscreen(bpy.types.Operator):
             format = gpu.types.GPUVertFormat()
             pos_id = format.attr_add(
                 id="pos",
-                comp_type="F32",
+                comp_type='F32',
                 len=2,
-                fetch_mode="FLOAT")
-
+                fetch_mode='FLOAT',
+            )
             uv_id = format.attr_add(
                 id="texCoord",
-                comp_type="F32",
+                comp_type='F32',
                 len=2,
-                fetch_mode="FLOAT")
-
+                fetch_mode='FLOAT',
+            )
             vbo = gpu.types.GPUVertBuf(
                 len=len(g_plane_vertices),
-                format=format)
+                format=format,
+            )
 
-            vbo.fill(id=pos_id, data=g_plane_vertices["pos"])
-            vbo.fill(id=uv_id, data=g_plane_vertices["uv"])
+            vbo.attr_fill(id=pos_id, data=g_plane_vertices["pos"])
+            vbo.attr_fill(id=uv_id, data=g_plane_vertices["uv"])
 
             batch_plane = gpu.types.GPUBatch(type="TRIS", buf=vbo)
             shader = self.global_shader



More information about the Bf-blender-cvs mailing list