Pyglet OpenGL drawing anti-aliasing

Allow Pyglet to use an extra sample buffer might help. Change your window line to this:

config = pyglet.gl.Config(sample_buffers=1, samples=4)
window = pyglet.window.Window(config=config, resizable=True) 

This works for me.


It's a bit hard to say for sure. The first thing is probably to change your hint from GL_DONT_CARE to GL_NICEST. It probably won't make much difference with most graphics cards, but it might help a little.

Other than that, it's a bit hard to say. Here's a bit of code (in C++; sorry):

void draw_line(float y_offset) { 
    glBegin(GL_LINES);
        glColor3f(1.0f, 1.0f, 1.0f);
        glVertex3f(-1.0f, 0.0f+y_offset, -1.0f);
        glVertex3f(1.0f, 0.1f+y_offset, -1.0f);
    glEnd();
}

void draw() { 
    glClearColor(0.0f, 0.0f, 0.2f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    glFrustum(-1.2f, 1.2f, -0.2f, 0.2f, 0.8f, 5.0f);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glEnable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glLineWidth(3.0f);
    glDisable(GL_LINE_SMOOTH);
    draw_line(0.0f);
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
    draw_line(-0.1f);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    draw_line(-0.2f);

    glFlush();
}

And here's what I'm getting as output from that:

alt text

The difference when line-smoothing is turned on seems pretty obvious. The difference between GL_DONT_CARE and GL_NICEST is (at most) a lot less so.