diff --git a/.gitignore b/.gitignore index e257658..9db82ca 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ *.out *.app +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..cdb1f4f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.20) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +include_directories(/usr/include/SFML) +include(FetchContent) +# FetchContent_Declare(SFML +# GIT_REPOSITORY https://github.com/SFML/SFML.git +# GIT_TAG 3.0.0 +# GIT_SHALLOW ON +# EXCLUDE_FROM_ALL +# SYSTEM) +#FetchContent_MakeAvailable(SFML) +find_package(SFML 2.5 COMPONENTS system window graphics REQUIRED) +project(hello VERSION 1.0) +add_executable(hello main.cpp) +#target_link_libraries(hello sfml-graphics) +target_link_libraries(hello + sfml-system + sfml-window + sfml-graphics + sfml-audio +) + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7b8dc6f --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +SHELL := /bin/bash +.DEFAULT_GOAL := build +.PHONY: build + +build: + @if test -d build; then rm -fr build; fi + @cmake -B build -S . -DCMAKE_PREFIX_PATH="/usr;/usr/lib64;/usr/lib64/cmake" -DCMAKE_SUPPRESS_DEVELOPER_WARNINGS=ON + @cmake --build build + @build/hello diff --git a/arial.ttf b/arial.ttf new file mode 100644 index 0000000..7ff88f2 Binary files /dev/null and b/arial.ttf differ diff --git a/cute_image.jpg b/cute_image.jpg new file mode 100755 index 0000000..a3d65a9 Binary files /dev/null and b/cute_image.jpg differ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..9ff77e9 --- /dev/null +++ b/main.cpp @@ -0,0 +1,50 @@ +#include +#include + +int main() { + // Create the main window + auto mode = sf::VideoMode({2048, 2048}); + auto window = sf::RenderWindow(mode, "SFML window"); + + // Load a sprite to display + sf::Texture texture; + if (!texture.loadFromFile("cute_image.jpg")) { + exit(1); + } + + sf::Sprite sprite(texture); + + // Create a graphical text to display + auto font = sf::Font(); + font.loadFromFile("arial.tff"); + sf::Text text("Hello SFML", font, 50); // ✅ + // Load a music to play + sf::Music music; + music.openFromFile("nice_music.ogg"); + + // Play the music + music.play(); + + // Start the game loop + while (window.isOpen()) { + // Process events + sf::Event event; + while (window.pollEvent(event)) { + if (event.type == sf::Event::Closed) { + window.close(); + } + + // Clear screen + window.clear(); + + // Draw the sprite + window.draw(sprite); + + // Draw the string + window.draw(text); + + // Update the window + window.display(); + } + } +} diff --git a/nice_music.ogg b/nice_music.ogg new file mode 100644 index 0000000..4a47527 Binary files /dev/null and b/nice_music.ogg differ