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

Author Topic: [solved] sf::RenderTexture is inverted  (Read 2474 times)

0 Members and 1 Guest are viewing this topic.

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
[solved] sf::RenderTexture is inverted
« on: August 24, 2013, 07:16:31 am »
Edit : found the solution ><

int main() {
    sf::Sprite runner;
    sf::Texture text;
    text.loadFromFile("textures.png");
    runner.setTextureRect(sf::IntRect(0,0,32,32));
    runner.setTexture(text);
    runner.setPosition(sf::Vector2f(0,0));

    sf::RenderTexture scene;
    scene.create(800,600);

    scene.draw(runner);

    sf::RenderWindow window(sf::VideoMode(800, 600), "My window");

    // run the program as long as the window is open
    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }

        sf::Sprite spr;
        spr.setTexture(scene.getTexture());

        window.clear();
        window.draw(spr);
        window.display();
    }
}

Of course everything is fine if I directly draw the sprite on window

I'm using Ubuntu but I've report of the same thing with my previous game on windows
« Last Edit: August 24, 2013, 07:29:22 am by Lo-X »

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
Re: Urgent : sf::RenderTexture is inverted
« Reply #1 on: August 24, 2013, 07:22:48 am »
Oh my god I just forgot to display()...
Coding between 3:00am and 7:00am is not a good idea...

solved :p