this is my code my problem is down below, when i run the code
import pygame as pg
from OpenGL import *
from OpenGL.GL import *
from OpenGL.GLU import *
from pygame.locals import *
def Point():
glBegin(GL_POINTS)
glVertex3f(0,0,0)
glEnd()
def main():
pg.init()
display=(800, 600)
pg.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 pg.event.get():
if event.type == pg.QUIT:
pg.quit()
return
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
Point()
pg.display.flip()
pg.time.wait(10)
main()
when i run ,the window open then closes immediately my interepter is python 3.10.11
this is my code my problem is down below, when i run the code
import pygame as pg
from OpenGL import *
from OpenGL.GL import *
from OpenGL.GLU import *
from pygame.locals import *
def Point():
glBegin(GL_POINTS)
glVertex3f(0,0,0)
glEnd()
def main():
pg.init()
display=(800, 600)
pg.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 pg.event.get():
if event.type == pg.QUIT:
pg.quit()
return
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
Point()
pg.display.flip()
pg.time.wait(10)
main()
when i run ,the window open then closes immediately my interepter is python 3.10.11
Share Improve this question edited Mar 6 at 15:28 ahmad mohammad asked Mar 6 at 15:16 ahmad mohammadahmad mohammad 11 bronze badge 2 |1 Answer
Reset to default 0Try this:
Snippet:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744966824a4603731.html
pygame
functions. Use the debugger to step through the code to see where it goes wrong. – OldBoy Commented Mar 6 at 16:18