gpt4 book ai didi

c++ - float 类型的参数与 GLfloat 不匹配?

转载 作者:行者123 更新时间:2023-11-28 01:10:17 25 4
gpt4 key购买 nike

我试图在这里做点什么,但出现了错误我真的不知道如何正确完成它我试图将 Figure.h 中的所有变量作为 GLfloat 而不是 float 并且相同的错误不断出现主意?这是我的图.h

Class Figure
{
public:
Figure(float x,float y,float z);
void Parameters(float x,float y,float z);
void Draw();
float paramx(){
return x1;
}
float paramy(){
return y1;
}
float paramz(){
return z1;
}
protected:
private:
float x1,y1,z1;
list <Figure> m_vertices;
};

这是我的 .cpp,它给我带来了所有的麻烦 >.<

Figure::Figure(float x,float y,float z){
this->x1=x;
this->y1=y;
this->z1=z;
}
void Figure::Parameters(float x,float y,float z)
{
m_vertices.push_back(Figure(x, y, z));
}
void Figure::Draw()
{
list<Figure>::iterator p = m_vertices.begin();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glLoadIdentity();
gluLookAt(0.0,0.0,4.0,0.0,0.0,0.0,0.0,1.0,0.0);

glBegin(GL_TRIANGLES);
while(p != m_vertices.end()){
glNormal3f(p->paramx,p->paramy,p->paramz);
glVertex3f(p->paramx,p->paramy,p->paramz);
p++;
}
glEnd();

}

假设问题出在 glNormal3f 和 glVertex3f 任何帮助将不胜感激,非常感谢

最佳答案

您需要调用函数:

    glNormal3f(p->paramx(), p->paramy(), p->paramz());
glVertex3f(p->paramx(), p->paramy(), p->paramz());

关于c++ - float 类型的参数与 GLfloat 不匹配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3799989/

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