Query glGetError() before assuming that the value returned by getResource() is sane, #267