Jump to content
  • Advertisement
Sign in to follow this  

[DX10] Problem with D3DX10CreateMesh()

This topic is 3615 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'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.
// 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 },

	UINT numElements = sizeof(layout) / sizeof(D3D10_INPUT_ELEMENT_DESC);

	// Create the mesh-object member
	D3DX10CreateMesh( m_pDevice,
						  numVertices / 3,
						  &m_pMesh );

	// Try to set the data into the object
	m_pMesh->SetVertexData(0, vertices);

	// Commit changes

// When Drawing I use this...
for(UINT p=0; p < techniqueDescription.Passes; ++p)

This does not work. Does anybody have a working snippet they know work, I can use?

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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?

Share this post

Link to post
Share on other sites
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]

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!