# How do I clear streaming textures in SDL?

I need to clear a streaming texture before I draw into it on the next frame, because only a part is updated, and it's random enough that I can't predict which part will be clear.

I don't want to reinitialize it every time, or rewrite the whole texture each time.

Here is the code I tried, but this fails every time, since the texture is in streaming mode.

SDL_Texture* StreamingTexture = SDL_CreateTexture(render, SDL_PIXELFORMAT_RGBA8888,
SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height);

SDL_SetRenderTarget(render, StreamingTexture);
SDL_SetRenderDrawColor(render, 0, 0, 0, 0);
SDL_RenderClear(render);

• Why are you using a streaming texture? – Tyyppi_77 Oct 11 '16 at 4:44
• This feels like an XY problem. What are you actually trying to do here? – Tyyppi_77 Oct 11 '16 at 18:10
• nah i got it :D – The guy Oct 11 '16 at 21:08
• @Tyyppi_77 Essentially i need to write just few pixels, and i need to clear the texture, otherwise it makes this ghost effect. – The guy Oct 11 '16 at 21:15

SDLX_TextureLockSurface(Texture, Surface);