Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Clear part of RenderTexture  (Read 833 times)

0 Members and 1 Guest are viewing this topic.

mrfreeze

  • Newbie
  • *
  • Posts: 2
    • View Profile
Clear part of RenderTexture
« 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?

« Last Edit: May 06, 2016, 12:27:18 am by mrfreeze »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
AW: Clear part of RenderTexture
« Reply #1 on: May 06, 2016, 02:08:51 am »
Draw a transparent rectangle but us the blend mode: BlendNone
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

mrfreeze

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Clear part of RenderTexture
« Reply #2 on: May 06, 2016, 09:46:27 am »
Thanks! Works like a charm!
I totally forgot about blending  :-[