gpt4 book ai didi

C++ DirectX 9 径向(饼图)菜单

转载 作者:太空宇宙 更新时间:2023-11-04 11:32:26 25 4
gpt4 key购买 nike

<分区>

在 DirectX 9 中渲染径向菜单(具有动态个项目)的最简单方法是什么?

enter image description here

void DrawMenu(int x, int y, int radius, int width, int segments, LPDIRECT3DDEVICE9 dev){
Draw2DCircle(x, y, radius, D3DCOLOR_RGBA(0, 255, 255, 255), dev);
Draw2DCircle(x, y, radius-width, D3DCOLOR_RGBA(0, 255, 255, 255), dev);

float innerX, innerY, outerX, outerY;

float Theta;


for (int i = 0; i < segments; i++){
Theta = i * (2*PI / segments);

innerX = (radius - width)*cos(Theta) + x;
innerY = (radius - width)*sin(Theta) + y;

outerX = (radius)*cos(Theta) + x;
outerY = (radius)*sin(Theta) + y;

DrawLine(innerX, innerY, outerX, outerY, D3DCOLOR_RGBA(0, 255, 255, 255), dev);
}

}

我按照马里奥所说的做了,它就像一个魅力,但是......我需要做什么才能让菜单变色?

驱动函数:

void DrawLine(int x1, int y1, int x2, int y2, D3DCOLOR color, LPDIRECT3DDEVICE9 dev){
D3DTLVERTEX Line[2];
Line[0] = CreateD3DTLVERTEX(x1, y1, 0.0f, 1.0f, color, 0.0f, 0.0f);
Line[1] = CreateD3DTLVERTEX(x2, y2, 0.0f, 1.0f, color, 0.0f, 0.0f);

dev->SetFVF(D3DFVF_TL);
dev->SetTexture(0, NULL);
dev->DrawPrimitiveUP(D3DPT_LINESTRIP, 2, &Line[0], sizeof(Line[0]));}


void Draw2DCircle(int x, int y, float radius, D3DCOLOR color, LPDIRECT3DDEVICE9 dev){

const int NUMPOINTS = 40;
D3DTLVERTEX Circle[NUMPOINTS + 1];

int i;
float X;
float Y;
float Theta;

float AngleBetweenPoints;

AngleBetweenPoints = (float)((2 * PI) / NUMPOINTS);

for (i = 0; i <= NUMPOINTS; i++)

{
Theta = i * AngleBetweenPoints;
X = (float)(x + radius * cos(Theta));
Y = (float)(y - radius * sin(Theta));
Circle[i] = CreateD3DTLVERTEX(X, Y, 0.0f, 1.0f, color, 0.0f, 0.0f);
}

dev->SetFVF(D3DFVF_TL);
dev->SetTexture(0, NULL);
dev->DrawPrimitiveUP(D3DPT_LINESTRIP, NUMPOINTS, &Circle[0], sizeof(Circle[0]));}

自定义顶点结构

struct D3DTLVERTEX{
float fX;
float fY;
float fZ;
float fRHW;
D3DCOLOR Color;
float fU;
float fV;};

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com