青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

DXUT框架剖析(8)

DXUT框架與錯誤處理

Direct3D API的設計使程序能比較容易地處理各種錯誤,盡管大多數Direct3D API函數返回HTRSULT值,但只有一部分函數返回設備錯誤,如D3DERR_DEVICELOST或D3DERR_DRIVERINTERNALERROR。但是通常的Direct3D應用程序使用多種API函數,當傳遞的參數不合要求時,將返回D3DERR_INVALIDCALL。

當開發Direct3D應用程序時,應該檢查所有的API調用是否成功,如果出現一個沒有預測到的失敗調用,應用程序應立即給出通知或記錄該錯誤。使用這種方法,開發人員能很快發現哪些API函數的調用是不正確的。一個正確調用Direct3D API函數的應用程序應能安全地忽略大多數Direct3D API函數的失敗調用,除了一些關鍵性的API函數,如Present()或TestCooperativeLevel(),這些函數返回的錯誤應用程序不能忽略。

通過僅處理最重要的Direct3D錯誤,可以提高運行速度并使應用程序代碼更健壯,因為代碼中需要處理錯誤的地方并不多。對于為數不多的幾個API函數的失敗調用,必須予以適當處理。

框架中錯誤的處理對應Direct3D API中如何設計錯誤的處理,對于各種各樣的錯誤,如丟失媒體(missing media),應用程序能通知用戶并終止。對于每一幀都將調用的大多數API函數,錯誤僅在調試時向開發人員顯示一個錯誤消息框來處理,而在發布時這些錯誤都被忽略了??蚣苡迷贒XUT.h中定義的幾個宏來完成這一操作:

#if defined(DEBUG) || defined(_DEBUG)
#ifndef V
#define V(x) { hr = (x); if( FAILED(hr) ) { DXUTTrace( __FILE__, (DWORD)__LINE__, hr, L#x, true ); } }
#endif
#ifndef V_RETURN
#define V_RETURN(x) { hr = (x); if( FAILED(hr) ) { return DXUTTrace( __FILE__, (DWORD)__LINE__, hr, L#x, true ); } }
#endif
#else
#ifndef V
#define V(x) { hr = (x); }
#endif
#ifndef V_RETURN
#define V_RETURN(x) { hr = (x); if( FAILED(hr) ) { return hr; } }
#endif
#endif

當使用vs.net時,如果想跳到出錯代碼所在的行,只需簡單地雙擊調試輸出窗口中輸出的錯誤信息行即可。

 

選擇最可行的設備

DXUT使用高度靈活的方法從枚舉集合中選擇最好的設備,這個設備枚舉和分級系統可以通過調用函數DXUTFindValidDeviceSettings()獨立于框架使用,該函數的聲明如下:

Finds valid device settings to be used to create a new device.

HRESULT DXUTFindValidDeviceSettings(
DXUTDeviceSettings * pOut,
DXUTDeviceSettings * pIn,
DXUTMatchOptions * pMatchOptions
);

Parameters

pOut
[out] Pointer to a DXUTDeviceSettings structure that contains valid settings for the new device.
pIn
[in] Pointer to a DXUTDeviceSettings structure that contains desired settings for the new device. The default value is NULL.
pMatchOptions
[in] Pointer to a DXUTMatchOptions structure that contains flags describing how to use the device settings when choosing valid output device settings. Optimal device settings will be created based upon the match values in DXUTMatchOptions. If NULL, the function acts as if all members of this structure were DXUTMT_IGNORE_INPUT, meaning that the function will return valid device settings as close as possible to default device settings. See Remarks. The default value is NULL.

Return Values

If the function succeeds, the return value is S_OK. If the function fails, the return value can be one of the error codes in DXUTERR.

Remarks

This function attempts to find valid device settings based upon the input device settings, given by pIn. For each device setting, a match option in the DXUTDeviceSettings structure specifies how the function makes decisions. The function works for both Direct3D 9 and Direct3D 10 device settings.

This function is internally by DXUT used when toggling between full screen and windowed modes, when selecting between HAL and REF device types, and inside DXUTCreateDevice.


DXUTMatchOptions

Describes match options for finding valid device settings using the DXUTFindValidDeviceSettings function. Each member of this structure corresponds to a setting described by the DXUTDeviceSettings structure.

