Graphics engine for 3D and 2D games