Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Post-effect problem  (Read 1586 times)

0 Members and 1 Guest are viewing this topic.

kaB00M

  • Full Member
  • ***
  • Posts: 101
    • View Profile
    • Caffeware
    • Email
Post-effect problem
« on: January 12, 2013, 12:01:09 am »
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;
}
 



Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Post-effect problem
« Reply #1 on: January 12, 2013, 09:14:16 am »
Try this:
sprite02.setTexture(texture02, true);
Laurent Gomila - SFML developer