Jackson
Jackson

Reputation: 33

Very slow startup using SDL 2 on OS X 10.8

Even using the most basic SDL test, when I run the output file after compiling, I get a pinwheel for about 8 seconds, and then the program starts.
This doesn't happen if I don't use SDL.
I have tried both clang and g++ with the same results.

#include <iostream>
#include <SDL2/SDL.h>

int main(int argc, char **argv){
    if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
        std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
        return 1;
    }

    SDL_Quit();
    return 0;
}

Is this normal, or is there a way to fix this? It's really annoying for quickly testing :(

Upvotes: 2

Views: 1302

Answers (1)

nick.amor
nick.amor

Reputation: 192

I've found initializing the joysticks tends to take a long time across multiple platforms.

My solution is to initialize just the video to begin with, then later initialize other stuff separately.

SDL_Init(SDL_INIT_VIDEO);

// You can create your window and display a splash screen here

SDL_InitSubSystem(SDL_INIT_JOYSTICK);
SDL_InitSubSystem(SDL_INIT_AUDIO);

Upvotes: 5

Related Questions