SDL/opengl 多重采样不起作用

Posted

技术标签:

【中文标题】SDL/opengl 多重采样不起作用【英文标题】:SDL/opengl multisampling not working 【发布时间】:2011-01-13 17:24:19 【问题描述】:

我正在尝试使用 SDL/opengl 进行多重采样,但 SDL 不接受设置 SDL_MULTISAMPLEBUFFERS 和 SDL_MULTISAMPLESAMPLES。相反,这些保留为 0,然后 SDL_SetVideoMode() 将失败。我知道我的硬件可以使用 4x 多重采样来实现这种像素格式。我正在运行 Ubuntu 10.10。

代码:

SDL_Init( SDL_INIT_VIDEO );
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 0 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 0 );
SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4 );

Uint32 flags;
flags = SDL_OPENGL;
if( m_bFullscreen )

    flags = flags | SDL_FULLSCREEN;

SDL_SetVideoMode( m_sizeX, m_sizeY, 0, flags );

【问题讨论】:

你的显卡和驱动是什么? GF7950GT 与 Linux-x86_64 上的驱动程序 260.19.06 【参考方案1】:

添加这些测试:

if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) 
    fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
    EXIT_FAILURE;

if ( SDL_SetVideoMode(m_sizeX, m_sizeY, 0, flags) == NULL ) 
    fprintf(stderr, "Unable to create OpenGL screen: %s\n", SDL_GetError());
    SDL_Quit();
    EXIT_FAILURE;

然后观察你的标准错误输出。

【讨论】:

以上是关于SDL/opengl 多重采样不起作用的主要内容,如果未能解决你的问题,请参考以下文章