We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3648

Summary: SDL_UpdateTexture from a surface has different content than the creation from the same surface
Product: SDL Reporter: axel mattauch <axel.mattauch>
Component: renderAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.5   
Hardware: x86_64   
OS: Windows 8   
Attachments: Very small test program (#100 lines)

Description axel mattauch 2017-05-12 15:55:58 UTC
Created attachment 2732 [details]
Very small test program (#100 lines)

Hello!

I have created a surface through 
  psurface =  SDL_CreateRGBSurfaceWithFormat
and filled the psurface surface with some color (SDL_FillRect)
Then I created a texture from this surface
  ptexture = SDL_CreateTextureFromSurface(prenderer, psurface)
The rendering (SDL_RenderCopy + SDL_RenderPresent) is OK: the screen displays effectively a surface of the color as defined by the SDL_FillRect.

But in a second step, following immediately, I updated the same texture from the same surface by:
  SDL_UpdateTexture(ptexture, NULL, psurface->pixels, psurface->pitch)
While no execution errors are occuring, the display after rendering (SDL_RenderCopy + SDL_RenderPresent)  has a wrong color.

As I simplified atmost the test sequence, I believe that the problem comes from the SDL_UpdateTexture call. 

Thanks for the help.

Axel Mattauch
Comment 1 axel mattauch 2017-06-23 14:20:30 UTC
This bug is in close relation with #3680.
This 3648 shows only that a texture created by SDL_CreateTextureFromSurface from a give surface is modified by  SDL_UpdateTexture, even if the given surface is not changed.
#3680 shows precisely the problem (and the RGBA --> ARGB tournaround)
Comment 2 axel mattauch 2017-06-29 12:40:22 UTC
(In reply to axel mattauch from comment #1)
> This bug is in close relation with #3680.
> This 3648 shows only that a texture created by SDL_CreateTextureFromSurface
> from a give surface is modified by  SDL_UpdateTexture, even if the given
> surface is not changed.
> #3680 shows precisely the problem (and the RGBA --> ARGB tournaround)

Thus, this topic is closed. (see #3680)