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): ...@@ -47,6 +47,7 @@ class wxGLPanel(wx.Panel):
self.sizer = wx.BoxSizer(wx.HORIZONTAL) self.sizer = wx.BoxSizer(wx.HORIZONTAL)
self.canvas = glcanvas.GLCanvas(self, attribList = attribList) self.canvas = glcanvas.GLCanvas(self, attribList = attribList)
self.context = glcanvas.GLContext(self.canvas)
self.sizer.Add(self.canvas, 1, wx.EXPAND) self.sizer.Add(self.canvas, 1, wx.EXPAND)
self.SetSizer(self.sizer) self.SetSizer(self.sizer)
self.sizer.Fit(self) self.sizer.Fit(self)
...@@ -56,20 +57,6 @@ class wxGLPanel(wx.Panel): ...@@ -56,20 +57,6 @@ class wxGLPanel(wx.Panel):
self.canvas.Bind(wx.EVT_SIZE, self.processSizeEvent) self.canvas.Bind(wx.EVT_SIZE, self.processSizeEvent)
self.canvas.Bind(wx.EVT_PAINT, self.processPaintEvent) 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): def processEraseBackgroundEvent(self, event):
'''Process the erase background event.''' '''Process the erase background event.'''
pass # Do nothing, to avoid flashing on MSWin pass # Do nothing, to avoid flashing on MSWin
...@@ -79,8 +66,8 @@ class wxGLPanel(wx.Panel): ...@@ -79,8 +66,8 @@ class wxGLPanel(wx.Panel):
if self.canvas.GetContext(): if self.canvas.GetContext():
# Make sure the frame is shown before calling SetCurrent. # Make sure the frame is shown before calling SetCurrent.
self.Show() self.Show()
self.canvas.SetCurrent() self.canvas.SetCurrent(self.context)
size = self.GetGLExtents() size = self.canvas.GetClientSize()
self.winsize = (size.width, size.height) self.winsize = (size.width, size.height)
self.width, self.height = size.width, size.height self.width, self.height = size.width, size.height
self.OnReshape(size.width, size.height) self.OnReshape(size.width, size.height)
...@@ -90,7 +77,7 @@ class wxGLPanel(wx.Panel): ...@@ -90,7 +77,7 @@ class wxGLPanel(wx.Panel):
def processPaintEvent(self, event): def processPaintEvent(self, event):
'''Process the drawing event.''' '''Process the drawing event.'''
self.canvas.SetCurrent() self.canvas.SetCurrent(self.context)
if not self.GLinitialized: if not self.GLinitialized:
self.OnInitGL() self.OnInitGL()
...@@ -154,7 +141,7 @@ class wxGLPanel(wx.Panel): ...@@ -154,7 +141,7 @@ class wxGLPanel(wx.Panel):
self.pygletcontext.set_current() self.pygletcontext.set_current()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
self.draw_objects() self.draw_objects()
self.SwapBuffers() self.canvas.SwapBuffers()
#========================================================================== #==========================================================================
# To be implemented by a sub class # 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