大家好,我使用 winapi,我想在 3d 中做一个正方形,我定义点将它们与一个函数结合起来,我一直在尝试 3 个函数,但我无法让它们工作,我在 3 个 em 中遇到相同的错误 > .<
错误说
In member function `void Cube::Show(void)':|
cannot convert `const Cube::Show()::POINT3D**' to `const POINT*'
for argument `2' to `BOOL Polygon(HDC__*, const POINT*, int)'|
当我使用多边形函数或多边形贝塞尔曲线或折线时出现错误
请提供任何帮助,我们将不胜感激
void Cube::Show(void)
{
typedef struct point3d
{
double x;
double y;
double z;
} POINT3D;
POINT3D Face1[] = {
{ 20.0,-20.0,-20.0},
{-20.0,-20.0,-20.0},
{-20.0, 20.0,-20.0},
{ 20.0, 20.0,-20.0}
};
POINT3D Face2[] = {
{-20.0,-20.0,-20.0},
{-20.0,-20.0, 20.0},
{-20.0, 20.0, 20.0},
{-20.0, 20.0,-20.0}
};
POINT3D Face3[] = {
{ 20.0, 20.0, 20.0},
{-20.0, 20.0, 20.0},
{-20.0,-20.0, 20.0},
{ 20.0,-20.0, 20.0}
};
POINT3D Face4[] = {
{ 20.0,-20.0, 20.0},
{ 20.0,-20.0,-20.0},
{ 20.0, 20.0,-20.0},
{ 20.0, 20.0, 20.0}
};
POINT3D Face5[] = {
{ 20.0,-20.0, 20.0},
{-20.0,-20.0, 20.0},
{-20.0,-20.0,-20.0},
{ 20.0,-20.0,-20.0}
};
POINT3D Face6[] = {
{ 20.0, 20.0,-20.0},
{-20.0, 20.0,-20.0},
{-20.0, 20.0, 20.0},
{ 20.0, 20.0, 20.0}
};
POINT3D *Faces[] = {Face1,Face2,Face3,Face4,Face5,Face6};
Rectangle(this->_hdc,this->DrawArea.left,this->DrawArea.top,this->DrawArea.right,this->DrawArea.bottom);
Polygon(_hdc,Faces,6);
/*BeginPath(_hdc);
PolyBezier(Faces,6);
EndPath(_hdc);*/
//Polyline(_hdc,Faces,6);
}
最佳答案
您正在传递 POINT3D 版本的 POINT,而不是全局命名空间中的 POINT。结构相同,只是类型转换而成。此外,您传递的是数组的数组而不是单个数组。
因此,我建议您重新访问该 API,看看它需要什么 - 类似
Polygon(_hdc,((POINT *) (Faces[0])),6) perhaps
关于c++ - 无法将 struct** 转换为 const POINT* 作为参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3597660/