Hi there!
I am trying to fill a texture with some gray color. My very simple test code crashes... The code:
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(500, 500), "SFML works!");
window.setFramerateLimit(60);
sf::Uint8 pixelBuffer [250000];
sf::Texture texture;
texture.create(500, 500);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
window.close();
if(event.type == sf::Event::KeyReleased && event.key.code == sf::Keyboard::Escape)
window.close();
}
for(int i = 0; i < 249999; i++)
{
sf::Uint8 color = 128;
pixelBuffer[i] = (color << 16) | (color << 8) | color;
}
texture.update(pixelBuffer, 500, 500, 0, 0); //<---- crash happens here
window.clear();
window.draw(sf::Sprite(texture));
window.display();
}
return 0;
}
I get a SIGSEGV fault. I haven't used the
update() method of
sf::Texture before, so I don't really know if I handle everything correct. Does somebody know what I'm doing wrong? I'm using the latest source with MinGW 4.7.2 on windows 7.
Thanks, Foaly