【发布时间】:2012-04-18 08:34:38
【问题描述】:
我正在通过 glut 库学习 OpenGL。问题是当程序增长时,有很多global variables 需要处理。正如很多人所说,在程序中使用过多的global variables 是不妥的。但是,我不能通过将用户定义的参数传递给 glut 定义的回调函数来替代global variables。例如:
void display (void)
{
// How to pass user defined parameters here?
// some more code
}
int
main(void)
{
glutDisplayFunc(display);
// some more code
}
所以我的问题是这样的:
- 使用 glut 编写 OpenGL 时如何处理全局变量?
- 有没有其他方法可以替换全局变量而不是将参数传递给函数
- 其他处理 OpenGL 输入/输出的库(不是 glut)如何处理全局变量?
【问题讨论】:
标签: opengl global-variables glut