Skip to main content
gamedev.net
🔒 Locked

DrawSubset

Started by mauro78 Jun 15, 2010 at 1:58 AM 4 replies 1.2k views
Original Post
mauro78
mauro78
Hi All,
I'm trying to render a ID3DXMesh without using drawsubset...

m_d3d9Device->SetTransform(D3DTS_WORLD, &pActor->m_matWS);m_d3d9Device->SetTransform(D3DTS_PROJECTION, &m_Camera->mProj);m_d3d9Device->SetTransform(D3DTS_VIEW, &m_Camera->mView);IDirect3DVertexBuffer9* m_vb;IDirect3DIndexBuffer9* m_ib;HRESULT hResultVB =  pActor->m_mesh->GetVertexBuffer(&m_vb);HRESULT hResultIB = pActor->m_mesh->GetIndexBuffer(&m_ib);if(SUCCEEDED(hResultVB)){ int foo=0; foo++;}if(SUCCEEDED(hResultIB)){ int foo=0; foo++;} DWORD size = 0;          pActor->m_mesh->GetAttributeTable(NULL, &size);if (size){  [for every subset]  m_d3d9Device->SetVertexDeclaration(NMapVertex::Decl);  m_d3d9Device->SetStreamSource(0, m_vb, 0, sizeof(NMapVertex));  m_d3d9Device->SetIndices(m_ib);  m_d3d9Device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,vstart,vcount,fstart*3,fcount);}       m_vb->Release();m_ib->Release();


even with just one subset mesh is displayed wrong :-(
if I use drawsubset everything is fine...any idea?

Thanks in adavance
mauro78
mauro78
Quote:
Original post by Gage64
Do the debug runtimes say anything?

Also, are you sure you're using the correct vertex declaration? And how do you initialize vstart, vcount, etc.?


Yes vertex declaration is correct and vstart vcount are taken from the ID3DXMesh via that method:

HRESULT GetAttributeTable(

D3DXATTRIBUTERANGE *pAttribTable,
DWORD *pAttribTableSize
);

...very strange :-/
Evil Steve
Evil Steve
Quote:
Original post by mauro78
even with just one subset mesh is displayed wrong :-(
1. Define "wrong". Can we see a screenshot? (And a screenshot of how it looks when it's correct too)
2. Have you tried using PIX to compare the D3D calls when you use DrawSubset and your method? If everything is working correctly, the calls should be identical.

mauro78
mauro78
Quote:
Original post by Evil Steve
Quote:
Original post by mauro78
even with just one subset mesh is displayed wrong :-(
1. Define "wrong". Can we see a screenshot? (And a screenshot of how it looks when it's correct too)
2. Have you tried using PIX to compare the D3D calls when you use DrawSubset and your method? If everything is working correctly, the calls should be identical.



1. I'll post a screen shot.Wrong means different from the expected result; not by just some poly but the entire mesh is messed up
2. I'll try with PIX

but from my point of view It's just a VB and a IB so I don't expect some strange calls from DrawSubset...I'll post results later

cheers, Mauro

EDIT: googling around I found some post about using:
IDirect3DDevice9::DrawIndexedPrimitiveUP

for big meshes....and my meshes are big...I'll try this way also..

[Edited by - mauro78 on June 15, 2010 3:23:00 AM]
mauro78
mauro78
Seems to be a fixed function pipeline problem: I was drawing those primitives with FFP for testing; I've maxed out the debug level and the result is:

Direct3D9: Decl Validator: X284: (Element Error) (Decl Element [2]) Declaration can't map to fixed function FVF because a usage+index pair (D3DDECLUSAGE_BINORMAL,0) that is not valid for fixed function appears between two vertex elements that have usage+index pairs valid for fixed function. For a vertex declaration to map to fixed function, all individual elements that are valid for fixed function must appear contiguously starting from the first element. Remaining elements at the end do not have to be valid for fixed function, as long as there are few enough that they can be aliased internally to texcoord(n), texcoord(n+1) etc. up to max. texcoord7 (thereby appearing to conform to an FVF, although the aliased values should not be used).

I'm testing it with a shader right now...

EDIT:
It works with this new setup but also I had to change this:

m_d3d9Device->SetFVF( pActor->m_mesh->GetFVF() );
m_d3d9Device->SetStreamSource(0, m_vb, 0, D3DXGetFVFVertexSize( pActor->m_mesh->GetFVF() )));

since I was getting another error on the DrawIndexedPrimitive....

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.