为什么 SDL 如此慢以及如何让它运行得更快?

发布于 2024-09-26 05:47:51 字数 456 浏览 1 评论 0原文

我有以下测试设置:

  • 使用 SDL_HWSURFACE 创建的 1024 * 768 屏幕表面
  • 主循环仅包含 SDL_Flip() 和一个简单的 FPS 计数器

问题是:

我只能获得大约 1000 FPS 。当你考虑到你甚至没有画任何东西时,这真的很低!

当我继续在屏幕上传输相当大的表面时,FPS 下降得非常快。

我想做的:

一个逐像素效果/物理可破坏地形/物体游戏。

  • 为什么 SDL 这么慢? (我已经玩了三天的小示例测试,并消除了我可能犯的所有可能的错误,所以我很确定这实际上是 SDL 的错)

  • 有什么秘密技巧可以让它运行得更快吗?

  • 是否有其他 2D API 可以提供简单且快速的单像素访问?

I have the following test setup:

  • 1024 * 768 screen surface created with SDL_HWSURFACE
  • The main loop consists only of SDL_Flip() and a simple FPS counter

The problem is:

I am only getting around 1000 FPS with this. Which is really really low when you consider that you do not even draw anything!

The FPS drop really fast when I continue on to blitting rather large surfaces on the screen as well.

What I wanted to do:

A pixel-per-pixel effects/physics destructible terrain/objects game.

  • Why is SDL so slow? (I have played around for three days with the small example test and eliminated every possible mistake I could have made, so I am quite sure that it actually is SDL's fault)

  • Are there any secret tricks to get it to run faster?

  • Are there other 2D APIs which provide easy and rather fast single-pixel access?

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

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

发布评论

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

评论(2

潇烟暮雨 2024-10-03 05:47:51

像素访问在硬件表面上非常慢(这是硬件限制,而不是 sdl 限制)。

您可以尝试 SFML 它是 OpenGL 加速的。

Pixel access it's very slow in hardware surfaces (it's a hardware limit, not a sdl limit).

You can try SFML that it's OpenGL accelerated.

梦醒时光 2024-10-03 05:47:51

请注意,调用 SDL_HWSURFACE 并不总是会导致使用硬件,具体取决于您的图形卡。

Note that calling SDL_HWSURFACE won't always result in the use of the hardware depending on your graphical card.

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