I am trying to draw a background-like circle. Instead of the regular filled circle, I want to fill the outside of the circle.
This is the current code of the filled circle that I have:
void CDraw::CircleFilled(float x, float y, float rad, float rotate, int type, int resolution, DWORD color)
{
std::vector<vertex> circle(resolution + 2);
float angle = rotate * D3DX_PI / 180;
float pi;
if (type == full) pi = D3DX_PI; // Full circle
if (type == half) pi = D3DX_PI / 2; // 1/2 circle
if (type == quarter) pi = D3DX_PI / 4; // 1/4 circle
pi *= 100;
circle[0].x = x;
circle[0].y = y;
circle[0].z = 0;
circle[0].rhw = 1;
circle[0].color = color;
for (int i = 1; i < resolution + 2; i++)
{
circle[i].x = (float)(x - rad * cos(pi * ((i - 1) / (resolution / 2.0f))));
circle[i].y = (float)(y - rad * sin(pi * ((i - 1) / (resolution / 2.0f))));
circle[i].z = 0;
circle[i].rhw = 1;
circle[i].color = color;
}
// Rotate matrix
int _res = resolution + 2;
for (int i = 0; i < _res; i++)
{
circle[i].x = x + cos(angle) * (circle[i].x - x) - sin(angle) * (circle[i].y - y);
circle[i].y = y + sin(angle) * (circle[i].x - x) + cos(angle) * (circle[i].y - y);
}
pDevice->CreateVertexBuffer((resolution + 2) * sizeof(vertex), D3DUSAGE_WRITEONLY, D3DFVF_XYZRHW | D3DFVF_DIFFUSE, D3DPOOL_DEFAULT, &g_pVB, NULL);
VOID* pVertices;
g_pVB->Lock(0, (resolution + 2) * sizeof(vertex), (void**)&pVertices, 0);
memcpy(pVertices, &circle[0], (resolution + 2) * sizeof(vertex));
g_pVB->Unlock();
pDevice->SetTexture(0, NULL);
pDevice->SetPixelShader(NULL);
//pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
//pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
//pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
pDevice->SetStreamSource(0, g_pVB, 0, sizeof(vertex));
pDevice->SetFVF(0x104);
pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, resolution);
if (g_pVB != NULL) g_pVB->Release();
}
I want it to look like this and I have tried but I don’t know much of how these work and I have been googling for 2 days with no progress. I would appreciate any help