]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/GLCanvas.py
Remove const bool
[wxWidgets.git] / wxPython / demo / GLCanvas.py
index 89b984df694b15fa93532faa945fed7bda6cd672..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
@@ -219,7 +225,7 @@ class ConeCanvas(MyCanvasBase):
         glLight(GL_LIGHT0, GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0])
         glLight(GL_LIGHT0, GL_SPECULAR, [1.0, 1.0, 1.0, 1.0])
         glLight(GL_LIGHT0, GL_POSITION, [1.0, 1.0, 1.0, 0.0])
-        glLightModel(GL_LIGHT_MODEL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
+        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
         glEnable(GL_LIGHTING)
         glEnable(GL_LIGHT0)
         glDepthFunc(GL_LESS)
@@ -229,7 +235,8 @@ class ConeCanvas(MyCanvasBase):
         glMatrixMode(GL_MODELVIEW)
         # position viewer
         glTranslatef(0.0, 0.0, -2.0);
-
+        #
+        glutInit(sys.argv)
 
 
     def OnDraw(self):