gource – repository history visualization

March 8, 2010

Today I found out about gource. A little tool for visualizing repository(git, cvs, mercurial etc.) history. I was playing with it for a while, here you see the history of my project since the beginning of january(when i created git repository):

The visualization can be generated with the simple command:

gource --stop-at-end

To save the visualization in a video file, just execute(on linux):

gource --stop-at-end --output-ppm-stream - | ffmpeg -y -b 3000K -r 60 -f image2pipe -vcodec ppm -i - -vcodec mpeg4 gource.avi

Signals

March 7, 2010

I wanted to have a signal/events mechanism in my engine, so first i looked up some libraries which are already implemented – less code to write and maintain is always better. I liked the Qt signal/slot mechanism, but it is slow(string based) and needs the code to be preprocessed by Qt toolchain. It works nice for GUI apps, but it’s useless when it comes to games. The second choice was libsigc++, the library used by gtk. It’s much nicer in terms of speed, and also does not require any code preprocessing, but has one big flaw: it requires the class to derive from the sigc::trackable object. This can be omitted by the usage of sigc::connection objects returned by the connect function. This in turn requires to manage those connections manually, either storing them in a container or having them as members in the given receiver class. For me this is too much hassle.

In the end I decided to implement my own signals. The goal was the ease of use of the Qt signals with the speed and native C++ implementation as in libsigc++. Since I already use FastDelegate through out my code, there was no need for implementing a delegate mechanism. The only thing that had to be done was the signals themself. The signal functionality can be divided into two categories. Emitting the signals and connecting signal handlers. The first part is pretty obvious. I have a separate template signal class depending on the number of arguments. For now I implemented signals for methods/functions with 0 up to 3 arguments(if I need a signal taking more arguments it’s pretty much copy+paste).

The second type of functionality, connecting handlers, is a little more complicated. The most important thing is that when the instance of the object connected to the given signal gets destroyed, the signal should remove the callback from it’s list of handlers. For this, C++ has a killer feature: destructors. The simplest approach, used in libsigc++, is to create a connection object that will disconnect the callback from the signal when it gets destroyed. As I stated earlier I don’t like the need to have to manage those connections manually. The solution of course is a base class(again this approach is used in libsigc++), which will manage all the connections of the derived class. The problem arises when you have a class that already derives from another class. You could use virtual inheritance but this is what I would like to avoid at all cost.

Read the rest of this entry »

Seaching through STL containers

March 4, 2010

Recently I discovered that I often search through STL containers(mostly vector) using the following syntax(pseudo code):

for(iterator it=begin(); it!=end(); ++it){
  if( it->key()==key ){
    // do something.
  }
}

I know there is std::find but it uses operator== so if I have one for my class I would have to create a temporary object to compare to or overload the operator for the given type. The first approach is useless in most cases, and the second one is more or less also useless since i can have 2 getters returning the same type and the operator== would work only for one of them.

On the other hand, there is std::find_if function which takes a predicate as a last argument and returns the object that satisfies predicate(obj)==true. This allows for a per vector/object customization of the search. The downside is that I would have to write a predicate for each vector type. I can have multiple predicates per class for different search conditions.

I found the solution to be quite simple. I implemented a predicate class for use with std::find_if that takes the getter address and the desired value and uses this getter for comparison. This way I have a little piece of code that allows me to search through every container using specific criterion(the given getter).

Read the rest of this entry »

Launch

February 21, 2010

I planned to start a homepage of some sorts for a long time. At the beginning I wanted to write it by myself, but as web development isn’t something that I like it was never completed. Now the time has come that I’ve decided that it’s just easier to sign to wordpress and have the page running in few clicks, so here it is. It doesn’t mean I’ll never complete my own homepage, if I do :) I’ll move the content and post a notice here.

As for the blog content, I will be posting my thought’s and ideas about coding here. Probably it’ll be mostly about game development since this is my area of interest, but I’m not locking my self on one subject. There won’t be any photos(except for screens :) ), love stories etc. If you’re after one, I’m sorry to disappoint :)

So here it is, I hope you’ll find something useful here.


Follow

Get every new post delivered to your Inbox.