PDA

View Full Version : popup menu callback not declared in the scope



true_atlantis
09-03-2005, 01:44 PM
im trying to create a popup menu, but when i try to register the callback for the menu, i get this error...

minicad.cpp: In function ‘void mouse(int, int, int, int)’:
minicad.cpp:43: error: ‘selectObject’ was not declared in this scope

here is my code....

void mouse(int button, int state, int x, int y){
glutCreateMenu(selectObject);
glutAddMenuEntry("Sphere",1);
glutAddMenuEntry("Cube",2);
glutAddMenuEntry("Torus",3);
glutAddMenuEntry("Iconsahedron",4);
glutAddMenuEntry("Octahedron",5);
glutAddMenuEntry("Tetrahedron",6);
glutAddMenuEntry("Dodecahedron",7);
glutAddMenuEntry("Cone",8);
glutAddMenuEntry("Teapot",9);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}

void selectObject(int id){
glutPostRedisplay();
}

memfr0b
09-03-2005, 03:15 PM
Functions are not visible before they are declared. Either move "selectObject" in front of "mouse" or add a prototype:


void selectObject(int);

void mouse(int button, int state, int x, int y) {
...
}

void selectObject(int id) {
...
}