Jump to content
  • Advertisement
Sign in to follow this  
yahastu

VertexStride in stream 0 error

This topic is 3915 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

I've been stuck on this error for a while and unable to solve it. The problem only occurs when running on the debug version of direct 3d9. My mesh will not render, and I get this error in the debug console. I am setting the vertex declaration explicitly before rendering, so Im not sure whats wrong. I get the same problem in a couple different places... On my custom mesh format that just uses buffers:
void Mesh::Render()
{
	dxDevice->SetVertexDeclaration(pVertexDecl);
	dxDevice->SetIndices(pIndexBuffer);
	dxDevice->SetStreamSource( 0, pVertexBuffer, 0, sizeof(VFORMAT) );
	dxDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, (UINT)faces.size()*3, 0, (UINT)faces.size());
}

Also, when rendering the .X files I loaded with D3DXLoadMeshFromX:
for( DWORD i=0; i<dwNumMaterials; i++ )
{
	dxDevice->SetMaterial( &pMeshMaterials );
	dxDevice->SetTexture( 0, pMeshTextures );
	pMesh->DrawSubset( i ); //Direct3D9: (ERROR) :Vertex stride in stream 0 is less than in the declaration
}

This problem occurs before any issues with device being lost. Any idea where to look?

Share this post


Link to post
Share on other sites
Advertisement
I was just about to reply and say I found a problem in my vertex declaration. So I now have the Mesh::Render working properly.

However I am still having the same problem with the mesh that I load using D3DXLoadMeshFromX

Since I do not manage a vertex declaration for that...I don't know how to set it!

I am basically just using example code


HRESULT ShapeNode::Load(const char *filename)
{
LPD3DXBUFFER pD3DXMtrlBuffer;

// Load the mesh from the specified file
if( FAILED( D3DXLoadMeshFromX( filename, D3DXMESH_MANAGED,
dxDevice, NULL,
&pD3DXMtrlBuffer, NULL, &dwNumMaterials,
&pMesh ) ) )
{
return E_FAIL;
}

// We need to extract the material properties and texture names from the
// pD3DXMtrlBuffer
D3DXMATERIAL *d3dxMaterials = (D3DXMATERIAL*)pD3DXMtrlBuffer->GetBufferPointer();
pMeshMaterials = new D3DMATERIAL9[dwNumMaterials];
pMeshTextures = new LPDIRECT3DTEXTURE9[dwNumMaterials];

for( DWORD i=0; i<dwNumMaterials; i++ )
{
// Copy the material
pMeshMaterials = d3dxMaterials.MatD3D;

// Set the ambient color for the material (D3DX does not do this)
pMeshMaterials.Ambient = pMeshMaterials.Diffuse;

// Create the texture
if( FAILED( D3DXCreateTextureFromFile( dxDevice,
d3dxMaterials.pTextureFilename,
&pMeshTextures ) ) )
{
pMeshTextures = NULL;
}
}

// Done with the material buffer
SAFE_RELEASE(pD3DXMtrlBuffer);

return S_OK;
}

void ShapeNode::Render()
{
for( DWORD i=0; i<dwNumMaterials; i++ )
{
dxDevice->SetMaterial( &pMeshMaterials );
dxDevice->SetTexture( 0, pMeshTextures );
pMesh->DrawSubset( i ); //Direct3D9: (ERROR) :Vertex stride in stream 0 is less than in the declaration
}
}

Share this post


Link to post
Share on other sites
I've never loaded or rendered a .X mesh, so I can't tell you exactly what you need to do. What I can say is that pretty much every sample that ships with the SDK loads X files, and renders them... just check what one of the really simple samples does.

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!