opengl_lesson01.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:program-arcade-games-w-python 作者: Apress 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号