1
Java / RenderTexture won't clear when moving the view of the renderTexture
« on: December 24, 2017, 04:14:34 pm »
Hello crab people ,
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:
Inside the function that render sprites in the RenderTexture:
Then in the RenderWindow main function:
The problem is that the RenderTarget seems to not clear all the space. Then it let the previous drawings, and the next ones.
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);
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();
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();
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.