| Summary: | Multisampling does not work. | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Andrew Exo <andrewexo> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED ABANDONED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | amaranth72, BurnSpamAddress, gabomdq, philipp.wiesemann |
| Version: | 2.0.1 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
Are you calling SDL_GL_SetAttribute before or after SDL_CreateWindow? On Linux/X11 you might have to call them before, when setting the multisample parameters. I am calling SDL_GL_SetAttribute before SDL_CreateWindow. Here is my full initialization code:
// Initialize SDL
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
{
fprintf(stderr, "SDL initialization failed: %s\n", SDL_GetError());
return false;
}
// OpenGL settings
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 4 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 2 );
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_DEPTH_SIZE, 24 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 16 );
SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );
// create SDL window
if((window = SDL_CreateWindow("Final Project",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
xres,yres,
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE)) == NULL)
{
fprintf(stderr, "Create window failed: %s\n", SDL_GetError());
return false;
}
// create GL Context
if((gl_context = SDL_GL_CreateContext(window)) == NULL)
{
fprintf(stderr, "Create GL context failed: %s\n", SDL_GetError());
return false;
}
if(!GLEW_VERSION_4_2)
{
fprintf(stderr, "Insuffcient GL version!\n");
return false;
}
// Initialize GLEW
glewExperimental = GL_TRUE;
glewInit();
glEnable(GL_DEPTH_TEST);
glFrontFace(GL_CW);
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_3D);
glEnable(GL_TEXTURE_2D);
glEnable(GL_MULTISAMPLE);
I accidentally swapped these two code fragments in my other comment. Obviously glew has to be initialized before you can check the glew version.
// This is first
glewExperimental = GL_TRUE;
glewInit();
// This is second
if(!GLEW_VERSION_4_2)
{
fprintf(stderr, "Insuffcient GL version!\n");
return false;
}
Related? https://bugzilla.libsdl.org/show_bug.cgi?id=2281 It may be that the current way of getting/setting certain attributes SDL uses just doesn't work with newer contexts. Two possible causes: 1. (unlikely) The OpenGL driver does not advertise WGL_ARB_multisample. 2. (more likely) wglChoosePixelFormatARB fails to find a pixel format with 16x AA. Here is what SDL is doing internally (https://hg.libsdl.org/SDL/file/2e4f1bd21196/src/video/windows/SDL_windowsopengl.c): pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs); [...] if (!pixel_format) { pixel_format = WIN_GL_ChoosePixelFormat(hdc, &pfd); } If the ARB call fails to find a matching pixel format (e.g. 16x AA is not supported), SDL will fall back to old-style PFD format selection which does not support AA at all. In the native (non-SDL) backend for OpenTK, I reduce requested parameters in a loop until a matching mode is found. This way, if the user requests 32x AA and his card supports only 4x he will get 4x, whereas the current SDL implementation will give 0x. SDL actually implements a similar minimization strategy inside WIN_GL_ChoosePixelFormat, but it does not apply the same logic in WIN_GL_ChoosePixelFormatARB. It might be worth adding the same logic to the latter. Hello, and sorry if you're getting dozens of copies of this message by email. We are closing out bugs that appear to be abandoned in some form. This can happen for lots of reasons: we couldn't reproduce it, conversation faded out, the bug was noted as fixed in a comment but we forgot to mark it resolved, the report is good but the fix is impractical, we fixed it a long time ago without realizing there was an associated report, etc. Individually, any of these bugs might have a better resolution (such as WONTFIX or WORKSFORME or INVALID) but we've added a new resolution of ABANDONED to make this easily searchable and make it clear that it's not necessarily unreasonable to revive a given bug report. So if this bug is still a going concern and you feel it should still be open: please feel free to reopen it! But unless you respond, we'd like to consider these bugs closed, as many of them are several years old and overwhelming our ability to prioritize recent issues. (please note that hundred of bug reports were sorted through here, so we apologize for any human error. Just reopen the bug in that case!) Thanks, --ryan. |
Setting the multisampling attributes: SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4 ); and enabling GL_MULTISAMPLE: glEnable(GL_MULTISAMPLE); has no effect. The window and context are both created without error, but multisampling does not happen. Searching the internet for a solution only lead to finding other users with the same problem. My video card is an ATI Radeon HD 5870 so it definitely supports multisampling.