🔒 Locked
why this return FALSE?
Advertisement
Original Post
the CreateDevice Return FALSE, and i don''t know why...
int InitD3D()
{
D3DPRESENT_PARAMETERS d3dpp;
D3DDISPLAYMODE d3ddm;
//Creating D3D
if ((g_D3D=Direct3DCreate8(D3D_SDK_VERSION))==NULL)
{
MessageBox(NULL,"Error creating D3D","ERROR",MB_OK );
return FALSE;
}
//Initilazing DisplayMode
d3ddm.Width=w_Width;
d3ddm.Height=w_Height;
d3ddm.RefreshRate=0;
d3ddm.Format=D3DFMT_R5G6B5;
//Initilazing Present Parameters
ZeroMemory(&d3dpp,sizeof(d3dpp));
d3dpp.Windowed=FALSE;
d3dpp.SwapEffect=D3DSWAPEFFECT_DISCARD;
d3dpp.FullScreen_RefreshRateInHz=D3DPRESENT_RATE_DEFAULT;
d3dpp.FullScreen_PresentationInterval=D3DPRESENT_INTERVAL_DEFAULT;
d3dpp.BackBufferWidth=800;
d3dpp.BackBufferHeight=600;
d3dpp.BackBufferFormat=d3ddm.Format;
//Create
if(FAILED(g_D3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,g_hWnd,D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dpp,&g_D3DDevice)))
{
MessageBox(NULL,"Error creating the device","Error",MB_OK);
return FALSE;
}
return TRUE;
}
What error is CreateDevice() returning?
What does the DEBUG D3D runtime tell you? - it will tell you exactly WHY it returned an error from CreateDevice().
----
Helping you to help yourself:
When you installed the SDK, the installer gave you an option about which runtime versions to install: Debug or Retail.
For ALL DirectX development you should have chosen Debug.
Go to the Windows Control Panel (Start->Settings->Control Panel) and open the DirectX applet - if you don''t have a DirectX applet or if all the items in the applet that opens are greyed, then uninstall the SDK and reinstall, this time selecting the Debug runtimes.
In the DirectX applet, click on the Direct3D tab. In there is a section called "Debug/Retail D3D Runtime" and it has a couple of radio buttons, one labelled "Use Debug Version of Direct3D" and the other labelled "Use Retail Version of Direct3D". Make sure that you have "Use Debug Version of Direct3D" selected.
Also in the same pane is a slider labelled "Debug Output Level", move this slider all the way to the right ("More") - this controls how much information Direct3D will send to the debug stream.
Apply the changes and close the DirectX control panel applet.
Now go back to your program:
- If you''re using MSVC, press F5 to run your program in the debugger. Wait for the program to crash/return FALSE from your device creation function. If your program is still running, bring MSVC into focus and press Shift-F5 to stop debugging. Now look at the MSVC "output" pane (usually at the bottom of the window) - look at ALL the text in there - Direct3D WILL tell you WHY it failed the call.
- If you''re using a development environment that doesn''t have a debug output window, then use dbmon.exe or DebugView from www.sysinternals.com to view the output stream.
--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
What does the DEBUG D3D runtime tell you? - it will tell you exactly WHY it returned an error from CreateDevice().
----
Helping you to help yourself:
When you installed the SDK, the installer gave you an option about which runtime versions to install: Debug or Retail.
For ALL DirectX development you should have chosen Debug.
Go to the Windows Control Panel (Start->Settings->Control Panel) and open the DirectX applet - if you don''t have a DirectX applet or if all the items in the applet that opens are greyed, then uninstall the SDK and reinstall, this time selecting the Debug runtimes.
In the DirectX applet, click on the Direct3D tab. In there is a section called "Debug/Retail D3D Runtime" and it has a couple of radio buttons, one labelled "Use Debug Version of Direct3D" and the other labelled "Use Retail Version of Direct3D". Make sure that you have "Use Debug Version of Direct3D" selected.
Also in the same pane is a slider labelled "Debug Output Level", move this slider all the way to the right ("More") - this controls how much information Direct3D will send to the debug stream.
Apply the changes and close the DirectX control panel applet.
Now go back to your program:
- If you''re using MSVC, press F5 to run your program in the debugger. Wait for the program to crash/return FALSE from your device creation function. If your program is still running, bring MSVC into focus and press Shift-F5 to stop debugging. Now look at the MSVC "output" pane (usually at the bottom of the window) - look at ALL the text in there - Direct3D WILL tell you WHY it failed the call.
- If you''re using a development environment that doesn''t have a debug output window, then use dbmon.exe or DebugView from www.sysinternals.com to view the output stream.
--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
In your device creation you put "D3DCREATE_HARDWARE_VERTEXPROCESSING". Does your video card support this? If not, try using "D3DCREATE_SOFTWARE_VERTEXPROCESSING".
Ryan Buhr
Reactor Interactive, LLC.
www.reactorinteractive.net
Ryan Buhr
Reactor Interactive, LLC.
www.reactorinteractive.net
quote:
Original post by Ilankt
I tried them both and the same shitty FALSE...
well
i will see, maybe it''s a problem of the project...
happens sometimes...
WHAT DOES THE **DEBUG OUTPUT** TELL YOU ?
I can think of about 10 different reasons why CreateDevice would fail - HanSoL0 listed one of them.
Now, I (and others) _could_ post a reason at a time, you could check for that, then post "nope, it''s not that" in response to most of them...
...OR you could (PLEASE) just check the debug output and let the D3D runtime answer your question in one go - saves you (and everyone else) a lot of time.
Here''s an example of the kind of thing the runtime will tell you:
quote:
Direct3D8: (ERROR) :The specified mode is unsupported. CreateDevice/Reset Fails
Direct3D8: (ERROR) :Failed to initialize Framework Device. CreateDevice Failed.
i.e. much simpler than everyone here guessing, you trying something, it not working, more suggestions being made and so on.
If you don''t understand the meaning of a message sent to your debug output within the context of what you''re doing, then post it here - that''s much easier to answer in one go.
--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement