title: A method to rotate a texture in SDL2, C++
body: <p>I have a Texture class which allows me to load images and render them.
  It has the following attributes:</p>
  
  <pre><code>private:
     SDL_Texture *m_texture; ///The actual texture
     int m_width; ///Its width
     int m_height; ///Its height
  </code></pre>
  
  <p>I wanted to create a method to rotate the texture by an angle. And here's what I've done :</p>
  
  <pre><code>void Texture::rotation( SDL_Renderer *renderer, float angle )
  {
     //Target texture to render to
     SDL_Texture *target = SDL_CreateTexture( renderer, SDL_PIXELFORMAT_RGBA4444, SDL_TEXTUREACCESS_TARGET, m_width, m_height );
     //Set the target texture for rendering
     SDL_SetRenderTarget( renderer, target );
     //Render m_texture to the target texture with an angle
     SDL_RenderCopyEx( renderer, m_texture, NULL, NULL, angle, NULL, SDL_FLIP_NONE );
     //Detach the target texture
     SDL_SetRenderTarget( renderer, NULL );
     //Save texture
     SDL_DestroyTexture( m_texture );
     m_texture = target;
  }
  </code></pre>
  
  <p>However, it doesn't quite work :</p>
  
  <ol>
  <li>Transparency is lost ( it becomes black ).</li>
  <li>Only a part of the texture is kept because the dimensions for the transformed texture should not be the initial m_width and m_height.</li>
  </ol>
  
  <p>I can't simply rotate the texture when rendering because of many reasons such as the collision detection and the efficiency. So, how should I do it ?</p>