views:

119

answers:

1

Hello, I need to implement my own main event loop in C++ which will be based on GLib library. I don't know where to begin. I studied some materials about GLib, but it doesn't help me to know, how implement event loop. Could somebody give me some advise about it or give me some source code? I basically need to implement GSource and GSourceFuncs from GLib. Event loop should be platform independent, but my application will be run on Android. I can't find how event loop is implemented in Android, could somebody explain it to me too? Thanks a lot.

Lukas

A: 

This sounds like a difficult project. You should probably start by studying the glib source code. Most main loops are similar: your program turns over control to them, and they call functions ("callbacks" or "event handlers" in your program when certain events occur.

Do you need to write a glib-based main loop that will integrate with the Android main loop? Why C++? Are you planning to compile it with the Android NDK? It would be easier to answer your question if you were able to give more information.

ptomato
I'm starting porting existing C++ application to Android. Therefore I need to implement my own event loop in C++. I will compile the code with Crystax NDK with full C++ library. I need receiving user actions and other events in C++ code.
Lukas
I have another question: Where to find how event loop is implemented on Android? Is there any documentation or I need to browse the source code? Thanks.
Lukas
@Lukas, I don't know about the Android main loop. I would suggest the Android API documentation or perhaps an Android book. However, I think that it would probably be easier to port your GUI code to Android's main loop and then use an NDK-compiled library for the back end of your application, whatever it is.
ptomato
I'd like to know, how the main event loop is implemented in Androidsource code, because I need to implement my own event loop in C++ andAndroid implementation could be useful for me to help with C++implementation.
Lukas