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

天行健 君子當(dāng)自強而不息

DXUT框架剖析(4)

創(chuàng)建一個設(shè)備

通常可以用標(biāo)準(zhǔn)的Direct3D方法CreateDevice()創(chuàng)建一個Direct3D設(shè)備,這個方法需要一個有效的顯示適配器、設(shè)備類型(硬件抽象層設(shè)備或參考設(shè)備)、窗口句柄、運行標(biāo)志(軟件/硬件頂點運算模式和其他驅(qū)動標(biāo)志)和提交參數(shù)。更重要的是,結(jié)構(gòu)體 D3DPRESENT_PARAMETERS有許多成員指定了后臺緩沖區(qū)的設(shè)置、多重采樣設(shè)置、交換效果、窗口模式、深度緩沖區(qū)設(shè)置、刷新頻率、提交間隔和提交標(biāo)志等。

為所有的參數(shù)選擇合適的設(shè)置是比較繁瑣的,DXUT框架使用函數(shù)DXUTCreateDevice()簡化了Direct3D設(shè)備的創(chuàng)建,該函數(shù)的聲明如下:

Creates a Direct3D 9 or Direct3D 10 device.

 HRESULT DXUTCreateDevice( 
bool bWindowed ,
INT nSuggestedWidth ,
INT nSuggestedHeight
) ;

Parameters

bWindowed
[in] If TRUE, the application will start in windowed mode; if FALSE, the application will start in full-screen mode. The default value is TRUE.
nSuggestedWidth
[in] The requested initial width of the application's back buffer. The actual width may be adjusted to fit device and operating system constraints. The default value is 0.
nSuggestedHeight
[in] The requested initial height of the application's back buffer. The actual height may be adjusted to fit device and operating system constraints. The default value is 0. If both nSuggestedWidth and nSuggestedHeight are zero, the dimension of the client area of the window is used.

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 creates a new Direct3D 9 or Direct3D 10 device for the application. DXUT will pick the best device for the application based upon what is availble on the system and which Direct3D API version(s) the application supports. The API version(s) that the application supports is detrimined by which device callbacks are set. This logic can be overridden by calling DXUTSetD3DVersionSupport. If both Direct3D 9 and Direct3D 10 are availble on the system and both are supported by the application, then DXUT will favor Direct3D 10.

Alternately, the application can use the DXUTCreateDeviceFromSettings or handle device creation and pass the desired device to DXUT by using the DXUTSetD3D9Device or DXUTSetD3D10Device function. If neither DXUTCreateDevice , DXUTCreateDeviceFromSettings , nor DXUTSetD3D9Device or DXUTSetD3D10Device have been called before calling DXUTMainLoop, DXUT will automatically call DXUTCreateDevice using the default parameter values.

The application can call this method after a device has already been created to change the current device.

If a device is successfully found, 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.

通過這個簡單的調(diào)用,DXUT框架創(chuàng)建了一個使用默認(rèn)設(shè)置的Direct3D設(shè)備,它可以在大多數(shù)情況下使用,默認(rèn)的設(shè)備創(chuàng)建設(shè)置如下表所示:

