You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用ModernGL为Pygame创建上下文时遇版本错误求助

在MacOS BigSur 11.7.6中结合Pygame与ModernGL时遇OpenGL版本匹配错误

我正在开发一款基于Pygame的软件,想集成ModernGL的着色器功能,代码参考了某YouTube教程。运行时ModernGL抛出错误:

ValueError: Requested OpenGL version 330, got version 0

我猜测可能是只安装了ModernGL但未配置好OpenGL环境,但执行pip install OpenGL时提示找不到匹配的版本。我的系统是MacOS BigSur 11.7.6,教程中的代码能正常运行,查阅ModernGL官方文档也没找到相关解决方案,特来求助。

代码片段

import moderngl
import pygame
pygame.init()
DISPLAYSURf = pygame.display.set_mode((500,475), pygame.OPENGL | pygame.DOUBLEBUF)
ctx = moderngl.create_context() # <-- 此处触发错误

内容的提问来源于stack exchange,提问作者RandomPythonDev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 06:02:36