PDA

View Full Version : Qt as guest dll to act as GUI for existing OpenGL engine.



travick
3rd March 2013, 01:45
Hi,

I'm trying to figure out how connect Qt with existing application as a GUI component.
This application loads dll, and in this dll I can do whatever I want, there is function "update" called in main thread of application.

As far I created a QLabel, and it shows as separate window but my goal is to paint some GUI on top of game scene rendered by the engine. I'm going to use QtQuick for GUI.

Unfortunately, every sample assumes that Qt is main application that runs the whole world including OpenGL. I can't find any sample of embedding Qt in existing 3rd party opengl application.

Has any one faced use case like this?

wysota
3rd March 2013, 15:35
What is the 3rd party application using for showing a GL window?

travick
3rd March 2013, 16:33
Barok Engine: http://barokengine.com/

wysota
3rd March 2013, 17:03
How does it render the scene?

travick
3rd March 2013, 17:58
What do you mean?
It creates everything it need to work and final result is rendered with OpenGL.

You are able to create and load your own library (dll) to operate with that engine. For eg. CEGUI (placed in this dll) works with that engine, bu I want to use Qt if possible.

wysota
3rd March 2013, 18:23
What do you mean?
It creates everything it need to work and final result is rendered with OpenGL.
I'm asking you to analyze what it creates and how the final result is rendered.

In general it makes more sense to make Qt the primary event handler (a.k.a. the main framework) and make the game engine render into something that can be used with Qt (preferably into an FBO or into a current OpenGL context Qt may provide). Otherwise you end up with a need to forward all input events to Qt with the need of mapping it from the game's coordinate space into the UI coordinate space. Furthermore if you want to have an animating UI, you'd need to tap into some low-level event handling in Qt to be able to render each frame of the UI into something you can display with your game engine. It's much easier to do it the other way if the engine itself doesn't provide enough infrastructure to make it easier.

travick
3rd March 2013, 18:46
I'm asking you to analyze what it creates and how the final result is rendered.
Still don't know what you mean. It uses OpenGL what more do you need to know? Write more details or an example here.

As far as I imagine the situation the main problem is to tell Qt to use an existing OpenGL context instead of creating new one but at this point I could be wrong. What's more I didn't find any example, tutorial, explanation, documentation for similar case.

P.S. Replay with quote doesn't work: after sending a post it redirects to "reply to thread" and what you've wrote is gone... (or it works randomly for me)

wysota
3rd March 2013, 18:57
It uses OpenGL what more do you need to know?
How it uses OpenGL.


Write more details or an example here.
OpenGL is just a language of programming a graphics rendering pipeline. It does not deal with windows, keyboard or mouse input, etc. All this has to be provided by an external mechanism, such as GLUT, Qt, WinAPI or a few dozen different frameworks. You need to find out how this particular framework works, how it handles events, what its display architecture looks like, etc. There is no magical "merge two totally different frameworks together" approach you can take.


As far as I imagine the situation the main problem is to tell Qt to use an existing OpenGL context
No, it's not that big of a deal and it's more than trivial in Qt5. But it won't allow you to implement a UI since you need access to key and mouse events. If Qt's event loop is not running, you have to periodically trigger it by hand and you have post input events to the event loop yourself instead of relying on Qt's platform integration to do it for you. If you have access to all the data in your game engine then you can even make a custom platform plugin for your game engine and have the UI render using your platform plugin. But first you need to get all the data from your game engine.


P.S. Replay with quote doesn't work: after sending a post it redirects to "reply to thread" and what you've wrote is gone... (or it works randomly for me)
You're pushing the wrong button. Push "Post Quick Reply" instead of "Reply to Thread".