G
googlinggoogler
Hi
This should all be pretty standard C stuff, but I'm going to use terms
like mouse callback to communicate what Im tyring to do.
Basically I have my program whirling around in an infinite loop (easy)
waiting for the mouse to be clicked (I dont need help with this) and
depending on user input a variable might define what function I want
(be it line, circle....(again these are my issues)
So I was thinking that I could use something like an array of function
pointers because I can make all the functions exist with the same
function type I suppose, although that could potentially get messy
What I dont know how to do neatly (I could bodge something but im
trying to do this properly) is essentially have something as follows
1) inside loop some case statement where I can set some varible to
state i want to call the line, circle, etc (theres loads of these)
function. (all these functions in some array of function prototypes
somewhere?)
2)pass the number of mouse clicks to wait to some global variable that
can be picked up when I hit the mouse.
3) in same said mouse call back, use the variable set in point 1 to
get some function pointer someplace from some array of function
pointers and then call something like function_circle(int x, int y,
char color, char text) based on what i've set previously...
I can see lots of holes in this and was woundering whether someone
could help me with my ideas?
Regards
David
This should all be pretty standard C stuff, but I'm going to use terms
like mouse callback to communicate what Im tyring to do.
Basically I have my program whirling around in an infinite loop (easy)
waiting for the mouse to be clicked (I dont need help with this) and
depending on user input a variable might define what function I want
(be it line, circle....(again these are my issues)
So I was thinking that I could use something like an array of function
pointers because I can make all the functions exist with the same
function type I suppose, although that could potentially get messy
What I dont know how to do neatly (I could bodge something but im
trying to do this properly) is essentially have something as follows
1) inside loop some case statement where I can set some varible to
state i want to call the line, circle, etc (theres loads of these)
function. (all these functions in some array of function prototypes
somewhere?)
2)pass the number of mouse clicks to wait to some global variable that
can be picked up when I hit the mouse.
3) in same said mouse call back, use the variable set in point 1 to
get some function pointer someplace from some array of function
pointers and then call something like function_circle(int x, int y,
char color, char text) based on what i've set previously...
I can see lots of holes in this and was woundering whether someone
could help me with my ideas?
Regards
David