I've just started to testing SDL library. I've notice that SDL_CreateWindow()
is very slow when I set SDL_WINDOW_OPENGL
flag (takes about 10x longer). And I'm talking only about the window creation, not creation of OpenGl context.
Basically this line takes about 55 ms on my machine:
SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_SHOWN);
And this takes about 500 ms:
SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL);
And I feel this is much faster today. Yesterday I't feelt like it took about 2s to show the window (though I didn't measure it)
Is this normal to take so long or am I missing something? I'm also new to OpenGL so I can't even guess what it is doing under the hood.
The thing that takes a long time is loading the OpenGL driver from your graphics card vendor.
I was having a similar issue, so I rebuild SDL with symbols and profiled it. Almost all the time was spent in the ChoosePixelFormat function, which is part of wgl, the windows specific opengl interface. For me, today, with an Nvidia card, it takes a whole second to do this initialization.
There is a nice thread here that describes the issues in more detail:
https://hero.handmade.network/forums/code-discussion/t/2503-%5Bday_235%5D_opengls_pixel_format_takes_a_long_time
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With