Skip to main content
gamedev.net
🔒 Locked

Python in C++

Started by S-Rave 2 replies 1.3k views
Original Post
S-Rave
S-Rave
In my current project I was thinking of rendering some "cool effect" in the background of my interface while the app is running, and then I reached the conclusion that I should make some kind of scripting language to make that possible. First I was thinking of making my own, with very limited functions, but it seemed better to use some existing scripting language, and since I've used python before it seemed best to use that. So I was wondering on how I can use python to render opengl when using c++ for everything else? Can I use boost.python for this? Cause from what little I read about it, it was more "use c++ functions from python" than the other way around (which I think is what I want). I dunno... anyhow, any ideas? :)
SiCrane
SiCrane
Yes, you can use Python from C++. I personally recommend boost::python for this task.
sipickles
sipickles
Quote:
Original post by S-Rave
Can I use boost.python for this? Cause from what little I read about it, it was more "use c++ functions from python" than the other way around (which I think is what I want).



Calling c++ from python is called 'extending' python, while calling python from c++ (which is much nicer I thinK!) is called 'embedding'.

There is a small chpater on it in the boost.python tutorial, but a google search on EMBEDDING PYTHON C++ would help more.

Also consider signing up to the c++-sig mailing list where lots of nice patient people have helped me in the path. It specifically concerns interfacing python and c++

hth


EDIT

sicrane has done a handy article too
mvBarracuda
mvBarracuda
Quote:
Original post by sipickles
Calling c++ from python is called 'extending' python, while calling python from c++ (which is much nicer I thinK!) is called 'embedding'.

Here is a quite one-sided but hopefully interesting article that tries to explain why extending python can be a great option:
Extending vs. embedding Python - a heavily biased rant
-----PARPG - open source isometric 2d old school RPG still looking for interested contributors

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.