Esempio n. 1
0
def main():
    global gl
    global test_model

    # Initialize the library
    if not glfwInit():
        sys.exit()

    # Initilize GL
    gl = pygloo.init()
    if not gl:
        sys.exit()

    # Create a windowed mode window and its OpenGL context
    window = glfwCreateWindow(640, 480, "Hello World", None, None)
    if not window:
        glfwTerminate()
        sys.exit()

    # Make the window's context current
    glfwMakeContextCurrent(window)

    # Install a input handlers
    glfwSetKeyCallback(window, on_key)
    glfwSetMouseButtonCallback(window, on_mouse)
    glfwSetCursorPosCallback(window, on_mouse_move)
    glfwSetScrollCallback(window, on_scroll)

    # Load an obj
    #
    test_model = Geometry.from_OBJ(gl, "assets/sphere.obj")

    # Loop until the user closes the window
    while not glfwWindowShouldClose(window):

        # Render
        width, height = glfwGetFramebufferSize(window)
        gl.glViewport(0, 0, width, height)

        gl.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0)
        gl.glClearColor(1.0, 1.0, 1.0, 1.0)  # white
        gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        gl.glEnable(GL_DEPTH_TEST)
        # gl.glDepthFunc(GL_LESS);
        gl.glDepthFunc(GL_LEQUAL)

        # Render
        #
        render(width, height)

        # Poll for and process events
        glfwPollEvents()

        # Swap front and back buffers
        glfwSwapBuffers(window)

    glfwTerminate()
Esempio n. 2
0
def main():
	global gl
	global test_model

	# Initialize the library
	if not glfwInit():
		sys.exit()

	# Initilize GL
	gl = pygloo.init()
	if not gl:
		sys.exit()


	# Create a windowed mode window and its OpenGL context
	window = glfwCreateWindow(640, 480, "Hello World", None, None)
	if not window:
		glfwTerminate()
		sys.exit()

	# Make the window's context current
	glfwMakeContextCurrent(window)

	# Install a input handlers
	glfwSetKeyCallback(window, on_key)
	glfwSetMouseButtonCallback(window, on_mouse)
	glfwSetCursorPosCallback(window, on_mouse_move)
	glfwSetScrollCallback(window, on_scroll)



	# Load an obj
	#
	test_model = Geometry.from_OBJ(gl, "assets/sphere.obj")


	# Loop until the user closes the window
	while not glfwWindowShouldClose(window):

		# Render
		width, height = glfwGetFramebufferSize(window)
		gl.glViewport(0, 0, width, height)

		gl.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
		gl.glClearColor(1.0, 1.0, 1.0, 1.0) # white
		gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
		gl.glEnable(GL_DEPTH_TEST);
		# gl.glDepthFunc(GL_LESS);
		gl.glDepthFunc(GL_LEQUAL);

		# Render
		#
		render(width, height)

		# Poll for and process events
		glfwPollEvents()

		# Swap front and back buffers
		glfwSwapBuffers(window)

	glfwTerminate()