1
1

Cleanup: gpu docs

This commit is contained in:
2018-11-20 07:32:49 +11:00
parent 5f21030a81
commit 3c8c976086
12 changed files with 130 additions and 86 deletions

View File

@@ -13,13 +13,18 @@ IMAGE_NAME = "Untitled"
image = bpy.data.images[IMAGE_NAME]
shader = gpu.shader.from_builtin('2D_IMAGE')
batch = batch_for_shader(shader, 'TRI_FAN',
{"pos" : ((100, 100), (200, 100), (200, 200), (100, 200)),
"texCoord" : ((0, 0), (1, 0), (1, 1), (0, 1))})
batch = batch_for_shader(
shader, 'TRI_FAN',
{
"pos": ((100, 100), (200, 100), (200, 200), (100, 200)),
"texCoord": ((0, 0), (1, 0), (1, 1), (0, 1)),
},
)
if image.gl_load():
raise Exception()
def draw():
bgl.glActiveTexture(bgl.GL_TEXTURE0)
bgl.glBindTexture(bgl.GL_TEXTURE_2D, image.bindcode)
@@ -28,4 +33,5 @@ def draw():
shader.uniform_int("image", 0)
batch.draw(shader)
bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL')
bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL')