由于顯示卡技術發展迅猛,不同的渲染技術層出不窮。要對付這種市場的變化,就不能固定一種特定的顯示特性,那么就需要一個配置文件來定義這種特性。第二人生這個游戲,是需要特定顯示特性才能運行的,如果不符合這種最低要求的環境就不能運行它。下面就來分析類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等獲取顯示特性,根據這些特性來判斷當前的顯示卡是否滿足要求。
?
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
