简体   繁体   中英

Using wxPython with an existing c++ Opengl Context

I can't find how to use wxPython with a preexisting OpenGL context. 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?

So, I have an engine written in c++ that uses OpenGL. I'm planning an using python for the ui elements. 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?

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.

The easy way to structure the program is to use wxPython as the main control. You create the game engine view from Python, as a Python object, and run the wxPython event loop. Every time the custom view updates or idles, it can invoke the C++ game engine code.

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. wxPython and wxWidgets, like most GUI toolkits, is written assuming it is the main event loop and has full control over events. You're going to have to figure out how to invoke the wxPython event handler inner loop once per frame.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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