Added viewport support, fixed const correctness.

Support for multiple viewports has been added. Const correctness of some
member functions has also been fixed.