「DirectX各版本差異比較」修訂間的差異
跳至導覽
跳至搜尋
(→參考資料) |
|||
行 178: | 行 178: | ||
==參考資料== | ==參考資料== | ||
*[http://msdn.microsoft.com/zh-tw/library/windows/apps/dn166864.aspx 將 DirectX 9 功能對應到 DirectX 11 API] | *[http://msdn.microsoft.com/zh-tw/library/windows/apps/dn166864.aspx 將 DirectX 9 功能對應到 DirectX 11 API] | ||
+ | *[http://blogs.msdn.com/b/chuckw/archive/2013/08/21/living-without-d3dx.aspx Living without D3DX - Games for Windows and the DirectX SDK - Site Home - MSDN Blogs] | ||
+ | *[http://blogs.msdn.com/b/chuckw/archive/2014/06/27/directxmesh.aspx DirectXMesh - Games for Windows and the DirectX SDK - Site Home - MSDN Blogs] | ||
[[Category:DirectX]] | [[Category:DirectX]] |
於 2014年9月18日 (四) 19:21 的最新修訂
DirectX各版本差異比較
初始裝置
版本 | 用法 |
---|---|
DX9 |
IDirect3D9* pD3D9; IDirect3DDevice9* pDevice; pD3D9 = Direct3DCreate9(D3D_SDK_VERSION); if (pD3D9 == NULL) return false; D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS)); d3dpp.BackBufferWidth = width; d3dpp.BackBufferHeight = height; if (isFullScreen) { // Full Screen mode d3dpp.Windowed = false; d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferCount = D3DPRESENT_BACK_BUFFERS_MAX; d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; } else { // Window mode d3dpp.Windowed = true; D3DDISPLAYMODE d3ddm; pD3D9->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ); d3dpp.BackBufferFormat = d3ddm.Format; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferCount = D3DPRESENT_BACK_BUFFERS_MAX; d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; } DWORD Flags = D3DCREATE_MIXED_VERTEXPROCESSING | D3DCREATE_MULTITHREADED; HRESULT hr = pD3D9->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, Flags, &d3dpp, &pDevice ); if (FAILED(hr) || (_pDevice == NULL)) return false; |
DX10 |
ID3D10Device* pDevice; IDXGISwapChain* pSwapChain; DXGI_SWAP_CHAIN_DESC scd; ZeroMemory(&scd, sizeof(scd)); scd.BufferCount = 1; // one back buffer scd.BufferDesc.Width = width; scd.BufferDesc.Height = height; scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; // use 32-bit color if (_vsync_enabled) { scd.BufferDesc.RefreshRate.Numerator = 60; scd.BufferDesc.RefreshRate.Denominator = 1; } else { scd.BufferDesc.RefreshRate.Numerator = 0; scd.BufferDesc.RefreshRate.Denominator = 1; } scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // how swap chain is to be used scd.OutputWindow = hWnd; scd.SampleDesc.Count = 4; // how many multisamples scd.SampleDesc.Quality = 0; if (isFullScreen) { scd.Windowed = TRUE; } else { scd.Windowed = FALSE; } UINT SDKVersion = D3D10_SDK_VERSION; D3D_FEATURE_LEVEL FeatureLevels = D3D_FEATURE_LEVEL_10_0; D3D10_DRIVER_TYPE DriverType = D3D10_DRIVER_TYPE_HARDWARE; D3D_FEATURE_LEVEL FeatureLevel; HRESULT hr = D3D10CreateDeviceAndSwapChain( NULL, //[in] IDXGIAdapter *pAdapter, DriverType, //[in] D3D10_DRIVER_TYPE DriverType, NULL, //[in] HMODULE Software, 0, //[in] UINT Flags, SDKVersion, //[in] UINT SDKVersion, &scd, //[in] DXGI_SWAP_CHAIN_DESC *pSwapChainDesc, &pSwapChain, //[out] IDXGISwapChain **ppSwapChain, &pDevice //[out] ID3D10Device **ppDevice ); if (FAILED(hr)) return false; |
DX11 |
ID3D11Device* pDevice; IDXGISwapChain* pSwapChain; ID3D11DeviceContext* pDeviceContext; DXGI_SWAP_CHAIN_DESC scd; ZeroMemory(&scd, sizeof(scd)); scd.BufferCount = 1; // one back buffer scd.BufferDesc.Width = width; scd.BufferDesc.Height = height; scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; // use 32-bit color if (_vsync_enabled) { scd.BufferDesc.RefreshRate.Numerator = 60; scd.BufferDesc.RefreshRate.Denominator = 1; } else { scd.BufferDesc.RefreshRate.Numerator = 0; scd.BufferDesc.RefreshRate.Denominator = 1; } scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // how swap chain is to be used scd.OutputWindow = hWnd; scd.SampleDesc.Count = 4; scd.SampleDesc.Quality = 0; if (isFullScreen) { scd.Windowed = TRUE; } else { scd.Windowed = FALSE; } UINT SDKVersion = D3D11_SDK_VERSION; D3D_FEATURE_LEVEL FeatureLevels = D3D_FEATURE_LEVEL_11_0; D3D_DRIVER_TYPE DriverType = D3D_DRIVER_TYPE_HARDWARE; D3D_FEATURE_LEVEL FeatureLevel; HRESULT hr = D3D11CreateDeviceAndSwapChain( NULL, //[in] IDXGIAdapter *pAdapter DriverType, //[in] D3D_DRIVER_TYPE DriverType NULL, //[in] HMODULE Software 0, //[in] UINT Flags &FeatureLevels, //[in] D3D_FEATURE_LEVEL *pFeatureLevels 1, //[in] UINT FeatureLevels SDKVersion, //[in] UINT SDKVersion &scd, //[in] DXGI_SWAP_CHAIN_DESC *pSwapChainDesc &pSwapChain, //[out] IDXGISwapChain **ppSwapChain &pDevice, //[out] ID3D11Device **ppDevice &FeatureLevel, //[out] D3D_FEATURE_LEVEL *pFeatureLevel &pDeviceContext); //[out] ID3D11DeviceContext **ppDeviceContext if (FAILED(hr)) return false; |
建立DepthBuffer
版本 | 用法 |
---|---|
DX9 | |
DX10 | |
DX11 |