0

My task : make weighted antialiasing algorithm with accumulation buffer in OpenGL. In other words, i have pixels array, which i have to shift by one pixel in all directions with multipliers.

My problem : I don`t really understand what my code does.

while(!glfwWindowShouldClose(window)) {
    glReadBuffer(GL_FRONT);
    glDrawBuffer(GL_FRONT);
    glDrawPixels(800, 800, GL_RGBA, GL_UNSIGNED_BYTE, pixels);

    glAccum(GL_LOAD, 1.0);
    glRasterPos2d(1.0, 0.0);
    glAccum(GL_ACCUM, 2.0);
    glRasterPos2d(0.0, 1.0);
    glAccum(GL_ACCUM, 2.0);
    glAccum(GL_RETURN, 1.0);

    glfwPollEvents();
    glfwSwapBuffers(window);
}

As i understand, glRasterPos changes "cursor" position, so with changing it my picture should shift to one pixel to right and to bottom. But i don't see any antialiasing results, just blinking of my shape(pixels array contains only white pixels). I understand that i should do GL_ACCUM to all nine directions. And i should use exactly glRasterPos for this. What don't i understand with glAccum and glRasterPos?

wzpcm
  • 1
  • 6
    [Please don't use the accumulation buffer, it's old and not worth it anymore.](http://stackoverflow.com/questions/10508872/opengl-antialiasing-without-the-accumulation-buffer) If you want anti-aliasing [then use multisampling, which can be enabled with a single function call in GLFW.](http://stackoverflow.com/a/42858872/2470818) – vallentin Apr 09 '17 at 05:07
  • @Vallentin thank you for answer, but I have no choise, it is specific homework with specific demands. And I saw this link, user moves camera, but I need move my image with glRasterPos function and I don't understand how I should do this – wzpcm Apr 09 '17 at 12:46
  • @wzpcm: Homework? Good lord, your course material surely hasn't been updated in 20 years, for sure. You'll be hard pressed to find systems that actually support accumulation buffers these days; in fact accum buffers **never** were properly supported by consumer hardware at all. If you really want to go down this road (rendering several times with jittered projection matrices) then in this day and age you'll have to use framebuffer objects instead of accum buffer. – datenwolf Apr 09 '17 at 22:01

1 Answers1

0

Calling glRasterPos doesn't move anything, it just sets current position - treat it as assigning values to internal posx and posy variables. You should draw your image again (call glDrawPixels) in order to see the effect of this call.

Mr D
  • 96
  • 5