Direct3D創(chuàng)建標(biāo)志 描述 DXUTCreateDevice的默認(rèn)值
函數(shù)CheckDeviceFormat()的參數(shù)AdapterFormat 適配器表面格式 當(dāng)前桌面顯示模式,如果桌面顯示模式不足32位,則使用D3DFMT_X8R8G8B8
IDirect3D9::CreateDevice()的參數(shù)Adapter 顯示適配器編號 D3DADAPTER_DEFAULT
D3DPRESENT_PARAMETERS.BackBufferCount 后臺緩沖區(qū)數(shù)目 2,表示有兩個后臺緩沖區(qū),可實現(xiàn)3倍緩沖。
D3DPRESENT_PARAMETERS.BackBufferFormat 后臺緩沖區(qū)格式 桌面顯示模式,如果桌面顯示模式不足32位,則使用D3DFMT_X8R8G8B8
D3DPRESENT_PARAMETERS.AutoDepthStencilFormat 設(shè)備將自動創(chuàng)建的深度模板表面的深度格式 如果后臺緩沖區(qū)格式小于等于16位,則使用D3DFMT_D16,否則使用D3DFMT_D32。
IDirect3D9::CreateDevice()函數(shù)的參數(shù)DeviceType 設(shè)備類型 若D3DDEVTYPE_HAL可行,則使用之,否則使用D3DDEVTYPE_REF,若二者均不可行,則創(chuàng)建失敗。
D3DPRESENT_PARAMETERS.MultiSampleQuality 多重采樣數(shù)量 MultiSampleQuality = 0表示禁用多重采樣
D3DPRESENT_PARAMETERS.Flags 提交參數(shù)標(biāo)志 D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
D3DPRESENT_PARAMETERS.PresentationInterval 提交間隔 窗口模式下為D3DPRESENT_INTERVAL_IMMEDIATE,全屏模式下為D3DPRESENT_INTERVAL_DEFAULT。
D3DPRESENT_PARAMETERS.FullScreen_RefreshRateInHz 顯示適配器刷新屏幕的頻率 0,表示當(dāng)前桌面設(shè)置的刷新頻率。
D3DPRESENT_PARAMETERS.BackBufferWidth和BackBufferHeight 顯示器分辨率 在窗口模式下為640 x 480,全屏模式下為桌面分辨率。
D3DPRESENT_PARAMETERS.SwapEffect 交換效果 D3DSWAPEFFECT_DISCARD
IDirect3D9::CreateDevice()的參數(shù)BehaviorFlags 頂點運算標(biāo)志 如果硬件支持,就使用D3DCREATE_HARDWARE_VERTEXPROCESSING,否則使用D3DCREATE_SOFTWARE_VERTEXPROCESSING。
D3DPRESENT_PARAMETERS.Windowed 窗口模式或全屏模式 TRUE,表示窗口模式
IDirect3D9::CreateDevice()的參數(shù)hFocusWindow 創(chuàng)建窗口的句柄 DXUTSetWindow函數(shù)的參數(shù)hWndFocus
D3DPRESENT_PARAMETERS.hDeviceWindow 設(shè)備窗口的句柄 DXUTSetWindow的參數(shù)hWndDeviceFullScreen或hWndDeviceWindowed
D3DPRESENT_PARAMETERS.EnableAutoDepthStencil 深度模板緩沖區(qū)創(chuàng)建標(biāo)志 TRUE,表示自動創(chuàng)建深度模板緩沖區(qū)

 

選擇最好的設(shè)備設(shè)置

在應(yīng)用程序中,可以使用DXUTSetCallbackD3D9DeviceAcceptable設(shè)置回調(diào)函數(shù)IsDeviceAcceptable()幫助DXUT框架為應(yīng)用程序選擇最好的設(shè)備,該函數(shù)的聲明如下:

Sets the Direct3D 9 device acceptable callback function.

 VOID DXUTSetCallbackD3D9DeviceAcceptable( 
LPDXUTCALLBACKISD3D9DEVICEACCEPTABLE pCallback ,
void* pUserContext
) ;

Parameters

pCallback
[in] Pointer to a LPDXUTCALLBACKISD3D9DEVICEACCEPTABLE callback function. If the callback function is supplied, it will be called after the Direct3D 9 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

No return value.

Remarks

This function only needs to be called if the application supports rendering with Direct3D 9 device.

The LPDXUTCALLBACKISD3D9DEVICEACCEPTABLE callback function is the appropriate location for the application to.

LPDXUTCALLBACKISD3D9DEVICEACCEPTABLE

Application-defined callback function, called by DXUT to build an enumerated list of all possible Direct3D 9 devices. DXUT then selects the best device for creation among this list. This callback function allows the application to prevent unwanted devices from being added to the list.

 bool LPDXUTCALLBACKISD3D9DEVICEACCEPTABLE( 
D3DCAPS9* pCaps ,
D3DFORMAT AdapterFormat ,
D3DFORMAT BackBufferFormat ,
bool bWindowed ,
void* pUserContext
) ;

Parameters

pCaps
[in] Pointer to the D3DCAPS9 capabilities of the Direct3D 9 device
AdapterFormat
[in] Format of the Direct3D 9 adapter
BackBufferFormat
[in] Format of the Direct3D 9 backbuffer
bWindowed
[in] Indicates windowed mode. TRUE if the application runs windowed; FALSE if the application runs full-screen.
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 if the device settings are acceptable. If not, the application should return FALSE.

Remarks

This function's parameters describe a set of unique valid device settings that could be used to create a device. The application can examine and reject this set if desired.

All possible unique valid combinations of the following device settings are sent to this callback function:

  • pCaps
  • AdapterFormat
  • BackBufferFormat
  • bWindowed

