Re: [PyOpenGL-Users] mixing C++ and python w/ opengl
Brought to you by:
mcfletch
From: Dirk R. <dir...@gm...> - 2011-01-26 15:39:38
|
Hi All, On 01/26/2011 08:40 AM, Alejandro Segovia wrote: > > I definitely recommend it. I used Cython to expose the core classes of an > in-house render engine I was developing in C++ to Python code and I can say it > was a breeze. > > All you have to do is write a simple wrapper around your C/C++ code and a pyx > file that will compile your wrapper into a shared object. You can then import > the compiled .so from Python. > > Wrapping C++ was a little more complicated than pure C, as objects had to be > used as opaque types in version 0.12, but now that version 0.13 is out, C++ > support has been vastly improved. > > Once you have your Cython module compiled, you can create an OpenGL window/panel > from Python code and the draw calls in your C/C++ code will automagically work :) to throw another option in the mix: we've done similar things using boost::python. We have a set of core rendering classes that do the slow stuff (iterate through long loops and pass the data to OpenGL) and the UI (PyQT) and OpenGL setups are done in Python. Mixing PyOpenGL and C/C++ is no problem at all and works very well. I haven't used the C++ interface for Cython, but boost::python is very, very easy to use. Just my $.02 Dirk |