Under Linux (after my previously-posted fix) wxtest.py starts up as a
black window. This is because when the canvas gets its initial
EVT_SIZE event, the GTK/GDK/X window doesn't exist yet, so
.on_resize() can't switch to the correct context (and ends up setting
the viewport and projection matrix of the previous GLX context).
This patch fixes the problem. It keeps .on_resize() from acting on
the wrong context, and calls .on_resize() again on the first EVT_PAINT
event.
(It also includes my previous fix to disable double-buffering.)
Index: wxtest.py
===================================================================
--- wxtest.py (revision 2446)
+++ wxtest.py (working copy)
@@ -50,6 +50,9 @@
self._context = context
def on_resize(self, width, height):
+ if not self._window:
+ return
+
self.switch_to()
glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION)
@@ -118,6 +121,8 @@
def __init__(self, parent, id=-1, config=None, context=None):
super(GTKWxCanvas, self).__init__(parent, id, config, context)
+ self.SetDoubleBuffered(False)
+
self._glx_context = self._context._context
self._x_display = self._config._display
self._x_screen_id = self._screen._x_screen_id
@@ -136,6 +141,9 @@
self._glx_window = glx.glXCreateWindow(self._x_display,
self._config._fbconfig, self._window, None)
self.switch_to()
+
+ width, height = self.GetClientSize()
+ self.on_resize(width, height)
super(GTKWxCanvas, self)._OnPaint(event)
def _switch_to_impl(self):
Carl
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---