You can try something: replace the RenderWindow with this:
sf::Context context;
If it still produces the error, try to move it after "rtexture.create".
(this is just some debug stuff to help me figure out what happens)
int main(int argc, char** argv)
{
using namespace sf;
/*
RenderWindow rWindow(sf::VideoMode(640,480), "Test",
Style::Close | Style::Titlebar, ContextSettings());
rWindow.clear(Color::Blue);
rWindow.display();
*/
Context context;
RenderTexture rTexture;
rTexture.create(800,600);
rTexture.clear(Color::Black);
rTexture.display();
rTexture.getTexture().copyToImage().saveToFile("test.png");
/*
rWindow.clear(Color::Blue);
rWindow.display();
*/
}
Causes screen to flicker black, locks up OS and ultimately forces me to restart (complete crash and unresponsive).
int main(int argc, char** argv)
{
using namespace sf;
/*
RenderWindow rWindow(sf::VideoMode(640,480), "Test",
Style::Close | Style::Titlebar, ContextSettings());
rWindow.clear(Color::Blue);
rWindow.display();
*/
RenderTexture rTexture;
Context context;
rTexture.create(800,600);
rTexture.clear(Color::Black);
rTexture.display();
rTexture.getTexture().copyToImage().saveToFile("test.png");
/*
rWindow.clear(Color::Blue);
rWindow.display();
*/
}
Works as expected.
#include <SFML/Graphics.hpp>
int main(int argc, char** argv)
{
using namespace sf;
RenderWindow rWindow(sf::VideoMode(640,480), "Test",
Style::Close | Style::Titlebar, ContextSettings());
rWindow.clear(Color::Blue);
rWindow.display();
RenderTexture rTexture;
Context context;
rTexture.create(800,600);
rTexture.clear(Color::Black);
rTexture.display();
rTexture.getTexture().copyToImage().saveToFile("test.png");
rWindow.clear(Color::Blue);
rWindow.display();
}
Testing this one now, wrote this before testing it so be back in a sec if it crashes.Seems to work this way. No crashes, no errors. Testing it with my actual code now.
Strange, getting flash&crash in actual code again.