+ def OnSize(self, event):
+ size = self.GetClientSize()
+ if self.GetContext():
+ self.SetCurrent()
+ glViewport(0, 0, size.width, size.height)
+
+ def GLInit( self ):
+ glMatrixMode(GL_PROJECTION);
+ # camera frustrum setup
+ glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0);
+ glMaterial(GL_FRONT, GL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
+ glMaterial(GL_FRONT, GL_DIFFUSE, [0.8, 0.8, 0.8, 1.0])
+ glMaterial(GL_FRONT, GL_SPECULAR, [1.0, 0.0, 1.0, 1.0])
+ glMaterial(GL_FRONT, GL_SHININESS, 50.0)
+ glLight(GL_LIGHT0, GL_AMBIENT, [0.0, 1.0, 0.0, 1.0])
+ 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])
+ glEnable(GL_LIGHTING)
+ glEnable(GL_LIGHT0)
+ glDepthFunc(GL_LESS)
+ glEnable(GL_DEPTH_TEST)
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
+
+
+ def OnPaint( self, event ):
+ dc = wxPaintDC(self)
+ if not self.init:
+ self.GLInit()
+ self.init = true
+
+ ### Tell system to use _this_ glcanvas for all commands
+ self.SetCurrent()
+ # clear color and depth buffers
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ # position viewer
+ glMatrixMode(GL_MODELVIEW);
+ # use a fresh transformation matrix
+ glPushMatrix()
+ # position object
+ glTranslate(0.0, 0.0, -2.0);
+ glRotate(30.0, 1.0, 0.0, 0.0);
+ glRotate(30.0, 0.0, 1.0, 0.0);
+
+ ### From cone.py
+ glTranslate(0, -1, 0)
+ glRotate(250, 1, 0, 0)
+ glutSolidCone(1, 2, 50, 10)
+ glPopMatrix()
+ # push into visible buffer
+ self.SwapBuffers()
+
+
+#----------------------------------------------------------------------