当前位置: 首页>>代码示例>>C++>>正文


C++ Window::close方法代码示例

本文整理汇总了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();
        }
    }
开发者ID:uetoyo,项目名称:Skeletal-Animation-Library,代码行数:56,代码来源:sfml_examples.cpp

示例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;
            }
        }
        
}
开发者ID:Tibigorno,项目名称:Project-AAAA,代码行数:32,代码来源:event.cpp

示例3: while

void
windowEvents ( sf::Window& window)
{
    sf::Event e;

    while ( window.pollEvent ( e ) ) {
        if ( e.type == sf::Event::Closed ) {
            window.close();
        }
    }
}
开发者ID:Hopson97,项目名称:Simple-OpenGL-Rectangle-,代码行数:11,代码来源:main.cpp

示例4: pollEvents

void pollEvents()
{
	sf::Event windowEvent;
	while (window.pollEvent(windowEvent))
	{
		switch (windowEvent.type)
		{
		case sf::Event::Closed:
			window.close();
			break;
		}
	}
}
开发者ID:IGME-RIT,项目名称:graphics-sfml-bezierSpline,代码行数:13,代码来源:main.cpp

示例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();
	}
开发者ID:mimaun,项目名称:Computer-Graphics,代码行数:14,代码来源:main.cpp

示例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;
			}
		}
	}
开发者ID:mwhiter,项目名称:hex,代码行数:44,代码来源:InputHandler.cpp

示例7:

	~Global() {
		wnd.close();
		delete e;
	}
开发者ID:ChunHungLiu,项目名称:openrw,代码行数:4,代码来源:test_globals.hpp


注:本文中的sf::Window::close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。