从压缩档案中读取
我想将所有程序内容放入压缩存档文件中,因为它开始变得相当大。 我知道有一些像 zlib 这样的库,但我不知道如何让它们做我想做的事情:
能够从文件加载纹理/模型等,目前我使用 d3dx 方法,例如 D3DXCreateTextureFromFileEx。 我真的不想为我想要的不同格式编写自己的图像加载器,所以我需要某种方法来与这些 d3d 方法兼容。 我知道他们有一种从内存文件加载的方法,是否适合以某种方式将文件提取到内存中然后加载它?
能够将 C++ 流与压缩存档中的文件一起使用,例如:
std::zipstream file("data.zip:sounds/beep.wav", std::ios::in | std::ios::binary);
I want to place all my programs content in a compressed archive file as its starting to get quite large. I know theres a few libraries around like zlib but i dont know how to make them do what I want to do:
Be able to load textures/models etc from the file, curretly im using d3dx methods such as D3DXCreateTextureFromFileEx. I dont really want to have to write my own image loaders for the diffrent formats I want, so I need some way to be compatible with these d3d methods. I know they have a way to load from an in-memory file, would it be suitable to extract the file into memory somehow then load that?
Be able to use c++ streams with files in the compressed archive eg:
std::zipstream file("data.zip:sounds/beep.wav", std::ios::in | std::ios::binary);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议您查看开源游戏(例如 quake3)。 正如 Vilx 指出的,其中一些正在打包资源并具有“虚拟文件系统”的有效实现。 你可能会得到一些想法。
I'd recommend looking at open source games (quake3 for example). Some of them are packing resources and have working implementations of "virtual file system", as Vilx noted. You might get some ideas.
有一篇题为 对虚拟文件系统进行编程的文章,存档于 flipcode 应该可以提供您需要的内容。 如果您有针对该文章的问题,许多前 Flipcode 会员现在经常访问 论坛,网址为 DevMaster.net。
There is an article entitled Programming a Virtual File System archived on flipcode that should provide what you need. If you have questions specific to that article, many former flipcode members now frequent the forums at DevMaster.net.
对于这类事情有现成的库。 恐怕我不知道任何名称,但我建议用谷歌搜索关键字“虚拟文件系统”。
There are ready made libraries for this sort of thing. I'm afraid I don't know any names, but I suggest to google on the keywords "virtual file system".