第二人生的源码分析(七十二)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等获取显示特性,根据这些特性来判断当前的显示卡是否满足要求。
 
posted @ 2008-05-26 20:30  ajuanabc  阅读(161)  评论(0)    收藏  举报