C++能够处理 1,000,000 个 2D 精灵的 2D 图形库?
我正在尝试做一个需要处理大量简单 2D 对象的项目,当然还需要绘制它们。为此,我需要一个好的 C++ 库来处理大量的“精灵”。
我一直在尝试 Qt,因为我认为他们的“40,000 芯片”演示非常令人印象深刻。然而,稍微摆弄一下,我的电脑似乎在管理 160,000 个芯片时遇到了很多麻烦。我不知道它为什么慢的技术细节(CPU?OpenGL的GPU使用不好?Qt对于大量项目来说不好?)
所以,我一直在网上搜索适合我需要的库。但我找不到任何库,主要是因为似乎没有库说“嘿,我擅长管理 1,000,000 个对象!”,但我确信有些库比其他库更有能力。
我不需要像 SDL 这样“好”的库,如果我没有操纵杆支持或其他什么也没关系。我只需要显示、缩放、旋转和移动大量简单的 2D 对象。
谢谢!
PS:我测试过Ogre3D。我想知道他们的演示程序如何在我的计算机上处理 15K 个三角形并以 100fps 的速度运行。而且,它是 3D 的!如果我使用 150K 个三角形,它是否可以很好地扩展?
I'm trying to do a project that need to handles very large amount of simple 2D objects, and of course needs to draw them. For that, I need a good C++ library that can handle large amount of "sprites".
I've been trying Qt, because I thought their "40,000 chip" demo was very impressive. However, with a bit of toying, it seems my computer has lot of trouble managing 160,000 chips. I don't know the technical details why it's slow (CPU? Bad OpenGL's GPU usage? Qt's bad for very large number of items?)
So, I've been searching the web for a library that suits my need. But I couldn't find any, mainly because no library seems to say "Hey, I'm good at managing 1,000,000 objects!", but I'm sure some libraries are more capable than others.
I don't need a library as "good" as the SDL, it doesn't matter if I don't have joystick support or whatever. I just need to display, zoom, rotate and move a large number of simple 2D objects.
Thanks!
P.S : I've tested Ogre3D. I wonder how they manage to handle 15K triangles and run at 100fps on my computer in their demo program. And, it's in 3D! Does it scale well if I go to 150K triangles?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在这里猜测,但我认为问题是 GUI 工具包(如 qt、gtk)的对象对于您使用 1,000,000 个来说太重了。 GUI 对象是引用计数的,并且具有大量额外数据。确实,我不认为您会找到一个可以满足您要求的 GUI 工具包。
然而,您需要的是 2d 图形(或 3d)库。对于这种大小的东西,您需要在相当低的水平上有效地管理渲染,OpenGL 是一个合理的选择,尽管它需要一点学习曲线(特别是对于精灵)。但开始看看这个,并找到一个适合你的像样的图书馆。
甚至可能只是将问题更改为“处理 1,000,000 个 2D 精灵的 C++ 2D 图形库?”
I am guessing here, but I think the problem is that GUI toolkits (like qt, gtk) have objects that are just much too heavy for you to use 1,000,000. The GUI objects are reference counted, and have huge amounts of extra data. Really I don't think you will find a GUI toolkit that can do what you want.
However what you need is a 2d graphics (or 3d) library. For something of this size you are going to want to manage the rendering efficiently and at a pretty low level, OpenGL is a reasonable option though it requires a little bit of a learning curve (especially for sprites). But start looking at that, and find a decent library that suites you.
Maybe even just change the question to "C++ 2D Graphics Library that handles 1,000,000 2D sprites?"
据我所知,目前还没有主流视频游戏能够在一帧中渲染 1,000,000 个 2D 精灵(粒子)。然而,2004 年的一个研究项目展示了如何做到这一点:构建百万个粒子系统
在我看来,当视频游戏最终在一帧中渲染 1,000,000 个粒子时,它们将通过 OpenCL 或 DirectCompute 进行渲染,因为这避免了著名的填充率硬件瓶颈,该瓶颈使得在 OpenGL 或 Direct3D 中渲染粒子变得不切实际。
To my knowledge no mainstream videogame exists that renders 1,000,000 2D sprites (particles) in one frame. A research project from 2004 showed how it could be done, however: Building a Million Particle System
In my opinion, when videogames finally do render 1,000,000 particles in a frame, they will do so via OpenCL or DirectCompute, because this avoids the famous fill-rate hardware bottleneck that makes it impractical to render particles in OpenGL or Direct3D.