#11 Tk Rawopengl resize / matrix mode fix

v2.0
closed-accepted
Tk (1)
5
2002-12-28
2002-11-24
No

Apologies for this not being in a proper patch format.
I can't find the file in your CVS respository, so I
don't know if this is even relevant anymore.

If you attempt to resize a Rawopengl Widget, you can
get into a situation where it recieves a tkRedraw-using
message during the update_idletasks call inside
tkRedraw. This is only a problem inside the
gl{Push|Pop}Matrix pair, since you can cause a stack
overflow.

Also, I wouldn't rely on self.redraw to keep the
matrix mode as projection, so I put another matrix mode
set in there.

Here's the "fixed" function. Perhaps it'd be a good
idea to know why update_idletasks is being called in
redraw.

distribution file: OpenGL/tk/__init__.py
class Rawopengl:
def tkRedraw(self, *dummy):
# This must be outside of a pushmatrix, since a
resize event
# will call redraw recursively.
self.update_idletasks()
self.tk.call(self._w, 'makecurrent')
_mode = glGetDoublev(GL_MATRIX_MODE)

glMatrixMode(GL_PROJECTION)
glPushMatrix()

self.redraw()
glFlush()

glMatrixMode(GL_PROJECTION)
glPopMatrix()

glMatrixMode(_mode)
self.tk.call(self._w, 'swapbuffers')

Discussion

  • Tom Whittock

    Tom Whittock - 2002-11-24

    Logged In: YES
    user_id=376142

    I just realised that this fixes the "PyOpenGL under WinXP
    problem" thread on your users mailing list.

     
  • Mike C. Fletcher

    • assigned_to: nobody --> mcfletch
    • status: open --> closed-accepted
     
  • Mike C. Fletcher

    Logged In: YES
    user_id=34901

    This change is now in CVS (I added some try:finally: clauses
    to the function as well).

     

Log in to post a comment.