Realism is view point that external things are real and exist independently of mind.
Materialism as opposed to idealism is that it is material things that shape our ideas and ideologies. In contrast, idealism states that ideas come first and then changes in material things are pursued in accordance with those ideas. For example, Hegel’s Dialectical Idealism states that ideas can change shape themselves and material input is not required. Marx’s Dialectical Materialism is a contrast to that position and it asserts that Material Things themselves are subject to dialectical dynamics and ideologies take their form and shape out of material dynamics.