]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/GLCanvas.py
use wxString in wxRegKey methods; make it compile without implicit wxString->char...
[wxWidgets.git] / wxPython / demo / GLCanvas.py
index dd8716e63eece3ee03c51af1b1df043f70a2be4c..3c7f3f7c4cdefb3060814295a670470e924711cd 100644 (file)
@@ -1,5 +1,6 @@
 
 import wx
+import sys
 
 try:
     from wx import glcanvas
@@ -77,6 +78,8 @@ class MyCanvasBase(glcanvas.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
@@ -94,16 +97,19 @@ class MyCanvasBase(glcanvas.GLCanvas):
 
 
     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
@@ -230,7 +236,7 @@ class ConeCanvas(MyCanvasBase):
         # position viewer
         glTranslatef(0.0, 0.0, -2.0);
         #
-        glutInit([])
+        glutInit(sys.argv)
 
 
     def OnDraw(self):