Exemple #1
0
def get_dk2():
    for monitor in fw.get_monitors():
        if monitor.physical_size == (71, 126):
            return monitor
    return None

    # If we're still here (no rift?), lets just return the primary display
    return fw.get_primary_monitor()
Exemple #2
0
Fichier : app.py Projet : lhl/vrdev
def get_dk2():
  for monitor in fw.get_monitors():
    if monitor.physical_size == (71, 126):
      return monitor
  return None

  # If we're still here (no rift?), lets just return the primary display
  return fw.get_primary_monitor()
    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
Exemple #4
0
def get_rift():
  '''
  http://unix.stackexchange.com/questions/67983/get-monitor-make-and-model-and-other-info-in-human-readable-form
  http://superuser.com/questions/800572/interpret-edid-information-to-get-manufacturer-and-type-number-of-my-laptop-scre
  http://ubuntuforums.org/showthread.php?t=1946208
  https://github.com/glfw/glfw/issues/212

  If we could easily read the EDID that'd be much easier
  Vendor is OVR

  read-edid barfs w/ Nvida (maybe can use NV-CONTROL)

  xrandr --verbose works...
  '''

  # For now, lets do the easiest thing and get it by physical size of DK2
  for monitor in fw.get_monitors():
    if monitor.physical_size == (71, 126):
      return monitor

  ### TODO: DK1 physical size

  # If we're still here (no rift?), lets just return the primary display
  return fw.get_primary_monitor()
Exemple #5
0
def get_rift():
  '''
  http://unix.stackexchange.com/questions/67983/get-monitor-make-and-model-and-other-info-in-human-readable-form
  http://superuser.com/questions/800572/interpret-edid-information-to-get-manufacturer-and-type-number-of-my-laptop-scre
  http://ubuntuforums.org/showthread.php?t=1946208
  https://github.com/glfw/glfw/issues/212

  If we could easily read the EDID that'd be much easier
  Vendor is OVR

  read-edid barfs w/ Nvida (maybe can use NV-CONTROL)

  xrandr --verbose works...
  '''

  # For now, lets do the easiest thing and get it by physical size of DK2
  for monitor in fw.get_monitors():
    if monitor.physical_size == (71, 126):
      return monitor

  ### TODO: DK1 physical size

  # If we're still here (no rift?), lets just return the primary display
  return fw.get_primary_monitor()
Exemple #6
0
    def pos(self, x_y):
        x, y = x_y
        self.pos_x = self.cnt_x + x
        self.pos_y = self.cnt_y + y


def on_key(window, key, scancode, action, mods):
    if action == glfw.Window.PRESS and key == glfw.Keys.ESCAPE:
        window.should_close = True


if __name__ == '__main__':

    glfw.init()

    pm = glfw.get_primary_monitor()

    vm = pm.video_modes[-1]

    win = glfw.Window(vm.width, vm.height, "nayadra", pm)
    win.swap_interval(0)
    win.set_key_callback(on_key)

    if not win.monitor == pm:
        raise Exception("Wrong monitor set!")

    jst = glfw.Joystick(0)

    with win:
        render = Render(win.framebuffer_size)
Exemple #7
0
    @pos.setter
    def pos(self, x_y):
        x, y = x_y
        self.pos_x = self.cnt_x + x
        self.pos_y = self.cnt_y + y


def on_key(window, key, scancode, action, mods):
    if action == glfw.Window.PRESS and key == glfw.Keys.ESCAPE:
        window.should_close = True

if __name__ == '__main__':

    glfw.init()

    pm = glfw.get_primary_monitor()

    vm = pm.video_modes[-1]

    win = glfw.Window(vm.width, vm.height, "nayadra", pm)
    win.swap_interval(0)
    win.set_key_callback(on_key)

    if not win.monitor == pm:
        raise Exception("Wrong monitor set!")

    jst = glfw.Joystick(0)

    with win:
        render = Render(win.framebuffer_size)