Default values are used when a member is set to DXUTMT_IGNORE_INPUT. See Remarks.

typedef struct DXUTMatchOptions {
DXUT_MATCH_TYPE eAPIVersion;
DXUT_MATCH_TYPE eAdapterOrdinal;
DXUT_MATCH_TYPE eOutput;
DXUT_MATCH_TYPE eDeviceType;
DXUT_MATCH_TYPE eWindowed;
DXUT_MATCH_TYPE eAdapterFormat;
DXUT_MATCH_TYPE eVertexProcessing;
DXUT_MATCH_TYPE eResolution;
DXUT_MATCH_TYPE eBackBufferFormat;
DXUT_MATCH_TYPE eBackBufferCount;
DXUT_MATCH_TYPE eMultiSample;
DXUT_MATCH_TYPE eSwapEffect;
DXUT_MATCH_TYPE eDepthFormat;
DXUT_MATCH_TYPE eStencilFormat;
DXUT_MATCH_TYPE ePresentFlags;
DXUT_MATCH_TYPE eRefreshRate;
DXUT_MATCH_TYPE ePresentInterval;
} DXUTMatchOptions, *LPDXUTMatchOptions;

Members

eAPIVersion
Match type for the API version.
eAdapterOrdinal
Match type for the display adapter ordinal.
eOutput
Match type for the adapter output ordinal.
eDeviceType
Match type for the enumerated type of the device. If set to DXUTMT_IGNORE_INPUT, then the default value is D3DDEVTYPE_HAL.
eWindowed
Match type for the windowed or full-screen mode. if set to DXUTMT_IGNORE_INPUT, then the default value is windowed mode (TRUE).
eAdapterFormat
Match type for the adapter surface format. If set to DXUTMT_IGNORE_INPUT, then the default value is the desktop display mode, or D3DFMT_X8R8G8B8 if the desktop display mode is less than 32 bits.
eVertexProcessing
Match type for the vertex processing flags D3DCREATE_HARDWARE_VERTEXPROCESSING, D3DCREATE_MIXED_VERTEXPROCESSING, or D3DCREATE_SOFTWARE_VERTEXPROCESSING. if set to DXUTMT_IGNORE_INPUT, then the default value is D3DCREATE_HARDWARE_VERTEXPROCESSING.
eResolution
Match type for the display mode resolution. if set to DXUTMT_IGNORE_INPUT, then the default value is 640 x 480 pixels for windowed mode, or the desktop resolution for full-screen mode.
eBackBufferFormat
Match type for the back buffer format. if BackBufferFormat is set to DXUTMT_IGNORE_INPUT, then the default value is to match the adapter format.
eBackBufferCount
Match type for the number of back buffers. if BackBufferCount is set to DXUTMT_IGNORE_INPUT, then the default value is 2 for triple buffering.
eMultiSample
Match type for the quality level. if set to DXUTMT_IGNORE_INPUT, then the default value is to disable multisampling (MultiSampleQuality = 0).
eSwapEffect
Match type for the swap effect. if set to DXUTMT_IGNORE_INPUT, then the default value is D3DSWAPEFFECT_DISCARD.
eDepthFormat
Match type for the depth format of the automatic depth-stencil surface that the device will create. If both eDepthFormat and eStencilFormat are set to DXUTMT_IGNORE_INPUT, then the default value is D3DFMT_D16 if the backbuffer format is 16 bits or less, or D3DFMT_D32 otherwise.
eStencilFormat
Match type for the stencil format of the automatic depth-stencil surface that the device will create. if both eDepthFormat and eStencilFormat are set to DXUTMT_IGNORE_INPUT, then the default value is D3DFMT_D16 if the backbuffer format is 16 bits or less, or D3DFMT_D32 otherwise.
ePresentFlags
Match type for the presentation parameters flags. if set to DXUTMT_IGNORE_INPUT, then the default value is D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL.
eRefreshRate
Match type for the rate at which the display adapter refreshes the screen. If set to DXUTMT_IGNORE_INPUT, then the default value is 0, indicating windowed mode.
ePresentInterval
Match type for the presentation interval. if set to DXUTMT_IGNORE_INPUT, then the default value is D3DPRESENT_INTERVAL_IMMEDIATE for windowed mode, or D3DPRESENT_INTERVAL_DEFAULT for full-screen mode.

