voxel_engine/mesh/quad.py

31 lines
791 B
Python
Raw Permalink Normal View History

2023-10-19 12:59:58 +02:00
#!/usr/bin/python3
from settings import *
from mesh.base import BaseMesh
class QuadMesh(BaseMesh):
def __init__(self, app):
super().__init__()
self.app = app
self.ctx = app.ctx
self.program = app.shader_program.quad
self.vbo_format = "3f 3f"
self.attributes = ("in_position", "in_color")
self.vao = self.get_vao()
def get_vertex_data(self):
vertices = [
(0.5, 0.5, 0.0), (-0.5, 0.5, 0.0), (-0.5, -0.5, 0.0),
(0.5, 0.5, 0.0), (-0.5, -0.5, 0.0), (0.5, -0.5, 0.0)
]
colors = [
(0, 1, 0), (1, 0, 0), (1, 1, 0),
(0, 1, 0), (1, 1, 0), (0, 0, 1)
]
vertex_data = numpy.hstack([vertices, colors], dtype="float32")
return vertex_data