// Create vertex buffer
VertexPosTexStruct vertices[] =
{
{ D3DXVECTOR3(0.0f, 1.0f, 0.0f), D3DXVECTOR3(0.0f, 0.0f, -1.0f), D3DXVECTOR2(0.5f, 0.0f) },
{ D3DXVECTOR3(1.0f, -0.5f, 0.0f), D3DXVECTOR3(0.0f, 0.0f, -1.0f), D3DXVECTOR2(1.0f, 1.0f) },
{ D3DXVECTOR3(-1.0f, -0.5f, 0.0f), D3DXVECTOR3(0.0f, 0.0f, -1.0f), D3DXVECTOR2(0.0f, 1.0f) },
};
// Calculate the number of vertices in the array
UINT numVertices = sizeof(vertices) / sizeof(VertexPosTexStruct);
UINT numStride = sizeof(VertexPosTexStruct);
UINT numOffset = 0;
// Create inputlayout
D3D10_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0 },
};
UINT numElements = sizeof(layout) / sizeof(D3D10_INPUT_ELEMENT_DESC);
// Create the mesh-object member
D3DX10CreateMesh( m_pDevice,
layout,
numElements,
"POSITION",
numVertices,
numVertices / 3,
D3DX10_MESH_32_BIT,
&m_pMesh );
// Try to set the data into the object
m_pMesh->SetVertexData(0, vertices);
// Commit changes
m_pMesh->CommitToDevice();
// When Drawing I use this...
for(UINT p=0; p < techniqueDescription.Passes; ++p)
{
pShaderTechnique->GetPassByIndex(p)->Apply(0);
m_pMesh->DrawSubset(0);
}
[DX10] Problem with D3DX10CreateMesh()
I'm trying to create a D3DX10Mesh-object but can't get the thing to draw. Checking all HRESULTS (removed for easier reading) but no errors are thrown.
The code I use for creating this object is shown below.
This does not work.
Does anybody have a working snippet they know work, I can use?
A couple of suggestions:
Try PIX. You'll be able to see if anything is being drawn, and how vertices are transformed (if they are).
Try this code without the mesh. Create a vertex buffer and draw it. That'd show you if the problem is with the mesh or the data.
Try PIX. You'll be able to see if anything is being drawn, and how vertices are transformed (if they are).
Try this code without the mesh. Create a vertex buffer and draw it. That'd show you if the problem is with the mesh or the data.
I've tried it with the same data, but in a normal vertexbuffer and it works fine, so it's probably a matter of how the mesh is created or user.
Do I have to set anything in the mesh manually before rendering besides what's already there in the example? Is there a tut of this somewhere?
Do I have to set anything in the mesh manually before rendering besides what's already there in the example? Is there a tut of this somewhere?
I am just guessing, but don't you need an index buffer to tell it what vertices to draw and in what order?
I also do not see where you bound the input layout using IASetInputLayout()
[Edited by - brekehan on August 26, 2008 5:06:07 PM]
I also do not see where you bound the input layout using IASetInputLayout()
[Edited by - brekehan on August 26, 2008 5:06:07 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement