What is a callback routine? :-(

Could someone please explain to me what a ‘call back’ routine is? How is it different from a regular function?

Also for Tesselation in OpenGL. I understand that one has to provide the tesselation routines? In that case, how is glu lib helping at all for tesselations?

Thank you,
Luke

Callback routines are functions that you pass to another function, which then calls your passed function through a pointer. That’s because the original function doesn’t know how to handle something, and it’s up to the caller to pass a function to handle it.

GLUT uses callbacks a lot. It knows when to call certain routines, it just doesn’t know what to do in those routines.

Just adding to starman’s explanation. When you press a key, GLUT or any other library would know that an event has ocurred and a procedure should be called to enable the programmer to handle the particular keystroke and make the program respond in a certain way. GLUT knows this and it can call a built in function. But then, how will you make your program respond to keystrokes? So you pass your function’s name to the built-in function (like glutDisplayFunc etc.) which in turn calls your function through the pointer you have passed whenever that event occurs.