-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathvao.py
48 lines (38 loc) · 1.43 KB
/
vao.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
45
46
47
48
from vbo import VBO
from shader_program import ShaderProgram
class VAO:
def __init__(self, ctx):
self.ctx = ctx
self.vbo = VBO(ctx)
self.program = ShaderProgram(ctx)
self.vaos = {}
# cube vao
self.vaos['cube'] = self.get_vao(
program=self.program.programs['default'],
vbo = self.vbo.vbos['cube'])
# shadow cube vao
self.vaos['shadow_cube'] = self.get_vao(
program=self.program.programs['shadow_map'],
vbo = self.vbo.vbos['cube'])
# cat vao
self.vaos['cat'] = self.get_vao(
program=self.program.programs['default'],
vbo=self.vbo.vbos['cat'])
# shadow cat vao
self.vaos['shadow_cat'] = self.get_vao(
program=self.program.programs['shadow_map'],
vbo=self.vbo.vbos['cat'])
# skybox vao
self.vaos['skybox'] = self.get_vao(
program=self.program.programs['skybox'],
vbo=self.vbo.vbos['skybox'])
# advanced_skybox vao
self.vaos['advanced_skybox'] = self.get_vao(
program=self.program.programs['advanced_skybox'],
vbo=self.vbo.vbos['advanced_skybox'])
def get_vao(self, program, vbo):
vao = self.ctx.vertex_array(program, [(vbo.vbo, vbo.format, *vbo.attribs)], skip_errors=True)
return vao
def destroy(self):
self.vbo.destroy()
self.program.destroy()