Taking the next step on coding Blender

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

Post Reply
Posts: 10
Joined: Wed Mar 19, 2003 10:48 am

Taking the next step on coding Blender

Post by Smerity »

How do you take the next step when learning to code Blender?

So far, I've compiled Blender, added some buttons around the shop, learned how extrude worked and added some funky otions there and changed the location that a specular spot would appear, but when I go to trying to understand anything else, I'm stuck! :shock:

I know all the simple bases of C and C++, yet nothing in the books I've read has really prepared me to see real code I guess...

I'd like to know how some of the Blender coders learned C and C++, did you start practicing on a smaller or simpler to understand project, or maybe another opensource project, or what? I've been loading up LInux for months and compiling new batches and staring at bits and pieces of the code, hoping for some breakthrough, but as of yet, it hasn't come.

Can you help me? =)

Posts: 192
Joined: Wed Oct 16, 2002 5:35 pm

Post by leinad13 »

Don't worry i would love to play around with Blender, but i just still cant compile it on windows. Ah well maybe no in the Holidays i will give it another go.
Over to you boffins


Posts: 410
Joined: Mon Oct 14, 2002 4:32 am
Location: Sydney, Australia

Post by matt_e »

Look for a small problem (or something you want to change) and figure out how to solve it. Then move on to the next, and the next, and the next :)

At least if it's something you're personally interested in, you'll be motivated to keep trying if you don't at first succeed, unlike if you were trying to fix some obscure bug you found in the tracker or something. That can come later!

Posts: 0
Joined: Tue Nov 25, 2003 5:27 pm
Location: Denzenberg, could walk to Hölderling-Tower

Post by bjornmose »

understanding blender code is not only C or C++. i'm a software pro for about 15 years now and i think i can read C. i started looking at the blender sources a few weeks ago, but till now i only have a faint idea of how the whole thing is plugged together.

when you look at the source of a rather complex application that was done by someone else you're almost bound to understand nothing at all.

this is because the code was written by some people who did talk to another, made concepts, defined rules, agreed on naming variables and functions.
when they did the code they had it all in mind, so (like most developers)
they did not feel the need to write some explaining comments.

it quite often happens that a developer becomes archaeologist diggin in somone elses code to find out what and how it is done there. it is in fact 70% of my job.
be aware! "historical code" is not always a good teacher. Sometimes developers do some "too lazy coding a new function see what i can abuse"

as broken said: start with a small task, you think you can tackle.
then dig out bone after bone.

Posts: 10
Joined: Wed Mar 19, 2003 10:48 am

Thanx =) Feeling better already

Post by Smerity »

Thanx for the comments =)

Broken - Thanks, I guess I'll try that =) I seem to have enough determination, cuz like every second day I boot Linux and have a play around with Blender's code, and no matter how redundant it seems its still fun =)

bjornmose - thanx man, you really put it into perspective for me =) I guess it was a closed source project initially and they never expected having to guide young newbie coders thru a small work of havoc they created =)

I guess I'll start with the simplest things I can think of, trying to undertstand how a section works and adding some /* comments */ =)
Once I get far enough doing that, I'm thinking of looking at the algorithm for how Cntrl+J works (turning tris into quads) since so far the algorithm is about as efficient and effective as Blender's booleans (from a while back, not saying that the code people are generating is not good, matter of fact I actually saw a project devoted to Blenders booleans =))
Anyway, enough babble, it seems that I'm just going to have to take a long slow path, but thank you guys SO much! =)

Posts: 24
Joined: Wed Oct 16, 2002 12:45 am
Location: Mumbai, India

Post by iluvblender »

Also, try reading something on different software architecture models. Like
Layered models, Blackboard models etc.,

Understanding the architecture of the application is very important before one can contribute to the codebase.

my 2 cents... :D

have fun coding and blending...

Posts: 10
Joined: Wed Mar 19, 2003 10:48 am


Post by Smerity »

Woo! I've gotten to a point where I've gotten enough to backtrack in using general Blender terms to find out what each thing does, eventually :wink:

iluvblender - heh =) Thanx! I love reading technical docs (a little weird I guess, but meh =)) but for the rest of the holidays I'm going to devote entirely to coding non-stop (or at least an honest attempt to lol) I'll read it back at school when I'm bored ;) (Year 8 IT is REALLY unchallenging)

Just a tip to anyone who is a little lost like me, use the blender/source/blender/src/space.c to find a simple function, or to track the progress on how a process runs...
For example, you know Control + J in edit mode turns 2 tris to a quad (which is the algorithm I'm interested in for improvement), and you go to case JKEY:, and to

Code: Select all

else if(G.obedit) {
					if(G.obedit->type==OB_MESH) {
This basically means that if in object edit mode, if in object edit mode and the type is a mesh, run the process join_triangles (which is found in editmesh.c in same folder typically, but if its an unknown function, use Find and use "Containing Text" to track it down, available both in Windoze and Linux at least in KDE).
Also, not that I had trouble with it (Ton noted it in most of the headers, THX TON! :D) that vlak is used interchangably with face, as at the time of coding it seemed that the term "face" wasn't developed

Anyway, from this point on I've got it fairly underlocks, I've even understand 99% of the algorithm, so that's a major positive! :D
Thanks duly to you guys for ur help! Hope instilled, sleep removed, caffeine in overload! :lol:

Code: Select all

if( Smerity_sleepy == 1 ) caffeine(overdose); 
     else code();
Only hope there is space for improvement in the algo ;) (or I can rewrite it *eek* lol)

Blend on, blend well!

Post Reply