I am doing the DirectX programming course part 2 with the Game Institute. I have had many problems with finding the solutions to these errors, but this one is nowhere to be found. i have gone over the code and it matches the course project but still, when I run my game engine it runs aground instantly. It brings up an error saying "Device creation failed. The application will exit". This error message occurs when the "CreateDisplay" function shown below fails.
HRESULT D3DInitialize::CreateDisplay(CD3DSettings& Settings, ULONG Flags, HWND hWnd, WNDPROC wndProc, LPCTSTR Title, ULONG Width, ULONG Height, LPVOID lParam)
{
ULONG CreateFlags = 0;
CD3DSettings::Settings *pSettings = Settings.GetSettings();
if(!hWnd)
{
WNDCLASS wc;
wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = wndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = (HINSTANCE)GetModuleHandle(NULL);
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = Title;
ULONG Left = CW_USEDEFAULT, Top = CW_USEDEFAULT;
ULONG Style = WS_OVERLAPPEDWINDOW;
if(!Settings.Windowed)
{
Left = 0; Top = 0;
Width = pSettings->DisplayMode.Width;
Height = pSettings->DisplayMode.Height;
Style = WS_VISIBLE | WS_POPUP;
}
mhWnd = CreateWindow(Title, Title, Style, Left, Top, Width, Height, NULL, NULL, wc.hInstance, lParam);
if(!mhWnd)
return E_FAIL;
} else
{
mhWnd = hWnd;
if(!Settings.Windowed)
{
SetMenu(mhWnd, NULL);
SetWindowLong(mhWnd, GWL_STYLE, WS_VISIBLE | WS_POPUP);
SetWindowPos(mhWnd, NULL, 0, 0, pSettings->DisplayMode.Width, pSettings->DisplayMode.Height, SWP_NOZORDER);
} else
{
RECT rc;
GetWindowRect(hWnd, &rc);
SetWindowLong(mhWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
SetWindowPos(hWnd, HWND_NOTOPMOST, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), SWP_NOACTIVATE | SWP_SHOWWINDOW);
}
}
D3DPRESENT_PARAMETERS d3dpp = BuildPresentParameters(Settings);
CreateFlags = Flags;
if(pSettings->VertexProcessingType == PURE_HARDWARE_VP)
CreateFlags |= D3DCREATE_PUREDEVICE | D3DCREATE_HARDWARE_VERTEXPROCESSING;
else if(pSettings->VertexProcessingType == HARDWARE_VP)
CreateFlags |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
else if(pSettings->VertexProcessingType == MIXED_VP)
CreateFlags |= D3DCREATE_MIXED_VERTEXPROCESSING;
else if(pSettings->VertexProcessingType == SOFTWARE_VP)
CreateFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
mD3DDevice = NULL;
HRESULT hRet = mD3D->CreateDevice(pSettings->AdapterOrdinal, pSettings->DeviceType, mhWnd, CreateFlags, &d3dpp, &mD3DDevice);
if(FAILED(hRet))
{
if(mD3DDevice)
mD3DDevice->Release();
mD3DDevice = NULL;
return hRet;
}
return S_OK;
}
Any help will be appreciated. Thanks in advance
Kieran