为什么 SDL 如此慢以及如何让它运行得更快?
我有以下测试设置:
- 使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像素访问在硬件表面上非常慢(这是硬件限制,而不是 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.
请注意,调用 SDL_HWSURFACE 并不总是会导致使用硬件,具体取决于您的图形卡。
Note that calling SDL_HWSURFACE won't always result in the use of the hardware depending on your graphical card.