# CreateOffscreenPlainSurface = D3DERR_INVALIDCALL???

This topic is 4867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

When I try to run the following lines of code I recieve a HRESULT of D3DERR_INVALIDCALL. How can I fix this?
LPDIRECT3DSURFACE9 m_pHeightData;
HRESULT hr;

m_pHeightData = NULL;
hr = CreateOffscreenPlainSurface(256,256, D3DFMT_R8G8B8, D3DPOOL_MANAGED, &m_pHeightData, NULL);


##### Share on other sites
D3DPOOL_MANAGED is not allowed when creating an offscreen plain surface. You should be using D3DPOOL_DEFAULT in most cases. When you're wondering why a D3D function fails, check out the debug output. It almost always leaves you with precise information about the failure.

##### Share on other sites
Changed to D3DPOOL_DEFAULT and still the same result. I tried increasing the debug output level from DirectX but its greyed out and is marked at the lowest (Think it may be due to developing with 9b and running 9c?)

Any other suggestions?

##### Share on other sites
If it's an option, I'd probably suggest getting the 9c SDK and see if you can change the output level then.

Without it you're probably going to be hard-pressed finding out exactly what the problem is. Are there any problems getting the 9c SDK?

##### Share on other sites
Unfortunately I can't use 9c, due to assignment requirements which is a real pain

Ideas anyone?

##### Share on other sites
I suspect the surface format you're asking for may not actually be supported by your graphics hardware/driver (24-bit modes aren't good for most hardware, try X8R8G8B8).

As has already been suggested, use the DEBUG Direct3D runtime (see the FAQ) to determine *why* D3D has returned the INVALIDCALL error. You don't need to have DirectX 9.0c to do this - you just have to have the DirectX SDK installed.

##### Share on other sites
Quote:
 Original post by S1CAI suspect the surface format you're asking for may not actually be supported by your graphics hardware/driver (24-bit modes aren't good for most hardware, try X8R8G8B8).

Yep, that was the problem. Thanks!

Quote:
 As has already been suggested, use the DEBUG Direct3D runtime (see the FAQ) to determine *why* D3D has returned the INVALIDCALL error. You don't need to have DirectX 9.0c to do this - you just have to have the DirectX SDK installed.

How can I turn on the Debug runtime without access to the Direct X Control Panel (from the windows control panel) if it isn't there? And VS.NET won't allow me to adjust the settings as they are greyed out?