Initial commit

This commit is contained in:
2025-03-24 00:28:44 +01:00
parent a24b21549f
commit 789cb89125
7 changed files with 83 additions and 0 deletions

1
.gitignore vendored
View File

@@ -32,3 +32,4 @@
*.out
*.app
build/

23
CMakeLists.txt Normal file
View File

@@ -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
)

9
Makefile Normal file
View File

@@ -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

BIN
arial.ttf Normal file

Binary file not shown.

BIN
cute_image.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

50
main.cpp Normal file
View File

@@ -0,0 +1,50 @@
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
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();
}
}
}

BIN
nice_music.ogg Normal file

Binary file not shown.