| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
import glfw |
| 7 |
|
| 8 |
def main(): |
| 9 |
print("Initialize the library") |
| 10 |
if not glfw.init(): |
| 11 |
return 1 |
| 12 |
print("Create a windowed mode window and its OpenGL context") |
| 13 |
window = glfw.create_window(640, 480, "Hello World", None, None) |
| 14 |
if not window: |
| 15 |
glfw.terminate() |
| 16 |
return 2 |
| 17 |
|
| 18 |
print("Make the window's context current") |
| 19 |
glfw.make_context_current(window) |
| 20 |
|
| 21 |
print("Loop until the user closes the window or a certain number of") |
| 22 |
print("iterations has passed, for unattended tests") |
| 23 |
i = 0 |
| 24 |
while i < 8 and not glfw.window_should_close(window): |
| 25 |
print("Render here, e.g. using pyOpenGL") |
| 26 |
i = i + 1 |
| 27 |
print("(iteration " + str(i) + ")") |
| 28 |
|
| 29 |
print("Swap front and back buffers") |
| 30 |
glfw.swap_buffers(window) |
| 31 |
|
| 32 |
print("Poll for and process events") |
| 33 |
glfw.poll_events() |
| 34 |
|
| 35 |
print("Terminate the library") |
| 36 |
glfw.terminate() |
| 37 |
return 0 |
| 38 |
|
| 39 |
if __name__ == "__main__": |
| 40 |
exit(main()) |