Hi there,
I have great faith in SFML, but I think I may actually have found a bug :shock:
I'm creating a black rectangle and trying to turn it white retroactively. I stubbornly remains black. SetColor() doesn't seem to be working!
Here the minimal code:
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
int main()
{
//Create the main Window
sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Michael Jackson!");
//Create a black rectangle
sf::Shape mj;
mj = sf::Shape::Rectangle(0,0,128,128,sf::Color(0,0,0));
//attempt to change the rectangle's colour to white
mj.SetColor(sf::Color(255,255,255));
//Create Event handler
sf::Event event;
//Start main loop
bool running = true;
while (running)
{
//Read each Event, store in 'event' and treat
while (window.GetEvent(event))
if(event.Type == sf::Event::Closed || event.Type == sf::Event::KeyPressed)
running = false;
//Clear the Windows
window.Clear(sf::Color(200, 0, 0));
//Draw the rectangle
window.Draw(mj);
//Redraw the Window
window.Display();
}
//Destroy the Window
window.Close();
return EXIT_SUCCESS;
}
In actual fact I'm doing stuff a lot trickier than this, but the problem is still visible in this dumbed-down version: the rectangle is created black, and refuses to change colour!
Is this is bug or is it my code? I just don't see what I could be doing wrong when there's so little of it...
William