We reexamine the formation of the O I resonance lines (1302.168, 1304.858, 1306.029 angstrom) in chromospheric models of the Sun and cool stars. We focus on testing excitation mechanisms and understanding the dependence of the emergent spectra on the thermodynamical conditions in chromospheres. Based upon a complete reevaluation of atomic parameters and a sensitivity analysis, we confirm the dominance of the H Lybeta pumping mechanism found in earlier work, but also find important differences. In giant stars, electron collisions do not contribute significantly to the creation or destruction of resonance line photons of O I. These lines are controlled by emission through Lybeta fluorescence and by absorption in the Si I photoionization continuum. In dwarf stars, electron collisions contribute between 5% and 20% of the total line excitation. We derive analytical approximations for the emissivity, emergent flux densities and line ratios of the resonance lines. These formulae are based on the dominance of the Lybeta mechanism and the coupling between hydrogen and oxygen number densities through strong charge transfer reactions. The emissivity of the lines is proportional to (density) instead of the (density)2 dependence of collisionally excited lines. We derive scaling laws for the line flux densities which are broadly consistent with stellar observations. We discuss reasons for important differences between model calculations and observations, including (1) a problem with the mean number of resonance line scatterings in giant stars, and (2) the possibility that electron collisions are more important than our calculations suggest owing to inaccurate cross sections at thermal energies. Finally, we discuss the possible applications of these lines as diagnostics of chromospheric structure. In companion papers we will discuss other lines of O I and make more detailed comparisons with observations.