I tried using the 'sf::Texture::update(Window&)' method for applying post-effects. Initially it works fine, but if the window is re-sized the 'top image' get distorted.
#include <iostream>
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
using namespace std;
int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(500, 500), "SFML window");
sf::Texture texture01;
texture01.loadFromFile("sfml-big.png");
sf::Sprite sprite01(texture01);
sf::Texture texture02;
sf::Sprite sprite02;
sf::Shader shader;
shader.loadFromFile("colorize.sfx", sf::Shader::Fragment);
// Start the game loop
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close window : exit
if (event.type == sf::Event::Closed)
window.close();
}
// Clear screen
window.clear();
window.draw(sprite01);
texture02.create(window.getSize().x, window.getSize().y);
texture02.update(window);
sprite02.setTexture(texture02);
window.draw(sprite02, &shader);
// Update the window
window.display();
}
return EXIT_SUCCESS;
}