glBegin() context manager?

70 views
Skip to first unread message

Mark

unread,
Nov 1, 2012, 5:11:02 AM11/1/12
to pyglet-users
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?

anatoly techtonik

unread,
Nov 1, 2012, 7:14:35 AM11/1/12
to pyglet...@googlegroups.com
Just want to make sure that you aware that immediate mode is deprecated in modern OpenGL versions.

Mark

unread,
Nov 1, 2012, 7:19:53 AM11/1/12
to pyglet-users
I didn't know that. At the moment I'm working through the 4th edn. of
the Open GL SuperBible...

On 1 Nov, 11:14, anatoly techtonik <techto...@gmail.com> wrote:
> Just want to make sure that you aware that immediate mode is deprecated in modern
> OpenGL versions <http://arcsynthesis.org/gltut/>.

anatoly techtonik

unread,
Nov 1, 2012, 8:50:06 AM11/1/12
to pyglet...@googlegroups.com
These are deprecated since OpenGL 3.1

Here is the PDF with some differences explained
http://campar.cs.tum.edu/files/teaching/2011ss/KinectCourse/IntroOpenGL.pdf
--
anatoly t.


On Thu, Nov 1, 2012 at 2:19 PM, Mark <li...@qtrac.plus.com> wrote:
Open GL SuperBible

Adam Griffiths

unread,
Nov 19, 2012, 7:42:49 PM11/19/12
to pyglet...@googlegroups.com
I've implemented some context managers here:

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
Reply all
Reply to author
Forward
0 new messages