64 lines
2.0 KiB
Python
Executable File
64 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
||
"""
|
||
简单的OpenGL测试脚本,用于验证NVIDIA GPU是否正常工作
|
||
"""
|
||
|
||
import os
|
||
import sys
|
||
|
||
# 设置NVIDIA GPU环境变量
|
||
os.environ['__NV_PRIME_RENDER_OFFLOAD'] = '1'
|
||
os.environ['__GLX_VENDOR_LIBRARY_NAME'] = 'nvidia'
|
||
|
||
try:
|
||
from panda3d.core import loadPrcFileData
|
||
from direct.showbase.ShowBase import ShowBase
|
||
|
||
print("🔍 测试Panda3D和OpenGL...")
|
||
|
||
# 基本配置
|
||
loadPrcFileData("", "window-type offscreen")
|
||
loadPrcFileData("", "win-size 800 600")
|
||
|
||
class TestApp(ShowBase):
|
||
def __init__(self):
|
||
ShowBase.__init__(self)
|
||
|
||
# 获取GPU信息
|
||
if hasattr(self, 'win') and self.win:
|
||
gsg = self.win.get_gsg()
|
||
if gsg:
|
||
print(f"✅ GPU驱动供应商: {gsg.get_driver_vendor()}")
|
||
print(f"✅ GPU渲染器: {gsg.get_driver_renderer()}")
|
||
print(f"✅ GPU驱动版本: {gsg.get_driver_version()}")
|
||
|
||
# 检查OpenGL版本
|
||
gl_version = gsg.get_driver_version_major(), gsg.get_driver_version_minor()
|
||
print(f"✅ OpenGL版本: {gl_version[0]}.{gl_version[1]}")
|
||
|
||
if gl_version[0] >= 4 and gl_version[1] >= 3:
|
||
print("✅ OpenGL版本满足RenderPipeline要求")
|
||
else:
|
||
print("❌ OpenGL版本不满足RenderPipeline要求(需要4.3+)")
|
||
else:
|
||
print("❌ 无法获取图形状态")
|
||
else:
|
||
print("❌ 无法创建窗口")
|
||
|
||
# 立即退出
|
||
self.userExit()
|
||
|
||
print("正在初始化Panda3D...")
|
||
app = TestApp()
|
||
print("✅ Panda3D初始化成功")
|
||
|
||
except ImportError as e:
|
||
print(f"❌ 导入错误: {e}")
|
||
print("请确保Panda3D已正确安装")
|
||
sys.exit(1)
|
||
except Exception as e:
|
||
print(f"❌ 测试失败: {e}")
|
||
sys.exit(1)
|
||
|
||
print("🎉 OpenGL测试完成")
|