SFML community forums

Bindings - other languages => Java => Topic started by: Hopuranium on December 24, 2017, 04:14:34 pm

Title: RenderTexture won't clear when moving the view of the renderTexture
Post by: Hopuranium on December 24, 2017, 04:14:34 pm
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.
Title: Re: RenderTexture won't clear when moving the view of the renderTexture
Post by: Hopuranium on December 24, 2017, 07:35:12 pm
I resolve the problem by drawing a RectangleShape. ;) but it's not a real solution :o
Title: Re: RenderTexture won't clear when moving the view of the renderTexture
Post by: eXpl0it3r on December 24, 2017, 08:42:53 pm
Make sure your sprite's texture rect is the correct size.