def main():
""" Main function for the game. """
# Get Pygame ready
pygame.init()
# Set the width and height of the screen [width,height]
size = (640,480)
video_flags = pygame.OPENGL | pygame.DOUBLEBUF
screen = pygame.display.set_mode(size, video_flags)
# Create an OpenGL viewport
resize_gl_scene(size)
init_gl()
# These are for calculating FPS
frames = 0
ticks = pygame.time.get_ticks()
done = False
while not done:
event = pygame.event.poll()
if event.type == pygame.QUIT:
done = True
draw_gl_scene()
pygame.display.flip()
frames = frames + 1
total_ticks = pygame.time.get_ticks() - ticks
print("Average of {:.1f} fps".format((frames * 1000) / total_ticks))
pygame.quit()
opengl_lesson01.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录