Re: [gtkmm] How to do call a function once every 'frame'? And some documentation feedback.



On Sat, 09 Nov 2002 14:29:58 +0100
Dirk Gerrits <dirk gerrits homeip net> wrote:

> This little piece of documentation tells you ABSOLUTELY NOTHING that the 
> function signature doesn't tell you.
Yes it does; it even gives you an hint: "you want to use SignalIdle::connect()."
I strongly suggest you re-read the tutorial section on signals.

Yet the classes you mentioned are the wrong approach to this problem. The idle handler is very unreliable and the MainLoop is something quite different.

The right class for your purpose is Glib::signal_timeout()

See http://gtkmm.sourceforge.net/gtkmm2/docs/reference/html/classGlib_1_1SignalTimeout.html
where you can find a quite detailed description on how to use it.
In your case you may probably (I can't know; see below) want something like that:

//---

void myFrameFunc()
{
     DoFrame();
}

int main(int argc, char** argv)
{
	// init stuff for Gtk::Main...
	// [...]

	//call frame function every 1000 milliseconds = 1 second
 	Glib::signal_timeout().connect(SigC::slot(&myFrameFunc), 1000);

	//now run the main loop...
	// [...]

	return 0;
}

//---

> The tutorial is very good IMHO, but it does not tell you everything. 
> That's what the reference documentation is supposed to do, right?
Yes, but you have to connect both of them.
 
> So can anyone who knows gtkmm2 well enough that he doesn't need the 
> reference tell me how I would accomplish my once every 'frame' function?
What's a 'frame' for you? An animated GIF may have 5 frames; Quake3 may have 40 frames on your graphics adapter. Please be more specific.

Leslie



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]