PyOpenGL + Pygame 在全屏模式下的上限为 60 FPS

发布于 2024-08-01 12:45:23 字数 313 浏览 5 评论 0原文

我目前正在开发一个用 pygame 编写的游戏引擎,我想添加 OpenGL 支持。

我写了一个测试来看看如何让 pygame 和 OpenGL 一起工作,当它在窗口模式下运行时,它的运行速度在 150 到 200 fps 之间。 当我全屏运行它时(我所做的就是在设置窗口时添加 FULLSCREEN 标志),它下降到 60 fps。 我添加了更多绘图功能,看看这是否只是性能大幅下降,但它始终以 60 fps 运行。

我需要做一些额外的事情来告诉 OpenGL 它正在全屏运行还是这是 OpenGL 的限制?

(我运行的是Windows XP)

I'm currently working on a game engine written in pygame and I wanted to add OpenGL support.

I wrote a test to see how to make pygame and OpenGL work together, and when it's running in windowed mode, it runs between 150 and 200 fps. When I run it full screen (all I did was add the FULLSCREEN flag when I set up the window), it drops down to 60 fps. I added a lot more drawing functions to see if it was just a huge performance drop, but it always ran at 60 fps.

Is there something extra I need to do to tell OpenGL that it's running fullscreen or is this a limitation of OpenGL?

(I am running in Windows XP)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

画▽骨i 2024-08-08 12:45:23

正如 frou 所指出的,这可能是由于当您通过调用 display.flip() 更新屏幕时 Pygame 等待垂直回溯。 作为 Pygame display 文档 注意,如果使用 HWSURFACEDOUBLEBUF 标志设置显示模式,display.flip() 将在垂直回扫之前等待交换缓冲区。

老实说,我没有看到任何好的理由(除了基准测试之外)来尝试实现比屏幕刷新率更快的帧速率。 您(以及玩游戏的人)将无法注意到速度或性能的任何差异,因为显示器无论如何只能绘制 60 fps。 另外,如果您不与垂直回扫同步,您很有可能会出现屏幕撕裂< /a>.

As frou pointed out, this would be due to Pygame waiting for the vertical retrace when you update the screen by calling display.flip(). As the Pygame display documentation notes, if you set the display mode using the HWSURFACE or the DOUBLEBUF flags, display.flip() will wait for the vertical retrace before swapping buffers.

To be honest, I don't see any good reason (aside from benchmarking) to try to achieve a frame rate that's faster than the screen's refresh rate. You (and the people playing your game) won't be able to notice any difference in speed or performance, since the display can only draw 60 fps anyways. Plus, if you don't sync with the vertical retrace, there's a good chance that you'll get screen tearing.

━╋う一瞬間旳綻放 2024-08-08 12:45:23

这是V-Sync 问题吗? 有关配置或您的环境的某些因素可能会限制显示器刷新率的最大帧速率。

Is this a V-Sync issue? Something about the config or your environment may be limiting maximum frame rate to your monitor's refresh rate.

溺ぐ爱和你が 2024-08-08 12:45:23

如果在全屏和窗口模式之间切换时没有更改clock.tick(),则几乎可以肯定是垂直同步问题。 如果你使用的是 LCD,那么这是 100% 确定的。

不幸的是,垂直同步可以在很多地方处理,包括 SDL、Pyopengl、显示服务器和视频驱动程序。 如果您使用的是 Windows,您可以调整 nvidia 控制面板中的垂直同步开关进行测试,并且很可能在 Linux 的 nvidia 设置中也有一些内容。 我猜其他制造商的驱动程序也有类似的设置,但这只是猜测。

If you are not changing your clock.tick() when you change between full screen and windowed mode this is almost certainly a vsync issue. If you are on an LCD then it's 100% certain.

Unfortunately v-sync can be handled in many places including SDL, Pyopengl, your display server and your video drivers. If you are using windows you can adjust the vsync toggle in the nvidia control panel to test, and there's more than likely something in nvidia-settings for linux as well. I'd guess other manufacturers drivers have similar settings but that's a guess.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文