原因:glBegin和glEnd之间只能调用顶点属性等相关函数,glGetError不可调用,GL_INVALID_OPERATION指的是glGetError操作无效。
gBegin的文档说明如下(以微软的MSDN的GL1.1为例)
You can use only a subset of OpenGL functions between glBegin and glend. The functions you can use are:
You can also use glCallList or glCallLists to execute display lists that include only the preceding functions. If any other OpenGL function is called between glBegin and glend, the error flag is set and the function is ignored.