Recent Posts
None | 18 sec ago
None | 25 sec ago
None | 37 sec ago
None | 38 sec ago
ASM (NASM) | 46 sec ago
MySQL | 47 sec ago
HTML | 47 sec ago
C# | 58 sec ago
None | 59 sec ago
None | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By phlyingpenguin on the 2nd of Oct 2008 05:06:45 PM Download | Raw | Embed | Report
  1. from OpenGL.GL import *
  2. from OpenGL.GLU import *
  3. from OpenGL.GLUT import *
  4.  
  5. """
  6. This is a converted version of the Homework 4 program from C to Python.
  7. """
  8.  
  9. year = 0
  10. day = 0
  11.  
  12. def display():
  13.         global day,year
  14.         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
  15.         glPushMatrix()
  16.         glColor3f(1.0, 1.0, 0.0)
  17.         glutSolidSphere(1.0, 20, 16)
  18.         glRotatef(year, 0.0, 1.0, 0.0)
  19.         glTranslatef(2.0, 0.0, 0.0)
  20.         glRotatef(day, 0.0, 1.0, 0.0)
  21.         glColor3f(0.0, 0.0, 1.0)
  22.         glutWireSphere(0.2, 10, 8)
  23.         glPopMatrix()
  24.         glutSwapBuffers()
  25.  
  26. def reshape(w, h):
  27.         global day,year
  28.         glViewport(0,0,w,h)
  29.         glMatrixMode(GL_PROJECTION)
  30.         glLoadIdentity()
  31.         if w <= h:
  32.                 glOrtho(-4.0, 4.0, -4.0 *  h /  w, 4.0 *  h /  w, -10.0, 10.0)
  33.         else:
  34.                 glOrtho(-4.0 *  w /  h, 4.0 *  w /  h, -4.0, 4.0, -10.0, 10.0)
  35.         glMatrixMode(GL_MODELVIEW)
  36.         glLoadIdentity()
  37.  
  38. def keyboard(key, x, y):
  39.         global day,year
  40.         if key == 'd': day=(day+10)%360
  41.         if key == 'D' : day=(day-10)%360
  42.         if key == 'y': year=(year+5)%360
  43.         if key == 'Y': year=(year-5)%360
  44.         if key in ['Q','q']: exit(0)
  45.         glutPostRedisplay()
  46.  
  47. glutInit()
  48. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
  49. glutInitWindowSize(500, 500)
  50. glutInitWindowPosition(100,100)
  51. glutCreateWindow("HW4-2")
  52. glClearColor(0.0, 0.0, 0.0, 1.0)
  53. glutDisplayFunc(display)
  54.  
  55. glMatrixMode(GL_PROJECTION)
  56. glutReshapeFunc(reshape)
  57. glutKeyboardFunc(keyboard)
  58. glEnable(GL_DEPTH_TEST) #       /* Enable hidden-surface removal */
  59.  
  60. glutMainLoop()
Submit a correction or amendment below. [ previous version ] | [ difference ] | Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: