I just started learning DirectX and have question enabling npatch.
How do I turn on?
I don't know why my program do not draw more polygons.
This is my rendering code
m_pD3DDevice->SetRenderState (D3DRS_PATCHSEGMENTS, (DWORD)8.0f);
m_pD3DDevice->SetRenderState (D3DRS_PATCHEDGESTYLE, D3DPATCHEDGE_DISCRETE);
m_pD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, m_dwNumOfVertices, 0, m_dwNumOfPolygons);
m_pD3DDevice->SetRenderState (D3DRS_PATCHSEGMENTS, (DWORD)1.0f);
This is my FVF
#define CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL)
struct CUSTOMVERTEX
{
FLOAT x, y, z; FLOAT nx, ny, nz;
};
I have these lines when initializing
m_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING |
D3DCREATE_PUREDEVICE, &d3dpp, &m_pD3DDevice);
m_pD3DDevice->SetRenderState (D3DRS_POSITIONORDER, D3DORDER_CUBIC);
m_pD3DDevice->SetRenderState (D3DRS_NORMALORDER, D3DORDER_LINEAR);
m_pD3DDevice->CreateVertexBuffer(m_dwNumOfVertices * sizeof(CUSTOMVERTEX), D3DUSAGE_NPATCHES, D3DFVF_CUSTOMVERTEX,
D3DPOOL_MANAGED, &m_pVertexBuffer);
m_pD3DDevice->CreateIndexBuffer(m_dwNumOfIndices * sizeof(WORD), D3DUSAGE_NPATCHES, D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_pIndexBuffer)
I have set all the normals before rendering.
Is there anything that I'm missing?
Is there anything that I have to do before enabling npatch?
or Is there anything that I should not do for npatch?
How do I turn on?
I don't know why my program do not draw more polygons.
This is my rendering code
m_pD3DDevice->SetRenderState (D3DRS_PATCHSEGMENTS, (DWORD)8.0f);
m_pD3DDevice->SetRenderState (D3DRS_PATCHEDGESTYLE, D3DPATCHEDGE_DISCRETE);
m_pD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, m_dwNumOfVertices, 0, m_dwNumOfPolygons);
m_pD3DDevice->SetRenderState (D3DRS_PATCHSEGMENTS, (DWORD)1.0f);
This is my FVF
#define CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL)
struct CUSTOMVERTEX
{
FLOAT x, y, z; FLOAT nx, ny, nz;
};
I have these lines when initializing
m_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING |
D3DCREATE_PUREDEVICE, &d3dpp, &m_pD3DDevice);
m_pD3DDevice->SetRenderState (D3DRS_POSITIONORDER, D3DORDER_CUBIC);
m_pD3DDevice->SetRenderState (D3DRS_NORMALORDER, D3DORDER_LINEAR);
m_pD3DDevice->CreateVertexBuffer(m_dwNumOfVertices * sizeof(CUSTOMVERTEX), D3DUSAGE_NPATCHES, D3DFVF_CUSTOMVERTEX,
D3DPOOL_MANAGED, &m_pVertexBuffer);
m_pD3DDevice->CreateIndexBuffer(m_dwNumOfIndices * sizeof(WORD), D3DUSAGE_NPATCHES, D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_pIndexBuffer)
I have set all the normals before rendering.
Is there anything that I'm missing?
Is there anything that I have to do before enabling npatch?
or Is there anything that I should not do for npatch?
Last edited: