diff --git a/.editorconfig b/.editorconfig index 0d35e36..7b60442 100644 --- a/.editorconfig +++ b/.editorconfig @@ -28,12 +28,12 @@ indent_size = 2 # C [{*.c,*.h}] indent_style = space -indent_size = 4 +indent_size = 2 # C++ [{*.cpp,*.ino,*.hpp}] indent_style = space -indent_size = 4 +indent_size = 2 # V [{*.v,v.mod}] diff --git a/projects/SFML/.gitignore b/projects/SFML/.gitignore new file mode 100644 index 0000000..ef60e60 --- /dev/null +++ b/projects/SFML/.gitignore @@ -0,0 +1,3 @@ +# XMake +build/ +.xmake/ diff --git a/projects/SFML/fullscreen.cpp b/projects/SFML/fullscreen.cpp new file mode 100644 index 0000000..208c79d --- /dev/null +++ b/projects/SFML/fullscreen.cpp @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include + +int main() { + bool isFullscreen = false; + int screenWidth = sf::VideoMode::getDesktopMode().width; + int screenHeight = sf::VideoMode::getDesktopMode().height; + + sf::Font font; + std::string fontPath = "/usr/share/fonts/truetype/ubuntu/Ubuntu-R.ttf"; + if (!font.loadFromFile(fontPath)) { + std::cout << "Error loading font: " << fontPath << std::endl; + exit(EXIT_FAILURE); + } + + sf::Text text; + text.setFont(font); + text.setCharacterSize(24); + text.setFillColor(sf::Color::White); + text.setString("Press F keyboard button to toggle fullscreen mode"); + + sf::RenderWindow window; + window.create(sf::VideoMode(640, 480), "Fullscreen example"); + + while (window.isOpen()) { + sf::Event event; + + while (window.pollEvent(event)) { + if (event.type == sf::Event::Closed) + window.close(); + + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) + window.close(); + + if (sf::Keyboard::isKeyPressed(sf::Keyboard::F)) { + isFullscreen = !isFullscreen; + + window.close(); + + if (isFullscreen) + window.create(sf::VideoMode(screenWidth, screenHeight), + "Fullscreen example", sf::Style::Fullscreen); + else + window.create(sf::VideoMode(640, 480), "Fullscreen example", + sf::Style::Default); + } + } + + window.clear(sf::Color::Black); + window.draw(text); + window.display(); + } + + return EXIT_SUCCESS; +} diff --git a/projects/SFML/xmake.lua b/projects/SFML/xmake.lua new file mode 100644 index 0000000..da314cb --- /dev/null +++ b/projects/SFML/xmake.lua @@ -0,0 +1,8 @@ +set_project("sfml_examples") +set_languages("cxx14") + +target("fullscreen") + set_kind("binary") + add_syslinks("sfml-graphics", "sfml-window", "sfml-system") + add_files("fullscreen.cpp") + -- add_deps("log", "trt_api", "yolov8", "serial")