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

Author Topic: RenderTexture won't clear when moving the view of the renderTexture  (Read 11266 times)

0 Members and 2 Guests are viewing this topic.

Hopuranium

  • Newbie
  • *
  • Posts: 6
    • View Profile
Hello crab people :o,

I have an issue when I try to clear a renderTarget because when I want to, the area do not clear everything when I changed the center of the renderTexture position. I apply the texture of the RenderTexture in a sprite.

Inside the function that update the view:
View view = new View();
view.setSize(renderTexture.getView().getSize());
view.setCenter(CENTER);
this.renderTexture.setView(view);
 

Inside the function that render sprites in the RenderTexture:
renderTexture.clear(CLEAR_COLOR);

for (Sprite canvas : canvases)
      renderTexture.draw(canvas);

renderTexture.display();
 

Then in the RenderWindow main function:
Sprite sprite = ....;
sprite.setTexture(renderTarget.getTexture());
//LOOP
//view modifications
... using the first function
//graphics
window.clear();
window.draw(sprite);
window.display();
 

The problem is that the RenderTarget seems to not clear all the space. Then it let the previous drawings, and the next ones.
« Last Edit: December 24, 2017, 04:18:16 pm by Hopuranium »

Hopuranium

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: RenderTexture won't clear when moving the view of the renderTexture
« Reply #1 on: December 24, 2017, 07:35:12 pm »
I resolve the problem by drawing a RectangleShape. ;) but it's not a real solution :o

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: RenderTexture won't clear when moving the view of the renderTexture
« Reply #2 on: December 24, 2017, 08:42:53 pm »
Make sure your sprite's texture rect is the correct size.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything