Thank you guys for your answers, I was able to recreate the program in c++ with the following code I think the problem arises after adding a ContextSettings to the RenderTextures (is antialiasing not supported on textures?)
//g++ -Wall -o "%e" "%f" -I. -L. -lsfml-graphics-2 -lsfml-window-2 -lsfml-system-2
#include "SFML/Graphics.hpp"
#include <iostream>
void displaytex(sf::RenderTexture *tex){tex->display();}
void clear(sf::RenderTarget *target){target->clear(sf::Color(255,255,255,0));}
void drawsprite(sf::Sprite *sprite, sf::RenderTarget *target, int x, int y){
if(x!=0 || y!=0) sprite->setPosition(x,y);
target->draw(*sprite);
}
int main(){
sf::ContextSettings settings;
settings.antialiasingLevel = 8;
sf::CircleShape shape(50.f);
shape.setFillColor(sf::Color(100, 250, 50, 155));
shape.setPosition(0,0);
sf::CircleShape shape2(50.f);
shape2.setFillColor(sf::Color(250, 100, 50, 155));
shape2.setPosition(100,0);
sf::RenderWindow window(sf::VideoMode(800, 600), "My window", sf::Style::Default, settings);
auto mainlayer = new sf::RenderTexture();
mainlayer->create(800,600, settings);
auto layer1 = new sf::RenderTexture();
layer1->create(800,600, settings);
while (window.isOpen()){
sf::Event event;
while (window.pollEvent(event)){
if (event.type == sf::Event::Closed)
window.close();
if (event.type==sf::Event::MouseMoved) {
std::cout << "mouse moved" << std::endl;
clear(mainlayer);
clear(layer1);
layer1->draw(shape); //drawing lots of things
layer1->draw(shape2); //drawing lots of things
displaytex(layer1);
sf::Sprite *sprite1=new sf::Sprite(layer1->getTexture());
drawsprite(sprite1,mainlayer,0,0);
}
}
window.clear(sf::Color(200,200,200,255));
mainlayer->display();
sf::Sprite sprite(mainlayer->getTexture());
window.draw(sprite);
window.display();
}
return 0;
}
I am still not sure what I am doing wrong, on update I clear, draw and display the textures. What would you change?