What happens is that I define code to show a texture part in C ++ with the SDL libraries. Something like this:
#include <SDL.h>
#include <stdio.h>
SDL_Window * ventana;
SDL_Renderer * render;
SDL_Texture * textura;
SDL_Rect tRect1, tRectD1; // Uno selecciona el área de la textura y el otro dónde se va a mostrar.
int main()
{
// ... omitimos la inicialización, crear ventana, contexto y establecer color
while(!salir) // Variable que cuando se vuelva verdad saldrá del bucle
{
while(SDL_PollEvent(&evento)){
// Insertense los eventos que quiera...
}
SDL_RenderClear() // Limpia la pantalla
SDL_RenderCopy(render, textura, &tRect1, &tRectD1); // Función de render
SDL_RenderPresent() // Actualiza la pantalla
}
// Insertese código de cierre
return 0;
}
The problem arises when initializing the structures rect "tRect1" and "tRectD1"; if I initialize them out of the main while -while (! exit) -, the image is not displayed, but, when initializing them inside the loop, if it shows it. Does anyone know why and how can I solve it?
Thanks I remain attentive to any suggestions.