SFML community forums

Help => Graphics => Topic started by: mrfreeze on May 06, 2016, 12:18:49 am

Title: Clear part of RenderTexture
Post by: mrfreeze on May 06, 2016, 12:18:49 am
I'm making a simcity-style game. I use one big RenderTexture for the terrain and one big RenderTexture for all the roads, so I don't have to iterate through all the tiles every frame. So for the terrain and the roads I only have two sprites and two draw-calls. If the player builds a road, the corresponding sprite (I use an atlas with all possible roadtypes, e.g. horizontal, vertical, corners, crossing, etc.) is drawn on the roads-rendertexture. This works fine.
The problem is when I remove a road, I want to clear that part of the rendertexture with transparant pixels. But since the rendertexture is never 'cleared', how can I do this? I tried drawing a transparant rectangleshape on the rendertexture, but (of course) this draws on top of the current pixels, so nothing happens. How can I 'replace' the pixels on the rendertexture with transparant ones?

Title: AW: Clear part of RenderTexture
Post by: eXpl0it3r on May 06, 2016, 02:08:51 am
Draw a transparent rectangle but us the blend mode: BlendNone
Title: Re: Clear part of RenderTexture
Post by: mrfreeze on May 06, 2016, 09:46:27 am
Thanks! Works like a charm!
I totally forgot about blending  :-[