Pygame 和 PyOpenGL:屏幕上不显示任何形状

问题描述

我之前使用 C++ 和 OpenGL 创建了一个完整的蛇游戏,我想使用 Python、pygame 和 PyOpenGL 做同样的事情。我目前遇到的问题是我生成水果后,它没有出现在屏幕上。这是我的主要功能的代码:

def get_dataset_keys(f):
    keys = []
    f.visit(lambda key : keys.append(key) if isinstance(f[key],h5py.Dataset) else None)
    return keys

我可能缺少 pygame 或 pyopengl 函数,但我不确定。我也尝试将 def main(): # Main function # Initialize game components game = Game(800,600) test_fruit = game.spawn_fruit(Point(100,100)) # Initialize pygame module pygame.init() pygame.display.set_mode(game.get_window_size(),DOUBLEBUF | OPENGL) pygame.display.set_caption("Python Game") # Define variable to control main loop running = True # Main loop while running: # event handling,gets all event from the event queue for event in pygame.event.get(): # only do something if the event is of type QUIT if event.type == pygame.QUIT: # change the value to False,to exit the main loop running = False # Modify game properties glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) game.draw_shapes() pygame.display.flip() pygame.time.wait(5) 更改为 pygame.display.flip(),但它却给了我一个错误(“无法更新 OpenGL 显示”)。

这是我试图显示的形状的代码:

pygame.display.update()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)