Commit f2cab549 authored by Guillaume Seguin's avatar Guillaume Seguin

Fix wx2.9 compatibility and cleanup

Tested on both wx2.9 and wx2.8, shouldn't bring any regression.
parent 1e2a09b9
......@@ -47,6 +47,7 @@ class wxGLPanel(wx.Panel):
self.sizer = wx.BoxSizer(wx.HORIZONTAL)
self.canvas = glcanvas.GLCanvas(self, attribList = attribList)
self.context = glcanvas.GLContext(self.canvas)
self.sizer.Add(self.canvas, 1, wx.EXPAND)
self.SetSizer(self.sizer)
self.sizer.Fit(self)
......@@ -56,20 +57,6 @@ class wxGLPanel(wx.Panel):
self.canvas.Bind(wx.EVT_SIZE, self.processSizeEvent)
self.canvas.Bind(wx.EVT_PAINT, self.processPaintEvent)
#==========================================================================
# Canvas Proxy Methods
#==========================================================================
def GetGLExtents(self):
'''Get the extents of the OpenGL canvas.'''
return self.canvas.GetClientSize()
def SwapBuffers(self):
'''Swap the OpenGL buffers.'''
self.canvas.SwapBuffers()
#==========================================================================
# wxPython Window Handlers
#==========================================================================
def processEraseBackgroundEvent(self, event):
'''Process the erase background event.'''
pass # Do nothing, to avoid flashing on MSWin
......@@ -79,8 +66,8 @@ class wxGLPanel(wx.Panel):
if self.canvas.GetContext():
# Make sure the frame is shown before calling SetCurrent.
self.Show()
self.canvas.SetCurrent()
size = self.GetGLExtents()
self.canvas.SetCurrent(self.context)
size = self.canvas.GetClientSize()
self.winsize = (size.width, size.height)
self.width, self.height = size.width, size.height
self.OnReshape(size.width, size.height)
......@@ -90,7 +77,7 @@ class wxGLPanel(wx.Panel):
def processPaintEvent(self, event):
'''Process the drawing event.'''
self.canvas.SetCurrent()
self.canvas.SetCurrent(self.context)
if not self.GLinitialized:
self.OnInitGL()
......@@ -154,7 +141,7 @@ class wxGLPanel(wx.Panel):
self.pygletcontext.set_current()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
self.draw_objects()
self.SwapBuffers()
self.canvas.SwapBuffers()
#==========================================================================
# To be implemented by a sub class
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment