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

天行健 君子當自強而不息

DXUT框架剖析(5)

修改可用的設備

應用程序可以通過DXUTSetCallbackDeviceChanging()設置回調函數來修改Direct3D設備的創建設置:

Sets a callback function that allow the application to change the device settings before the device is created.

VOID DXUTSetCallbackDeviceChanging(
LPDXUTCALLBACKMODIFYDEVICESETTINGS pCallbackModifyDeviceSettings,
void* pUserContext
);

Parameters

pCallbackModifyDeviceSettings
[in] Pointer to a LPDXUTCALLBACKMODIFYDEVICESETTINGS callback function. If the callback function is supplied, it will be called before the Direct3D device is created. If NULL, DXUT will not notify the application about device changes.
pUserContext
[in] Pointer to a user-defined value which is passed to the callback function. Typically used by an application to pass a pointer to a data structure that provides context information for the callback function. The default value is NULL

Return Values

No return value.

Remarks

Before a device is created by DXUT, the LPDXUTCALLBACKMODIFYDEVICESETTINGS callback will be called to allow the application to examine or change the device settings before the device is created. This allows an application to modify the device creation settings as it sees fit.

This callback also allows applications to reject changing the device altogether. Returning false from inside this callback will notify DXUT to keep using the current device instead of changing to the new device.

LPDXUTCALLBACKMODIFYDEVICESETTINGS

Application-defined callback function, called by DXUT to allow changes in device settings before the device is created.

bool LPDXUTCALLBACKMODIFYDEVICESETTINGS(
DXUTDeviceSettings * pDeviceSettings,
void* pUserContext
);

Parameters

pDeviceSettings
[in] Pointer to a DXUTDeviceSettings structure that contains the settings for the new device.
pUserContext
[in] Pointer to a user-defined value which is passed to the callback function. Typically used by an application to pass a pointer to a data structure that provides context information for the callback function. The default value is NULL

Return Values

Program the application to return true to continue creating the device. If not, the application should return false to continue using the current device if one exists.

Remarks

Before a device is created by DXUT, the LPDXUTCALLBACKMODIFYDEVICESETTINGS callback will be called to allow the application to examine or change the device settings before the device is created. This allows an application to modify the device creation settings as it sees fit.

This callback also allows applications to reject changing the device altogether. Returning false from inside this callback will notify DXUT to keep using the current device instead of changing to the new device.

Anything in pDeviceSettings can be changed by the application. DXUT will not prevent the failure of device creation caused by changes to device settings.

DXUTDeviceSettings

A union of settings describing how to create the Direct3D 9 or Direct3D 10 device.

typedef struct DXUTDeviceSettings {
DXUTDeviceVersion ver;
union {
DXUTD3D9DeviceSettings d3d9;
DXUTD3D10DeviceSettings d3d10;
};
} DXUTDeviceSettings, *LPDXUTDeviceSettings;

Members

ver
Indicates whether the settings structure is for a Direct3D 9 or Direct3D 10 device.
d3d9
Device settings for Direct3D 9 device. Only valid if ver is DXUT_D3D9_DEVICE.
d3d10
Device settings for Direct3D 10 device. Only valid if ver is DXUT_D3D10_DEVICE.

Remarks

The DXUTDeviceSettings can only describe a single device because the DXUTD3D9DeviceSettings and DXUTD3D10DeviceSettings member variables are unioned together. The DXUTDeviceVersion indicates which of these structures is valid.

DXUTD3D9DeviceSettings

Describes the settings used to create a Direct3D 9 device.

typedef struct DXUTD3D9DeviceSettings {
UINT AdapterOrdinal;
D3DDEVTYPE DeviceType;
D3DFORMAT AdapterFormat;
DWORD BehaviorFlags;
D3DPRESENT_PARAMETERS pp;
} DXUTD3D9DeviceSettings, *LPDXUTD3D9DeviceSettings;

Members

AdapterOrdinal
Ordinal number that denotes the display adapter.
DeviceType
Enumerated type of the device.
AdapterFormat
Adapter surface format.
BehaviorFlags
Behavior flags. This member can be a combination of one or more of the D3DCREATE values.
pp
Presentation parameters structure.

DXUT fills this structure with valid values, and then passes the structure to the callback function where the application can modify it. Be sure to validate any changes your application makes in this callback function. Here is an example that changes the depth-stencil format.

