sfml 学习 1
sfml官网:https://www.sfml-dev.org/
sfml官网linux安装:https://www.sfml-dev.org/tutorials/2.5/start-linux.php
CMakeLists.txt:
cmake_minimum_required(VERSION 3.19)
project(sfml_study)
set(CMAKE_CXX_STANDARD 17)
find_package(SFML REQUIRED COMPONENTS audio network graphics window system)
if (NOT SFML_FOUND)
message(FATAL_ERROR "SFML NOT FOUND!")
else()
message("SFML FOUND!")
endif()
include_directories(${SFML_INCLUDE_DIR})
add_executable(sfml_study main.cpp)
target_link_libraries(sfml_study sfml-system)
target_link_libraries(sfml_study sfml-window)
target_link_libraries(sfml_study sfml-graphics)
target_link_libraries(sfml_study sfml-network)
target_link_libraries(sfml_study sfml-audio)
测试代码:
#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;
}