Changing triangle demo to C and putting all code into a single file