Blender Dev FAQ
What Language is Blender written in?
Short Answer C/C++/Python.
- C - for blenders core and most internal functionality, tools and editors.
- C++ - windowing, physics, audio and the game engine.
- Python - The interface definitions, addons and most format import/export
What Editors/IDE's do blender developers use?
These IDE's are known to work well for blender development where CMake is used to create project files.
- XCode on OSX
- MSVC 2008/2010 on Windows
- Eclipse on any
- QtCreator on any
- Netbeans on any
- KDevelop on Linux
Some developers use editors such as vim, emacs, geany, notepad++ and scite.
Its quite common to use a different editor/ide for C/C++ than python code.
Where is the right place to request features in blender?
There are so many possible features to add to blender that its difficult to manage them usefully so we don't accept feature requests on our tracker as some projects do.
If the feature requests are small, like an option to an existing tool you could try to contact the developer of that tool, or at least the maintainer.
See Module Owners
If you're suggestion is a larger change, try make this a suggestion on blenderstorm and use this to get feedback, link others to it and eventually get a developer to look over it to see if its feasible.
Why not switch to distributed version control? (git/mercurial/bazaar)
Some existing core developers would really like to move to distributed version control, however its not so easy for us.
This is a possibility for the future but is complicated by blender having large binary files committed into svn which makes moving the history to another system more difficult since these files need to be masked and managed somehow. GIT stores the entire history in a checkout so this is impractical when dealing with binary files.
mercurial/bazaar may provide a better upgrade path, but it needs to be investigated.
This is something we would need to have an experienced admin work on who's willing to help with the transition, so not just something we can do without planning and research.
Note: we're aware there are solutions for managing binary files such as git-annex.
Note: we do have a git mirror
Note: We are currently investigating git migration, for a large code-base this poses many challenges.
Why did my Blender compile fail?
There may be many reason why it failed, but here are some common causes. Also remember to look for the first error that is printed, as this is usually the root cause, further errors may only be a result of this.
File not found or Unresolved Symbols
This usually means a library was not installed, not configured in the build system, or the wrong version of the library was used. Also make sure to download the lib/ folder on Window and Mac, and to install the needed development packages on windows. It's also possible to disable certain libraries when building Blender to avoid the issue. See the Building Blender documentation for details on dependencies.
Blenderplayer failed to compile due to missing functions
Many developers don't compile the blenderplayer, so don't notice this - if it happens grep the source, find the function prototype and copy and paste the function prototype in the stubs.c file with the appropriate NULL or 0 return. If a struct is return you should cast NULL to the appropriate struct type
DNA compile errors
Usually this means you added something to a struct in a header file and forgot to adjust the amount of padding in the struct. Blender requires that the structs be multiples of 8, see the SDNA Notes for more detail. So if you add a short, and there is a char pad; you change it to char pad, to keep it a multiple of eight. Of course if you forget the rules just keep adding a char pad till it compiles without errors :) (which is what you will do if it compiles in your 32 bit machine and others say it is failing in their 64 bit ones... save some time and read the rules instead, alignment matters too, no matter how much padding you add).
RNA compile errors
This usually means the wrong DNA struct type or property name was specified.
Missing Interface Buttons and Menus
Usually this means you added something to the user interface python code and made a mistake. Check the console for errors, often this is because of mixing tabs and spaces. All python scripts in Blender uses spaces for indentation.
Menu or checkbox defaults to the wrong value
Make sure you added a default value in the function that creates the struct, and that you create a version patch in do_versions in readfile.c to initialize values on existing structs.
Source Code FAQ
How do I build Blender?
Follow the excellent instructions on Dev:Doc/Building_Blender.
What documentation is there?
Dev:Source/Architecture has a bunch of documentation on the concepts behind Blender's C code. It is not easy for a newcomer to understand, there is a lot to read, and it is not completely up to date. But you should keep coming back to it - the more you understand pieces of Blender, the more all of this will make sense and be helpful.
Where does blender start and what happens next?
source/creator/creator.c has the
main() routine in it.
After parsing args, a bunch of initialization, and reading a .blend file,
main() passes control to
source/blender/windowmanager/intern/wm.c. That is an infinite loop that just processes events and notifications and draws updates on the screen. Events and notifications are things caused either by the user doing something (e.g., mouse click) or the internal blender systems signaling to other parts of blender that something has changed and that means something has to be recalculated, redrawn, or something else.
What is an overview of how the files and subsystems are organized?
Here is a great picture.
Most of the code you will care about is under the
source/blender/ subdirectory, though some Python code you may want to look at is under
Where is the UI code?
The UI layout is defined in Python but the drawing is done in C, and some of the UI is defined in C too.
The Python code is in
space_view3d.pyin that directory is the code for the 3D View editor type (space).
The C interface drawing code is in:
The glue code defining the API python uses to create interfaces
The Python UI code mostly just lays out user-interaction widgets that adjust properties of operators. Operators are Blender tools. At some point you should read Dev:2.5/Source/Architecture/Operators.
How are Operators connected to C code?
If you hover over a button like Spin in the user interface, it shows you the Python name for the operator that will be invoked if you hit the button -
bpy.ops.mesh.spin(). This is implemented in C by an operator named
MESH_OT_spin (see the naming convention in Dev:2.5/Source/Architecture/Operators). If you look for that name, you'll find it as a function that fills in various function pointers and flags in a
wmOperatorType struct. The important one is the invoke function, in this case
spin_mesh_invoke(). If you put a breakpoint on that you'll find that it gets called soon after you push the Spin button.
bpy_operator.c code knows how to go back and forth between module.func and MODULE_OT_func.
What is this DNA and RNA stuff?
The names come from the genetic nucleic acids and hint at their function: DNA, as in genetics, is the code that lets you reproduce something. In the case of Blender, this is essentially what is written to and read from disk as a .blend file - it has all of the user settings and mesh, object, scene, etc. data. RNA, as in genetics, is a helper to transmit the DNA code into the rest of the internal Blender system.
.h files in
source/blender/makesdna/ define the structs, enums, etc., for all the data that needs to be persisted to disk. These are usually used in memory in the running system too. For example,
DNA_mesh_types.h defines the
Mesh struct that has enough information to store a user's mesh on disk. While running, there may be a
Mesh in memory, but there will likely be various derived mesh structures that are more efficient to use during editing, say.
Another aspect of DNA is that it is also a system for helping compatibility between different versions of Blender. The way this works is that a coded description of the layout of each struct is also written to and read from disk. This means that the layout does not have to stay fixed. The C files in the
makesdna directory are for generating and interpreting the structure descriptions. See Dev:Source/Data_Structures/DNAStructs.
RNA is also something that is partially made by code generation, using code in
source/blender/makesrna. It is supposed to be a somewhat more abstract and nicer interface to the DNA data. For example, where a DNA struct might use a particular bit in a short for some flag, RNA would expose that as a bool property. So far, this nicer Data API isn't used too much in the C source code. Where it is heavily used is as the interface to and from Python. Most of the Python access to Blender data is generated automatically to use the RNA system. See Dev:2.5/Source/Architecture/RNA for more information about RNA.
Where are the icons?
The PNG files for icons are in
The file called
blender_icons.svg is one large SVG file with almost all of the button icons in a kind of matrix arrangement in it. There is a shell file to convert that file into 16x16 and 32x32 per icon versions of the SVG file as PNG files. The brush icons are separate PNG files in the
brushicons subdirectory. The
datafiles directory also has the splash image and some TrueType fonts.
All of these data files are turned into C files that declare their data as char arrays at build time, so any modifications to these files will be visible after rebuilding.
Most of the icons are in the
blender_icons32.png) image. This image is loaded as one texture on graphics cards, and the appropriate 16x16 or 32x32 piece is copied to the right place on the screen when desired. The code for initializing the icons is in
source/blender/editors/interface/interface_icons.c, in the
init_internal_icons() function. The order of the icons in the image is, bottom to top, left to right, the order of the
DEF_ICON declarations in
You can make your own icon file to override the compiled-in
blender_icons.png one. The User Preferences Theme panel has a place where you can enter an icon file name. The file should be laid out like