diff --git a/.gitignore b/.gitignore index 4ef6152..00f948f 100644 --- a/.gitignore +++ b/.gitignore @@ -393,4 +393,7 @@ Editor/bin Editor/intermediate-files Game/bin -imgui.ini \ No newline at end of file +lib/ + + +imgui.ini diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a7dd850 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vendor"] + path = vendor + url = https://gitlab.com/JosephA1997/imgui-sfml-premake.git diff --git a/Create-Solution.bat b/Create-Solution.bat deleted file mode 100644 index 2cd4d72..0000000 --- a/Create-Solution.bat +++ /dev/null @@ -1,2 +0,0 @@ -.\vendor\premake5\premake5.exe vs2022 -PAUSE \ No newline at end of file diff --git a/build-ninja.sh b/build-ninja.sh deleted file mode 100755 index c963c86..0000000 --- a/build-ninja.sh +++ /dev/null @@ -1,5 +0,0 @@ -#! /bin/bash - -./vendor/premake5/premake5 ecc -./vendor/premake5/premake5 ninja -ninja $1 diff --git a/build.sh b/build.sh deleted file mode 100755 index cdc8fdd..0000000 --- a/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#! /bin/bash - -./vendor/premake5/premake5 ecc -./vendor/premake5/premake5 gmake -make config=$1 \ No newline at end of file diff --git a/clean-ninja.sh b/clean-ninja.sh deleted file mode 100644 index 4b8a403..0000000 --- a/clean-ninja.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/bash - -ninja clean \ No newline at end of file diff --git a/clean.sh b/clean.sh deleted file mode 100755 index 9f7c6eb..0000000 --- a/clean.sh +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/bash - if [ -z "$1" ] || [ $# -eq 0 ] - then - make config=debug clean && make config=release clean - else - make config=$1 clean - fi \ No newline at end of file diff --git a/ecc.sh b/ecc.sh deleted file mode 100755 index 006ddac..0000000 --- a/ecc.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/bash - -./vendor/premake5/premake5 ecc \ No newline at end of file diff --git a/premake5.lua b/premake5.lua deleted file mode 100644 index b81d69d..0000000 --- a/premake5.lua +++ /dev/null @@ -1,148 +0,0 @@ -require "ecc/ecc" -require "ninja/ninja" - -workspace "ray-casting-demos" - architecture "x64" - - configurations - { - "debug", - "release" - } - -output_dir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}" -vs_intdir = "$(SolutionDir)intermediate-files/" .. output_dir -intdir = "%{wks.location}/intermediate-files/" .. output_dir -vs_bindir = "$(SolutionDir)bin/" .. output_dir -bindir = "%{wks.location}/bin/" .. output_dir -vs_sfmldir = "$(SolutionDir)vendor/SFML" -sfmldir = "%{wks.location}/vendor/SFML" -vs_imguidir = "$(SolutionDir)vendor/imgui" -imguidir = "%{wks.location}/vendor/imgui" -vs_include_dir = "$(SolutionDir)include" -include_dir = "%{wks.location}/include" - -project "Game" - language "C++" - cppdialect "C++17" - systemversion "latest" - targetname "Game" - - files - { - "src/**.cpp", - "include/**.h", - "include/**.hpp", - "vendor/imgui/imgui.cpp", - "vendor/imgui/imgui_draw.cpp", - "vendor/imgui/imgui_tables.cpp", - "vendor/imgui/imgui_widgets.cpp", - "vendor/imgui/imgui-SFML.cpp" - } - --visual studio-- - filter {"action:vs*", "system:windows"} - targetdir (vs_bindir) - objdir (vs_intdir) - - includedirs - { - "src", - vs_include_dir, - vs_sfmldir .. "/include", - vs_imguidir - } - - libdirs {vs_sfmldir .."/lib"} - - --not visual studio on windows-- - filter {"not action:vs*", "system:windows"} - targetdir (bindir) - objdir (intdir) - includedirs - { - "src", - include_dir, - sfmldir .. "/include", - imguidir - } - - libdirs {sfmldir .."/lib"} - - filter{"system:windows"} - defines "SFML_STATIC" - defines "PLATFORM_WINDOWS" - staticruntime "on" - - filter {"system:windows", "configurations:debug"} - defines{"_DEBUG", "_CONSOLE"} - links - { - "sfml-main-d", - "sfml-graphics-s-d", - "sfml-window-s-d", - "opengl32", - "gdi32", - "freetype", - "sfml-audio-s-d", - "flac", - "vorbisfile", - "vorbis", - "ogg", - "sfml-system-s-d", - "winmm" - } - - filter {"system:windows", "configurations:release"} - defines{"NDEBUG"} - links - { - "sfml-main", - "sfml-graphics-s", - "sfml-window-s", - "opengl32", - "gdi32", - "freetype", - "sfml-audio-s", - "openal32", - "flac", - "vorbisfile", - "vorbis", - "ogg", - "sfml-system-s", - "winmm" - } - - filter {"system:linux"} - targetdir (bindir) - objdir (intdir) - defines "PLATFORM_LINUX" - includedirs - { - "src", - include_dir, - imguidir - } - - links - { - "sfml-graphics", - "sfml-window", - "sfml-audio", - "sfml-system", - "OpenGL", - } - - --config settings-- - filter "configurations:debug" - defines {"LOG_ENABLE", "GAME_DEBUG"} - symbols "on" - runtime "Debug" - kind "ConsoleApp" - - filter "configurations:release" - defines {"GAME_RELEASE"} - optimize "Speed" - inlining "Auto" - symbols "off" - runtime "Release" - kind "WindowedApp" \ No newline at end of file diff --git a/run.sh b/run.sh deleted file mode 100755 index 20dacf1..0000000 --- a/run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/bash - -./bin/$1-linux-x86_64/Game \ No newline at end of file diff --git a/scripts/Create-Solution.bat b/scripts/Create-Solution.bat new file mode 100644 index 0000000..a4532ab --- /dev/null +++ b/scripts/Create-Solution.bat @@ -0,0 +1,4 @@ +@ECHO OFF +ECHO Project files will be written to snake/build +..\vendor\premake5\premake5.exe vs2022 +PAUSE diff --git a/scripts/build-ninja.sh b/scripts/build-ninja.sh new file mode 100755 index 0000000..4adada0 --- /dev/null +++ b/scripts/build-ninja.sh @@ -0,0 +1,9 @@ +#! /bin/bash +set -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd "$SCRIPT_DIR" + +echo build files will be placed in /build +../vendor/premake5/premake5 premake-ninja && ninja $1 -C ../build + diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..89ee0db --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,8 @@ +#! /bin/bash +set -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd "$SCRIPT_DIR" + +echo build files will be placed in ./build +./vendor/premake5/premake5 gmake2 && make -C ../build config=$1 diff --git a/scripts/clean-ninja.sh b/scripts/clean-ninja.sh new file mode 100755 index 0000000..0078286 --- /dev/null +++ b/scripts/clean-ninja.sh @@ -0,0 +1,11 @@ +#! /bin/bash + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd "$SCRIPT_DIR" + +if [ -z "$1" ] || [ $# -eq 0 ] + then + ninja -C ../build -t clean + else + ninja -C ../build -t clean $1 +fi \ No newline at end of file diff --git a/scripts/clean.sh b/scripts/clean.sh new file mode 100755 index 0000000..4095c54 --- /dev/null +++ b/scripts/clean.sh @@ -0,0 +1,11 @@ +#! /bin/bash + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd "$SCRIPT_DIR" + +if [ -z "$1" ] || [ $# -eq 0 ] + then + make -C ../build config=Debug clean && make -C ../build config=Release clean + else + make -C ../build config=$1 clean +fi \ No newline at end of file diff --git a/scripts/ecc.sh b/scripts/ecc.sh new file mode 100755 index 0000000..f2ea50c --- /dev/null +++ b/scripts/ecc.sh @@ -0,0 +1,14 @@ +#! /bin/bash + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd "$SCRIPT_DIR" + +if [ -z "$1" ] || [ $# -eq 0 ] + then + ../vendor/premake5/premake5 --config=Debug ecc + else + ../vendor/premake5/premake5 --config=$1 ecc +fi + + +mv compile_commands.json ../compile_commands.json diff --git a/scripts/premake5.lua b/scripts/premake5.lua new file mode 100644 index 0000000..e3f857f --- /dev/null +++ b/scripts/premake5.lua @@ -0,0 +1,67 @@ +require "ecc/ecc" +require "ninja/ninja" + +package.path = package.path .. ";../vendor/premake-scripts/?.lua" + +local ogg = require("build-ogg") +local sfml = require("build-sfml") +local flac = require("build-flac") +local imgui = require("build-imgui") +local vorbis = require("build-vorbis") +local freetype = require("build-freetype") +local imguisfml = require("build-imgui-sfml") + +local game = require("project") +-- use a variable for rootdir to make it easier to move scripts to another directory +local rootdir = "../" + +workspace "ray-casting-demos" + architecture "x64" + startproject "Game" + configurations{"Debug", "Release"} + location (rootdir .. "build") + + filter"system:linux" + staticruntime"Off" + + filter"system:windows" + staticruntime"On" + filter"" + + filter"system:linux" + pic"On" -- fix warning when statically linking + filter"" + + + output_dir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}" + intdir = rootdir .. "intermediate-files/" + bindir = rootdir .. "bin/" .. output_dir + liboutdir = rootdir.. "lib/" .. output_dir + + externalwarnings "Off" + + filter "configurations:debug" + defines {"LOG_ENABLE", "GAME_DEBUG"} + symbols "on" + runtime "Debug" + warnings "Extra" + + filter "configurations:release" + defines {"GAME_RELEASE"} + optimize "Speed" + inlining "Auto" + symbols "off" + runtime "Release" + filter"" + + group"Dependencies" + ogg.generateproject(liboutdir, intdir) + sfml.generateproject(liboutdir, intdir) + flac.generateproject(liboutdir, intdir) + imgui.generateproject(liboutdir, intdir) + vorbis.generateproject(liboutdir, intdir) + freetype.generateproject(liboutdir, intdir) + imguisfml.generateproject(liboutdir, intdir) + group"" + + game.generateproject(bindir, intdir) diff --git a/scripts/project.lua b/scripts/project.lua new file mode 100644 index 0000000..a298a85 --- /dev/null +++ b/scripts/project.lua @@ -0,0 +1,58 @@ +local m = {} + +local rootdir = path.join(path.getabsolute(path.getdirectory(_SCRIPT)), "../") + +package.path = package.path .. ";../vendor/premake-scripts/?.lua" + +local sfml = require("build-sfml") +local imgui = require("build-imgui") +local imguisfml = require("build-imgui-sfml") + + +function m.generateproject(bindir, intdir) +project "Game" + language "C++" + cppdialect "C++20" + systemversion "latest" + kind "WindowedApp" + targetname "Game" + targetdir (bindir) + debugdir (rootdir) + objdir (intdir) + + +files +{ + path.join(rootdir, "src/**.cpp"), + path.join(rootdir, "include/**.h"), + path.join(rootdir, "include/**.hpp"), +} + +includedirs +{ + path.join(rootdir, "src"), + path.join(rootdir, "include"), +} + +-- link order matters on GCC/Clang +imgui.link() +imguisfml.link() +sfml.link() + +--windows specific settings-- +filter{"system:windows"} +defines {"PLATFORM_WINDOWS"} + +filter {"system:windows", "configurations:debug"} +defines{"_DEBUG", "_CONSOLE"} + +filter {"system:windows", "configurations:release"} +defines{"NDEBUG"} + +--linux specific settings-- +filter {"system:linux"} +defines {"PLATFORM_LINUX"} + +end + +return m diff --git a/scripts/run.sh b/scripts/run.sh new file mode 100755 index 0000000..8c077cf --- /dev/null +++ b/scripts/run.sh @@ -0,0 +1,6 @@ +#! /bin/bash + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +cd "$SCRIPT_DIR/.." + +./bin/$1-linux-x86_64/Game diff --git a/src/main.cpp b/src/main.cpp index da3276e..d4a8d9d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,9 +31,9 @@ int numRays{ 500 }; int vertexBounds[2] = { 3, 10 }; int averageSize{ 100 }; float rayLength{ 500.f }; -imguiColor rayColor = constructImguiColor(sf::Color::Red); -imguiColor lightColor = constructImguiColor(sf::Color::Yellow); -imguiColor endPointColor = constructImguiColor(sf::Color::Magenta); +ImguiColor rayColor = constructImguiColor(sf::Color::Red); +ImguiColor lightColor = constructImguiColor(sf::Color::Yellow); +ImguiColor endPointColor = constructImguiColor(sf::Color::Magenta); bool drawRays{ false }; bool drawLight{ true }; bool drawEndPoints{ false }; @@ -97,7 +97,7 @@ void GUI() ImGui::Begin("Config"); ImGui::Text("Controls:"); ImGui::Indent(); - ImGui::Text("Right Click: place rectangle at mouse position"); + ImGui::Text("Right Click: place a square at mouse position"); ImGui::Text("R: place a randomly sized polygon at mouse position"); ImGui::Text("C: clear all polygons"); ImGui::Text("Scroll wheel: increase/decrease light direction (if light is bounded)"); @@ -273,4 +273,4 @@ void render() ImGui::SFML::Render(window); window.display(); -} \ No newline at end of file +} diff --git a/vendor b/vendor new file mode 160000 index 0000000..5223f72 --- /dev/null +++ b/vendor @@ -0,0 +1 @@ +Subproject commit 5223f725218bd8a62b2e5dac4e3d852b761731a6 diff --git a/vendor/SFML/include/SFML/Audio.hpp b/vendor/SFML/include/SFML/Audio.hpp deleted file mode 100644 index f0d262e..0000000 --- a/vendor/SFML/include/SFML/Audio.hpp +++ /dev/null @@ -1,55 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#pragma once - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - -//////////////////////////////////////////////////////////// -/// \defgroup audio Audio module -/// -/// Sounds, streaming (musics or custom sources), recording, -/// spatialization. -/// -//////////////////////////////////////////////////////////// diff --git a/vendor/SFML/include/SFML/Audio/AudioResource.hpp b/vendor/SFML/include/SFML/Audio/AudioResource.hpp deleted file mode 100644 index 3230637..0000000 --- a/vendor/SFML/include/SFML/Audio/AudioResource.hpp +++ /dev/null @@ -1,93 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#pragma once - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include - -#include - - -namespace sf -{ -//////////////////////////////////////////////////////////// -/// \brief Base class for classes that require an audio device -/// -//////////////////////////////////////////////////////////// -class SFML_AUDIO_API AudioResource -{ -public: - //////////////////////////////////////////////////////////// - /// \brief Copy constructor - /// - //////////////////////////////////////////////////////////// - AudioResource(const AudioResource&) = default; - - //////////////////////////////////////////////////////////// - /// \brief Copy assignment - /// - //////////////////////////////////////////////////////////// - AudioResource& operator=(const AudioResource&) = default; - - //////////////////////////////////////////////////////////// - /// \brief Move constructor - /// - //////////////////////////////////////////////////////////// - AudioResource(AudioResource&&) noexcept = default; - - //////////////////////////////////////////////////////////// - /// \brief Move assignment - /// - //////////////////////////////////////////////////////////// - AudioResource& operator=(AudioResource&&) noexcept = default; - -protected: - //////////////////////////////////////////////////////////// - /// \brief Default constructor - /// - //////////////////////////////////////////////////////////// - AudioResource(); - -private: - //////////////////////////////////////////////////////////// - // Member data - //////////////////////////////////////////////////////////// - std::shared_ptr m_device; //!< Sound device -}; - -} // namespace sf - - -//////////////////////////////////////////////////////////// -/// \class sf::AudioResource -/// \ingroup audio -/// -/// This class is for internal use only, it must be the base -/// of every class that requires a valid audio device in -/// order to work. -/// -//////////////////////////////////////////////////////////// diff --git a/vendor/SFML/include/SFML/Audio/Export.hpp b/vendor/SFML/include/SFML/Audio/Export.hpp deleted file mode 100644 index c50efc0..0000000 --- a/vendor/SFML/include/SFML/Audio/Export.hpp +++ /dev/null @@ -1,44 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#pragma once - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include - - -//////////////////////////////////////////////////////////// -// Portable import / export macros -//////////////////////////////////////////////////////////// -#if defined(SFML_AUDIO_EXPORTS) - -#define SFML_AUDIO_API SFML_API_EXPORT - -#else - -#define SFML_AUDIO_API SFML_API_IMPORT - -#endif diff --git a/vendor/SFML/include/SFML/Audio/InputSoundFile.hpp b/vendor/SFML/include/SFML/Audio/InputSoundFile.hpp deleted file mode 100644 index 523b8e5..0000000 --- a/vendor/SFML/include/SFML/Audio/InputSoundFile.hpp +++ /dev/null @@ -1,336 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#pragma once - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include - -#include - -#include -#include -#include - -#include -#include - - -namespace sf -{ -class Time; -class InputStream; - -//////////////////////////////////////////////////////////// -/// \brief Provide read access to sound files -/// -//////////////////////////////////////////////////////////// -class SFML_AUDIO_API InputSoundFile -{ -public: - //////////////////////////////////////////////////////////// - /// \brief Default constructor - /// - /// Construct an input sound file that is not associated - /// with a file to read. - /// - //////////////////////////////////////////////////////////// - InputSoundFile() = default; - - //////////////////////////////////////////////////////////// - /// \brief Construct a sound file from the disk for reading - /// - /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC, MP3. - /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. - /// - /// Because of minimp3_ex limitation, for MP3 files with big (>16kb) APEv2 tag, - /// it may not be properly removed, tag data will be treated as MP3 data - /// and there is a low chance of garbage decoded at the end of file. - /// See also: https://github.com/lieff/minimp3 - /// - /// \param filename Path of the sound file to load - /// - /// \throws sf::Exception if opening the file was unsuccessful - /// - //////////////////////////////////////////////////////////// - explicit InputSoundFile(const std::filesystem::path& filename); - - //////////////////////////////////////////////////////////// - /// \brief Construct a sound file in memory for reading - /// - /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. - /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. - /// - /// \param data Pointer to the file data in memory - /// \param sizeInBytes Size of the data to load, in bytes - /// - /// \throws sf::Exception if opening the file was unsuccessful - /// - //////////////////////////////////////////////////////////// - InputSoundFile(const void* data, std::size_t sizeInBytes); - - //////////////////////////////////////////////////////////// - /// \brief Construct a sound file from a custom stream for reading - /// - /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. - /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. - /// - /// \param stream Source stream to read from - /// - /// \throws sf::Exception if opening the file was unsuccessful - /// - //////////////////////////////////////////////////////////// - explicit InputSoundFile(InputStream& stream); - - //////////////////////////////////////////////////////////// - /// \brief Open a sound file from the disk for reading - /// - /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC, MP3. - /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. - /// - /// Because of minimp3_ex limitation, for MP3 files with big (>16kb) APEv2 tag, - /// it may not be properly removed, tag data will be treated as MP3 data - /// and there is a low chance of garbage decoded at the end of file. - /// See also: https://github.com/lieff/minimp3 - /// - /// \param filename Path of the sound file to load - /// - /// \return `true` if the file was successfully opened - /// - //////////////////////////////////////////////////////////// - [[nodiscard]] bool openFromFile(const std::filesystem::path& filename); - - //////////////////////////////////////////////////////////// - /// \brief Open a sound file in memory for reading - /// - /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. - /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. - /// - /// \param data Pointer to the file data in memory - /// \param sizeInBytes Size of the data to load, in bytes - /// - /// \return `true` if the file was successfully opened - /// - //////////////////////////////////////////////////////////// - [[nodiscard]] bool openFromMemory(const void* data, std::size_t sizeInBytes); - - //////////////////////////////////////////////////////////// - /// \brief Open a sound file from a custom stream for reading - /// - /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. - /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. - /// - /// \param stream Source stream to read from - /// - /// \return `true` if the file was successfully opened - /// - //////////////////////////////////////////////////////////// - [[nodiscard]] bool openFromStream(InputStream& stream); - - //////////////////////////////////////////////////////////// - /// \brief Get the total number of audio samples in the file - /// - /// \return Number of samples - /// - //////////////////////////////////////////////////////////// - [[nodiscard]] std::uint64_t getSampleCount() const; - - //////////////////////////////////////////////////////////// - /// \brief Get the number of channels used by the sound - /// - /// \return Number of channels (1 = mono, 2 = stereo) - /// - //////////////////////////////////////////////////////////// - [[nodiscard]] unsigned int getChannelCount() const; - - //////////////////////////////////////////////////////////// - /// \brief Get the sample rate of the sound - /// - /// \return Sample rate, in samples per second - /// - //////////////////////////////////////////////////////////// - [[nodiscard]] unsigned int getSampleRate() const; - - //////////////////////////////////////////////////////////// - /// \brief Get the map of position in sample frame to sound channel - /// - /// This is used to map a sample in the sample stream to a - /// position during spatialization. - /// - /// \return Map of position in sample frame to sound channel - /// - /// \see `getSampleRate`, `getChannelCount`, `getDuration` - /// - //////////////////////////////////////////////////////////// - [[nodiscard]] const std::vector& getChannelMap() const; - - //////////////////////////////////////////////////////////// - /// \brief Get the total duration of the sound file - /// - /// This function is provided for convenience, the duration is - /// deduced from the other sound file attributes. - /// - /// \return Duration of the sound file - /// - //////////////////////////////////////////////////////////// - [[nodiscard]] Time getDuration() const; - - //////////////////////////////////////////////////////////// - /// \brief Get the read offset of the file in time - /// - /// \return Time position - /// - //////////////////////////////////////////////////////////// - [[nodiscard]] Time getTimeOffset() const; - - //////////////////////////////////////////////////////////// - /// \brief Get the read offset of the file in samples - /// - /// \return Sample position - /// - //////////////////////////////////////////////////////////// - [[nodiscard]] std::uint64_t getSampleOffset() const; - - //////////////////////////////////////////////////////////// - /// \brief Change the current read position to the given sample offset - /// - /// This function takes a sample offset to provide maximum - /// precision. If you need to jump to a given time, use the - /// other overload. - /// - /// The sample offset takes the channels into account. - /// If you have a time offset instead, you can easily find - /// the corresponding sample offset with the following formula: - /// `timeInSeconds * sampleRate * channelCount` - /// If the given offset exceeds to total number of samples, - /// this function jumps to the end of the sound file. - /// - /// \param sampleOffset Index of the sample to jump to, relative to the beginning - /// - //////////////////////////////////////////////////////////// - void seek(std::uint64_t sampleOffset); - - //////////////////////////////////////////////////////////// - /// \brief Change the current read position to the given time offset - /// - /// Using a time offset is handy but imprecise. If you need an accurate - /// result, consider using the overload which takes a sample offset. - /// - /// If the given time exceeds to total duration, this function jumps - /// to the end of the sound file. - /// - /// \param timeOffset Time to jump to, relative to the beginning - /// - //////////////////////////////////////////////////////////// - void seek(Time timeOffset); - - //////////////////////////////////////////////////////////// - /// \brief Read audio samples from the open file - /// - /// \param samples Pointer to the sample array to fill - /// \param maxCount Maximum number of samples to read - /// - /// \return Number of samples actually read (may be less than \a maxCount) - /// - //////////////////////////////////////////////////////////// - [[nodiscard]] std::uint64_t read(std::int16_t* samples, std::uint64_t maxCount); - - //////////////////////////////////////////////////////////// - /// \brief Close the current file - /// - //////////////////////////////////////////////////////////// - void close(); - -private: - //////////////////////////////////////////////////////////// - /// \brief Deleter for input streams that only conditionally deletes - /// - //////////////////////////////////////////////////////////// - struct SFML_AUDIO_API StreamDeleter - { - StreamDeleter(bool theOwned); - - // To accept ownership transfer from usual std::unique_ptr - template - StreamDeleter(const std::default_delete&); - - void operator()(InputStream* ptr) const; - - bool owned{true}; - }; - - //////////////////////////////////////////////////////////// - // Member data - //////////////////////////////////////////////////////////// - std::unique_ptr m_reader; //!< Reader that handles I/O on the file's format - std::unique_ptr m_stream{nullptr, false}; //!< Input stream used to access the file's data - std::uint64_t m_sampleOffset{}; //!< Sample Read Position - std::uint64_t m_sampleCount{}; //!< Total number of samples in the file - unsigned int m_sampleRate{}; //!< Number of samples per second - std::vector m_channelMap; //!< The map of position in sample frame to sound channel -}; - -} // namespace sf - - -//////////////////////////////////////////////////////////// -/// \class sf::InputSoundFile -/// \ingroup audio -/// -/// This class decodes audio samples from a sound file. It is -/// used internally by higher-level classes such as `sf::SoundBuffer` -/// and `sf::Music`, but can also be useful if you want to process -/// or analyze audio files without playing them, or if you want to -/// implement your own version of `sf::Music` with more specific -/// features. -/// -/// Usage example: -/// \code -/// // Open a sound file -/// sf::InputSoundFile file("music.ogg"); -/// -/// // Print the sound attributes -/// std::cout << "duration: " << file.getDuration().asSeconds() << '\n' -/// << "channels: " << file.getChannelCount() << '\n' -/// << "sample rate: " << file.getSampleRate() << '\n' -/// << "sample count: " << file.getSampleCount() << std::endl; -/// -/// // Read and process batches of samples until the end of file is reached -/// std::array samples; -/// std::uint64_t count; -/// do -/// { -/// count = file.read(samples.data(), samples.size()); -/// -/// // process, analyze, play, convert, or whatever -/// // you want to do with the samples... -/// } -/// while (count > 0); -/// \endcode -/// -/// \see `sf::SoundFileReader`, `sf::OutputSoundFile` -/// -//////////////////////////////////////////////////////////// diff --git a/vendor/SFML/include/SFML/Audio/Listener.hpp b/vendor/SFML/include/SFML/Audio/Listener.hpp deleted file mode 100644 index 81c1794..0000000 --- a/vendor/SFML/include/SFML/Audio/Listener.hpp +++ /dev/null @@ -1,234 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#pragma once - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include - -#include -#include - - -//////////////////////////////////////////////////////////// -/// \brief The audio listener is the point in the scene -/// from where all the sounds are heard -/// -//////////////////////////////////////////////////////////// -namespace sf::Listener -{ -//////////////////////////////////////////////////////////// -/// \brief Structure defining the properties of a directional cone -/// -/// Sounds will play at gain 1 when they are positioned -/// within the inner angle of the cone. Sounds will play -/// at `outerGain` when they are positioned outside the -/// outer angle of the cone. The gain declines linearly -/// from 1 to `outerGain` as the sound moves from the inner -/// angle to the outer angle. -/// -//////////////////////////////////////////////////////////// -struct Cone -{ - Angle innerAngle; //!< Inner angle - Angle outerAngle; //!< Outer angle - float outerGain{}; //!< Outer gain -}; - -//////////////////////////////////////////////////////////// -/// \brief Change the global volume of all the sounds and musics -/// -/// `volume` is a number between 0 and 100; it is combined -/// with the individual volume of each sound / music. -/// The default value for the volume is 100 (maximum). -/// -/// \param volume New global volume, in the range [0, 100] -/// -/// \see `getGlobalVolume` -/// -//////////////////////////////////////////////////////////// -SFML_AUDIO_API void setGlobalVolume(float volume); - -//////////////////////////////////////////////////////////// -/// \brief Get the current value of the global volume -/// -/// \return Current global volume, in the range [0, 100] -/// -/// \see `setGlobalVolume` -/// -//////////////////////////////////////////////////////////// -[[nodiscard]] SFML_AUDIO_API float getGlobalVolume(); - -//////////////////////////////////////////////////////////// -/// \brief Set the position of the listener in the scene -/// -/// The default listener's position is (0, 0, 0). -/// -/// \param position New listener's position -/// -/// \see `getPosition`, `setDirection` -/// -//////////////////////////////////////////////////////////// -SFML_AUDIO_API void setPosition(const Vector3f& position); - -//////////////////////////////////////////////////////////// -/// \brief Get the current position of the listener in the scene -/// -/// \return Listener's position -/// -/// \see `setPosition` -/// -//////////////////////////////////////////////////////////// -[[nodiscard]] SFML_AUDIO_API Vector3f getPosition(); - -//////////////////////////////////////////////////////////// -/// \brief Set the forward vector of the listener in the scene -/// -/// The direction (also called "at vector") is the vector -/// pointing forward from the listener's perspective. Together -/// with the up vector, it defines the 3D orientation of the -/// listener in the scene. The direction vector doesn't -/// have to be normalized. -/// The default listener's direction is (0, 0, -1). -/// -/// \param direction New listener's direction -/// -/// \see `getDirection`, `setUpVector`, `setPosition` -/// -//////////////////////////////////////////////////////////// -SFML_AUDIO_API void setDirection(const Vector3f& direction); - -//////////////////////////////////////////////////////////// -/// \brief Get the current forward vector of the listener in the scene -/// -/// \return Listener's forward vector (not normalized) -/// -/// \see `setDirection` -/// -//////////////////////////////////////////////////////////// -[[nodiscard]] SFML_AUDIO_API Vector3f getDirection(); - -//////////////////////////////////////////////////////////// -/// \brief Set the velocity of the listener in the scene -/// -/// The default listener's velocity is (0, 0, -1). -/// -/// \param velocity New listener's velocity -/// -/// \see `getVelocity`, `getDirection`, `setUpVector`, `setPosition` -/// -//////////////////////////////////////////////////////////// -SFML_AUDIO_API void setVelocity(const Vector3f& velocity); - -//////////////////////////////////////////////////////////// -/// \brief Get the current forward vector of the listener in the scene -/// -/// \return Listener's velocity -/// -/// \see `setVelocity` -/// -//////////////////////////////////////////////////////////// -[[nodiscard]] SFML_AUDIO_API Vector3f getVelocity(); - -//////////////////////////////////////////////////////////// -/// \brief Set the cone properties of the listener in the audio scene -/// -/// The cone defines how directional attenuation is applied. -/// The default cone of a sound is (2 * PI, 2 * PI, 1). -/// -/// \param cone Cone properties of the listener in the scene -/// -/// \see `getCone` -/// -//////////////////////////////////////////////////////////// -SFML_AUDIO_API void setCone(const Listener::Cone& cone); - -//////////////////////////////////////////////////////////// -/// \brief Get the cone properties of the listener in the audio scene -/// -/// \return Cone properties of the listener -/// -/// \see `setCone` -/// -//////////////////////////////////////////////////////////// -[[nodiscard]] SFML_AUDIO_API Listener::Cone getCone(); - -//////////////////////////////////////////////////////////// -/// \brief Set the upward vector of the listener in the scene -/// -/// The up vector is the vector that points upward from the -/// listener's perspective. Together with the direction, it -/// defines the 3D orientation of the listener in the scene. -/// The up vector doesn't have to be normalized. -/// The default listener's up vector is (0, 1, 0). It is usually -/// not necessary to change it, especially in 2D scenarios. -/// -/// \param upVector New listener's up vector -/// -/// \see `getUpVector`, `setDirection`, `setPosition` -/// -//////////////////////////////////////////////////////////// -SFML_AUDIO_API void setUpVector(const Vector3f& upVector); - -//////////////////////////////////////////////////////////// -/// \brief Get the current upward vector of the listener in the scene -/// -/// \return Listener's upward vector (not normalized) -/// -/// \see `setUpVector` -/// -//////////////////////////////////////////////////////////// -[[nodiscard]] SFML_AUDIO_API Vector3f getUpVector(); -} // namespace sf::Listener - - -//////////////////////////////////////////////////////////// -/// \namespace sf::Listener -/// \ingroup audio -/// -/// The audio listener defines the global properties of the -/// audio environment, it defines where and how sounds and musics -/// are heard. If `sf::View` is the eyes of the user, then -/// `sf::Listener` are their ears (by the way, they are often linked -/// together -- same position, orientation, etc.). -/// -/// `sf::Listener` is a simple interface, which allows to setup the -/// listener in the 3D audio environment (position, direction and -/// up vector), and to adjust the global volume. -/// -/// Usage example: -/// \code -/// // Move the listener to the position (1, 0, -5) -/// sf::Listener::setPosition({1, 0, -5}); -/// -/// // Make it face the right axis (1, 0, 0) -/// sf::Listener::setDirection({1, 0, 0}); -/// -/// // Reduce the global volume -/// sf::Listener::setGlobalVolume(50); -/// \endcode -/// -//////////////////////////////////////////////////////////// diff --git a/vendor/SFML/include/SFML/Audio/Music.hpp b/vendor/SFML/include/SFML/Audio/Music.hpp deleted file mode 100644 index 91a2787..0000000 --- a/vendor/SFML/include/SFML/Audio/Music.hpp +++ /dev/null @@ -1,377 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#pragma once - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include - -#include - -#include -#include -#include - -#include -#include - - -namespace sf -{ -class Time; -class InputStream; -class InputSoundFile; - -//////////////////////////////////////////////////////////// -/// \brief Streamed music played from an audio file -/// -//////////////////////////////////////////////////////////// -class SFML_AUDIO_API Music : public SoundStream -{ -public: - //////////////////////////////////////////////////////////// - /// \brief Structure defining a time range using the template type - /// - //////////////////////////////////////////////////////////// - template - struct Span - { - T offset{}; //!< The beginning offset of the time range - T length{}; //!< The length of the time range - }; - - // Associated `Span` type - using TimeSpan = Span