Btw, I now realize that you’re attempting to execute SDL-specific functions before SDL is initialized. You need to initialize SDL before doing any SDL-specific operations and before executing any SDL-specific functions.
So my recommendation is that, at the startup of the program, create everything in the following order:
- Initialize SDL by exeuting
SDL_Init();
- Create the SDL window by executing
SDL_CreateWindow();
- Create the SDL renderer by executing
SDL_CreateRenderer();
- Create the texture(s) and other data.
Don’t forget to do error checking when creating stuff. SDL_GetError();
will help you a lot.
Note: when pasting code into a post here on the forum, you need to highlight all your code and then embed it into a code block by pressing the </>
button. By doing this, the whole code is embedded into a code block and will be much easier to read.