#include <iostream>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
int main() {
sf::RenderWindow *window = new sf::RenderWindow(sf::VideoMode(800, 600), "My window");
sf::Texture *backgroundtexture = new sf::Texture();
backgroundtexture->loadFromFile("background.png");
sf::Sprite *backgroundsprite = new sf::Sprite();
backgroundsprite->setTexture(*backgroundtexture);
sf::Image ball;
ball.loadFromFile("ball.png");
ball.createMaskFromColor(sf::Color::White);
backgroundtexture->update(ball, 100, 100);
while (window->isOpen()) {
sf::Event event;
while (window->pollEvent(event)) {
// check the type of the event...
switch (event.type) {
// window closed
case sf::Event::Closed:
window->close();
break;
// we don't process other types of events
default:
break;
}
}
window->clear();
window->draw(*backgroundsprite);
window->display();
}
}
For me run on windows 7 using visual studio 2010 this creates the green background and the ball is updated onto the texture and the white background is turned black.
[attachment deleted by admin]