views:

126

answers:

2

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);
    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.

A: 

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.

Matias Valdenegro
Thank you for your input. I used cout everywhere and then found out it originated after glEnd.
Matthew Mitchell
+2  A: 

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.

Adam Rosenfield
Read what I put for the last answer. I will check it again though.
Matthew Mitchell
Whoops. I do get it after the glEnd but also after glLineWidth.
Matthew Mitchell
"width - 1.08222e-31"There's my problem I guess. I'll see what I can do.
Matthew Mitchell
It works now that I've sorted the arguments out. Your answer pointed me to check glGetError properly again and then I spotted something I missed. Thank you and to everyone else.
Matthew Mitchell