import wx
+import sys
try:
from wx import glcanvas
def __init__(self, parent):
glcanvas.GLCanvas.__init__(self, parent, -1)
self.init = False
+ self.context = glcanvas.GLContext(self)
+
# initial mouse position
self.lastx = self.x = 30
self.lasty = self.y = 30
def OnSize(self, event):
- size = self.size = self.GetClientSize()
- if self.GetContext():
- self.SetCurrent()
- glViewport(0, 0, size.width, size.height)
+ wx.CallAfter(self.DoSetViewport)
event.Skip()
+ def DoSetViewport(self):
+ size = self.size = self.GetClientSize()
+ self.SetCurrent(self.context)
+ glViewport(0, 0, size.width, size.height)
+
+
def OnPaint(self, event):
dc = wx.PaintDC(self)
- self.SetCurrent()
+ self.SetCurrent(self.context)
if not self.init:
self.InitGL()
self.init = True
# position viewer
glTranslatef(0.0, 0.0, -2.0);
#
- glutInit([])
+ glutInit(sys.argv)
def OnDraw(self):