After the application rejects the unwanted device settings combinations, DXUT picks the best of the remaining combinations and uses that best combination to create the device. Before creating the device, DXUT calls LPDXUTCALLBACKMODIFYDEVICESETTINGS to allow the application to change any of the device creation settings.

應(yīng)用程序可以使用這個回調(diào)函數(shù)拒絕任何硬件不支持或不想要的組合。例如,應(yīng)用程序可以使用下列代碼拒絕16位后臺緩沖區(qū)格式以及所有至少不支持像素渲染2.0版本的設(shè)備:

bool CALLBACK IsD3D9DeviceAcceptable(D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, 
bool bWindowed, void* pUserContext)
{
if(pCaps->PixelShaderVersion < D3DPS_VERSION(2, 0))
return false;
	if(BackBufferFormat == D3DFMT_X1R5G5B5 || BackBufferFormat == D3DFMT_R5G6B5)
return false;
	return true;
}

在回調(diào)函數(shù)IsD3D9DeviceAcceptable()被每種設(shè)置的組合調(diào)用之后,框架把這些可以接受的組合分級,并從中選出最優(yōu)的使用。較高級別的組合包括:

(1)D3DDEVTYPE_HAL,為了得到硬件加速。

(2)如果該應(yīng)用程序運行在全屏模式下,該框架會選擇桌面格式所對應(yīng)的適配器格式,這樣從窗口到全屏模式的轉(zhuǎn)換就快多了。例外的是,如果桌面顯示模式不足32位,該框架會選擇D3DFMT_X8R8G8B8。

(3)適配器格式所對應(yīng)的后臺緩沖區(qū)格式。

示例程序中,選擇設(shè)備設(shè)置的核心代碼如下:

//--------------------------------------------------------------------------------------
// Rejects any D3D9 devices that aren't acceptable to the app by returning false.
//--------------------------------------------------------------------------------------
bool CALLBACK IsD3D9DeviceAcceptable(D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat,
bool bWindowed, void* pUserContext)
{
// Typically want to skip back buffer formats that don't support alpha blending
    IDirect3D9* pD3D = DXUTGetD3D9Object(); 
	/*
HRESULT CheckDeviceFormat(
UINT Adapter,
D3DDEVTYPE DeviceType,
D3DFORMAT AdapterFormat,
DWORD Usage,
D3DRESOURCETYPE RType,
D3DFORMAT CheckFormat
);
/*/
    if(FAILED(pD3D->CheckDeviceFormat(pCaps->AdapterOrdinal, pCaps->DeviceType, AdapterFormat, 
D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, BackBufferFormat)))
{
return false;
}
    return true;
}

IDirect3D9::CheckDeviceFormat

Determines whether a surface format is available as a specified resource type and can be used as a texture, depth-stencil buffer, or render target, or any combination of the three, on a device representing this adapter.

 HRESULT CheckDeviceFormat( 
UINT Adapter ,
D3DDEVTYPE DeviceType ,
D3DFORMAT AdapterFormat ,
DWORD Usage ,
D3DRESOURCETYPE RType ,
D3DFORMAT CheckFormat
) ;

Parameters

Adapter
[in] Ordinal number denoting the display adapter to query. D3DADAPTER_DEFAULT is always the primary display adapter. This method returns D3DERR_INVALIDCALL when this value equals or exceeds the number of display adapters in the system.
DeviceType
[in] Member of the D3DDEVTYPE enumerated type, identifying the device type.
AdapterFormat
[in] Member of the D3DFORMAT enumerated type, identifying the format of the display mode into which the adapter will be placed.
Usage
[in] Requested usage options for the surface. Usage options are any combination of D3DUSAGE and D3DUSAGE_QUERY constants (only a subset of the D3DUSAGE constants are valid for IDirect3D9::CheckDeviceFormat; see the table on the D3DUSAGE page).
RType
[in] Resource type requested for use with the queried format. Member of D3DRESOURCETYPE.
CheckFormat
[in] Format of the surfaces which may be used, as defined by Usage. Member of D3DFORMAT .

Return Values

If the format is compatible with the specified device for the requested usage, this method returns D3D_OK.

D3DERR_INVALIDCALL is returned if Adapter equals or exceeds the number of display adapters in the system, or if DeviceType is unsupported.

D3DERR_NOTAVAILABLE is returned if the format is not acceptable to the device for this usage.

