Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void gui::CircleFilledDualColor(float x, float y, float rad, float rotate, int type, int resolution, DWORD color, DWORD color2, IDirect3DDevice9* m_device)
- {
- std::vector<CUSTOMVERTEX> circle(resolution + 2);
- float angle = rotate * D3DX_PI2 / 180, pi = D3DX_PI2;
- if (type == full)
- pi = D3DX_PI2; // Full circle
- if (type == half)
- pi = D3DX_PI2 / 2; // 1/2 circle
- if (type == quarter)
- pi = D3DX_PI2 / 4; // 1/4 circle
- pi = D3DX_PI2 / type; // 1/4 circle
- circle[0].x = x;
- circle[0].y = y;
- circle[0].z = 0;
- circle[0].rhw = 1;
- circle[0].color = color2;
- 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);
- }
- m_device->CreateVertexBuffer((resolution + 2) * sizeof(CUSTOMVERTEX), D3DUSAGE_WRITEONLY, D3DFVF_XYZRHW | D3DFVF_DIFFUSE, D3DPOOL_DEFAULT, &g_pVB2, NULL);
- VOID* pVertices;
- g_pVB2->Lock(0, (resolution + 2) * sizeof(CUSTOMVERTEX), (void**)&pVertices, 0);
- memcpy(pVertices, &circle[0], (resolution + 2) * sizeof(CUSTOMVERTEX));
- g_pVB2->Unlock();
- m_device->SetTexture(0, NULL);
- m_device->SetPixelShader(NULL);
- m_device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- m_device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- m_device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- m_device->SetStreamSource(0, g_pVB2, 0, sizeof(CUSTOMVERTEX));
- m_device->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
- m_device->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, resolution);
- if (g_pVB2 != NULL)
- g_pVB2->Release();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement