Corange

29/05/2011

Making your own game engine is always something people tell you never to bother with - still, it seems a to be an allure which most graphics programmers can't avoid.

In the past I've worked at a fairly low level - even using an existing framework or engine you still need to know about the basics for many techniques. I knew the steps needed for getting a teapot on screen.

So I went ahead and took the dive - created what is called Corange. For anyone interested the WIP source code can be found on github. It uses SDL and OpenGL and I've been largely developing it in windows using MinGW.

I also decided to decided to develop it in pure C. This was almost the point of the experience - I wanted a project to get my C skills up to a more acceptable standard. In the end, there didn't turn out to be that much stuff in C which was new to me. Most of what I learnt was about objects, linking, libraries, gcc, gdb and all the things involved with actually making a C project. I've used C++ before and to put it lightly I'm not a fan. Perhaps I should have not picked an industry that uses it almost exclusively. Either way there were lots of things I liked about C.

  • Memory Management is fun! I like thinking about stuff on this kind of low level - it helps you appreciate all that is done for you on high level languages, but it also give you a much more distinct view at memory usage. The only thing I missed were some nicities like destructors and constructors, which I could have used in some of my more generic container types. Still - it wasn't too much of a pain. In the end I used function pointers and handlers to give the appearance of generics, which ended up working fairly well, and giving a nice interface on things like asset management.
  • C forces you to keep it simple. I've said before how much I think keeping it simple is the key to good abstraction - rather than strong typing and code beaurocracy. Because doing complicated things in C can be hard, it encourages you to look for simple, effective solutions. No more throwing Dictionaries, Arraylists and extra Classes at a problem - it makes you examine the data flow, which often leads to a better solution.
  • Values are values. Everything is data. No longer do I have to worry about what things "are" - structs are values - pointers point to memory. The nice thing this leads to is that I can also hack in some of the dynamic and functional programming constructs which I love.

There were also some things I don't like.

  • Strings in C are evil. Filled with so many pitfalls in trying to use them. And I had to use them a lot - for any file formats I was parsing. The other thing that haunts me - and I know the reasons why this is easier said than done to implement in C - is that strings should be values. This is just a semantic so strong in my head that I stuggle to see the world in any other way. Even if strings were forced to be immutable and a bastardised functional programming approach had to be used to implement them - I would still prefer this.
  • Namespaces - If your language standard includes a preprocessor definition at the beginning of every header file then you've basically fucked up. As with strings, I understand why it had to be done in this way, but it seems crazy. Luckily I didn't come into any namespace issues, but I was careful to avoid them, and there are some horrible things going on in some well used libraries with regards to namespaces. For a language which is so beautiful, this doesn't seem right.

So Corange is in pure C - feel free to take anything you'd like, even if it is just the vector libraries. It can be considered BSD until I come up with something else. As far as "neat features" goes it doesn't have that many. Asset management is pretty nice and easy, done using filetype handlers. It can render using custom GLSL shaders and also it does font rendering.

Contains a basic (probably buggy and untested) .obj importer and working .dds importer. I'll probably extend it some more - when I have things to be playing with like some stuff for my thesis project.