D3DXCreateSphere fails

Started by
6 comments, last by Ouranos 21 years, 1 month ago
Hey peoples, Whenever I call D3DXCreateSphere (or any of the other shape drawing functions) it always fails. I checked for the error codes it's supposed to return but it's none of those. I realize that I can do all of the sphere creation code myself but the fact that these simple methods don't work really bugs me. Here is the method in my graphics interface that creates a sphere: int CGraphics::DrawSphere( D3DXVECTOR3 pos, const float &radius ) { LPD3DXMESH meshSphere; D3DXMATRIX matLocation; D3DXMatrixIdentity( &matLocation ); if( !D3DXCreateSphere( m_pd3dDevice, radius, 16, 16, &meshSphere, NULL ) ) return 0; D3DXMatrixTranslation( &matLocation, pos.x, pos.y, pos.z ); SetWorldMatrix( matLocation ); D3DMATERIAL9 mtrlSphere; ZeroMemory( &mtrlSphere, sizeof( mtrlSphere ) ); mtrlSphere.Diffuse.r = mtrlSphere.Ambient.r = 1.0; mtrlSphere.Diffuse.g = mtrlSphere.Ambient.g = 1.0; mtrlSphere.Diffuse.b = mtrlSphere.Ambient.b = 1.0; mtrlSphere.Diffuse.a = mtrlSphere.Ambient.a = 1.0; m_pd3dDevice->SetMaterial( &mtrlSphere ); if( !meshSphere->DrawSubset( 0 ) ) return 0; return 1; } insert witty signature here [edited by - Ouranos on March 7, 2003 4:51:09 PM]
-------------------------http://www.roachpuppy.com
Advertisement
Seems to me it should work to generate the sphere,
but subset 1 ? One would believe it should be subset 0...

--
MFC is sorta like the swedish police... It''''s full of crap, and nothing can communicate with anything else.
You''re right it is subset 0, I was just playing around with that value before I realized the sphere was not getting generated to begin with.

insert witty signature here
-------------------------http://www.roachpuppy.com
Have you tried the D3D Error lookup tool?


--
MFC is sorta like the swedish police... It''''s full of crap, and nothing can communicate with anything else.
I have had problems with that function too. I don''t know what''s wrong, but why are you creating the sphere in the render loop? This will be very performance costy. Consider changing this when you find your initial problem.
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions
Yea I know, this is just a very specialized function (you cant even set the color) that we''re using to test our collision detection. The radius always changes and I didnt want to go through the trouble of changing the VB, etc. for a function we wont even use in the final game.

insert witty signature here
-------------------------http://www.roachpuppy.com
jesus christ man, it was all a matter of inconsistent coding in the API. The function was returning 0 for S_OK (D3D_OK is not zero), and the way I had it coded it bails when it returns zero. thanks for all your help guys.

insert witty signature here
-------------------------http://www.roachpuppy.com
Uhm, atleast in D3DX9 it says:
If the function succeeds, the return value is D3D_OK.



--
MFC is sorta like the swedish police... It''''s full of crap, and nothing can communicate with anything else.

This topic is closed to new replies.

Advertisement