GLdouble angleMZ = 0;
GLdouble angleMX = 0;
int ExampleFramerateSFML_Mono()
{
sf::ContextSettings settings(24, 8, 4, 3, 0);
sf::RenderWindow* window = new sf::RenderWindow(sf::VideoMode(640, 480),"OpenGL Base", sf::Style::Default, settings);
window->setFramerateLimit(60);
glViewport(0, 0, window->getSize().x, window->getSize().y);
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective(70,(double)640/480,1,1000);
glMatrixMode( GL_MODELVIEW );
glEnable(GL_DEPTH_TEST);
DrawCube(angleMX, angleMZ);
sf::Clock clock;
bool running = true;
while (running)
{
sf::Event event;
while (window->pollEvent(event))
{
switch(event.type)
{
case sf::Event::Closed:
running = false;
break;
}
}
sf::Time elapsed = clock.restart();
int elapsed_ms = elapsed.asMilliseconds();
angleMZ += 0.05 * elapsed_ms;
angleMX += 0.05 * elapsed_ms;
DrawCube(angleMX, angleMZ);
window->display();
}
window->close();
delete window;
return 0;
}
GLdouble angleTZ = 0;
GLdouble angleTX = 0;
void ThreadDrawingT(sf::RenderWindow* window)
{
window->setActive(true);
glViewport(0, 0, window->getSize().x, window->getSize().y);
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective(70,(double)640/480,1,1000);
glMatrixMode( GL_MODELVIEW );
glEnable(GL_DEPTH_TEST);
DrawCube(angleTX, angleTZ);
sf::Clock clock;
while(window->isOpen())
{
sf::Time elapsed = clock.restart();
int elapsed_ms = elapsed.asMilliseconds();
angleTZ += 0.05 * elapsed_ms;
angleTX += 0.05 * elapsed_ms;
DrawCube(angleTX, angleTZ);
window->display();
}
}
int ExampleFramerateSFML_Multi()
{
XInitThreads();
sf::ContextSettings settings(24, 8, 4, 3, 0);
sf::RenderWindow* window = new sf::RenderWindow(sf::VideoMode(640, 480),"OpenGL Base", sf::Style::Default, settings);
window->setFramerateLimit(60);
window->setActive(false);
std::thread* thread = new std::thread(ThreadDrawingT, window);
bool running = true;
while (running)
{
sf::Event event;
while (window->pollEvent(event))
{
switch(event.type)
{
case sf::Event::Closed:
running = false;
break;
}
}
}
window->close();
thread->join();
delete thread;
delete window;
return 0;
}