PDA

View Full Version : Use of QCoreApplication



moowy
14th May 2007, 20:38
Hi,

I'm writing a game for a project in school and it has to work in multiplayer... I'm not sure of one thing and I would like to hear your opinion. For the graphics part I'm using Irrlicht engine (that part I have almost finished) and for the network part I'm using Qt. I have written the server successfully and it's time for the network part of the game (from the user side of the game).
Here comes the part where I need your help... For long I didn't know which library to use for tcp/ip protocol so I have written the whole game based on Irrlicht engine (and std) library only. I have written a small library (the library is actually not .lib and .dll but simple .cpp and .h meant to be integrated in code) for the user part which contains a lot of signals/slots used for the right occasion and it contains qtcpsocket objects and all the stuff used for communication... and now I have to merge this code with the rest of the code. The problem is that I want to use those signals/slots from the library with my code but I want the game to know as little about qt as possible....

I use irrlichts main event loop so I don't want to use Qt's... For using signals/slots I have to use Q_OBJECT macro. What do you suggest ? Is there a way to use qt as limited as possible (only signals, slots, and not having to extend QObject for every class in game and using QCoreApplication object...) without having to write a .pro file for the whole game (in that case the library would have to be in .lib and .dll form) ??

I hope that I made any sense in this post...

marcel
14th May 2007, 20:48
Using QTcpSocket will not work without a Qt event loop. It an asynchronous object, much like QFtp and QHttp.
The main reason you cannot use it is that QTcpSocket uses internallu a QTimer, which definitely needs an event loop to work.

I suggest writing the network part using platform depending API.


Regards

wysota
14th May 2007, 21:51
Personally I wouldn't use Qt just for its network capabilities (at least unless I needed a portable solution).

moowy
14th May 2007, 23:20
The main thing why I decided to use Qt and irrlicht is because I need something that works on Linux, WIndows and Mac,...

wysota
14th May 2007, 23:32
BSD sockets should work everywhere... I don't know what irrlicht is, but maybe you could get rid of it? :) And seriously you can try to merge those two event loops. Start by reading QAbstractEventDispatcher docs.

moowy
17th May 2007, 02:09
I can't get rid off irrlicht because it is a 3d engine I need to implement my game. I have solved the problem with porting my code into qt code and integrating irrlicht and its device within a QWidget. I fixed the event loops by studying the above link. Tnx for the help.

fullmetalcoder
17th May 2007, 09:27
I can't get rid off irrlicht because it is a 3d engine I need to implement my game. I have solved the problem with porting my code into qt code and integrating irrlicht and its device within a QWidget. I fixed the event loops by studying the above link. Tnx for the help.
Whoaaa! You managed to integrate Irrlicht into a QWidget?:eek: I was wondering if anyone would try this someday... Could you please send me this part of the code? Or tell me when your game will be available and where?

@wysota : Irrlicht (http://irrlicht.sf.net) is a great open source cross-platform 3d engine.

wysota
17th May 2007, 09:47
@wysota : Irrlicht (http://irrlicht.sf.net) is a great open source cross-platform 3d engine.

Yes, I know that now. I made my homework after writing the post.

moowy
18th May 2007, 08:33
My game will be available through berlios ( I think. I will post the link ) probably by the end of the next week. This is a project (made by me and my two schoolmates and it will be completely opensource and later development will be made.

U need something like this code I attached to integrate. This code is from irrlicht's official forum.