C++、Ogre3D、SFML,共享资源?
是否可以以某种方式与程序的其他部分共享从 resources.cfg 加载到 Ogre::ResourceManager 中的 Ogre3D 资源?如果可以使用 SFML 那就太好了。
例如,我知道 CEGUI 可以自动执行此操作。
Is it possible to somehow share the Ogre3D resources loaded in the Ogre::ResourceManager from resources.cfg with other parts of a programm? If possible with SFML that would be nice.
I know that CEGUI, for example, can do this automatically.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Ogre 本质上将资源从文件路径中抽象出来。这是因为资源不一定来自文件系统(它可以通过网络流式传输,或者从压缩存档中解压)。所以不,在不破坏封装的情况下,不可能从 Ogre 资源获取文件系统路径。
您将需要扩展 SFML 拥有的任何资源系统(如果有的话,我不熟悉 SFML 的工作原理),然后将资源数据本身传递到该库中。我发现大多数库都有某种方式向它们提供数据,而不是通过文件系统路径。如果 SFML 没有该功能,我可能建议研究一些更......完整的东西。
您提到 CEGUI 已经做到了这一点。这是正确的。 CEGUI/Ogre 互操作层构建在 Ogre 的资源处理框架之上,几乎可以完成此任务。它向Ogre请求资源,通过Ogre加载它们,然后将数据传递到CEGUI。 CEGUI 本身从不接触文件系统。
Ogre by nature abstracts resources away from their file paths. This is because a resource may not necessarily come from the filesystem (it could be streamed over the network, or unpacked from a compressed archive). So no, without breaking encapsulation it's not possible to get the filesystem path from an Ogre resource.
You will need to extend whatever resource system SFML has (if any, I'm not familiar with how SFML works) and then pass the resource data itself into that library. I've found that most libraries have some way of providing data to them other than via filesystem paths. If SFML doesn't have that feature, I might suggest looking into something a little bit more... complete.
You mentioned that CEGUI does this already. That's correct. The CEGUI/Ogre interop layer builds on top of Ogre's resource handling framework to do pretty much this. It requests resources from Ogre, loads them through Ogre, and then passes the data into CEGUI. CEGUI itself never touches the filesystem.
我认为您可以调用资源管理器来检索您想要的任何内容,然后将其提供给 SFML。当然,您必须编写代码将两者粘合在一起。
I would think you could call Resource Manager to retrieve anything you wanted and then provide it to SFML. You're going to have to write the code to glue the two together of course.