forked from StanislavPetrovV/3D-Graphics-Engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscene_renderer.py
More file actions
34 lines (27 loc) · 862 Bytes
/
scene_renderer.py
File metadata and controls
34 lines (27 loc) · 862 Bytes
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
class SceneRenderer:
def __init__(self, app):
self.app = app
self.ctx = app.ctx
self.mesh = app.mesh
self.scene = app.scene
# depth buffer
self.depth_texture = self.mesh.texture.textures['depth_texture']
self.depth_fbo = self.ctx.framebuffer(depth_attachment=self.depth_texture)
def render_shadow(self):
self.depth_fbo.clear()
self.depth_fbo.use()
for obj in self.scene.objects:
obj.render_shadow()
def main_render(self):
self.app.ctx.screen.use()
for obj in self.scene.objects:
obj.render()
self.scene.skybox.render()
def render(self):
self.scene.update()
# pass 1
self.render_shadow()
# pass 2
self.main_render()
def destroy(self):
self.depth_fbo.release()