Refactor entire rendering process to a function

The entire rendering process is now refactored into a separate function
in renderdriver module. It is a prelimary step for merging the
interactive to the main code.