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

原文地址:https://www.cnblogs.com/karl07/p/10285680.html