Remarks

For each member of this structure, match options are specified using the constant values of the DXUT_MATCH_TYPE enumeration, as in the following code example.

matchOptions.eResolution = DXUTMT_CLOSEST_TO_INPUT;

To use default device settings instead, use the DXUTMT_IGNORE_INPUT flag as follows:

matchOptions.eResolution = DXUTMT_IGNORE_INPUT;

DXUT_MATCH_TYPE

Describes how to match input device settings when creating a new device with a function.

typedef enum DXUT_MATCH_TYPE
{
DXUTMT_IGNORE_INPUT = 0,
DXUTMT_PRESERVE_INPUT,
DXUTMT_CLOSEST_TO_INPUT,
} DXUT_MATCH_TYPE, *LPDXUT_MATCH_TYPE;

Constants

DXUTMT_IGNORE_INPUT
Ignore the device setting input, and return a device setting as close as possible to a default device setting.
DXUTMT_PRESERVE_INPUT
Return without changing the device setting that was given as input to the function.
DXUTMT_CLOSEST_TO_INPUT
Return a device setting as close as possible to the device setting that was given as input to the function.

假設想要獲取一個硬件抽象層設備,其后臺緩沖區格式是D3DFMT_A2B10G10R10,如果系統中的硬件抽象層設備不支持這種后臺緩沖區格式,但有一個安裝好的參考設備支持,那么該函數可以使用該參考設備或根據硬件抽象層設備改變后臺緩沖區格式,這都將通過枚舉類型DXUT_MATCH_TYPE來控制如何采用設備格式。