Remarks

Here are some examples using IDirect3D9::CheckDeviceFormat to check for hardware support of:

  • An off-screen plain surface format - Specify Usage = 0 and RType = D3DRTYPE_SURFACE.
  • A depth-stencil format - The following snippet tests for the passed in depth-stencil format:
    BOOL IsDepthFormatExisting( D3DFORMAT DepthFormat, D3DFORMAT AdapterFormat ) 
    {
    HRESULT hr = pD3D->CheckDeviceFormat( D3DADAPTER_DEFAULT,
    D3DDEVTYPE_HAL,
    AdapterFormat,
    D3DUSAGE_DEPTHSTENCIL,
    D3DRTYPE_SURFACE,
    DepthFormat);

    return SUCCEEDED( hr );
    }

    See Selecting a Device (Direct3D 9) for more detail on the enumeration process.

  • Can this texture be rendered in a particular format - Given the current display mode, this example shows how to verify that the texture format is compatible with the specific back-buffer format:
    BOOL IsTextureFormatOk( D3DFORMAT TextureFormat, D3DFORMAT AdapterFormat ) 
    {
    HRESULT hr = pD3D->CheckDeviceFormat( D3DADAPTER_DEFAULT,
    D3DDEVTYPE_HAL,
    AdapterFormat,
    0,
    D3DRTYPE_TEXTURE,
    TextureFormat);

    return SUCCEEDED( hr );
    }
  • Alpha blending in a pixel shader - Set Usage to D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING . Expect this to fail for all floating-point render targets.
  • Autogeneration of mipmaps - Set Usage to D3DUSAGE_AUTOGENMIPMAP . If the mipmap automatic generation fails, the application will get a non-mipmapped texture. Calling this method is considered a hint, so this method can return D3DOK_NOAUTOGEN (a valid success code) if the only thing that fails is the mipmap generation. For more information about mipmap generation, see Automatic Generation of Mipmaps (Direct3D 9).
D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING Query the resource to verify support for post pixel shader blending support. If IDirect3D9::CheckDeviceFormat fails with D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, post pixel blending operations are not supported. These include alpha test, pixel fog, render-target blending, color write enable, and dithering.

 

posted on 2008-05-15 14:54 lovedday 閱讀(2858) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導(dǎo)航

統(tǒng)計

常用鏈接

隨筆分類(178)

