SDL2 does not actually create an OpenGL context without requesting it. However, if you ask him to create an OpenGL context when OpenGL does not work at all, SDL2 is like, erm, freestyle a bit. (The actual reason is that it does a poor job of checking for errors, so if X does not create an OpenGL context, it assumes this is because the context has already been created)
So, to answer the third question ("how to get around this problem"), you must fix OpenGL before trying to use it. The numbers, right?
To answer the first and second, well, API API I know about ... but you can do it a little differently:
SDL_Window* window = NULL; SDL_GLContext* context = NULL; // NOTE: This is a pointer! ... int main(int argc, char** argv) { // Stuff here, initialize 'window' *context = SDL_GL_CreateContext(window); // More stuff here if (context) { // context is initialized!! yay! } return 2; // Just to confuse people a bit =P }
source share