Qt C++ MMORPG

Started by
17 comments, last by DZee 11 years, 9 months ago
I want to use qt because of it network classes and its portability.
Advertisement

One step in the right direction may be to rethink the decision to use Qt for your game. I'm a Qt user myself, and am currently using it on my game - but my game is a 2D RPG where performance isn't critical.
Qt isn't really designed with games in mind, and as such, has some performance issues that pop up at unpredictable times - in particular I'm thinking about a blog post I read recently, where someone was making a Minecraft clone using OpenGL and Qt, and showed performance measurements for his game where Qt was eating the lion's share of it.
If that's the post I'm thinking of, it was specifically only to do with using the Qt GUI, overlayed with the graphics scene.

It's still perfectly fine to use Qt as an API for game development on a similar level to say SDL and SFML. Qt provides far more than a GUI - it provides windowing, input, sound, 2D graphics (or 3D via OpenGL/D3D, like with SDL), networking, SMP and so on, all the things you'd want in a cross-platform game API.

The key thing that's an issue for performance is if you want to have a GUI rendered as part of your scene, on the GPU. But say SDL doesn't provide any support for that whatsoever, but that's not a reason to not use SDL. As always, you either have to roll your own, or get a game UI toolkit that's built specifically for that job. (OOI, is there an open source cross-platform toolkit that does provide all the low level things like windowing, input, sound, networking, *and* a fast GUI toolkit as well?)

(This is a few times I've seen references to that blog post now - I fear it's starting a "Qt can't be used for games" myth, which completely misses the point of what Qt can provide, and what that blog post was measuring. Even without fast OpenGL/D3D based GUI, Qt still provides plenty for game development, and does just as well as the likes of SDL IMO.)

Now yes, Qt is perhaps most well known for its GUI engine and it perhaps seems a waste to not use that at all - but if we've decided that the GUI shouldn't be used, that doesn't mean there's nothing left to offer when it comes to low level game APIs like SDL etc. I'm not saying Qt is necessarily better than SDL, but they're both viable choices. Also a well written game/engine shouldn't necessarily be restricted to one or the other, and it shouldn't be the constraining choice in developing a game - I have a game that uses SDL for Windows/Linux/OS X, but I added Qt support for Symbian and Android (on Android, the Qt port seems better supported and easier to use than SDL or anything else I could find for C++). Nothing in my game code has signals/slots forced upon it, apart from a small amount of Qt specific code.

I'm also using it in a game where I use the Qt GUI elements in separate windows (and RPG, where the UI surrounds the main game window), and so I'm not sure if the performance criticisms apply there(?) since the GUI won't be rendered every frame.

Also Qt kinda enforces it's own programming paradigm on you, forcing you to use signals and slots whether you want to or not, and takes complete control of the main loop of the application.[/quote]Signals and slots are great things, though yes it does mean you aren't writing "pure" C++. Though as I say, you don't have to use signals and slots everywhere, only where your game/engine interfaces with the Qt API.

