[SDL] Problem to display texture correctly

Beoran beoran at gmail.com
Thu Jul 28 23:02:15 PDT 2011


Dear Cyrille, 

First of all, you should check if the texture is created properly. 
if (!video_texture) { 
 printf("Creation of video texture failed: %s\n", SDL_GetError());
 SDL_Quit();
 exit(1); 
}

Next, in stead of calling 
SDL_RenderCopy(m_sdl_renderer, video_texture, NULL,NULL); 
With NULL, NULL

You may want to pass in two SDL_Rect rectangles to control more precisely the drawing of the texture.
{
SDL_Rect src_rect = { 0, 0, 440, 445 } 
SDL_Rect dst_rect = { 0, 0, 440, 445 } 
SDL_RenderCopy(m_sdl_renderer, video_texture, &dst_rect, &src_rect); 
SDL_RenderPresent(m_sdl_renderer); 
}

Finally, it's going to be very slow if you create and destroy such a big texture all the time
whilst drawing, so I don't see why you need the SDL_DestroyTexture there, especially if you are in
a drawing loop.

Kind Regards, 

B.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20110728/351107dc/attachment-0008.htm>


More information about the SDL mailing list