I just found out the hard way that any SDL_GL_SetAttribute()
calls that affect the OS pixel-format, e.g. frame buffer, depth buffer, stencil buffer, etc., must be made before the call to SDL_CreateWindow()
, because the OS pixel-format is only evaluated once, at that time, and not during SDL_GL_CreateContext()
.
The samples I’ve based my code on (here, here, and here) either don’t do this consistently, or don’t set any OpenGL attributes that affect the pixel format.
Was this documented somewhere? I had to incorporate SDL2 as a sub-project of my CMake solution, and put breakpoints in the code that set up the OS pixel format, to figure this out. (But at least my stenciling now works in MS Windows and Linux.)