• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
KieranChandler

Device Creation Failure - On Start

37 posts in this topic

Hi,
I am doing the DirectX programming course part 2 with the [url="http://www.gameinstitute.com/"]Game Institute[/url]. 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.

[CODE]
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;
}
[/CODE]

Any help will be appreciated. Thanks in advance :)


Kieran
0

Share this post


Link to post
Share on other sites
Presumably CreateDevice() is failing - is that what your debugger tells you (If you put a breakpoint in the if(FAILED(hRet)) block, is it hit)?

What to the debug Direct3D runtimes tell you (Start menu -> DirectX SDK -> Tools -> DirectX Control Panel -> Direct3D9 tab, select "Use Debug Version of Direct3D 9")?

What does BuildPresentParameters() do?
0

Share this post


Link to post
Share on other sites
Thanks, how do I use the debug runtimes ? Here is the source code for the "BuildPresentParamaters" function:

[CODE]
D3DPRESENT_PARAMETERS D3DInitialize::BuildPresentParameters(CD3DSettings& Settings, ULONG Flags)
{
D3DPRESENT_PARAMETERS d3dpp;
CD3DSettings::Settings *pSettings = Settings.GetSettings();
ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS));
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferFormat = pSettings->BackBufferFormat;
d3dpp.Windowed = Settings.Windowed;
d3dpp.MultiSampleType = pSettings->MultisampleType;
d3dpp.MultiSampleQuality = pSettings->MultisampleQuality;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = pSettings->DepthStencilFormat;
d3dpp.PresentationInterval = pSettings->PresentInterval;
d3dpp.Flags = D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL | Flags;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
if(!d3dpp.Windowed)
{
d3dpp.FullScreen_RefreshRateInHz = pSettings->DisplayMode.RefreshRate;
d3dpp.BackBufferWidth = pSettings->DisplayMode.Width;
d3dpp.BackBufferHeight = pSettings->DisplayMode.Height;
}
return d3dpp;
}
[/CODE]
0

Share this post


Link to post
Share on other sites
Once you have the debug runtimes selected, you'll get D3D warnings and errors emitted to Visual Studio's output window.

What are the values of all those settings? Are you sure you've chosen settings that your graphics card supports?
0

Share this post


Link to post
Share on other sites
Do you get any debug output at all? And any D3D output at all? What version of the DirectX SDK are you using?
0

Share this post


Link to post
Share on other sites
Does it work with the following settings:
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8
d3dpp.Windowed = TRUE;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.MultiSampleQuality = 0;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
d3dpp.Flags = D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;

?
If so, then one of the values in pSettings is incompatible with your graphics card.
0

Share this post


Link to post
Share on other sites
Windows 7: Just type "dxdiag" in the start menu
Windows XP -> Start Menu -> Run -> "dxdiag.exe"
Windows Vista: I think the same as Windows 7.

Also, what is the value of hRet when CreateDevice() fails (Look at it in the debugger, preferably in hexadecimal view)?
0

Share this post


Link to post
Share on other sites
[quote name='KieranChandler' timestamp='1329393622' post='4913628']
I know where it is but I don't know what I am supposed to be doing with it.
[/quote]Click Save All Information, and then paste the contents of the text file here.

[quote name='KieranChandler' timestamp='1329393622' post='4913628']
E_FAIL[/quote]Really? I've never seen CreateDevice() return that, it should be something like D3DERR_INVALIDCALL or D3DERR_NOTAVAILABLE.
0

Share this post


Link to post
Share on other sites
[quote name='KieranChandler' timestamp='1329397687' post='4913641']
It doesn't give me the option to save it.
[/quote]What happens when you click on the "Save All Information" button then?

[quote name='KieranChandler' timestamp='1329397687' post='4913641']
Oh how do I check it ?
[/quote][quote name='Evil Steve' timestamp='1329386415' post='4913608']
Also, what is the value of hRet when CreateDevice() fails (Look at it in the debugger, preferably in hexadecimal view)?
[/quote]
0

Share this post


Link to post
Share on other sites
I think it may be something wrong with my computer because unity won't start up, it's giving me an error saying it can't initialize Direct3D.
0

Share this post


Link to post
Share on other sites
What version of the DirectX SDK do you have? Can you give us a screenshot of your dxdiag window? What version of Windows do you have? What graphics card do you have? Do you have the latest drivers?

It sounds like you don't have a D3D9 compatible video card, or you're running through remote desktop, virtual machine or something similar that would prevent D3D9 from being used.

You can get to hexadecimal view in Visual Studio by right clicking in the watch window in the debugger and selecting "Hexadecimal Display".
0

Share this post


Link to post
Share on other sites
I am using Windows 7 Starter. I have a compatible graphics card because up until now it has always worked i have tried updating the drivers earlier today and it said they are up-to date. how do I tell if I am running remote desktop mode and how do i disable it ?
0

Share this post


Link to post
Share on other sites
If you're not logging in remotely, you're not using remote desktop.

Can we get a screenshot of your dxdiag window? Something sounds very wrong with your setup.

You could also try doing a system restore to roll back to a time when other 3D games worked.
1

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  
Followers 0