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)

	program = common2d.init_shader_program()

	# Loop until the user closes the window
	while not glfw.window_should_close(window):
		# Render here
		common2d.display(program)

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

		# Poll for and process events
		glfw.poll_events()

	glfw.terminate()
Example #2
0
	gl.glViewport(0, 0, width, height)

def keyboard( key, x, y ):
	if key == '\033':
		sys.exit( )

if __name__=="__main__":
	# GLUT init
	# --------------------------------------
	glut.glutInit()
	glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA)
	glut.glutCreateWindow('Hello world!')
	glut.glutReshapeWindow(640,480)
	glut.glutReshapeFunc(reshape)
	glut.glutDisplayFunc(displayFunc)
	glut.glutKeyboardFunc(keyboard)

	program = common2d.init_shader_program()
	set_global_program(program)

	# Make program the default program
	gl.glUseProgram(program)

	# Enter mainloop
	# --------------------------------------
	glut.glutMainLoop()

if __name__ == '__main__': 
	main()

# 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()