예제 #1
0
 def poll_events(self):
     glfw.poll_events()
     try:
         if self._stainq.get_nowait():
             self._on_draw()
     except queue.Empty:
         pass
예제 #2
0
def main():
  ### Initialize
  fw.init()

  ### Monitor Info
  # print_all_monitors()

  ### Rift
  monitor = get_rift()
  curmode = monitor.video_mode
  curmode.refresh_rate # should be 74


  # Check for Monitor - really should check for Rift attach/detach...
  # this doesn't work like I think it should
  fw.Monitor.set_callback(on_monitor)

  win = CbWindow(curmode.width, curmode.height, 'pyglfw', monitor)
  win.make_current()

  while not win.should_close:

    # blue!
    blue = (0.0, 0.0, 1.0, 0.0)
    glClearColor(*blue)

    glClear(GL_COLOR_BUFFER_BIT)

    win.swap_buffers()
    fw.poll_events()

    if win.keys.escape:
        win.should_close = True

  fw.terminate()
예제 #3
0
def main():
    # Initialize the library
    if not glfw.init():
        return
    # Create a windowed mode window and its OpenGL context
    window = glfw.window.Window(640, 480, "Hello World", None, None)
    if not window:
        glfw.terminate()
        return

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

    # Make the window's context current
    window.make_current()

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

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

        # Swap front and back buffers
        window.swap_buffers()

        # Poll for and process events
        glfw.poll_events()

    glfw.terminate()
예제 #4
0
파일: eezl.py 프로젝트: philetus/pyeezl
 def poll_events( self ):
     glfw.poll_events()
     try:
         if self._stainq.get_nowait():
             self._on_draw()
     except queue.Empty:
         pass
예제 #5
0
def main():
  ### Initialize
  fw.init()

  ### Rift
  monitor = get_rift()

  win = CbWindow(640, 480, 'pyglfw')
  win.make_current()

  # XWindows...
  d = Display()
  root = d.screen().root
  pixmap = root.create_pixmap(256, 256, 8)
  # glXCreateWindow(d, cfg, pixmap, 0)


  while not win.should_close:

    render()

    win.swap_buffers()
    fw.poll_events()

    if win.keys.escape:
        win.should_close = True

  fw.terminate()
예제 #6
0
def main():
    ### Initialize
    fw.init()

    ### Monitor Info
    # print_all_monitors()

    ### Rift
    monitor = get_rift()
    curmode = monitor.video_mode
    curmode.refresh_rate  # should be 74

    # Check for Monitor - really should check for Rift attach/detach...
    # this doesn't work like I think it should
    fw.Monitor.set_callback(on_monitor)

    win = CbWindow(curmode.width, curmode.height, 'pyglfw', monitor)
    win.make_current()

    while not win.should_close:

        # blue!
        blue = (0.0, 0.0, 1.0, 0.0)
        glClearColor(*blue)

        glClear(GL_COLOR_BUFFER_BIT)

        win.swap_buffers()
        fw.poll_events()

        if win.keys.escape:
            win.should_close = True

    fw.terminate()
예제 #7
0
    def draw_hologram(self):
        tex_map = self.cuda_pbo.map()
        data, sz = tex_map.device_ptr_and_size()
        self.fill_screen_output(self.holo_real_gpu,
                                self.holo_imag_gpu,
                                self.screenpars_gpu,
                                self.screen_pup_coords_x_gpu,
                                self.screen_pup_coords_y_gpu,
                                numpy.intp(data),
                                block=(1024, 1, 1),
                                grid=(int(self.PUP_NP / 1024) + 1, 1, 1))
        tex_map.unmap()
        glfw.poll_events()
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, self.pbo)
        glBindTexture(GL_TEXTURE_2D, self.pbo)
        glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, self.screenresolution[1],
                        self.screenresolution[0], GL_LUMINANCE,
                        GL_UNSIGNED_BYTE, None)

        glBegin(GL_QUADS)
        glTexCoord2f(0, 1.0)
        glVertex3f(0, 0, 0)
        glTexCoord2f(0, 0)
        glVertex3f(0, 1.0, 0)
        glTexCoord2f(1.0, 0)
        glVertex3f(1.0, 1.0, 0)
        glTexCoord2f(1.0, 1.0)
        glVertex3f(1.0, 0, 0)
        glEnd()
        self.win.swap_buffers()
예제 #8
0
    def run(self):
        """ Runs the game.  This method returns when the terminate flag is set. """

        while not self._terminate:

            time_passed = self.clock.tick(60.)
            print "{0:.3f}\r".format(self.clock.fps),

            self.gameData.update(time_passed)

            self.renderer.update(time_passed)

            glfw.poll_events()

            if self.window.should_close:
                self._terminate = True
예제 #9
0
def main():
    fw.init()

    fw.Monitor.set_callback(on_monitor)

    win = CbWindow(800, 600, "callback window")
    win.make_current()

    while not win.should_close:

        win.swap_buffers()
        fw.poll_events()

        if win.keys.escape:
            win.should_close = True

    fw.terminate()
예제 #10
0
def main():
    fw.init()

    fw.Monitor.set_callback(on_monitor)

    win = CbWindow(800, 600, "callback window")
    win.make_current()

    while not win.should_close:

        win.swap_buffers()
        fw.poll_events()

        if win.keys.escape:
            win.should_close = True

    fw.terminate()
