OpenGL GL_LINE_STRIP gives error 1281 (Invalid value) after glEnd
I have no idea what is wrong with the simple code. The function is for use with python and 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);
开发者_StackOverflow中文版 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(); gives out 1281 each time.
Thankyou.
glGetError()
is sticky: once the error gets set by some function, it will stay at that error value until you call glGetError()
. So, the error is likely being caused elsewhere. Check the value of glGetError()
on function entry, and then after each function call to find out where it's being set.
Are you sure the error is not triggered before glEnd? glGetError will report the last GL error, which might be caused earlier in program execution.
精彩评论