Sdl slow init and init issues, c++

Hello, I’m trying to make a simple application and I got stuck.
I have an issue when I use SDL_Init(SDL_INIT_EVERYTHING) it takes 2 minutes to load everything , altough the cpu is standing at 0% in the application when running and after 2 minutes it starts working.
And when I try only to init SDL_INIT_VIDEO , it is immediately shows the screen though it’s not responding.
CODE :
#include
#define SDL_MAIN_HANDLED
#include “SDL.h”

int main()
{
	SDL_Init(0);
	SDL_Init(SDL_INIT_VIDEO);
	SDL_Window *window = SDL_CreateWindow("Game", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 600, 480, SDL_WINDOW_SHOWN);
	if (window == NULL)
		return 1;
	SDL_Event event;
	bool running = true;
	while (running) {
		while (SDL_PollEvent(&event)) {
			switch (event.type) {
				case SDL_QUIT:
					running = false;
					break;
			}
		}
	}
	SDL_Quit();
	std::cout << "Hello :)" << std::endl;
	return 0;
}

Firstly, I find it strange that you are calling SDL_Init(0), and then SDL_Init(SDL_INIT_EVERYTHING). You should remove the SDL_Init(0) line. You should also wrap the return of SDL_Init() to see if it says anything.

if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
  puts(SDL_GetError());
}

If you choose to use SDL_Init(0), you must use subsequent calls to SDL_InitSubSystem(), NOT SDL_Init().

1 Like