可以用Python编写一个显示FPS(每秒帧数)的程序吗?

发布于 2024-09-06 19:58:25 字数 77 浏览 1 评论 0原文

我想知道...

可以做到吗?

一个简单的基于控制台命令的程序,显示您当前运行的游戏/程序的 FPS 怎么样?

I was wondering...

It's possible to do it?

A simple console command based program that shows how are your FPS, for your currently running game/program?

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

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

发布评论

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

评论(3

花间憩 2024-09-13 19:58:25

简短回答:是的。

长答案:除了当你在被测程序中有钩子时收集统计数据要简单得多,还可以在较低级别上钩子:直接连接到 DirectX 或 OpenGL。从一些现有帖子。它们是用 C++ 编写的,但那是另一回事:您可以使用 SWIG 在之间进行互操作Python 和 C/C++。

作为一个证明。有著名的 Fraps 应用程序可以执行您所说的操作。

Short answer: Yes.

Long answer: Beside that it is much simpler to gather statistics when you have hooks inside the measured program, it is possible also to hook on lower level: directly to DirectX or OpenGL. Start your discovery from some existing posts. They are in C++ but that's another deal: you can use SWIG to interop between Python and C/C++.

As a proof. There is famous Fraps applications that does what you say.

怎樣才叫好 2024-09-13 19:58:25

简短回答:不。

详细回答:如果不了解应用程序的内部结构,并且应用程序没有适当的挂钩来执行此类测量,则不会。

Short answer: No.

Long answer: Not without knowing the internals of the application, and without the application having the appropriate hooks to perform such a measurement.

噩梦成真你也成魔 2024-09-13 19:58:25

只要您有可用的绑定/挂钩来读取该应用程序通过它使用的任何库正在执行的操作,就可以。
这些计数器通常作为对通过 OpenGL(或 directX)绘制的程序的查询来实现。

如果它是一个 OGL 应用程序,pyOpenGL 提供了大量的功能,可能值得您花时间研究它。我没有使用 directX 的经验,但我假设您可能会找到类似的绑定。

http://www.cs.man.ac.uk/~toby/ frameratedisplayer.htm 如果你想要一个简单的例子来看看它就可以做到这一点(假设你可以理解很少的 C 语法)

As long as you have the available bindings/hooks to read what that application is doing through whatever library it uses, yes.
Those counters are normally implemented as queries to a program drawing through OpenGL (or directX).

If it's an OGL app, pyOpenGL provides a decent amount of functionality, might be worth your time looking into it. I have no experience with directX, but I assume you might find similar bindings.

http://www.cs.man.ac.uk/~toby/frameratedisplayer.htm if you want a simple example to look at that does just that (assuming you're ok puzzling out very little C syntax)

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