if im reading your code right, the second addtriangle is drawing the triangle in the wrong order, try:
But your clearing the whole surface of the cube so u need to rebuild it.
addtriangle(side1,2,1,3)
But your clearing the whole surface of the cube so u need to rebuild it.