]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/wxGLCanvas.py
fixed the width of the (week day as number) field, should be 1, not 2
[wxWidgets.git] / wxPython / demo / wxGLCanvas.py
index 2fff582751da809d4b610bdd196851736abdbd98..d1e2c025b5fb32a47c5d0357b2833c2ea57cfc76 100644 (file)
@@ -1,4 +1,3 @@
-
 from wxPython.wx       import *
 try:
     from wxPython.glcanvas import *
 from wxPython.wx       import *
 try:
     from wxPython.glcanvas import *
@@ -57,9 +56,16 @@ else:
                 box.Add(btn, 0, wxALIGN_CENTER|wxALL, 15)
                 EVT_BUTTON(self, k, self.OnButton)
 
                 box.Add(btn, 0, wxALIGN_CENTER|wxALL, 15)
                 EVT_BUTTON(self, k, self.OnButton)
 
+            #** Enable this to show putting a wxGLCanvas on the wxPanel
+            if 0:
+                c = CubeCanvas(self)
+                c.SetSize((200, 200))
+                box.Add(c, 0, wxALIGN_CENTER|wxALL, 15)
+
             self.SetAutoLayout(true)
             self.SetSizer(box)
 
             self.SetAutoLayout(true)
             self.SetSizer(box)
 
+
         def OnButton(self, evt):
             canvasClassName = buttonDefs[evt.GetId()][0]
             canvasClass = eval(canvasClassName)
         def OnButton(self, evt):
             canvasClassName = buttonDefs[evt.GetId()][0]
             canvasClass = eval(canvasClassName)
@@ -75,6 +81,7 @@ else:
 
 
 
 
 
 
+
     class MyCanvasBase(wxGLCanvas):
         def __init__(self, parent):
             wxGLCanvas.__init__(self, parent, -1)
     class MyCanvasBase(wxGLCanvas):
         def __init__(self, parent):
             wxGLCanvas.__init__(self, parent, -1)
@@ -85,9 +92,9 @@ else:
             EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
             EVT_SIZE(self, self.OnSize)
             EVT_PAINT(self, self.OnPaint)
             EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
             EVT_SIZE(self, self.OnSize)
             EVT_PAINT(self, self.OnPaint)
-            #EVT_LEFT_DOWN(self, self.OnMouseDown)  # needs fixing...
-            #EVT_LEFT_UP(self, self.OnMouseUp)
-            #EVT_MOTION(self, self.OnMouseMotion)
+            EVT_LEFT_DOWN(self, self.OnMouseDown)  # needs fixing...
+            EVT_LEFT_UP(self, self.OnMouseUp)
+            EVT_MOTION(self, self.OnMouseMotion)
 
         def OnEraseBackground(self, event):
             pass # Do nothing, to avoid flashing on MSW.
 
         def OnEraseBackground(self, event):
             pass # Do nothing, to avoid flashing on MSW.
@@ -116,7 +123,7 @@ else:
             if evt.Dragging() and evt.LeftIsDown():
                 self.x, self.y = self.lastx, self.lasty
                 self.x, self.y = evt.GetPosition()
             if evt.Dragging() and evt.LeftIsDown():
                 self.x, self.y = self.lastx, self.lasty
                 self.x, self.y = evt.GetPosition()
-                self.Refresh()
+                self.Refresh(false)
 
 
 
 
 
 
@@ -183,8 +190,8 @@ else:
             glVertex3f(-0.5, 0.5,-0.5)
             glEnd()
 
             glVertex3f(-0.5, 0.5,-0.5)
             glEnd()
 
-            glRotatef(self.lasty - self.y, 1.0, 0.0, 0.0);
-            glRotatef(self.lastx - self.x, 0.0, 1.0, 0.0);
+            glRotatef((self.lasty - self.y)/100., 1.0, 0.0, 0.0);
+            glRotatef((self.lastx - self.x)/100., 0.0, 1.0, 0.0);
 
             self.SwapBuffers()
 
 
             self.SwapBuffers()
 
@@ -211,13 +218,13 @@ else:
             glDepthFunc(GL_LESS)
             glEnable(GL_DEPTH_TEST)
             glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
             glDepthFunc(GL_LESS)
             glEnable(GL_DEPTH_TEST)
             glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
+            # position viewer
+            glMatrixMode(GL_MODELVIEW);
 
 
         def OnDraw(self):
             # clear color and depth buffers
             glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
 
         def OnDraw(self):
             # 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
             # use a fresh transformation matrix
             glPushMatrix()
             # position object
@@ -227,8 +234,10 @@ else:
 
             glTranslate(0, -1, 0)
             glRotate(250, 1, 0, 0)
 
             glTranslate(0, -1, 0)
             glRotate(250, 1, 0, 0)
-            glutSolidCone(1, 2, 50, 10)
+            glutSolidCone(0.5, 1, 30, 5)
             glPopMatrix()
             glPopMatrix()
+            glRotatef((self.lasty - self.y)/100., 0.0, 0.0, 1.0);
+            glRotatef(0.0, (self.lastx - self.x)/100., 1.0, 0.0);
             # push into visible buffer
             self.SwapBuffers()
 
             # push into visible buffer
             self.SwapBuffers()
 
@@ -268,3 +277,4 @@ def _test():
 
 if __name__ == '__main__':
     _test()
 
 if __name__ == '__main__':
     _test()
+