3D游戲編程相關(guān)鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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| 麻豆成人精品| 欧美一区二区三区视频免费播放| 亚洲电影观看| 亚洲激情一区| 亚洲日本成人| 日韩午夜在线视频| 亚洲视频在线一区观看| 一本大道久久a久久综合婷婷| 99精品国产高清一区二区| 亚洲三级免费电影| 99精品99| 久久高清国产| 久久午夜精品一区二区| 亚洲第一伊人| 日韩亚洲欧美成人| 亚洲一二三区视频在线观看| 久久精品国产久精国产爱| 欧美激情亚洲激情| 国产精品日韩精品| 亚洲国产乱码最新视频| 亚洲一区二区三区免费观看| 久久久91精品国产一区二区精品| 亚洲第一天堂无码专区| 亚洲调教视频在线观看| 美日韩精品视频| 国产精品自拍在线| 亚洲精品久久久久| 久久精品国产一区二区三区| 亚洲国产天堂久久综合网| 亚洲一级二级| 欧美精品久久久久久| 狠狠色综合网| 午夜精品久久久99热福利| 欧美激情bt| 欧美一级艳片视频免费观看| 欧美日本在线观看| 亚洲国产一区二区视频| 欧美诱惑福利视频| 日韩视频在线观看国产| 麻豆国产精品va在线观看不卡| 国产精品毛片大码女人 | 国产精品久久久久久超碰| 韩国v欧美v日本v亚洲v| 亚洲主播在线播放| 亚洲电影免费在线| 新67194成人永久网站| 欧美色视频在线| 亚洲三级电影在线观看| 久久在线视频| 午夜精品网站| 国产精品美女在线| 亚洲天堂激情| 亚洲精品偷拍| 欧美黄网免费在线观看| 国产精品拍天天在线| 欧美乱妇高清无乱码| 亚洲第一级黄色片| 久久综合色影院| 欧美中文字幕精品| 国产一区二区三区的电影| 亚久久调教视频| 亚洲一区二区三区四区视频| 欧美丝袜一区二区| 亚洲一区免费视频| 亚洲一区国产| 国产欧美日韩综合| 久久久精品日韩欧美| 久久精品在线观看| 亚洲国产午夜| 日韩视频亚洲视频| 国产精品国产三级国产普通话99| 亚洲一区二区三区四区中文| 亚洲一区二区四区| 国产一区二区三区在线观看免费视频| 久久国产精品色婷婷| 久久久久综合| 艳女tv在线观看国产一区| 一区二区日韩欧美| 国产日韩精品视频一区| 久久亚洲欧洲| 欧美国产日韩亚洲一区| 亚洲一区二区高清| 欧美有码在线观看视频| 亚洲激情成人| 亚洲网站在线| 在线观看国产精品网站| 亚洲福利视频一区二区| 国产精品日本一区二区 | 在线观看视频欧美| 亚洲国产欧美不卡在线观看| 欧美三级资源在线| 久久精品夜色噜噜亚洲a∨| 免费成人在线观看视频| 亚洲午夜激情| 久久久久久久一区二区| 亚洲一区二区三区视频播放| 久久成人一区| 亚洲一区二区精品在线观看| 久久精品水蜜桃av综合天堂| 在线一区亚洲| 久久久久9999亚洲精品| av成人福利| 久久精品视频导航| 午夜欧美精品| 欧美女主播在线| 久久色中文字幕| 国产精品jvid在线观看蜜臀| 欧美成人有码| 国产乱码精品一区二区三区不卡 | 亚洲精品国产日韩| 久热爱精品视频线路一| 久久国产精品久久久久久久久久 | 亚洲欧美激情四射在线日| 久久全球大尺度高清视频| 99国产精品久久久久久久成人热| 亚洲欧美日韩在线高清直播| 亚洲精品一区在线观看| 亚洲欧美精品| 亚洲一区二区久久| 另类图片综合电影| 久久精品国产免费观看| 欧美—级在线免费片| 久久久精品日韩| 国产精品香蕉在线观看| 亚洲激情综合| 亚洲国产高清在线| 午夜免费日韩视频| 午夜影院日韩| 国产精品视频第一区| 91久久在线观看| 亚洲第一中文字幕在线观看| 亚洲综合精品| 久久久精品999| 久久国产精品高清| 国产精品你懂得| 99国产麻豆精品| 99v久久综合狠狠综合久久| 母乳一区在线观看| 嫩草伊人久久精品少妇av杨幂| 国产精品一区二区三区四区| 一区二区三区免费看| 在线亚洲精品| 欧美日韩视频在线第一区| 亚洲精品中文字| 99热这里只有成人精品国产| 欧美大片一区| 亚洲精品国产视频| 一本色道久久88精品综合| 欧美另类一区| 中文网丁香综合网| 亚洲欧美日韩国产精品| 国产精品嫩草99av在线| 亚洲免费视频中文字幕| 欧美一区二区在线播放| 国语对白精品一区二区| 久久精品一级爱片| 免费一区视频| 亚洲精品在线二区| 国产精品成人aaaaa网站| 中文在线资源观看视频网站免费不卡| 亚洲欧美日韩一区在线| 国产精品一区视频| 午夜精品亚洲| 久久综合综合久久综合| 亚洲国产裸拍裸体视频在线观看乱了| 黄色成人在线免费| 久久精品卡一| 亚洲国产精品黑人久久久 | 羞羞答答国产精品www一本| 国产午夜亚洲精品羞羞网站| 欧美中文字幕在线观看| 欧美国产免费| 亚洲永久字幕| 国产一区91| 欧美成人亚洲成人日韩成人| 国产一区二区三区av电影| 一本色道久久综合狠狠躁的推荐| 欧美一区二区久久久| 亚洲日韩欧美一区二区在线| 亚洲欧美中文日韩v在线观看| 亚洲一区二区三区午夜| 久久精品国产亚洲精品| 亚洲免费观看高清完整版在线观看熊 | 国产精品视频免费| 媚黑女一区二区| 中文国产成人精品久久一| 久久亚洲国产成人| 一本到12不卡视频在线dvd| 伊人成人网在线看| 国产精品黄色| 免费不卡在线观看av| 亚洲一区免费在线观看| 亚洲区免费影片| 免费不卡在线观看av| 亚洲欧美一区二区精品久久久| 在线精品观看| 国产亚洲美州欧州综合国| 欧美日韩精品免费看| 亚洲国产1区|