SDL/opengl 多重采样不起作用

发布于 2024-10-12 11:16:01 字数 864 浏览 7 评论 0原文

我正在尝试使用 SDL/opengl 进行多重采样,但 SDL 不接受设置 SDL_MULTISAMPLEBUFFERS 和 SDL_MULTISAMPLESAMPLES。相反,这些值保留为 0,之后 SDL_SetVideoMode() 将失败。我知道我的硬件可以通过 4 倍多重采样来实现这种像素格式。我运行的是 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 );

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪漫之都 2024-10-19 11:16:01

添加这些测试:

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

观察您的 stderr 输出。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文