本文整理汇总了Python中vispy.gloo.Program.activate方法的典型用法代码示例。如果您正苦于以下问题:Python Program.activate方法的具体用法?Python Program.activate怎么用?Python Program.activate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vispy.gloo.Program
的用法示例。
在下文中一共展示了Program.activate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_context_sharing
# 需要导入模块: from vispy.gloo import Program [as 别名]
# 或者: from vispy.gloo.Program import activate [as 别名]
def test_context_sharing():
"""Test context sharing"""
with Canvas() as c1:
vert = VertexShader("uniform vec4 pos;"
"void main (void) {gl_Position = pos;}")
frag = FragmentShader("uniform vec4 pos;"
"void main (void) {gl_FragColor = pos;}")
program = Program(vert, frag)
program['pos'] = [1, 2, 3, 4]
program.activate() # should print
def check():
program.activate()
check_error()
with Canvas() as c2:
# pyglet always shares
if 'pyglet' not in c2.app.backend_name.lower():
assert_raises(RuntimeError, check)
if c1.app.backend_name.lower() in ('glut',):
assert_raises(RuntimeError, Canvas, context=c1.context)
else:
with Canvas(context=c1.context) as c2:
assert c1.context is c2.context # Same context object
check()