Factor out shader loading into a function

This will help when we want to compile more than one shader.
Fix an unused variable warning