Advertisement
webbersof

Cube

Nov 27th, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. import pygame
  2. from pygame.locals import *
  3.  
  4. from OpenGL.GL import *
  5. from OpenGL.GLU import *
  6.  
  7. verticies = (
  8.     (1, -1, -1),
  9.     (1, 1, -1),
  10.     (-1, 1, -1),
  11.     (-1, -1, -1),
  12.     (1, -1, 1),
  13.     (1, 1, 1),
  14.     (-1, -1, 1),
  15.     (-1, 1, 1)
  16.     )
  17.  
  18. edges = (
  19.     (0,1),
  20.     (0,3),
  21.     (0,4),
  22.     (2,1),
  23.     (2,3),
  24.     (2,7),
  25.     (6,3),
  26.     (6,4),
  27.     (6,7),
  28.     (5,1),
  29.     (5,4),
  30.     (5,7)
  31.     )
  32.  
  33.  
  34. def Cube():
  35.     glBegin(GL_LINES)
  36.     for edge in edges:
  37.         for vertex in edge:
  38.             glVertex3fv(verticies[vertex])
  39.     glEnd()
  40.  
  41.  
  42. def main():
  43.     pygame.init()
  44.     display = (800,600)
  45.     pygame.display.set_mode(display, DOUBLEBUF|OPENGL)
  46.  
  47.     gluPerspective(45, (display[0]/display[1]), 0.1, 50.0)
  48.  
  49.     glTranslatef(0.0,0.0, -5)
  50.  
  51.     while True:
  52.         for event in pygame.event.get():
  53.             if event.type == pygame.QUIT:
  54.                 pygame.quit()
  55.                 quit()
  56.  
  57.         glRotatef(1, 3, 1, 1)
  58.         glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
  59.         Cube()
  60.         pygame.display.flip()
  61.         pygame.time.wait(10)
  62.  
  63.  
  64. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement