1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| import pygame
from pygame.locals import *
from OpenGL.GLU import *
from OpenGL.GL import *
class testMode():
def __init__(self):
self.windowWidth=800
self.windowHeight=600
self.modeOpenGpl = False
pygame.init()
self.windowInit = pygame.display.set_mode((self.windowWidth,self.windowHeight))
self.withoutOpenGpl()
def withOpenGpl(self):
#pygame.display.quit()
#pygame.display.set_mode((self.windowWidth,self.windowHeight), DOUBLEBUF|OPENGL|OPENGLBLIT)
print("Pass1")
self.windowInit.fill((0,128,32))
glMatrixMode(GL_PROJECTION); glLoadIdentity()
gluPerspective(45, (self.windowWidth/self.windowHeight), 0.1, 200.0)
glMatrixMode(GL_MODELVIEW); glLoadIdentity()
glScalef(0.01,0.01,0.01)
gluLookAt(0,0,0, 0,0,-1, 0,1,0)
glBegin(GL_QUADS)
glTexCoord2f(0.0, 0.0); glVertex3f(0.0, -50.0, -1000.0)
glTexCoord2f(1.0, 0.0); glVertex3f(0.0, -50.0, 100.0)
glTexCoord2f(1.0, 1.0); glVertex3f(100.0, -50.0, 1000.0)
glTexCoord2f(0.0, 1.0); glVertex3f(100.0, -50.0, -1000.0)
glEnd()
pygame.display.flip()
def withoutOpenGpl(self):
print("Pass2")
self.windowInit.fill((255,128,32))
#pygame.display.quit()
#self.windowInit = pygame.display.set_mode((self.windowWidth,self.windowHeight))
carre = pygame.Surface((100,100))
carre.fill((255,0,0))
self.windowInit.blit(carre,(10,10))
pygame.display.flip()
tMode = testMode()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit(); import sys; sys.exit()
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
pygame.quit(); import sys; sys.exit()
elif event.key == pygame.K_c:
tMode.modeOpenGpl = not tMode.modeOpenGpl
if tMode.modeOpenGpl: tMode.withOpenGpl()
else: tMode.withoutOpenGpl()
key = pygame.key.get_pressed()
pygame.quit() |
Partager