第二人生的源码分析(七十二)LLFeatureManager类加载显示特性

由于显示卡技术发展迅猛,不同的渲染技术层出不穷。要对付这种市场的变化,就不能固定一种特定的显示特性,那么就需要一个配置文件来定义这种特性。第二人生这个游戏,是需要特定显示特性才能运行的,如果不符合这种最低要求的环境就不能运行它。下面就来分析类LLFeatureManager,看看第二人生是怎么样实现这个功能的。
类 LLFeatureManager的声明代码如下:
#001 class LLFeatureManager : public LLFeatureList
#002 {
#003 public:
#004     LLFeatureManager() : mInited(FALSE), mTableVersion(0), mSafe(FALSE), mGPUClass(GPU_CLASS_UNKNOWN) {}
#005     ~LLFeatureManager() {cleanupFeatureTables();}
#006 
 
下面函数加载文件显示特性。
#007     // initialize this by loading feature table and gpu table
#008     void init();
#009 
#010     void maskCurrentList(const char *name); // Mask the current feature list with the named list
#011 
 
下面函数从文件里加载显示特性。
#012     BOOL loadFeatureTables();
#013 
#014     EGPUClass getGPUClass()             { return mGPUClass; }
#015     std::string& getGPUString()         { return mGPUString; }
#016     BOOL isGPUSupported()               { return mGPUSupported; }
#017    
 
清除显示特性表。
#018     void cleanupFeatureTables();
#019 
 
获取特性文件的版本。
#020     S32 getVersion() const              { return mTableVersion; }
#021     void setSafe(const BOOL safe)       { mSafe = safe; }
#022     BOOL isSafe() const                 { return mSafe; }
#023 
 
查找给出的名称属性表。
#024     LLFeatureList *findMask(const char *name);
#025     BOOL maskFeatures(const char *name);
#026 
#027     // set the graphics to low, medium, high, or ultra.
#028     // skipFeatures forces skipping of mostly hardware settings
#029     // that we don't want to change when we change graphics
#030     // settings
#031     void setGraphicsLevel(S32 level, bool skipFeatures);
#032    
 
应用 GPU的特性。
#033     void applyBaseMasks();
#034     void applyRecommendedSettings();
#035 
#036     // apply the basic masks. Also, skip one saved
#037     // in the skip list if true
#038     void applyFeatures(bool skipFeatures);
#039 
#040 protected:
 
加载 GPU的类型。
#041     void loadGPUClass();
#042     void initBaseMask();
#043 
#044 
#045     std::map<LLString, LLFeatureList *> mMaskList;
#046     std::set<LLString> mSkippedFeatures;
#047     BOOL        mInited;
#048     S32         mTableVersion;
#049     BOOL        mSafe;                  // Reinitialize everything to the "safe" mask
#050     EGPUClass   mGPUClass;
#051     std::string mGPUString;
#052     BOOL        mGPUSupported;
#053 };
#054 
 
使用这个类时,先调用函数 init来实始化,然后通过函数isFeatureAvailable等获取显示特性,根据这些特性来判断当前的显示卡是否满足要求。
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

caimouse

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值