PDA

View Full Version : how to pass arguments to call back functions



jayaprakash
04-02-2009, 02:00 AM
Dear all,
I am using openGL in multithreading application.
In this I am registering one function with glutDisplayFunc() which is usefull for displaying video and here I am accessing global variables. But in my application global variables should not use.
Instead of global variables is it possible to pass the arguments through callback registering to the callback function?

Please give me some ideas.

Thanks & Regards,
Jayaprakash

trinitrotoluene
04-02-2009, 01:55 PM
You can use the singleton (http://en.wikipedia.org/wiki/Singleton_pattern) design pattern. It have the same effect of global variables, but if used correctly, should produce better code to understand.

enunes
04-04-2009, 03:21 AM
Hi,

with standard glut you probably can't.

You can try other toolkits that don't use a callback functions model. SDL would be a good example of that.