"""
This module formats an application's Vertex Array Objects (VAOs)
"""
# Import application modules
from shader_program import ShaderProgram
from vbo import VBO
[docs]
class VAO:
def __init__(self, ctx):
self.ctx = ctx
self.vbo = VBO(ctx)
self.program = ShaderProgram(ctx)
self.vaos = {}
# Generate a Cube VAO for a specified shader program
self.vaos['cube'] = self.get_vao(
program=self.program.programs['default'],
vbo=self.vbo.vbos['cube'])
# Generate a Cube VAO shadow-map for a specified shader program
self.vaos['shadow_cube'] = self.get_vao(
program=self.program.programs['shadow_map'],
vbo=self.vbo.vbos['cube'])
# Generate a Cat VAO for a specified shader program
self.vaos['cat'] = self.get_vao(
program=self.program.programs['default'],
vbo=self.vbo.vbos['cat'])
# Generate a Cat VAO shadow-map for a specified shader program
self.vaos['shadow_cat'] = self.get_vao(
program=self.program.programs['shadow_map'],
vbo=self.vbo.vbos['cat'])
# Generate a SkyBox VAO for a specified shader program
self.vaos['skybox'] = self.get_vao(
program=self.program.programs['skybox'],
vbo=self.vbo.vbos['skybox'])
# Generate an advanced SkyBox VAO for a specified shader program
self.vaos['advanced_skybox'] = self.get_vao(
program=self.program.programs['advanced_skybox'],
vbo=self.vbo.vbos['advanced_skybox'])
# Formats a Vertex Buffer Object (VBO) into a renderable Vertex Array Object (VAO)
[docs]
def get_vao(self, program, vbo):
vao = self.ctx.vertex_array(program, [(vbo.vbo, vbo.format, *vbo.attribs)], skip_errors=True)
return vao
[docs]
def destroy(self):
self.vbo.destroy()
self.program.destroy()