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

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

DXUT框架剖析(4)

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

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

為所有的參數(shù)選擇合適的設(shè)置是比較繁瑣的,DXUT框架使用函數(shù)DXUTCreateDevice()簡(jiǎn)化了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.

通過(guò)這個(gè)簡(jiǎn)單的調(diào)用,DXUT框架創(chuàng)建了一個(gè)使用默認(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 顯示適配器編號(hào) D3DADAPTER_DEFAULT
D3DPRESENT_PARAMETERS.BackBufferCount 后臺(tái)緩沖區(qū)數(shù)目 2,表示有兩個(gè)后臺(tái)緩沖區(qū),可實(shí)現(xiàn)3倍緩沖。
D3DPRESENT_PARAMETERS.BackBufferFormat 后臺(tái)緩沖區(qū)格式 桌面顯示模式,如果桌面顯示模式不足32位,則使用D3DFMT_X8R8G8B8
D3DPRESENT_PARAMETERS.AutoDepthStencilFormat 設(shè)備將自動(dòng)創(chuàng)建的深度模板表面的深度格式 如果后臺(tái)緩沖區(qū)格式小于等于16位,則使用D3DFMT_D16,否則使用D3DFMT_D32。
IDirect3D9::CreateDevice()函數(shù)的參數(shù)DeviceType 設(shè)備類(lèi)型 若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 頂點(diǎn)運(yùn)算標(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,表示自動(dòng)創(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)用程序可以使用這個(gè)回調(diào)函數(shù)拒絕任何硬件不支持或不想要的組合。例如,應(yīng)用程序可以使用下列代碼拒絕16位后臺(tái)緩沖區(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)用之后,框架把這些可以接受的組合分級(jí),并從中選出最優(yōu)的使用。較高級(jí)別的組合包括:

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

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

(3)適配器格式所對(duì)應(yīng)的后臺(tái)緩沖區(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) 評(píng)論(0)  編輯 收藏 引用


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


公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(lèi)(178)

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

搜索

最新評(píng)論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲国产精品一区| 亚洲黄一区二区| 一本色道久久88精品综合| 欧美成人精品h版在线观看| 午夜日韩电影| 性做久久久久久| 久久九九精品| 欧美电影美腿模特1979在线看| 欧美成人免费大片| 最新国产成人av网站网址麻豆| 亚洲国产女人aaa毛片在线| 亚洲激情六月丁香| 一区二区av| 欧美尤物巨大精品爽| 久久色在线观看| 欧美精品粉嫩高潮一区二区 | 欧美不卡视频一区发布| 欧美激情在线| 欧美午夜三级| 精品福利av| 亚洲一区二区伦理| 久久野战av| 一区二区三区视频在线播放| 欧美在线视频免费| 欧美日韩国产麻豆| 国产日韩亚洲| 99精品国产99久久久久久福利| 性做久久久久久久久| 欧美激情无毛| 先锋资源久久| 欧美精品国产一区| 国产在线精品一区二区中文| 亚洲精品中文字| 久久精品首页| 99热这里只有精品8| 久久九九免费| 国产欧美日韩激情| 亚洲午夜成aⅴ人片| 免费看黄裸体一级大秀欧美| 一本一本久久a久久精品牛牛影视| 欧美资源在线观看| 国产精品久久久久aaaa九色| 亚洲人成小说网站色在线| 欧美一级在线亚洲天堂| 国产亚洲欧美aaaa| 一本色道久久加勒比精品| 午夜欧美理论片| 亚洲电影网站| 久久精品毛片| 国产欧美一区二区三区久久人妖| 99国内精品久久| 免费观看国产成人| 欧美一级在线播放| 国产精品婷婷| 一区二区三区毛片| 美女国产一区| 欧美中文字幕不卡| 国产综合视频| 久久久久久久高潮| 久久精品国产一区二区三区免费看| 国产精品va在线播放我和闺蜜| 亚洲国产天堂久久综合| 久久综合久久综合九色| 亚洲欧美成人| 欧美视频二区| 99精品视频一区二区三区| 欧美激情中文字幕在线| 久久久久久久欧美精品| 韩日精品视频| 欧美中文字幕在线| 亚洲欧美一区二区三区久久 | 亚洲国产高清高潮精品美女| 欧美一区二区三区视频在线| 亚洲网在线观看| 欧美日韩国产91| 亚洲一级电影| 亚洲一区精品电影| 国产欧美日韩亚州综合| 亚洲欧洲99久久| 西瓜成人精品人成网站| 国产女人水真多18毛片18精品视频| 亚洲欧美日韩精品久久| 宅男66日本亚洲欧美视频| 国产精品99一区二区| 午夜精品成人在线视频| 欧美一区在线看| 在线观看欧美视频| 亚洲高清三级视频| 欧美三级在线视频| 久久久视频精品| 欧美黄在线观看| 欧美一区二区观看视频| 久久蜜臀精品av| 亚洲私人黄色宅男| 久久精品国产69国产精品亚洲| 狠狠久久亚洲欧美专区| 亚洲激情图片小说视频| 国产精品国产自产拍高清av王其| 久久免费视频在线| 欧美日韩午夜在线视频| 久久久久久9999| 欧美天天视频| 另类天堂av| 欧美日韩成人一区二区| 亚洲国产成人不卡| 日韩一级精品| 黄色亚洲在线| 亚洲精品国产视频| 国产欧美一区二区精品仙草咪| 欧美成人一品| 国产精品免费视频xxxx| 欧美激情精品久久久久| 国产乱人伦精品一区二区| 欧美激情1区2区3区| 国产精品入口日韩视频大尺度| 欧美国产日本在线| 国产一区av在线| 艳妇臀荡乳欲伦亚洲一区| 国产婷婷成人久久av免费高清| 亚洲国产天堂网精品网站| 国产一区二区三区自拍| 亚洲综合第一| 午夜国产精品视频| 欧美日韩一区二区三区四区五区| 免费在线国产精品| 国产一区二区三区免费观看| 一二三四社区欧美黄| 日韩亚洲在线| 嫩草影视亚洲| 欧美/亚洲一区| 国产一区二区三区免费观看 | 一本色道久久综合一区| 亚洲精品色图| 免费在线视频一区| 欧美激情亚洲自拍| 亚洲高清在线观看一区| 另类综合日韩欧美亚洲| 欧美大尺度在线观看| 在线观看日韩av电影| 久久精品官网| 欧美不卡高清| 亚洲福利视频专区| 蜜桃精品一区二区三区| 免费一区二区三区| 亚洲日本在线视频观看| 欧美ed2k| 亚洲精品免费观看| 一区二区三区黄色| 国产精品成人免费视频| 亚洲午夜精品久久久久久浪潮| 午夜精品成人在线| 激情久久五月天| 老色鬼精品视频在线观看播放| 欧美大片在线看免费观看| 91久久久久久久久| 欧美日本一区二区三区| 日韩午夜在线播放| 亚洲在线日韩| 国产视频欧美| 猛男gaygay欧美视频| 亚洲人成在线观看| 亚洲欧美日韩国产综合在线 | 欧美理论在线| 亚洲一区二区三区视频播放| 欧美中文字幕在线| 激情综合在线| 欧美区一区二区三区| 亚洲一区二区动漫| 美国三级日本三级久久99| 亚洲精品乱码久久久久久蜜桃麻豆 | 黄色精品一区| 免费在线亚洲欧美| 中文久久精品| 男女激情视频一区| 亚洲自拍三区| 在线观看日韩www视频免费| 欧美精品在线网站| 欧美中文在线观看| 日韩午夜av在线| 美腿丝袜亚洲色图| 一区二区三区色| 激情久久久久久| 国产精品久久久久aaaa九色| 久久夜色精品国产欧美乱| 亚洲无毛电影| 亚洲精品久久久蜜桃| 老牛嫩草一区二区三区日本| 亚洲欧美成人网| 亚洲免费精品| 在线成人中文字幕| 国产女人18毛片水18精品| 欧美国产日韩一区二区| 久久国产视频网| 亚洲午夜精品福利| 亚洲三级毛片| 欧美风情在线观看| 久久乐国产精品| 亚洲欧美综合精品久久成人| 中文精品视频| 日韩一区二区精品在线观看|