There are two basic types of cushions: knife edge (thick at the center and tapered at the edges) and box edge (uniform in thickness throughout).
To cover a knife-edge foam cushion, cut two fabric pieces the dimensions of the foam. Stitch piping all around one piece 1/2 inch from its edges. With right sides facing and the piped piece on top, stitch a seam 1/2 inch from the edges, leaving one side open. (The 1/2-inch seam makes the cover 1 inch smaller than the foam, ensuring a snug fit.)
Turn the cover right side out; press. Insert the cushion, slipstitch the opening. To make it easier to slip the foam in and out of the cover for washing, make an inner cover of plain, lightweight fabric.
To cover a rectangular box-edge cushion, cut two pieces of fabric the dimensions of the cushion’s top plus half its depth on all four sides. Following the package directions, stitch an invisible zipper to one side; leave the zipper open. With right sides facing, stitch the two pieces together, beginning and ending at the zipper placket. With the pillow inside, pin the corners to fit smoothly. Take the pillow out. Stitch where you pinned; clip off the excess. Turn the cover right side out; push out the corners.
A box-edge cushion cover
With loose filling you can make a cushion any size and shape you like. To contain the filling, first cut and stitch an inner cover of firmly woven fabric, leaving one side open. Cut a hole in a corner of the bag of filling (polyester, kapok, feathers, or down), insert it into the cover, and ease out the filling. Slipstitch the opening. Make an outer cover, following the directions for a knife-edge cushion.