We study N=2 supersymmetric four dimensional gauge theories, in a certain N=2
supergravity background, called Omega-background. The partition function of the
theory in the Omega-background can be calculated explicitly. We investigate
various representations for this partition function: a statistical sum over
random partitions, a partition function of the ensemble of random curves, a
free fermion correlator. These representations allow to derive rigorously the
Seiberg-Witten geometry, the curves, the differentials, and the prepotential.
We study pure N=2 theory, as well as the theory with matter hypermultiplets in
the fundamental or adjoint representations, and the five dimensional theory
compactified on a circle.