We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f46e780 commit ae341ecCopy full SHA for ae341ec
pygly/gl.py
@@ -78,4 +78,31 @@ def begin( mode ):
78
yield
79
glEnd()
80
81
+@contextmanager
82
+def matrix_mode( mode ):
83
+ """Wraps glMatrixMode in a context manager,
84
+ providing the 'with' keyword.
85
+ Automatically restores the existing matrix
86
+ mode on exit.
87
+
88
+ For example:
89
+ with gl.matrix( GL_MODELVIEW ):
90
+ pass
91
+ """
92
+ glPushAttrib( GL_MATRIX_MODE )
93
+ glMatrixMode( mode )
94
+ yield
95
+ glPopAttrib()
96
97
+def matrix( mat ):
98
+ """Wraps glPushMatrix and glPopMatrix in a
99
+ context manager, providing the 'with' keyword.
100
101
102
+ with gl.matrix( world_matrix ):
103
104
105
+ glPushMatrix( mat )
106
107
+ glPopMatrix()
108
0 commit comments