The latter is a good thing, particularly for mobile development (it means the programmer doesn't have to be trusted when it comes to things like sleeping, not wasting battery life on unnecessary CPU and so on). E.g., you don't get a main loop in Android at all - see http://stackoverflow.com/questions/1099640/main-loop-in-android .

http://erebusrpg.sourceforge.net/ - Erebus, Open Source RPG for Windows/Linux/Android
http://conquests.sourceforge.net/ - Conquests, Open Source Civ-like Game for Windows/Linux

double post

http://erebusrpg.sourceforge.net/ - Erebus, Open Source RPG for Windows/Linux/Android
http://conquests.sourceforge.net/ - Conquests, Open Source Civ-like Game for Windows/Linux


I am starting making a mmorpg game using qt and c++ does if anyone can point my in the right direction such as books, tutorials, website anything to help me get started.


As it happens I am almost a certified QT programmer. I've had an in-depth course of one year by an expert. I don't know if you want your game to be in 3D then you have to check out the QtOpenGL module, from that point on you have an OpenGL context. If you want the mmo to be 2D the QGraphicsView and the Animation State Machine are a solid option.

The QGraphicsScene implements a search tree that let's you easily handle millions of drawn elements on screen.

http://qt-project.or...phicsScene.html

Essentially, you have a QGraphicsScene, a QGraphicsView and then add items that inherit QGraphicsItem for custom behavior. This is mostly for a 2D game. Otherwise I'd go with OpenGL.

Keep in mind that QT isn't an engine, it doesn't provide game-peculiar tools to help you in your development. If you are feeling adventurous, Qt Quick can be worth it. It has a similar writting style to javascript and CSS, yet you can write C++ backend for intensive tasks if you wish.

QT has very, very good documentation, I doubt you really need any book at all. Here's the page with examples, there's a tetris and an asteroid game in there:

http://doc.qt.nokia....l-examples.html

There's a QT Dev who wrote a game down where you shoot things down on a boat using a cannon. That's it.

[size=1]I "surf" the web, literally.

Its a 3d game so i want to use opengl

I want to use qt because of it network classes and its portability.


The network code from one game is the most easiest part of its development. If the game's architecture is well written it can take a day or two to make "the multiplayer mode".
Nothing more to say. Call me when you finish it, but with this SDK priorities it won't be soon smile.png
My opinion, no offence. However, good luck!
(This is a few times I've seen references to that blog post now - I fear it's starting a "Qt can't be used for games" myth, which completely misses the point of what Qt can provide, and what that blog post was measuring. Even without fast OpenGL/D3D based GUI, Qt still provides plenty for game development, and does just as well as the likes of SDL IMO.)
Other people have been burned by using Qt in their games too, it's not as if that person who blogged about it was the only one.

Nobody is saying that it "can't" be used for games, but rather that there are important issues to weight into consideration.
As it happens I am almost a certified QT programmer. I've had an in-depth course of one year by an expert.
How much of this course was related to game programming? Don't get me wrong, Qt is pretty good at what it is designed for, just in my experience Qt has been a bad choice for games.
Stop twiddling your bits and use them already!

[quote name='Servant of the Lord' timestamp='1342483067' post='4959811']
One step in the right direction may be to rethink the decision to use Qt for your game. I'm a Qt user myself, and am currently using it on my game - but my game is a 2D RPG where performance isn't critical.
Qt isn't really designed with games in mind, and as such, has some performance issues that pop up at unpredictable times - in particular I'm thinking about a blog post I read recently, where someone was making a Minecraft clone using OpenGL and Qt, and showed performance measurements for his game where Qt was eating the lion's share of it.
If that's the post I'm thinking of, it was specifically only to do with using the Qt GUI, overlayed with the graphics scene.[/quote]
Yes, I meant the GUI in particular. Here's the post.

It's still perfectly fine to use Qt as an API for game development on a similar level to say SDL and SFML. Qt provides far more than a GUI - it provides windowing, input, sound, 2D graphics (or 3D via OpenGL/D3D, like with SDL), networking, SMP and so on, all the things you'd want in a cross-platform game API.[/quote]

You're absolutely right. For myself personally, one of the main draws of Qt is the GUI, so I do tend to think of Qt as a 'GUI' toolkit, even though I have made use of many other parts of its extensive libraries. It is definitely more than just GUI, as you said.

As I mentioned earlier, my own game project uses Qt for the editor, and the editor is built into the game itself (Qt-controlled SFML window for the game, and Qt-controlled Qt widgets all around the sides). For my 2D RPG, the performance costs aren't a hindrance. The signals and slots, which are nice for desktop applications, don't sit too well with me for game messenging, but that's probably from a lack of experience with them.

Qt is definitely very useful! Especially when it comes to desktop applications. I should rephrase my criticism to the OP as:
"If you are using Qt for a GUI in your 3D MMORPG (if your MMO is 3D), then you ought to be aware of possible performance hogging by Qt's widget system. However, Qt is open source, so you can alter it to fit your needs, or just not use the GUI part of Qt - Qt has much more than just widgets that may benefit your project."

Better? smile.png

I appreciate the correction, Qt is an awesome set of libraries! I only meant to make sure the OP weighs the pros and cons (of the Qt widget system) for his particular project, not dissuade him from all Qt use, or even from all Qt for games use - so thank you for making me clarify my statements. wink.png

[quote name='DZee' timestamp='1342540656' post='4960039']As it happens I am almost a certified QT programmer. I've had an in-depth course of one year by an expert.
How much of this course was related to game programming? Don't get me wrong, Qt is pretty good at what it is designed for, just in my experience Qt has been a bad choice for games.
[/quote]

Well, since QT was originally a wrapper to make writing cross-platform C++ code there was never an intention to write native classes with gaming in mind. My course mostly went trough the different layers of the QT hierarchy starting from QtCore to QtGui all the way to phonon and multi-threading etc. There was too much ground to cover to have anything to do with games. I'd say that QT works well for games that rely heavily on graphical interfaces. I wrote a Sudoku and it took around 1 hour to style it with QSS in Qt Designer. So in that regard it's interesting.

Personally QT has an interesting approach in the sense that you are forced to use an MVC-like structure with each entity being a graphical item with a set position in space(Already done for you in 2D) which eases understanding of the code. I've worked at a company that remade the interface of a flight simulator with graphs in QT and it handled it very well with at least 1000 classes. My only gripe with QT is that the moc it generates for it's signal/slot mechanism and custom slang can sometimes cause headaches during compilation time.

If I were to write a desktop application with a GUI Qt would be a definite choice. It's up-to-date and the documentation is stellar. Also, projects with a large scope of different tasks would leverage the library well. If your goal is to use QT by spawning a window with a blank canvas to draw space ships and stuff then it's crap. You're gonna include half the world for something other more straight-forward libraries can do for you.

Here's an interesting page that shows what people have done with QT, ranges from small and big projects:

http://qt.nokia.com/qt-in-use

So to sum it up, you can very well use QT for your game. It provides touch support too. So I suppose making games for some embedded devices could be interesting.

[size=1]I "surf" the web, literally.

This topic is closed to new replies.

Advertisement