我正在尝试在 C++ 中使用 glut 根据我输入到我的主函数中的文件中的信息来创建绘图。
int main (int argc, char** argv) //I think this is all relevant info in main
{
glutDisplayFunc (display);
fstream file = fstream ("Tree.txt");
Tree myTree = Tree(file);
}
static //this is the function I need to draw from but it can't take any parameters
void display(void)
{
}
static void draw_frame(Tree::Node* t) //my draw function needs access to info from my file stream
{
int x = t->xValue; //for example I need to access these variables
int y = t->yValue;
}
我尝试将 Tree* myTree 设为全局变量,但我遇到了更多错误,它会完全停止读取我的文件。如果有人有任何想法,我将不胜感激!