Hi guys, I'm fairly new to c++ and I've been using the SFML 2.0 API for about a week now. The brilliant documentation has got me quite far and yesterday I started trying to build a little Mandelbrot Set explorer. All I have done so far is to get the algorithm to draw the set and send it to a renderwindow (I include a picture of the results). The next step is to start to package it up into a more object oriented framework and add zoom and scroll features, here I'm stumbling at the first hurdle. The code which sends the image to the renderwindow looks something like this at the moment:
sf::RenderWindow window( sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32), "MandelBrot Set!");
sf::Texture texture;
sf::Sprite sprite;
sf::image image(SCREEN_WIDTH, SCREEN_HEIGHT, sf::Color::White);
for(unsigned i=0; i<SCREEN_WIDTH; ++i)
{
for(unsigned j=0; j<SCREEN_HEIGHT; ++i)
{
// calculate color for each pixel here using image.SetPixel(i,j,sf::Color)
}
}
image.SaveToFile("some_directory.png");
texture.LoadFromFile("some_directory.png");
sprite.SetTexture(texture);
window.draw(sprite);
window.display();
//then some display loop
So my question is: Do I have to save the image to disk before i can access it with a texture? I cant see any way around it from just reading the stuff in the documentation. I never used 1.6 but I gather from various tutorials and such that this used to be possible by passing an image directly to a sprite, the image seems to be more abstract in 2.0.
Thanks.
Edit: Forgot the image..
http://postimg.org/image/w3azfoju3/