Re: multithreaded strategy boardgame



Adrien Treuille wrote:
> 
> Hi all,
Hi Adrien,

> 
> 1 - Is there a way of finding out the width and height of a GdkPixmap?
> ...
	I don't know if this really works, but since GdkPixmap and GdkWindow
are mostly the same thing, you should be able to cast it into a
GdkWindow and use gdk_window_get_size. Looks like a weird thing, but it
might work.

> 2 - How would one implement multithreading in gtk? (I'm a java programmer,
> and new to threads in c/linux.) One solution seems to be LinuxThreads
> (i.e. #include <pthreads.h>), and another seems to be gdk threads... Are
> these two the same or not? If not which one would you recommend? Perhaps
> something else? I'd like to be able to accomplish interthread
> communication without using global variables. Also, where can I find good
> sample code to learn how to do all this stuff.
	GLib threads are actually wrappers for the pthreads in a Linux (Posix)
box, so if you don't care about portability to other Unices or Windows,
there isn't a huge difference, just a somewhat nicer looking api.
	About how to implement this, only the main thread should do gui stuff,
you should call g_threads_init, and in case you are going to do gui
stuff from various threads (that would be bad desing, but sometimes it
is unavoidable), wrap your g[d/t]k calls with gdk_threads_enter,
gdk_threads_leave.
	There are hundreds of programs that use pthreads, and dozens using the
gthread implementation. Just check them.
	Check also the GLib docs from the gnome site, they are a very valuable
source of info, and you will need them anyway when developing with GTK+.
Read the Gtk+ faq and the Tutorials too.

Iñaki




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