1
votes

I've got a weird problem that's suddenly appeared across all projects I'm working on. I'm using C++, SDL2 and OpenGL, and one of the first things that happens in my int main is to create an SDL window with an OpenGL flag like below:

int main( int argc, char* args[] )
{
    //Minor stuff here e.g. initialising SDL
    mainwindow = SDL_CreateWindow("...", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL);
}

For some reason this has started to cause a segmentation fault. If I change the flag from SDL_WINDOW_OPENGL to anything else, it does create a window but obviously fails shortly afterwards given the lack of an OpenGL context to do anything with. I've gone as far as to strip out all code except for the SDL and OpenGL initialisation stuff, and it still fails with a segfault error.

This issue has started as of today across two projects that share the same basic int main structure. This leads me to believe it's not a code issue (largely because the code hasn't actually changed), but that something with my setup / environment has gone wrong. So far I've tried the following to no avail:

  • Redownloaded latest SDL library
  • Redownloaded latest GLEW library
  • Reinstalled Codeblocks

Any ideas for a) what might be causing this and b) where I should start looking to fix it?

Thanks

Nathan

1
You do call "SDL_Init(SDL_INIT_VIDEO)"?Santiago Varela
I call SDL_Init(SDL_INIT_EVERYTHING) - also tried with just SDL_INIT_VIDEO (no change), and also verified that SDL has initialised properly with SDL_WasInit - all seems finenathanburns

1 Answers

0
votes

And like so many other problems in life, the answer turned out to be drivers. A system-wide update of some kind interfered with the graphics' ability to render any kind of OpenGL. A direct download and install of the latest graphic drivers fixed it.