Hi, I’m developing a sandbox game with SDLv2, and I’ve got to the point where I need to start rendering the first textures (Code below to understand). The function does return 0, but either the texture doesn’t render, the entire program quits normally, or I get a window that can’t listen to events. Here is some information:
TextureLoader(const char* path, SDL_Renderer** WRenderer, SDL_Window** WindowPointer) { // I used to have a pointer to a bool that says whether the window should be closed or not, to free the textures
SDL_Surface* TextureWrapper = IMG_Load(path);
// Usual error checking
SDL_Texture TextureID = SDL_CreateTextureFromSurface(the usual parameters);
// Again checking for errors
SDL_Rect* Rectangles;
SDL_QueryTexture(TextureID, NULL, NULL, &Rectangles->w, &Rectangles->h);
Rectangles->x = 0;
Rectangles->y = 0;
// Here begins the error. If I don't pass an SDL_Rect struct here, it gives me a free dynamic resize. But if I do, the problems begin.
SDL_RenderCopy(*Renderer, TextureID, NULL, Rectangles);
How can I fix that? Maybe I need to change something? If I do, I get warnings, so I don’t even try it. If anybody knows how to make this work, let me know.