c++ - OpenGL GL_LINE_STRIP 在 glEnd 之后给出错误 1281(无效值)

标签 c++ python opengl ctypes

我不知道简单代码有什么问题。该函数适用于 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();每次给出1281。

谢谢。

最佳答案

glGetError()是粘性的:一旦某个函数设置了错误,它将保持在该错误值,直到您调用 glGetError()。因此,错误很可能是在其他地方引起的。在函数入口检查 glGetError() 的值,然后在每次函数调用后找出它的设置位置。

关于c++ - OpenGL GL_LINE_STRIP 在 glEnd 之后给出错误 1281(无效值),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2929598/

相关文章:

c++ - 编译此代码时遇到问题

c++ - Palm OS 5.4 (Garnet) IR 编程(在 IrDa 端口上使用 CIR)

c++ - 链接目标文件时的多重定义

opengl - 如何将 int 转换为 const GLvoid*?

opengl - 删除过多的代码

python - 如何在 SQLAlchemy 0.7+ 中重写已弃用的 DDL() 语句

c++ 二维数组和指向指针的指针-我不明白这段代码

c++ - 正确实现类函数数组

python - 使用 python 登录 facebook

类方法和静态方法的python装饰器?