-
Notifications
You must be signed in to change notification settings - Fork 0
/
Renderer.py
39 lines (33 loc) · 1.01 KB
/
Renderer.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
from OpenGL.GL import *
from Buffers import VertexBuffer, IndexBuffer
class Renderer:
@staticmethod
def draw(vao, ibo: IndexBuffer, shader):
"""
Renders the content of Vertex Array using the Index Buffer
:param vao: Vertex Array Object
:param ibo: Index Buffer Object
:param shader: Shader
:return:
"""
shader.bind()
vao.bind()
ibo.bind()
glDrawElements(GL_TRIANGLES, ibo.count, GL_UNSIGNED_INT, None)
@staticmethod
def draw(vao, vbo: VertexBuffer, shader):
"""
Renders the content of Vertex Array using the Vertex Buffer
:param vao: Vertex Array Object
:param vbo: Vertex Buffer Object
:param shader: Shader
:return:
"""
shader.bind()
vao.bind()
glDrawArrays(GL_TRIANGLES, 0, vbo.count)
@staticmethod
def clear():
"""Clears color and depth buffers"""
glClear(GL_COLOR_BUFFER_BIT)
glClear(GL_DEPTH_BUFFER_BIT)