Sign in to follow this  
Magmatwister

DirectX10

Recommended Posts

Magmatwister    109
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; };

Share this post


Link to post
Share on other sites
Magmatwister    109
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?

Share this post


Link to post
Share on other sites
Guns    150
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

Share this post


Link to post
Share on other sites
ET3D    810
Guns' suggestion is good. I'd also suggest that you get a DX10+ card. You can get a pretty inexpensive one quite easily.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this