DirectX10
I'm trying to convert a project from directx9 to directx10, and I get the error:
"Failed to create D3D Device and swap chain. " during runtime. Here is my code:
D3DCLASS::D3DCLASS(HWND WIN, int WIN_WIDTH, int WIN_HEIGHT, bool WINDOWED)
{
WIDTH = WIN_WIDTH;
HEIGHT = WIN_HEIGHT;
WIN_STATE = WINDOWED;
DXGI_SWAP_CHAIN_DESC SwapChain_Desc;
ZeroMemory(&SwapChain_Desc, sizeof(SwapChain_Desc));
SwapChain_Desc.BufferCount = 1;
SwapChain_Desc.BufferDesc.Height = WIN_HEIGHT;
SwapChain_Desc.BufferDesc.Width = WIN_WIDTH;
SwapChain_Desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
SwapChain_Desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
SwapChain_Desc.OutputWindow = WIN;
SwapChain_Desc.SampleDesc.Count = 1;
SwapChain_Desc.SampleDesc.Quality = 0;
SwapChain_Desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
SwapChain_Desc.Windowed = WINDOWED;
if( FAILED (D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, NULL, D3D10_SDK_VERSION, &SwapChain_Desc, &SwapChain, &D3DDEV)))
{ throw(TEXT("Failed to create D3D Device and swap chain.")); }
class D3DCLASS
{
/*typedef void (*ON_DEVICE_RESET)(D3DCLASS* PD3D);
typedef void (*ON_DEVICE_LOST)();*/
public:
D3DCLASS(HWND WIN, int WIN_WIDTH, int WIN_HEIGHT, bool WINDOWED);
~D3DCLASS();
void RenderD3D();
void InitialiseFonts();
int GetWindowHeight() { return HEIGHT; }
int GetWindowWidth() { return WIDTH; }
int Get_FPS() { return FPS; }
ID3D10Device* D3DDEV;
IDXGISwapChain* SwapChain;
ID3D10RenderTargetView* RTV;
protected:
D3D10_VIEWPORT ViewPort;
int WIDTH, HEIGHT, WIN_STATE;
DWORD ElapsedTime, CurrentTicks, Frames, FPS, LastUpdate;
};
Yes, yes it does. But I just checked my graphics card and it doesn't support dx10. - _ - so that's about 10 files i just converted into dx10 that I can't properly test xD. Thanks anyway.
Edit:
How could I make my program so that It can run on directx9 or directx10? Do I literally just type out all the code for dx10, AND directx9, and do some kind of if statement to see if the user choses either?
Edit:
How could I make my program so that It can run on directx9 or directx10? Do I literally just type out all the code for dx10, AND directx9, and do some kind of if statement to see if the user choses either?
You can try Dx11 and use feature levels to run it on Directx9 hardware. Dx11 and Dx10 APIs are almost the same.
http://msdn.microsoft.com/en-us/library/ff476876(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ff476876(VS.85).aspx
Guns' suggestion is good. I'd also suggest that you get a DX10+ card. You can get a pretty inexpensive one quite easily.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement