SFML community forums

Help => Graphics => Topic started by: gsaurus on February 23, 2010, 12:51:29 am

Title: [SFML 2] explicit Bind?
Post by: gsaurus on February 23, 2010, 12:51:29 am
I'm finally trying sfml2.
By accident, I got a sprite being drawn in white instead of it's original image.

(http://img521.imageshack.us/img521/5418/49246500.png)


I reproduced it this way:

Code: [Select]
#include <SFML\Graphics.hpp>

int main(){
    sf::RenderWindow App(sf::VideoMode(200, 200, 32), "press key for white picture!");

    sf::Image img;

    while (App.IsOpened()){
        sf::Event Event;
        while (App.GetEvent(Event)){
            if (Event.Type == sf::Event::Closed) App.Close();            
            if (Event.Type == sf::Event::KeyPressed){
                img.LoadFromFile("paddle_right.png");
            }
        }

        App.Clear();
        App.Draw(sf::Sprite(img));
        App.Display();
    }

    return EXIT_SUCCESS;
}


The image is from the pong example.
The same code works with SFML 1.6.
Calling img.Bind() after loading solves it. Am I supposed to explicitly call Bind?
Title: [SFML 2] explicit Bind?
Post by: Laurent on February 23, 2010, 08:40:19 am
Thanks, I'll try to fix it today :)
Title: [SFML 2] explicit Bind?
Post by: Laurent on February 25, 2010, 08:06:52 pm
It should work now.