posted on 2008-05-16 18:43 lovedday 閱讀(1093) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            91久久精品日日躁夜夜躁欧美| 欧美精品一区二区久久婷婷| 国产精品视频第一区| 国产精品揄拍一区二区| 欧美性理论片在线观看片免费| 欧美韩国日本一区| 男人的天堂亚洲在线| 欧美人妖在线观看| 狠狠久久综合婷婷不卡| 欧美日韩国产一区精品一区| 欧美精品激情在线| 欧美日韩精品免费在线观看视频| 久久久久久久久久久久久9999| 久久精品亚洲一区二区| 欧美成人精品三级在线观看| 欧美日韩国产经典色站一区二区三区| 欧美日韩亚洲国产精品| 欧美α欧美αv大片| 欧美午夜视频网站| 国产亚洲人成a一在线v站| 亚洲人成人一区二区三区| 亚洲欧美日韩国产另类专区| 欧美成人xxx| 午夜精品在线视频| 欧美一区二区女人| 久久综合色8888| 亚洲人永久免费| 久久久久高清| 国产亚洲欧美中文| 性欧美激情精品| 这里只有精品视频| 国产精品国产a| 欧美一区二区三区在线| 这里只有精品丝袜| 国产精品久久一区二区三区| 亚洲在线观看免费| 午夜久久久久久| 尤物99国产成人精品视频| 久久一区二区三区av| 久久都是精品| 亚洲美女淫视频| 亚洲一区在线播放| 国产一区91| 亚洲国产天堂久久综合网| 欧美日韩国产一区二区| 欧美一级网站| 你懂的亚洲视频| 欧美在线亚洲| 欧美日韩亚洲91| 久久偷看各类wc女厕嘘嘘偷窃| 久久中文字幕一区二区三区| 一区二区三区国产在线观看| 久久精品一区二区三区不卡| 在线综合亚洲| 久久精品国产99国产精品| 亚洲美女诱惑| 欧美 日韩 国产 一区| 欧美一区二区三区视频在线 | 好看的日韩av电影| 亚洲精品美女久久7777777| 国产一区二区久久精品| 99伊人成综合| 亚洲美女一区| 老司机午夜精品视频在线观看| 午夜老司机精品| 亚洲一区在线免费观看| 欧美jizzhd精品欧美喷水| 欧美一级视频一区二区| 国产精品久99| 一区二区三区欧美亚洲| 亚洲深夜福利网站| 欧美绝品在线观看成人午夜影视| 麻豆成人在线观看| 亚洲缚视频在线观看| 欧美成人免费在线观看| 久久人人97超碰人人澡爱香蕉| 国产日韩精品综合网站| 亚洲一区二区少妇| 亚洲一区日韩在线| 国产午夜精品全部视频在线播放 | 欧美日韩国产精品一区二区亚洲| 久久久久久一区二区三区| 国产专区精品视频| 亚洲毛片在线观看| 欧美日韩黄色大片| 欧美一乱一性一交一视频| 久热精品在线视频| 一区二区三区 在线观看视| 欧美日韩国产综合久久| 午夜精品一区二区三区四区| 欧美激情五月| 久久国产综合精品| 欧美亚洲一区在线| 亚洲乱码国产乱码精品精| 久久国产婷婷国产香蕉| 亚洲人成网站777色婷婷| 国产婷婷一区二区| 欧美日韩情趣电影| 欧美韩日一区二区| 久久精品国产综合| 久久精品国产v日韩v亚洲| 日韩午夜在线视频| 欧美成人影音| 欧美黄在线观看| 欧美mv日韩mv国产网站app| 亚洲在线免费观看| 亚洲一区二区少妇| 亚洲综合电影| 亚洲一区二区三| 欧美亚洲免费| 欧美一进一出视频| 久久精品国产精品亚洲| 欧美资源在线观看| 久久精品国产精品亚洲| 欧美一区二区女人| 久久久久成人精品| 久久久亚洲国产天美传媒修理工| 久久九九99| 亚洲国产高潮在线观看| 亚洲国产精品一区二区第四页av| 欧美高清在线播放| 一本一本a久久| 久久精品水蜜桃av综合天堂| 乱人伦精品视频在线观看| 欧美激情视频在线免费观看 欧美视频免费一 | 亚洲视频自拍偷拍| 午夜日韩激情| 久久综合色8888| 亚洲精品影院| 亚洲一区国产视频| 久久精品国产77777蜜臀| 亚洲精品123区| 欧美在线免费观看视频| 欧美手机在线视频| 在线观看日韩精品| 久久久久欧美| 亚洲午夜高清视频| 欧美.www| 在线观看三级视频欧美| 久久99伊人| 一本一本久久a久久精品综合麻豆 一本一本久久a久久精品牛牛影视 | 欧美日韩一区二区在线观看视频 | 亚洲一区免费网站| 欧美色另类天堂2015| 午夜伦理片一区| 午夜久久久久久久久久一区二区| 国产精品海角社区在线观看| 欧美在线视频网站| 久久久久久一区| 99精品欧美一区| 麻豆精品视频在线| 欧美日韩一区二区三区在线观看免 | 亚洲国产欧美精品| 久久久久欧美精品| 亚洲国产视频一区二区| 亚洲三级性片| 国产精品国产精品国产专区不蜜| 亚洲一区二区在线看| 亚洲一区二区在线| 一区在线播放| 国内外成人免费激情在线视频| 久久精品二区亚洲w码| 久久久精品国产免大香伊| 亚洲激情一区二区三区| 99国产精品一区| 韩日欧美一区二区三区| 亚洲福利av| 国产视频一区在线| 亚洲激情av在线| 国产专区精品视频| 亚洲作爱视频| 最近看过的日韩成人| 午夜精品免费视频| 一本久久a久久免费精品不卡| 亚洲婷婷在线| 亚洲深夜福利| 欧美日韩国产首页在线观看| 久久午夜电影网| 91久久精品美女| 亚洲国产一区二区三区在线播| 亚洲一区二区三区精品在线观看| 日韩一区二区福利| 欧美α欧美αv大片| 欧美xart系列高清| 亚洲国产一区二区视频| 久久综合九色综合久99| 久久久精品tv| 欲色影视综合吧| 免费欧美日韩国产三级电影| 久久蜜桃资源一区二区老牛| 国产精品一区在线播放| 久久婷婷国产综合精品青草 | 亚洲网站视频| 国产精品国产自产拍高清av| 久久久精品一区| 一区二区欧美视频| 欧美大片91| 欧美影院精品一区| 99视频热这里只有精品免费| 国产日韩欧美不卡在线|