수색…


비고

sf::RectangleShape 또는 sf::Sprite 와 같이 SFML에서 제공하는 그리기 프리미티브를 사용하려면 sf::Window 대신 sf::RenderWindow 를 사용해야합니다.

OpenGL 창 만들기

SFML의 Windows는 두 가지 클래스 중 하나로 표현됩니다.

  • sf::Window 는 OpenGL 렌더링 컨텍스트를 포함하여 운영 체제가 제공하는 일반 창입니다.
  • sf::RenderWindowsf::Window 의 특수 버전으로 sf::RenderTarget 역할을 수행하므로 SFML의 프리미티브를 렌더링 할 수 있습니다.

두 가지 경우 모두 기본 사용법은 동일합니다.

#include <SFML/Window.hpp>

int main(int argc, char *argv) {
    // Create and initialize a window object
    sf::Window window(sf::VideoMode(640, 480), "My SFML Window");

    // Repeat this as long as the window is open
    while (window.isOpen()) {
        // Handle window events ("event loop")
        sf::Event event;
        while (window.pollEvent(event)) {
            switch(event.type) {
                case sf::Event::Closed: // User tries to close the window
                    window.close(); // Actually close the window
                    break;
            }
        }

        // Render logic would be placed here
        
        // Swap buffers and update the window
        window.display();
    }
    return 0;
}


Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow