SDL_GL_SetAttribute no establece tamaños de color

I'm trying to change the size of the Accumulation buffer color components in *SDL_opengl*, but the SetAttribute command doesn't seem to be doing anything. Here's the code I'm using.
(To reduce code size I am only dealing with the RED component here, but in the actual code I pass all 4 components to both the color and the accumulation buffer and the effect is the same)

#include <iostream>
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>

int main(int argc, char *argv[])
    //Initialize all SDL subsystems
    if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )std::cout << "SDL ERROR!";

    // Try to Set the BitSize, while checking for errors
    int BitSize = 1; //This number never makes a difference!!
    int ErrorCode = 0;
    ErrorCode += SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ) // This one WORKS
        + SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, BitSize ) // These ones DON'T
        + SDL_GL_SetAttribute( SDL_GL_RED_SIZE, BitSize )

    if( ErrorCode < 0 )std::cout << "SDL ERROR!";

    // Create the Window
    int w = 1000, h = 700;  
    int bpp = 32;

    SDL_Surface* Screen = SDL_SetVideoMode( w, h, bpp, SDL_OPENGL | 

    if( !Screen )std::cout << "SDL ERROR!";

    // Check if BitSize's are correct (they are not)
    // I'm using glGetInteger, but SDL_GL_GetAttribute yields the same output.
    glGetIntegerv( GL_ACCUM_RED_BITS, &BitSize );
    std::cout << "AccumBuffer color component size in bits is " << BitSize << "\n";

    glGetIntegerv( GL_RED_BITS, &BitSize );
    std::cout << "ColorBuffer color component size in bits is " << BitSize << "\n";

    ErrorCode = SDL_GL_GetAttribute( SDL_GL_BUFFER_SIZE, &BitSize );
    std::cout << "FrameBuffer BitSize is " << BitSize << "\n";

    if( ErrorCode < 0 )std::cout << "SDL ERROR!";
    if( glGetError() != GL_NO_ERROR )std::cout << "GL ERROR";

    return 0;

This compiles fine, and always prints the following output:

AccumBuffer color component size in bits is 16
ColorBuffer color component size in bits is 8
FrameBuffer Bit Size is 32

no matter what I set the BitSize variable to. It's like the SDL_GL_SetAttribute( SDL_GL_*_SIZE, int ) aren't having any effect. I can understand the Color Buffer components might be restricted to 8 bits because I initialize the window with 32 bpp. But shouldn't I be able to edit the Accumulation Buffer color resolution?

preguntado el 01 de febrero de 12 a las 14:02

2 Respuestas

The attribute values you set are only requests for what you expect as a minimum, but it is perfectly valid to give you something larger.

BTW: The accumulation buffer is probably not HW accelerated, unless you have a professional grade GPU (FireGL, Quadro). Use a Framebuffer Object instead.

Respondido 01 Feb 12, 21:02

Accumulation buffer bit depths are also restricted to what the GPU supports, and in your case, it looks your GPU only supports a 16-bit per component accumulation buffer.

Respondido 01 Feb 12, 20:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.