bool CALLBACK ModifyDeviceSettings( 
DXUTDeviceSettings* pDeviceSettings,
void* pUserContext )
{
if( pDeviceSettings->ver == DXUT_D3D9_DEVICE )
{
IDirect3D9* pD3D = DXUTGetD3DObject();

if( SUCCEEDED( pD3D->CheckDeviceFormat(
pDeviceSettings->d3d9.AdapterOrdinal, pDeviceSettings->d3d9.DeviceType,
pDeviceSettings->d3d9.AdapterFormat, D3DUSAGE_DEPTHSTENCIL,
D3DRTYPE_SURFACE, D3DFMT_D24S8 ) ) )
{
if( SUCCEEDED( pD3D->CheckDepthStencilMatch(
pDeviceSettings->d3d9.AdapterOrdinal, pDeviceSettings->d3d9.DeviceType,
pDeviceSettings->d3d9.AdapterFormat, pDeviceSettings->d3d9.pp.BackBufferFormat,
D3DFMT_D24S8 ) ) )
{
pDeviceSettings->d3d9.pp.AutoDepthStencilFormat = D3DFMT_D24S8;
}
}
}

return true;
}

如果應用程序需要的深度模板格式是D3DFMT_D24S8,那么程序需要確定設備支持它。

回調函數ModifyDeviceSettings()返回一個布爾值,如果應用程序返回TRUE,DXUT框架繼續像在正常情況下那樣進行設備創建。如果返回FALSE,框架不能改變設備,如果已有一個設備,則繼續使用當前設備。如果框架提出的請求是改變到一個應用程序不能使用的設備,應用程序可以拒絕該請求。例如,在一個多顯示器配置中,默認情況下在顯示器之間拖動窗口將使框架改變設備。但如果應用程序不能使用其他設備,它就必須拒絕這種改變并繼續使用當前設備。

 

降級到軟件頂點處理

Be careful if your hardware supports pixel processing (transforms and lighting) but does not support vertex processing. One common mistake is to reject devices based on the vertex shader version in the (LPDXUTCALLBACKISD3D9DEVICEACCEPTABLE or LPDXUTCALLBACKISD3D10DEVICEACCEPTABLE) callback functions. The correct solution is to implement the checking in the ModifyDeviceSettings callback function as shown here.

