IDirect3D9学习
来源:互联网 发布:资生堂有淘宝旗舰店吗 编辑:程序博客网 时间:2024/06/06 15:06
IDirect3D9接口共14个方法,分别是:
1.创建设备
HRESULT CreateDevice( UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS * pPresentationParameters, IDirect3DDevice9 ** ppReturnedDeviceInterface);
参数
[I]Adapter:显卡的序列号,一般使用主显卡D3DADAPTER_DEFAULT
[I]DeviceType:设备类型,HAL or REF,一般都是使用D3DDEVTYPE_HAL
[I]hFocusWindow:窗口句柄
[I]BehaviorFlags:一般使用D3DCREATE_HARDWARE_VERTEXPROCESSING,不过需要用GetDeviceCaps获取caps进行确认
[I]pPresentationParameters:这个结构体在之后会详细说明
[OUT]ppReturnedDeviceInterface:二级指针,返回一个D3D设备接口
用法:
LPDIRECT3DDEVICE9 pDevice = NULL;D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) );d3dpp.Windowed = TRUE;d3dpp.SwapEffect = D3DSWAPEFFECT_COPY;if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3dDevice)))return E_FAIL;
2.检测在一个特定的显示mode下,一个depth-stencil格式是否与渲染目标的格式兼容
HRESULT CheckDepthStencilMatch( UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat);
参数:
【I】Adapter:显示设备
【I】DeviceType:设备类型
【I】AdapterFormat:显卡格式
【I】RenderTargetFormat:渲染目标格式
【I】DepthStencilFormat:深度模板格式
用法:BOOL IsDepthFormatOk(D3DFORMAT DepthFormat, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat){ // 检查这个depth-stencil格式是否有效 HRESULT hr = pD3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, AdapterFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, DepthFormat); if(FAILED(hr)) return FALSE; // 检查the depth format 和 BackBuffer format是否兼容 hr = pD3D->CheckDepthStencilMatch(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, AdapterFormat, BackBufferFormat, DepthFormat); return SUCCEEDED(hr); }
3.在一个显示设备上,检查一个格式(这个格式被用于:texture,depth-stencil buffer,render target,或者这三个的组合)是否可用的
HRESULT CheckDeviceFormat( UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat);参数:
【I】Adapter:显示设备
【I】DeviceType:设备类型
【I】AdapterFormat:显卡格式
【I】Usage:检查类型
【I】RType:资源类型
【I】CheckFormat:被检查的格式
用法:参照2HRESULT CheckDeviceFormatConversion( UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat);
【I】Adapter:显示设备
【I】DeviceType:设备类型
【I】SourceFormat:要检查的格式,必须是FOURCC format or a valid back buffer format
【I】argetFormat:被检查的格式
5.确定多级取样技术在当前设备中是否可用。
HRESULT CheckDeviceMultiSampleType( UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels);
【I】Adapter:显示设备
【I】DeviceType:设备类型
【I】SurfaceFormat:用于标识要进行多级取样的图面
【I】Windowed:设为 true,则查询有窗口的多级取样。设为 false,则查询全屏多级取样
【I】MultiSampleType:用于标识要测试的多级取样技术
【out】pQualityLevels:一般为NULL
用法:
if( SUCCEEDED(pD3D->CheckDeviceMultiSampleType( pCaps->AdapterOrdinal, pCaps->DeviceType, BackBufferFormat, FALSE, D3DMULTISAMPLE_3_SAMPLES, NULL ) ) && SUCCEEDED(pD3D->CheckDeviceMultiSampleType( pCaps->AdapterOrdinal, pCaps->DeviceType, DepthBufferFormat, FALSE, D3DMULTISAMPLE_3_SAMPLES, NULL ) ) ) return S_OK;
6.检查一种硬件加速设备类型是否可以在指定显示上使用
HRESULT CheckDeviceType( UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed);
参数:
【I】Adapter:显示设备
【I】DeviceType:设备类型
【I】DisplayFormat:被检查的类型
【I】BackBufferFormat:D3DFMT_UNKNOWN is allowed for windowed mode.
【I】Windowed:TRUE:窗口,FALSE:全屏
7,获取显卡的当前Display模式
HRESULT GetAdapterDisplayMode( UINT Adapter, D3DDISPLAYMODE * pMode);参数:
【I】Adapter:显示设备
【I】pMode:D3DDISPLAYMODE 结构体指针
D3DDISPLAYMODE 如下:
typedef struct D3DDISPLAYMODE { UINT Width; UINT Height; UINT RefreshRate; D3DFORMAT Format;} D3DDISPLAYMODE, *LPD3DDISPLAYMODE;成员说明:
Width:屏幕宽,单位像素
Height:屏幕高,单位像素
RefreshRate:刷新(速)率
Format:显示模式的平面格式
8、获取设备的具体信息
HRESULT GetDeviceCaps( UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9 * pCaps);
参数:Adapter:显示设备
DeviceType:设备类型
pCaps:D3DCAPS9结构体指针
- IDirect3D9学习
- IDirect3D9接口学习
- DirectX9函数:IDirect3D9::GetAdapterDisplayMode 方法
- DirectX9函数:IDirect3D9::CreateDevice 方法
- 调用IDirect3D9::CreateDevice()时按下Ctrl+Alt+Del失败的问题
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- poj 3667 hotel
- “分布式哈希”和“一致性哈希”的概念与算法实现
- 蜘蛛来了!
- ARP欺骗实验
- Android开发初学者必看文档:Android开发规范
- IDirect3D9学习
- ubuntu优化详解
- linux多线程编程
- java clone
- C语言100个经典的算法
- ADO.NET 如何读取 Excel
- java文件输出示例
- 如何导入导出大数据量(1000万条)的表
- 多图详解 “Android UI”设计官方教程