How to use the glfw.swap_buffers 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 / demo / rift / libovr_headtracking.py View on Github external
GL.GL_READ_FRAMEBUFFER,
            GL.GL_COLOR_ATTACHMENT0,
            GL.GL_TEXTURE_2D, mirrorId, 0)

        GL.glViewport(0, 0, 800, 600)
        GL.glScissor(0, 0, 800, 600)
        GL.glClearColor(0.0, 0.0, 0.0, 1.0)
        GL.glClear(GL.GL_COLOR_BUFFER_BIT)
        GL.glBlitFramebuffer(0, 0, 800, 600,
                             0, 600, 800, 0,
                             GL.GL_COLOR_BUFFER_BIT,
                             GL.GL_NEAREST)

        GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0)

        glfw.swap_buffers(window)

        updateInputState(CONTROLLER_TYPE_TOUCH)
        A = getButton(CONTROLLER_TYPE_TOUCH, BUTTON_A, 'falling')
        B = getButton(CONTROLLER_TYPE_TOUCH, BUTTON_B, 'falling')

        if A[0]:
            recenterTrackingOrigin()
        elif B[0]:
            break

        glfw.poll_events()

        _, sessionStatus = getSessionStatus()
        if sessionStatus.shouldQuit:
            break
github cmbruns / pyopenvr / src / samples / glfw / hellovr_glfw.py View on Github external
def run_main_loop(self):
        while not glfw.window_should_close(self.window):
            self.handle_input()
            self.render_frame()
            glfw.swap_buffers(self.window)
            GL.glClearColor(0, 0, 0, 1)
            GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
            glfw.poll_events()
github kitao / pyxel / pyxel / app.py View on Github external
def main_loop():
            while not glfw.window_should_close(self._window):
                glfw.poll_events()

                self._measure_fps()
                self._update_viewport()
                self._update_frame()
                self._draw_frame()

                glfw.swap_buffers(self._window)
            glfw.terminate()
github Jerdak / opengl_tutorials_python / tutorial8.py View on Github external
null                                # array buffer offset (c_type == void*)
        )


        # Draw the triangles, vertex data now contains individual vertices
        # so use array length
        glDrawArrays(GL_TRIANGLES, 0, len(vertex_data))

        # Not strictly necessary because we only have 
        glDisableVertexAttribArray(0)
        glDisableVertexAttribArray(1)
        glDisableVertexAttribArray(2)
    
    
        # Swap front and back buffers
        glfw.swap_buffers(window)

        # Poll for and process events
        glfw.poll_events()

        frames += 1

    # !Note braces around vertex_buffer and uv_buffer.  
    # glDeleteBuffers expects a list of buffers to delete
    glDeleteBuffers(1, [vertex_buffer])
    glDeleteBuffers(1, [uv_buffer])
    glDeleteBuffers(1, [normal_buffer])
    glDeleteProgram(program_id)
    glDeleteTextures([texture_id])
    glDeleteVertexArrays(1, [vertex_array_id])

    glfw.terminate()
github totex / PyOpenGL_tutorials / video_17_obj_file_loading.py View on Github external
while not glfw.window_should_close(window):
        glfw.poll_events()

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        rot_x = pyrr.Matrix44.from_x_rotation(0.5 * glfw.get_time() )
        rot_y = pyrr.Matrix44.from_y_rotation(0.8 * glfw.get_time() )

        transformLoc = glGetUniformLocation(shader, "transform")
        glUniformMatrix4fv(transformLoc, 1, GL_FALSE, rot_x * rot_y)

        glDrawArrays(GL_TRIANGLES, 0, len(obj.vertex_index))

        glfw.swap_buffers(window)

    glfw.terminate()
github sciapp / mogli / mogli.py View on Github external
# Create the GR3 scene
    gr3.setbackgroundcolor(255, 255, 255, 0)
    _create_gr3_scene(molecule, show_bonds)
    # Configure GLFW
    glfw.set_cursor_pos_callback(window, _mouse_move_callback)
    glfw.set_mouse_button_callback(window, _mouse_click_callback)
    glfw.swap_interval(1)
    # Start the GLFW main loop
    while not glfw.window_should_close(window):
        glfw.poll_events()
        _set_gr3_camera()
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        gr3.drawimage(0, width, 0, height,
                      width, height, gr3.GR3_Drawable.GR3_DRAWABLE_OPENGL)
        glfw.swap_buffers(window)
    glfw.terminate()
    gr3.terminate()
github tangrams / tangram-es / swig / examples / demo.py View on Github external
def loop(self):
        self.running = True

        lastTime = glfw.get_time()

        while not glfw.window_should_close(self.window) and self.running:
            currentTime = glfw.get_time()
            delta = currentTime - lastTime
            lastTime = currentTime

            tangram.poke_network_queue()

            self.m.update(delta)
            self.m.render()

            glfw.swap_buffers(self.window)
            # glfw.poll_events()
            glfw.wait_events()
github Jerdak / opengl_tutorials_python / tutorial9.py View on Github external
# Draw the triangles !
        glDrawElements(
            GL_TRIANGLES,           # mode
            len(indices),           # count
            GL_UNSIGNED_SHORT,      # type
            null                    # element array buffer offset
        )
        # Not strictly necessary because we only have 
        glDisableVertexAttribArray(0)
        glDisableVertexAttribArray(1)
        glDisableVertexAttribArray(2)
    
    
        # Swap front and back buffers
        glfw.swap_buffers(window)

        # Poll for and process events
        glfw.poll_events()

        frames += 1

    # !Note braces around vertex_buffer and uv_buffer.  
    # glDeleteBuffers expects a list of buffers to delete
    glDeleteBuffers(1, [vertex_buffer])
    glDeleteBuffers(1, [uv_buffer])
    glDeleteBuffers(1, [normal_buffer])
    glDeleteProgram(program_id)
    glDeleteTextures([texture_id])
    glDeleteVertexArrays(1, [vertex_array_id])

    glfw.terminate()