Ive been just readin about Game Loops and stuff a while ago. And it comes to that is totally right some article that ive readed in that time that they say that the graphics should be totally separated from event manager.
Reasons?
It wont care if your machine its really slow generating graphics, your Event response will be the same anyway.
The fact is that i really wanted to take advantage of that.
How?
Making this
And it wont work -_-
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(1024, 768, 32), "Teh Game");
bool appRuning = true;
void ThreadFunction(void* UserData)
{
sf::Event Event;
while (appRuning)
{
if (Event.Key.Code == sf::Key::F1)
{
appRuning = false;
}
}
}
////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
// Create a thread with our function
sf::Thread Thread(&ThreadFunction);
// Start it !
Thread.Launch();
sf::Image imgIntroLogo;
imgIntroLogo.LoadFromFile("images/introLogo.png");
sf::Sprite sprIntroLogo(imgIntroLogo);
// Hides original SO mouse cursor
App.ShowMouseCursor(false);
// Disable vertical synchronization to get maximum framerate
App.UseVerticalSync(true);
// Start game loop
while (appRuning)
{
// Clear the screen with red color
App.Clear(sf::Color(255,0,255));
// Draw teh Logo
App.Draw(sprIntroLogo);
}
return EXIT_SUCCESS;
}
Why this dosnt works?
Btw, the problem is that it wount take any event. Ive tried in so much ways, it dosnt want to work!