如何创建一个PopUp菜单来调整OpenGL中的灯光设置

时间:2018-04-08 12:25:44

标签: c++ opengl popupmenu

我可以创建一个PopUp菜单来使用SDL在OpenGL中更改或修改我的灯光属性吗?

我正在尝试使用glutCreateMenu();

void mydisplay()
{
    //glClear(GL_COLOR_BUFFER_BIT);
    GLfloat tp_ambient[] = { 0.05,0.05,0.05,1 };
    GLfloat tp_diffuse[] = { 0.7,0.3,1,1 };
    GLfloat tp_specular[] = { 0.6,0.6,0.6,1 };
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, tp_ambient);
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, tp_diffuse);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, tp_specular);
    glPushMatrix();
    glTranslatef(0.0f, 0.0f, -0.6f);
    GLUquadricObj *quadric = gluNewQuadric();
    gluSphere(quadric, 0.1, 16, 16);
    gluDeleteQuadric(quadric);

    glPopMatrix();
    /*
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(0.0f, 0.0f, -0.1f);*/

    glutCreateMenu(ProcessMenu);
    glutAddMenuEntry("position change", 0);
    glutAttachMenu(GLUT_RIGHT_BUTTON);

}
void ProcessMenu(int value) {
    if (value == 0) {
        GLfloat ambient[] = { 0.1,0.1,0.1,1 };
    }
    glutPostRedisplay();
}

但是我收到了这个错误:

  

错误C2065'ProcessMenu':未声明的标识符

我应该设置什么?
我是否使用正确的方法来构建PopUp菜单? 如果查看我的所有编码很有用,请查看我的previous, solved question

0 个答案:

没有答案