如何一起使用Qt和SDL? [英] How do I use Qt and SDL together?

查看:481
本文介绍了如何一起使用Qt和SDL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows中构建物理仿真引擎和编辑器。我想使用Qt构建编辑器部分,我想使用SDL与OpenGL运行引擎。

I am building a physics simulation engine and editor in Windows. I want to build the editor part using Qt and I want to run the engine using SDL with OpenGL.

我的第一个想法是构建编辑器只使用Qt和共享许多代码与引擎(资源管理器,渲染器,数学)。但是,我也希望能够在编辑器中运行模拟。 这意味着我还必须共享使用SDL线程的模拟代码。

My first idea was to build the editor using only Qt and share as much code with the engine (the resource manager, the renderer, the maths). But, I would also like to be able to run the simulation inside the editor. This means I also have to share the simulation code which uses SDL threads.

所以,我的问题是这样:使用SDL将OpenGL渲染到Qt窗口?

So, my question is this: Is there a way to have an the render OpenGL to a Qt window by using SDL?

我在网上看过,可能为SDL提供一个窗口句柄来呈现。任何人都有经验的东西?

I have read on the web that it might be possible to supply SDL with a window handle in which to render. Anybody has experience dong that?

此外,模拟器的线程部分可能会造成一个问题,因为它使用SDL线程。

Also, the threaded part of the simulator might pose a problem since it uses SDL threads.

推荐答案

虽然你可能得到它的工作像第一个答案建议你可能会遇到问题,由于线程。没有简单的解决方案,当谈到线程,这里你会有SDL Qt和OpenGL主循环交互。没有乐趣。

While you might get it to work like first answer suggest you will likely run into problems due to threading. There is no simple solutions when it comes to threading, and here you would have SDL Qt and OpenGL mainloop interacting. Not fun.

最简单和最简单的解决方案是将两个部件分离。所以SDL和Qt运行在单独的进程,并让他们使用某种消息通信(我建议d-bus这里)。您可以将SDL渲染为无边框窗口,您的编辑器通过消息发送命令。

The easiest and sanest solution would be to decouple both parts. So that SDL and Qt run in separate processes and have them use some kind of messaging to communicate (I'd recommend d-bus here ). You can have SDL render into borderless window and your editor sends commands via messages.

这篇关于如何一起使用Qt和SDL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