SDL/opengl multisampling not working

被刻印的时光 ゝ 提交于 2020-01-14 03:41:11

问题


I'm trying to do multisampling with SDL/opengl but SDL won't accept setting SDL_MULTISAMPLEBUFFERS and SDL_MULTISAMPLESAMPLES. Instead these are left at 0 and SDL_SetVideoMode() will fail afterwards. I know my hardware can do this pixel format with 4x multisampling. I'm running Ubuntu 10.10.

Code:

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 );

回答1:


Add those tests :

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

and

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;
}

then watch your stderr output.



来源:https://stackoverflow.com/questions/4683094/sdl-opengl-multisampling-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!