I am experimenting with the new beta version of SDL2 and the OpenGL3 context, and I have a strange problem:
If I run the SDL initialization code in my main () function, it works fine, but I want this code to be executed in the separete init_sdl () function.
If I put the initialization code in a separate init_sdl () function and call this function from main (), the background color will never be drawn, and the program will start to absorb all my system resources insanely.
Can someone point me to a working example where the SDL is initialized in a separate function? It seems I canβt find ... Maybe this is impossible? I think I vaguely remember that I had a similar problem with SDL 1.2, but several years have passed since I used this, and I donβt think I have ever found a solution. In fact, this may be the reason I decided to switch to using SFML.
I really want to use SDL2 instead of SFML, because it works on other platforms, but the inability to split things up into small functions is an interruption for me. It should be easy. Am I missing something obvious?
Edit:
It works:
#include <iostream>
This does not work:
#include <iostream>
Defcronyke
source share