Definition: A callback is a function or routine that is passed as an argument to another function, to be invoked automatically in response to an event.
Purpose in HCI/Graphics:
How it works:
onMouseClick).Example in OpenGL/GLUT (C):
void onMouseClick(int button, int state, int x, int y) {
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
printf("Mouse clicked at (%d, %d)\n", x, y);
}
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutCreateWindow("Callback Example");
glutMouseFunc(onMouseClick); // Register callback
glutMainLoop();
}
Advantages:
Definition: Picking is the process of selecting graphical objects (points, lines, polygons) using an input device like a mouse, stylus, or touch.
Purpose:
How Picking Works:
Picking Methods:
Color-based Picking:
Geometry-based Picking:
OpenGL Selection Mode (Deprecated but still relevant conceptually):
Example Scenario:
Picking often relies on callbacks.
For example:
onMouseClick).Workflow Diagram (Conceptual):
User clicks → Mouse callback invoked → Picking routine checks objects → Object selected → Action performed
Open this section to load past papers