Re: Stupid callback question
Paul Martin wrote:
> The question is, if I'm not using all of the [GLUT] events,
> will I have to set the ones I'm not using to NULL.
Assuming that I'm understanding the question, you have set up something like
this:
if iMsg = EVENT1 then
...
call_proc( HANDLE_EVENT1, {...} )
elsif iMsg = EVENT2 then
...
call_proc( HANDLE_EVENT2, {...} )
elsif iMsg = EVENT3 then
...
call_proc( HANDLE_EVENT3, {...} )
end if
And since your application never uses EVENT3 (for example), how can you make
sure that it doesn't get triggered?
Remember that, unlike most of the Euphoria functions, a routine id value of
zero/NULL is *valid*. I sort of wish that call_proc and routine_id worked
differently than they currently do - especially for cases like this. It
would be *nice* if 0 meant "do nothing" and -1 meant "error, undefined"...
but that's not how it (currently) works.
You probably can't initialize your variables to a "do nothing" routine,
because each no op procedure will have to have the correct number of
arguments associated with it. You might consider initializing all your
variables to -1 and redefining call_proc and call_func to something like
this:
global procedure callProc( integer routineId, sequence args )
if routineId > -1 then
call_proc( routineId, args )
end if
end procedure
global procedure callFunc( integer routineId, sequence args )
if routineId > -1 then
return call_func( routineId, args )
else
return 0
end if
end procedure
Of course, if you are ever expecting something other than a number back from
callFunc, you are in trouble with callFunc, so I typically bite the bullet
and just code it manually:
if HANDLE_EVENT1 > -1 then
call_proc( HANDLE_EVENT1, args )
end if
Hope this helps.
-- David Cuny
|
Not Categorized, Please Help
|
|