-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
49 lines (36 loc) · 1.11 KB
/
main.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
47
48
49
import numpy as np
from OpenGL.GL import *
import glfw
import models
def main():
if not glfw.init():
print("failed to initialize GLFW")
return
resolution = (1000, 1000)
window = glfw.create_window(*resolution, 'simulation', None, None)
if not window:
glfw.terminate()
print("failed to create window")
return
glfw.make_context_current(window)
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 4)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 5)
model: models.Model = models.Boids()
model.setup(window)
fps = 30
glfw.set_time(0)
current = glfw.get_time()
previous = glfw.get_time()
glClearColor(0, 0, 0, 0)
while not glfw.window_should_close(window):
if current - previous >= 1.0 / fps:
glClear(GL_COLOR_BUFFER_BIT)
model.render()
glfw.swap_buffers(window)
previous = current
glfw.poll_events()
current = glfw.get_time()
glfw.destroy_window(window)
glfw.terminate()
if __name__ == "__main__":
main()