OpenGL calls flow fix and performance improvement.

Fixed OpenGL errors due to incorrect material unuse() calls flow.
Performance improvement: lazy loaded, cached uniform locations.