Jump to content
  • Advertisement
Sign in to follow this  
X-Shiryu

[D3D9] Draw Filled Circle avoiding Triangle Fan

This topic is 1970 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 implementing some controls for my GUI system, and now its time to do a RadioButton class, whereas I'll not using textures, but pure primitive shapes.

 

Its very simple: what I'll do is render a unfilled external circle and if RadioButton is clicked/checked, will be rendered a filled one inside.

 

Since Triangle Fan is marked as deprecated for D3D10+, can achieve it using Triangle Strips?

Model circle;
float position_x = 50;
float position_y = 350;

float radius_x = 30;
float radius_y = 30;

const int degrees = 360;
const float degrees_to_radians = 3.14159265f / 180.0f;

circle.ResizeVertices(degrees);

//Direct3D Triangle Strip
//circle.SetPrimitiveType(TriangleStrip);

//Direct3D Line Strip
circle.SetPrimitiveType(LineStrip);

circle.SetPrimitiveCount(circle.GetVertexTotal() - 1);

for (int i = 0; i < degrees; i++)
{
    const float rad = i * degrees_to_radians;

    circle.SetVertexPosition(i,position_x + (cos(rad) * radius_x),position_y + (sin(rad) * radius_y));

    circle.SetVertexColor(i,Color::Black);
}
 

Using LineStrip top result and TriangleStrip bottom result:

Untitled.png

Edited by X-Shiryu

Share this post


Link to post
Share on other sites
Advertisement

Why not just use DrawIndexed with triangles instead?  That can replicate any primitive type from earlier versions of D3D.

Share this post


Link to post
Share on other sites

Yeah, i just tried using Triangle List and worked.

 

Using indices like this: 0 1 2   0 2 3   0 3 4  ..., i can simulate a Triangle Fan and fill circle, but uses more indices.

Untitled.jpg

Edited by X-Shiryu

Share this post


Link to post
Share on other sites

Because i'm focusing more on functionalities of controls than graphical aspect, but later i can add a sprite and render it textured.


 

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!