How to use the glfw.poll_events function in glfw

To help you get started, we’ve selected a few glfw examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mdcutone / psychxr / test_rift.py View on Github external
# if button 'A' is released on the touch controller, recenter the
        # viewer in the scene.
        if rift.get_buttons('touch', 'A', 'falling'):
            rift.recenter_tracking_origin()
        elif rift.get_buttons('touch', 'B', 'falling'):
            # exit if button 'B' is pressed
            break
        elif rift.get_buttons('touch', 'X', 'falling'):
            rift.set_render_high_quality(False)
        elif rift.get_buttons('touch', 'Y', 'falling'):
            rift.set_render_high_quality(True)

        # flip the GLFW window and poll events
        glfw.swap_buffers(window)
        glfw.poll_events()

    # switch off the performance summary
    rift.perf_hud_mode("Off")

    # end the rift session cleanly, all swap chains are destroyed here
    rift.end_session()

    # close the GLFW application
    glfw.terminate()

    return 0
github swistakm / pyimgui / doc / examples / glfw3.py View on Github external
def main():
    window = impl_glfw_init()
    impl = GlfwRenderer(window)

    while not glfw.window_should_close(window):
        glfw.poll_events()
        impl.process_inputs()

        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True
                )

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()
github nobuyuki83 / delfem2 / pydelfem2 / gl / _glfw.py View on Github external
glfw.set_mouse_button_callback(self.win, self.mouse)
    glfw.set_cursor_pos_callback(self.win, self.motion)
    glfw.set_key_callback(self.win, self.keyinput)
#    glfw.set_window_size_callback(self.win, self.window_size)
    while not glfw.window_should_close(self.win):
      gl.glClearColor(self.color_bg[0], self.color_bg[1], self.color_bg[2], 1.0)
      gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
      gl.glEnable(gl.GL_POLYGON_OFFSET_FILL)
      gl.glPolygonOffset(1.1, 4.0)
      self.wm.camera.set_gl_camera()
      for func_step_time in self.list_func_step_time:
        func_step_time()
      for draw_func in self.list_func_draw:
        draw_func()
      glfw.swap_buffers(self.win)
      glfw.poll_events()
      if self.wm.isClose:
        break
    self.close()
github totex / PyOpenGL_tutorials / video_09_texturing_quad.py View on Github external
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)

    image = Image.open("res/crate.jpg")
    img_data = numpy.array(list(image.getdata()), numpy.uint8)
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, img_data)




    glUseProgram(shader)

    glClearColor(0.2, 0.3, 0.2, 1.0)

    while not glfw.window_should_close(window):
        glfw.poll_events()

        glClear(GL_COLOR_BUFFER_BIT)

        glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, None)

        glfw.swap_buffers(window)

    glfw.terminate()
github 3D-Printing-for-Microfluidics / OpenGL-STL-slicer / pyopengl / app_pyopengl.py View on Github external
i, height = 0, 0.
    while not glfw.window_should_close(window):
        processInput(window)
        
        if height >= params.total_thickness - EPSILON:
            break
        else:
            height += layer_thickness
            i += 1
        
        draw(sliceShader, height-EPSILON)
        renderSlice(sliceShader, height-EPSILON, os.path.join(slice_save_path, 'out{:04d}.png'.format(i-1)))
        
        glfw.swap_buffers(window)
        glfw.poll_events()
    
    glfw.terminate()
github almarklein / wgpu-py / examples / triangle_glfw.py View on Github external
def simple_event_loop():
    """ A real simple event loop, but it keeps the CPU busy. """
    while update_glfw_canvasses():
        glfw.poll_events()
github cmbruns / pyopenvr / src / openvr / glframework / glfw_app.py View on Github external
def render_scene(self):
        "render scene one time"
        self.init_gl() # should be a no-op after the first frame is rendered
        glfw.make_context_current(self.window)
        self.renderer.render_scene()
        # Done rendering
        # glfw.swap_buffers(self.window) # avoid double buffering to avoid stalling
        glFlush() # single buffering
        glfw.poll_events()
github almarklein / wgpu-py / examples / example_glfw.py View on Github external
def __mainLoop(self):
        while not glfw.window_should_close(self.__window):
            glfw.poll_events()
            self.__drawFrame()
github totex / PyOpenGL_tutorials / main.py View on Github external
position = glGetAttribLocation(shader, "position")
    glVertexAttribPointer(position, 3, GL_FLOAT, GL_FALSE, 24, ctypes.c_void_p(0))
    glEnableVertexAttribArray(position)

    color = glGetAttribLocation(shader, "color")
    glVertexAttribPointer(color, 3, GL_FLOAT, GL_FALSE, 24, ctypes.c_void_p(12))
    glEnableVertexAttribArray(color)


    glUseProgram(shader)

    glClearColor(0.2, 0.3, 0.2, 1.0)

    while not glfw.window_should_close(window):
        glfw.poll_events()

        glClear(GL_COLOR_BUFFER_BIT)

        glDrawArrays(GL_TRIANGLES, 0, 3)

        glfw.swap_buffers(window)

    glfw.terminate()