• Advertisement
Sign in to follow this  

need help with accumulation buffer again

This topic is 2999 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm just trying to use the accumulation buffer, but I can't get it to render at all. I just get a black screen. What I should be seeing is 4 rotated polygons over each other, which I do see IF I remove the accumulation buffer code...
init()
{
    SDL_GET_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 16 );
    //same for GREEN, BLUE, ALPHA

    glGetIntegerv( GL_ACCUM_RED_BITS, &var ); 
    //did the same for GREEN, BLUE, ALPHA. all contained 16, which verified that there are 16 bits for each channel for that buffer
    //which means I can use it?
}

//render() is called every frame
render()
{
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT );
    glClearAccum( 1, 0, 0, 1 );

    glMatrixMode( GL_MODELVIEW );
    glPushMatrix();
        glLoadIdentity();
        glMultMatrix( /*world-view matrix*/ );
        RenderPolygon();
    glPopMatrix();

    glAccum( GL_RETURN, 1.f );
    SDL_GL_SwapBuffers();
}

RenderPolygon()
{
  for( unsigned i = 0; i < 4; i++ )
  {
     glPushMatrix();
       //rotate
       //render with glDrawArrays( ... )
     glPopMatrix();
     glAccum( GL_ACCUM, 1 );
  }
}




[Edited by - 16bit_port on December 7, 2009 2:35:02 PM]

Share this post


Link to post
Share on other sites
Advertisement
The code looks fine. As long as your GL_ACCUM_RED_BITS etc do return 16, it means that the accumulation buffer is allocated and available.

glClearAccum should be called before glClear but that is a minor issue.

Also, the accumulation buffer is generally cleared separately somewhere else than the color and depth. In other words, replace :

glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT );

with :

glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glClear( GL_ACCUM_BUFFER_BIT );

In theory that should not be needed, though. Just odd things to try.

Also, please try to replace :
glAccum( GL_RETURN, 1.f );

with :
glClearAccum( 1, 0, 0, 1 );
glClear( GL_ACCUM_BUFFER_BIT );
glAccum( GL_RETURN, 1.f );

This should display a red screen. If not, it means the accumulation buffer is not working at all (maybe bad driver support, or SDL badly handling accumulation buffer).

Also please check if glGetError returns something.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement