OPENGL: Properly query for OpenGL errors.

There might be various error flags and we need to clear all of them to get
precise error results. Thus, we need to call glGetError in a loop to achieve
that.