Jump to content
  • Advertisement
Sign in to follow this  
Seabolt

[DX9] CreateDepthStencilSurface before CreateVertexDeclaration causes crash

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey GameDev,

I've got a question for you. I've executed this code right after I create my device:



// Create the depth stencil
HRESULT result = gDeviceManager->GetDevice()->CreateDepthStencilSurface( bufferWidth,
bufferHeight,
textureFormat == FormatD32 ? D3DFMT_D32 : D3DFMT_D24S8,
D3DMULTISAMPLE_NONE,
0, FALSE,
&mPlatformData.mDepthTexture,
NULL );
assert( "Failed to create depth stencil" && SUCCEEDED( result ) ); // Check to see if we failed



It executes fine, no errors.

But then this code returns INVALID_CALL




//--
// PositionNormalColor
//--
D3DVERTEXELEMENT9 dwDecl[] =
{
// Stream Offset Type Method Usage Usage Index
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 1, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
{ 2, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
D3DDECL_END()
};
mPlatformData[ kPositionNormalColor ] = new TCVertexDeclarationPlatformData;
hResult = gDeviceManager->GetDevice()->CreateVertexDeclaration( dwDecl, &mPlatformData[ kPositionNormalColor ]->mDecl );
assert( "Failed to create vertex declaration" && hResult == S_OK );




There is nothing different about this code from before hand, but with that initialization I assert on CreateVertexDeclaration. If I take it out, it works fine. Any idea why guys?

Share this post


Link to post
Share on other sites
Advertisement
Could you de-OO this code and just try creating a vertex declaration directly on an LPDIRECT3DVERTEXDECLARATION9. If that works OK, then the most likely source of your problem is something in your OO layer.

Share this post


Link to post
Share on other sites
Use the directx control panel to enable the debug runtime and verbose error reporting, then check the output log to see why the call fails.

Share this post


Link to post
Share on other sites
Thanks guys, I enabled the verbose output, and found out it was because I was calling Reset and hadn't freed the depth buffer I created. Thanks guy, I had no idea a tool like that existed, and I've been doing dx9 for almost three years now! Haha

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!