サーチ…


備考

sf::RectangleShapesf::Spriteなど、SFMLで提供される描画プリミティブを使用する場合は、 sf::Windowではなくsf::RenderWindowを使用する必要があります。

OpenGLウィンドウの作成

SFMLのWindowsは、次の2つのクラスのいずれかで表されます。

  • 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