本文整理汇总了C++中sf::Window::close方法的典型用法代码示例。如果您正苦于以下问题:C++ Window::close方法的具体用法?C++ Window::close怎么用?C++ Window::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Window
的用法示例。
在下文中一共展示了Window::close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
void start() {
std::chrono::time_point<std::chrono::system_clock> startTime=std::chrono::system_clock::now();
//Event thread (main thread)
bool running = true;
while (running) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::KeyPressed) {
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) {
window.close();
running=false;
}
}
else if (event.type == sf::Event::Closed) {
window.close();
running = false;
}
}
std::chrono::duration<double> elapsed_seconds = std::chrono::system_clock::now() - startTime;
double time=elapsed_seconds.count();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(0.0, 30.0, -65.0, //Camera position in World Space
0.0, 5.0, 0.0, //Camera looks towards this position
0.0, 1.0, 0.0); //Up
glPushMatrix();
glRotatef(-time*50.0, 0.0, 1.0, 0.0);
glTranslatef(20.0, 0.0, 0.0);
unanimatedAstroBoy.draw();
glPopMatrix();
glPushMatrix();
glRotatef(-time*50.0+90.0, 0.0, 1.0, 0.0);
glTranslatef(20.0, 0.0, 0.0);
astroBoy.drawFrame(time);
glPopMatrix();
glPushMatrix();
glRotatef(-time*50.0+180.0, 0.0, 1.0, 0.0);
glTranslatef(20.0, 0.0, 0.0);
astroBoyMovingGlasses.drawFrame(time);
glPopMatrix();
glRotatef(-time*50.0+270.0, 0.0, 1.0, 0.0);
glTranslatef(20.0, 0.0, 0.0);
astroBoyHeadBanging.drawFrame(time);
//Swap buffer (show result)
window.display();
}
}
示例2: mainEventHandler
void mainEventHandler(sf::Window &window){
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type){
case sf::Event::Closed:
window.close();
break;
case sf::Event::KeyPressed:
keyPressedHandler(event);
break;
case sf::Event::KeyReleased:
keyReleasedHandler(event);
break;
case sf::Event::LostFocus:
/* pause(); */
break;
case sf::Event::GainedFocus:
/* resume(); */
break;
default: break;
}
}
}
示例3: while
void
windowEvents ( sf::Window& window)
{
sf::Event e;
while ( window.pollEvent ( e ) ) {
if ( e.type == sf::Event::Closed ) {
window.close();
}
}
}
示例4: pollEvents
void pollEvents()
{
sf::Event windowEvent;
while (window.pollEvent(windowEvent))
{
switch (windowEvent.type)
{
case sf::Event::Closed:
window.close();
break;
}
}
}
示例5: renderLoop
void renderLoop(sf::Window & window)
{
sf::Clock time;
WorldState state;
while (state.isRunning())
{
this->handleEvents(window, state);
state.timeStep( time.getElapsedTime().asSeconds() );
engine.display(state);
window.display();
}
window.close();
}
示例6: processEvents
void InputHandler::processEvents(sf::Window& window) {
reset();
sf::Event event;
while (window.pollEvent(event)) {
switch (event.type) {
case sf::Event::KeyPressed:
if (key_press_callback_func != nullptr)
key_press_callback_func(event.key);
break;
case sf::Event::KeyReleased:
if (key_release_callback_func != nullptr)
key_release_callback_func(event.key);
break;
case sf::Event::MouseMoved:
m_NewMousePosition.x = event.mouseMove.x;
m_NewMousePosition.y = event.mouseMove.y;
if (mouse_moved_callback_func != nullptr)
mouse_moved_callback_func(event.mouseMove);
m_LastMousePosition.x = event.mouseMove.x;
m_LastMousePosition.y = event.mouseMove.y;
break;
case sf::Event::MouseWheelScrolled:
if (mouse_wheel_scroll_callback_func != nullptr)
mouse_wheel_scroll_callback_func(event.mouseWheelScroll);
break;
case sf::Event::MouseButtonPressed:
if (mouse_button_pressed_callback_func != nullptr)
mouse_button_pressed_callback_func(event.mouseButton);
StartDrag(event.mouseButton);
break;
case sf::Event::MouseButtonReleased:
StopDrag(event.mouseButton);
if (mouse_button_released_callback_func != nullptr)
mouse_button_released_callback_func(event.mouseButton);
break;
case sf::Event::Closed:
window.close();
break;
}
}
}