+class glGuiPanel(glcanvas.GLCanvas):
+ def __init__(self, parent):
+ attribList = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24, glcanvas.WX_GL_STENCIL_SIZE, 8)
+ glcanvas.GLCanvas.__init__(self, parent, attribList = attribList)
+ self._parent = parent
+ self._context = glcanvas.GLContext(self)
+ self._glGuiControlList = []
+ self._buttonSize = 64
+
+ wx.EVT_PAINT(self, self._OnGuiPaint)
+ wx.EVT_SIZE(self, self._OnSize)
+ wx.EVT_ERASE_BACKGROUND(self, self._OnEraseBackground)
+ wx.EVT_MOUSE_EVENTS(self, self._OnGuiMouseEvents)
+ wx.EVT_MOTION(self, self._OnGuiMouseMotion)
+
+ def _OnGuiMouseEvents(self,e):
+ if e.ButtonDown() and e.LeftIsDown():
+ for ctrl in self._glGuiControlList:
+ if ctrl.OnMouseDown(e.GetX(), e.GetY()):
+ return
+
+ def _OnGuiMouseMotion(self,e):
+ self.Refresh()
+ for ctrl in self._glGuiControlList:
+ if ctrl.OnMouseMotion(e.GetX(), e.GetY()):
+ return
+ self.OnMouseMotion(e)
+
+ def _OnGuiPaint(self, e):
+ dc = wx.PaintDC(self)
+ self.SetCurrent(self._context)
+ self.OnPaint(e)
+ self._drawGui()
+ glFlush()
+ self.SwapBuffers()
+
+ def _drawGui(self):
+ glDisable(GL_DEPTH_TEST)
+ glEnable(GL_BLEND)
+ glDisable(GL_LIGHTING)
+ glColor4ub(255,255,255,255)
+
+ glMatrixMode(GL_PROJECTION)
+ glLoadIdentity()
+ size = self.GetSize()
+ glOrtho(0, size.GetWidth()-1, size.GetHeight()-1, 0, -1000.0, 1000.0)
+ glMatrixMode(GL_MODELVIEW)
+ glLoadIdentity()
+
+ for glButton in self._glGuiControlList:
+ glButton.draw()
+
+ def _OnEraseBackground(self,event):
+ #Workaround for windows background redraw flicker.
+ pass
+
+ def _OnSize(self,e):
+ self.Refresh()
+
+ def OnMouseEvents(self,e):
+ pass
+
+ def OnMouseMotion(self, e):
+ pass
+ def OnPaint(self, e):
+ pass
+