How about C++

Hi blender users.

I recently started learning C++ from online tutorials.

What i want to do is simply “set” the blender game engine to exchange data with c++ functions that i write intsead of scripting python or using th built-in logic processor .

I think this is possible by recompiling the engine and adding functions on naked code.

hold on, relax. Lots of commercial game engines are in fact scritping engines. It is A LOT easier. Why? I wrote my onw engine, and at some point the compilation was already like 1-2 mins, though it was a very simple program. Compilation of BGE may take hours.

Also, rendering is run by GPU. So, when you send data to the video card - it is only the video card that limits performance. Scripts run on CPU.

its not the Speed that matters , at least in my level , what i want is to run C++ functions instead of python scripting.

I want to do it cause i know the basics of C++ and i dont want (at this time) to try another language ,
when i master C++ i ll look at another lang.

Sounds cool and I may be wrong but I think it ought to be doable I seem to remember reading the engine was built in C++ as were Logic bricks so they ought to be accessable somehow.

You’ll lost quite a lot time doing so. C++ is a very fast disappearing language in game development.

Panda3D, another free game engine, supports python and C++. I would suggest using it. If you are familure with blender modelling and such you can always model in blender and just import the models into Panda. The engine is based off of scripting only (no logic bricks or nodes). Good luck!

-The Dawisch

if you can find a middle gound -like… if you hate how one language handles classes or whatever, you can somehow make a program which include whatever interpreters you need, and only use the language you don’t like much to call functions, and the one you like to write the code that does the actual work…

-you might need to think about a way to order your data in a file type that either already exists or one you come up with on your own… (this would be your middle ground, and all you’ll have to do is learn how to write and alter this file (or files) and read in whichever language you code in…

but in doing so you’ll be creating a bottle-neck… but if you have more than one working simultaneously…

(seems more trouble than it’s worth, but it’s not at all strange… xml might be fun for you to meddle with)

yes, grab a SVN checkout from, learn how to build it and get hacking!

Can’t you already code C++ scripts right into blender? In some of the files that Twilight 22 gave out they where writing the really intensive visual stuff in C++. If it’s not supported it should be.

Although I highly recommend using python and then converting python into C++, if you need to. That’s how the industry dose it and that’s because python is a lot like C++ only 10 times easier.

He’ll be able to help with BGE development though, he’ll actually be able to add features to Blender.

Some thoughts:

  1. compiling and re-compiling blender/bge is not so time consuming.

  2. I do like better python for prototyping and C++ for the final implementation. But that’s personal :slight_smile: and I think python faster to code too.

  3. a nice video on warping C++ external modules on python:

  4. Other alternative it’s to do your modules with dotNet and use CLR to integrate it with python.

  5. So as you can see learning python would be a great idea IMO:) You will not be able to do only C++ coding to make a BGE game. You will need scripting eventually.

I hope it helps, good luck

ok thnx alot

this video shows how to make python call a c++ function ???

@Nikolay it doesn’t take hours to compile the bge, it only takes like 5 min to compile all of blender.

The problem using C++ in bigger projects is, that C++ code is not readable compared to e.g. Python code. A lot of work gets wasted writing code which nobody understands. That is the main reason one should avoid C++.

//I think there can be comments

A bad programmer can create shit code in any language

Yet stil, these are not arguments when selecting programming language. The language grammar dictates the average style of written programms, and the grammar of C++ is quite a mess by itself. There is no reason why you could not become a good C++ programmer, but compared to modern languages it means more work.

rule of thumb.
write in python, when that fails, write specific parts in C/C++

Often you end up not even having to touch C/C++ if you are careful with your scripts.

From scratch? Well, yea, if you’re on a quad core system and you set the -j option to 4 (assuming you’re using scons). However, if on a single core machine, it takes more than an hour.

But that is a good point you bring up; compilation times will be a significantly lesser problem in the future, because it’s one of those rare things that can be spread over several processors quite easily.

However, higher level languages, like python, are still more comfortable to work with, in almost all cases.

Absolutely. This is, in my view, the right way to do it.

Learning languages really is not hard once you know the basics of programming. You change only minor things… like how you declare objects/classes/methods/functions, how you call them, and some other basic things.

It’s easy to jump languages… if you are fluent in one, you might spend a few hours to a day learning the specifics of another one. I’d say my first language that I could actually program in was Java, and from there I went to Python, then to C, and now all of them are very easy.

I’d focus less on learning C++ and more on learning programming basics like how object-oriented programming works, what compiling actually does, etc…