-
Notifications
You must be signed in to change notification settings - Fork 1
/
glfw_example3d.py
44 lines (32 loc) · 897 Bytes
/
glfw_example3d.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import glfw, common3d
import OpenGL.GL as gl
def error_callback():
print ("error_callback")
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)
# Poll for and process events
glfw.poll_events()
glfw.terminate()
if __name__ == "__main__":
main()