How to implement a graphics API