-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.py
46 lines (35 loc) · 1.2 KB
/
demo.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
from pyglet.graphics.shader import Shader, ShaderProgram
from pyglet.math import Vec3
import pyglet
from sombra_engine.camera import FPSCamera
from sombra_engine.models.obj import OBJLoader
from sombra_engine.scene import Scene
window = pyglet.window.Window(caption="Sombra Engine")
camera = FPSCamera(
window, position=Vec3(0.0, 0.0, -15.0), pitch=90, yaw=90
)
batch = pyglet.graphics.Batch()
model = None
wf = None
@window.event
def on_draw():
window.clear()
pyglet.gl.glEnable(pyglet.gl.GL_DEPTH_TEST)
batch.draw()
def main():
global model, wf
with open('sombra_engine/shaders/default.vert') as f:
vert_shader = Shader(f.read(), 'vertex')
with open('sombra_engine/shaders/lambert.frag') as f:
frag_shader = Shader(f.read(), 'fragment')
program = ShaderProgram(vert_shader, frag_shader)
scene = Scene()
scene.create_light(Vec3(100.0, 150.0, 7.0), Vec3(1.0, 1.0, 1.0))
program.uniforms['light.position'].set(scene.lights[0].position)
program.uniforms['light.color'].set(scene.lights[0].color)
model = OBJLoader.load(
"tests/data/shoe_box2.obj", "House", program, batch=batch,
)
pyglet.app.run()
if __name__ == '__main__':
main()