I've implemented some context managers here:
https://github.com/adamlwgriffiths/PyGLy/blob/master/pygly/gl/legacy/...
Note the legacy module prefix.
Also, be aware that using multiple context managers in a single with
statement will result in undesired behavior due to the order that python
unwinds them.
Ie:
with matrix_mode( GL_PROJECTION ), matrix( projmatrix ):
pass
Python unwinds in the same order it set (go figure), so the following will
occur:
matrix mode begins unknown
matrix mode push - matrix mode now projection
matrix push - matrix added to projection matrix stack
matrix mode pop - projection mode popped from matrix mode, matrix mode
unknown
matrix pop - matrix popped from unknown matrix stack
Cheers,
Adam
On Thursday, November 1, 2012 8:11:04 PM UTC+11, Mark wrote:
> Rather than writing:
> glBegin()
> ... draw
> glEnd()
> it would be nice to write:
> with glContext():
> ... draw
> I know I can easily create my own glContext context manager, but it
> just seems that it would be nicer built in. Or is there one and I just
> haven't found it?