使用 glui 菜单栏

发布于 2024-10-15 06:15:09 字数 2463 浏览 1 评论 0原文

我是 glui 的新手。我无法创建 glui 菜单栏。每当我创建 glui 菜单栏时,我都会收到以下错误:

1.cpp:13: error: expected constructor, destructor, or type conversion before ‘*’ token
1.cpp: In function ‘void controlcallback(int)’:
1.cpp:42: error: ‘m’ was not declared in this scope
1.cpp:42: error: expected type-specifier before ‘GLUI_MenuBar’
1.cpp:42: error: expected `;' before ‘GLUI_MenuBar’

来源:

int main_window;
GLUI *w1;
GLUI_Listbox *l1;
GLUI_Button *b1,*b2,*b3,*b4,*b5,*b6,*b7,*b8;
GLUI_Panel *p1,*p2;
enum GLUI_MenuBar *m1;

int id;

void init()
{
    glClearColor(0,1,1,0);
}

void display()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glFlush();
    glutPostRedisplay();
}

void reshape (int w, int h)
{ 
    GLUI_Master.auto_set_viewport(); 
}

 void  controlcallback( int val)
{ 

    if( val == 1) {
        w1->set_main_gfx_window(main_window);
        m=new GLUI_MenuBar(p1);
    } else {
        w1->set_main_gfx_window(main_window);
    }
}

int main(int a, char **b)
{
    glutInit(&a,b);
    glutInitWindowSize(3000,3000);
    glutInitWindowPosition(0,0);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);

    main_window = glutCreateWindow("  practice");
    init();
    glutDisplayFunc(display);


    GLUI_Master.set_glutReshapeFunc(reshape);
    w1=GLUI_Master.create_glui_subwindow(main_window,GLUI_SUBWINDOW_TOP);
    id=w1->get_glut_window_id();
    p1=w1->add_panel("",GLUI_PANEL_RAISED);
    b1=w1->add_button_to_panel(p1,"navigator",1,controlcallback);
    w1->add_column_to_panel(p1,true);
    b2=w1->add_button_to_panel(p1,"naigator",2,controlcallback);
    w1->add_column_to_panel(p1,true);
    b3=w1->add_button_to_panel(p1,"navigator",3,controlcallback);
    w1->add_column_to_panel(p1,true);
    b4=w1->add_button_to_panel(p1,"naigator",4,controlcallback);
    w1->add_column_to_panel(p1,true);
    b5=w1->add_button_to_panel(p1,"navigator",5,controlcallback);
    w1->add_column_to_panel(p1,true);
    b6=w1->add_button_to_panel(p1,"naigator",6,controlcallback);
    w1->add_column_to_panel(p1,true);
    b7=w1->add_button_to_panel(p1,"navigator",7,controlcallback);
    w1->add_column_to_panel(p1,true);
    b8=w1->add_button_to_panel(p1,"naigator",8,controlcallback);
    w1->add_column_to_panel(p1,true);
    GLUI_MenuBar *m1 = new GLUI_MenuBar(id,GLUI_SUBWINDOW_TOP);

    w1->set_main_gfx_window(main_window);
    glutMainLoop();
}

I am new to glui. I am not able to create glui menubar. Whenever I create a glui menubar I get following errors:

1.cpp:13: error: expected constructor, destructor, or type conversion before ‘*’ token
1.cpp: In function ‘void controlcallback(int)’:
1.cpp:42: error: ‘m’ was not declared in this scope
1.cpp:42: error: expected type-specifier before ‘GLUI_MenuBar’
1.cpp:42: error: expected `;' before ‘GLUI_MenuBar’

source:

int main_window;
GLUI *w1;
GLUI_Listbox *l1;
GLUI_Button *b1,*b2,*b3,*b4,*b5,*b6,*b7,*b8;
GLUI_Panel *p1,*p2;
enum GLUI_MenuBar *m1;

int id;

void init()
{
    glClearColor(0,1,1,0);
}

void display()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glFlush();
    glutPostRedisplay();
}

void reshape (int w, int h)
{ 
    GLUI_Master.auto_set_viewport(); 
}

 void  controlcallback( int val)
{ 

    if( val == 1) {
        w1->set_main_gfx_window(main_window);
        m=new GLUI_MenuBar(p1);
    } else {
        w1->set_main_gfx_window(main_window);
    }
}

int main(int a, char **b)
{
    glutInit(&a,b);
    glutInitWindowSize(3000,3000);
    glutInitWindowPosition(0,0);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);

    main_window = glutCreateWindow("  practice");
    init();
    glutDisplayFunc(display);


    GLUI_Master.set_glutReshapeFunc(reshape);
    w1=GLUI_Master.create_glui_subwindow(main_window,GLUI_SUBWINDOW_TOP);
    id=w1->get_glut_window_id();
    p1=w1->add_panel("",GLUI_PANEL_RAISED);
    b1=w1->add_button_to_panel(p1,"navigator",1,controlcallback);
    w1->add_column_to_panel(p1,true);
    b2=w1->add_button_to_panel(p1,"naigator",2,controlcallback);
    w1->add_column_to_panel(p1,true);
    b3=w1->add_button_to_panel(p1,"navigator",3,controlcallback);
    w1->add_column_to_panel(p1,true);
    b4=w1->add_button_to_panel(p1,"naigator",4,controlcallback);
    w1->add_column_to_panel(p1,true);
    b5=w1->add_button_to_panel(p1,"navigator",5,controlcallback);
    w1->add_column_to_panel(p1,true);
    b6=w1->add_button_to_panel(p1,"naigator",6,controlcallback);
    w1->add_column_to_panel(p1,true);
    b7=w1->add_button_to_panel(p1,"navigator",7,controlcallback);
    w1->add_column_to_panel(p1,true);
    b8=w1->add_button_to_panel(p1,"naigator",8,controlcallback);
    w1->add_column_to_panel(p1,true);
    GLUI_MenuBar *m1 = new GLUI_MenuBar(id,GLUI_SUBWINDOW_TOP);

    w1->set_main_gfx_window(main_window);
    glutMainLoop();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深白境迁sunset 2024-10-22 06:15:09

好吧,该错误与编译器报告的完全一样 1.cpp:42: error: 'm' was not returned in this scope 因为 m 实际上没有在任何地方声明。

另一个错误 1.cpp:13: error: Expected constructor, destructor, or type conversion before '*' token 听起来像是您忘记为 GLUI_Listbox 包含一些 glui 标头。

顺便说一句,您正在使用 GLUI_MenuBar *m1 = new GLUI_MenuBar(id,GLUI_SUBWINDOW_TOP); 隐藏全局变量 m1

Well, the error is exactly as reported by the compiler 1.cpp:42: error: ‘m’ was not declared in this scope as m is really not declared anywhere.

The other error 1.cpp:13: error: expected constructor, destructor, or type conversion before ‘*’ token sound like you forgot to include some glui header for GLUI_Listbox.

BTW, you are shadowing the global variable m1 with GLUI_MenuBar *m1 = new GLUI_MenuBar(id,GLUI_SUBWINDOW_TOP);.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文