我有这个小代码
GLUquadricObj *q = gluNewQuadric()
....
.....
glTranslatef(s->c.x, s->c.y, s->c.z);
gluSphere(q, s->r, SPHERE_DIVS, SPHERE_DIVS);
我想用我制作的函数替换这个glusphere。它将3D中心,镭和跟踪球体作为参数
int gp21_gluSphere(GLfloat x, GLfloat y, GLfloat z, GLdouble radius);
但我的问题是当我更换功能
gluSphere(q, s->r, SPHERE_DIVS, SPHERE_DIVS);
带
gp21_gluSphere (q.x, q.y, q.z, s->r);
我收到这些错误
error C2228: left of '.x' must have class/struct/union type
error C2228: left of '.y' must have class/struct/union type
error C2228: left of '.z' must have class/struct/union type
我该怎么办?
答案 0 :(得分:0)
您已将q
声明为指针,然后尝试访问其结构/对象之类的成员。
尝试改为:
gp21_gluSphere (q->x, q->y, q->z, s->r);