我不知道简单代码有什么问题。该函数适用于python和ctypes。extern "C" void add_lines(bool antialias,GLdouble coordinates[][2],int array_size,GLdouble w,GLdouble r,GLdouble g, GLdouble b,GLdouble a){ glDisable(GL_TEXTURE_2D); if (antialias){ glEnable(GL_LINE_SMOOTH); //Enable line smoothing. } glColor4d(r,g,b,a); glLineWidth(w); glBegin(GL_LINE_STRIP); for (int x = 0; x < array_size; x++) { glVertex2d(coordinates[x][0],coordinates[x][1]); } glEnd(); std::cout << glGetError(); if (antialias){ glDisable(GL_LINE_SMOOTH); //Disable line smoothing. } glEnable(GL_TEXTURE_2D);}std::cout 谢谢。 最佳答案 glGetError() 是粘性的:一旦某个函数设置了错误,它将一直保持该错误值,直到您调用glGetError()为止。因此,该错误很可能是在其他地方引起的。检查函数入口上的glGetError()的值,然后在每个函数调用之后找出它的设置位置。关于c++ - glEnd之后,OpenGL GL_LINE_STRIP给出错误1281(无效值),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2929598/
10-11 01:04