Greetings everyone.
I have integrated SFML in my project development that uses some RenderTextues, Sprites,... and when try it t run in fullscreen, the entity that stores the RenderTexture is destroyed, cause some sort of flickering in the screen.
For 1-2 frames, the screen goes black and then return to normal. Trying to reproduce this problem, I've discovered what causes this comportament but not why.
In the following code, I find that when a RenderTexture is destroyed (out of scope/delete), the problem appears.
My specs are Win 7 64 bits, Nvidia 560Ti (driver version 320.49 WHQL), i5 2500k.
#include <iostream>
#include <SFML\Graphics.hpp>
#include <SFML\Window.hpp>
int main()
{
sf::RenderWindow App(sf::VideoMode(640, 480, 32), "SFML Test", sf::Style::Fullscreen);
App.setFramerateLimit(60);
sf::RectangleShape rect(sf::Vector2f(300,300));
rect.setFillColor(sf::Color::White);
rect.setPosition(170, 100);
sf::RenderTexture *tex_ptr = NULL;
while (App.isOpen())
{
sf::Event Event;
while (App.pollEvent(Event))
{
// Close Window
if (Event.type == sf::Event::Closed)
return 1;
if (Event.type == sf::Event::KeyPressed)
{
// Exit
if (Event.key.code == sf::Keyboard::Escape)
return 1;
// Each time F1 is pressed, screen goes black in some sort flickering
if (Event.key.code == sf::Keyboard::F1)
{
sf::RenderTexture tex;
tex.create(200,200);
}
// Each time F2 is pressed, screen goes black in some sort flickering
if (Event.key.code == sf::Keyboard::F2)
{
tex_ptr = new sf::RenderTexture();
tex_ptr->create(200,200);
delete tex_ptr; // if this line is commented, does not flick
}
}
}
App.clear();
App.draw(rect);
App.display();
}
return 0;
}