예제 #11
0
def main():
    # Initialize the library
    if not glfw.init():
        return

    # Set some window hints
    glfw.Window.hint(floating=glfw.Window.floating)

    # Create a windowed mode window and its OpenGL context
    window = glfw.Window(300, 300, "Hello World", None, None)
    if not window:
        glfw.terminate()
        return

    # Move Window
    window.pos = (1600, 50)

    # Make the window's context current
    window.make_current()

    # vsync
    window.swap_interval(1)

    # Setup GL shaders, data, etc.
    initialize()

    # Loop until the user closes the window
    while not window.should_close:
        # Render here, e.g. using pyOpenGL
        render()

        # Swap front and back buffers
        window.swap_buffers()

        # Poll for and process events
        glfw.poll_events()

    glfw.terminate()
예제 #12
0
파일: app.py 프로젝트: yoyonel/vrdev
def main():
    fw.init()

    monitor = get_dk2()
    if not monitor:
        sys.exit('Could not find DK2')
    curmode = monitor.video_mode
    print(curmode.refresh_rate)  # should be 74

    win = CbWindow(960, 540, 'pyglfw')
    win.make_current()

    dk2 = DK2(win)

    while not win.should_close:
        dk2.render()

        fw.poll_events()

        if win.keys.escape:
            win.should_close = True

    fw.terminate()
예제 #13
0
파일: app.py 프로젝트: lhl/vrdev
def main():
  fw.init()

  monitor = get_dk2()
  if not monitor:
    sys.exit('Could not find DK2')
  curmode = monitor.video_mode
  print(curmode.refresh_rate) # should be 74

  win = CbWindow(960, 540, 'pyglfw')
  win.make_current()

  dk2 = DK2(win)

  while not win.should_close:
    dk2.render()

    fw.poll_events()

    if win.keys.escape:
        win.should_close = True

  fw.terminate()
예제 #14
0
파일: hello_glfw.py 프로젝트: yuyou/pyovr
def main():
    # Initialize the library
    if not glfw.init():
        return
    # Create a windowed mode window and its OpenGL context
    window = glfw.window.Window(640, 480, "Hello World", None, None)
    if not window:
        glfw.terminate()
        return

    # Make the window's context current
    window.make_current()

    # Loop until the user closes the window
    while not window.should_close:
        # Render here, e.g. using pyOpenGL

        # Swap front and back buffers
        window.swap_buffers()

        # Poll for and process events
        glfw.poll_events()

    glfw.terminate()
예제 #15
0
def main():
  ### Initialize
  fw.init()

  ### Hints
  # ok, that doesn't work... can't get context for that
  # fw.Window.hint(stereo=True)


  ### Monitor Info
  # print_all_monitors()

  ### Rift
  monitor = get_rift()
  curmode = monitor.video_mode
  curmode.refresh_rate # should be 74


  # Check for Monitor - really should check for Rift attach/detach...
  # this doesn't work like I think it should
  fw.Monitor.set_callback(on_monitor)

  win = CbWindow(640, 480, 'pyglfw')
  win.make_current()

  while not win.should_close:

    render()

    win.swap_buffers()
    fw.poll_events()

    if win.keys.escape:
        win.should_close = True

  fw.terminate()
예제 #16
0
# coding=utf-8

import pyglfw.pyglfw as glfw
import common2d

if __name__ == '__main__':
	glfw.init()

	w = glfw.Window(640, 480, "Hello world!")

	w.make_current()

	program = common2d.init_shader_program()

	while not w.should_close:
		# Render here
		common2d.display(program)

		w.swap_buffers()
		glfw.poll_events()

		if w.keys.escape:
			w.should_close = True

	glfw.terminate()

예제 #17
0
# coding=utf-8

import pyglfw.pyglfw as glfw
import common2d

if __name__ == '__main__':
    glfw.init()

    w = glfw.Window(640, 480, "Hello world!")

    w.make_current()

    program = common2d.init_shader_program()

    while not w.should_close:
        # Render here
        common2d.display(program)

        w.swap_buffers()
        glfw.poll_events()

        if w.keys.escape:
            w.should_close = True

    glfw.terminate()
예제 #18
0
        sys.exit(1)

    fw.Window.hint(visible=False)

    for i in range(4):
        windows[i] = fw.Window(200, 200, titles[i])
        if not windows[i]:
            fw.terminate()
            sys.exit(1)

        windows[i].make_current()
        glClearColor(*colors[i])

        windows[i].pos = 100 + (i & 1) * 300, 100 + (i >> 1) * 300
        windows[i].show()

    while running:
        for i in range(4):
            windows[i].make_current()

            glClear(GL_COLOR_BUFFER_BIT)
            windows[i].swap_buffers()

            if windows[i].should_close:
                running = False

        fw.poll_events()

    fw.terminate()
    sys.exit(0)
예제 #19
0
파일: windows.py 프로젝트: lhl/pyglfw
        sys.exit(1)

    fw.Window.hint(visible=False)

    for i in range(4):
        windows[i] = fw.Window(200, 200, titles[i])
        if not windows[i]:
            fw.terminate()
            sys.exit(1)

        windows[i].make_current()
        glClearColor(*colors[i])

        windows[i].pos = 100 + (i & 1) * 300, 100 + (i >> 1) * 300
        windows[i].show()

    while running:
        for i in range(4):
            windows[i].make_current()

            glClear(GL_COLOR_BUFFER_BIT)
            windows[i].swap_buffers()

            if windows[i].should_close:
                running = False

        fw.poll_events()

    fw.terminate()
    sys.exit(0)