Draw spheres using glutWiredSphere
authorDmitriy Morozov <dmitriy@mrzv.org>
Thu, 05 May 2011 09:24:41 -0700
changeset 13 a4e763e563c5
parent 12 2d50a82295ab
child 14 9e82d4394fc3
Draw spheres using glutWiredSphere
spheres.py
--- a/spheres.py	Thu May 05 08:43:19 2011 -0700
+++ b/spheres.py	Thu May 05 09:24:41 2011 -0700
@@ -1,6 +1,7 @@
 from        OpenGL.GL   import glGenLists, glNewList, GL_COMPILE, glEndList, glCallList, \
                                glBegin, glEnd, GL_LINES, glVertex3f, glColor3f, \
-                               glEnable, glDisable, GL_LIGHTING, GL_POINTS
+                               glEnable, glDisable, GL_LIGHTING, GL_POINTS, glTranslatef
+from        OpenGL.GLUT import glutInit, glutWireSphere
 
 from        points      import Point, centerMinMax
 from        ViewerItem  import ViewerItem
@@ -14,6 +15,7 @@
 
         self.read_spheres(filename)
 
+        glutInit()
         self.create_display_list()
         self.center, self.min, self.max = centerMinMax(self.vertices())
 
@@ -25,11 +27,10 @@
         glEndList()
 
     def draw_spheres(self):
-        # TODO
-        glBegin(GL_POINTS)
         for (c,r) in self.spheres:
-            glVertex3f(c.x, c.y, c.z)
-        glEnd()
+            glTranslatef(c.x,c.y,c.z)
+            glutWireSphere(r, 20, 20)
+            glTranslatef(-c.x,-c.y,-c.z)
 
     def draw(self):
         if not self.visible: return