I'm trying to use the accumulation buffer in an OpenGL application. But I've got an OpenGL 3.3 card and as far as the Red Book goes, it's not available. I assume that's why I can't accumulate decreased value fragments.
I'm trying to do anti-aliasing via the accumulation buffer (it's a school assignment). Is there any way to simulate this phenomenon, to paint several faded color images into a buffer, accumulate the result and output to the rendering context?

I'm also trying to set up a background image for my scene, which contains a modifiable object. So I need to be able to take an image and put it behind the object and make it stay there no matter what happens to the object. I've tried drawing a quad with texture behind the object before the object draw call and after it and so far with no success.

I've tried solving these two problems using framebuffers but also with no success. I've scoured Google for help as much as I can but nothing works so far.
Has anyone did something like this and can help me through it?

Below is the code for my background drawing and accumulation anti-aliasing attempts so far. The commented code is my previous attempts and the uncommented code is the one I tried with framebuffers. At this time, I even have a breakage with the framebuffer data transfers somewhere. Please help.

(projectionMatrix() modifies the projection transformation according to selected Ortho or Perspective. First parameters is window scale, the next is the aspect ratio and the third divides the screen if necessary)
Qt Code:
  1. if (background_image)
  2. {
  3. // Probably need to render to frame buffer
  4. glEnable(GL_TEXTURE_2D);
  5. QImage png;
  6. if (!png.load(background_path))
  7. {
  8. png = QImage(16,16,QImage::Format_ARGB32);
  9. png.fill(QColor(255,255,255,255).rgba());
  10. }
  11. png = QGLWidget::convertToGLFormat(png);
  12.  
  13. // If png was read, instantiate texture parameters
  14. GLuint bg_texture;
  15. glGenTextures(1,&bg_texture);
  16. glBindTexture(GL_TEXTURE_2D,bg_texture);
  17.  
  18. glTexImage2D(GL_TEXTURE_2D,0,3,png.width(),png.height(),0,GL_RGBA,GL_UNSIGNED_BYTE,png.bits());
  19.  
  20. QGLFramebufferObject framer(width,height,QGLFramebufferObject::Depth);
  21. framer.bind();
  22.  
  23. framer.drawTexture(QRectF(0.0f,0.0f,(float)width,(float)height),bg_texture);
  24. draw();
  25.  
  26. framer.blitFramebuffer(0,QRect(0,0,width,height),&framer,QRect(0,0,width,height),
  27. GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  28. framer.release();
  29. // double distance = box_min[2] - 5;
  30. // double pl_height = qCeil(2*qTan(15.0/180.0*PI)*(-distance));
  31. // double pl_width = qCeil((double)width/(double)height*pl_height);
  32.  
  33. // glPushMatrix();
  34. // glLoadIdentity();
  35.  
  36. // glColor3f(1.0f,1.0f,1.0f);
  37.  
  38. // glBegin(GL_QUADS);
  39. // glTexCoord2i(0,0);
  40. // glVertex3d(-pl_width/2,-pl_height/2,distance);
  41. // glTexCoord2i(1,0);
  42. // glVertex3d(pl_width/2,-pl_height/2,distance);
  43. // glTexCoord2i(1,1);
  44. // glVertex3d(pl_width/2,pl_height/2,distance);
  45. // glTexCoord2i(0,1);
  46. // glVertex3d(-pl_width/2,pl_height/2,distance);
  47. // glEnd();
  48. // glFlush();
  49.  
  50. // glPopMatrix();
  51. }
  52.  
  53. // Accumulation Style AntiAliasing
  54. if ((antialiasing) && (antialiasing_mode == ACCUMULATION))
  55. {
  56. QGLFramebufferObject framer(width*4,height*4,QGLFramebufferObject::Depth);
  57. framer.bind();
  58.  
  59. draw();
  60.  
  61. framer.blitFramebuffer(0,QRect(0,0,width,height),&framer,QRect(0,0,width*4,height*4));
  62. framer.release();
  63.  
  64. // float jitter[] = {0.5625,0.4375,0.0625,0.9375,0.3125,0.6875,0.6875,0.8125,
  65. // 0.8125,0.1875,0.9375,0.5625,0.4375,0.0625,0.1875,0.3125};
  66. // double lim = 1/scale;
  67.  
  68. // for (int j = 0; j < 16; j+=2)
  69. // {
  70. // // Define projection matrix
  71. // projectionMatrix(1.0,(double)(width+jitter[j]*lim)/(double)(height+jitter[j+1]*lim),
  72. // (enable_split_screen) ? 2.0 : 1.0);
  73. // draw();
  74. // glAccum(GL_ACCUM,1/8);
  75. // }
  76. // glAccum(GL_RETURN,1.0f);
  77. } else {
  78. // projectionMatrix(1.0,(double)width/(double)height,(enable_split_screen) ? 2.0 : 1.0);
  79. draw();
  80. }
To copy to clipboard, switch view to plain text mode