Commit 160c9d62 authored by Guillaume Seguin's avatar Guillaume Seguin

Start cleaning up stlview

parent 1921d2ab
...@@ -67,7 +67,6 @@ class wxGLPanel(wx.Panel): ...@@ -67,7 +67,6 @@ class wxGLPanel(wx.Panel):
def processSizeEvent(self, event): def processSizeEvent(self, event):
'''Process the resize event.''' '''Process the resize event.'''
size = self.GetClientSize() size = self.GetClientSize()
self.winsize = (size.width, size.height)
self.width, self.height = size.width, size.height self.width, self.height = size.width, size.height
if (wx.VERSION > (2,9) and self.canvas.IsShownOnScreen()) or self.canvas.GetContext(): if (wx.VERSION > (2,9) and self.canvas.IsShownOnScreen()) or self.canvas.GetContext():
# Make sure the frame is shown before calling SetCurrent. # Make sure the frame is shown before calling SetCurrent.
......
...@@ -47,10 +47,10 @@ class GLPanel(wx.Panel): ...@@ -47,10 +47,10 @@ class GLPanel(wx.Panel):
# Create the canvas # Create the canvas
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)
self.Layout()
# bind events # bind events
self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.processEraseBackgroundEvent) self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.processEraseBackgroundEvent)
...@@ -77,20 +77,18 @@ class GLPanel(wx.Panel): ...@@ -77,20 +77,18 @@ class GLPanel(wx.Panel):
def processSizeEvent(self, event): def processSizeEvent(self, event):
'''Process the resize event.''' '''Process the resize event.'''
if self.canvas.GetContext(): size = self.GetClientSize()
self.width, self.height = size.width, size.height
if (wx.VERSION > (2,9) and self.canvas.IsShownOnScreen()) or self.canvas.GetContext():
# Make sure the frame is shown before calling SetCurrent. # Make sure the frame is shown before calling SetCurrent.
self.Show() self.canvas.SetCurrent(self.context)
self.canvas.SetCurrent()
size = self.GetGLExtents()
self.winsize = (size.width, size.height)
self.width, self.height = size.width, size.height
self.OnReshape(size.width, size.height) self.OnReshape(size.width, size.height)
self.canvas.Refresh(False) self.canvas.Refresh(False)
event.Skip() event.Skip()
def processPaintEvent(self, event): def processPaintEvent(self, event):
'''Process the drawing event.''' '''Process the drawing event.'''
self.canvas.SetCurrent() self.canvas.SetCurrent(self.context)
# This is a 'perfect' time to initialize OpenGL ... only if we need to # This is a 'perfect' time to initialize OpenGL ... only if we need to
if not self.GLinitialized: if not self.GLinitialized:
...@@ -180,7 +178,7 @@ class GLPanel(wx.Panel): ...@@ -180,7 +178,7 @@ class GLPanel(wx.Panel):
def OnDraw(self, *args, **kwargs): def OnDraw(self, *args, **kwargs):
"""Draw the window.""" """Draw the window."""
#clear the context #clear the context
self.canvas.SetCurrent() self.canvas.SetCurrent(self.context)
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)
#draw objects #draw objects
......
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