Hello idr,
Screenshot #1: single buffering
Screenshot #2: double buffering
Initialization (I’m working with Borland C++ Builder - Panel1 is simply a child of the main window, hDC and hRC are Global), calling SetPixelFormatDescriptor:
hDC = GetDC(Panel1->Handle);
SetPixelFormatDescriptor();
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);
int Dim = min(Panel1->Width, Panel1->Height);
glViewport((Panel1->Width - Dim) / 2, (Panel1->Height - Dim) / 2, Dim, Dim);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(30.0, 1.0, 1.0, 25.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor(0.0, 0.0, 0.0, 0.0);
glClearAccum(0.0, 0.0, 0.0, 0.0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
Might anything be wrong in my pixel format procedure?
void TForm1::SetPixelFormatDescriptor()
{
PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
PFD_DOUBLEBUFFER, // double buffered
PFD_TYPE_RGBA, // RGBA type
24, // 24-bit color depth
0, 0, 0, 0, 0, 0, // color bits ignored
0, // no alpha buffer
0, // shift bit ignored
32, // accumulation buffer
0, 0, 0, 0, // accum bits
32, // 32-bit z-buffer
0, // no stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};
int PixelFormat;
PixelFormat = ChoosePixelFormat(hDC, &pfd);
SetPixelFormat(hDC, PixelFormat, &pfd);
}
And, finally, the accumulation functions (in a test procedure that, as I mentioned, worked correctly in single buffer mode). Two spheres with different sizes but the same origin are painted and accumulated:
glClear(GL_ACCUM_BUFFER_BIT);
glPushMatrix();
glTranslatef(0.0, 0.0, -25.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSolidSphere(3.0, 20, 20);
glAccum(GL_ACCUM, 0.5);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSolidSphere(4.0, 20, 20);
glAccum(GL_ACCUM, 0.5);
glAccum(GL_RETURN, 1.0);
glFlush();
glPopMatrix();
SwapBuffers(hDC);