Created
May 1, 2023 05:25
-
-
Save EncodeTheCode/440a30ad7cfa3ccc6d20f4498644f45e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
from pygame.locals import * | |
from OpenGL.GL import * | |
from OpenGL.GLU import * | |
from numpy import * | |
vertices = array([ | |
[-1, -1, -1], | |
[1, -1, -1], | |
[1, 1, -1], | |
[-1, 1, -1], | |
[-1, -1, 1], | |
[1, -1, 1], | |
[1, 1, 1], | |
[-1, 1, 1] | |
]) | |
edges = [(0,1), (0,3), (0,4), (1,2), (1,5), (2,3), (2,6), (3,7), (4,5), (4,7), (5,6), (6,7)] | |
def Cube(): | |
glBegin(GL_LINES) | |
for edge in edges: | |
for vertex in edge: | |
glVertex3fv(vertices[vertex]) | |
glEnd() | |
def main(): | |
pygame.init() | |
display = (800, 600) | |
pygame.display.set_mode(display, DOUBLEBUF | OPENGL) | |
gluPerspective(45, (display[0]/display[1]), 0.1, 50.0) | |
glTranslatef(0.0, 0.0, -5) | |
while True: | |
for event in pygame.event.get(): | |
if event.type == pygame.QUIT: | |
pygame.quit() | |
quit() | |
glRotatef(1, 3, 1, 1) | |
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) | |
Cube() | |
pygame.display.flip() | |
pygame.time.wait(10) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment