ContextGL++ tute2: Howto create a window as the OpenGL context in Python.

First things first. I assume you have installed the python bindings from the pycontextgl package. Just as in the C++ example we are going to make a simple window with an OpenGL context. Open a new file called "test.py"

#!/usr/bin/env python from OpenGL import * import ContextGL window = ContextGL.GLWindow(ContextGL.DOUBLE | ContextGL.DEPTH, 0,0, 400, 400) window.create("Simple Example") window.show() window.makeCurrent() event = ContextGL.WMEvent(window) done = False while not done: glClear(GL_COLOR_BUFFER_BIT) window.swapBuffers() while event.nextEvent(): event_type = event.type() if event_type == ContextGL.CLOSE_EVENT: done = True window.close() elif event_type == ContextGL.BUTTON_PRESS_EVENT: done = True
Run and you should have this ScreenShot1

OK, that concludes the second tutorial on ContextGL++, the first that handles Pyhton bindings. You can find the source for this python program (if you're too lazy to cut and paste) in the root of the pycontextgl source tree.