View Full Version : What is a callback routine? :-(
08-01-2003, 11:20 AM
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?
08-01-2003, 11:51 AM
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.
08-04-2003, 02:54 AM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.