Convert tgaview.c to C++