-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
44 lines (31 loc) 路 1014 Bytes
/
app.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
44
from glcontext import *
gl = GLContext() # GL object
# setting the viewport and clear color
gl.set_canvas_size(512, 512)
gl.set_clear_color(0.0, 0.0, 0.0, 1.0)
# setting the vertices
gl.set_attributes(
"position",
np.array([[0.0, 0.5, 0.0], [0.5, -0.5, 0.0], [-0.5, -0.5, 0.0]]),
)
# setting the assembly scheme
gl.assembly_scheme = TRIANGLE
# setting the color of each vertex
gl.set_attributes(
"color",
np.array([[1.0, 0.0, 0.0, 1.0], [0.0, 1.0, 0.0, 1.0], [0.0, 0.0, 1.0,
1.0]]),
)
# setting the number of vertices we want to pass to the shader
gl.set_count(3)
# dumy vertex shader
def vertex_shader(attribute: dict, uniform: dict):
return np.append(attribute["position"], 1.0)
# dumy fragment shader
def fragment_shader(attribute: dict, uniform: dict):
return 225 * attribute["color"]
# setting the shaders
gl.vShader = vertex_shader
gl.fShader = fragment_shader
# name of the file
gl.name = "plank-triangle.png"