Re: Wrapping C Libraries callback

new topic     » goto parent     » topic index » view thread      » older message » newer message
Icy_Viking said...
FGAPI void    FGAPIENTRY glutMouseWheelFunc( void (* callback)( int, int, int, int ) ); 

This is the actual C code. I'm sure there is a special way you need to wrap the callback pointer in there.

That translates to (obviously untested, and somewhat based on the first hit I got from google being "void glutMouseWheelFunc(void(*)(int wheel, int direction, int x, int y) callback)")

-- library code: 
constant xglutMouseWheelFunc = define_c_proc(lib,"glutMouseWheelFunc",{C_POINTER}) 
 
procedure glutMouseWheelFunc(atom callback) 
    c_proc(xglutMouseWheelFunc,{callback}) 
end procedure 
 
-- application code: 
function glutMouseWheelFunc_cb(integer wheel, integer direction, integer x, integer y) 
    -- do what your app must do 
end function 
 
glutMouseWheelFunc(call_back(routine_id("glutMouseWheelFunc_cb"))) 

Or at least that would be my first stab.

I think that in C "void(* callback)()" and "void(*)() callback" are actually exactly the same thing, go figure.

Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu