[osg-users] OpenGL

Alberto Luaces aluaces at udc.es
Wed Jul 5 08:53:25 PDT 2017

"Mottaghi, Arman" writes:

> Hi all,
> I have a general question. I’ve googled this before, but I haven’t had
> any luck. I am new to programming world, so I decided to give it a
> shot on this forum/mailing list.
> I have a program written in C++ and it uses OSG and OpenGL for its
> visual graphics. I have a simple GUI code in Python that says “Hello
> my friend” on the left side and I’d like to have my OSG program on the
> right side.
> Is this possible? The thing I am confused about is whether Python is
> capable of displaying my C++/OSG program or not. Basically, imagine my
> main program has some buttons, texts, menus, and a graphic OSG part
> inside it—let’s say as a small window.  The best outcome would only
> display that OSG window. I am not interested in displaying the entire
> program in my python GUI window. Would that be possible? I don’t care
> if I have to run the program alongside my python program or if I can
> embed my main program or at least part of it in my python. Again, I’ve
> never done programming before, so sorry for my bad description.

Hi Arman,

indeed is a very open question: both Python and C++ —actually almost any
general purpose languages— are able to open console (text), graphics or
GUI windows on their own.

The lowest effort path could be letting each part of the program open
their own window and then use the window manager to arrange them in a
tiling fashion, side by side.

Other more complex solution would be to open a 3D context in the Python
GUI, and call the C++ routines from Python in other to update it.  In
the examples section of OSG you can find programs that embed 3D windows
inside GUIs, but as far as I recall, none of them with a mixed language
strategy.  Nevertheless, that is not the difficult part, since there are
many projects that can help you with the task of interfacing Python and
C++: SWIG, Boost.Python, pybind11, Python ctypes...


More information about the osg-users mailing list