SFML從入門到放棄(0) 配置環境


SFML從入門到放棄(0) 配置環境

恩。。開始划水。。學sfml的時候順便做點筆記什么的。。

安裝

在linux里面打開終端

然后輸入

sudo apt-get install libsfml-dev

好了

 

 

編譯

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

寫一個程序測試一下

編譯的時候加入參數-lsfml-graphics -lsfml-window -lsfml-system應該就可以了

g++ main.cpp -o test -lsfml-graphics -lsfml-window -lsfml-system

./test

成功的話會看到一個綠色的球

 

參考:https://www.sfml-dev.org/tutorials/2.5

 

by karl07


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM