Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt library for 2D/3D game development

Tags:

c++

qt

As a hobby, I've been working on remaking an old video game, and I want to avoid reinventing the wheel where possible. The game is heavily GUI-based, but the GUI needs to be customized in terms of look-and-feel, and also needs to work with 3D OpenGL rendering for a few game screens.

To give you an idea, here's a screenshot from the initial prototype:

enter image description here

There's a lot of animation used, and 3D also, but the GUI widgets behave much the same as in a standard desktop application.

Thus far, I've been using my own GUI library (it's not robust or complete, and I've been running into some problems).

I've been considering migrating to Qt given it's reputation and impressive features, and some of the nice screenshots on the Qt website. But I've never used Qt before, so I don't really have an idea of what it's capable of, or what kind of time investment would be required to learn it. (Note I've used FLTK).

My question is: would it be possible / practical to use Qt in this situation?

UPDATE: After mocking up some game screens in Qt, I've decided not to use it. While it supports many of the features I need out-of-the-box (particularly through Style Sheets), I need to support custom bitmap-based pre-rendered fonts (I can't convert/replace them). And I can't subclass QFont, or reimplement it without it breaking in future Qt releases. That said, I was extremely impressed with Qt (both in its ease of use, and good documentation). I will be borrowing some of its features for my own engine. Thank you to all who provided input.

like image 931
Daniel Hanrahan Avatar asked Jun 04 '12 09:06

Daniel Hanrahan


2 Answers

It's hard to know everything your game needs to do based on a screenshot; however, I will echo the sentiments of other posters here and provide a couple of avenues for you to look at.

One, is that you might want to consider QtQuick over the GraphicsView Framework, but this REALLY depends on what you need to do. I just want to throw it out there as an alternative so you don't miss it. This tutorial uses QtQuick to put together a really slick looking connect four style game. This may be more simplistic than what you want to go for, but then again, maybe it isn't, it depends on what you need to do.

Second, before writing custom paint events for all of your buttons, I would consider using Qt Style Sheets and style your widgets in a CSS like syntax. This will allow you to change the look and feel of your GUI in a very flexible way really quickly. Based on your screenshot, I think you can get what you want out of style sheets much faster than subclassing and rolling your own setup. But once again, it's hard to know based on one screenshot. Here's an example of a dark and orange GUI that was implemented using only Qt Style Sheets. The border-radius property of QPushButton's style sheet would give you the rounded buttons (ref).

like image 193
Eli Hooten Avatar answered Oct 02 '22 10:10

Eli Hooten


The simple answer has been given above but to throw some more thoughts in: yes it's possible, you probably won't need to fight against Qt too much. For the most part the recommended advice for going to heavily customised widgets like that is subclass and implemented the paint event yourself.

You can then use a load of basic drawing primitives to get the basic shapes for the elements and expand from there. There's actually a couple of questions on here with really good resources about how to do it.

like image 37
Nicholas Smith Avatar answered Oct 02 '22 11:10

Nicholas Smith