How to use the glfw.terminate 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
def main():
    # start GLFW
    if not glfw.init():
        return -1

    # setup GLFW window options
    glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 2)
    glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 1)

    # open the window
    window = glfw.create_window(800, 600, "Oculus Test", None, None)

    if not window:
        glfw.terminate()

    # always call this before setting up render layers
    glfw.make_context_current(window)

    # load textures from file
    texture_ref_l = load_image(r"C:\Users\mdc\Desktop\test_images\original\left\Aryaa1.ppm")
    texture_ref_r = load_image(r"C:\Users\mdc\Desktop\test_images\original\right\Aryaa1.ppm")
    texture_cmp_l = load_image(r"C:\Users\mdc\Desktop\test_images\compressed\left\Aryaa1_dec.ppm")
    texture_cmp_r = load_image(r"C:\Users\mdc\Desktop\test_images\compressed\right\Aryaa1_dec.ppm")

    # disable v-sync, we are syncing to the v-trace of head-set, leaving this on
    # will cause the HMD to lock to the frequency/phase of the display.
    glfw.swap_interval(0)

    # start an Oculus session
    rift.start_session()
github Jerdak / opengl_tutorials_python / tutorial6.py View on Github external
# Initialize the library
    if not glfw.init():
        print("Failed to initialize GLFW\n",file=sys.stderr)
        return False

    # Open Window and create its OpenGL context
    window = glfw.create_window(1024, 768, "Tutorial 06", None, None) #(in the accompanying source code this variable will be global)
    glfw.window_hint(glfw.SAMPLES, 4)
    glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
    glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
    glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, GL_TRUE)
    glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)

    if not window:
        print("Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n",file=sys.stderr)
        glfw.terminate()
        return False

    # Initialize GLEW
    glfw.make_context_current(window)
    glewExperimental = True

    # GLEW is a framework for testing extension availability.  Please see tutorial notes for
    # more information including why can remove this code.a
    if glewInit() != GLEW_OK:
        print("Failed to initialize GLEW\n",file=sys.stderr);
        return False
    return True
github TimSC / py-modern-opengl / glfw_example3d.py View on Github external
def main():
	# Initialize the library
	if not glfw.init():
		return
	
	glfw.set_error_callback(error_callback)

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

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

	params = common3d.init()
	gl.glClearColor(0.8, 0.8, 0.8, 1.0)

	# Loop until the user closes the window
	while not glfw.window_should_close(window):
		# Render here
		common3d.draw(params, 1.)

		# Swap front and back buffers
		glfw.swap_buffers(window)
github Jerdak / opengl_tutorials_python / tutorial4.py View on Github external
# Initialize the library
	if not glfw.init():
		print("Failed to initialize GLFW\n",file=sys.stderr)
		return False

	# Open Window and create its OpenGL context
	window = glfw.create_window(1024, 768, "Tutorial 04", None, None) #(in the accompanying source code this variable will be global)
	glfw.window_hint(glfw.SAMPLES, 4)
	glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
	glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
	glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, GL_TRUE)
	glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)

	if not window:
		print("Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n",file=sys.stderr)
		glfw.terminate()
		return False

	# Initialize GLEW
	glfw.make_context_current(window)
	glewExperimental = True

	# GLEW is a framework for testing extension availability.  Please see tutorial notes for
	# more information including why can remove this code.
	if glewInit() != GLEW_OK:
		print("Failed to initialize GLEW\n",file=sys.stderr);
		return False
	return True
github nobuyuki83 / delfem2 / pydelfem2 / gl / _glfw.py View on Github external
def close(self):
    glfw.destroy_window(self.win)
    glfw.terminate()
github 3D-Printing-for-Microfluidics / OpenGL-STL-slicer / app.py View on Github external
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 totex / PyOpenGL_tutorials / video_07_cube.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)

        glDrawElements(GL_TRIANGLES, 36, 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
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 totex / PyOpenGL_tutorials / video_09_texturing_quad.py View on Github external
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()