Hello
Again toying with fresh built sfml2rc I've encountered strange problem that was non existing in previous built(RC built on April 12th).
It might not be best practice but nonetheless this is what I am using at the moment:
Thread one - event pulling;
Thread two - drawing and calculating;
with old build of sfml everything ran smooth and fast. However with fresh one it seems like window is not "in focus" by default or something of sort and I have to click/hold on Title bar which will boost fps. After that clicking back and forth on different windows(chrome/VS) causes similar thing, although clinking away from window boosts fps and clicking into Drawing area of render window slaps it down.
this happens in "SFML-2.0-rc-69-ge4ea686" build on W7x64, in both VS10 and VS11 each with their own built ddls, most recent nVidia WHQL drivers. I can not confirm which release is the one that works fine, only date it was build on(and downloaded) - April 12th.
This does not happen if i put drawing in same thread as event pulling
Problem occurs with this code
#include <SFML/Graphics.hpp>
void Draw();
sf::RenderWindow window;
int main()
{
//Initialize window
window.create(sf::VideoMode(1680, 1050),"");
window.setActive(false);
//thread for draw function
sf::Thread RenderThread(&Draw);
RenderThread.launch();
//GameLoop
while(window.isOpen())
{
//Event Handling
sf::Event event;
while(window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
window.close();
if(event.type == sf::Event::KeyPressed)
{
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
window.close();
}
}
}
return 0;
}
void Draw()
{
int counter = 0;
int fps = 0;
sf::Text fpsText;
sf::Clock clk;
sf::Font font;
font.loadFromFile("corbel.ttf");
fpsText.setFont(font);
window.setActive(true);
window.setVerticalSyncEnabled(false);
while(window.isOpen())
{
counter++;
if(clk.getElapsedTime().asSeconds()>=1)
{
fps = counter/clk.getElapsedTime().asSeconds();
counter=0;
clk.restart();
std::string sss;
char tempB[20];
sprintf(tempB, "%d", fps);
sss = tempB;
fpsText.setString(sss);
}
window.clear();
window.draw(fpsText);
window.display();
}
};
I know I am asking a lot of questions, but this really does bother me.