Buscar..


Observaciones

sf::RenderWindow usar sf::RenderWindow lugar de sf::Window , si planea dibujar primitivos proporcionados por SFML, como sf::RectangleShape o sf::Sprite .

Creando una ventana de OpenGL

Las ventanas en SFML están representadas por una de dos clases:

  • sf::Window es una ventana genérica proporcionada por el sistema operativo que incluye un contexto de procesamiento OpenGL.
  • sf::RenderWindow es una versión especializada de sf::Window que también actúa como sf::RenderTarget , permitiendo que los primitivos de SFML se representen en ella.

El uso básico es el mismo en ambos casos.

#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
Licenciado bajo CC BY-SA 3.0
No afiliado a Stack Overflow