If all you need to do is flip texture X coordinates, set S := 1; instead of 0 and replace S := S + ds; with S := S - ds;