-
Notifications
You must be signed in to change notification settings - Fork 0
/
TRON.py
73 lines (57 loc) · 1.91 KB
/
TRON.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import sys
import glfw
from OpenGL.GL import *
import time
import shader_handling
import context
import structure_handling
import object_handling
import file_handling
import light_handling
import keyboard_handling
import camera_handling
import window_handling
import mouse_handling
from file_handling import TronFileHandler
from object_handling import TronObject
from context import main_context
from light_handling import TronDirectionalLight
class TronProgram:
def __init__(self):
if not glfw.init():
print("(!) TRON FATAL ERROR: Failed to init GLFW!")
sys.exit(1)
def new_window(self, camera_id, **kwargs):
context.main_context.windows.append(window_handling.TronWindow(camera_id, **kwargs))
return context.main_context.windows[-1]
def new_camera(self):
context.main_context.cameras.append(camera_handling.TronCamera())
return context.main_context.cameras[-1].id
def main_loop(self):
glEnable(GL_DEPTH_TEST)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glEnable(GL_BLEND)
while True:
for window in context.main_context.windows:
window.draw()
class FPS:
def __init__(self, user_interval):
self.startTime = time.time()
self.interval = user_interval
self.counter = 0
def update(self):
self.counter += 1
def print_fps(self):
if (time.time() - self.startTime) > self.interval:
print("FPS: ", self.counter / (time.time() - self.startTime))
self.counter = 0
self.startTime = time.time()
def update_and_print(self):
self.counter += 1
if (time.time() - self.startTime) > self.interval:
fps = self.counter / (time.time() - self.startTime)
print("FPS: ", fps)
self.counter = 0
self.startTime = time.time()
return fps
return 0