├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── documentation.md │ └── feature_request.md ├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── install.sh ├── lib └── SFML-2.5.1 │ ├── include │ └── SFML │ │ ├── Audio.hpp │ │ ├── Audio │ │ ├── AlResource.hpp │ │ ├── Export.hpp │ │ ├── InputSoundFile.hpp │ │ ├── Listener.hpp │ │ ├── Music.hpp │ │ ├── OutputSoundFile.hpp │ │ ├── Sound.hpp │ │ ├── SoundBuffer.hpp │ │ ├── SoundBufferRecorder.hpp │ │ ├── SoundFileFactory.hpp │ │ ├── SoundFileFactory.inl │ │ ├── SoundFileReader.hpp │ │ ├── SoundFileWriter.hpp │ │ ├── SoundRecorder.hpp │ │ ├── SoundSource.hpp │ │ └── SoundStream.hpp │ │ ├── Config.hpp │ │ ├── GpuPreference.hpp │ │ ├── Graphics.hpp │ │ ├── Graphics │ │ ├── BlendMode.hpp │ │ ├── CircleShape.hpp │ │ ├── Color.hpp │ │ ├── ConvexShape.hpp │ │ ├── Drawable.hpp │ │ ├── Export.hpp │ │ ├── Font.hpp │ │ ├── Glsl.hpp │ │ ├── Glsl.inl │ │ ├── Glyph.hpp │ │ ├── Image.hpp │ │ ├── PrimitiveType.hpp │ │ ├── Rect.hpp │ │ ├── Rect.inl │ │ ├── RectangleShape.hpp │ │ ├── RenderStates.hpp │ │ ├── RenderTarget.hpp │ │ ├── RenderTexture.hpp │ │ ├── RenderWindow.hpp │ │ ├── Shader.hpp │ │ ├── Shape.hpp │ │ ├── Sprite.hpp │ │ ├── Text.hpp │ │ ├── Texture.hpp │ │ ├── Transform.hpp │ │ ├── Transformable.hpp │ │ ├── Vertex.hpp │ │ ├── VertexArray.hpp │ │ ├── VertexBuffer.hpp │ │ └── View.hpp │ │ ├── Main.hpp │ │ ├── Network.hpp │ │ ├── Network │ │ ├── Export.hpp │ │ ├── Ftp.hpp │ │ ├── Http.hpp │ │ ├── IpAddress.hpp │ │ ├── Packet.hpp │ │ ├── Socket.hpp │ │ ├── SocketHandle.hpp │ │ ├── SocketSelector.hpp │ │ ├── TcpListener.hpp │ │ ├── TcpSocket.hpp │ │ └── UdpSocket.hpp │ │ ├── OpenGL.hpp │ │ ├── System.hpp │ │ ├── System │ │ ├── Clock.hpp │ │ ├── Err.hpp │ │ ├── Export.hpp │ │ ├── FileInputStream.hpp │ │ ├── InputStream.hpp │ │ ├── Lock.hpp │ │ ├── MemoryInputStream.hpp │ │ ├── Mutex.hpp │ │ ├── NativeActivity.hpp │ │ ├── NonCopyable.hpp │ │ ├── Sleep.hpp │ │ ├── String.hpp │ │ ├── String.inl │ │ ├── Thread.hpp │ │ ├── Thread.inl │ │ ├── ThreadLocal.hpp │ │ ├── ThreadLocalPtr.hpp │ │ ├── ThreadLocalPtr.inl │ │ ├── Time.hpp │ │ ├── Utf.hpp │ │ ├── Utf.inl │ │ ├── Vector2.hpp │ │ ├── Vector2.inl │ │ ├── Vector3.hpp │ │ └── Vector3.inl │ │ ├── Window.hpp │ │ └── Window │ │ ├── Clipboard.hpp │ │ ├── Context.hpp │ │ ├── ContextSettings.hpp │ │ ├── Cursor.hpp │ │ ├── Event.hpp │ │ ├── Export.hpp │ │ ├── GlResource.hpp │ │ ├── Joystick.hpp │ │ ├── Keyboard.hpp │ │ ├── Mouse.hpp │ │ ├── Sensor.hpp │ │ ├── Touch.hpp │ │ ├── VideoMode.hpp │ │ ├── Window.hpp │ │ ├── WindowHandle.hpp │ │ └── WindowStyle.hpp │ └── lib │ ├── cmake │ └── SFML │ │ ├── SFMLConfig.cmake │ │ ├── SFMLConfigDependencies.cmake │ │ ├── SFMLConfigVersion.cmake │ │ ├── SFMLSharedTargets-release.cmake │ │ └── SFMLSharedTargets.cmake │ ├── libsfml-audio.so │ ├── libsfml-audio.so.2.5 │ ├── libsfml-audio.so.2.5.1 │ ├── libsfml-graphics.so │ ├── libsfml-graphics.so.2.5 │ ├── libsfml-graphics.so.2.5.1 │ ├── libsfml-network.so │ ├── libsfml-network.so.2.5 │ ├── libsfml-network.so.2.5.1 │ ├── libsfml-system.so │ ├── libsfml-system.so.2.5 │ ├── libsfml-system.so.2.5.1 │ ├── libsfml-window.so │ ├── libsfml-window.so.2.5 │ └── libsfml-window.so.2.5.1 └── src ├── SortAlgorithms.cpp ├── SortAlgorithms.h ├── SortController.cpp ├── SortController.h ├── Sortable.cpp ├── Sortable.h ├── Utils.cpp ├── Utils.h └── main.cpp /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]: " 5 | labels: bug, needs triage 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Describe you problem: 11 | *replace me* 12 | 13 | ## Steps to reproduce (optional): 14 | *replace me* 15 | 16 | ## Additional info (optional): 17 | *replace me* 18 | 19 | ## Possible fix (optional): 20 | *replace me* 21 | 22 | ## OS 23 | - [ ] : Windows 24 | - [ ] : Mac OS 25 | - [x] : Linux 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Documentation 3 | about: Suggest a change in the documentation 4 | title: "[DOC]: " 5 | labels: documentation, needs triage 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Which part of the documentation? 11 | - [x] Wiki 12 | - [ ] Readme 13 | - [ ] Code comments 14 | - [ ] Others 15 | 16 | # Describe your suggestion 17 | *replace me* 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[FEAT]: " 5 | labels: enhancement, needs triage 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Feature description: 11 | *replace me* 12 | 13 | ## Additional info (optional): 14 | *replace me* 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | sorting-visualizer 3 | build/ 4 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | project(sorting-visualizer) 3 | 4 | set(default_build_type "Release") 5 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 6 | message( STATUS "Setting build type to '${default_build_type}' as none was specified.") 7 | set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) 8 | # Set the possible values of build type for cmake-gui 9 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 10 | "Debug" "Release" "MinSizeRel" "RelWithDebInfo") 11 | endif() 12 | 13 | set(SFML_DIR "C:/Program Files (x86)/SFML/lib/cmake/SFML") 14 | 15 | find_package(SFML COMPONENTS graphics window CONFIG REQUIRED) 16 | 17 | add_executable(sorting-visualizer src/main.cpp src/Sortable.cpp src/SortAlgorithms.cpp src/SortController.cpp src/Utils.cpp) 18 | 19 | target_link_libraries(sorting-visualizer sfml-graphics sfml-window) 20 | 21 | # Copy across .dlls for windows users 22 | get_target_property(SFML_TYPE sfml-graphics TYPE) 23 | if(SFML_TYPE STREQUAL "SHARED_LIBRARY") 24 | message(STATUS "Copying sfml-graphics DLLs to ${CMAKE_CURRENT_BINARY_DIR}/$") 25 | add_custom_command( 26 | TARGET sorting-visualizer POST_BUILD 27 | COMMAND ${CMAKE_COMMAND} -E copy 28 | $ 29 | ${CMAKE_CURRENT_BINARY_DIR}/$) 30 | 31 | message(STATUS "Copying sfml-window DLLs to ${CMAKE_CURRENT_BINARY_DIR}/$") 32 | add_custom_command( 33 | TARGET sorting-visualizer POST_BUILD 34 | COMMAND ${CMAKE_COMMAND} -E copy 35 | $ 36 | ${CMAKE_CURRENT_BINARY_DIR}/$) 37 | 38 | message(STATUS "Copying sfml-system DLLs to ${CMAKE_CURRENT_BINARY_DIR}/$") 39 | add_custom_command( 40 | TARGET sorting-visualizer POST_BUILD 41 | COMMAND ${CMAKE_COMMAND} -E copy 42 | $ 43 | ${CMAKE_CURRENT_BINARY_DIR}/$) 44 | endif() 45 | 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 alesbe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 📊 Sorting Visualizer 2 | 3 | A lightweight sorting visualizer made with C++ and [SFML](https://www.sfml-dev.org/index.php). 4 | 5 | | ![Quick sort gif](https://i.imgur.com/TsWwumg.gif) | 6 | |:--:| 7 | | *Quick sort* | 8 | 9 | | ![Bubble visualizer](https://i.imgur.com/086SZ51.png) | 10 | |:--:| 11 | | *Bubble sort* | 12 | 13 | | ![Bubble sort info](https://i.imgur.com/P5ypw86.png) | 14 | |:--:| 15 | | *Bubble sort info* | 16 | 17 | ## 📖 I want to contribute to the project! 18 | Awesome! [Here](https://github.com/alesbe/sorting-visualizer/wiki) you can find some useful info about the visualizer, we accept first contributors too! 19 | 20 | *Also, make sure to pull the last changes from [dev](https://github.com/alesbe/sorting-visualizer/tree/dev) branch!* 21 | 22 | ## 🗂️ Sort types 23 | - **Bubble sort** 24 | - Bubble sort works by continuously swapping elements next to each other that are in the wrong place. Starting from the beginning of the dataset, each element 'floats' to its correct spot. More on Bubble sort can be found [here](https://www.geeksforgeeks.org/bubble-sort/). 25 | - **Selection sort** 26 | - Selection sort works by having two sections, the sorted and unsorted sections, and continuously search through the unsorted section and place the smallest element into the sorted section. This sorting algorithm could be implemented where the largest element is selected instead. More on selection sort can be found [here](https://www.geeksforgeeks.org/selection-sort/). 27 | - **Insertion sort** 28 | - Insertion sort is similar to selection sort in that they both have a sorted and unsorted section. Instead of continuously selected the smallest/largest element, it will insert a selected element from the unsorted portion and 'insert' it into the correct spot in the sorted section. More on insertion sort can be found [here](https://www.geeksforgeeks.org/insertion-sort/). 29 | - **Quick sort** 30 | - Quick sort is a "Divide and Conquer" algorithm. Divide and Conquer algorithms work by splitting the problem into smaller portions, solving the smaller problems, then combing the solutions into one final solution. Quick sort works by choosing an element as a 'pivot', moving the other elements around where elements less than the pivot are on one side and elements greater than the pivot are on the other, then continuously doing that process with each side. Once each element has been partitioned, the solution is combined into the sorted array. More on quick sort can be found [here](https://www.geeksforgeeks.org/quick-sort/) and more on Divide and Conquer algorithms can be found [here](https://www.geeksforgeeks.org/introduction-to-divide-and-conquer-algorithm-data-structure-and-algorithm-tutorials/). 31 | - **Cocktail shaker sort** 32 | - Cocktail shaker sort is a variant of Bubble Sort. Instead of only having elements 'float' from the bottom to its correct spot in the dataset, elements also 'sink' from the top of the datset into its correct position. More on cocktail shaker sort can be found [here](https://www.geeksforgeeks.org/cocktail-sort/). 33 | - **Bogo sort** 34 | - Bogo sort is an inefficient sorting algorithm where it randomly generates different versions of the original dataset and checks if it's sorted or not. More on bogo sort can be found [here](https://www.geeksforgeeks.org/bogosort-permutation-sort/). 35 | - **Bitonic sort** 36 | - Bitonic sort is a comparison based sorting algorithm that can be run with parallel implementation. Within different subarrays, the algorithm checks if the first element is smaller than the second and vice versa. It continuously does that on larger subarrays until the whole dataset is sorted. More on bitonic sort can be found [here](https://www.geeksforgeeks.org/bitonic-sort/). 37 | - **Odd-Even sort** 38 | - Odd-Even sort is comparassion vased sorting algorithm developed for use on pararell processors, its based on bubble sort but is divided into two phases Odd and Even Phase. On Odd phase algorithm performs bubble sort on odd indexed elements, during even phase on even indexed elements. More on Odd-Even sort can be found [here](https://www.geeksforgeeks.org/odd-even-sort-brick-sort/). 39 | 40 | 41 | ## 🕹️ Usage 42 | - **Space**: Start sort
43 | - **Backspace**: Stop sort
44 | - **h**: Display help
45 | - **F1**: Change number of elements
46 | - **F2**: Change time between comparisons
47 | - **Arrow Up / Arrow down**: Change sort type
48 | 49 | ## 🖨️ Download 50 | **Requirements:** 51 | - CMake 52 | 53 | ### 🐧 Linux 54 | - Clone the project: `git clone https://github.com/alesbe/sorting-visualizer && cd sorting-visualizer` 55 | - Run `./install.sh` 56 | 57 | ### 🖥️ Windows / MacOS 58 | #### [Download from releases](https://github.com/alesbe/sorting-visualizer/releases/) 59 | 60 | If you want to compile the project by yourself you need to follow the next steps: 61 | 1. Download SFML from the [official website](https://www.sfml-dev.org/download/sfml/2.6.1/) 62 | 2. Download [CMake](https://cmake.org/download/) 63 | 3. Clone the repository 64 | 4. Open `CMakeLists.txt` and locate the variable `SFML_DIR`. Set the path to the route where the SFML CMake files are located. For instance `C:/Program Files (x86)/SFML/lib/cmake/SFML`. 65 | 5. From the root directory of the repository, run: 66 | ``` 67 | mkdir build cd build 68 | cmake .. 69 | cmake -G 'Visual Studio 17 2022' .. 70 | ``` 71 | 6. In the `/build` directory should be a Visual Studio solution. Now you can open the solution and compile the file with the play button as usual! 72 | 73 | _Note: If you don't want to use Visual Studio 2022, download SFML for your target compiler and change the cmake generator in step 6. You can check the list of generators with cmake -G_ 74 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | main() { 3 | # Build Makefile 4 | echo "Building Makefile..." 5 | mkdir -p build 6 | pushd build 7 | cmake .. 8 | 9 | # Compile using Makefile 10 | echo "" 11 | echo "Compiling project..." 12 | popd 13 | cmake --build build 14 | 15 | # Select binary location 16 | echo "" 17 | echo "Would you like to move the visualizer to /usr/bin? (Requires root)" 18 | read -n 1 -p "yes (default) / no: " option 19 | echo "" 20 | echo "" 21 | 22 | # Option 1: Leave the binary in the same folder (project root) 23 | if [ "$option" = "n" ]; then 24 | mv build/sorting-visualizer . 25 | echo "Done! Run ./sorting-visualizer" 26 | exit 27 | fi 28 | 29 | # Option 2: Move the binary to /usr/bin 30 | sudo mv build/sorting-visualizer /usr/bin 31 | echo "Done! Run sorting-visualizer" 32 | 33 | exit 34 | } 35 | 36 | main 37 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Audio.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_AUDIO_HPP 26 | #define SFML_AUDIO_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | 48 | #endif // SFML_AUDIO_HPP 49 | 50 | //////////////////////////////////////////////////////////// 51 | /// \defgroup audio Audio module 52 | /// 53 | /// Sounds, streaming (musics or custom sources), recording, 54 | /// spatialization. 55 | /// 56 | //////////////////////////////////////////////////////////// 57 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Audio/AlResource.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_ALRESOURCE_HPP 26 | #define SFML_ALRESOURCE_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | namespace sf 35 | { 36 | //////////////////////////////////////////////////////////// 37 | /// \brief Base class for classes that require an OpenAL context 38 | /// 39 | //////////////////////////////////////////////////////////// 40 | class SFML_AUDIO_API AlResource 41 | { 42 | protected: 43 | 44 | //////////////////////////////////////////////////////////// 45 | /// \brief Default constructor 46 | /// 47 | //////////////////////////////////////////////////////////// 48 | AlResource(); 49 | 50 | //////////////////////////////////////////////////////////// 51 | /// \brief Destructor 52 | /// 53 | //////////////////////////////////////////////////////////// 54 | ~AlResource(); 55 | }; 56 | 57 | } // namespace sf 58 | 59 | 60 | #endif // SFML_ALRESOURCE_HPP 61 | 62 | //////////////////////////////////////////////////////////// 63 | /// \class sf::AlResource 64 | /// \ingroup audio 65 | /// 66 | /// This class is for internal use only, it must be the base 67 | /// of every class that requires a valid OpenAL context in 68 | /// order to work. 69 | /// 70 | //////////////////////////////////////////////////////////// 71 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Audio/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_AUDIO_EXPORT_HPP 26 | #define SFML_AUDIO_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_AUDIO_EXPORTS) 38 | 39 | #define SFML_AUDIO_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_AUDIO_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_AUDIO_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Audio/OutputSoundFile.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_OUTPUTSOUNDFILE_HPP 26 | #define SFML_OUTPUTSOUNDFILE_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | #include 34 | 35 | 36 | namespace sf 37 | { 38 | class SoundFileWriter; 39 | 40 | //////////////////////////////////////////////////////////// 41 | /// \brief Provide write access to sound files 42 | /// 43 | //////////////////////////////////////////////////////////// 44 | class SFML_AUDIO_API OutputSoundFile : NonCopyable 45 | { 46 | public: 47 | 48 | //////////////////////////////////////////////////////////// 49 | /// \brief Default constructor 50 | /// 51 | //////////////////////////////////////////////////////////// 52 | OutputSoundFile(); 53 | 54 | //////////////////////////////////////////////////////////// 55 | /// \brief Destructor 56 | /// 57 | /// Closes the file if it was still open. 58 | /// 59 | //////////////////////////////////////////////////////////// 60 | ~OutputSoundFile(); 61 | 62 | //////////////////////////////////////////////////////////// 63 | /// \brief Open the sound file from the disk for writing 64 | /// 65 | /// The supported audio formats are: WAV, OGG/Vorbis, FLAC. 66 | /// 67 | /// \param filename Path of the sound file to write 68 | /// \param sampleRate Sample rate of the sound 69 | /// \param channelCount Number of channels in the sound 70 | /// 71 | /// \return True if the file was successfully opened 72 | /// 73 | //////////////////////////////////////////////////////////// 74 | bool openFromFile(const std::string& filename, unsigned int sampleRate, unsigned int channelCount); 75 | 76 | //////////////////////////////////////////////////////////// 77 | /// \brief Write audio samples to the file 78 | /// 79 | /// \param samples Pointer to the sample array to write 80 | /// \param count Number of samples to write 81 | /// 82 | //////////////////////////////////////////////////////////// 83 | void write(const Int16* samples, Uint64 count); 84 | 85 | private: 86 | 87 | //////////////////////////////////////////////////////////// 88 | /// \brief Close the current file 89 | /// 90 | //////////////////////////////////////////////////////////// 91 | void close(); 92 | 93 | //////////////////////////////////////////////////////////// 94 | // Member data 95 | //////////////////////////////////////////////////////////// 96 | SoundFileWriter* m_writer; ///< Writer that handles I/O on the file's format 97 | }; 98 | 99 | } // namespace sf 100 | 101 | 102 | #endif // SFML_OUTPUTSOUNDFILE_HPP 103 | 104 | 105 | //////////////////////////////////////////////////////////// 106 | /// \class sf::OutputSoundFile 107 | /// \ingroup audio 108 | /// 109 | /// This class encodes audio samples to a sound file. It is 110 | /// used internally by higher-level classes such as sf::SoundBuffer, 111 | /// but can also be useful if you want to create audio files from 112 | /// custom data sources, like generated audio samples. 113 | /// 114 | /// Usage example: 115 | /// \code 116 | /// // Create a sound file, ogg/vorbis format, 44100 Hz, stereo 117 | /// sf::OutputSoundFile file; 118 | /// if (!file.openFromFile("music.ogg", 44100, 2)) 119 | /// /* error */; 120 | /// 121 | /// while (...) 122 | /// { 123 | /// // Read or generate audio samples from your custom source 124 | /// std::vector samples = ...; 125 | /// 126 | /// // Write them to the file 127 | /// file.write(samples.data(), samples.size()); 128 | /// } 129 | /// \endcode 130 | /// 131 | /// \see sf::SoundFileWriter, sf::InputSoundFile 132 | /// 133 | //////////////////////////////////////////////////////////// 134 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Audio/SoundBufferRecorder.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SOUNDBUFFERRECORDER_HPP 26 | #define SFML_SOUNDBUFFERRECORDER_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | 37 | namespace sf 38 | { 39 | //////////////////////////////////////////////////////////// 40 | /// \brief Specialized SoundRecorder which stores the captured 41 | /// audio data into a sound buffer 42 | /// 43 | //////////////////////////////////////////////////////////// 44 | class SFML_AUDIO_API SoundBufferRecorder : public SoundRecorder 45 | { 46 | public: 47 | 48 | //////////////////////////////////////////////////////////// 49 | /// \brief destructor 50 | /// 51 | //////////////////////////////////////////////////////////// 52 | ~SoundBufferRecorder(); 53 | 54 | //////////////////////////////////////////////////////////// 55 | /// \brief Get the sound buffer containing the captured audio data 56 | /// 57 | /// The sound buffer is valid only after the capture has ended. 58 | /// This function provides a read-only access to the internal 59 | /// sound buffer, but it can be copied if you need to 60 | /// make any modification to it. 61 | /// 62 | /// \return Read-only access to the sound buffer 63 | /// 64 | //////////////////////////////////////////////////////////// 65 | const SoundBuffer& getBuffer() const; 66 | 67 | protected: 68 | 69 | //////////////////////////////////////////////////////////// 70 | /// \brief Start capturing audio data 71 | /// 72 | /// \return True to start the capture, or false to abort it 73 | /// 74 | //////////////////////////////////////////////////////////// 75 | virtual bool onStart(); 76 | 77 | //////////////////////////////////////////////////////////// 78 | /// \brief Process a new chunk of recorded samples 79 | /// 80 | /// \param samples Pointer to the new chunk of recorded samples 81 | /// \param sampleCount Number of samples pointed by \a samples 82 | /// 83 | /// \return True to continue the capture, or false to stop it 84 | /// 85 | //////////////////////////////////////////////////////////// 86 | virtual bool onProcessSamples(const Int16* samples, std::size_t sampleCount); 87 | 88 | //////////////////////////////////////////////////////////// 89 | /// \brief Stop capturing audio data 90 | /// 91 | //////////////////////////////////////////////////////////// 92 | virtual void onStop(); 93 | 94 | private: 95 | 96 | //////////////////////////////////////////////////////////// 97 | // Member data 98 | //////////////////////////////////////////////////////////// 99 | std::vector m_samples; ///< Temporary sample buffer to hold the recorded data 100 | SoundBuffer m_buffer; ///< Sound buffer that will contain the recorded data 101 | }; 102 | 103 | } // namespace sf 104 | 105 | #endif // SFML_SOUNDBUFFERRECORDER_HPP 106 | 107 | 108 | //////////////////////////////////////////////////////////// 109 | /// \class sf::SoundBufferRecorder 110 | /// \ingroup audio 111 | /// 112 | /// sf::SoundBufferRecorder allows to access a recorded sound 113 | /// through a sf::SoundBuffer, so that it can be played, saved 114 | /// to a file, etc. 115 | /// 116 | /// It has the same simple interface as its base class (start(), stop()) 117 | /// and adds a function to retrieve the recorded sound buffer 118 | /// (getBuffer()). 119 | /// 120 | /// As usual, don't forget to call the isAvailable() function 121 | /// before using this class (see sf::SoundRecorder for more details 122 | /// about this). 123 | /// 124 | /// Usage example: 125 | /// \code 126 | /// if (sf::SoundBufferRecorder::isAvailable()) 127 | /// { 128 | /// // Record some audio data 129 | /// sf::SoundBufferRecorder recorder; 130 | /// recorder.start(); 131 | /// ... 132 | /// recorder.stop(); 133 | /// 134 | /// // Get the buffer containing the captured audio data 135 | /// const sf::SoundBuffer& buffer = recorder.getBuffer(); 136 | /// 137 | /// // Save it to a file (for example...) 138 | /// buffer.saveToFile("my_record.ogg"); 139 | /// } 140 | /// \endcode 141 | /// 142 | /// \see sf::SoundRecorder 143 | /// 144 | //////////////////////////////////////////////////////////// 145 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Audio/SoundFileFactory.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | //////////////////////////////////////////////////////////// 26 | // Headers 27 | //////////////////////////////////////////////////////////// 28 | 29 | 30 | namespace sf 31 | { 32 | namespace priv 33 | { 34 | template SoundFileReader* createReader() {return new T;} 35 | template SoundFileWriter* createWriter() {return new T;} 36 | } 37 | 38 | //////////////////////////////////////////////////////////// 39 | template 40 | void SoundFileFactory::registerReader() 41 | { 42 | // Make sure the same class won't be registered twice 43 | unregisterReader(); 44 | 45 | // Create a new factory with the functions provided by the class 46 | ReaderFactory factory; 47 | factory.check = &T::check; 48 | factory.create = &priv::createReader; 49 | 50 | // Add it 51 | s_readers.push_back(factory); 52 | } 53 | 54 | 55 | //////////////////////////////////////////////////////////// 56 | template 57 | void SoundFileFactory::unregisterReader() 58 | { 59 | // Remove the instance(s) of the reader from the array of factories 60 | for (ReaderFactoryArray::iterator it = s_readers.begin(); it != s_readers.end(); ) 61 | { 62 | if (it->create == &priv::createReader) 63 | it = s_readers.erase(it); 64 | else 65 | ++it; 66 | } 67 | } 68 | 69 | //////////////////////////////////////////////////////////// 70 | template 71 | void SoundFileFactory::registerWriter() 72 | { 73 | // Make sure the same class won't be registered twice 74 | unregisterWriter(); 75 | 76 | // Create a new factory with the functions provided by the class 77 | WriterFactory factory; 78 | factory.check = &T::check; 79 | factory.create = &priv::createWriter; 80 | 81 | // Add it 82 | s_writers.push_back(factory); 83 | } 84 | 85 | 86 | //////////////////////////////////////////////////////////// 87 | template 88 | void SoundFileFactory::unregisterWriter() 89 | { 90 | // Remove the instance(s) of the writer from the array of factories 91 | for (WriterFactoryArray::iterator it = s_writers.begin(); it != s_writers.end(); ) 92 | { 93 | if (it->create == &priv::createWriter) 94 | it = s_writers.erase(it); 95 | else 96 | ++it; 97 | } 98 | } 99 | 100 | } // namespace sf 101 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Audio/SoundFileWriter.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SOUNDFILEWRITER_HPP 26 | #define SFML_SOUNDFILEWRITER_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | //////////////////////////////////////////////////////////// 38 | /// \brief Abstract base class for sound file encoding 39 | /// 40 | //////////////////////////////////////////////////////////// 41 | class SFML_AUDIO_API SoundFileWriter 42 | { 43 | public: 44 | 45 | //////////////////////////////////////////////////////////// 46 | /// \brief Virtual destructor 47 | /// 48 | //////////////////////////////////////////////////////////// 49 | virtual ~SoundFileWriter() {} 50 | 51 | //////////////////////////////////////////////////////////// 52 | /// \brief Open a sound file for writing 53 | /// 54 | /// \param filename Path of the file to open 55 | /// \param sampleRate Sample rate of the sound 56 | /// \param channelCount Number of channels of the sound 57 | /// 58 | /// \return True if the file was successfully opened 59 | /// 60 | //////////////////////////////////////////////////////////// 61 | virtual bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) = 0; 62 | 63 | //////////////////////////////////////////////////////////// 64 | /// \brief Write audio samples to the open file 65 | /// 66 | /// \param samples Pointer to the sample array to write 67 | /// \param count Number of samples to write 68 | /// 69 | //////////////////////////////////////////////////////////// 70 | virtual void write(const Int16* samples, Uint64 count) = 0; 71 | }; 72 | 73 | } // namespace sf 74 | 75 | 76 | #endif // SFML_SOUNDFILEWRITER_HPP 77 | 78 | 79 | //////////////////////////////////////////////////////////// 80 | /// \class sf::SoundFileWriter 81 | /// \ingroup audio 82 | /// 83 | /// This class allows users to write audio file formats not natively 84 | /// supported by SFML, and thus extend the set of supported writable 85 | /// audio formats. 86 | /// 87 | /// A valid sound file writer must override the open and write functions, 88 | /// as well as providing a static check function; the latter is used by 89 | /// SFML to find a suitable writer for a given filename. 90 | /// 91 | /// To register a new writer, use the sf::SoundFileFactory::registerWriter 92 | /// template function. 93 | /// 94 | /// Usage example: 95 | /// \code 96 | /// class MySoundFileWriter : public sf::SoundFileWriter 97 | /// { 98 | /// public: 99 | /// 100 | /// static bool check(const std::string& filename) 101 | /// { 102 | /// // typically, check the extension 103 | /// // return true if the writer can handle the format 104 | /// } 105 | /// 106 | /// virtual bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) 107 | /// { 108 | /// // open the file 'filename' for writing, 109 | /// // write the given sample rate and channel count to the file header 110 | /// // return true on success 111 | /// } 112 | /// 113 | /// virtual void write(const sf::Int16* samples, sf::Uint64 count) 114 | /// { 115 | /// // write 'count' samples stored at address 'samples', 116 | /// // convert them (for example to normalized float) if the format requires it 117 | /// } 118 | /// }; 119 | /// 120 | /// sf::SoundFileFactory::registerWriter(); 121 | /// \endcode 122 | /// 123 | /// \see sf::OutputSoundFile, sf::SoundFileFactory, sf::SoundFileReader 124 | /// 125 | //////////////////////////////////////////////////////////// 126 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/GpuPreference.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_GPUPREFERENCE_HPP 26 | #define SFML_GPUPREFERENCE_HPP 27 | 28 | 29 | //////////////////////////////////////////////////////////// 30 | /// Headers 31 | //////////////////////////////////////////////////////////// 32 | #include 33 | 34 | 35 | //////////////////////////////////////////////////////////// 36 | /// \file 37 | /// 38 | /// \brief File containing SFML_DEFINE_DISCRETE_GPU_PREFERENCE 39 | /// 40 | //////////////////////////////////////////////////////////// 41 | 42 | 43 | //////////////////////////////////////////////////////////// 44 | /// \def SFML_DEFINE_DISCRETE_GPU_PREFERENCE 45 | /// 46 | /// \brief A macro to encourage usage of the discrete GPU 47 | /// 48 | /// In order to inform the Nvidia/AMD driver that an SFML 49 | /// application could benefit from using the more powerful 50 | /// discrete GPU, special symbols have to be publicly 51 | /// exported from the final executable. 52 | /// 53 | /// SFML defines a helper macro to easily do this. 54 | /// 55 | /// Place SFML_DEFINE_DISCRETE_GPU_PREFERENCE in the 56 | /// global scope of a source file that will be linked into 57 | /// the final executable. Typically it is best to place it 58 | /// where the main function is also defined. 59 | /// 60 | //////////////////////////////////////////////////////////// 61 | #if defined(SFML_SYSTEM_WINDOWS) 62 | 63 | #define SFML_DEFINE_DISCRETE_GPU_PREFERENCE \ 64 | extern "C" __declspec(dllexport) unsigned long NvOptimusEnablement = 1; \ 65 | extern "C" __declspec(dllexport) unsigned long AmdPowerXpressRequestHighPerformance = 1; 66 | 67 | #else 68 | 69 | #define SFML_DEFINE_DISCRETE_GPU_PREFERENCE 70 | 71 | #endif 72 | 73 | 74 | #endif // SFML_GPUPREFERENCE_HPP 75 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Graphics.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_GRAPHICS_HPP 26 | #define SFML_GRAPHICS_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | 60 | 61 | #endif // SFML_GRAPHICS_HPP 62 | 63 | //////////////////////////////////////////////////////////// 64 | /// \defgroup graphics Graphics module 65 | /// 66 | /// 2D graphics module: sprites, text, shapes, ... 67 | /// 68 | //////////////////////////////////////////////////////////// 69 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Graphics/CircleShape.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_CIRCLESHAPE_HPP 26 | #define SFML_CIRCLESHAPE_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | //////////////////////////////////////////////////////////// 38 | /// \brief Specialized shape representing a circle 39 | /// 40 | //////////////////////////////////////////////////////////// 41 | class SFML_GRAPHICS_API CircleShape : public Shape 42 | { 43 | public: 44 | 45 | //////////////////////////////////////////////////////////// 46 | /// \brief Default constructor 47 | /// 48 | /// \param radius Radius of the circle 49 | /// \param pointCount Number of points composing the circle 50 | /// 51 | //////////////////////////////////////////////////////////// 52 | explicit CircleShape(float radius = 0, std::size_t pointCount = 30); 53 | 54 | //////////////////////////////////////////////////////////// 55 | /// \brief Set the radius of the circle 56 | /// 57 | /// \param radius New radius of the circle 58 | /// 59 | /// \see getRadius 60 | /// 61 | //////////////////////////////////////////////////////////// 62 | void setRadius(float radius); 63 | 64 | //////////////////////////////////////////////////////////// 65 | /// \brief Get the radius of the circle 66 | /// 67 | /// \return Radius of the circle 68 | /// 69 | /// \see setRadius 70 | /// 71 | //////////////////////////////////////////////////////////// 72 | float getRadius() const; 73 | 74 | //////////////////////////////////////////////////////////// 75 | /// \brief Set the number of points of the circle 76 | /// 77 | /// \param count New number of points of the circle 78 | /// 79 | /// \see getPointCount 80 | /// 81 | //////////////////////////////////////////////////////////// 82 | void setPointCount(std::size_t count); 83 | 84 | //////////////////////////////////////////////////////////// 85 | /// \brief Get the number of points of the circle 86 | /// 87 | /// \return Number of points of the circle 88 | /// 89 | /// \see setPointCount 90 | /// 91 | //////////////////////////////////////////////////////////// 92 | virtual std::size_t getPointCount() const; 93 | 94 | //////////////////////////////////////////////////////////// 95 | /// \brief Get a point of the circle 96 | /// 97 | /// The returned point is in local coordinates, that is, 98 | /// the shape's transforms (position, rotation, scale) are 99 | /// not taken into account. 100 | /// The result is undefined if \a index is out of the valid range. 101 | /// 102 | /// \param index Index of the point to get, in range [0 .. getPointCount() - 1] 103 | /// 104 | /// \return index-th point of the shape 105 | /// 106 | //////////////////////////////////////////////////////////// 107 | virtual Vector2f getPoint(std::size_t index) const; 108 | 109 | private: 110 | 111 | //////////////////////////////////////////////////////////// 112 | // Member data 113 | //////////////////////////////////////////////////////////// 114 | float m_radius; ///< Radius of the circle 115 | std::size_t m_pointCount; ///< Number of points composing the circle 116 | }; 117 | 118 | } // namespace sf 119 | 120 | 121 | #endif // SFML_CIRCLESHAPE_HPP 122 | 123 | 124 | //////////////////////////////////////////////////////////// 125 | /// \class sf::CircleShape 126 | /// \ingroup graphics 127 | /// 128 | /// This class inherits all the functions of sf::Transformable 129 | /// (position, rotation, scale, bounds, ...) as well as the 130 | /// functions of sf::Shape (outline, color, texture, ...). 131 | /// 132 | /// Usage example: 133 | /// \code 134 | /// sf::CircleShape circle; 135 | /// circle.setRadius(150); 136 | /// circle.setOutlineColor(sf::Color::Red); 137 | /// circle.setOutlineThickness(5); 138 | /// circle.setPosition(10, 20); 139 | /// ... 140 | /// window.draw(circle); 141 | /// \endcode 142 | /// 143 | /// Since the graphics card can't draw perfect circles, we have to 144 | /// fake them with multiple triangles connected to each other. The 145 | /// "points count" property of sf::CircleShape defines how many of these 146 | /// triangles to use, and therefore defines the quality of the circle. 147 | /// 148 | /// The number of points can also be used for another purpose; with 149 | /// small numbers you can create any regular polygon shape: 150 | /// equilateral triangle, square, pentagon, hexagon, ... 151 | /// 152 | /// \see sf::Shape, sf::RectangleShape, sf::ConvexShape 153 | /// 154 | //////////////////////////////////////////////////////////// 155 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Graphics/ConvexShape.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_CONVEXSHAPE_HPP 26 | #define SFML_CONVEXSHAPE_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | #include 34 | 35 | 36 | namespace sf 37 | { 38 | //////////////////////////////////////////////////////////// 39 | /// \brief Specialized shape representing a convex polygon 40 | /// 41 | //////////////////////////////////////////////////////////// 42 | class SFML_GRAPHICS_API ConvexShape : public Shape 43 | { 44 | public: 45 | 46 | //////////////////////////////////////////////////////////// 47 | /// \brief Default constructor 48 | /// 49 | /// \param pointCount Number of points of the polygon 50 | /// 51 | //////////////////////////////////////////////////////////// 52 | explicit ConvexShape(std::size_t pointCount = 0); 53 | 54 | //////////////////////////////////////////////////////////// 55 | /// \brief Set the number of points of the polygon 56 | /// 57 | /// \a count must be greater than 2 to define a valid shape. 58 | /// 59 | /// \param count New number of points of the polygon 60 | /// 61 | /// \see getPointCount 62 | /// 63 | //////////////////////////////////////////////////////////// 64 | void setPointCount(std::size_t count); 65 | 66 | //////////////////////////////////////////////////////////// 67 | /// \brief Get the number of points of the polygon 68 | /// 69 | /// \return Number of points of the polygon 70 | /// 71 | /// \see setPointCount 72 | /// 73 | //////////////////////////////////////////////////////////// 74 | virtual std::size_t getPointCount() const; 75 | 76 | //////////////////////////////////////////////////////////// 77 | /// \brief Set the position of a point 78 | /// 79 | /// Don't forget that the polygon must remain convex, and 80 | /// the points need to stay ordered! 81 | /// setPointCount must be called first in order to set the total 82 | /// number of points. The result is undefined if \a index is out 83 | /// of the valid range. 84 | /// 85 | /// \param index Index of the point to change, in range [0 .. getPointCount() - 1] 86 | /// \param point New position of the point 87 | /// 88 | /// \see getPoint 89 | /// 90 | //////////////////////////////////////////////////////////// 91 | void setPoint(std::size_t index, const Vector2f& point); 92 | 93 | //////////////////////////////////////////////////////////// 94 | /// \brief Get the position of a point 95 | /// 96 | /// The returned point is in local coordinates, that is, 97 | /// the shape's transforms (position, rotation, scale) are 98 | /// not taken into account. 99 | /// The result is undefined if \a index is out of the valid range. 100 | /// 101 | /// \param index Index of the point to get, in range [0 .. getPointCount() - 1] 102 | /// 103 | /// \return Position of the index-th point of the polygon 104 | /// 105 | /// \see setPoint 106 | /// 107 | //////////////////////////////////////////////////////////// 108 | virtual Vector2f getPoint(std::size_t index) const; 109 | 110 | private: 111 | 112 | //////////////////////////////////////////////////////////// 113 | // Member data 114 | //////////////////////////////////////////////////////////// 115 | std::vector m_points; ///< Points composing the convex polygon 116 | }; 117 | 118 | } // namespace sf 119 | 120 | 121 | #endif // SFML_CONVEXSHAPE_HPP 122 | 123 | 124 | //////////////////////////////////////////////////////////// 125 | /// \class sf::ConvexShape 126 | /// \ingroup graphics 127 | /// 128 | /// This class inherits all the functions of sf::Transformable 129 | /// (position, rotation, scale, bounds, ...) as well as the 130 | /// functions of sf::Shape (outline, color, texture, ...). 131 | /// 132 | /// It is important to keep in mind that a convex shape must 133 | /// always be... convex, otherwise it may not be drawn correctly. 134 | /// Moreover, the points must be defined in order; using a random 135 | /// order would result in an incorrect shape. 136 | /// 137 | /// Usage example: 138 | /// \code 139 | /// sf::ConvexShape polygon; 140 | /// polygon.setPointCount(3); 141 | /// polygon.setPoint(0, sf::Vector2f(0, 0)); 142 | /// polygon.setPoint(1, sf::Vector2f(0, 10)); 143 | /// polygon.setPoint(2, sf::Vector2f(25, 5)); 144 | /// polygon.setOutlineColor(sf::Color::Red); 145 | /// polygon.setOutlineThickness(5); 146 | /// polygon.setPosition(10, 20); 147 | /// ... 148 | /// window.draw(polygon); 149 | /// \endcode 150 | /// 151 | /// \see sf::Shape, sf::RectangleShape, sf::CircleShape 152 | /// 153 | //////////////////////////////////////////////////////////// 154 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Graphics/Drawable.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_DRAWABLE_HPP 26 | #define SFML_DRAWABLE_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | class RenderTarget; 38 | 39 | //////////////////////////////////////////////////////////// 40 | /// \brief Abstract base class for objects that can be drawn 41 | /// to a render target 42 | /// 43 | //////////////////////////////////////////////////////////// 44 | class SFML_GRAPHICS_API Drawable 45 | { 46 | public: 47 | 48 | //////////////////////////////////////////////////////////// 49 | /// \brief Virtual destructor 50 | /// 51 | //////////////////////////////////////////////////////////// 52 | virtual ~Drawable() {} 53 | 54 | protected: 55 | 56 | friend class RenderTarget; 57 | 58 | //////////////////////////////////////////////////////////// 59 | /// \brief Draw the object to a render target 60 | /// 61 | /// This is a pure virtual function that has to be implemented 62 | /// by the derived class to define how the drawable should be 63 | /// drawn. 64 | /// 65 | /// \param target Render target to draw to 66 | /// \param states Current render states 67 | /// 68 | //////////////////////////////////////////////////////////// 69 | virtual void draw(RenderTarget& target, RenderStates states) const = 0; 70 | }; 71 | 72 | } // namespace sf 73 | 74 | 75 | #endif // SFML_DRAWABLE_HPP 76 | 77 | 78 | //////////////////////////////////////////////////////////// 79 | /// \class sf::Drawable 80 | /// \ingroup graphics 81 | /// 82 | /// sf::Drawable is a very simple base class that allows objects 83 | /// of derived classes to be drawn to a sf::RenderTarget. 84 | /// 85 | /// All you have to do in your derived class is to override the 86 | /// draw virtual function. 87 | /// 88 | /// Note that inheriting from sf::Drawable is not mandatory, 89 | /// but it allows this nice syntax "window.draw(object)" rather 90 | /// than "object.draw(window)", which is more consistent with other 91 | /// SFML classes. 92 | /// 93 | /// Example: 94 | /// \code 95 | /// class MyDrawable : public sf::Drawable 96 | /// { 97 | /// public: 98 | /// 99 | /// ... 100 | /// 101 | /// private: 102 | /// 103 | /// virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const 104 | /// { 105 | /// // You can draw other high-level objects 106 | /// target.draw(m_sprite, states); 107 | /// 108 | /// // ... or use the low-level API 109 | /// states.texture = &m_texture; 110 | /// target.draw(m_vertices, states); 111 | /// 112 | /// // ... or draw with OpenGL directly 113 | /// glBegin(GL_QUADS); 114 | /// ... 115 | /// glEnd(); 116 | /// } 117 | /// 118 | /// sf::Sprite m_sprite; 119 | /// sf::Texture m_texture; 120 | /// sf::VertexArray m_vertices; 121 | /// }; 122 | /// \endcode 123 | /// 124 | /// \see sf::RenderTarget 125 | /// 126 | //////////////////////////////////////////////////////////// 127 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Graphics/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_GRAPHICS_EXPORT_HPP 26 | #define SFML_GRAPHICS_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_GRAPHICS_EXPORTS) 38 | 39 | #define SFML_GRAPHICS_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_GRAPHICS_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_GRAPHICS_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Graphics/Glsl.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | 26 | //////////////////////////////////////////////////////////// 27 | /// \brief Helper functions to copy sf::Transform to sf::Glsl::Mat3/4 28 | /// 29 | //////////////////////////////////////////////////////////// 30 | void SFML_GRAPHICS_API copyMatrix(const Transform& source, Matrix<3, 3>& dest); 31 | void SFML_GRAPHICS_API copyMatrix(const Transform& source, Matrix<4, 4>& dest); 32 | 33 | //////////////////////////////////////////////////////////// 34 | /// \brief Copy array-based matrix with given number of elements 35 | /// 36 | /// Indirection to std::copy() to avoid inclusion of 37 | /// and MSVC's annoying 4996 warning in header 38 | /// 39 | //////////////////////////////////////////////////////////// 40 | void SFML_GRAPHICS_API copyMatrix(const float* source, std::size_t elements, float* dest); 41 | 42 | //////////////////////////////////////////////////////////// 43 | /// \brief Helper functions to copy sf::Color to sf::Glsl::Vec4/Ivec4 44 | /// 45 | //////////////////////////////////////////////////////////// 46 | void SFML_GRAPHICS_API copyVector(const Color& source, Vector4& dest); 47 | void SFML_GRAPHICS_API copyVector(const Color& source, Vector4& dest); 48 | 49 | 50 | //////////////////////////////////////////////////////////// 51 | /// \brief Matrix type, used to set uniforms in GLSL 52 | /// 53 | //////////////////////////////////////////////////////////// 54 | template 55 | struct Matrix 56 | { 57 | //////////////////////////////////////////////////////////// 58 | /// \brief Construct from raw data 59 | /// 60 | /// \param pointer Points to the beginning of an array that 61 | /// has the size of the matrix. The elements 62 | /// are copied to the instance. 63 | /// 64 | //////////////////////////////////////////////////////////// 65 | explicit Matrix(const float* pointer) 66 | { 67 | copyMatrix(pointer, Columns * Rows, array); 68 | } 69 | 70 | //////////////////////////////////////////////////////////// 71 | /// \brief Construct implicitly from SFML transform 72 | /// 73 | /// This constructor is only supported for 3x3 and 4x4 74 | /// matrices. 75 | /// 76 | /// \param transform Object containing a transform. 77 | /// 78 | //////////////////////////////////////////////////////////// 79 | Matrix(const Transform& transform) 80 | { 81 | copyMatrix(transform, *this); 82 | } 83 | 84 | float array[Columns * Rows]; ///< Array holding matrix data 85 | }; 86 | 87 | //////////////////////////////////////////////////////////// 88 | /// \brief 4D vector type, used to set uniforms in GLSL 89 | /// 90 | //////////////////////////////////////////////////////////// 91 | template 92 | struct Vector4 93 | { 94 | //////////////////////////////////////////////////////////// 95 | /// \brief Default constructor, creates a zero vector 96 | /// 97 | //////////////////////////////////////////////////////////// 98 | Vector4() : 99 | x(0), 100 | y(0), 101 | z(0), 102 | w(0) 103 | { 104 | } 105 | 106 | //////////////////////////////////////////////////////////// 107 | /// \brief Construct from 4 vector components 108 | /// 109 | /// \param X Component of the 4D vector 110 | /// \param Y Component of the 4D vector 111 | /// \param Z Component of the 4D vector 112 | /// \param W Component of the 4D vector 113 | /// 114 | //////////////////////////////////////////////////////////// 115 | Vector4(T X, T Y, T Z, T W) : 116 | x(X), 117 | y(Y), 118 | z(Z), 119 | w(W) 120 | { 121 | } 122 | 123 | //////////////////////////////////////////////////////////// 124 | /// \brief Conversion constructor 125 | /// 126 | /// \param other 4D vector of different type 127 | /// 128 | //////////////////////////////////////////////////////////// 129 | template 130 | explicit Vector4(const Vector4& other) : 131 | x(static_cast(other.x)), 132 | y(static_cast(other.y)), 133 | z(static_cast(other.z)), 134 | w(static_cast(other.w)) 135 | { 136 | } 137 | 138 | //////////////////////////////////////////////////////////// 139 | /// \brief Construct float vector implicitly from color 140 | /// 141 | /// \param color Color instance. Is normalized to [0, 1] 142 | /// for floats, and left as-is for ints. 143 | /// 144 | //////////////////////////////////////////////////////////// 145 | Vector4(const Color& color) 146 | // uninitialized 147 | { 148 | copyVector(color, *this); 149 | } 150 | 151 | T x; ///< 1st component (X) of the 4D vector 152 | T y; ///< 2nd component (Y) of the 4D vector 153 | T z; ///< 3rd component (Z) of the 4D vector 154 | T w; ///< 4th component (W) of the 4D vector 155 | }; 156 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Graphics/Glyph.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_GLYPH_HPP 26 | #define SFML_GLYPH_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | //////////////////////////////////////////////////////////// 38 | /// \brief Structure describing a glyph 39 | /// 40 | //////////////////////////////////////////////////////////// 41 | class SFML_GRAPHICS_API Glyph 42 | { 43 | public: 44 | 45 | //////////////////////////////////////////////////////////// 46 | /// \brief Default constructor 47 | /// 48 | //////////////////////////////////////////////////////////// 49 | Glyph() : advance(0) {} 50 | 51 | //////////////////////////////////////////////////////////// 52 | // Member data 53 | //////////////////////////////////////////////////////////// 54 | float advance; ///< Offset to move horizontally to the next character 55 | FloatRect bounds; ///< Bounding rectangle of the glyph, in coordinates relative to the baseline 56 | IntRect textureRect; ///< Texture coordinates of the glyph inside the font's texture 57 | }; 58 | 59 | } // namespace sf 60 | 61 | 62 | #endif // SFML_GLYPH_HPP 63 | 64 | 65 | //////////////////////////////////////////////////////////// 66 | /// \class sf::Glyph 67 | /// \ingroup graphics 68 | /// 69 | /// A glyph is the visual representation of a character. 70 | /// 71 | /// The sf::Glyph structure provides the information needed 72 | /// to handle the glyph: 73 | /// \li its coordinates in the font's texture 74 | /// \li its bounding rectangle 75 | /// \li the offset to apply to get the starting position of the next glyph 76 | /// 77 | /// \see sf::Font 78 | /// 79 | //////////////////////////////////////////////////////////// 80 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Graphics/PrimitiveType.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_PRIMITIVETYPE_HPP 26 | #define SFML_PRIMITIVETYPE_HPP 27 | 28 | namespace sf 29 | { 30 | //////////////////////////////////////////////////////////// 31 | /// \ingroup graphics 32 | /// \brief Types of primitives that a sf::VertexArray can render 33 | /// 34 | /// Points and lines have no area, therefore their thickness 35 | /// will always be 1 pixel, regardless the current transform 36 | /// and view. 37 | /// 38 | //////////////////////////////////////////////////////////// 39 | enum PrimitiveType 40 | { 41 | Points, ///< List of individual points 42 | Lines, ///< List of individual lines 43 | LineStrip, ///< List of connected lines, a point uses the previous point to form a line 44 | Triangles, ///< List of individual triangles 45 | TriangleStrip, ///< List of connected triangles, a point uses the two previous points to form a triangle 46 | TriangleFan, ///< List of connected triangles, a point uses the common center and the previous point to form a triangle 47 | Quads, ///< List of individual quads (deprecated, don't work with OpenGL ES) 48 | 49 | // Deprecated names 50 | LinesStrip = LineStrip, ///< \deprecated Use LineStrip instead 51 | TrianglesStrip = TriangleStrip, ///< \deprecated Use TriangleStrip instead 52 | TrianglesFan = TriangleFan ///< \deprecated Use TriangleFan instead 53 | }; 54 | 55 | } // namespace sf 56 | 57 | 58 | #endif // SFML_PRIMITIVETYPE_HPP 59 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Graphics/Rect.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | 26 | //////////////////////////////////////////////////////////// 27 | template 28 | Rect::Rect() : 29 | left (0), 30 | top (0), 31 | width (0), 32 | height(0) 33 | { 34 | 35 | } 36 | 37 | 38 | //////////////////////////////////////////////////////////// 39 | template 40 | Rect::Rect(T rectLeft, T rectTop, T rectWidth, T rectHeight) : 41 | left (rectLeft), 42 | top (rectTop), 43 | width (rectWidth), 44 | height(rectHeight) 45 | { 46 | 47 | } 48 | 49 | 50 | //////////////////////////////////////////////////////////// 51 | template 52 | Rect::Rect(const Vector2& position, const Vector2& size) : 53 | left (position.x), 54 | top (position.y), 55 | width (size.x), 56 | height(size.y) 57 | { 58 | 59 | } 60 | 61 | 62 | //////////////////////////////////////////////////////////// 63 | template 64 | template 65 | Rect::Rect(const Rect& rectangle) : 66 | left (static_cast(rectangle.left)), 67 | top (static_cast(rectangle.top)), 68 | width (static_cast(rectangle.width)), 69 | height(static_cast(rectangle.height)) 70 | { 71 | } 72 | 73 | 74 | //////////////////////////////////////////////////////////// 75 | template 76 | bool Rect::contains(T x, T y) const 77 | { 78 | // Rectangles with negative dimensions are allowed, so we must handle them correctly 79 | 80 | // Compute the real min and max of the rectangle on both axes 81 | T minX = std::min(left, static_cast(left + width)); 82 | T maxX = std::max(left, static_cast(left + width)); 83 | T minY = std::min(top, static_cast(top + height)); 84 | T maxY = std::max(top, static_cast(top + height)); 85 | 86 | return (x >= minX) && (x < maxX) && (y >= minY) && (y < maxY); 87 | } 88 | 89 | 90 | //////////////////////////////////////////////////////////// 91 | template 92 | bool Rect::contains(const Vector2& point) const 93 | { 94 | return contains(point.x, point.y); 95 | } 96 | 97 | 98 | //////////////////////////////////////////////////////////// 99 | template 100 | bool Rect::intersects(const Rect& rectangle) const 101 | { 102 | Rect intersection; 103 | return intersects(rectangle, intersection); 104 | } 105 | 106 | 107 | //////////////////////////////////////////////////////////// 108 | template 109 | bool Rect::intersects(const Rect& rectangle, Rect& intersection) const 110 | { 111 | // Rectangles with negative dimensions are allowed, so we must handle them correctly 112 | 113 | // Compute the min and max of the first rectangle on both axes 114 | T r1MinX = std::min(left, static_cast(left + width)); 115 | T r1MaxX = std::max(left, static_cast(left + width)); 116 | T r1MinY = std::min(top, static_cast(top + height)); 117 | T r1MaxY = std::max(top, static_cast(top + height)); 118 | 119 | // Compute the min and max of the second rectangle on both axes 120 | T r2MinX = std::min(rectangle.left, static_cast(rectangle.left + rectangle.width)); 121 | T r2MaxX = std::max(rectangle.left, static_cast(rectangle.left + rectangle.width)); 122 | T r2MinY = std::min(rectangle.top, static_cast(rectangle.top + rectangle.height)); 123 | T r2MaxY = std::max(rectangle.top, static_cast(rectangle.top + rectangle.height)); 124 | 125 | // Compute the intersection boundaries 126 | T interLeft = std::max(r1MinX, r2MinX); 127 | T interTop = std::max(r1MinY, r2MinY); 128 | T interRight = std::min(r1MaxX, r2MaxX); 129 | T interBottom = std::min(r1MaxY, r2MaxY); 130 | 131 | // If the intersection is valid (positive non zero area), then there is an intersection 132 | if ((interLeft < interRight) && (interTop < interBottom)) 133 | { 134 | intersection = Rect(interLeft, interTop, interRight - interLeft, interBottom - interTop); 135 | return true; 136 | } 137 | else 138 | { 139 | intersection = Rect(0, 0, 0, 0); 140 | return false; 141 | } 142 | } 143 | 144 | 145 | //////////////////////////////////////////////////////////// 146 | template 147 | inline bool operator ==(const Rect& left, const Rect& right) 148 | { 149 | return (left.left == right.left) && (left.width == right.width) && 150 | (left.top == right.top) && (left.height == right.height); 151 | } 152 | 153 | 154 | //////////////////////////////////////////////////////////// 155 | template 156 | inline bool operator !=(const Rect& left, const Rect& right) 157 | { 158 | return !(left == right); 159 | } 160 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Graphics/RectangleShape.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_RECTANGLESHAPE_HPP 26 | #define SFML_RECTANGLESHAPE_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | //////////////////////////////////////////////////////////// 38 | /// \brief Specialized shape representing a rectangle 39 | /// 40 | //////////////////////////////////////////////////////////// 41 | class SFML_GRAPHICS_API RectangleShape : public Shape 42 | { 43 | public: 44 | 45 | //////////////////////////////////////////////////////////// 46 | /// \brief Default constructor 47 | /// 48 | /// \param size Size of the rectangle 49 | /// 50 | //////////////////////////////////////////////////////////// 51 | explicit RectangleShape(const Vector2f& size = Vector2f(0, 0)); 52 | 53 | //////////////////////////////////////////////////////////// 54 | /// \brief Set the size of the rectangle 55 | /// 56 | /// \param size New size of the rectangle 57 | /// 58 | /// \see getSize 59 | /// 60 | //////////////////////////////////////////////////////////// 61 | void setSize(const Vector2f& size); 62 | 63 | //////////////////////////////////////////////////////////// 64 | /// \brief Get the size of the rectangle 65 | /// 66 | /// \return Size of the rectangle 67 | /// 68 | /// \see setSize 69 | /// 70 | //////////////////////////////////////////////////////////// 71 | const Vector2f& getSize() const; 72 | 73 | //////////////////////////////////////////////////////////// 74 | /// \brief Get the number of points defining the shape 75 | /// 76 | /// \return Number of points of the shape. For rectangle 77 | /// shapes, this number is always 4. 78 | /// 79 | //////////////////////////////////////////////////////////// 80 | virtual std::size_t getPointCount() const; 81 | 82 | //////////////////////////////////////////////////////////// 83 | /// \brief Get a point of the rectangle 84 | /// 85 | /// The returned point is in local coordinates, that is, 86 | /// the shape's transforms (position, rotation, scale) are 87 | /// not taken into account. 88 | /// The result is undefined if \a index is out of the valid range. 89 | /// 90 | /// \param index Index of the point to get, in range [0 .. 3] 91 | /// 92 | /// \return index-th point of the shape 93 | /// 94 | //////////////////////////////////////////////////////////// 95 | virtual Vector2f getPoint(std::size_t index) const; 96 | 97 | private: 98 | 99 | //////////////////////////////////////////////////////////// 100 | // Member data 101 | //////////////////////////////////////////////////////////// 102 | Vector2f m_size; ///< Size of the rectangle 103 | }; 104 | 105 | } // namespace sf 106 | 107 | 108 | #endif // SFML_RECTANGLESHAPE_HPP 109 | 110 | 111 | //////////////////////////////////////////////////////////// 112 | /// \class sf::RectangleShape 113 | /// \ingroup graphics 114 | /// 115 | /// This class inherits all the functions of sf::Transformable 116 | /// (position, rotation, scale, bounds, ...) as well as the 117 | /// functions of sf::Shape (outline, color, texture, ...). 118 | /// 119 | /// Usage example: 120 | /// \code 121 | /// sf::RectangleShape rectangle; 122 | /// rectangle.setSize(sf::Vector2f(100, 50)); 123 | /// rectangle.setOutlineColor(sf::Color::Red); 124 | /// rectangle.setOutlineThickness(5); 125 | /// rectangle.setPosition(10, 20); 126 | /// ... 127 | /// window.draw(rectangle); 128 | /// \endcode 129 | /// 130 | /// \see sf::Shape, sf::CircleShape, sf::ConvexShape 131 | /// 132 | //////////////////////////////////////////////////////////// 133 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Graphics/Vertex.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_VERTEX_HPP 26 | #define SFML_VERTEX_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | #include 34 | 35 | 36 | namespace sf 37 | { 38 | //////////////////////////////////////////////////////////// 39 | /// \brief Define a point with color and texture coordinates 40 | /// 41 | //////////////////////////////////////////////////////////// 42 | class SFML_GRAPHICS_API Vertex 43 | { 44 | public: 45 | 46 | //////////////////////////////////////////////////////////// 47 | /// \brief Default constructor 48 | /// 49 | //////////////////////////////////////////////////////////// 50 | Vertex(); 51 | 52 | //////////////////////////////////////////////////////////// 53 | /// \brief Construct the vertex from its position 54 | /// 55 | /// The vertex color is white and texture coordinates are (0, 0). 56 | /// 57 | /// \param thePosition Vertex position 58 | /// 59 | //////////////////////////////////////////////////////////// 60 | Vertex(const Vector2f& thePosition); 61 | 62 | //////////////////////////////////////////////////////////// 63 | /// \brief Construct the vertex from its position and color 64 | /// 65 | /// The texture coordinates are (0, 0). 66 | /// 67 | /// \param thePosition Vertex position 68 | /// \param theColor Vertex color 69 | /// 70 | //////////////////////////////////////////////////////////// 71 | Vertex(const Vector2f& thePosition, const Color& theColor); 72 | 73 | //////////////////////////////////////////////////////////// 74 | /// \brief Construct the vertex from its position and texture coordinates 75 | /// 76 | /// The vertex color is white. 77 | /// 78 | /// \param thePosition Vertex position 79 | /// \param theTexCoords Vertex texture coordinates 80 | /// 81 | //////////////////////////////////////////////////////////// 82 | Vertex(const Vector2f& thePosition, const Vector2f& theTexCoords); 83 | 84 | //////////////////////////////////////////////////////////// 85 | /// \brief Construct the vertex from its position, color and texture coordinates 86 | /// 87 | /// \param thePosition Vertex position 88 | /// \param theColor Vertex color 89 | /// \param theTexCoords Vertex texture coordinates 90 | /// 91 | //////////////////////////////////////////////////////////// 92 | Vertex(const Vector2f& thePosition, const Color& theColor, const Vector2f& theTexCoords); 93 | 94 | //////////////////////////////////////////////////////////// 95 | // Member data 96 | //////////////////////////////////////////////////////////// 97 | Vector2f position; ///< 2D position of the vertex 98 | Color color; ///< Color of the vertex 99 | Vector2f texCoords; ///< Coordinates of the texture's pixel to map to the vertex 100 | }; 101 | 102 | } // namespace sf 103 | 104 | 105 | #endif // SFML_VERTEX_HPP 106 | 107 | 108 | //////////////////////////////////////////////////////////// 109 | /// \class sf::Vertex 110 | /// \ingroup graphics 111 | /// 112 | /// A vertex is an improved point. It has a position and other 113 | /// extra attributes that will be used for drawing: in SFML, 114 | /// vertices also have a color and a pair of texture coordinates. 115 | /// 116 | /// The vertex is the building block of drawing. Everything which 117 | /// is visible on screen is made of vertices. They are grouped 118 | /// as 2D primitives (triangles, quads, ...), and these primitives 119 | /// are grouped to create even more complex 2D entities such as 120 | /// sprites, texts, etc. 121 | /// 122 | /// If you use the graphical entities of SFML (sprite, text, shape) 123 | /// you won't have to deal with vertices directly. But if you want 124 | /// to define your own 2D entities, such as tiled maps or particle 125 | /// systems, using vertices will allow you to get maximum performances. 126 | /// 127 | /// Example: 128 | /// \code 129 | /// // define a 100x100 square, red, with a 10x10 texture mapped on it 130 | /// sf::Vertex vertices[] = 131 | /// { 132 | /// sf::Vertex(sf::Vector2f( 0, 0), sf::Color::Red, sf::Vector2f( 0, 0)), 133 | /// sf::Vertex(sf::Vector2f( 0, 100), sf::Color::Red, sf::Vector2f( 0, 10)), 134 | /// sf::Vertex(sf::Vector2f(100, 100), sf::Color::Red, sf::Vector2f(10, 10)), 135 | /// sf::Vertex(sf::Vector2f(100, 0), sf::Color::Red, sf::Vector2f(10, 0)) 136 | /// }; 137 | /// 138 | /// // draw it 139 | /// window.draw(vertices, 4, sf::Quads); 140 | /// \endcode 141 | /// 142 | /// Note: although texture coordinates are supposed to be an integer 143 | /// amount of pixels, their type is float because of some buggy graphics 144 | /// drivers that are not able to process integer coordinates correctly. 145 | /// 146 | /// \see sf::VertexArray 147 | /// 148 | //////////////////////////////////////////////////////////// 149 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Main.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_MAIN_HPP 26 | #define SFML_MAIN_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | #if defined(SFML_SYSTEM_IOS) 35 | 36 | // On iOS, we have no choice but to have our own main, 37 | // so we need to rename the user one and call it later 38 | #define main sfmlMain 39 | 40 | #endif 41 | 42 | 43 | #endif // SFML_MAIN_HPP 44 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Network.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_NETWORK_HPP 26 | #define SFML_NETWORK_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | 45 | #endif // SFML_NETWORK_HPP 46 | 47 | //////////////////////////////////////////////////////////// 48 | /// \defgroup network Network module 49 | /// 50 | /// Socket-based communication, utilities and higher-level 51 | /// network protocols (HTTP, FTP). 52 | /// 53 | //////////////////////////////////////////////////////////// 54 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Network/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_NETWORK_EXPORT_HPP 26 | #define SFML_NETWORK_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_NETWORK_EXPORTS) 38 | 39 | #define SFML_NETWORK_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_NETWORK_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_NETWORK_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Network/SocketHandle.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SOCKETHANDLE_HPP 26 | #define SFML_SOCKETHANDLE_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | #if defined(SFML_SYSTEM_WINDOWS) 34 | #include 35 | #endif 36 | 37 | 38 | namespace sf 39 | { 40 | //////////////////////////////////////////////////////////// 41 | // Define the low-level socket handle type, specific to 42 | // each platform 43 | //////////////////////////////////////////////////////////// 44 | #if defined(SFML_SYSTEM_WINDOWS) 45 | 46 | typedef UINT_PTR SocketHandle; 47 | 48 | #else 49 | 50 | typedef int SocketHandle; 51 | 52 | #endif 53 | 54 | } // namespace sf 55 | 56 | 57 | #endif // SFML_SOCKETHANDLE_HPP 58 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/OpenGL.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_OPENGL_HPP 26 | #define SFML_OPENGL_HPP 27 | 28 | 29 | //////////////////////////////////////////////////////////// 30 | /// Headers 31 | //////////////////////////////////////////////////////////// 32 | #include 33 | 34 | 35 | //////////////////////////////////////////////////////////// 36 | /// This file just includes the OpenGL headers, 37 | /// which have actually different paths on each system 38 | //////////////////////////////////////////////////////////// 39 | #if defined(SFML_SYSTEM_WINDOWS) 40 | 41 | // The Visual C++ version of gl.h uses WINGDIAPI and APIENTRY but doesn't define them 42 | #ifdef _MSC_VER 43 | #include 44 | #endif 45 | 46 | #include 47 | 48 | #elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD) 49 | 50 | #if defined(SFML_OPENGL_ES) 51 | #include 52 | #include 53 | #else 54 | #include 55 | #endif 56 | 57 | #elif defined(SFML_SYSTEM_MACOS) 58 | 59 | #include 60 | 61 | #elif defined (SFML_SYSTEM_IOS) 62 | 63 | #include 64 | #include 65 | 66 | #elif defined (SFML_SYSTEM_ANDROID) 67 | 68 | #include 69 | #include 70 | 71 | // We're not using OpenGL ES 2+ yet, but we can use the sRGB extension 72 | #include 73 | #include 74 | 75 | #endif 76 | 77 | 78 | #endif // SFML_OPENGL_HPP 79 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SYSTEM_HPP 26 | #define SFML_SYSTEM_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | #endif // SFML_SYSTEM_HPP 52 | 53 | //////////////////////////////////////////////////////////// 54 | /// \defgroup system System module 55 | /// 56 | /// Base module of SFML, defining various utilities. It provides 57 | /// vector classes, Unicode strings and conversion functions, 58 | /// threads and mutexes, timing classes. 59 | /// 60 | //////////////////////////////////////////////////////////// 61 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/Clock.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_CLOCK_HPP 26 | #define SFML_CLOCK_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | //////////////////////////////////////////////////////////// 38 | /// \brief Utility class that measures the elapsed time 39 | /// 40 | //////////////////////////////////////////////////////////// 41 | class SFML_SYSTEM_API Clock 42 | { 43 | public: 44 | 45 | //////////////////////////////////////////////////////////// 46 | /// \brief Default constructor 47 | /// 48 | /// The clock starts automatically after being constructed. 49 | /// 50 | //////////////////////////////////////////////////////////// 51 | Clock(); 52 | 53 | //////////////////////////////////////////////////////////// 54 | /// \brief Get the elapsed time 55 | /// 56 | /// This function returns the time elapsed since the last call 57 | /// to restart() (or the construction of the instance if restart() 58 | /// has not been called). 59 | /// 60 | /// \return Time elapsed 61 | /// 62 | //////////////////////////////////////////////////////////// 63 | Time getElapsedTime() const; 64 | 65 | //////////////////////////////////////////////////////////// 66 | /// \brief Restart the clock 67 | /// 68 | /// This function puts the time counter back to zero. 69 | /// It also returns the time elapsed since the clock was started. 70 | /// 71 | /// \return Time elapsed 72 | /// 73 | //////////////////////////////////////////////////////////// 74 | Time restart(); 75 | 76 | private: 77 | 78 | //////////////////////////////////////////////////////////// 79 | // Member data 80 | //////////////////////////////////////////////////////////// 81 | Time m_startTime; ///< Time of last reset, in microseconds 82 | }; 83 | 84 | } // namespace sf 85 | 86 | 87 | #endif // SFML_CLOCK_HPP 88 | 89 | 90 | //////////////////////////////////////////////////////////// 91 | /// \class sf::Clock 92 | /// \ingroup system 93 | /// 94 | /// sf::Clock is a lightweight class for measuring time. 95 | /// 96 | /// Its provides the most precise time that the underlying 97 | /// OS can achieve (generally microseconds or nanoseconds). 98 | /// It also ensures monotonicity, which means that the returned 99 | /// time can never go backward, even if the system time is 100 | /// changed. 101 | /// 102 | /// Usage example: 103 | /// \code 104 | /// sf::Clock clock; 105 | /// ... 106 | /// Time time1 = clock.getElapsedTime(); 107 | /// ... 108 | /// Time time2 = clock.restart(); 109 | /// \endcode 110 | /// 111 | /// The sf::Time value returned by the clock can then be 112 | /// converted to a number of seconds, milliseconds or even 113 | /// microseconds. 114 | /// 115 | /// \see sf::Time 116 | /// 117 | //////////////////////////////////////////////////////////// 118 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/Err.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_ERR_HPP 26 | #define SFML_ERR_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | //////////////////////////////////////////////////////////// 38 | /// \brief Standard stream used by SFML to output warnings and errors 39 | /// 40 | //////////////////////////////////////////////////////////// 41 | SFML_SYSTEM_API std::ostream& err(); 42 | 43 | } // namespace sf 44 | 45 | 46 | #endif // SFML_ERR_HPP 47 | 48 | 49 | //////////////////////////////////////////////////////////// 50 | /// \fn sf::err 51 | /// \ingroup system 52 | /// 53 | /// By default, sf::err() outputs to the same location as std::cerr, 54 | /// (-> the stderr descriptor) which is the console if there's 55 | /// one available. 56 | /// 57 | /// It is a standard std::ostream instance, so it supports all the 58 | /// insertion operations defined by the STL 59 | /// (operator <<, manipulators, etc.). 60 | /// 61 | /// sf::err() can be redirected to write to another output, independently 62 | /// of std::cerr, by using the rdbuf() function provided by the 63 | /// std::ostream class. 64 | /// 65 | /// Example: 66 | /// \code 67 | /// // Redirect to a file 68 | /// std::ofstream file("sfml-log.txt"); 69 | /// std::streambuf* previous = sf::err().rdbuf(file.rdbuf()); 70 | /// 71 | /// // Redirect to nothing 72 | /// sf::err().rdbuf(NULL); 73 | /// 74 | /// // Restore the original output 75 | /// sf::err().rdbuf(previous); 76 | /// \endcode 77 | /// 78 | /// \return Reference to std::ostream representing the SFML error stream 79 | /// 80 | //////////////////////////////////////////////////////////// 81 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SYSTEM_EXPORT_HPP 26 | #define SFML_SYSTEM_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_SYSTEM_EXPORTS) 38 | 39 | #define SFML_SYSTEM_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_SYSTEM_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_SYSTEM_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/InputStream.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_INPUTSTREAM_HPP 26 | #define SFML_INPUTSTREAM_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | //////////////////////////////////////////////////////////// 38 | /// \brief Abstract class for custom file input streams 39 | /// 40 | //////////////////////////////////////////////////////////// 41 | class SFML_SYSTEM_API InputStream 42 | { 43 | public: 44 | 45 | //////////////////////////////////////////////////////////// 46 | /// \brief Virtual destructor 47 | /// 48 | //////////////////////////////////////////////////////////// 49 | virtual ~InputStream() {} 50 | 51 | //////////////////////////////////////////////////////////// 52 | /// \brief Read data from the stream 53 | /// 54 | /// After reading, the stream's reading position must be 55 | /// advanced by the amount of bytes read. 56 | /// 57 | /// \param data Buffer where to copy the read data 58 | /// \param size Desired number of bytes to read 59 | /// 60 | /// \return The number of bytes actually read, or -1 on error 61 | /// 62 | //////////////////////////////////////////////////////////// 63 | virtual Int64 read(void* data, Int64 size) = 0; 64 | 65 | //////////////////////////////////////////////////////////// 66 | /// \brief Change the current reading position 67 | /// 68 | /// \param position The position to seek to, from the beginning 69 | /// 70 | /// \return The position actually sought to, or -1 on error 71 | /// 72 | //////////////////////////////////////////////////////////// 73 | virtual Int64 seek(Int64 position) = 0; 74 | 75 | //////////////////////////////////////////////////////////// 76 | /// \brief Get the current reading position in the stream 77 | /// 78 | /// \return The current position, or -1 on error. 79 | /// 80 | //////////////////////////////////////////////////////////// 81 | virtual Int64 tell() = 0; 82 | 83 | //////////////////////////////////////////////////////////// 84 | /// \brief Return the size of the stream 85 | /// 86 | /// \return The total number of bytes available in the stream, or -1 on error 87 | /// 88 | //////////////////////////////////////////////////////////// 89 | virtual Int64 getSize() = 0; 90 | }; 91 | 92 | } // namespace sf 93 | 94 | 95 | #endif // SFML_INPUTSTREAM_HPP 96 | 97 | 98 | //////////////////////////////////////////////////////////// 99 | /// \class sf::InputStream 100 | /// \ingroup system 101 | /// 102 | /// This class allows users to define their own file input sources 103 | /// from which SFML can load resources. 104 | /// 105 | /// SFML resource classes like sf::Texture and 106 | /// sf::SoundBuffer provide loadFromFile and loadFromMemory functions, 107 | /// which read data from conventional sources. However, if you 108 | /// have data coming from a different source (over a network, 109 | /// embedded, encrypted, compressed, etc) you can derive your 110 | /// own class from sf::InputStream and load SFML resources with 111 | /// their loadFromStream function. 112 | /// 113 | /// Usage example: 114 | /// \code 115 | /// // custom stream class that reads from inside a zip file 116 | /// class ZipStream : public sf::InputStream 117 | /// { 118 | /// public: 119 | /// 120 | /// ZipStream(std::string archive); 121 | /// 122 | /// bool open(std::string filename); 123 | /// 124 | /// Int64 read(void* data, Int64 size); 125 | /// 126 | /// Int64 seek(Int64 position); 127 | /// 128 | /// Int64 tell(); 129 | /// 130 | /// Int64 getSize(); 131 | /// 132 | /// private: 133 | /// 134 | /// ... 135 | /// }; 136 | /// 137 | /// // now you can load textures... 138 | /// sf::Texture texture; 139 | /// ZipStream stream("resources.zip"); 140 | /// stream.open("images/img.png"); 141 | /// texture.loadFromStream(stream); 142 | /// 143 | /// // musics... 144 | /// sf::Music music; 145 | /// ZipStream stream("resources.zip"); 146 | /// stream.open("musics/msc.ogg"); 147 | /// music.openFromStream(stream); 148 | /// 149 | /// // etc. 150 | /// \endcode 151 | /// 152 | //////////////////////////////////////////////////////////// 153 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/Lock.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_LOCK_HPP 26 | #define SFML_LOCK_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | class Mutex; 38 | 39 | //////////////////////////////////////////////////////////// 40 | /// \brief Automatic wrapper for locking and unlocking mutexes 41 | /// 42 | //////////////////////////////////////////////////////////// 43 | class SFML_SYSTEM_API Lock : NonCopyable 44 | { 45 | public: 46 | 47 | //////////////////////////////////////////////////////////// 48 | /// \brief Construct the lock with a target mutex 49 | /// 50 | /// The mutex passed to sf::Lock is automatically locked. 51 | /// 52 | /// \param mutex Mutex to lock 53 | /// 54 | //////////////////////////////////////////////////////////// 55 | explicit Lock(Mutex& mutex); 56 | 57 | //////////////////////////////////////////////////////////// 58 | /// \brief Destructor 59 | /// 60 | /// The destructor of sf::Lock automatically unlocks its mutex. 61 | /// 62 | //////////////////////////////////////////////////////////// 63 | ~Lock(); 64 | 65 | private: 66 | 67 | //////////////////////////////////////////////////////////// 68 | // Member data 69 | //////////////////////////////////////////////////////////// 70 | Mutex& m_mutex; ///< Mutex to lock / unlock 71 | }; 72 | 73 | } // namespace sf 74 | 75 | 76 | #endif // SFML_LOCK_HPP 77 | 78 | 79 | //////////////////////////////////////////////////////////// 80 | /// \class sf::Lock 81 | /// \ingroup system 82 | /// 83 | /// sf::Lock is a RAII wrapper for sf::Mutex. By unlocking 84 | /// it in its destructor, it ensures that the mutex will 85 | /// always be released when the current scope (most likely 86 | /// a function) ends. 87 | /// This is even more important when an exception or an early 88 | /// return statement can interrupt the execution flow of the 89 | /// function. 90 | /// 91 | /// For maximum robustness, sf::Lock should always be used 92 | /// to lock/unlock a mutex. 93 | /// 94 | /// Usage example: 95 | /// \code 96 | /// sf::Mutex mutex; 97 | /// 98 | /// void function() 99 | /// { 100 | /// sf::Lock lock(mutex); // mutex is now locked 101 | /// 102 | /// functionThatMayThrowAnException(); // mutex is unlocked if this function throws 103 | /// 104 | /// if (someCondition) 105 | /// return; // mutex is unlocked 106 | /// 107 | /// } // mutex is unlocked 108 | /// \endcode 109 | /// 110 | /// Because the mutex is not explicitly unlocked in the code, 111 | /// it may remain locked longer than needed. If the region 112 | /// of the code that needs to be protected by the mutex is 113 | /// not the entire function, a good practice is to create a 114 | /// smaller, inner scope so that the lock is limited to this 115 | /// part of the code. 116 | /// 117 | /// \code 118 | /// sf::Mutex mutex; 119 | /// 120 | /// void function() 121 | /// { 122 | /// { 123 | /// sf::Lock lock(mutex); 124 | /// codeThatRequiresProtection(); 125 | /// 126 | /// } // mutex is unlocked here 127 | /// 128 | /// codeThatDoesntCareAboutTheMutex(); 129 | /// } 130 | /// \endcode 131 | /// 132 | /// Having a mutex locked longer than required is a bad practice 133 | /// which can lead to bad performances. Don't forget that when 134 | /// a mutex is locked, other threads may be waiting doing nothing 135 | /// until it is released. 136 | /// 137 | /// \see sf::Mutex 138 | /// 139 | //////////////////////////////////////////////////////////// 140 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/MemoryInputStream.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_MEMORYINPUTSTREAM_HPP 26 | #define SFML_MEMORYINPUTSTREAM_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | 37 | namespace sf 38 | { 39 | //////////////////////////////////////////////////////////// 40 | /// \brief Implementation of input stream based on a memory chunk 41 | /// 42 | //////////////////////////////////////////////////////////// 43 | class SFML_SYSTEM_API MemoryInputStream : public InputStream 44 | { 45 | public: 46 | 47 | //////////////////////////////////////////////////////////// 48 | /// \brief Default constructor 49 | /// 50 | //////////////////////////////////////////////////////////// 51 | MemoryInputStream(); 52 | 53 | //////////////////////////////////////////////////////////// 54 | /// \brief Open the stream from its data 55 | /// 56 | /// \param data Pointer to the data in memory 57 | /// \param sizeInBytes Size of the data, in bytes 58 | /// 59 | //////////////////////////////////////////////////////////// 60 | void open(const void* data, std::size_t sizeInBytes); 61 | 62 | //////////////////////////////////////////////////////////// 63 | /// \brief Read data from the stream 64 | /// 65 | /// After reading, the stream's reading position must be 66 | /// advanced by the amount of bytes read. 67 | /// 68 | /// \param data Buffer where to copy the read data 69 | /// \param size Desired number of bytes to read 70 | /// 71 | /// \return The number of bytes actually read, or -1 on error 72 | /// 73 | //////////////////////////////////////////////////////////// 74 | virtual Int64 read(void* data, Int64 size); 75 | 76 | //////////////////////////////////////////////////////////// 77 | /// \brief Change the current reading position 78 | /// 79 | /// \param position The position to seek to, from the beginning 80 | /// 81 | /// \return The position actually sought to, or -1 on error 82 | /// 83 | //////////////////////////////////////////////////////////// 84 | virtual Int64 seek(Int64 position); 85 | 86 | //////////////////////////////////////////////////////////// 87 | /// \brief Get the current reading position in the stream 88 | /// 89 | /// \return The current position, or -1 on error. 90 | /// 91 | //////////////////////////////////////////////////////////// 92 | virtual Int64 tell(); 93 | 94 | //////////////////////////////////////////////////////////// 95 | /// \brief Return the size of the stream 96 | /// 97 | /// \return The total number of bytes available in the stream, or -1 on error 98 | /// 99 | //////////////////////////////////////////////////////////// 100 | virtual Int64 getSize(); 101 | 102 | private: 103 | 104 | //////////////////////////////////////////////////////////// 105 | // Member data 106 | //////////////////////////////////////////////////////////// 107 | const char* m_data; ///< Pointer to the data in memory 108 | Int64 m_size; ///< Total size of the data 109 | Int64 m_offset; ///< Current reading position 110 | }; 111 | 112 | } // namespace sf 113 | 114 | 115 | #endif // SFML_MEMORYINPUTSTREAM_HPP 116 | 117 | 118 | //////////////////////////////////////////////////////////// 119 | /// \class sf::MemoryInputStream 120 | /// \ingroup system 121 | /// 122 | /// This class is a specialization of InputStream that 123 | /// reads from data in memory. 124 | /// 125 | /// It wraps a memory chunk in the common InputStream interface 126 | /// and therefore allows to use generic classes or functions 127 | /// that accept such a stream, with content already loaded in memory. 128 | /// 129 | /// In addition to the virtual functions inherited from 130 | /// InputStream, MemoryInputStream adds a function to 131 | /// specify the pointer and size of the data in memory. 132 | /// 133 | /// SFML resource classes can usually be loaded directly from 134 | /// memory, so this class shouldn't be useful to you unless 135 | /// you create your own algorithms that operate on an InputStream. 136 | /// 137 | /// Usage example: 138 | /// \code 139 | /// void process(InputStream& stream); 140 | /// 141 | /// MemoryInputStream stream; 142 | /// stream.open(thePtr, theSize); 143 | /// process(stream); 144 | /// \endcode 145 | /// 146 | /// InputStream, FileInputStream 147 | /// 148 | //////////////////////////////////////////////////////////// 149 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/Mutex.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_MUTEX_HPP 26 | #define SFML_MUTEX_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | namespace priv 38 | { 39 | class MutexImpl; 40 | } 41 | 42 | //////////////////////////////////////////////////////////// 43 | /// \brief Blocks concurrent access to shared resources 44 | /// from multiple threads 45 | /// 46 | //////////////////////////////////////////////////////////// 47 | class SFML_SYSTEM_API Mutex : NonCopyable 48 | { 49 | public: 50 | 51 | //////////////////////////////////////////////////////////// 52 | /// \brief Default constructor 53 | /// 54 | //////////////////////////////////////////////////////////// 55 | Mutex(); 56 | 57 | //////////////////////////////////////////////////////////// 58 | /// \brief Destructor 59 | /// 60 | //////////////////////////////////////////////////////////// 61 | ~Mutex(); 62 | 63 | //////////////////////////////////////////////////////////// 64 | /// \brief Lock the mutex 65 | /// 66 | /// If the mutex is already locked in another thread, 67 | /// this call will block the execution until the mutex 68 | /// is released. 69 | /// 70 | /// \see unlock 71 | /// 72 | //////////////////////////////////////////////////////////// 73 | void lock(); 74 | 75 | //////////////////////////////////////////////////////////// 76 | /// \brief Unlock the mutex 77 | /// 78 | /// \see lock 79 | /// 80 | //////////////////////////////////////////////////////////// 81 | void unlock(); 82 | 83 | private: 84 | 85 | //////////////////////////////////////////////////////////// 86 | // Member data 87 | //////////////////////////////////////////////////////////// 88 | priv::MutexImpl* m_mutexImpl; ///< OS-specific implementation 89 | }; 90 | 91 | } // namespace sf 92 | 93 | 94 | #endif // SFML_MUTEX_HPP 95 | 96 | 97 | //////////////////////////////////////////////////////////// 98 | /// \class sf::Mutex 99 | /// \ingroup system 100 | /// 101 | /// Mutex stands for "MUTual EXclusion". A mutex is a 102 | /// synchronization object, used when multiple threads are involved. 103 | /// 104 | /// When you want to protect a part of the code from being accessed 105 | /// simultaneously by multiple threads, you typically use a 106 | /// mutex. When a thread is locked by a mutex, any other thread 107 | /// trying to lock it will be blocked until the mutex is released 108 | /// by the thread that locked it. This way, you can allow only 109 | /// one thread at a time to access a critical region of your code. 110 | /// 111 | /// Usage example: 112 | /// \code 113 | /// Database database; // this is a critical resource that needs some protection 114 | /// sf::Mutex mutex; 115 | /// 116 | /// void thread1() 117 | /// { 118 | /// mutex.lock(); // this call will block the thread if the mutex is already locked by thread2 119 | /// database.write(...); 120 | /// mutex.unlock(); // if thread2 was waiting, it will now be unblocked 121 | /// } 122 | /// 123 | /// void thread2() 124 | /// { 125 | /// mutex.lock(); // this call will block the thread if the mutex is already locked by thread1 126 | /// database.write(...); 127 | /// mutex.unlock(); // if thread1 was waiting, it will now be unblocked 128 | /// } 129 | /// \endcode 130 | /// 131 | /// Be very careful with mutexes. A bad usage can lead to bad problems, 132 | /// like deadlocks (two threads are waiting for each other and the 133 | /// application is globally stuck). 134 | /// 135 | /// To make the usage of mutexes more robust, particularly in 136 | /// environments where exceptions can be thrown, you should 137 | /// use the helper class sf::Lock to lock/unlock mutexes. 138 | /// 139 | /// SFML mutexes are recursive, which means that you can lock 140 | /// a mutex multiple times in the same thread without creating 141 | /// a deadlock. In this case, the first call to lock() behaves 142 | /// as usual, and the following ones have no effect. 143 | /// However, you must call unlock() exactly as many times as you 144 | /// called lock(). If you don't, the mutex won't be released. 145 | /// 146 | /// \see sf::Lock 147 | /// 148 | //////////////////////////////////////////////////////////// 149 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/NativeActivity.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_NATIVEACTIVITY_HPP 26 | #define SFML_NATIVEACTIVITY_HPP 27 | 28 | 29 | //////////////////////////////////////////////////////////// 30 | // Headers 31 | //////////////////////////////////////////////////////////// 32 | #include 33 | 34 | 35 | #if !defined(SFML_SYSTEM_ANDROID) 36 | #error NativeActivity.hpp: This header is Android only. 37 | #endif 38 | 39 | 40 | struct ANativeActivity; 41 | 42 | namespace sf 43 | { 44 | //////////////////////////////////////////////////////////// 45 | /// \ingroup system 46 | /// \brief Return a pointer to the Android native activity 47 | /// 48 | /// You shouldn't have to use this function, unless you want 49 | /// to implement very specific details, that SFML doesn't 50 | /// support, or to use a workaround for a known issue. 51 | /// 52 | /// \return Pointer to Android native activity structure 53 | /// 54 | /// \sfplatform{Android,SFML/System/NativeActivity.hpp} 55 | /// 56 | //////////////////////////////////////////////////////////// 57 | SFML_SYSTEM_API ANativeActivity* getNativeActivity(); 58 | 59 | } // namespace sf 60 | 61 | 62 | #endif // SFML_NATIVEACTIVITY_HPP 63 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/NonCopyable.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_NONCOPYABLE_HPP 26 | #define SFML_NONCOPYABLE_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | namespace sf 35 | { 36 | //////////////////////////////////////////////////////////// 37 | /// \brief Utility class that makes any derived 38 | /// class non-copyable 39 | /// 40 | //////////////////////////////////////////////////////////// 41 | class SFML_SYSTEM_API NonCopyable 42 | { 43 | protected: 44 | 45 | //////////////////////////////////////////////////////////// 46 | /// \brief Default constructor 47 | /// 48 | /// Because this class has a copy constructor, the compiler 49 | /// will not automatically generate the default constructor. 50 | /// That's why we must define it explicitly. 51 | /// 52 | //////////////////////////////////////////////////////////// 53 | NonCopyable() {} 54 | 55 | //////////////////////////////////////////////////////////// 56 | /// \brief Default destructor 57 | /// 58 | /// By declaring a protected destructor it's impossible to 59 | /// call delete on a pointer of sf::NonCopyable, thus 60 | /// preventing possible resource leaks. 61 | /// 62 | //////////////////////////////////////////////////////////// 63 | ~NonCopyable() {} 64 | 65 | private: 66 | 67 | //////////////////////////////////////////////////////////// 68 | /// \brief Disabled copy constructor 69 | /// 70 | /// By making the copy constructor private, the compiler will 71 | /// trigger an error if anyone outside tries to use it. 72 | /// To prevent NonCopyable or friend classes from using it, 73 | /// we also give no definition, so that the linker will 74 | /// produce an error if the first protection was inefficient. 75 | /// 76 | //////////////////////////////////////////////////////////// 77 | NonCopyable(const NonCopyable&); 78 | 79 | //////////////////////////////////////////////////////////// 80 | /// \brief Disabled assignment operator 81 | /// 82 | /// By making the assignment operator private, the compiler will 83 | /// trigger an error if anyone outside tries to use it. 84 | /// To prevent NonCopyable or friend classes from using it, 85 | /// we also give no definition, so that the linker will 86 | /// produce an error if the first protection was inefficient. 87 | /// 88 | //////////////////////////////////////////////////////////// 89 | NonCopyable& operator =(const NonCopyable&); 90 | }; 91 | 92 | } // namespace sf 93 | 94 | 95 | #endif // SFML_NONCOPYABLE_HPP 96 | 97 | 98 | //////////////////////////////////////////////////////////// 99 | /// \class sf::NonCopyable 100 | /// \ingroup system 101 | /// 102 | /// This class makes its instances non-copyable, by explicitly 103 | /// disabling its copy constructor and its assignment operator. 104 | /// 105 | /// To create a non-copyable class, simply inherit from 106 | /// sf::NonCopyable. 107 | /// 108 | /// The type of inheritance (public or private) doesn't matter, 109 | /// the copy constructor and assignment operator are declared private 110 | /// in sf::NonCopyable so they will end up being inaccessible in both 111 | /// cases. Thus you can use a shorter syntax for inheriting from it 112 | /// (see below). 113 | /// 114 | /// Usage example: 115 | /// \code 116 | /// class MyNonCopyableClass : sf::NonCopyable 117 | /// { 118 | /// ... 119 | /// }; 120 | /// \endcode 121 | /// 122 | /// Deciding whether the instances of a class can be copied 123 | /// or not is a very important design choice. You are strongly 124 | /// encouraged to think about it before writing a class, 125 | /// and to use sf::NonCopyable when necessary to prevent 126 | /// many potential future errors when using it. This is also 127 | /// a very important indication to users of your class. 128 | /// 129 | //////////////////////////////////////////////////////////// 130 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/Sleep.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SLEEP_HPP 26 | #define SFML_SLEEP_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | //////////////////////////////////////////////////////////// 38 | /// \ingroup system 39 | /// \brief Make the current thread sleep for a given duration 40 | /// 41 | /// sf::sleep is the best way to block a program or one of its 42 | /// threads, as it doesn't consume any CPU power. 43 | /// 44 | /// \param duration Time to sleep 45 | /// 46 | //////////////////////////////////////////////////////////// 47 | void SFML_SYSTEM_API sleep(Time duration); 48 | 49 | } // namespace sf 50 | 51 | 52 | #endif // SFML_SLEEP_HPP 53 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/String.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | 26 | //////////////////////////////////////////////////////////// 27 | template 28 | String String::fromUtf8(T begin, T end) 29 | { 30 | String string; 31 | Utf8::toUtf32(begin, end, std::back_inserter(string.m_string)); 32 | return string; 33 | } 34 | 35 | 36 | //////////////////////////////////////////////////////////// 37 | template 38 | String String::fromUtf16(T begin, T end) 39 | { 40 | String string; 41 | Utf16::toUtf32(begin, end, std::back_inserter(string.m_string)); 42 | return string; 43 | } 44 | 45 | 46 | //////////////////////////////////////////////////////////// 47 | template 48 | String String::fromUtf32(T begin, T end) 49 | { 50 | String string; 51 | string.m_string.assign(begin, end); 52 | return string; 53 | } 54 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/Thread.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | namespace priv 26 | { 27 | // Base class for abstract thread functions 28 | struct ThreadFunc 29 | { 30 | virtual ~ThreadFunc() {} 31 | virtual void run() = 0; 32 | }; 33 | 34 | // Specialization using a functor (including free functions) with no argument 35 | template 36 | struct ThreadFunctor : ThreadFunc 37 | { 38 | ThreadFunctor(T functor) : m_functor(functor) {} 39 | virtual void run() {m_functor();} 40 | T m_functor; 41 | }; 42 | 43 | // Specialization using a functor (including free functions) with one argument 44 | template 45 | struct ThreadFunctorWithArg : ThreadFunc 46 | { 47 | ThreadFunctorWithArg(F function, A arg) : m_function(function), m_arg(arg) {} 48 | virtual void run() {m_function(m_arg);} 49 | F m_function; 50 | A m_arg; 51 | }; 52 | 53 | // Specialization using a member function 54 | template 55 | struct ThreadMemberFunc : ThreadFunc 56 | { 57 | ThreadMemberFunc(void(C::*function)(), C* object) : m_function(function), m_object(object) {} 58 | virtual void run() {(m_object->*m_function)();} 59 | void(C::*m_function)(); 60 | C* m_object; 61 | }; 62 | 63 | } // namespace priv 64 | 65 | 66 | //////////////////////////////////////////////////////////// 67 | template 68 | Thread::Thread(F functor) : 69 | m_impl (NULL), 70 | m_entryPoint(new priv::ThreadFunctor(functor)) 71 | { 72 | } 73 | 74 | 75 | //////////////////////////////////////////////////////////// 76 | template 77 | Thread::Thread(F function, A argument) : 78 | m_impl (NULL), 79 | m_entryPoint(new priv::ThreadFunctorWithArg(function, argument)) 80 | { 81 | } 82 | 83 | 84 | //////////////////////////////////////////////////////////// 85 | template 86 | Thread::Thread(void(C::*function)(), C* object) : 87 | m_impl (NULL), 88 | m_entryPoint(new priv::ThreadMemberFunc(function, object)) 89 | { 90 | } 91 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/ThreadLocal.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_THREADLOCAL_HPP 26 | #define SFML_THREADLOCAL_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | #include 34 | 35 | 36 | namespace sf 37 | { 38 | namespace priv 39 | { 40 | class ThreadLocalImpl; 41 | } 42 | 43 | //////////////////////////////////////////////////////////// 44 | /// \brief Defines variables with thread-local storage 45 | /// 46 | //////////////////////////////////////////////////////////// 47 | class SFML_SYSTEM_API ThreadLocal : NonCopyable 48 | { 49 | public: 50 | 51 | //////////////////////////////////////////////////////////// 52 | /// \brief Default constructor 53 | /// 54 | /// \param value Optional value to initialize the variable 55 | /// 56 | //////////////////////////////////////////////////////////// 57 | ThreadLocal(void* value = NULL); 58 | 59 | //////////////////////////////////////////////////////////// 60 | /// \brief Destructor 61 | /// 62 | //////////////////////////////////////////////////////////// 63 | ~ThreadLocal(); 64 | 65 | //////////////////////////////////////////////////////////// 66 | /// \brief Set the thread-specific value of the variable 67 | /// 68 | /// \param value Value of the variable for the current thread 69 | /// 70 | //////////////////////////////////////////////////////////// 71 | void setValue(void* value); 72 | 73 | //////////////////////////////////////////////////////////// 74 | /// \brief Retrieve the thread-specific value of the variable 75 | /// 76 | /// \return Value of the variable for the current thread 77 | /// 78 | //////////////////////////////////////////////////////////// 79 | void* getValue() const; 80 | 81 | private: 82 | 83 | //////////////////////////////////////////////////////////// 84 | // Member data 85 | //////////////////////////////////////////////////////////// 86 | priv::ThreadLocalImpl* m_impl; ///< Pointer to the OS specific implementation 87 | }; 88 | 89 | } // namespace sf 90 | 91 | 92 | #endif // SFML_THREADLOCAL_HPP 93 | 94 | 95 | //////////////////////////////////////////////////////////// 96 | /// \class sf::ThreadLocal 97 | /// \ingroup system 98 | /// 99 | /// This class manipulates void* parameters and thus is not 100 | /// appropriate for strongly-typed variables. You should rather 101 | /// use the sf::ThreadLocalPtr template class. 102 | /// 103 | //////////////////////////////////////////////////////////// 104 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/ThreadLocalPtr.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_THREADLOCALPTR_HPP 26 | #define SFML_THREADLOCALPTR_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | namespace sf 35 | { 36 | //////////////////////////////////////////////////////////// 37 | /// \brief Pointer to a thread-local variable 38 | /// 39 | //////////////////////////////////////////////////////////// 40 | template 41 | class ThreadLocalPtr : private ThreadLocal 42 | { 43 | public: 44 | 45 | //////////////////////////////////////////////////////////// 46 | /// \brief Default constructor 47 | /// 48 | /// \param value Optional value to initialize the variable 49 | /// 50 | //////////////////////////////////////////////////////////// 51 | ThreadLocalPtr(T* value = NULL); 52 | 53 | //////////////////////////////////////////////////////////// 54 | /// \brief Overload of unary operator * 55 | /// 56 | /// Like raw pointers, applying the * operator returns a 57 | /// reference to the pointed-to object. 58 | /// 59 | /// \return Reference to the thread-local variable 60 | /// 61 | //////////////////////////////////////////////////////////// 62 | T& operator *() const; 63 | 64 | //////////////////////////////////////////////////////////// 65 | /// \brief Overload of operator -> 66 | /// 67 | /// Similarly to raw pointers, applying the -> operator 68 | /// returns the pointed-to object. 69 | /// 70 | /// \return Pointer to the thread-local variable 71 | /// 72 | //////////////////////////////////////////////////////////// 73 | T* operator ->() const; 74 | 75 | //////////////////////////////////////////////////////////// 76 | /// \brief Conversion operator to implicitly convert the 77 | /// pointer to its raw pointer type (T*) 78 | /// 79 | /// \return Pointer to the actual object 80 | /// 81 | //////////////////////////////////////////////////////////// 82 | operator T*() const; 83 | 84 | //////////////////////////////////////////////////////////// 85 | /// \brief Assignment operator for a raw pointer parameter 86 | /// 87 | /// \param value Pointer to assign 88 | /// 89 | /// \return Reference to self 90 | /// 91 | //////////////////////////////////////////////////////////// 92 | ThreadLocalPtr& operator =(T* value); 93 | 94 | //////////////////////////////////////////////////////////// 95 | /// \brief Assignment operator for a ThreadLocalPtr parameter 96 | /// 97 | /// \param right ThreadLocalPtr to assign 98 | /// 99 | /// \return Reference to self 100 | /// 101 | //////////////////////////////////////////////////////////// 102 | ThreadLocalPtr& operator =(const ThreadLocalPtr& right); 103 | }; 104 | 105 | } // namespace sf 106 | 107 | #include 108 | 109 | 110 | #endif // SFML_THREADLOCALPTR_HPP 111 | 112 | 113 | //////////////////////////////////////////////////////////// 114 | /// \class sf::ThreadLocalPtr 115 | /// \ingroup system 116 | /// 117 | /// sf::ThreadLocalPtr is a type-safe wrapper for storing 118 | /// pointers to thread-local variables. A thread-local 119 | /// variable holds a different value for each different 120 | /// thread, unlike normal variables that are shared. 121 | /// 122 | /// Its usage is completely transparent, so that it is similar 123 | /// to manipulating the raw pointer directly (like any smart pointer). 124 | /// 125 | /// Usage example: 126 | /// \code 127 | /// MyClass object1; 128 | /// MyClass object2; 129 | /// sf::ThreadLocalPtr objectPtr; 130 | /// 131 | /// void thread1() 132 | /// { 133 | /// objectPtr = &object1; // doesn't impact thread2 134 | /// ... 135 | /// } 136 | /// 137 | /// void thread2() 138 | /// { 139 | /// objectPtr = &object2; // doesn't impact thread1 140 | /// ... 141 | /// } 142 | /// 143 | /// int main() 144 | /// { 145 | /// // Create and launch the two threads 146 | /// sf::Thread t1(&thread1); 147 | /// sf::Thread t2(&thread2); 148 | /// t1.launch(); 149 | /// t2.launch(); 150 | /// 151 | /// return 0; 152 | /// } 153 | /// \endcode 154 | /// 155 | /// ThreadLocalPtr is designed for internal use; however you 156 | /// can use it if you feel like it fits well your implementation. 157 | /// 158 | //////////////////////////////////////////////////////////// 159 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/ThreadLocalPtr.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | 26 | namespace sf 27 | { 28 | //////////////////////////////////////////////////////////// 29 | template 30 | ThreadLocalPtr::ThreadLocalPtr(T* value) : 31 | ThreadLocal(value) 32 | { 33 | } 34 | 35 | 36 | //////////////////////////////////////////////////////////// 37 | template 38 | T& ThreadLocalPtr::operator *() const 39 | { 40 | return *static_cast(getValue()); 41 | } 42 | 43 | 44 | //////////////////////////////////////////////////////////// 45 | template 46 | T* ThreadLocalPtr::operator ->() const 47 | { 48 | return static_cast(getValue()); 49 | } 50 | 51 | 52 | //////////////////////////////////////////////////////////// 53 | template 54 | ThreadLocalPtr::operator T*() const 55 | { 56 | return static_cast(getValue()); 57 | } 58 | 59 | 60 | //////////////////////////////////////////////////////////// 61 | template 62 | ThreadLocalPtr& ThreadLocalPtr::operator =(T* value) 63 | { 64 | setValue(value); 65 | return *this; 66 | } 67 | 68 | 69 | //////////////////////////////////////////////////////////// 70 | template 71 | ThreadLocalPtr& ThreadLocalPtr::operator =(const ThreadLocalPtr& right) 72 | { 73 | setValue(right.getValue()); 74 | return *this; 75 | } 76 | 77 | } // namespace sf 78 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/Vector2.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | 26 | //////////////////////////////////////////////////////////// 27 | template 28 | inline Vector2::Vector2() : 29 | x(0), 30 | y(0) 31 | { 32 | 33 | } 34 | 35 | 36 | //////////////////////////////////////////////////////////// 37 | template 38 | inline Vector2::Vector2(T X, T Y) : 39 | x(X), 40 | y(Y) 41 | { 42 | 43 | } 44 | 45 | 46 | //////////////////////////////////////////////////////////// 47 | template 48 | template 49 | inline Vector2::Vector2(const Vector2& vector) : 50 | x(static_cast(vector.x)), 51 | y(static_cast(vector.y)) 52 | { 53 | } 54 | 55 | 56 | //////////////////////////////////////////////////////////// 57 | template 58 | inline Vector2 operator -(const Vector2& right) 59 | { 60 | return Vector2(-right.x, -right.y); 61 | } 62 | 63 | 64 | //////////////////////////////////////////////////////////// 65 | template 66 | inline Vector2& operator +=(Vector2& left, const Vector2& right) 67 | { 68 | left.x += right.x; 69 | left.y += right.y; 70 | 71 | return left; 72 | } 73 | 74 | 75 | //////////////////////////////////////////////////////////// 76 | template 77 | inline Vector2& operator -=(Vector2& left, const Vector2& right) 78 | { 79 | left.x -= right.x; 80 | left.y -= right.y; 81 | 82 | return left; 83 | } 84 | 85 | 86 | //////////////////////////////////////////////////////////// 87 | template 88 | inline Vector2 operator +(const Vector2& left, const Vector2& right) 89 | { 90 | return Vector2(left.x + right.x, left.y + right.y); 91 | } 92 | 93 | 94 | //////////////////////////////////////////////////////////// 95 | template 96 | inline Vector2 operator -(const Vector2& left, const Vector2& right) 97 | { 98 | return Vector2(left.x - right.x, left.y - right.y); 99 | } 100 | 101 | 102 | //////////////////////////////////////////////////////////// 103 | template 104 | inline Vector2 operator *(const Vector2& left, T right) 105 | { 106 | return Vector2(left.x * right, left.y * right); 107 | } 108 | 109 | 110 | //////////////////////////////////////////////////////////// 111 | template 112 | inline Vector2 operator *(T left, const Vector2& right) 113 | { 114 | return Vector2(right.x * left, right.y * left); 115 | } 116 | 117 | 118 | //////////////////////////////////////////////////////////// 119 | template 120 | inline Vector2& operator *=(Vector2& left, T right) 121 | { 122 | left.x *= right; 123 | left.y *= right; 124 | 125 | return left; 126 | } 127 | 128 | 129 | //////////////////////////////////////////////////////////// 130 | template 131 | inline Vector2 operator /(const Vector2& left, T right) 132 | { 133 | return Vector2(left.x / right, left.y / right); 134 | } 135 | 136 | 137 | //////////////////////////////////////////////////////////// 138 | template 139 | inline Vector2& operator /=(Vector2& left, T right) 140 | { 141 | left.x /= right; 142 | left.y /= right; 143 | 144 | return left; 145 | } 146 | 147 | 148 | //////////////////////////////////////////////////////////// 149 | template 150 | inline bool operator ==(const Vector2& left, const Vector2& right) 151 | { 152 | return (left.x == right.x) && (left.y == right.y); 153 | } 154 | 155 | 156 | //////////////////////////////////////////////////////////// 157 | template 158 | inline bool operator !=(const Vector2& left, const Vector2& right) 159 | { 160 | return (left.x != right.x) || (left.y != right.y); 161 | } 162 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/System/Vector3.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | 26 | //////////////////////////////////////////////////////////// 27 | template 28 | inline Vector3::Vector3() : 29 | x(0), 30 | y(0), 31 | z(0) 32 | { 33 | 34 | } 35 | 36 | 37 | //////////////////////////////////////////////////////////// 38 | template 39 | inline Vector3::Vector3(T X, T Y, T Z) : 40 | x(X), 41 | y(Y), 42 | z(Z) 43 | { 44 | 45 | } 46 | 47 | 48 | //////////////////////////////////////////////////////////// 49 | template 50 | template 51 | inline Vector3::Vector3(const Vector3& vector) : 52 | x(static_cast(vector.x)), 53 | y(static_cast(vector.y)), 54 | z(static_cast(vector.z)) 55 | { 56 | } 57 | 58 | 59 | //////////////////////////////////////////////////////////// 60 | template 61 | inline Vector3 operator -(const Vector3& left) 62 | { 63 | return Vector3(-left.x, -left.y, -left.z); 64 | } 65 | 66 | 67 | //////////////////////////////////////////////////////////// 68 | template 69 | inline Vector3& operator +=(Vector3& left, const Vector3& right) 70 | { 71 | left.x += right.x; 72 | left.y += right.y; 73 | left.z += right.z; 74 | 75 | return left; 76 | } 77 | 78 | 79 | //////////////////////////////////////////////////////////// 80 | template 81 | inline Vector3& operator -=(Vector3& left, const Vector3& right) 82 | { 83 | left.x -= right.x; 84 | left.y -= right.y; 85 | left.z -= right.z; 86 | 87 | return left; 88 | } 89 | 90 | 91 | //////////////////////////////////////////////////////////// 92 | template 93 | inline Vector3 operator +(const Vector3& left, const Vector3& right) 94 | { 95 | return Vector3(left.x + right.x, left.y + right.y, left.z + right.z); 96 | } 97 | 98 | 99 | //////////////////////////////////////////////////////////// 100 | template 101 | inline Vector3 operator -(const Vector3& left, const Vector3& right) 102 | { 103 | return Vector3(left.x - right.x, left.y - right.y, left.z - right.z); 104 | } 105 | 106 | 107 | //////////////////////////////////////////////////////////// 108 | template 109 | inline Vector3 operator *(const Vector3& left, T right) 110 | { 111 | return Vector3(left.x * right, left.y * right, left.z * right); 112 | } 113 | 114 | 115 | //////////////////////////////////////////////////////////// 116 | template 117 | inline Vector3 operator *(T left, const Vector3& right) 118 | { 119 | return Vector3(right.x * left, right.y * left, right.z * left); 120 | } 121 | 122 | 123 | //////////////////////////////////////////////////////////// 124 | template 125 | inline Vector3& operator *=(Vector3& left, T right) 126 | { 127 | left.x *= right; 128 | left.y *= right; 129 | left.z *= right; 130 | 131 | return left; 132 | } 133 | 134 | 135 | //////////////////////////////////////////////////////////// 136 | template 137 | inline Vector3 operator /(const Vector3& left, T right) 138 | { 139 | return Vector3(left.x / right, left.y / right, left.z / right); 140 | } 141 | 142 | 143 | //////////////////////////////////////////////////////////// 144 | template 145 | inline Vector3& operator /=(Vector3& left, T right) 146 | { 147 | left.x /= right; 148 | left.y /= right; 149 | left.z /= right; 150 | 151 | return left; 152 | } 153 | 154 | 155 | //////////////////////////////////////////////////////////// 156 | template 157 | inline bool operator ==(const Vector3& left, const Vector3& right) 158 | { 159 | return (left.x == right.x) && (left.y == right.y) && (left.z == right.z); 160 | } 161 | 162 | 163 | //////////////////////////////////////////////////////////// 164 | template 165 | inline bool operator !=(const Vector3& left, const Vector3& right) 166 | { 167 | return (left.x != right.x) || (left.y != right.y) || (left.z != right.z); 168 | } 169 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Window.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_SFML_WINDOW_HPP 26 | #define SFML_SFML_WINDOW_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | 49 | 50 | #endif // SFML_SFML_WINDOW_HPP 51 | 52 | //////////////////////////////////////////////////////////// 53 | /// \defgroup window Window module 54 | /// 55 | /// Provides OpenGL-based windows, and abstractions for 56 | /// events and input handling. 57 | /// 58 | //////////////////////////////////////////////////////////// 59 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Window/Clipboard.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_CLIPBOARD_HPP 26 | #define SFML_CLIPBOARD_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | //////////////////////////////////////////////////////////// 38 | /// \brief Give access to the system clipboard 39 | /// 40 | //////////////////////////////////////////////////////////// 41 | class SFML_WINDOW_API Clipboard 42 | { 43 | public: 44 | 45 | //////////////////////////////////////////////////////////// 46 | /// \brief Get the content of the clipboard as string data 47 | /// 48 | /// This function returns the content of the clipboard 49 | /// as a string. If the clipboard does not contain string 50 | /// it returns an empty sf::String object. 51 | /// 52 | /// \return Clipboard contents as sf::String object 53 | /// 54 | //////////////////////////////////////////////////////////// 55 | static String getString(); 56 | 57 | //////////////////////////////////////////////////////////// 58 | /// \brief Set the content of the clipboard as string data 59 | /// 60 | /// This function sets the content of the clipboard as a 61 | /// string. 62 | /// 63 | /// \warning Due to limitations on some operating systems, 64 | /// setting the clipboard contents is only 65 | /// guaranteed to work if there is currently an 66 | /// open window for which events are being handled. 67 | /// 68 | /// \param text sf::String containing the data to be sent 69 | /// to the clipboard 70 | /// 71 | //////////////////////////////////////////////////////////// 72 | static void setString(const String& text); 73 | }; 74 | 75 | } // namespace sf 76 | 77 | 78 | #endif // SFML_CLIPBOARD_HPP 79 | 80 | 81 | //////////////////////////////////////////////////////////// 82 | /// \class sf::Clipboard 83 | /// \ingroup window 84 | /// 85 | /// sf::Clipboard provides an interface for getting and 86 | /// setting the contents of the system clipboard. 87 | /// 88 | /// It is important to note that due to limitations on some 89 | /// operating systems, setting the clipboard contents is 90 | /// only guaranteed to work if there is currently an open 91 | /// window for which events are being handled. 92 | /// 93 | /// Usage example: 94 | /// \code 95 | /// // get the clipboard content as a string 96 | /// sf::String string = sf::Clipboard::getString(); 97 | /// 98 | /// // or use it in the event loop 99 | /// sf::Event event; 100 | /// while(window.pollEvent(event)) 101 | /// { 102 | /// if(event.type == sf::Event::Closed) 103 | /// window.close(); 104 | /// if(event.type == sf::Event::KeyPressed) 105 | /// { 106 | /// // Using Ctrl + V to paste a string into SFML 107 | /// if(event.key.control && event.key.code == sf::Keyboard::V) 108 | /// string = sf::Clipboard::getString(); 109 | /// 110 | /// // Using Ctrl + C to copy a string out of SFML 111 | /// if(event.key.control && event.key.code == sf::Keyboard::C) 112 | /// sf::Clipboard::setString("Hello World!"); 113 | /// } 114 | /// } 115 | /// \endcode 116 | /// 117 | /// \see sf::String, sf::Event 118 | /// 119 | //////////////////////////////////////////////////////////// 120 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Window/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_WINDOW_EXPORT_HPP 26 | #define SFML_WINDOW_EXPORT_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | // Define portable import / export macros 36 | //////////////////////////////////////////////////////////// 37 | #if defined(SFML_WINDOW_EXPORTS) 38 | 39 | #define SFML_WINDOW_API SFML_API_EXPORT 40 | 41 | #else 42 | 43 | #define SFML_WINDOW_API SFML_API_IMPORT 44 | 45 | #endif 46 | 47 | 48 | #endif // SFML_WINDOW_EXPORT_HPP 49 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Window/GlResource.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_GLRESOURCE_HPP 26 | #define SFML_GLRESOURCE_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | 38 | class Context; 39 | 40 | typedef void(*ContextDestroyCallback)(void*); 41 | 42 | //////////////////////////////////////////////////////////// 43 | /// \brief Base class for classes that require an OpenGL context 44 | /// 45 | //////////////////////////////////////////////////////////// 46 | class SFML_WINDOW_API GlResource 47 | { 48 | protected: 49 | 50 | //////////////////////////////////////////////////////////// 51 | /// \brief Default constructor 52 | /// 53 | //////////////////////////////////////////////////////////// 54 | GlResource(); 55 | 56 | //////////////////////////////////////////////////////////// 57 | /// \brief Destructor 58 | /// 59 | //////////////////////////////////////////////////////////// 60 | ~GlResource(); 61 | 62 | //////////////////////////////////////////////////////////// 63 | /// \brief Register a function to be called when a context is destroyed 64 | /// 65 | /// This is used for internal purposes in order to properly 66 | /// clean up OpenGL resources that cannot be shared between 67 | /// contexts. 68 | /// 69 | /// \param callback Function to be called when a context is destroyed 70 | /// \param arg Argument to pass when calling the function 71 | /// 72 | //////////////////////////////////////////////////////////// 73 | static void registerContextDestroyCallback(ContextDestroyCallback callback, void* arg); 74 | 75 | //////////////////////////////////////////////////////////// 76 | /// \brief RAII helper class to temporarily lock an available context for use 77 | /// 78 | //////////////////////////////////////////////////////////// 79 | class SFML_WINDOW_API TransientContextLock : NonCopyable 80 | { 81 | public: 82 | //////////////////////////////////////////////////////////// 83 | /// \brief Default constructor 84 | /// 85 | //////////////////////////////////////////////////////////// 86 | TransientContextLock(); 87 | 88 | //////////////////////////////////////////////////////////// 89 | /// \brief Destructor 90 | /// 91 | //////////////////////////////////////////////////////////// 92 | ~TransientContextLock(); 93 | }; 94 | }; 95 | 96 | } // namespace sf 97 | 98 | 99 | #endif // SFML_GLRESOURCE_HPP 100 | 101 | //////////////////////////////////////////////////////////// 102 | /// \class sf::GlResource 103 | /// \ingroup window 104 | /// 105 | /// This class is for internal use only, it must be the base 106 | /// of every class that requires a valid OpenGL context in 107 | /// order to work. 108 | /// 109 | //////////////////////////////////////////////////////////// 110 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Window/Touch.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_TOUCH_HPP 26 | #define SFML_TOUCH_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | class Window; 38 | 39 | //////////////////////////////////////////////////////////// 40 | /// \brief Give access to the real-time state of the touches 41 | /// 42 | //////////////////////////////////////////////////////////// 43 | class SFML_WINDOW_API Touch 44 | { 45 | public: 46 | 47 | //////////////////////////////////////////////////////////// 48 | /// \brief Check if a touch event is currently down 49 | /// 50 | /// \param finger Finger index 51 | /// 52 | /// \return True if \a finger is currently touching the screen, false otherwise 53 | /// 54 | //////////////////////////////////////////////////////////// 55 | static bool isDown(unsigned int finger); 56 | 57 | //////////////////////////////////////////////////////////// 58 | /// \brief Get the current position of a touch in desktop coordinates 59 | /// 60 | /// This function returns the current touch position 61 | /// in global (desktop) coordinates. 62 | /// 63 | /// \param finger Finger index 64 | /// 65 | /// \return Current position of \a finger, or undefined if it's not down 66 | /// 67 | //////////////////////////////////////////////////////////// 68 | static Vector2i getPosition(unsigned int finger); 69 | 70 | //////////////////////////////////////////////////////////// 71 | /// \brief Get the current position of a touch in window coordinates 72 | /// 73 | /// This function returns the current touch position 74 | /// relative to the given window. 75 | /// 76 | /// \param finger Finger index 77 | /// \param relativeTo Reference window 78 | /// 79 | /// \return Current position of \a finger, or undefined if it's not down 80 | /// 81 | //////////////////////////////////////////////////////////// 82 | static Vector2i getPosition(unsigned int finger, const Window& relativeTo); 83 | }; 84 | 85 | } // namespace sf 86 | 87 | 88 | #endif // SFML_TOUCH_HPP 89 | 90 | 91 | //////////////////////////////////////////////////////////// 92 | /// \class sf::Touch 93 | /// \ingroup window 94 | /// 95 | /// sf::Touch provides an interface to the state of the 96 | /// touches. It only contains static functions, so it's not 97 | /// meant to be instantiated. 98 | /// 99 | /// This class allows users to query the touches state at any 100 | /// time and directly, without having to deal with a window and 101 | /// its events. Compared to the TouchBegan, TouchMoved 102 | /// and TouchEnded events, sf::Touch can retrieve the 103 | /// state of the touches at any time (you don't need to store and 104 | /// update a boolean on your side in order to know if a touch is down), 105 | /// and you always get the real state of the touches, even if they 106 | /// happen when your window is out of focus and no event is triggered. 107 | /// 108 | /// The getPosition function can be used to retrieve the current 109 | /// position of a touch. There are two versions: one that operates 110 | /// in global coordinates (relative to the desktop) and one that 111 | /// operates in window coordinates (relative to a specific window). 112 | /// 113 | /// Touches are identified by an index (the "finger"), so that in 114 | /// multi-touch events, individual touches can be tracked correctly. 115 | /// As long as a finger touches the screen, it will keep the same index 116 | /// even if other fingers start or stop touching the screen in the 117 | /// meantime. As a consequence, active touch indices may not always be 118 | /// sequential (i.e. touch number 0 may be released while touch number 1 119 | /// is still down). 120 | /// 121 | /// Usage example: 122 | /// \code 123 | /// if (sf::Touch::isDown(0)) 124 | /// { 125 | /// // touch 0 is down 126 | /// } 127 | /// 128 | /// // get global position of touch 1 129 | /// sf::Vector2i globalPos = sf::Touch::getPosition(1); 130 | /// 131 | /// // get position of touch 1 relative to a window 132 | /// sf::Vector2i relativePos = sf::Touch::getPosition(1, window); 133 | /// \endcode 134 | /// 135 | /// \see sf::Joystick, sf::Keyboard, sf::Mouse 136 | /// 137 | //////////////////////////////////////////////////////////// 138 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Window/WindowHandle.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_WINDOWHANDLE_HPP 26 | #define SFML_WINDOWHANDLE_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | 33 | // Windows' HWND is a typedef on struct HWND__* 34 | #if defined(SFML_SYSTEM_WINDOWS) 35 | struct HWND__; 36 | #endif 37 | 38 | namespace sf 39 | { 40 | #if defined(SFML_SYSTEM_WINDOWS) 41 | 42 | // Window handle is HWND (HWND__*) on Windows 43 | typedef HWND__* WindowHandle; 44 | 45 | #elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD) 46 | 47 | // Window handle is Window (unsigned long) on Unix - X11 48 | typedef unsigned long WindowHandle; 49 | 50 | #elif defined(SFML_SYSTEM_MACOS) 51 | 52 | // Window handle is NSWindow or NSView (void*) on Mac OS X - Cocoa 53 | typedef void* WindowHandle; 54 | 55 | #elif defined(SFML_SYSTEM_IOS) 56 | 57 | // Window handle is UIWindow (void*) on iOS - UIKit 58 | typedef void* WindowHandle; 59 | 60 | #elif defined(SFML_SYSTEM_ANDROID) 61 | 62 | // Window handle is ANativeWindow* (void*) on Android 63 | typedef void* WindowHandle; 64 | 65 | #elif defined(SFML_DOXYGEN) 66 | 67 | // Define typedef symbol so that Doxygen can attach some documentation to it 68 | typedef "platform-specific" WindowHandle; 69 | 70 | #endif 71 | 72 | } // namespace sf 73 | 74 | 75 | #endif // SFML_WINDOWHANDLE_HPP 76 | 77 | //////////////////////////////////////////////////////////// 78 | /// \typedef sf::WindowHandle 79 | /// \ingroup window 80 | /// 81 | /// Define a low-level window handle type, specific to 82 | /// each platform. 83 | /// 84 | /// Platform | Type 85 | /// ----------------|------------------------------------------------------------ 86 | /// Windows | \p HWND 87 | /// Linux/FreeBSD | \p %Window 88 | /// Mac OS X | either \p NSWindow* or \p NSView*, disguised as \p void* 89 | /// iOS | \p UIWindow* 90 | /// Android | \p ANativeWindow* 91 | /// 92 | /// \par Mac OS X Specification 93 | /// 94 | /// On Mac OS X, a sf::Window can be created either from an 95 | /// existing \p NSWindow* or an \p NSView*. When the window 96 | /// is created from a window, SFML will use its content view 97 | /// as the OpenGL area. sf::Window::getSystemHandle() will 98 | /// return the handle that was used to create the window, 99 | /// which is a \p NSWindow* by default. 100 | /// 101 | //////////////////////////////////////////////////////////// 102 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/include/SFML/Window/WindowStyle.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) 5 | // 6 | // This software is provided 'as-is', without any express or implied warranty. 7 | // In no event will the authors be held liable for any damages arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it freely, 11 | // subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; 14 | // you must not claim that you wrote the original software. 15 | // If you use this software in a product, an acknowledgment 16 | // in the product documentation would be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, 19 | // and must not be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source distribution. 22 | // 23 | //////////////////////////////////////////////////////////// 24 | 25 | #ifndef SFML_WINDOWSTYLE_HPP 26 | #define SFML_WINDOWSTYLE_HPP 27 | 28 | 29 | namespace sf 30 | { 31 | namespace Style 32 | { 33 | //////////////////////////////////////////////////////////// 34 | /// \ingroup window 35 | /// \brief Enumeration of the window styles 36 | /// 37 | //////////////////////////////////////////////////////////// 38 | enum 39 | { 40 | None = 0, ///< No border / title bar (this flag and all others are mutually exclusive) 41 | Titlebar = 1 << 0, ///< Title bar + fixed border 42 | Resize = 1 << 1, ///< Title bar + resizable border + maximize button 43 | Close = 1 << 2, ///< Title bar + close button 44 | Fullscreen = 1 << 3, ///< Fullscreen mode (this flag and all others are mutually exclusive) 45 | 46 | Default = Titlebar | Resize | Close ///< Default window style 47 | }; 48 | } 49 | 50 | } // namespace sf 51 | 52 | 53 | #endif // SFML_WINDOWSTYLE_HPP 54 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/cmake/SFML/SFMLConfigDependencies.cmake: -------------------------------------------------------------------------------- 1 | 2 | if (CMAKE_VERSION VERSION_LESS 3.5.2) 3 | include(CMakeParseArguments) 4 | endif() 5 | 6 | # in case of static linking, we must also define the list of all the dependencies of SFML libraries 7 | if(SFML_STATIC_LIBRARIES) 8 | # detect the OS 9 | if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") 10 | set(FIND_SFML_OS_WINDOWS 1) 11 | elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") 12 | set(FIND_SFML_OS_LINUX 1) 13 | elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") 14 | set(FIND_SFML_OS_FREEBSD 1) 15 | elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 16 | if (DEFINED IOS) 17 | set(FIND_SFML_OS_IOS 1) 18 | else() 19 | set(FIND_SFML_OS_MACOSX 1) 20 | endif() 21 | endif() 22 | 23 | # start with an empty list 24 | set(FIND_SFML_DEPENDENCIES_NOTFOUND) 25 | 26 | # macro that searches for a 3rd-party library 27 | function(sfml_bind_dependency) 28 | cmake_parse_arguments(THIS "" "TARGET;FRIENDLY_NAME" "SEARCH_NAMES" ${ARGN}) 29 | if (THIS_UNPARSED_ARGUMENTS) 30 | message(FATAL_ERROR "Unknown arguments when calling sfml_bind_dependency: ${THIS_UNPARSED_ARGUMENTS}") 31 | endif() 32 | 33 | # No lookup in environment variables (PATH on Windows), as they may contain wrong library versions 34 | find_library(${THIS_FRIENDLY_NAME}_LIB NAMES ${THIS_SEARCH_NAMES} 35 | PATHS ${FIND_SFML_PATHS} PATH_SUFFIXES lib NO_SYSTEM_ENVIRONMENT_PATH) 36 | mark_as_advanced(${THIS_FRIENDLY_NAME}_LIB) 37 | if(${THIS_FRIENDLY_NAME}_LIB) 38 | set_property(TARGET ${THIS_TARGET} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${${THIS_FRIENDLY_NAME}_LIB}") 39 | else() 40 | set(FIND_SFML_DEPENDENCIES_NOTFOUND "${FIND_SFML_DEPENDENCIES_NOTFOUND} ${THIS_FRIENDLY_NAME}" PARENT_SCOPE) 41 | endif() 42 | endfunction() 43 | 44 | # sfml-window 45 | list(FIND SFML_FIND_COMPONENTS "window" FIND_SFML_WINDOW_COMPONENT_INDEX) 46 | if(FIND_SFML_WINDOW_COMPONENT_INDEX GREATER -1) 47 | if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD) 48 | sfml_bind_dependency(TARGET X11 FRIENDLY_NAME "X11" SEARCH_NAMES "X11") 49 | sfml_bind_dependency(TARGET X11 FRIENDLY_NAME "Xrandr" SEARCH_NAMES "Xrandr") 50 | endif() 51 | 52 | if(FIND_SFML_OS_LINUX) 53 | sfml_bind_dependency(TARGET UDev FRIENDLY_NAME "UDev" SEARCH_NAMES "udev" "libudev") 54 | endif() 55 | 56 | if (FIND_SFML_OS_WINDOWS) 57 | set_property(TARGET OpenGL APPEND PROPERTY INTERFACE_LINK_LIBRARIES "OpenGL32") 58 | elseif(NOT FIND_SFML_OS_IOS) 59 | sfml_bind_dependency(TARGET OpenGL FRIENDLY_NAME "OpenGL" SEARCH_NAMES "OpenGL" "GL") 60 | endif() 61 | endif() 62 | 63 | # sfml-graphics 64 | list(FIND SFML_FIND_COMPONENTS "graphics" FIND_SFML_GRAPHICS_COMPONENT_INDEX) 65 | if(FIND_SFML_GRAPHICS_COMPONENT_INDEX GREATER -1) 66 | sfml_bind_dependency(TARGET Freetype FRIENDLY_NAME "FreeType" SEARCH_NAMES "freetype") 67 | endif() 68 | 69 | # sfml-audio 70 | list(FIND SFML_FIND_COMPONENTS "audio" FIND_SFML_AUDIO_COMPONENT_INDEX) 71 | if(FIND_SFML_AUDIO_COMPONENT_INDEX GREATER -1) 72 | sfml_bind_dependency(TARGET OpenAL FRIENDLY_NAME "OpenAL" SEARCH_NAMES "OpenAL" "openal" "openal32") 73 | if (NOT FIND_SFML_OS_IOS) 74 | sfml_bind_dependency(TARGET Vorbis FRIENDLY_NAME "VorbisFile" SEARCH_NAMES "vorbisfile") 75 | sfml_bind_dependency(TARGET Vorbis FRIENDLY_NAME "VorbisEnc" SEARCH_NAMES "vorbisenc") 76 | endif() 77 | sfml_bind_dependency(TARGET Vorbis FRIENDLY_NAME "Vorbis" SEARCH_NAMES "vorbis") 78 | sfml_bind_dependency(TARGET Vorbis FRIENDLY_NAME "Ogg" SEARCH_NAMES "ogg") 79 | sfml_bind_dependency(TARGET FLAC FRIENDLY_NAME "FLAC" SEARCH_NAMES "FLAC") 80 | endif() 81 | 82 | if (FIND_SFML_DEPENDENCIES_NOTFOUND) 83 | set(FIND_SFML_ERROR "SFML found but some of its dependencies are missing (${FIND_SFML_DEPENDENCIES_NOTFOUND})") 84 | set(SFML_FOUND FALSE) 85 | endif() 86 | endif() 87 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/cmake/SFML/SFMLConfigVersion.cmake: -------------------------------------------------------------------------------- 1 | # This is a basic version file for the Config-mode of find_package(). 2 | # It is used by write_basic_package_version_file() as input file for configure_file() 3 | # to create a version-file which can be installed along a config.cmake file. 4 | # 5 | # The created file sets PACKAGE_VERSION_EXACT if the current version string and 6 | # the requested version string are exactly the same and it sets 7 | # PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version, 8 | # but only if the requested major version is the same as the current one. 9 | # The variable CVF_VERSION must be set before calling configure_file(). 10 | 11 | 12 | set(PACKAGE_VERSION "2.5.1") 13 | 14 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 15 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 16 | else() 17 | 18 | if("2.5.1" MATCHES "^([0-9]+)\\.") 19 | set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") 20 | else() 21 | set(CVF_VERSION_MAJOR "2.5.1") 22 | endif() 23 | 24 | if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) 25 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 26 | else() 27 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 28 | endif() 29 | 30 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 31 | set(PACKAGE_VERSION_EXACT TRUE) 32 | endif() 33 | endif() 34 | 35 | 36 | # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: 37 | if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "") 38 | return() 39 | endif() 40 | 41 | # check that the installed version has the same 32/64bit-ness as the one which is currently searching: 42 | if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8") 43 | math(EXPR installedBits "8 * 8") 44 | set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") 45 | set(PACKAGE_VERSION_UNSUITABLE TRUE) 46 | endif() 47 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/cmake/SFML/SFMLSharedTargets-release.cmake: -------------------------------------------------------------------------------- 1 | #---------------------------------------------------------------- 2 | # Generated CMake target import file for configuration "Release". 3 | #---------------------------------------------------------------- 4 | 5 | # Commands may need to know the format version. 6 | set(CMAKE_IMPORT_FILE_VERSION 1) 7 | 8 | # Import target "sfml-system" for configuration "Release" 9 | set_property(TARGET sfml-system APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 10 | set_target_properties(sfml-system PROPERTIES 11 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libsfml-system.so.2.5.1" 12 | IMPORTED_SONAME_RELEASE "libsfml-system.so.2.5" 13 | ) 14 | 15 | list(APPEND _IMPORT_CHECK_TARGETS sfml-system ) 16 | list(APPEND _IMPORT_CHECK_FILES_FOR_sfml-system "${_IMPORT_PREFIX}/lib/libsfml-system.so.2.5.1" ) 17 | 18 | # Import target "sfml-window" for configuration "Release" 19 | set_property(TARGET sfml-window APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 20 | set_target_properties(sfml-window PROPERTIES 21 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libsfml-window.so.2.5.1" 22 | IMPORTED_SONAME_RELEASE "libsfml-window.so.2.5" 23 | ) 24 | 25 | list(APPEND _IMPORT_CHECK_TARGETS sfml-window ) 26 | list(APPEND _IMPORT_CHECK_FILES_FOR_sfml-window "${_IMPORT_PREFIX}/lib/libsfml-window.so.2.5.1" ) 27 | 28 | # Import target "sfml-network" for configuration "Release" 29 | set_property(TARGET sfml-network APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 30 | set_target_properties(sfml-network PROPERTIES 31 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libsfml-network.so.2.5.1" 32 | IMPORTED_SONAME_RELEASE "libsfml-network.so.2.5" 33 | ) 34 | 35 | list(APPEND _IMPORT_CHECK_TARGETS sfml-network ) 36 | list(APPEND _IMPORT_CHECK_FILES_FOR_sfml-network "${_IMPORT_PREFIX}/lib/libsfml-network.so.2.5.1" ) 37 | 38 | # Import target "sfml-graphics" for configuration "Release" 39 | set_property(TARGET sfml-graphics APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 40 | set_target_properties(sfml-graphics PROPERTIES 41 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libsfml-graphics.so.2.5.1" 42 | IMPORTED_SONAME_RELEASE "libsfml-graphics.so.2.5" 43 | ) 44 | 45 | list(APPEND _IMPORT_CHECK_TARGETS sfml-graphics ) 46 | list(APPEND _IMPORT_CHECK_FILES_FOR_sfml-graphics "${_IMPORT_PREFIX}/lib/libsfml-graphics.so.2.5.1" ) 47 | 48 | # Import target "sfml-audio" for configuration "Release" 49 | set_property(TARGET sfml-audio APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 50 | set_target_properties(sfml-audio PROPERTIES 51 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libsfml-audio.so.2.5.1" 52 | IMPORTED_SONAME_RELEASE "libsfml-audio.so.2.5" 53 | ) 54 | 55 | list(APPEND _IMPORT_CHECK_TARGETS sfml-audio ) 56 | list(APPEND _IMPORT_CHECK_FILES_FOR_sfml-audio "${_IMPORT_PREFIX}/lib/libsfml-audio.so.2.5.1" ) 57 | 58 | # Commands beyond this point should not need to know the version. 59 | set(CMAKE_IMPORT_FILE_VERSION) 60 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/cmake/SFML/SFMLSharedTargets.cmake: -------------------------------------------------------------------------------- 1 | # Generated by CMake 2 | 3 | if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) 4 | message(FATAL_ERROR "CMake >= 2.6.0 required") 5 | endif() 6 | cmake_policy(PUSH) 7 | cmake_policy(VERSION 2.6) 8 | #---------------------------------------------------------------- 9 | # Generated CMake target import file. 10 | #---------------------------------------------------------------- 11 | 12 | # Commands may need to know the format version. 13 | set(CMAKE_IMPORT_FILE_VERSION 1) 14 | 15 | # Protect against multiple inclusion, which would fail when already imported targets are added once more. 16 | set(_targetsDefined) 17 | set(_targetsNotDefined) 18 | set(_expectedTargets) 19 | foreach(_expectedTarget sfml-system sfml-window X11 OpenGL UDev sfml-network sfml-graphics Freetype OpenAL Vorbis FLAC sfml-audio) 20 | list(APPEND _expectedTargets ${_expectedTarget}) 21 | if(NOT TARGET ${_expectedTarget}) 22 | list(APPEND _targetsNotDefined ${_expectedTarget}) 23 | endif() 24 | if(TARGET ${_expectedTarget}) 25 | list(APPEND _targetsDefined ${_expectedTarget}) 26 | endif() 27 | endforeach() 28 | if("${_targetsDefined}" STREQUAL "${_expectedTargets}") 29 | unset(_targetsDefined) 30 | unset(_targetsNotDefined) 31 | unset(_expectedTargets) 32 | set(CMAKE_IMPORT_FILE_VERSION) 33 | cmake_policy(POP) 34 | return() 35 | endif() 36 | if(NOT "${_targetsDefined}" STREQUAL "") 37 | message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") 38 | endif() 39 | unset(_targetsDefined) 40 | unset(_targetsNotDefined) 41 | unset(_expectedTargets) 42 | 43 | 44 | # Compute the installation prefix relative to this file. 45 | get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) 46 | get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) 47 | get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) 48 | get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) 49 | if(_IMPORT_PREFIX STREQUAL "/") 50 | set(_IMPORT_PREFIX "") 51 | endif() 52 | 53 | # Create imported target sfml-system 54 | add_library(sfml-system SHARED IMPORTED) 55 | 56 | set_target_properties(sfml-system PROPERTIES 57 | INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" 58 | ) 59 | 60 | # Create imported target sfml-window 61 | add_library(sfml-window SHARED IMPORTED) 62 | 63 | set_target_properties(sfml-window PROPERTIES 64 | INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" 65 | INTERFACE_LINK_LIBRARIES "sfml-system" 66 | ) 67 | 68 | # Create imported target X11 69 | add_library(X11 INTERFACE IMPORTED) 70 | 71 | # Create imported target OpenGL 72 | add_library(OpenGL INTERFACE IMPORTED) 73 | 74 | # Create imported target UDev 75 | add_library(UDev INTERFACE IMPORTED) 76 | 77 | # Create imported target sfml-network 78 | add_library(sfml-network SHARED IMPORTED) 79 | 80 | set_target_properties(sfml-network PROPERTIES 81 | INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" 82 | INTERFACE_LINK_LIBRARIES "sfml-system" 83 | ) 84 | 85 | # Create imported target sfml-graphics 86 | add_library(sfml-graphics SHARED IMPORTED) 87 | 88 | set_target_properties(sfml-graphics PROPERTIES 89 | INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" 90 | INTERFACE_LINK_LIBRARIES "sfml-window" 91 | ) 92 | 93 | # Create imported target Freetype 94 | add_library(Freetype INTERFACE IMPORTED) 95 | 96 | # Create imported target OpenAL 97 | add_library(OpenAL INTERFACE IMPORTED) 98 | 99 | # Create imported target Vorbis 100 | add_library(Vorbis INTERFACE IMPORTED) 101 | 102 | set_target_properties(Vorbis PROPERTIES 103 | INTERFACE_COMPILE_DEFINITIONS "OV_EXCLUDE_STATIC_CALLBACKS" 104 | ) 105 | 106 | # Create imported target FLAC 107 | add_library(FLAC INTERFACE IMPORTED) 108 | 109 | set_target_properties(FLAC PROPERTIES 110 | INTERFACE_COMPILE_DEFINITIONS "FLAC__NO_DLL" 111 | ) 112 | 113 | # Create imported target sfml-audio 114 | add_library(sfml-audio SHARED IMPORTED) 115 | 116 | set_target_properties(sfml-audio PROPERTIES 117 | INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" 118 | INTERFACE_LINK_LIBRARIES "sfml-system" 119 | ) 120 | 121 | if(CMAKE_VERSION VERSION_LESS 3.0.0) 122 | message(FATAL_ERROR "This file relies on consumers using CMake 3.0.0 or greater.") 123 | endif() 124 | 125 | # Load information for each installed configuration. 126 | get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 127 | file(GLOB CONFIG_FILES "${_DIR}/SFMLSharedTargets-*.cmake") 128 | foreach(f ${CONFIG_FILES}) 129 | include(${f}) 130 | endforeach() 131 | 132 | # Cleanup temporary variables. 133 | set(_IMPORT_PREFIX) 134 | 135 | # Loop over all imported files and verify that they actually exist 136 | foreach(target ${_IMPORT_CHECK_TARGETS} ) 137 | foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) 138 | if(NOT EXISTS "${file}" ) 139 | message(FATAL_ERROR "The imported target \"${target}\" references the file 140 | \"${file}\" 141 | but this file does not exist. Possible reasons include: 142 | * The file was deleted, renamed, or moved to another location. 143 | * An install or uninstall procedure did not complete successfully. 144 | * The installation package was faulty and contained 145 | \"${CMAKE_CURRENT_LIST_FILE}\" 146 | but not all the files it references. 147 | ") 148 | endif() 149 | endforeach() 150 | unset(_IMPORT_CHECK_FILES_FOR_${target}) 151 | endforeach() 152 | unset(_IMPORT_CHECK_TARGETS) 153 | 154 | # This file does not depend on other imported targets which have 155 | # been exported from the same project but in a separate export set. 156 | 157 | # Commands beyond this point should not need to know the version. 158 | set(CMAKE_IMPORT_FILE_VERSION) 159 | cmake_policy(POP) 160 | -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/libsfml-audio.so: -------------------------------------------------------------------------------- 1 | libsfml-audio.so.2.5 -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/libsfml-audio.so.2.5: -------------------------------------------------------------------------------- 1 | libsfml-audio.so.2.5.1 -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/libsfml-audio.so.2.5.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alesbe/sorting-visualizer/74ffffb8c6aa21206156729cbc5b8dbc29115f52/lib/SFML-2.5.1/lib/libsfml-audio.so.2.5.1 -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/libsfml-graphics.so: -------------------------------------------------------------------------------- 1 | libsfml-graphics.so.2.5 -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/libsfml-graphics.so.2.5: -------------------------------------------------------------------------------- 1 | libsfml-graphics.so.2.5.1 -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/libsfml-graphics.so.2.5.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alesbe/sorting-visualizer/74ffffb8c6aa21206156729cbc5b8dbc29115f52/lib/SFML-2.5.1/lib/libsfml-graphics.so.2.5.1 -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/libsfml-network.so: -------------------------------------------------------------------------------- 1 | libsfml-network.so.2.5 -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/libsfml-network.so.2.5: -------------------------------------------------------------------------------- 1 | libsfml-network.so.2.5.1 -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/libsfml-network.so.2.5.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alesbe/sorting-visualizer/74ffffb8c6aa21206156729cbc5b8dbc29115f52/lib/SFML-2.5.1/lib/libsfml-network.so.2.5.1 -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/libsfml-system.so: -------------------------------------------------------------------------------- 1 | libsfml-system.so.2.5 -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/libsfml-system.so.2.5: -------------------------------------------------------------------------------- 1 | libsfml-system.so.2.5.1 -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/libsfml-system.so.2.5.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alesbe/sorting-visualizer/74ffffb8c6aa21206156729cbc5b8dbc29115f52/lib/SFML-2.5.1/lib/libsfml-system.so.2.5.1 -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/libsfml-window.so: -------------------------------------------------------------------------------- 1 | libsfml-window.so.2.5 -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/libsfml-window.so.2.5: -------------------------------------------------------------------------------- 1 | libsfml-window.so.2.5.1 -------------------------------------------------------------------------------- /lib/SFML-2.5.1/lib/libsfml-window.so.2.5.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alesbe/sorting-visualizer/74ffffb8c6aa21206156729cbc5b8dbc29115f52/lib/SFML-2.5.1/lib/libsfml-window.so.2.5.1 -------------------------------------------------------------------------------- /src/SortAlgorithms.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "Sortable.h" 5 | 6 | namespace algo { 7 | int bubbleSort(std::vector& sortElements, int timeSleep, const std::atomic& interrupt); 8 | int selectionSort(std::vector& sortElements, int timeSleep, const std::atomic& interrupt); 9 | int insertionSort(std::vector& sortElements, int timeSleep, const std::atomic& interrupt); 10 | int quickSort(std::vector& sortElements, int timeSleep, const std::atomic& interrupt); 11 | int cocktailSort(std::vector& sortElements, int timeSleep, const std::atomic& interrupt); 12 | int bogoSort(std::vector& sortElements, int timeSleep, const std::atomic& interrupt); 13 | int bitonicSort(std::vector& sortElements, int timeSleep, const std::atomic& interrupt); 14 | int oddEvenSort(std::vector& sortElements, int timeSleep, const std::atomic& interrupt); 15 | } 16 | 17 | namespace algoUtils { 18 | void swap(std::vector& sortElements, int timeSleep, Sortable& el1, Sortable& el2); 19 | } 20 | -------------------------------------------------------------------------------- /src/SortController.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef _WIN32 3 | #define CLEAR "cls" 4 | #else 5 | #define CLEAR "clear" 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "Sortable.h" 16 | #include "SortAlgorithms.h" 17 | 18 | class SortController 19 | { 20 | private: 21 | // Configurations 22 | int _winWidth, _winHeight; 23 | int _timeSleep; 24 | 25 | // Sort state 26 | bool _isSorting = false; 27 | std::atomic _interrupt = { false }; 28 | 29 | // Vector to be sorted 30 | std::vector _sortElements; 31 | 32 | // Threads 33 | std::thread _sortingThread; 34 | std::thread _animThread; 35 | 36 | /* 37 | This does the actual sorting loop, while `startSort` 38 | (with no underscore) just starts this function in its own thread 39 | */ 40 | void _startSort(int sortType); 41 | 42 | public: 43 | // Constructor 44 | SortController(sf::Vector2u windowSize, int timeSleep); 45 | 46 | // Getters 47 | bool isSorting() const { return _isSorting; } 48 | int winWidth() const { return _winWidth; } 49 | int winHeight() const { return _winHeight; } 50 | const std::vector& sortElements() const { return _sortElements; } 51 | 52 | // Vector control methods 53 | void clear(); 54 | void populate(int numOfElements); 55 | void randomize(); 56 | void setTimeSleep(int t); 57 | void displaySortInfo(int sortType, bool isSorting, int numOfComparisons, int sortTime) const; 58 | 59 | // Sorting methods 60 | void startSort(int sortType); 61 | void stopSort(); 62 | void checkSortAnim(); 63 | bool isSorted(); 64 | }; 65 | 66 | -------------------------------------------------------------------------------- /src/Sortable.cpp: -------------------------------------------------------------------------------- 1 | #include "Sortable.h" 2 | 3 | /** 4 | * @brief Construct a new Sortable object. Sortables are the elements that conforms the main sorting array 5 | * 6 | * @param width width of the sortable on screen 7 | * @param height height of the sortable on screen 8 | * @param value associated value to each element used to sort 9 | */ 10 | Sortable::Sortable(float width, float height, int value) { 11 | this->width = width; 12 | this->height = height; 13 | this->value = value; 14 | } 15 | 16 | /** 17 | * @brief Defines a shape for the sortable 18 | * 19 | * @return sf::RectangleShape prepared to be directly drawn on screen 20 | */ 21 | sf::RectangleShape Sortable::shape() { 22 | return sf::RectangleShape(sf::Vector2f((float)width, (float)height)); 23 | } -------------------------------------------------------------------------------- /src/Sortable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class Sortable 6 | { 7 | public: 8 | sf::Color color = sf::Color::White; 9 | int value; 10 | float width, height; 11 | 12 | Sortable(float width, float hight, int value); 13 | sf::RectangleShape shape(); 14 | }; 15 | 16 | -------------------------------------------------------------------------------- /src/Utils.cpp: -------------------------------------------------------------------------------- 1 | #include "Utils.h" 2 | 3 | const std::string kNoSort = ""; 4 | 5 | /** 6 | * @brief Returns the name of the algorithms providing the number associated to it. 7 | * 8 | * @param sortType Number associated to the algorithm 9 | * @return String of the algorithm name 10 | */ 11 | std::string Utils::getSortType(int sortType) { 12 | switch (sortType) 13 | { 14 | case 0: 15 | return "Bubble sort"; 16 | 17 | case 1: 18 | return "Selection sort"; 19 | 20 | case 2: 21 | return "Insertion sort"; 22 | 23 | case 3: 24 | return "Quick sort"; 25 | 26 | case 4: 27 | return "Cocktail sort"; 28 | 29 | case 5: 30 | return "Bogo sort"; 31 | 32 | case 6: 33 | return "Bitonic sort"; 34 | 35 | case 7: 36 | return "Odd-Even sort"; 37 | 38 | default: 39 | return kNoSort; 40 | } 41 | } 42 | 43 | /** 44 | * @brief Checks if the sort type exists 45 | * 46 | * @param sortType Number associated to the algorithm 47 | * @return true The sort algorithm exists 48 | * @return false The sort algoritm does not exist 49 | */ 50 | bool Utils::hasNextSortType(int sortType) { 51 | return getSortType(sortType + 1) != kNoSort; 52 | } 53 | -------------------------------------------------------------------------------- /src/Utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Utils 5 | { 6 | std::string getSortType(int sortType); 7 | bool hasNextSortType(int sortType); 8 | }; 9 | 10 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @name Sorting visualizer 3 | * @author alesbe - github.com/alesbe/ 4 | * @brief A lightweight sorting visualizer made with C++ and SFML. 5 | * @version v1.1 6 | * 7 | * @copyright License - MIT [alesbe 2022] 8 | * 9 | */ 10 | 11 | #ifdef _WIN32 12 | #define CLEAR "cls" 13 | #else 14 | #define CLEAR "clear" 15 | #endif 16 | 17 | #include 18 | #include 19 | #include 20 | #include "SortController.h" 21 | #include "Utils.h" 22 | 23 | int main() 24 | { 25 | // Window settings 26 | sf::RenderWindow window(sf::VideoMode(600, 400), "Sorting visualizer v1.1"); 27 | window.setFramerateLimit(60); 28 | 29 | // Visualizer settings (can be changed on runtime through the key events) 30 | int numOfElements = 150; 31 | int timeSleep = 1; 32 | int sortType = 0; 33 | 34 | // Initialize SortController 35 | SortController sortController(window.getSize(), timeSleep); 36 | sortController.populate(numOfElements); 37 | 38 | // Main loop 39 | while (window.isOpen()) 40 | { 41 | 42 | // Events 43 | sf::Event event; 44 | while (window.pollEvent(event)) 45 | { 46 | if (event.type == sf::Event::KeyPressed) { 47 | switch (event.key.code) 48 | { 49 | 50 | // Start sort 51 | case sf::Keyboard::Space: 52 | if (!sortController.isSorting()) { 53 | sortController.clear(); 54 | sortController.populate(numOfElements); 55 | sortController.randomize(); 56 | 57 | sortController.startSort(sortType); 58 | } 59 | break; 60 | 61 | // Stop sort 62 | case sf::Keyboard::Backspace: 63 | if (sortController.isSorting()) { 64 | system(CLEAR); 65 | std::cout << "Sort stopped!" << std::endl; 66 | sortController.stopSort(); 67 | } 68 | break; 69 | 70 | // Display help 71 | case sf::Keyboard::H: 72 | system(CLEAR); 73 | std::cout << "[Space]: Start sort" << std::endl; 74 | std::cout << "[Backspace]: Stop sort" << std::endl; 75 | std::cout << "[Up/Down Arrows]: Change sort type" << std::endl; 76 | std::cout << "[F1]: Change number of elements" << std::endl; 77 | std::cout << "[F2]: Change time between comparisons" << std::endl; 78 | break; 79 | 80 | // Change sort type (increase) 81 | case sf::Keyboard::Up: 82 | if (sortType >= 0 && Utils::hasNextSortType(sortType)) { 83 | sortType++; 84 | system(CLEAR); 85 | std::cout << "Sort changed to: " << Utils::getSortType(sortType) << std::endl; 86 | } 87 | else { 88 | //Go to the first sorting algorithm 89 | sortType = 0; 90 | system(CLEAR); 91 | std::cout << "Sort changed to " << Utils::getSortType(sortType) << std::endl; 92 | } 93 | break; 94 | 95 | // Change sort type (decrease) 96 | case sf::Keyboard::Down: 97 | if (sortType > 0) { 98 | sortType--; 99 | system(CLEAR); 100 | std::cout << "Sort changed to: " << Utils::getSortType(sortType) << std::endl; 101 | } 102 | else { 103 | //Go to the last sorting algorithm 104 | while(Utils::hasNextSortType(sortType)) 105 | { 106 | sortType++; 107 | } 108 | 109 | system(CLEAR); 110 | std::cout << "Sort changed to: " << Utils::getSortType(sortType) << std::endl; 111 | } 112 | break; 113 | 114 | // Change number of elements 115 | case sf::Keyboard::F1: 116 | if(!sortController.isSorting()) { 117 | system(CLEAR); 118 | std::cout << "Number of elements: "; 119 | std::cin >> numOfElements; 120 | std::cout << std::endl; 121 | 122 | sortController.clear(); 123 | sortController.populate(numOfElements); 124 | break; 125 | } 126 | 127 | // Change time between comparisons 128 | case sf::Keyboard::F2: 129 | if(!sortController.isSorting()) { 130 | system(CLEAR); 131 | std::cout << "Time between comparisons (milliseconds): "; 132 | std::cin >> timeSleep; 133 | std::cout << std::endl; 134 | 135 | sortController.setTimeSleep(timeSleep); 136 | break; 137 | } 138 | 139 | default: 140 | break; 141 | } 142 | } 143 | 144 | // Close window 145 | if (event.type == sf::Event::Closed) { 146 | sortController.stopSort(); 147 | window.close(); 148 | } 149 | } 150 | 151 | // Clear screen between each frame 152 | window.clear(sf::Color::Black); 153 | 154 | // Draw array elements 155 | int index = 0; 156 | for (auto sortable : sortController.sortElements()) { 157 | sf::RectangleShape shape = sortable.shape(); 158 | shape.setFillColor(sortable.color); 159 | shape.setPosition(sf::Vector2f(sortable.width * index++, sortController.winHeight() - sortable.height)); 160 | window.draw(shape); 161 | } 162 | 163 | // Display drawed content on screen 164 | window.display(); 165 | } 166 | 167 | return 0; 168 | } 169 | --------------------------------------------------------------------------------