简体   繁体   English

在现有的c ++ Opengl上下文中使用wxPython

[英]Using wxPython with an existing c++ Opengl Context

I can't find how to use wxPython with a preexisting OpenGL context. 我找不到如何在预先存在的OpenGL上下文中使用wxPython。 I know how to use wxPython on its own and create it's own window but is it possible to use the context used by the Windows window? 我知道如何独自使用wxPython并创建自己的窗口,但是可以使用Windows窗口使用的上下文吗?

So, I have an engine written in c++ that uses OpenGL. 因此,我有一个使用OpenGL用c ++编写的引擎。 I'm planning an using python for the ui elements. 我正在计划对ui元素使用python。 I'm going to link python with c++ (this should be no problem) but is it possible to use wxPython in the python part and make it use the OpenGL context from the preexisting window? 我将用c ++链接python(这应该没问题),但是可以在python部分中使用wxPython并使其从预先存在的窗口中使用OpenGL上下文吗?

EDIT: For those who tried it before, would this work? 编辑:对于那些以前尝试过的人, 行得通吗?

Well, either way I think you're going to have to write a custom wxPython class as a wrapper around the game engine GL context. 好吧,无论哪种方式,我认为您都必须编写一个自定义的wxPython类作为游戏引擎GL上下文的包装。

The easy way to structure the program is to use wxPython as the main control. 构造程序的简单方法是使用wxPython作为主要控件。 You create the game engine view from Python, as a Python object, and run the wxPython event loop. 您可以从Python作为Python对象创建游戏引擎视图,然后运行wxPython事件循环。 Every time the custom view updates or idles, it can invoke the C++ game engine code. 每次自定义视图更新或空闲时,它都可以调用C ++游戏引擎代码。

If you have to write a C++ main() for the game engine and use the game engine event loop, it's going to be much harder. 如果您必须为游戏引擎编写C ++ main()并使用游戏引擎事件循环,它将变得更加困难。 wxPython and wxWidgets, like most GUI toolkits, is written assuming it is the main event loop and has full control over events. 像大多数GUI工具包一样,wxPython和wxWidgets是在假定它是主事件循环并完全控制事件的情况下编写的。 You're going to have to figure out how to invoke the wxPython event handler inner loop once per frame. 您将必须弄清楚如何每帧调用一次wxPython事件处理程序内部循环。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM