# Shapes in DirectX

5 replies to this topic

### #1TheLionKing

Valued Member

• Members
• 143 posts

Posted 16 September 2003 - 04:48 AM

Hi,

In OpenGL we can choose what we want do draw like GL_QUADS for Square and other stuff ... but in DirectX there is just TRIANGLE and other stuff related to it. :unsure: So, we have to use triangles to draw squares and other stuff ... right?

My question is if I want to draw a Sphere ... how can I do that? Do I have to generate it by an alogrithm or is there a function for it ...? :wtf:
<span style='color:blue'>I can survive anything ... even NUKES!!!
The Lion King</span>

### #2Dia

DevMaster Staff

• 1120 posts

Posted 16 September 2003 - 05:03 AM

DirectX9 has utilities (prefixed with D3DX) which can do what you need. Use this function:

HRESULT D3DXCreateSphere(

IDirect3DDevice9* pDevice,
unsigned int      slices,
unsigned int      stacks,
LPD3DXMESH*       mesh,
);


But if you don't want to use DirectX's mesh structure (D3DXMESH), then you'll have to generate the sphere yourself.

If you're interested, I can make a short article on implementing the algorithm for both OpenGL and DirectX.

Hope that helps.

### #3TheLionKing

Valued Member

• Members
• 143 posts

Posted 16 September 2003 - 12:48 PM

Thanks :yes: ! Why didn't I think of that before? Thanks again ...!

:nod: I would love to see your article (anything related to DX now ... since I am learning that now :blush: ).

D3DX is a DX utility like GLUT is for OpenGL ... right :) ?

There are then functions for creating other objects in D3DX like there is in the case of OpenGL?
<span style='color:blue'>I can survive anything ... even NUKES!!!
The Lion King</span>

### #4donBerto

Senior Member

• Members
• 369 posts

Posted 16 September 2003 - 02:13 PM

D3DX is the Direct 3D sub-api of DX. so most [if not all] of the D3D code you'll have will be "prefixed with D3D" [a la apex]

werd?
:yes:
Imagine.

### #5baldurk

Senior Member

• Members
• 1057 posts

Posted 16 September 2003 - 06:28 PM

bear in mind that regardless of the shape, it's always, AFAIK, split into triangles by the vidcard/API. So rendering is triangles is best all round.
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.

### #6TheLionKing

Valued Member

• Members
• 143 posts

Posted 17 September 2003 - 03:17 AM

Thanks :yes: ! Now I know why people told me to draw a quad through triangles in OpenGL :D !!!
<span style='color:blue'>I can survive anything ... even NUKES!!!
The Lion King</span>

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users