PDA

View Full Version : glutIdleFunc



01-11-2004, 10:01 AM
I am using glut wrapped up in my own c++ classes. I need glut to do graphics and microsoft's speech development kit to do text to speech to create a talking face. I am trying to use glutIdleFunc() to tell glut that while it isn't doind graphics it should be processing the speech function which produces synchonisation for the graphics. however i always get compilation errors when trying to pass a function to glutIdleFunc. it says i need the function in the form void (__cdecl *)(void) which i cannot achieve no matter whether i pass a pointer to the funtion, the function name when its in the same file, different file, same class, different class, friend class etc! What does this mean and how could I get any function to assume this form? Is it wrong to put this much work into the glutIdleFunc and if so what way should I be doing it?

I have all the speech code working properly but need help synchronizing it with some graphics of some kind...anyone fancy having a look at code as well?!

Thanks

nexusone
01-11-2004, 10:08 AM
the proper use is glutIdleFunc( name_function_to_call )

example:

glutIdleFunc( My_Idle_routine );


void My_Idle_routine( void )
{
// Stuff to do when idle

}

Hope this helps!

01-11-2004, 10:28 AM
that is how i've been trying to use glutIdleFunc but it doesnt compile saying my funtions need to be in the form that I put in my first posting. and the function i'm using is definately void return and void paramaters!?

01-11-2004, 11:10 AM
ok what I really need to know is what does this error mean...

error C2664: 'glutIdleFunc' : cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(void)' None of the functions with this name in scope match the target type

the function I am trying to use is simply void anyName (void) and i pass it to glutIdleFunc(anyName);

so whats all the (__cdecl *) stuff?

nexusone
01-11-2004, 05:43 PM
How about posting the glutidlefunc part of your code.

Also glut is written in C, so that maybe some error due to maybe trying to pass a C++ argument to a C type object, just guessing here.



Originally posted by Mr. JT:
that is how i've been trying to use glutIdleFunc but it doesnt compile saying my funtions need to be in the form that I put in my first posting. and the function i'm using is definately void return and void paramaters!?

mikael_aronsson
01-12-2004, 04:51 AM
It means that your function is using the wrong calling convention,

If you change it to something like:

void __cdecl your_idle_func()
{
}

It should compile.

Mikael

01-12-2004, 06:21 AM
Adding a _cdecl to the function declaration/instantiation doesnt seem to help, despite being a recognised keyword I still get the same error. Also for the other reply...it doesnt matter what the idle function is...it could simple contain a cout << "Hello"; but it wont compile. It doesnt work with class member functions but it does work with global functions which dont belong to a class. Is there any way to use c++ class functions as arguments to glutIdleFunc (or any other glut call back function?) Seems strange that it could only use globals when I've made sure that glut has access to all the classes functions!?