2

I am using windows 10 and sdl2. The SDL_INIT_GAMECONTROLLER flag must be initted or execution will not start. Here's some code from main (see the bottom comment at the gamecontroller init call):

SDL_Init(SDL_INIT_VIDEO);
int imgFlags = IMG_INIT_PNG;
if(!( IMG_Init(imgFlags) & imgFlags)) {
  printf( "SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError() );
  return 0;
}

SDL_ShowCursor(SDL_DISABLE);



SDL_Window* window = NULL;
window = SDL_CreateWindow("Anica", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, W, H,
                            SDL_WINDOW_SHOWN);
SDL_Renderer* renderer = NULL;
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);

SDL_InitSubSystem(SDL_INIT_AUDIO);
SDL_InitSubSystem(SDL_INIT_EVENTS);
SDL_InitSubSystem(SDL_INIT_TIMER);
// If this sub system is not initted execution stops. If it is initted
// execution works fine. It takes 2-3 seconds for this call to finish which
// is really slow.
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);

The window open and hangs until the gamecontroller init call is done (2-3 seconds) if the gamecontroller subsystem is initted. Then everything works fine. If the gamecontroller subsystem is not initted the window opens and hangs indefinitely.

I am using windows 10 if that makes any difference.

My partner does not have this issue using the same code on windows 10, which is confusing to both of us.

genpfault
  • 51,148
  • 11
  • 85
  • 139
shell
  • 1,867
  • 4
  • 23
  • 39
  • 2
    Does it happen with SDL 2.0.8? Or only 2.0.9? – genpfault Feb 15 '19 at 19:57
  • 2
    If genpfault guessed right, then it's probably a dupe of https://stackoverflow.com/questions/54469705/sdl-init-slows-the-program-while-code-is-correct-and-has-run-perfectly-before#comment95747857_54469705 – HolyBlackCat Feb 15 '19 at 20:02
  • I'm using SDL 2.0.9. – shell Feb 15 '19 at 20:05
  • Possible duplicate of [SDL\_PollEvent() stuttering while idle?](https://stackoverflow.com/questions/53644628/sdl-pollevent-stuttering-while-idle) – genpfault Feb 15 '19 at 20:51

1 Answers1

2

Going from SDL 2.0.9 to 2.0.8 fixed the problem for me.

Thanks to the comments on the question for helping.

shell
  • 1,867
  • 4
  • 23
  • 39