Skip to main content
GameDev.net gamedev.net
🔒 Locked

D3DXCreateMeshFVF function

Started by axv4745 Mar 20, 2005 at 8:58 PM 2 replies 1.5k views
Original Post
axv4745
axv4745
I am trying to create a mesh using the D3DXCreateMeshFVF however the function keeps returning a failure status of value D3DERR_INVALIDCALL. From what I have read in the documentation D3DERR_INVALIDCALL usually is returned as a result of one passing an invalid parameter to the function. This is basically the line of code I wrote for creating the mesh HRESULT hr = D3DXCreateMeshFVF (numTriangles,numVertices,D3DXMESH_MANAGED,CVFVF,Renderer::getDeviceHandle(),&mesh); where numTriangles is a DWORD that equals 130050, numVertices equals 65536, CVFVF is a #define constant equal to (D3DFVF_XYZ | D3DFVF_DIFFUSE), and Renderer::getDeviceHandle() is just a call to my Renderer wrapper class that just returns the device handle. now none of these parameters seem invalid to me unless there is some kind of rule where the numVertices has to be bigger than numTriangles. Would anyone have any idea as to why this would fail?
paulble
paulble
Quote:
Original post by axv4745

... numVertices equals 65536 ...

Would anyone have any idea as to why this would fail?


You might need to use the D3DXMESH_32BIT flag to get an index buffer that can properly index that many vertices. I'm not sure if this is the problem you are having though.

If you're linking to the debug d3dx, see if you get any messages in the debugger output.

Paul Bleisch (MS)
circlesoft
circlesoft
Quote:
Original post by paulble
You might need to use the D3DXMESH_32BIT flag to get an index buffer that can properly index that many vertices.


Shouldn't 16-bit indices be sufficient in this case? If there are 65,536 vertices, that means the indices will run from 0 to 65,535. This value is literally just in range of a 16-bit datatype.

Quote:

If you're linking to the debug d3dx, see if you get any messages in the debugger output.

Exactly - remember, if you ever get D3DERR_INVALIDCALL, just fire up the debugger. The debug runtime will always give you some detailed information as to why the function failed.
paulble
paulble
Quote:
Original post by circlesoft
Quote:
Original post by paulble
You might need to use the D3DXMESH_32BIT flag to get an index buffer that can properly index that many vertices.


Shouldn't 16-bit indices be sufficient in this case? If there are 65,536 vertices, that means the indices will run from 0 to 65,535. This value is literally just in range of a 16-bit datatype.


The mesh code uses 0xFFFF as a reserved marker for 16-bit meshes (0xFFFFFFFF for 32-bit meshes) so it can denote "unused" or "uninitialized" index values during some processing. For this reason, a 16-bit mesh can only store 65,535 vertices. Note also that for similar reasons, 16-bit meshes can only store 65,535 faces as well.

Paul Bleisch (MS)

Topic Locked

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

Sign in to reply to this topic.