-
-
Notifications
You must be signed in to change notification settings - Fork 100
/
glumpy-quad-solid.py
32 lines (25 loc) · 976 Bytes
/
glumpy-quad-solid.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
# -----------------------------------------------------------------------------
# Python & OpenGL for Scientific Visualization
# www.labri.fr/perso/nrougier/python+opengl
# Copyright (c) 2017, Nicolas P. Rougier
# Distributed under the 2-Clause BSD License.
# -----------------------------------------------------------------------------
from glumpy import app, gloo, gl
vertex = """
attribute vec2 position;
void main(){ gl_Position = vec4(position, 0.0, 1.0); } """
fragment = """
void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); } """
# Create a window with a valid GL context
window = app.Window()
# Build the program and corresponding buffers (with 4 vertices)
quad = gloo.Program(vertex, fragment, count=4)
# Upload data into GPU
quad['position'] = (-1,+1), (+1,+1), (-1,-1), (+1,-1)
# Tell glumpy what needs to be done at each redraw
@window.event
def on_draw(dt):
window.clear()
quad.draw(gl.GL_TRIANGLE_STRIP)
# Run the app
app.run()