Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am about to complete my first ever game. I have used Qt for windowing and OpenGL for actual game logic. I am confused about .. things which are related to design so according to FAQ, these kinda questions are valid. So from the past experience, people who are more interested in deciding what others should ask here and what should not, are taken care of.

(1) With Qt, How to go about connecting pieces? The very first thing comes to my mind is ==> create a screen having few images(carttons) on it, start some music loop, give few buttons; and upon button click event, create OpenGL context and handle the control to it.

But I doubt if this is the way it is done. I tried reading few forum posts but some were either not relevant and others were too complex

(2) And about exiting the game. Is it wise to have OpenGL context kept as it is; and upon reply, use that context to restart a game? Or will it be harmful in any way?

I understand that these questions would not have definite answers, but others suggestions, who have experienced and did these things, can definitely help me in going ahead.

share|improve this question
2  
Welcome to the crazy world of game development. –  Shotgun Ninja Mar 28 '13 at 13:36
add comment

closed as not a real question by Nicol Bolas, Trevor Powell, Josh Petrie, Sean Middleditch, Anko Apr 8 '13 at 8:36

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

You need to get some more QT experience and everything will all make sense. What you're trying to do is all very basic QT programming.

There's nothing different from a "regular" QT app pulling up a new window (or show()+raise()) and an OpenGL window is just another QMainWindow with a widget, or whatever you're using.

You don't "hand the control" to the new window, if it's the active window it has control when you raise() it. Your windows are running inside the QT framework, which is entirely event driven, you do not have a "main loop" of your own. Until you get some more QT experience, or you are experienced with other event-driven frameworks you're going to have a hard time designing your code.

The basic structure and flow of a full QT app is that you create a main window for the app itself, this runs the exec() which gets inputs via events from the GUI. Based on those events you then new MyNextWindow and show()+raise() to activate it. That window does its thing with inputs and events, and thus the circle of life is complete.

Since an OpenGL context is tied to a widget in a window you're not controlling that separately, whatever window has that widget controls the lifetime of the context. It's not harmful if you just hide() and show() that window, as far as I know. That's the extent of what QT does with OpenGL for you, everything else you are responsible for in the Paint method.

share|improve this answer
    
thanks for the reply.. you meant Qt in your instead of QT..! and yes you are money about event driven architecture.. I am indeed trying XWindow and Win32 also.. –  Adorn Mar 31 '13 at 20:24
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.