Esempio n. 1
0
 def __init__(self):
     super(DemoWidget, self).__init__()
     self.renderer = RiftGLRendererCompatibility()
     # Paint a triangle in the center of the screen
     self.renderer.append(TriangleDrawerCompatibility())
     # Update Rift outside of normal paintGL() sequence,
     # so we don't have to worry about vsync or monitor frame rate.
     self.riftTimer = QTimer(self)
     self.riftTimer.setSingleShot(True)
     self.riftTimer.setInterval(0)
     self.riftTimer.timeout.connect(self.renderRift)
Esempio n. 2
0
    def run(self):
        # Initialize the library
        if not glfw.init():
            return
        # Create a windowed mode window and its OpenGL context
        self.window = glfw.create_window(640, 480, "Hello World", None, None)
        if not self.window:
            glfw.terminate()
            return

        renderer = RiftGLRendererCompatibility()
        # Paint a triangle in the center of the screen
        renderer.append(TriangleDrawerCompatibility())

        # Make the window's context current
        glfw.make_context_current(self.window)

        # Initialize Oculus Rift
        renderer.init_gl()
        renderer.rift.recenter_pose()

        glfw.set_key_callback(self.window, self.key_callback)

        # Loop until the user closes the window
        while not glfw.window_should_close(self.window):
            # Render here, e.g. using pyOpenGL
            renderer.display_rift_gl()

            # Swap front and back buffers
            glfw.swap_buffers(self.window)

            # Poll for and process events
            glfw.poll_events()

        glfw.terminate()
Esempio n. 3
0
 def __init__(self):
     self.renderer = RiftGLRendererCompatibility()
     self.renderer.append(TriangleDrawerCompatibility())
     glutInit()
     glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE)
     glutInitWindowSize(400, 400)
     glutInitWindowPosition(50, 50)
     win = glutCreateWindow("Just a triangle")
     glutDisplayFunc(self.display)
     glutIdleFunc(self.renderer.display_gl)
     glutReshapeFunc(self.renderer.resize_gl)
     glutKeyboardFunc(self.key_press)
     self.renderer.init_gl()
     self.renderer.rift.recenter_pose()
     glutMainLoop()
Esempio n. 4
0
 def run(self):
     # Initialize the library
     if not glfw.init():
         return
     # Create a windowed mode window and its OpenGL context
     self.window = glfw.create_window(640, 480, "Hello World", None, None)
     if not self.window:
         glfw.terminate()
         return
 
     renderer = RiftGLRendererCompatibility()
     # Paint a triangle in the center of the screen
     renderer.append(TriangleDrawerCompatibility())
 
     # Make the window's context current
     glfw.make_context_current(self.window)
 
     # Initialize Oculus Rift
     renderer.init_gl()
     renderer.rift.recenter_pose()
     
     glfw.set_key_callback(self.window, self.key_callback)
 
     # Loop until the user closes the window
     while not glfw.window_should_close(self.window):
         # Render here, e.g. using pyOpenGL
         renderer.display_rift_gl()
 
         # Swap front and back buffers
         glfw.swap_buffers(self.window)
 
         # Poll for and process events
         glfw.poll_events()
 
     glfw.terminate()
Esempio n. 5
0
 def __init__(self):
     super(DemoWidget, self).__init__()
     self.renderer = RiftGLRendererCompatibility()
     # Paint a triangle in the center of the screen
     self.renderer.append(TriangleDrawerCompatibility())
     # Update Rift outside of normal paintGL() sequence,
     # so we don't have to worry about vsync or monitor frame rate.
     self.riftTimer = QTimer(self)
     self.riftTimer.setSingleShot(True)
     self.riftTimer.setInterval(0)
     self.riftTimer.timeout.connect(self.renderRift)
Esempio n. 6
0
class GlutDemoApp():
    def __init__(self):
        self.renderer = RiftGLRendererCompatibility()
        self.renderer.append(TriangleDrawerCompatibility())
        glutInit()
        glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE)
        glutInitWindowSize(400, 400)
        glutInitWindowPosition(50, 50)
        win = glutCreateWindow("Just a triangle")
        glutDisplayFunc(self.display)
        glutIdleFunc(self.renderer.display_gl)
        glutReshapeFunc(self.renderer.resize_gl)
        glutKeyboardFunc(self.key_press)
        self.renderer.init_gl()
        self.renderer.rift.recenter_pose()
        glutMainLoop()

    def display(self):
        self.renderer.display_gl()
        glutSwapBuffers()

    def key_press(self, key, x, y):
        if ord(key) == 27:
            # print "Escape!"
            if bool(glutLeaveMainLoop):
                glutLeaveMainLoop()
            else:
                raise Exception("Application quit")
        if key == "r":
            self.renderer.rift.recenter_pose()
