#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
// le shape sans texture
sf::RectangleShape rect_sansTexture( { 50 , 50 } );
rect_sansTexture.setFillColor(sf::Color( 255,255,0,100));
// le shape avec texture
sf::Texture texture;
texture.loadFromFile( "senseidoigt.gif");
sf::RectangleShape rect_avecTexture( { 50 , 50 } );
rect_avecTexture.setTexture( &texture );
// le shader
sf::Shader shader;
shader.loadFromFile("clippingMask.frag", sf::Shader::Fragment );
while (window.isOpen()){
window.clear(sf::Color(70,70,70));
// la version sans shader
rect_sansTexture.setPosition (20,20);
rect_avecTexture.setPosition (80,20);
window.draw( rect_sansTexture );
window.draw( rect_avecTexture );
// la version avec shader
sf::RenderStates state;
state.shader = &shader;
shader.setParameter("texture", sf::Shader::CurrentTexture);
rect_sansTexture.setPosition (20,120);
rect_avecTexture.setPosition (80,120);
window.draw( rect_sansTexture , state );
window.draw( rect_avecTexture , state );
window.display();
}
return 0;
}