forked from glumpy/glumpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp-two-programs.py
43 lines (34 loc) · 1 KB
/
app-two-programs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -----------------------------------------------------------------------------
# Copyright (c) 2009-2016 Nicolas P. Rougier. All rights reserved.
# Distributed under the (new) BSD License.
# -----------------------------------------------------------------------------
import numpy as np
from glumpy import gl, app, gloo
vertex = """
attribute vec2 a_position;
void main() {
gl_Position = vec4(a_position, 0.0, 1.0);
gl_PointSize = 30.0;
}
"""
fragment1 = """
void main() {
gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
}
"""
fragment2 = """
void main() {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
"""
program1 = gloo.Program(vertex, fragment1) # blue on the right
program1['a_position'] = np.zeros((1,2),dtype=np.float32) + 0.5
program2 = gloo.Program(vertex, fragment2) # red on the left
program2['a_position'] = np.zeros((1,2),dtype=np.float32) - 0.5
window = app.Window()
@window.event
def on_draw(dt):
window.clear()
program1.draw(gl.GL_POINTS)
program2.draw(gl.GL_POINTS)
app.run()