Commit e2fe8d97 authored by Guillaume Seguin's avatar Guillaume Seguin

Move GL initialization check to OnInitGL

parent 87b57175
...@@ -74,10 +74,7 @@ class wxGLPanel(wx.Panel): ...@@ -74,10 +74,7 @@ class wxGLPanel(wx.Panel):
'''Process the drawing event.''' '''Process the drawing event.'''
self.canvas.SetCurrent(self.context) self.canvas.SetCurrent(self.context)
if not self.GLinitialized:
self.OnInitGL() self.OnInitGL()
self.GLinitialized = True
self.OnDraw() self.OnDraw()
event.Skip() event.Skip()
...@@ -92,6 +89,9 @@ class wxGLPanel(wx.Panel): ...@@ -92,6 +89,9 @@ class wxGLPanel(wx.Panel):
#========================================================================== #==========================================================================
def OnInitGL(self, call_reshape = True): def OnInitGL(self, call_reshape = True):
'''Initialize OpenGL for use in the window.''' '''Initialize OpenGL for use in the window.'''
if self.GLinitialized:
return
self.GLinitialized = True
#create a pyglet context for this panel #create a pyglet context for this panel
self.pygletcontext = gl.Context(gl.current_context) self.pygletcontext = gl.Context(gl.current_context)
self.pygletcontext.canvas = self self.pygletcontext.canvas = self
...@@ -110,8 +110,6 @@ class wxGLPanel(wx.Panel): ...@@ -110,8 +110,6 @@ class wxGLPanel(wx.Panel):
def OnReshape(self, width, height): def OnReshape(self, width, height):
'''Reshape the OpenGL viewport based on the dimensions of the window.''' '''Reshape the OpenGL viewport based on the dimensions of the window.'''
if not self.GLinitialized:
self.GLinitialized = True
self.OnInitGL(call_reshape = False) self.OnInitGL(call_reshape = False)
glViewport(0, 0, width, height) glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION) glMatrixMode(GL_PROJECTION)
......
...@@ -90,6 +90,9 @@ class StlViewPanel(wxGLPanel): ...@@ -90,6 +90,9 @@ class StlViewPanel(wxGLPanel):
#========================================================================== #==========================================================================
def OnInitGL(self): def OnInitGL(self):
'''Initialize OpenGL for use in the window.''' '''Initialize OpenGL for use in the window.'''
if self.GLinitialized:
return
self.GLinitialized = True
#create a pyglet context for this panel #create a pyglet context for this panel
self.pygletcontext = Context(current_context) self.pygletcontext = Context(current_context)
self.pygletcontext.canvas = self self.pygletcontext.canvas = self
......
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