登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

秒大刀 博客

好好学习 天天向上

 
 
 

日志

 
 
 
 

Ogre::Resource赏析  

2011-05-02 22:34:12|  分类: Game |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

    Resources are data objects that must be loaded and managed throughout an application. A resource might be a mesh, a texture, or any other piece of data - the key thing is that they must be identified by a name which is unique, must be loaded only once, must be managed efficiently in terms of retrieval, and they may also be unloadable to free memory up when they have not been used for a while and the memory budget is under stress.

    Ogre::Resource::LoadingState描述的是资源的加载状态。创建一个Rersource并不会立即加载资源内容,只有显式的进行load后,资源才会被真正加载。从设计上讲,Rersource更像一个轻量级的常驻资源代理(让人想起WeakReference)。资源内容可以随时被卸载并在有必要的情况下重新加载,而资源会以更持久的方式存在。对用户来讲,只要应用Resource的概念就可以了,资源内容和底层Archive就不用费神了。这种轻量级代理的方式也使异步加载更为方便。

 

    A resource manager is responsible for managing a pool of resources of a particular type. It must index them, look them up, load and destroy them. It may also need to stay within a defined memory budget, and temporarily unload some resources if it needs to to stay within this budget.

    Resource managers use a priority system to determine what can be unloaded, and a Least Recently Used (LRU) policy within resources of the same priority.

    Resources can be loaded using the generalised load interface, and they can be unloaded and removed. In addition, each subclass of ResourceManager will likely define custom 'load' methods which take explicit parameters depending on the kind of resource being created.

    ResourceManager是某种特定Resource的管理器,负责该类型资源的创建和销毁。Resource和ResourceManager这种关系是抽象工厂(Abstract Factory)模式的典型体现。Resource是产品,ResourceManager是工厂,不同的工厂来制造相应类型的产品。

 

    ResourceGroupManager, this singleton class manages the list of resource groups, and notifying the various resource managers of their obligations to load / unload resources in a group.

    It also provides facilities to monitor resource loading per group (to do progress bars etc), provided the resources that are required are pre-registered.

 

    Archive组件提供了抽象文件的访问能力。Resource组件建立在Archive系统之上,提供灵活的资源加载方式,保证资源不会被重复加载,并能在适当的时候回收资源。Resource组件将底层面向文件系统的Archive提升到面向应用的资源。

    Resource和DataStream的层次有点类似,都代表最终的实用产品;ResourceManager和Archive有点类似,管理一系列有共同性质的东西;ResourceGroupManager则和ArchiveManager有点类似,在各自组件的中心管理器。

 

推荐阅读:

Resources and ResourceManagers

Ogre::Archive赏析

  评论这张
 
阅读(1754)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018