such as the CreateTeapot function - http://msdn.microsoft.com/en-us/library/windows/desktop/bb172798(v=vs.85).aspx

Is there an equivalent in DX10? If so, how do I use it?

In DX9 you..


LPD3DXMESH meshTeapot;


D3DXCreateTeapot(device, &meshTeapot, NULL);





Is there an equivalent set of methods for drawing primitives? (to be honest the sphere is of more interest to me than the teapot!)


Short Story

Check the DXUT Library under DXSDK_DIR\Samples\C++\DXUT.

Long Story

I'm not entirely sure, but from looking over the documentation it appears that the D3DX utility library has been significantly trimmed between DX9 and DX10. See the following links for a side by side comparison of both libraries:

It seems to me that the shape drawing functions have not been relocated to another portion of the library, but removed entirely instead. You still have mesh support though, using the ID3DX10Mesh interface and the D3DX10CreateMesh function.

With further investigation I managed to find the methods you wanted in the DXUT Library. This is the library used in most of the official DX samples that come with the SDK. I think you should be able to find the library under DXSDK_DIR\Samples\C++\DXUT. In particular check the DXUTShapes.h file which has the following method:

HRESULT WINAPI DXUTCreateSphere(ID3D10Device* pDevice, 
                                float fRadius, 
                                UINT uSlices, 
                                UINT uStacks, 
                                ID3DX10Mesh** ppMesh );

In case you don't want to use that library because it implies having to include and link to yet another library, here's some other alternatives I could think of:

  1. The easiest method and also the one I'd probably use would be to generate a sphere in a 3D modelling application such as Blender and import it. Make the sphere have a diameter of 1 unit and be centered around the origin, so that with a simple scaling and translation of the vertices you can adjust it to any size and location.

  2. Alternatively you could also think about generating the vertex information for the sphere procedurally with your own code (this answer has a lot of information on how to do this) and populating a mesh object with that data.

  3. Finally I can think of yet another solution but I'm not sure I would recommend it as it seems very much like a hack. That alternative would be to initialize a minimal Direct3D 9 device object just so so you can run the D3DXCreateSphere method once, store the data in memory, and then use it later to initialize the Direct3D 10 objects.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.