Esempio n. 7
0
class GlutDemoApp():

    def __init__(self):
        self.renderer = RiftGLRendererCompatibility()
        self.renderer.append(TriangleDrawerCompatibility())
        glutInit()
        glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE)
        glutInitWindowSize(400, 400)
        glutInitWindowPosition(50, 50)
        win = glutCreateWindow("Just a triangle")
        glutDisplayFunc(self.display)
        glutIdleFunc(self.renderer.display_gl)
        glutReshapeFunc(self.renderer.resize_gl)
        glutKeyboardFunc(self.key_press)
        self.renderer.init_gl()
        self.renderer.rift.recenter_pose()
        glutMainLoop()        

    def display(self):
        self.renderer.display_gl()
        glutSwapBuffers()

    def key_press(self, key, x, y):
        if ord(key) == 27:
            # print "Escape!"
            if bool(glutLeaveMainLoop):
                glutLeaveMainLoop()
            else:
                raise Exception("Application quit")
        if key == "r":
            self.renderer.rift.recenter_pose()
Esempio n. 8
0
 def __init__(self):
     self.renderer = RiftGLRendererCompatibility()
     self.renderer.append(TriangleDrawerCompatibility())
     glutInit()
     glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE)
     glutInitWindowSize(400, 400)
     glutInitWindowPosition(50, 50)
     win = glutCreateWindow("Just a triangle")
     glutDisplayFunc(self.display)
     glutIdleFunc(self.renderer.display_gl)
     glutReshapeFunc(self.renderer.resize_gl)
     glutKeyboardFunc(self.key_press)
     self.renderer.init_gl()
     self.renderer.rift.recenter_pose()
     glutMainLoop()        
Esempio n. 9
0
class DemoWidget(QGLWidget):

    def __init__(self):
        super(DemoWidget, self).__init__()
        self.renderer = RiftGLRendererCompatibility()
        # Paint a triangle in the center of the screen
        self.renderer.append(TriangleDrawerCompatibility())
        # Update Rift outside of normal paintGL() sequence,
        # so we don't have to worry about vsync or monitor frame rate.
        self.riftTimer = QTimer(self)
        self.riftTimer.setSingleShot(True)
        self.riftTimer.setInterval(0)
        self.riftTimer.timeout.connect(self.renderRift)
        # For display to screen (i.e. not Rift)
        # self.screenTimer = QTimer(self)
        # self.screenTimer.setSingleShot(True)
        # self.screenTimer.setInterval(20)
        # self.screenTimer.timeout.connect(self.updateGL)
        # self.setAutoBufferSwap(True)

    def initializeGL(self):
        self.renderer.init_gl()
        # Begin rendering to Rift as screen rendering begins
        self.renderer.rift.recenter_pose()
        self.riftTimer.start() 

    def paintGL(self):
        # self.renderer.display_desktop_gl()
        # self.screenTimer.start() # perpetually rerender
        pass

    def renderRift(self):
        "Rift rendering is asynchronous wrt paintGL"
        self.makeCurrent()
        self.renderer.display_rift_gl()
        self.doneCurrent()
        self.riftTimer.start() # trigger another call to renderRift

    def resizeGL(self, width, height):
        self.renderer.resize_gl(width, height)
Esempio n. 10
0
class DemoWidget(QGLWidget):
    def __init__(self):
        super(DemoWidget, self).__init__()
        self.renderer = RiftGLRendererCompatibility()
        # Paint a triangle in the center of the screen
        self.renderer.append(TriangleDrawerCompatibility())
        # Update Rift outside of normal paintGL() sequence,
        # so we don't have to worry about vsync or monitor frame rate.
        self.riftTimer = QTimer(self)
        self.riftTimer.setSingleShot(True)
        self.riftTimer.setInterval(0)
        self.riftTimer.timeout.connect(self.renderRift)
        # For display to screen (i.e. not Rift)
        # self.screenTimer = QTimer(self)
        # self.screenTimer.setSingleShot(True)
        # self.screenTimer.setInterval(20)
        # self.screenTimer.timeout.connect(self.updateGL)
        # self.setAutoBufferSwap(True)

    def initializeGL(self):
        self.renderer.init_gl()
        # Begin rendering to Rift as screen rendering begins
        self.renderer.rift.recenter_pose()
        self.riftTimer.start()

    def paintGL(self):
        # self.renderer.display_desktop_gl()
        # self.screenTimer.start() # perpetually rerender
        pass

    def renderRift(self):
        "Rift rendering is asynchronous wrt paintGL"
        self.makeCurrent()
        self.renderer.display_rift_gl()
        self.doneCurrent()
        self.riftTimer.start()  # trigger another call to renderRift

    def resizeGL(self, width, height):
        self.renderer.resize_gl(width, height)