Discussion:
CreateDevice() returns D3DERR_INVALIDCALL
(too old to reply)
PaulH
2007-01-18 22:28:02 UTC
Permalink
I have a dialog app where I'd like to have a control that is direct3d
rendered. So, when this control's window is created I call an
CreateDevice() as below. But, it always fails with the error code
D3DERR_INVALIDCALL (0x8876086c).
I've essentially stolen this function from the Directx9 (December 2006)
SDK vertex tutorial sample. The SDK tutorial works perfectly. Why does
the same code fail in my program? I assume it's because the whole
dialog window isn't Direct3D, just one control. Is there something
special I need to do to make this work?

(I have also tried using D3DDEVTYPE_REF as suggested to people
reporting a similar problem in other forums, but that doesn't seem to
make any difference.)

Thanks,
PaulH

HRESULT InitD3D()
{
// Create the D3D object.
if( NULL == ( m_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
{
ATLTRACE( _T( "Failed to Init Direct3D\n" ) );
return E_FAIL;
}

// Set up the structure used to create the D3DDevice
D3DPRESENT_PARAMETERS d3dpp = { 0 };
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;

// Create the D3DDevice
HRESULT hr = m_pD3D->CreateDevice( D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
m_hWnd,

D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&m_pd3dDevice );
if( FAILED( hr ) )
{
ATLTRACE( _T( "Failed to create Direct3D device. %#08x\n"
), hr );
return E_FAIL;
}

// Device state would normally be set here
return S_OK;
};

/// Used to create the D3DDevice
LPDIRECT3D9 m_pD3D;

/// Our rendering device
LPDIRECT3DDEVICE9 m_pd3dDevice;
PaulH
2007-01-18 22:49:14 UTC
Permalink
Post by PaulH
I have a dialog app where I'd like to have a control that is direct3d
rendered. So, when this control's window is created I call an
CreateDevice() as below. But, it always fails with the error code
D3DERR_INVALIDCALL (0x8876086c).
I've essentially stolen this function from the Directx9 (December 2006)
SDK vertex tutorial sample. The SDK tutorial works perfectly. Why does
the same code fail in my program? I assume it's because the whole
dialog window isn't Direct3D, just one control. Is there something
special I need to do to make this work?
(I have also tried using D3DDEVTYPE_REF as suggested to people
reporting a similar problem in other forums, but that doesn't seem to
make any difference.)
Thanks,
PaulH
HRESULT InitD3D()
{
// Create the D3D object.
if( NULL == ( m_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
{
ATLTRACE( _T( "Failed to Init Direct3D\n" ) );
return E_FAIL;
}
// Set up the structure used to create the D3DDevice
D3DPRESENT_PARAMETERS d3dpp = { 0 };
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
// Create the D3DDevice
HRESULT hr = m_pD3D->CreateDevice( D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
m_hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&m_pd3dDevice );
if( FAILED( hr ) )
{
ATLTRACE( _T( "Failed to create Direct3D device. %#08x\n"
), hr );
return E_FAIL;
}
// Device state would normally be set here
return S_OK;
};
/// Used to create the D3DDevice
LPDIRECT3D9 m_pD3D;
/// Our rendering device
LPDIRECT3DDEVICE9 m_pd3dDevice;
There's a few other things I should mention that might affect this as
well:
The DxViewer.exe utility crashes when I open it.
The DXErr.exe won't open at all.
I have a dual-monitor configuration and a GeForce FX5200 graphics card.
dxcpl.exe seems to work fine. I've tried using the debug version of
direct3d and I still get the same error.

Thanks,
-PaulH
legalize+ (Richard [Microsoft Direct3D MVP])
2007-01-18 22:52:02 UTC
Permalink
[Please do not mail me a copy of your followup]
Post by PaulH
I have a dialog app where I'd like to have a control that is direct3d
rendered. So, when this control's window is created I call an
CreateDevice() as below. But, it always fails with the error code
D3DERR_INVALIDCALL (0x8876086c). [...]
Standard questions apply:
- what versoin of the SDK are you using?
- Debug runtime installed?
- Debug runtime selected?
- What does the debug output say when you run your app?
- All HRESULTs checked?
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>

Legalize Adulthood! <http://blogs.xmission.com/legalize/>
PaulH
2007-01-18 23:36:18 UTC
Permalink
Post by legalize+ (Richard [Microsoft Direct3D MVP])
[Please do not mail me a copy of your followup]
Post by PaulH
I have a dialog app where I'd like to have a control that is direct3d
rendered. So, when this control's window is created I call an
CreateDevice() as below. But, it always fails with the error code
- what versoin of the SDK are you using?
September 2006
Post by legalize+ (Richard [Microsoft Direct3D MVP])
- Debug runtime installed?
Yes
Post by legalize+ (Richard [Microsoft Direct3D MVP])
- Debug runtime selected?
Yes
Post by legalize+ (Richard [Microsoft Direct3D MVP])
- What does the debug output say when you run your app?
Now this is interesting... I turned the debug up to the max in the
"DirectX Properties" app and now I see this:
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
Direct3D9: (ERROR) :Neither hDeviceWindow nor Focus window specified.
CreateDevice Failed.

I see my problem now.. The focus window is NULL, so my window creation
code hadn't been run yet.
Fixed! Thanks!
Post by legalize+ (Richard [Microsoft Direct3D MVP])
- All HRESULTs checked?
Yes, the HRESULT is the error code I'm posting (see code)
Post by legalize+ (Richard [Microsoft Direct3D MVP])
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>
Legalize Adulthood! <http://blogs.xmission.com/legalize/>
Thanks for your help. If you haven't seen my reply to my own first post
where I mention that half the directx SDK utilties aren't running,
please take a look at it and see if you can't recognize the issue. I
have tried reinstalling the SDK and restarting the computer, but the
problem remains.

Thanks,
PaulH
legalize+ (Richard [Microsoft Direct3D MVP])
2007-01-19 18:49:14 UTC
Permalink
[Please do not mail me a copy of your followup]
Post by PaulH
Thanks for your help. If you haven't seen my reply to my own first post
where I mention that half the directx SDK utilties aren't running,
please take a look at it and see if you can't recognize the issue.
Some people have mentioned that the viewer fails in the Decembe 2006
SDK, but the viewer source is included in the SDK, so try rebuilding
it.

As for why dxerr didn't open, I don't know about that.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>

Legalize Adulthood! <http://blogs.xmission.com/legalize/>
PaulH
2007-01-19 19:56:14 UTC
Permalink
Post by legalize+ (Richard [Microsoft Direct3D MVP])
[Please do not mail me a copy of your followup]
Post by PaulH
Thanks for your help. If you haven't seen my reply to my own first post
where I mention that half the directx SDK utilties aren't running,
please take a look at it and see if you can't recognize the issue.Some people have mentioned that the viewer fails in the Decembe 2006
SDK, but the viewer source is included in the SDK, so try rebuilding
it.
As for why dxerr didn't open, I don't know about that.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>
Legalize Adulthood! <http://blogs.xmission.com/legalize/>
dxerror works great now that it's been recompiled!

I recompiled dxviewer from the included source, but it seems angry
about not having d3dx10d.dll anywhere. I'm not too surprised it can't
be found since I only have directx 9.0c installed, but why would it be
looking for that dll?
It's all the more strange to me since in App::Main() it checks for the
availability of Direct3D 10 and then does a loadlibrary() on the dll if
they're available.
Any ideas on what's going on?

Thanks,
PaulH
legalize+ (Richard [Microsoft Direct3D MVP])
2007-01-19 21:03:21 UTC
Permalink
[Please do not mail me a copy of your followup]
Post by PaulH
I recompiled dxviewer from the included source, but it seems angry
about not having d3dx10d.dll anywhere. [...]
Try just removing d3dx10d.dll from the linker inputs in the project
configuration settings.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>

Legalize Adulthood! <http://blogs.xmission.com/legalize/>
Armin Zingler
2007-01-19 22:45:52 UTC
Permalink
Post by PaulH
dxerror works great now that it's been recompiled!
Had the same problem with dxerr tool. Did nothing at startup. Still doesn't
work after recompiling. Posted to m.p.w.p.d.SDK group but didn't get a reply
(see details there).


Armin
PaulH
2007-01-19 23:03:53 UTC
Permalink
Post by Armin Zingler
dxerror works great now that it's been recompiled!Had the same problem with dxerr tool. Did nothing at startup. Still doesn't
work after recompiling. Posted to m.p.w.p.d.SDK group but didn't get a reply
(see details there).
Armin
When you recompiled it and ran it in debug mode, did it give an error
message in the output window? If it doesn't, you can enable debug and
turn up the debug level in the "DirectX Properties" utility: dxcpl.exe.
That one worked for me without having to recompile.

-PaulH
Armin Zingler
2007-01-19 23:22:28 UTC
Permalink
Post by PaulH
Post by Armin Zingler
dxerror works great now that it's been recompiled!Had the same
problem with dxerr tool. Did nothing at startup. Still doesn't
work after recompiling. Posted to m.p.w.p.d.SDK group but didn't get a reply
(see details there).
When you recompiled it and ran it in debug mode, did it give an error
message in the output window? If it doesn't, you can enable debug and
dxcpl.exe.
That one worked for me without having to recompile.
No, no message. Debug runtime and maximied output is already active. As
mentioned, details see the other group.... wait, I paste it below.

Armin




Hi group,

the Dxerr tool does nothing here (Win XP Prof/SP2). Uinsg DX SDK Dec 2006.
Worked well in previous SDK version. Fortunatelly, it's source code is
supplied, but unfortunatelly I still can't find out why it doesn't work. It
gets a WM_DESTROY message even before the dialog is shown. I have no clue
why. The call stack when WM_DESTROY arrives is:


DXErr.exe!MainDlgProc(hDlg, msg, wParam, lParam) line 130
user32.dll!***@20()
user32.dll!***@32()
user32.dll!***@20()
user32.dll!***@16()
user32.dll!***@20()
user32.dll!***@32()
user32.dll!***@20()
user32.dll!***@4()
ntdll.dll!***@12()
user32.dll!***@16()
user32.dll!***@24()
user32.dll!***@24()
user32.dll!***@20()
DXErr.exe!WinMain(hInst, hPrevInst, pCmdLine, nCmdShow) line 87
DXErr.exe!WinMainCRTStartup() Zeile 251 C
kernel32.dll!***@4()

Anybody's got the same problem?
Armin Zingler
2007-01-19 23:36:31 UTC
Permalink
Post by Armin Zingler
Post by PaulH
Post by Armin Zingler
dxerror works great now that it's been recompiled!Had the same
problem with dxerr tool. Did nothing at startup. Still doesn't
work after recompiling. Posted to m.p.w.p.d.SDK group but didn't get a reply
(see details there).
When you recompiled it and ran it in debug mode, did it give an error
message in the output window? If it doesn't, you can enable debug and
dxcpl.exe.
That one worked for me without having to recompile.
No, no message. Debug runtime and maximied output is already active.
As mentioned, details see the other group.... wait, I paste it
below.
As it's a small app, I set breakpoints in all (4) functions. MainDlgProc is
called twice. The first time, msg=48 (WM_SETFONT), the second time it's
called, msg=2 (WM_DESTROY). There must be something in between that fails.
I'm gonna do some more debugging...


Armin
Armin Zingler
2007-01-20 00:50:53 UTC
Permalink
Post by Armin Zingler
As it's a small app, I set breakpoints in all (4) functions.
MainDlgProc is called twice. The first time, msg=48 (WM_SETFONT),
the second time it's called, msg=2 (WM_DESTROY). There must be
something in between that fails. I'm gonna do some more debugging...
Somewhere CreateWindow is called but return value is 0 (fail). Still
figuring out, why. After that, destroywindow is called.

...later...

After Createwindow fails I looked at GetLastError. It returns 1407:
ERROR_CANNOT_FIND_WND_CLASS, "Cannot find window class"

This is interesting. Now trying to find out, why...

...later...

The error (""Cannot find window class"") does not occur when creating the
main window, but when creating the first control within the dialog. Though,
I don't know why - yet....


Armin
legalize+ (Richard [Microsoft Direct3D MVP])
2007-01-20 01:15:26 UTC
Permalink
[Please do not mail me a copy of your followup]
Post by Armin Zingler
The error (""Cannot find window class"") does not occur when creating the
main window, but when creating the first control within the dialog. Though,
I don't know why - yet....
It means the window was created with a window class string for a class
that hasn't been registered.

What's the first control? If its a common control, you have to
initialize the common control library so that all the window classes
are registered.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>

Legalize Adulthood! <http://blogs.xmission.com/legalize/>
Armin Zingler
2007-01-21 21:25:14 UTC
Permalink
"Richard [Microsoft Direct3D MVP]" <legalize+***@mail.xmission.com>
schrieb
Post by legalize+ (Richard [Microsoft Direct3D MVP])
[Please do not mail me a copy of your followup]
Post by Armin Zingler
The error (""Cannot find window class"") does not occur when
creating the main window, but when creating the first control
within the dialog. Though, I don't know why - yet....
It means the window was created with a window class string for a
class that hasn't been registered.
I know, but I don't know why, but see below.
Post by legalize+ (Richard [Microsoft Direct3D MVP])
What's the first control? If its a common control, you have to
initialize the common control library so that all the window classes
are registered.
As the dialog is a resource, I don't know whether it's a common control. The
author should know...

I stopped debugging the tool because somebody else in the *.sdk group said
that it's a bug that might be fixed in the next SDK release.


Armin
legalize+ (Richard [Microsoft Direct3D MVP])
2007-01-22 17:30:22 UTC
Permalink
[Please do not mail me a copy of your followup]
Post by Armin Zingler
Post by legalize+ (Richard [Microsoft Direct3D MVP])
What's the first control? If its a common control, you have to
initialize the common control library so that all the window classes
are registered.
As the dialog is a resource, I don't know whether it's a common control. The
author should know...
Just open the *.rc file in Notepad
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>

Legalize Adulthood! <http://blogs.xmission.com/legalize/>
Loading...