pip install vispy python import numpy as np from vispy import app, gloo vertex_shader = """ attribute vec2 position; void main() { gl_Position = vec4(position, 0.0, 1.0); } """ fragment_shader = """ void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); } """ vertex_data = np.array([[0, 0], [0.5, 0.5], [-0.5, 0.5]], dtype=np.float32) program = gloo.Program(vertex_shader, fragment_shader) program['position'] = gloo.VertexBuffer(vertex_data) canvas = app.Canvas() canvas.show() @canvas.connect def on_draw(event): gloo.clear(color=True, depth=True) program.draw('triangles') app.run()


上一篇:
下一篇:
切换中文