bool CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, 
void* pUserContext )
{
if( pDeviceSettings->ver == DXUT_D3D9_DEVICE )
{
D3DCAPS9 caps;
DXUTGetD3D9DeviceCaps( pDeviceSettings, &caps );

// If device doesn't support HW T&L or doesn't support 1.1 vertex
// shaders in HW, then switch to SWVP.
if( (pCaps->DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0 ||
pCaps->VertexShaderVersion < D3DVS_VERSION(1,1) )
{
pDeviceSettings->d3d9.BehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
}

else
{
pDeviceSettings->d3d9.BehaviorFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;
}
}

return true;
}

posted on 2008-05-15 15:44 lovedday 閱讀(1348) 評論(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>
            欧美精品一区二区精品网| 欧美日韩1234| 狠狠色丁香婷婷综合| 久久国产乱子精品免费女| 午夜国产精品视频| 国产主播在线一区| 欧美阿v一级看视频| 欧美国产一区二区三区激情无套| 亚洲精品少妇30p| 一本到高清视频免费精品| 国产精品swag| 裸体一区二区| 欧美精选在线| 欧美在线亚洲综合一区| 久久久视频精品| 99视频精品全国免费| 亚洲欧美综合v| 亚洲国产另类精品专区 | 亚洲第一成人在线| 亚洲日产国产精品| 国产精品影音先锋| 欧美aⅴ99久久黑人专区| 欧美激情一二三区| 久久精品72免费观看| 欧美精品系列| 玖玖视频精品| 欧美性色aⅴ视频一区日韩精品| 欧美主播一区二区三区| 欧美黄色一级视频| 久久午夜电影| 欧美视频一二三区| 欧美激情亚洲自拍| 国产日韩欧美精品| 亚洲免费高清| 亚洲国产日韩美| 亚洲欧美电影院| 一区二区三区免费在线观看| 久久成人久久爱| 亚洲欧美国产精品va在线观看| 久久亚洲综合色| 久久精品30| 国产精品免费电影| 亚洲精品一区二区三区樱花 | 欧美r片在线| 久久久综合视频| 国产精品久久久亚洲一区| 亚洲国产日韩综合一区| 国语自产精品视频在线看| 亚洲天堂av综合网| 亚洲视频日本| 欧美日韩成人在线| 亚洲欧洲免费视频| 亚洲激情一区二区| 久久天堂成人| 免费高清在线一区| 在线不卡亚洲| 久久久人人人| 免费精品视频| 136国产福利精品导航| 欧美在线综合视频| 久久精品一区二区三区不卡牛牛| 国产精品高潮呻吟久久av黑人| 亚洲免费大片| 亚洲在线免费| 国产久一道中文一区| 亚洲视频一区二区免费在线观看| 这里只有视频精品| 国产精品yjizz| 亚洲一区二区三区免费观看| 亚洲一区二区三区成人在线视频精品| 欧美激情免费在线| 亚洲精品国产欧美| 宅男精品导航| 国产精品久久久久高潮| 亚洲欧美激情视频| 久久综合狠狠综合久久综青草| 国内自拍一区| 免费一级欧美片在线观看| 最新日韩在线| 亚洲欧美日韩一区在线| 国产无一区二区| 久久影院午夜片一区| 亚洲欧洲一区二区天堂久久| 亚洲性av在线| 国产亚洲欧美一区| 美脚丝袜一区二区三区在线观看 | 欧美一级二级三级蜜桃| 国产精品一区二区在线观看网站| 香蕉乱码成人久久天堂爱免费 | 99精品99| 欧美一区二区在线免费播放| 国产亚洲免费的视频看| 久久综合色88| 一区二区三区视频在线| 久久久国际精品| 最新国产成人av网站网址麻豆| 欧美日韩国产成人精品| 欧美一区二区在线视频| 亚洲国产日韩欧美在线图片| 亚洲欧美国产精品专区久久| 精品成人久久| 欧美视频中文字幕| 久久亚洲高清| 亚洲尤物在线视频观看| 欧美高清视频在线播放| 午夜精品久久| 亚洲精品专区| 国模吧视频一区| 欧美午夜电影一区| 久久天天躁狠狠躁夜夜爽蜜月| 一区二区欧美激情| 欧美黄色日本| 久久婷婷蜜乳一本欲蜜臀| 国产精品99久久久久久久久| 红桃视频欧美| 国产色爱av资源综合区| 欧美日韩三级视频| 欧美1区2区| 欧美一级久久久| 亚洲无限av看| 日韩系列欧美系列| 亚洲国产精品一区二区尤物区| 久久久久久自在自线| 亚洲一区尤物| 亚洲私人影院在线观看| 亚洲剧情一区二区| 精品999在线观看| 国产亚洲精品成人av久久ww| 欧美亚一区二区| 欧美另类高清视频在线| 久久资源在线| 久久天天躁狠狠躁夜夜爽蜜月| 亚洲女性裸体视频| 国产精品99久久久久久久女警| 亚洲精品三级| 亚洲三级影院| 亚洲精品影视| 亚洲精品美女在线观看播放| 亚洲国内欧美| 亚洲欧洲另类国产综合| 亚洲国产日韩综合一区| 亚洲福利小视频| 最新日韩在线视频| 日韩午夜av在线| 日韩亚洲精品在线| 一本色道久久综合亚洲精品不| 日韩午夜电影av| 中文国产成人精品久久一| 国产精品99久久久久久有的能看| 中国亚洲黄色| 午夜视频一区| 久久野战av| 欧美久久99| 国产精品盗摄一区二区三区| 国产精品福利在线| 国产亚洲网站| 91久久精品国产| 一本久道久久综合婷婷鲸鱼| 亚洲一区黄色| 久久精品日韩欧美| 欧美成人亚洲成人日韩成人| 亚洲国产另类 国产精品国产免费| 亚洲欧洲精品一区二区三区不卡| 亚洲精品一区二区三区在线观看 | 欧美国产1区2区| 亚洲精品免费在线播放| 一区二区三区 在线观看视| 亚洲欧美视频在线观看视频| 久久久99爱| 欧美日韩免费观看一区=区三区| 国产精品区一区| 一区久久精品| 亚洲小视频在线观看| 久久久久久一区二区| 亚洲国产精品久久久久婷婷老年| 一本一本久久a久久精品牛牛影视| 午夜精品一区二区三区电影天堂| 久久午夜视频| 国产精品久久久久久久久久久久久| 国产亚洲精品美女| 日韩亚洲欧美中文三级| 久久高清免费观看| 亚洲欧洲综合另类| 欧美一级理论性理论a| 欧美激情二区三区| 国产在线精品一区二区夜色| 99精品欧美一区二区三区综合在线| 午夜精品久久久久99热蜜桃导演| 欧美成人视屏| 亚洲欧美日韩电影| 欧美日韩国产限制| 亚洲国产精品欧美一二99| 西瓜成人精品人成网站| 亚洲欧洲日本一区二区三区| 欧美一区激情视频在线观看| 国产精品va在线播放| 亚洲美女中文字幕| 另类专区欧美制服同性| 亚洲男人的天堂在线| 欧美日韩综合久久|