使用glutDisplayFunc(opengl)绘图

用户名

我有一个显示功能,可以显示由两点定义的各种线段:

void display(long total_points, vector<vector<long>> adjmat){
    //stuff here
    glVertex2f(n1,n2);
    glVertex2f(n3,n4);
}

我想在窗口中显示这些细分,并使用glut来做到这一点:

int main(int argc, char *argv[]){
    //stuff here
    glutDisplayFunc(display(total_points, adjmat));
    glutMainLoop();
    return EXIT_SUCCESS;
}

我在出现错误glutDisplayFunc()invalid use of void expression我需要传递一些参数display()以获取所需的输出。

我怎样才能解决这个问题?

棘轮怪胎

不要将它们作为参数传递,而是将它们作为全局变量传递,这就是函数不足没有参数的过大的缺点。

long total_points;
vector<vector<long>> adjmat;

void display(){
    //stuff here
    glVertex2f(n1,n2);
    glVertex2f(n3,n4);
}

int main(int argc, char *argv[]){
    //stuff here
    //fill and assign total_points, adjmat
    glutDisplayFunc(display);
    glutMainLoop();
    return EXIT_SUCCESS;
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章