def __init__(self): with open("config.json") as cfg_file: game_cfg = load_json(cfg_file) if not glfw.init(): raise RuntimeError("Failed to initialise GLFW") GlfwWindow.hint(samples=game_cfg["aaSamples"]) GlfwWindow.hint(context_ver_major=3) GlfwWindow.hint(context_ver_minor=3) GlfwWindow.hint(forward_compat=True) GlfwWindow.hint(resizable=True) GlfwWindow.hint(opengl_profile=GlfwWindow.CORE_PROFILE) primary_monitor = None if game_cfg["fullscreen"]: primary_monitor = glfw.get_primary_monitor() self.window = GlfwWindow(game_cfg["screenWidth"], game_cfg["screenHeight"], "Tutorial", primary_monitor) if not self.window: raise RuntimeError("Failed to initialise window.") self.window.make_current() self.clock = Clock() self.dispatchTable = DispatchTable(self.window) # setup keyboard and mouse controls self.dispatchTable.registerKey(glfw.Keys.ESCAPE, self.escape) self.dispatchTable.registerKey(glfw.Keys.W, self.moveForward) self.dispatchTable.registerKey(glfw.Keys.S, self.moveBackward) self.dispatchTable.registerKey(glfw.Keys.A, self.moveLeft) self.dispatchTable.registerKey(glfw.Keys.D, self.moveRight) self.dispatchTable.registerMouseButton(glfw.Mice.RIGHT, self.toggleMouseLook) self.renderer = Renderer(self.window) self.renderer.fov = pi / 4. self.camera = None self.gameData = GameData() self._mouseLook = False self._terminate = False