├── .editorconfig ├── .gitignore ├── README.md ├── SAT ├── include │ ├── Application.hpp │ ├── Collider.hpp │ ├── Collision.hpp │ └── Utilities.hpp ├── main.cpp ├── pch │ ├── stpch.cpp │ └── stpch.h ├── premake5.lua └── src │ ├── Application.cpp │ ├── Collider.cpp │ └── Collision.cpp ├── build.bat ├── images └── preview.png ├── 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 │ ├── Color.inl │ ├── 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 │ ├── Transform.inl │ ├── Transformable.hpp │ ├── Vertex.hpp │ ├── Vertex.inl │ ├── 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 │ ├── Angle.hpp │ ├── Angle.inl │ ├── Clock.hpp │ ├── Err.hpp │ ├── Export.hpp │ ├── FileInputStream.hpp │ ├── InputStream.hpp │ ├── MemoryInputStream.hpp │ ├── NativeActivity.hpp │ ├── Sleep.hpp │ ├── String.hpp │ ├── String.inl │ ├── SuspendAwareClock.hpp │ ├── Time.hpp │ ├── Time.inl │ ├── 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 │ ├── Vulkan.hpp │ ├── Window.hpp │ ├── WindowBase.hpp │ ├── WindowHandle.hpp │ └── WindowStyle.hpp ├── libs ├── Debug │ ├── sfml-audio-s-d.lib │ ├── sfml-graphics-s-d.lib │ ├── sfml-main-d.lib │ ├── sfml-network-s-d.lib │ ├── sfml-system-s-d.lib │ └── sfml-window-s-d.lib ├── PDB │ ├── sfml-audio-s-d.pdb │ ├── sfml-audio-s.pdb │ ├── sfml-graphics-s-d.pdb │ ├── sfml-graphics-s.pdb │ ├── sfml-main-d.pdb │ ├── sfml-main-s.pdb │ ├── sfml-network-s-d.pdb │ ├── sfml-network-s.pdb │ ├── sfml-system-s-d.pdb │ ├── sfml-system-s.pdb │ ├── sfml-window-s-d.pdb │ └── sfml-window-s.pdb ├── Release │ ├── sfml-audio-s.lib │ ├── sfml-graphics-s.lib │ ├── sfml-main.lib │ ├── sfml-network-s.lib │ ├── sfml-system-s.lib │ └── sfml-window-s.lib └── extlibs │ ├── flac.lib │ ├── freetype.lib │ ├── ogg.lib │ ├── openal32.lib │ ├── vorbis.lib │ ├── vorbisenc.lib │ └── vorbisfile.lib ├── premake5.lua └── vendor ├── license.readme └── premake5.exe /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | indent_size = 4 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries 2 | **/bin/ 3 | 4 | # Visual Studio files and folder 5 | .vs/ 6 | **.sln 7 | **.vcxproj 8 | **.vcxproj.filters 9 | **.vcxproj.user -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SFML Simple SAT Collision 2 | 3 | ## Preview 4 | ![SAT](https://github.com/xSnapi/SAT-Collision/blob/master/images/preview.png?raw=true) 5 | 6 | # How to build? 7 | 8 | Clone repository and just run `build.bat` it will build for visual studio 2022
9 | If you want any older version run `.\vendor\premake5.exe vs2019` from main folder (works at least to vs17) -------------------------------------------------------------------------------- /SAT/include/Application.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SFML/Graphics/RenderWindow.hpp" 4 | #include "SFML/Window/Event.hpp" 5 | 6 | #include "Collider.hpp" 7 | #include "Collision.hpp" 8 | 9 | class Application { 10 | public: 11 | Application(); 12 | ~Application(); 13 | 14 | void Run(); 15 | 16 | static Application* Instance; 17 | static float DT; 18 | 19 | sf::RenderWindow Window; 20 | sf::Event Event; 21 | 22 | private: 23 | sf::Clock m_dtClock; 24 | 25 | std::vector m_Colliders; 26 | 27 | BoxCollider m_box; 28 | 29 | void CreateColliders(); 30 | void CheckCollision(); 31 | void UpdateBox(); 32 | 33 | void Update(); 34 | void Render(); 35 | 36 | void HandleEvents(); 37 | 38 | void InitWindow(); 39 | }; 40 | -------------------------------------------------------------------------------- /SAT/include/Collider.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SFML/Graphics/RenderTarget.hpp" 4 | #include "SFML/Graphics/Drawable.hpp" 5 | #include "SFML/System/Vector2.hpp" 6 | 7 | #include 8 | 9 | class Collision; 10 | 11 | class Collider : public sf::Drawable { 12 | public: 13 | Collider(uint32_t count); 14 | virtual ~Collider(); 15 | 16 | // Modifiers 17 | void SetPosition(sf::Vector2f position); 18 | void SetOrigin (sf::Vector2f origin); 19 | void SetRotation(sf::Angle angle); 20 | void Move (sf::Vector2f offset); 21 | void Rotate (sf::Angle angle); 22 | 23 | // Accessors 24 | sf::Vector2f GetPosition() const; 25 | sf::Vector2f GetOrigin() const; 26 | sf::Angle GetRotation() const; 27 | 28 | std::function Trigger; 29 | 30 | protected: 31 | sf::Vector2f m_position; 32 | sf::Vector2f m_origin; 33 | sf::Angle m_rotation; 34 | 35 | sf::Vector2f* m_vertices; 36 | uint32_t m_verticesCount = 0; 37 | 38 | private: 39 | friend class Collision; 40 | }; 41 | 42 | class BoxCollider : public Collider { 43 | public: 44 | BoxCollider(); 45 | ~BoxCollider(); 46 | 47 | void Create(sf::Vector2f size); 48 | 49 | private: 50 | sf::Vector2f m_size; 51 | 52 | virtual void draw(sf::RenderTarget& target, const sf::RenderStates& states) const; 53 | }; 54 | 55 | class CircleCollider : public Collider { 56 | public: 57 | CircleCollider(); 58 | ~CircleCollider(); 59 | 60 | void Create(float radius); 61 | 62 | float GetRadius() const; 63 | 64 | private: 65 | float m_radius = 0.0f; 66 | 67 | virtual void draw(sf::RenderTarget& target, const sf::RenderStates& states) const; 68 | }; 69 | 70 | class CustomCollider : public Collider { 71 | public: 72 | CustomCollider(); 73 | 74 | CustomCollider(uint32_t count); 75 | 76 | ~CustomCollider(); 77 | 78 | sf::Vector2f* GetVertices(); 79 | sf::Vector2f& GetVertices(uint32_t index); 80 | 81 | void Create(uint32_t count); 82 | 83 | sf::Vector2f& operator[](uint32_t index); 84 | 85 | private: 86 | virtual void draw(sf::RenderTarget& target, const sf::RenderStates& states) const; 87 | }; 88 | -------------------------------------------------------------------------------- /SAT/include/Collision.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Collider.hpp" 4 | 5 | constexpr float INF = std::numeric_limits::infinity(); 6 | 7 | class Collision { 8 | public: 9 | static Collision Instance; 10 | 11 | bool SATCollision(const Collider& body, const Collider& other, sf::Vector2f& MTV); 12 | 13 | bool SATCollision(const CircleCollider& body, const Collider& other, sf::Vector2f& MTV); 14 | bool SATCollision(const Collider& body, const CircleCollider& other, sf::Vector2f& MTV); 15 | 16 | bool SATCollision(const CircleCollider& body, const CircleCollider& other, sf::Vector2f& MTV); 17 | 18 | private: 19 | Collision(); 20 | ~Collision(); 21 | 22 | sf::Vector2f CircleAxis(sf::Vector2f* vertices, uint32_t count, sf::Vector2f center); 23 | 24 | sf::Vector2f PerpendicularAxis(sf::Vector2f* vertices, uint32_t index, uint32_t count) const; 25 | 26 | sf::Vector2f ProjectOnto(sf::Vector2f* vertices, uint32_t count, sf::Vector2f axis) const; 27 | sf::Vector2f ProjectCircle(sf::Vector2f circleCenter, float radius, sf::Vector2f axis) const; 28 | 29 | sf::Vector2f GetCenter(const Collider& body) const; 30 | 31 | float Overlap(sf::Vector2f v0, sf::Vector2f v1) const; 32 | }; -------------------------------------------------------------------------------- /SAT/include/Utilities.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | constexpr float PI = 3.14159265f; 4 | 5 | template 6 | inline float DotProduct(sf::Vector2 v0, sf::Vector2 v1) { 7 | return v0.x * v1.x + v0.y * v1.y; 8 | } 9 | 10 | template // Z coords of crossed vectors 11 | inline float CrossProduct(sf::Vector2 v0, sf::Vector2 v1) { 12 | return v0.x * v1.y - v0.y * v1.x; 13 | } 14 | 15 | template 16 | inline float Distance(sf::Vector2 v0, sf::Vector2 v1) { 17 | return sqrtf((v0 - v1).x * (v0 - v1).x + (v0 - v1).y * (v0 - v1).y); 18 | } 19 | 20 | template 21 | inline float Length(sf::Vector2 v) { 22 | return sqrtf(v.x * v.x + v.y * v.y); 23 | } 24 | 25 | template 26 | static sf::Vector2 Normalize(sf::Vector2 v) { 27 | float length = Length(v); 28 | 29 | return length ? v / length : sf::Vector2(); 30 | } 31 | 32 | template 33 | static sf::Vector2 Rotate(sf::Vector2 point, sf::Vector2 center, sf::Angle angle) { 34 | float r = angle.asRadians(); 35 | 36 | return sf::Vector2 37 | { 38 | cosf(r)* (point.x - center.x) - sinf(r) * (point.y - center.y) + center.x, 39 | sinf(r)* (point.x - center.x) + cosf(r) * (point.y - center.y) + center.y 40 | }; 41 | } 42 | 43 | template 44 | inline sf::Vector2 VecAbs(sf::Vector2 v) { 45 | return sf::Vector2 46 | { 47 | v.x < T(0) ? -v.x : v.x, 48 | v.y < T(0) ? -v.y : v.y 49 | }; 50 | } 51 | 52 | inline sf::Vector2f Lerp(sf::Vector2f x, sf::Vector2f y, float t) { 53 | return x * (1.0f - t) + y * t; 54 | } 55 | 56 | inline sf::Vector2f MousePos(const sf::RenderWindow& window = *(sf::RenderWindow*)nullptr) { 57 | return !&window ? (sf::Vector2f)sf::Mouse::getPosition() : window.mapPixelToCoords(sf::Mouse::getPosition(window)); 58 | } 59 | 60 | #ifdef DEBUG 61 | template 62 | void Print(T&&... args) { 63 | (std::cout << ... << args); 64 | } 65 | 66 | #define LOG(...) Print(__VA_ARGS__) 67 | 68 | #else 69 | 70 | #define LOG(...) 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /SAT/main.cpp: -------------------------------------------------------------------------------- 1 | #include "stpch.h" 2 | 3 | #include "Application.hpp" 4 | 5 | int main() { 6 | Application::Instance = new Application(); 7 | 8 | Application::Instance->Run(); 9 | 10 | delete Application::Instance; 11 | 12 | return EXIT_SUCCESS; 13 | } 14 | -------------------------------------------------------------------------------- /SAT/pch/stpch.cpp: -------------------------------------------------------------------------------- 1 | #include "stpch.h" -------------------------------------------------------------------------------- /SAT/pch/stpch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include "Utilities.hpp" 8 | 9 | constexpr uint32_t WINDOW_WIDTH = 1600; 10 | constexpr uint32_t WINDOW_HEIGHT = 900; 11 | 12 | extern const float& dt; 13 | -------------------------------------------------------------------------------- /SAT/premake5.lua: -------------------------------------------------------------------------------- 1 | project "SAT" 2 | kind "ConsoleApp" 3 | language "C++" 4 | cppdialect "C++17" 5 | staticruntime "on" 6 | 7 | targetdir "bin/%{cfg.buildcfg}" 8 | objdir "bin/Obj/%{cfg.buildcfg}" 9 | 10 | pchheader "stpch.h" 11 | pchsource "pch/stpch.cpp" 12 | 13 | files { 14 | "**.h", 15 | "**.hpp", 16 | "**.cpp", 17 | "*.lua", 18 | "*.dll" 19 | } 20 | 21 | includedirs { 22 | "../include", 23 | "include", 24 | "pch", 25 | } 26 | 27 | libdirs { 28 | "../libs/extlibs" 29 | } 30 | 31 | defines { 32 | "SFML_STATIC" 33 | } 34 | 35 | links { 36 | "opengl32.lib", 37 | "openal32.lib", 38 | "freetype.lib", 39 | "winmm.lib", 40 | "gdi32.lib", 41 | "flac.lib", 42 | "vorbisenc.lib", 43 | "vorbisfile.lib", 44 | "vorbis.lib", 45 | "ogg.lib", 46 | "ws2_32.lib", 47 | "legacy_stdio_definitions.lib", 48 | } 49 | 50 | filter "configurations:Debug" 51 | defines { "DEBUG" } 52 | symbols "On" 53 | libdirs { 54 | "../libs/Debug" 55 | } 56 | 57 | links { 58 | "sfml-graphics-s-d.lib", 59 | "sfml-window-s-d.lib", 60 | "sfml-system-s-d.lib", 61 | "sfml-audio-s-d.lib", 62 | "sfml-network-s-d.lib" 63 | } 64 | 65 | filter "configurations:Release" 66 | defines { "NDEBUG" } 67 | optimize "On" 68 | libdirs { 69 | "../libs/Release" 70 | } 71 | 72 | links { 73 | "sfml-graphics-s.lib", 74 | "sfml-window-s.lib", 75 | "sfml-system-s.lib", 76 | "sfml-audio-s.lib", 77 | "sfml-network-s.lib" 78 | } 79 | -------------------------------------------------------------------------------- /SAT/src/Application.cpp: -------------------------------------------------------------------------------- 1 | #include "stpch.h" 2 | #include "Application.hpp" 3 | 4 | Application* Application::Instance = nullptr; 5 | float Application::DT = 0.0f; 6 | 7 | const float& dt = Application::DT; 8 | 9 | Application::Application() { 10 | InitWindow(); 11 | 12 | CreateColliders(); 13 | } 14 | 15 | Application::~Application() { 16 | for (auto& c : m_Colliders) 17 | delete c; 18 | } 19 | 20 | void Application::Run() { 21 | m_dtClock.restart(); 22 | 23 | while (Window.isOpen()) { 24 | HandleEvents(); 25 | Update(); 26 | 27 | Window.clear(sf::Color(13, 17, 31)); 28 | Render(); 29 | Window.display(); 30 | 31 | DT = m_dtClock.restart().asSeconds(); 32 | } 33 | } 34 | 35 | void Application::CheckCollision() { 36 | for (auto& c : m_Colliders) { 37 | sf::Vector2f MTV; 38 | Collision::Instance.SATCollision(m_box, *c, MTV); 39 | 40 | m_box.Move(MTV); 41 | } 42 | } 43 | 44 | void Application::UpdateBox() { 45 | constexpr float smoothness = 16.0f; 46 | 47 | if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) 48 | m_box.Rotate(sf::degrees(100.0f * dt)); 49 | 50 | sf::Vector2f start = m_box.GetPosition(); 51 | sf::Vector2f end = MousePos(Window); 52 | sf::Vector2f pos = Lerp(start, end, smoothness * dt); 53 | 54 | m_box.SetPosition(pos); 55 | } 56 | 57 | void Application::Update() { 58 | UpdateBox(); 59 | CheckCollision(); 60 | } 61 | 62 | void Application::Render() { 63 | for (auto& c : m_Colliders) 64 | Window.draw(*c); 65 | 66 | Window.draw(m_box); 67 | } 68 | 69 | void Application::HandleEvents() { 70 | while (Window.pollEvent(Event)) { 71 | switch (Event.type) { 72 | case sf::Event::Closed: 73 | Window.close(); 74 | } 75 | } 76 | } 77 | 78 | void Application::InitWindow() { 79 | sf::VideoMode mode; 80 | mode.width = WINDOW_WIDTH; 81 | mode.height = WINDOW_HEIGHT; 82 | 83 | sf::ContextSettings settings; 84 | 85 | Window.create(mode, "SAT Collision", sf::Style::Close, settings); 86 | Window.setFramerateLimit(144); 87 | } 88 | 89 | void Application::CreateColliders() { 90 | { 91 | m_box.Create(sf::Vector2f(100.0f, 100.0f)); 92 | m_box.SetOrigin(sf::Vector2f(50.0f, 50.0f)); 93 | m_box.SetPosition(MousePos(Window)); 94 | } 95 | 96 | { 97 | CircleCollider* c = new CircleCollider(); 98 | 99 | c->Create(100.0f); 100 | 101 | c->SetPosition(sf::Vector2f(220.0f, 220.0f)); 102 | 103 | m_Colliders.push_back(c); 104 | } 105 | 106 | { 107 | CircleCollider* c = new CircleCollider(); 108 | 109 | c->Create(50.0f); 110 | 111 | c->SetPosition(sf::Vector2f(920.0f, 150.0f)); 112 | 113 | m_Colliders.push_back(c); 114 | } 115 | 116 | { 117 | BoxCollider* c = new BoxCollider(); 118 | 119 | c->Create(sf::Vector2f(200.0f, 200.0f)); 120 | 121 | c->SetPosition(sf::Vector2f(650.0f, 330.0f)); 122 | 123 | c->SetRotation(sf::degrees(45.0f)); 124 | 125 | m_Colliders.push_back(c); 126 | } 127 | 128 | { 129 | BoxCollider* c = new BoxCollider(); 130 | 131 | c->Create(sf::Vector2f(300.0f, 200.0f)); 132 | 133 | c->SetPosition(sf::Vector2f(120.0f, 560.0f)); 134 | 135 | c->SetRotation(sf::degrees(25.0f)); 136 | 137 | m_Colliders.push_back(c); 138 | } 139 | 140 | { 141 | 142 | CustomCollider* c = new CustomCollider(3); 143 | 144 | c->GetVertices(0) = sf::Vector2f(0.0f, 0.0f); 145 | c->GetVertices(1) = sf::Vector2f(200.0f, 200.0f); 146 | c->GetVertices(2) = sf::Vector2f(200.0f, 0.0f); 147 | 148 | c->SetPosition(sf::Vector2f(1230.0f, 80.0f)); 149 | 150 | c->SetRotation(sf::degrees(15.0f)); 151 | 152 | m_Colliders.push_back(c); 153 | } 154 | 155 | { 156 | 157 | CustomCollider* c = new CustomCollider(6); 158 | 159 | c->GetVertices(0) = sf::Vector2f(100.0f, 0.0f ); 160 | c->GetVertices(1) = sf::Vector2f(200.0f, 0.0f ); 161 | c->GetVertices(2) = sf::Vector2f(260.0f, 60.0f ); 162 | c->GetVertices(3) = sf::Vector2f(160.0f, 120.0f); 163 | c->GetVertices(4) = sf::Vector2f(80.0f , 120.0f); 164 | c->GetVertices(5) = sf::Vector2f(0.0f , 50.0f ); 165 | 166 | c->SetPosition(sf::Vector2f(1340.0f, 450.0f)); 167 | 168 | c->SetRotation(sf::degrees(15.0f)); 169 | 170 | m_Colliders.push_back(c); 171 | } 172 | 173 | { 174 | 175 | CustomCollider* c = new CustomCollider(4); 176 | 177 | c->GetVertices(0) = sf::Vector2f(0.0f , 0.0f ); 178 | c->GetVertices(1) = sf::Vector2f(200.0f, 200.0f); 179 | c->GetVertices(2) = sf::Vector2f(200.0f, 0.0f ); 180 | c->GetVertices(3) = sf::Vector2f(0.0f , -200.0f); 181 | 182 | c->SetPosition(sf::Vector2f(950.0f, 600.0f)); 183 | 184 | c->SetRotation(sf::degrees(75.0f)); 185 | 186 | m_Colliders.push_back(c); 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /SAT/src/Collider.cpp: -------------------------------------------------------------------------------- 1 | #include "stpch.h" 2 | #include "Collider.hpp" 3 | 4 | constexpr sf::Color ColliderColor(255, 255, 255); 5 | 6 | Collider::Collider(uint32_t count) 7 | : m_verticesCount(count) 8 | , m_vertices (nullptr) 9 | , m_position (0.0f, 0.0f) 10 | , m_origin (0.0f, 0.0f) 11 | , m_rotation (sf::degrees(0.0f)) 12 | { 13 | if (!count) 14 | return; 15 | 16 | m_vertices = new sf::Vector2f[count]; 17 | } 18 | 19 | Collider::~Collider() { 20 | delete[] m_vertices; 21 | } 22 | 23 | void Collider::SetPosition(sf::Vector2f position) { 24 | sf::Vector2f diff = position - m_position - m_origin; 25 | 26 | for (uint32_t i = 0; i < m_verticesCount; i++) { 27 | auto& v = m_vertices[i]; 28 | 29 | v += diff; 30 | } 31 | 32 | m_position = position - m_origin; 33 | } 34 | 35 | void Collider::SetOrigin(sf::Vector2f origin) { 36 | m_origin = origin; 37 | 38 | SetPosition(m_position); 39 | } 40 | 41 | void Collider::SetRotation(sf::Angle angle) { 42 | sf::Angle diff = angle - m_rotation; 43 | 44 | for (uint32_t i = 0; i < m_verticesCount; i++) { 45 | auto& v = m_vertices[i]; 46 | 47 | v = ::Rotate(v, m_position + m_origin, diff); 48 | } 49 | 50 | m_rotation = angle; 51 | } 52 | 53 | void Collider::Move(sf::Vector2f offset) { 54 | SetPosition(m_position + offset + m_origin); 55 | } 56 | 57 | void Collider::Rotate(sf::Angle angle) { 58 | SetRotation(m_rotation + angle); 59 | } 60 | 61 | sf::Vector2f Collider::GetPosition() const { 62 | return m_position + m_origin; 63 | } 64 | 65 | sf::Vector2f Collider::GetOrigin() const { 66 | return m_origin; 67 | } 68 | 69 | sf::Angle Collider::GetRotation() const { 70 | return m_rotation; 71 | } 72 | 73 | BoxCollider::BoxCollider() 74 | : Collider(4) 75 | { 76 | 77 | } 78 | 79 | BoxCollider::~BoxCollider() { 80 | 81 | } 82 | 83 | void BoxCollider::Create(sf::Vector2f size) { 84 | auto& v = m_vertices; 85 | 86 | sf::Vector2f pos = m_position - m_origin; 87 | 88 | v[0] = pos + sf::Vector2f(0.0f, 0.0f); 89 | v[1] = pos + sf::Vector2f(size.x, 0.0f); 90 | v[2] = pos + sf::Vector2f(size.x, size.y); 91 | v[3] = pos + sf::Vector2f(0.0f, size.y); 92 | } 93 | 94 | void BoxCollider::draw(sf::RenderTarget& target, const sf::RenderStates& states) const { 95 | static sf::Vertex v[6]; 96 | 97 | for (int i = 0; i < 4; i++) 98 | v[i] = sf::Vertex(m_vertices[i], ColliderColor); 99 | 100 | v[4] = sf::Vertex(m_vertices[0], ColliderColor); 101 | v[5] = sf::Vertex(m_vertices[2], ColliderColor); 102 | 103 | target.draw(v, 6, sf::LineStrip); 104 | } 105 | 106 | CircleCollider::CircleCollider() 107 | : Collider(1) 108 | { 109 | 110 | } 111 | 112 | CircleCollider::~CircleCollider() { 113 | 114 | } 115 | 116 | void CircleCollider::Create(float radius) { 117 | m_radius = radius; 118 | } 119 | 120 | float CircleCollider::GetRadius() const { 121 | return m_radius; 122 | } 123 | 124 | void CircleCollider::draw(sf::RenderTarget& target, const sf::RenderStates& states) const { 125 | constexpr uint32_t points = 32; 126 | 127 | if (m_radius <= 0.0f) 128 | return; 129 | 130 | sf::Angle angle = sf::radians(2 * PI / (float)points); 131 | 132 | sf::Vector2f p = m_position; 133 | p.y += m_radius; 134 | 135 | static sf::Vertex v[points + 1]; 136 | 137 | for (uint32_t i = 0; i <= points; i++) 138 | v[i] = sf::Vertex(::Rotate(p, m_position, angle * (float)i), ColliderColor); 139 | 140 | target.draw(v, points + 1, sf::LineStrip); 141 | target.draw(&sf::Vertex(m_position, ColliderColor), 1, sf::Points); 142 | } 143 | 144 | CustomCollider::CustomCollider() 145 | : Collider(0) 146 | { 147 | 148 | } 149 | 150 | CustomCollider::CustomCollider(uint32_t count) 151 | : Collider(count) 152 | { 153 | 154 | } 155 | 156 | CustomCollider::~CustomCollider() { 157 | 158 | } 159 | 160 | sf::Vector2f* CustomCollider::GetVertices() { 161 | return m_vertices; 162 | } 163 | 164 | sf::Vector2f& CustomCollider::GetVertices(uint32_t index) { 165 | return m_vertices[index]; 166 | } 167 | 168 | void CustomCollider::Create(uint32_t count) { 169 | delete[] m_vertices; 170 | 171 | m_vertices = new sf::Vector2f[count]; 172 | 173 | m_verticesCount = count; 174 | } 175 | 176 | sf::Vector2f& CustomCollider::operator[](uint32_t index) { 177 | return m_vertices[index]; 178 | } 179 | 180 | void CustomCollider::draw(sf::RenderTarget& target, const sf::RenderStates& states) const { 181 | const uint32_t count = m_verticesCount + 1; 182 | 183 | sf::Vertex* v = new sf::Vertex[count]; 184 | 185 | for (uint32_t i = 0; i < count - 1; i++) 186 | v[i] = sf::Vertex(m_vertices[i], ColliderColor); 187 | 188 | v[count - 1] = sf::Vertex(m_vertices[0], ColliderColor); 189 | 190 | target.draw(v, count, sf::LineStrip); 191 | 192 | delete[] v; 193 | } 194 | -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | xcopy /y "libs\PDB" "SAT\bin\Debug\*" 2 | .\vendor\premake5.exe vs2022 -------------------------------------------------------------------------------- /images/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/images/preview.png -------------------------------------------------------------------------------- /include/SFML/Audio.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /include/SFML/Audio/AlResource.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /include/SFML/Audio/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /include/SFML/Audio/OutputSoundFile.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | #include 35 | 36 | 37 | namespace sf 38 | { 39 | class SoundFileWriter; 40 | 41 | //////////////////////////////////////////////////////////// 42 | /// \brief Provide write access to sound files 43 | /// 44 | //////////////////////////////////////////////////////////// 45 | class SFML_AUDIO_API OutputSoundFile 46 | { 47 | public: 48 | 49 | //////////////////////////////////////////////////////////// 50 | /// \brief Default constructor 51 | /// 52 | //////////////////////////////////////////////////////////// 53 | OutputSoundFile(); 54 | 55 | //////////////////////////////////////////////////////////// 56 | /// \brief Destructor 57 | /// 58 | /// Closes the file if it was still open. 59 | /// 60 | //////////////////////////////////////////////////////////// 61 | ~OutputSoundFile(); 62 | 63 | //////////////////////////////////////////////////////////// 64 | /// \brief Deleted copy constructor 65 | /// 66 | //////////////////////////////////////////////////////////// 67 | OutputSoundFile(const OutputSoundFile&) = delete; 68 | 69 | //////////////////////////////////////////////////////////// 70 | /// \brief Deleted copy assignment 71 | /// 72 | //////////////////////////////////////////////////////////// 73 | OutputSoundFile& operator=(const OutputSoundFile&) = delete; 74 | 75 | //////////////////////////////////////////////////////////// 76 | /// \brief Open the sound file from the disk for writing 77 | /// 78 | /// The supported audio formats are: WAV, OGG/Vorbis, FLAC. 79 | /// 80 | /// \param filename Path of the sound file to write 81 | /// \param sampleRate Sample rate of the sound 82 | /// \param channelCount Number of channels in the sound 83 | /// 84 | /// \return True if the file was successfully opened 85 | /// 86 | //////////////////////////////////////////////////////////// 87 | [[nodiscard]] bool openFromFile(const std::filesystem::path& filename, unsigned int sampleRate, unsigned int channelCount); 88 | 89 | //////////////////////////////////////////////////////////// 90 | /// \brief Write audio samples to the file 91 | /// 92 | /// \param samples Pointer to the sample array to write 93 | /// \param count Number of samples to write 94 | /// 95 | //////////////////////////////////////////////////////////// 96 | void write(const Int16* samples, Uint64 count); 97 | 98 | //////////////////////////////////////////////////////////// 99 | /// \brief Close the current file 100 | /// 101 | //////////////////////////////////////////////////////////// 102 | void close(); 103 | 104 | private: 105 | 106 | //////////////////////////////////////////////////////////// 107 | // Member data 108 | //////////////////////////////////////////////////////////// 109 | std::unique_ptr m_writer; //!< Writer that handles I/O on the file's format 110 | }; 111 | 112 | } // namespace sf 113 | 114 | 115 | #endif // SFML_OUTPUTSOUNDFILE_HPP 116 | 117 | 118 | //////////////////////////////////////////////////////////// 119 | /// \class sf::OutputSoundFile 120 | /// \ingroup audio 121 | /// 122 | /// This class encodes audio samples to a sound file. It is 123 | /// used internally by higher-level classes such as sf::SoundBuffer, 124 | /// but can also be useful if you want to create audio files from 125 | /// custom data sources, like generated audio samples. 126 | /// 127 | /// Usage example: 128 | /// \code 129 | /// // Create a sound file, ogg/vorbis format, 44100 Hz, stereo 130 | /// sf::OutputSoundFile file; 131 | /// if (!file.openFromFile("music.ogg", 44100, 2)) 132 | /// /* error */; 133 | /// 134 | /// while (...) 135 | /// { 136 | /// // Read or generate audio samples from your custom source 137 | /// std::vector samples = ...; 138 | /// 139 | /// // Write them to the file 140 | /// file.write(samples.data(), samples.size()); 141 | /// } 142 | /// \endcode 143 | /// 144 | /// \see sf::SoundFileWriter, sf::InputSoundFile 145 | /// 146 | //////////////////////////////////////////////////////////// 147 | -------------------------------------------------------------------------------- /include/SFML/Audio/SoundBufferRecorder.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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() override; 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 | [[nodiscard]] bool onStart() override; 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 | [[nodiscard]] bool onProcessSamples(const Int16* samples, std::size_t sampleCount) override; 87 | 88 | //////////////////////////////////////////////////////////// 89 | /// \brief Stop capturing audio data 90 | /// 91 | //////////////////////////////////////////////////////////// 92 | void onStop() override; 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 | /// if (!recorder.start()) 131 | /// { 132 | /// // Handle error... 133 | /// } 134 | /// ... 135 | /// recorder.stop(); 136 | /// 137 | /// // Get the buffer containing the captured audio data 138 | /// const sf::SoundBuffer& buffer = recorder.getBuffer(); 139 | /// 140 | /// // Save it to a file (for example...) 141 | /// if (!buffer.saveToFile("my_record.ogg")) 142 | /// { 143 | /// // Handle error... 144 | /// } 145 | /// } 146 | /// \endcode 147 | /// 148 | /// \see sf::SoundRecorder 149 | /// 150 | //////////////////////////////////////////////////////////// 151 | -------------------------------------------------------------------------------- /include/SFML/Audio/SoundFileFactory.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 std::unique_ptr createReader() { return std::make_unique(); } 35 | template std::unique_ptr createWriter() { return std::make_unique(); } 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 (auto it = s_readers.begin(); it != s_readers.end(); /* noop */) 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 (auto it = s_writers.begin(); it != s_writers.end(); /* noop */) 92 | { 93 | if (it->create == &priv::createWriter) 94 | it = s_writers.erase(it); 95 | else 96 | ++it; 97 | } 98 | } 99 | 100 | } // namespace sf 101 | -------------------------------------------------------------------------------- /include/SFML/Audio/SoundFileWriter.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | #include 34 | 35 | 36 | namespace sf 37 | { 38 | //////////////////////////////////////////////////////////// 39 | /// \brief Abstract base class for sound file encoding 40 | /// 41 | //////////////////////////////////////////////////////////// 42 | class SFML_AUDIO_API SoundFileWriter 43 | { 44 | public: 45 | 46 | //////////////////////////////////////////////////////////// 47 | /// \brief Virtual destructor 48 | /// 49 | //////////////////////////////////////////////////////////// 50 | virtual ~SoundFileWriter() {} 51 | 52 | //////////////////////////////////////////////////////////// 53 | /// \brief Open a sound file for writing 54 | /// 55 | /// \param filename Path of the file to open 56 | /// \param sampleRate Sample rate of the sound 57 | /// \param channelCount Number of channels of the sound 58 | /// 59 | /// \return True if the file was successfully opened 60 | /// 61 | //////////////////////////////////////////////////////////// 62 | [[nodiscard]] virtual bool open(const std::filesystem::path& filename, unsigned int sampleRate, unsigned int channelCount) = 0; 63 | 64 | //////////////////////////////////////////////////////////// 65 | /// \brief Write audio samples to the open file 66 | /// 67 | /// \param samples Pointer to the sample array to write 68 | /// \param count Number of samples to write 69 | /// 70 | //////////////////////////////////////////////////////////// 71 | virtual void write(const Int16* samples, Uint64 count) = 0; 72 | }; 73 | 74 | } // namespace sf 75 | 76 | 77 | #endif // SFML_SOUNDFILEWRITER_HPP 78 | 79 | 80 | //////////////////////////////////////////////////////////// 81 | /// \class sf::SoundFileWriter 82 | /// \ingroup audio 83 | /// 84 | /// This class allows users to write audio file formats not natively 85 | /// supported by SFML, and thus extend the set of supported writable 86 | /// audio formats. 87 | /// 88 | /// A valid sound file writer must override the open and write functions, 89 | /// as well as providing a static check function; the latter is used by 90 | /// SFML to find a suitable writer for a given filename. 91 | /// 92 | /// To register a new writer, use the sf::SoundFileFactory::registerWriter 93 | /// template function. 94 | /// 95 | /// Usage example: 96 | /// \code 97 | /// class MySoundFileWriter : public sf::SoundFileWriter 98 | /// { 99 | /// public: 100 | /// 101 | /// [[nodiscard]] static bool check(const std::filesystem::path& filename) 102 | /// { 103 | /// // typically, check the extension 104 | /// // return true if the writer can handle the format 105 | /// } 106 | /// 107 | /// [[nodiscard]] bool open(const std::filesystem::path& filename, unsigned int sampleRate, unsigned int channelCount) override 108 | /// { 109 | /// // open the file 'filename' for writing, 110 | /// // write the given sample rate and channel count to the file header 111 | /// // return true on success 112 | /// } 113 | /// 114 | /// void write(const sf::Int16* samples, sf::Uint64 count) override 115 | /// { 116 | /// // write 'count' samples stored at address 'samples', 117 | /// // convert them (for example to normalized float) if the format requires it 118 | /// } 119 | /// }; 120 | /// 121 | /// sf::SoundFileFactory::registerWriter(); 122 | /// \endcode 123 | /// 124 | /// \see sf::OutputSoundFile, sf::SoundFileFactory, sf::SoundFileReader 125 | /// 126 | //////////////////////////////////////////////////////////// 127 | -------------------------------------------------------------------------------- /include/SFML/Config.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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_CONFIG_HPP 26 | #define SFML_CONFIG_HPP 27 | 28 | 29 | //////////////////////////////////////////////////////////// 30 | // Headers 31 | //////////////////////////////////////////////////////////// 32 | #include 33 | 34 | 35 | //////////////////////////////////////////////////////////// 36 | // Define the SFML version 37 | //////////////////////////////////////////////////////////// 38 | #define SFML_VERSION_MAJOR 3 39 | #define SFML_VERSION_MINOR 0 40 | #define SFML_VERSION_PATCH 0 41 | #define SFML_VERSION_IS_RELEASE false 42 | 43 | 44 | //////////////////////////////////////////////////////////// 45 | // Identify the operating system 46 | // see https://sourceforge.net/p/predef/wiki/Home/ 47 | //////////////////////////////////////////////////////////// 48 | #if defined(_WIN32) 49 | 50 | // Windows 51 | #define SFML_SYSTEM_WINDOWS 52 | #ifndef NOMINMAX 53 | #define NOMINMAX 54 | #endif 55 | 56 | #elif defined(__APPLE__) && defined(__MACH__) 57 | 58 | // Apple platform, see which one it is 59 | #include "TargetConditionals.h" 60 | 61 | #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR 62 | 63 | // iOS 64 | #define SFML_SYSTEM_IOS 65 | 66 | #elif TARGET_OS_MAC 67 | 68 | // MacOS 69 | #define SFML_SYSTEM_MACOS 70 | 71 | #else 72 | 73 | // Unsupported Apple system 74 | #error This Apple operating system is not supported by SFML library 75 | 76 | #endif 77 | 78 | #elif defined(__unix__) 79 | 80 | // UNIX system, see which one it is 81 | #if defined(__ANDROID__) 82 | 83 | // Android 84 | #define SFML_SYSTEM_ANDROID 85 | 86 | #elif defined(__linux__) 87 | 88 | // Linux 89 | #define SFML_SYSTEM_LINUX 90 | 91 | #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) 92 | 93 | // FreeBSD 94 | #define SFML_SYSTEM_FREEBSD 95 | 96 | #elif defined(__OpenBSD__) 97 | 98 | // OpenBSD 99 | #define SFML_SYSTEM_OPENBSD 100 | 101 | #elif defined(__NetBSD__) 102 | 103 | // NetBSD 104 | #define SFML_SYSTEM_NETBSD 105 | 106 | #else 107 | 108 | // Unsupported UNIX system 109 | #error This UNIX operating system is not supported by SFML library 110 | 111 | #endif 112 | 113 | #else 114 | 115 | // Unsupported system 116 | #error This operating system is not supported by SFML library 117 | 118 | #endif 119 | 120 | 121 | //////////////////////////////////////////////////////////// 122 | // Define a portable debug macro 123 | //////////////////////////////////////////////////////////// 124 | #if !defined(NDEBUG) 125 | 126 | #define SFML_DEBUG 127 | 128 | #endif 129 | 130 | 131 | //////////////////////////////////////////////////////////// 132 | // Define helpers to create portable import / export macros for each module 133 | //////////////////////////////////////////////////////////// 134 | #if !defined(SFML_STATIC) 135 | 136 | #if defined(SFML_SYSTEM_WINDOWS) 137 | 138 | // Windows compilers need specific (and different) keywords for export and import 139 | #define SFML_API_EXPORT __declspec(dllexport) 140 | #define SFML_API_IMPORT __declspec(dllimport) 141 | 142 | // For Visual C++ compilers, we also need to turn off this annoying C4251 warning 143 | #ifdef _MSC_VER 144 | 145 | #pragma warning(disable: 4251) 146 | 147 | #endif 148 | 149 | #else // Linux, FreeBSD, Mac OS X 150 | 151 | #define SFML_API_EXPORT __attribute__ ((__visibility__ ("default"))) 152 | #define SFML_API_IMPORT __attribute__ ((__visibility__ ("default"))) 153 | 154 | #endif 155 | 156 | #else 157 | 158 | // Static build doesn't need import/export macros 159 | #define SFML_API_EXPORT 160 | #define SFML_API_IMPORT 161 | 162 | #endif 163 | 164 | 165 | //////////////////////////////////////////////////////////// 166 | // Define portable fixed-size types 167 | //////////////////////////////////////////////////////////// 168 | namespace sf 169 | { 170 | // 8 bits integer types 171 | using Int8 = std::int8_t; 172 | using Uint8 = std::uint8_t; 173 | 174 | // 16 bits integer types 175 | using Int16 = std::int16_t; 176 | using Uint16 = std::uint16_t; 177 | 178 | // 32 bits integer types 179 | using Int32 = std::int32_t; 180 | using Uint32 = std::uint32_t; 181 | 182 | // 64 bits integer types 183 | using Int64 = std::int64_t; 184 | using Uint64 = std::uint64_t; 185 | 186 | } // namespace sf 187 | 188 | 189 | #endif // SFML_CONFIG_HPP 190 | -------------------------------------------------------------------------------- /include/SFML/GpuPreference.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /include/SFML/Graphics.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /include/SFML/Graphics/CircleShape.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | std::size_t getPointCount() const override; 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 | Vector2f getPoint(std::size_t index) const override; 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 | -------------------------------------------------------------------------------- /include/SFML/Graphics/Color.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | constexpr Color::Color() : 28 | r(0), 29 | g(0), 30 | b(0), 31 | a(255) 32 | { 33 | 34 | } 35 | 36 | 37 | //////////////////////////////////////////////////////////// 38 | constexpr Color::Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha) : 39 | r(red), 40 | g(green), 41 | b(blue), 42 | a(alpha) 43 | { 44 | 45 | } 46 | 47 | 48 | //////////////////////////////////////////////////////////// 49 | constexpr Color::Color(Uint32 color) : 50 | r(static_cast((color & 0xff000000) >> 24)), 51 | g(static_cast((color & 0x00ff0000) >> 16)), 52 | b(static_cast((color & 0x0000ff00) >> 8)), 53 | a(static_cast(color & 0x000000ff)) 54 | { 55 | 56 | } 57 | 58 | 59 | //////////////////////////////////////////////////////////// 60 | constexpr Uint32 Color::toInteger() const 61 | { 62 | return static_cast((r << 24) | (g << 16) | (b << 8) | a); 63 | } 64 | 65 | 66 | //////////////////////////////////////////////////////////// 67 | constexpr bool operator ==(const Color& left, const Color& right) 68 | { 69 | return (left.r == right.r) && 70 | (left.g == right.g) && 71 | (left.b == right.b) && 72 | (left.a == right.a); 73 | } 74 | 75 | 76 | //////////////////////////////////////////////////////////// 77 | constexpr bool operator !=(const Color& left, const Color& right) 78 | { 79 | return !(left == right); 80 | } 81 | 82 | 83 | //////////////////////////////////////////////////////////// 84 | constexpr Color operator +(const Color& left, const Color& right) 85 | { 86 | const auto clampedAdd = [](Uint8 lhs, Uint8 rhs) -> Uint8 87 | { 88 | const int intResult = static_cast(lhs) + static_cast(rhs); 89 | return static_cast(intResult < 255 ? intResult : 255); 90 | }; 91 | 92 | return Color(clampedAdd(left.r, right.r), 93 | clampedAdd(left.g, right.g), 94 | clampedAdd(left.b, right.b), 95 | clampedAdd(left.a, right.a)); 96 | } 97 | 98 | 99 | //////////////////////////////////////////////////////////// 100 | constexpr Color operator -(const Color& left, const Color& right) 101 | { 102 | const auto clampedSub = [](Uint8 lhs, Uint8 rhs) -> Uint8 103 | { 104 | const int intResult = static_cast(lhs) - static_cast(rhs); 105 | return static_cast(intResult > 0 ? intResult : 0); 106 | }; 107 | 108 | return Color(clampedSub(left.r, right.r), 109 | clampedSub(left.g, right.g), 110 | clampedSub(left.b, right.b), 111 | clampedSub(left.a, right.a)); 112 | } 113 | 114 | 115 | //////////////////////////////////////////////////////////// 116 | constexpr Color operator *(const Color& left, const Color& right) 117 | { 118 | const auto scaledMul = [](Uint8 lhs, Uint8 rhs) -> Uint8 119 | { 120 | const auto uint16Result = static_cast(static_cast(lhs) * static_cast(rhs)); 121 | return static_cast(uint16Result / 255u); 122 | }; 123 | 124 | return Color(scaledMul(left.r, right.r), 125 | scaledMul(left.g, right.g), 126 | scaledMul(left.b, right.b), 127 | scaledMul(left.a, right.a)); 128 | } 129 | 130 | 131 | //////////////////////////////////////////////////////////// 132 | constexpr Color& operator +=(Color& left, const Color& right) 133 | { 134 | return left = left + right; 135 | } 136 | 137 | 138 | //////////////////////////////////////////////////////////// 139 | constexpr Color& operator -=(Color& left, const Color& right) 140 | { 141 | return left = left - right; 142 | } 143 | 144 | 145 | //////////////////////////////////////////////////////////// 146 | constexpr Color& operator *=(Color& left, const Color& right) 147 | { 148 | return left = left * right; 149 | } 150 | 151 | 152 | //////////////////////////////////////////////////////////// 153 | // Static member data 154 | //////////////////////////////////////////////////////////// 155 | 156 | // Note: the 'inline' keyword here is technically not required, but VS2019 fails 157 | // to compile with a bogus "multiple definition" error if not explicitly used. 158 | inline constexpr Color Color::Black(0, 0, 0); 159 | inline constexpr Color Color::White(255, 255, 255); 160 | inline constexpr Color Color::Red(255, 0, 0); 161 | inline constexpr Color Color::Green(0, 255, 0); 162 | inline constexpr Color Color::Blue(0, 0, 255); 163 | inline constexpr Color Color::Yellow(255, 255, 0); 164 | inline constexpr Color Color::Magenta(255, 0, 255); 165 | inline constexpr Color Color::Cyan(0, 255, 255); 166 | inline constexpr Color Color::Transparent(0, 0, 0, 0); 167 | -------------------------------------------------------------------------------- /include/SFML/Graphics/ConvexShape.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | std::size_t getPointCount() const override; 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 | Vector2f getPoint(std::size_t index) const override; 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 | -------------------------------------------------------------------------------- /include/SFML/Graphics/Drawable.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | 33 | 34 | namespace sf 35 | { 36 | class RenderTarget; 37 | class RenderStates; 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, const 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 | /// void draw(sf::RenderTarget& target, const sf::RenderStates& states) const override 104 | /// { 105 | /// // You can draw other high-level objects 106 | /// target.draw(m_sprite, states); 107 | /// 108 | /// // ... or use the low-level API 109 | /// sf::RenderStates statesCopy(states); 110 | /// statesCopy.texture = &m_texture; 111 | /// target.draw(m_vertices, statesCopy); 112 | /// 113 | /// // ... or draw with OpenGL directly 114 | /// glBegin(GL_TRIANGLES); 115 | /// ... 116 | /// glEnd(); 117 | /// } 118 | /// 119 | /// sf::Sprite m_sprite; 120 | /// sf::Texture m_texture; 121 | /// sf::VertexArray m_vertices; 122 | /// }; 123 | /// \endcode 124 | /// 125 | /// \see sf::RenderTarget 126 | /// 127 | //////////////////////////////////////////////////////////// 128 | -------------------------------------------------------------------------------- /include/SFML/Graphics/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /include/SFML/Graphics/Glsl.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /include/SFML/Graphics/Glyph.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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), lsbDelta(0), rsbDelta(0) {} 50 | 51 | //////////////////////////////////////////////////////////// 52 | // Member data 53 | //////////////////////////////////////////////////////////// 54 | float advance; //!< Offset to move horizontally to the next character 55 | int lsbDelta; //!< Left offset after forced autohint. Internally used by getKerning() 56 | int rsbDelta; //!< Right offset after forced autohint. Internally used by getKerning() 57 | FloatRect bounds; //!< Bounding rectangle of the glyph, in coordinates relative to the baseline 58 | IntRect textureRect; //!< Texture coordinates of the glyph inside the font's texture 59 | }; 60 | 61 | } // namespace sf 62 | 63 | 64 | #endif // SFML_GLYPH_HPP 65 | 66 | 67 | //////////////////////////////////////////////////////////// 68 | /// \class sf::Glyph 69 | /// \ingroup graphics 70 | /// 71 | /// A glyph is the visual representation of a character. 72 | /// 73 | /// The sf::Glyph structure provides the information needed 74 | /// to handle the glyph: 75 | /// \li its coordinates in the font's texture 76 | /// \li its bounding rectangle 77 | /// \li the offset to apply to get the starting position of the next glyph 78 | /// 79 | /// \see sf::Font 80 | /// 81 | //////////////////////////////////////////////////////////// 82 | -------------------------------------------------------------------------------- /include/SFML/Graphics/PrimitiveType.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | }; 48 | 49 | } // namespace sf 50 | 51 | 52 | #endif // SFML_PRIMITIVETYPE_HPP 53 | -------------------------------------------------------------------------------- /include/SFML/Graphics/Rect.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | constexpr Rect::Rect() : 29 | left (0), 30 | top (0), 31 | width (0), 32 | height(0) 33 | { 34 | 35 | } 36 | 37 | 38 | //////////////////////////////////////////////////////////// 39 | template 40 | constexpr Rect::Rect(const Vector2& position, const Vector2& size) : 41 | left (position.x), 42 | top (position.y), 43 | width (size.x), 44 | height(size.y) 45 | { 46 | 47 | } 48 | 49 | 50 | //////////////////////////////////////////////////////////// 51 | template 52 | template 53 | constexpr Rect::Rect(const Rect& rectangle) : 54 | left (static_cast(rectangle.left)), 55 | top (static_cast(rectangle.top)), 56 | width (static_cast(rectangle.width)), 57 | height(static_cast(rectangle.height)) 58 | { 59 | } 60 | 61 | 62 | //////////////////////////////////////////////////////////// 63 | template 64 | constexpr bool Rect::contains(const Vector2& point) const 65 | { 66 | // Not using 'std::min' and 'std::max' to avoid depending on '' 67 | const auto min = [](T a, T b){ return (a < b) ? a : b; }; 68 | const auto max = [](T a, T b){ return (a < b) ? b : a; }; 69 | 70 | // Rectangles with negative dimensions are allowed, so we must handle them correctly 71 | 72 | // Compute the real min and max of the rectangle on both axes 73 | const T minX = min(left, static_cast(left + width)); 74 | const T maxX = max(left, static_cast(left + width)); 75 | const T minY = min(top, static_cast(top + height)); 76 | const T maxY = max(top, static_cast(top + height)); 77 | 78 | return (point.x >= minX) && (point.x < maxX) && (point.y >= minY) && (point.y < maxY); 79 | } 80 | 81 | 82 | //////////////////////////////////////////////////////////// 83 | template 84 | constexpr std::optional> Rect::findIntersection(const Rect& rectangle) const 85 | { 86 | // Not using 'std::min' and 'std::max' to avoid depending on '' 87 | const auto min = [](T a, T b){ return (a < b) ? a : b; }; 88 | const auto max = [](T a, T b){ return (a < b) ? b : a; }; 89 | 90 | // Rectangles with negative dimensions are allowed, so we must handle them correctly 91 | 92 | // Compute the min and max of the first rectangle on both axes 93 | const T r1MinX = min(left, static_cast(left + width)); 94 | const T r1MaxX = max(left, static_cast(left + width)); 95 | const T r1MinY = min(top, static_cast(top + height)); 96 | const T r1MaxY = max(top, static_cast(top + height)); 97 | 98 | // Compute the min and max of the second rectangle on both axes 99 | const T r2MinX = min(rectangle.left, static_cast(rectangle.left + rectangle.width)); 100 | const T r2MaxX = max(rectangle.left, static_cast(rectangle.left + rectangle.width)); 101 | const T r2MinY = min(rectangle.top, static_cast(rectangle.top + rectangle.height)); 102 | const T r2MaxY = max(rectangle.top, static_cast(rectangle.top + rectangle.height)); 103 | 104 | // Compute the intersection boundaries 105 | const T interLeft = max(r1MinX, r2MinX); 106 | const T interTop = max(r1MinY, r2MinY); 107 | const T interRight = min(r1MaxX, r2MaxX); 108 | const T interBottom = min(r1MaxY, r2MaxY); 109 | 110 | // If the intersection is valid (positive non zero area), then there is an intersection 111 | if ((interLeft < interRight) && (interTop < interBottom)) 112 | { 113 | return Rect({interLeft, interTop}, {interRight - interLeft, interBottom - interTop}); 114 | } 115 | else 116 | { 117 | return std::nullopt; 118 | } 119 | } 120 | 121 | 122 | //////////////////////////////////////////////////////////// 123 | template 124 | constexpr Vector2 Rect::getPosition() const 125 | { 126 | return Vector2(left, top); 127 | } 128 | 129 | 130 | //////////////////////////////////////////////////////////// 131 | template 132 | constexpr Vector2 Rect::getSize() const 133 | { 134 | return Vector2(width, height); 135 | } 136 | 137 | 138 | //////////////////////////////////////////////////////////// 139 | template 140 | constexpr bool operator ==(const Rect& left, const Rect& right) 141 | { 142 | return (left.left == right.left) && (left.width == right.width) && 143 | (left.top == right.top) && (left.height == right.height); 144 | } 145 | 146 | 147 | //////////////////////////////////////////////////////////// 148 | template 149 | constexpr bool operator !=(const Rect& left, const Rect& right) 150 | { 151 | return !(left == right); 152 | } 153 | -------------------------------------------------------------------------------- /include/SFML/Graphics/RectangleShape.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | std::size_t getPointCount() const override; 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 | Vector2f getPoint(std::size_t index) const override; 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 | -------------------------------------------------------------------------------- /include/SFML/Graphics/Vertex.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | 34 | 35 | namespace sf 36 | { 37 | //////////////////////////////////////////////////////////// 38 | /// \brief Define a point with color and texture coordinates 39 | /// 40 | //////////////////////////////////////////////////////////// 41 | class Vertex 42 | { 43 | public: 44 | 45 | //////////////////////////////////////////////////////////// 46 | /// \brief Default constructor 47 | /// 48 | //////////////////////////////////////////////////////////// 49 | constexpr Vertex(); 50 | 51 | //////////////////////////////////////////////////////////// 52 | /// \brief Construct the vertex from its position 53 | /// 54 | /// The vertex color is white and texture coordinates are (0, 0). 55 | /// 56 | /// \param thePosition Vertex position 57 | /// 58 | //////////////////////////////////////////////////////////// 59 | constexpr Vertex(const Vector2f& thePosition); 60 | 61 | //////////////////////////////////////////////////////////// 62 | /// \brief Construct the vertex from its position and color 63 | /// 64 | /// The texture coordinates are (0, 0). 65 | /// 66 | /// \param thePosition Vertex position 67 | /// \param theColor Vertex color 68 | /// 69 | //////////////////////////////////////////////////////////// 70 | constexpr Vertex(const Vector2f& thePosition, const Color& theColor); 71 | 72 | //////////////////////////////////////////////////////////// 73 | /// \brief Construct the vertex from its position and texture coordinates 74 | /// 75 | /// The vertex color is white. 76 | /// 77 | /// \param thePosition Vertex position 78 | /// \param theTexCoords Vertex texture coordinates 79 | /// 80 | //////////////////////////////////////////////////////////// 81 | constexpr Vertex(const Vector2f& thePosition, const Vector2f& theTexCoords); 82 | 83 | //////////////////////////////////////////////////////////// 84 | /// \brief Construct the vertex from its position, color and texture coordinates 85 | /// 86 | /// \param thePosition Vertex position 87 | /// \param theColor Vertex color 88 | /// \param theTexCoords Vertex texture coordinates 89 | /// 90 | //////////////////////////////////////////////////////////// 91 | constexpr Vertex(const Vector2f& thePosition, const Color& theColor, const Vector2f& theTexCoords); 92 | 93 | //////////////////////////////////////////////////////////// 94 | // Member data 95 | //////////////////////////////////////////////////////////// 96 | Vector2f position; //!< 2D position of the vertex 97 | Color color; //!< Color of the vertex 98 | Vector2f texCoords; //!< Coordinates of the texture's pixel to map to the vertex 99 | }; 100 | 101 | #include 102 | 103 | } // namespace sf 104 | 105 | 106 | #endif // SFML_VERTEX_HPP 107 | 108 | 109 | //////////////////////////////////////////////////////////// 110 | /// \class sf::Vertex 111 | /// \ingroup graphics 112 | /// 113 | /// A vertex is an improved point. It has a position and other 114 | /// extra attributes that will be used for drawing: in SFML, 115 | /// vertices also have a color and a pair of texture coordinates. 116 | /// 117 | /// The vertex is the building block of drawing. Everything which 118 | /// is visible on screen is made of vertices. They are grouped 119 | /// as 2D primitives (lines, triangles, ...), and these primitives 120 | /// are grouped to create even more complex 2D entities such as 121 | /// sprites, texts, etc. 122 | /// 123 | /// If you use the graphical entities of SFML (sprite, text, shape) 124 | /// you won't have to deal with vertices directly. But if you want 125 | /// to define your own 2D entities, such as tiled maps or particle 126 | /// systems, using vertices will allow you to get maximum performances. 127 | /// 128 | /// Example: 129 | /// \code 130 | /// // define a 100x100 square, red, with a 10x10 texture mapped on it 131 | /// sf::Vertex vertices[] = 132 | /// { 133 | /// sf::Vertex(sf::Vector2f( 0, 0), sf::Color::Red, sf::Vector2f( 0, 0)), 134 | /// sf::Vertex(sf::Vector2f( 0, 100), sf::Color::Red, sf::Vector2f( 0, 10)), 135 | /// sf::Vertex(sf::Vector2f(100, 100), sf::Color::Red, sf::Vector2f(10, 10)), 136 | /// sf::Vertex(sf::Vector2f( 0, 0), sf::Color::Red, sf::Vector2f( 0, 0)), 137 | /// sf::Vertex(sf::Vector2f(100, 100), sf::Color::Red, sf::Vector2f(10, 10)), 138 | /// sf::Vertex(sf::Vector2f(100, 0), sf::Color::Red, sf::Vector2f(10, 0)) 139 | /// }; 140 | /// 141 | /// // draw it 142 | /// window.draw(vertices, 6, sf::Triangles); 143 | /// \endcode 144 | /// 145 | /// Note: although texture coordinates are supposed to be an integer 146 | /// amount of pixels, their type is float because of some buggy graphics 147 | /// drivers that are not able to process integer coordinates correctly. 148 | /// 149 | /// \see sf::VertexArray 150 | /// 151 | //////////////////////////////////////////////////////////// 152 | -------------------------------------------------------------------------------- /include/SFML/Graphics/Vertex.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | constexpr Vertex::Vertex() : 28 | position (0, 0), 29 | color (255, 255, 255), 30 | texCoords(0, 0) 31 | { 32 | } 33 | 34 | 35 | //////////////////////////////////////////////////////////// 36 | constexpr Vertex::Vertex(const Vector2f& thePosition) : 37 | position (thePosition), 38 | color (255, 255, 255), 39 | texCoords(0, 0) 40 | { 41 | } 42 | 43 | 44 | //////////////////////////////////////////////////////////// 45 | constexpr Vertex::Vertex(const Vector2f& thePosition, const Color& theColor) : 46 | position (thePosition), 47 | color (theColor), 48 | texCoords(0, 0) 49 | { 50 | } 51 | 52 | 53 | //////////////////////////////////////////////////////////// 54 | constexpr Vertex::Vertex(const Vector2f& thePosition, const Vector2f& theTexCoords) : 55 | position (thePosition), 56 | color (255, 255, 255), 57 | texCoords(theTexCoords) 58 | { 59 | } 60 | 61 | 62 | //////////////////////////////////////////////////////////// 63 | constexpr Vertex::Vertex(const Vector2f& thePosition, const Color& theColor, const Vector2f& theTexCoords) : 64 | position (thePosition), 65 | color (theColor), 66 | texCoords(theTexCoords) 67 | { 68 | } 69 | -------------------------------------------------------------------------------- /include/SFML/Main.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /include/SFML/Network.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /include/SFML/Network/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /include/SFML/Network/SocketHandle.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | using SocketHandle = UINT_PTR; 47 | 48 | #else 49 | 50 | using SocketHandle = int; 51 | 52 | #endif 53 | 54 | } // namespace sf 55 | 56 | 57 | #endif // SFML_SOCKETHANDLE_HPP 58 | -------------------------------------------------------------------------------- /include/SFML/Network/TcpListener.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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_TCPLISTENER_HPP 26 | #define SFML_TCPLISTENER_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | #include 34 | 35 | 36 | namespace sf 37 | { 38 | class TcpSocket; 39 | 40 | //////////////////////////////////////////////////////////// 41 | /// \brief Socket that listens to new TCP connections 42 | /// 43 | //////////////////////////////////////////////////////////// 44 | class SFML_NETWORK_API TcpListener : public Socket 45 | { 46 | public: 47 | 48 | //////////////////////////////////////////////////////////// 49 | /// \brief Default constructor 50 | /// 51 | //////////////////////////////////////////////////////////// 52 | TcpListener(); 53 | 54 | //////////////////////////////////////////////////////////// 55 | /// \brief Get the port to which the socket is bound locally 56 | /// 57 | /// If the socket is not listening to a port, this function 58 | /// returns 0. 59 | /// 60 | /// \return Port to which the socket is bound 61 | /// 62 | /// \see listen 63 | /// 64 | //////////////////////////////////////////////////////////// 65 | unsigned short getLocalPort() const; 66 | 67 | //////////////////////////////////////////////////////////// 68 | /// \brief Start listening for incoming connection attempts 69 | /// 70 | /// This function makes the socket start listening on the 71 | /// specified port, waiting for incoming connection attempts. 72 | /// 73 | /// If the socket is already listening on a port when this 74 | /// function is called, it will stop listening on the old 75 | /// port before starting to listen on the new port. 76 | /// 77 | /// When providing sf::Socket::AnyPort as port, the listener 78 | /// will request an available port from the system. 79 | /// The chosen port can be retrieved by calling getLocalPort(). 80 | /// 81 | /// \param port Port to listen on for incoming connection attempts 82 | /// \param address Address of the interface to listen on 83 | /// 84 | /// \return Status code 85 | /// 86 | /// \see accept, close 87 | /// 88 | //////////////////////////////////////////////////////////// 89 | [[nodiscard]] Status listen(unsigned short port, const IpAddress& address = IpAddress::Any); 90 | 91 | //////////////////////////////////////////////////////////// 92 | /// \brief Stop listening and close the socket 93 | /// 94 | /// This function gracefully stops the listener. If the 95 | /// socket is not listening, this function has no effect. 96 | /// 97 | /// \see listen 98 | /// 99 | //////////////////////////////////////////////////////////// 100 | void close(); 101 | 102 | //////////////////////////////////////////////////////////// 103 | /// \brief Accept a new connection 104 | /// 105 | /// If the socket is in blocking mode, this function will 106 | /// not return until a connection is actually received. 107 | /// 108 | /// \param socket Socket that will hold the new connection 109 | /// 110 | /// \return Status code 111 | /// 112 | /// \see listen 113 | /// 114 | //////////////////////////////////////////////////////////// 115 | [[nodiscard]] Status accept(TcpSocket& socket); 116 | }; 117 | 118 | 119 | } // namespace sf 120 | 121 | 122 | #endif // SFML_TCPLISTENER_HPP 123 | 124 | 125 | //////////////////////////////////////////////////////////// 126 | /// \class sf::TcpListener 127 | /// \ingroup network 128 | /// 129 | /// A listener socket is a special type of socket that listens to 130 | /// a given port and waits for connections on that port. 131 | /// This is all it can do. 132 | /// 133 | /// When a new connection is received, you must call accept and 134 | /// the listener returns a new instance of sf::TcpSocket that 135 | /// is properly initialized and can be used to communicate with 136 | /// the new client. 137 | /// 138 | /// Listener sockets are specific to the TCP protocol, 139 | /// UDP sockets are connectionless and can therefore communicate 140 | /// directly. As a consequence, a listener socket will always 141 | /// return the new connections as sf::TcpSocket instances. 142 | /// 143 | /// A listener is automatically closed on destruction, like all 144 | /// other types of socket. However if you want to stop listening 145 | /// before the socket is destroyed, you can call its close() 146 | /// function. 147 | /// 148 | /// Usage example: 149 | /// \code 150 | /// // Create a listener socket and make it wait for new 151 | /// // connections on port 55001 152 | /// sf::TcpListener listener; 153 | /// listener.listen(55001); 154 | /// 155 | /// // Endless loop that waits for new connections 156 | /// while (running) 157 | /// { 158 | /// sf::TcpSocket client; 159 | /// if (listener.accept(client) == sf::Socket::Done) 160 | /// { 161 | /// // A new client just connected! 162 | /// std::cout << "New connection received from " << client.getRemoteAddress() << std::endl; 163 | /// doSomethingWith(client); 164 | /// } 165 | /// } 166 | /// \endcode 167 | /// 168 | /// \see sf::TcpSocket, sf::Socket 169 | /// 170 | //////////////////////////////////////////////////////////// 171 | -------------------------------------------------------------------------------- /include/SFML/OpenGL.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | #ifndef WIN32_LEAN_AND_MEAN 44 | #define WIN32_LEAN_AND_MEAN 45 | #endif 46 | #include 47 | #endif 48 | 49 | #include 50 | 51 | #elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD) || defined(SFML_SYSTEM_NETBSD) 52 | 53 | #if defined(SFML_OPENGL_ES) 54 | #include 55 | #include 56 | #else 57 | #include 58 | #endif 59 | 60 | #elif defined(SFML_SYSTEM_MACOS) 61 | 62 | #include 63 | 64 | #elif defined (SFML_SYSTEM_IOS) 65 | 66 | #include 67 | #include 68 | 69 | #elif defined (SFML_SYSTEM_ANDROID) 70 | 71 | #include 72 | #include 73 | 74 | // We're not using OpenGL ES 2+ yet, but we can use the sRGB extension 75 | #include 76 | #include 77 | 78 | #endif 79 | 80 | 81 | #endif // SFML_OPENGL_HPP 82 | -------------------------------------------------------------------------------- /include/SFML/System.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | 46 | #endif // SFML_SYSTEM_HPP 47 | 48 | //////////////////////////////////////////////////////////// 49 | /// \defgroup system System module 50 | /// 51 | /// Base module of SFML, defining various utilities. It provides 52 | /// vector classes, Unicode strings and conversion functions, 53 | /// threads and mutexes, timing classes. 54 | /// 55 | //////////////////////////////////////////////////////////// 56 | -------------------------------------------------------------------------------- /include/SFML/System/Clock.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | #include 34 | #include 35 | 36 | #ifdef SFML_SYSTEM_ANDROID 37 | #include 38 | #endif 39 | 40 | 41 | namespace sf 42 | { 43 | namespace priv 44 | { 45 | 46 | //////////////////////////////////////////////////////////// 47 | /// \brief Chooses a monotonic clock of highest resolution 48 | /// 49 | /// The high_resolution_clock is usually an alias for other 50 | /// clocks: steady_clock or system_clock, whichever has a 51 | /// higher precision. 52 | /// 53 | /// sf::Clock, however, is aimed towards monotonic time 54 | /// measurements and so system_clock could never be a choice 55 | /// as its subject to discontinuous jumps in the system time 56 | /// (e.g., if the system administrator manually changes 57 | /// the clock), and by the incremental adjustments performed 58 | /// by `adjtime` and Network Time Protocol. On the other 59 | /// hand, monotonic clocks are unaffected by this behavior. 60 | /// 61 | /// Note: Linux implementation of a monotonic clock that 62 | /// takes sleep time into account is represented by 63 | /// CLOCK_BOOTTIME. Android devices can define the macro: 64 | /// SFML_ANDROID_USE_SUSPEND_AWARE_CLOCK to use a separate 65 | /// implementation of that clock, instead. 66 | /// 67 | /// For more information on Linux clocks visit: 68 | /// https://linux.die.net/man/2/clock_gettime 69 | /// 70 | //////////////////////////////////////////////////////////// 71 | #if defined(SFML_SYSTEM_ANDROID) && defined(SFML_ANDROID_USE_SUSPEND_AWARE_CLOCK) 72 | using MostSuitableClock = SuspendAwareClock; 73 | #else 74 | using MostSuitableClock = std::conditional_t< 75 | std::chrono::high_resolution_clock::is_steady, 76 | std::chrono::high_resolution_clock, 77 | std::chrono::steady_clock>; 78 | #endif 79 | 80 | } // namespace priv 81 | 82 | class Time; 83 | 84 | //////////////////////////////////////////////////////////// 85 | /// \brief Utility class that measures the elapsed time 86 | /// 87 | //////////////////////////////////////////////////////////// 88 | class SFML_SYSTEM_API Clock 89 | { 90 | public: 91 | 92 | //////////////////////////////////////////////////////////// 93 | /// \brief Default constructor 94 | /// 95 | /// The clock starts automatically after being constructed. 96 | /// 97 | //////////////////////////////////////////////////////////// 98 | Clock(); 99 | 100 | //////////////////////////////////////////////////////////// 101 | /// \brief Get the elapsed time 102 | /// 103 | /// This function returns the time elapsed since the last call 104 | /// to restart() (or the construction of the instance if restart() 105 | /// has not been called). 106 | /// 107 | /// \return Time elapsed 108 | /// 109 | //////////////////////////////////////////////////////////// 110 | Time getElapsedTime() const; 111 | 112 | //////////////////////////////////////////////////////////// 113 | /// \brief Restart the clock 114 | /// 115 | /// This function puts the time counter back to zero. 116 | /// It also returns the time elapsed since the clock was started. 117 | /// 118 | /// \return Time elapsed 119 | /// 120 | //////////////////////////////////////////////////////////// 121 | Time restart(); 122 | 123 | private: 124 | using ClockImpl = priv::MostSuitableClock; 125 | 126 | static_assert(ClockImpl::is_steady, 127 | "Provided implementation is not a monotonic clock"); 128 | static_assert(std::ratio_less_equal::value, 129 | "Clock resolution is too low. Expecting at least a microsecond precision"); 130 | 131 | //////////////////////////////////////////////////////////// 132 | /// \brief Convert clock duration to Time 133 | /// 134 | /// This function acts as a utility for converting clock 135 | /// duration type instance into sf::Time 136 | /// 137 | /// \return Time instance 138 | /// 139 | //////////////////////////////////////////////////////////// 140 | [[nodiscard]] static Time durationToTime(ClockImpl::duration duration); 141 | 142 | //////////////////////////////////////////////////////////// 143 | // Member data 144 | //////////////////////////////////////////////////////////// 145 | ClockImpl::time_point m_startTime; //!< Time of last reset 146 | }; 147 | 148 | } // namespace sf 149 | 150 | 151 | #endif // SFML_CLOCK_HPP 152 | 153 | 154 | //////////////////////////////////////////////////////////// 155 | /// \class sf::Clock 156 | /// \ingroup system 157 | /// 158 | /// sf::Clock is a lightweight class for measuring time. 159 | /// 160 | /// Its provides the most precise time that the underlying 161 | /// OS can achieve (generally microseconds or nanoseconds). 162 | /// It also ensures monotonicity, which means that the returned 163 | /// time can never go backward, even if the system time is 164 | /// changed. 165 | /// 166 | /// Usage example: 167 | /// \code 168 | /// sf::Clock clock; 169 | /// ... 170 | /// Time time1 = clock.getElapsedTime(); 171 | /// ... 172 | /// Time time2 = clock.restart(); 173 | /// \endcode 174 | /// 175 | /// The sf::Time value returned by the clock can then be 176 | /// converted to a number of seconds, milliseconds or even 177 | /// microseconds. 178 | /// 179 | /// \see sf::Time 180 | /// 181 | //////////////////////////////////////////////////////////// 182 | -------------------------------------------------------------------------------- /include/SFML/System/Err.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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(nullptr); 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 | -------------------------------------------------------------------------------- /include/SFML/System/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /include/SFML/System/InputStream.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | [[nodiscard]] 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 | [[nodiscard]] 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 | [[nodiscard]] 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(const std::string& archive); 121 | /// 122 | /// [[nodiscard]] bool open(const std::filesystem::path& filename); 123 | /// 124 | /// [[nodiscard]] Int64 read(void* data, Int64 size); 125 | /// 126 | /// [[nodiscard]] Int64 seek(Int64 position); 127 | /// 128 | /// [[nodiscard]] 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 | /// 141 | /// if (!stream.open("images/img.png")) 142 | /// { 143 | /// // Handle error... 144 | /// } 145 | /// 146 | /// if (!texture.loadFromStream(stream)) 147 | /// { 148 | /// // Handle error... 149 | /// } 150 | /// 151 | /// // musics... 152 | /// sf::Music music; 153 | /// ZipStream stream("resources.zip"); 154 | /// 155 | /// if (!stream.open("musics/msc.ogg")) 156 | /// { 157 | /// // Handle error... 158 | /// } 159 | /// 160 | /// if (!music.openFromStream(stream)) 161 | /// { 162 | /// // Handle error... 163 | /// } 164 | /// 165 | /// // etc. 166 | /// \endcode 167 | /// 168 | //////////////////////////////////////////////////////////// 169 | -------------------------------------------------------------------------------- /include/SFML/System/MemoryInputStream.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | [[nodiscard]] Int64 read(void* data, Int64 size) override; 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 | [[nodiscard]] Int64 seek(Int64 position) override; 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 | [[nodiscard]] Int64 tell() override; 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 | Int64 getSize() override; 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 | -------------------------------------------------------------------------------- /include/SFML/System/NativeActivity.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /include/SFML/System/Sleep.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | 33 | 34 | namespace sf 35 | { 36 | class Time; 37 | 38 | //////////////////////////////////////////////////////////// 39 | /// \ingroup system 40 | /// \brief Make the current thread sleep for a given duration 41 | /// 42 | /// sf::sleep is the best way to block a program or one of its 43 | /// threads, as it doesn't consume any CPU power. Compared to 44 | /// the standard std::this_thread::sleep_for function, this 45 | /// one provides more accurate sleeping time thanks to some 46 | /// platform-specific tweaks. 47 | /// 48 | /// \param duration Time to sleep 49 | /// 50 | //////////////////////////////////////////////////////////// 51 | void SFML_SYSTEM_API sleep(Time duration); 52 | 53 | } // namespace sf 54 | 55 | 56 | #endif // SFML_SLEEP_HPP 57 | -------------------------------------------------------------------------------- /include/SFML/System/String.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /include/SFML/System/SuspendAwareClock.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | #ifndef SFML_SUSPENDAWARECLOCK_HPP 27 | #define SFML_SUSPENDAWARECLOCK_HPP 28 | 29 | //////////////////////////////////////////////////////////// 30 | // Headers 31 | //////////////////////////////////////////////////////////// 32 | #include 33 | #include 34 | 35 | 36 | namespace sf 37 | { 38 | //////////////////////////////////////////////////////////// 39 | /// \brief Android, chrono-compatible, suspend-aware clock 40 | /// 41 | /// Linux steady clock is represented by CLOCK_MONOTONIC. 42 | /// However, this implementation does not work properly for 43 | /// long-running clocks that work in the background when the 44 | /// system is suspended. 45 | /// 46 | /// SuspendAwareClock uses CLOCK_BOOTTIME which is identical 47 | /// to CLOCK_MONOTONIC, except that it also includes any time 48 | /// that the system is suspended. 49 | /// 50 | /// Note: In most cases, CLOCK_MONOTONIC is a better choice. 51 | /// Make sure this implementation is required for your use case. 52 | /// 53 | //////////////////////////////////////////////////////////// 54 | class SFML_SYSTEM_API SuspendAwareClock 55 | { 56 | public: 57 | //////////////////////////////////////////////////////////// 58 | /// \brief Type traits and static members 59 | /// 60 | /// These type traits and static members meet the requirements 61 | /// of a Clock concept in the C++ Standard. More specifically, 62 | /// TrivialClock requirements are met. Thus, naming convention 63 | /// has been kept consistent to allow for extended use e.g. 64 | /// https://en.cppreference.com/w/cpp/chrono/is_clock 65 | /// 66 | //////////////////////////////////////////////////////////// 67 | using duration = std::chrono::nanoseconds; 68 | using rep = duration::rep; 69 | using period = duration::period; 70 | using time_point = std::chrono::time_point; 71 | 72 | static constexpr bool is_steady = true; 73 | 74 | static time_point now() noexcept; 75 | }; 76 | 77 | } // namespace sf 78 | 79 | #endif // SFML_SUSPENDAWARECLOCK_HPP 80 | -------------------------------------------------------------------------------- /include/SFML/System/Vector2.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | constexpr Vector2::Vector2() : 29 | x(0), 30 | y(0) 31 | { 32 | 33 | } 34 | 35 | 36 | //////////////////////////////////////////////////////////// 37 | template 38 | constexpr Vector2::Vector2(T X, T Y) : 39 | x(X), 40 | y(Y) 41 | { 42 | 43 | } 44 | 45 | 46 | //////////////////////////////////////////////////////////// 47 | template 48 | template 49 | constexpr 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 | constexpr Vector2 operator -(const Vector2& right) 59 | { 60 | return Vector2(-right.x, -right.y); 61 | } 62 | 63 | 64 | //////////////////////////////////////////////////////////// 65 | template 66 | constexpr 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 | constexpr 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 | constexpr 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 | constexpr 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 | constexpr Vector2 operator *(const Vector2& left, T right) 105 | { 106 | return Vector2(left.x * right, left.y * right); 107 | } 108 | 109 | 110 | //////////////////////////////////////////////////////////// 111 | template 112 | constexpr Vector2 operator *(T left, const Vector2& right) 113 | { 114 | return Vector2(right.x * left, right.y * left); 115 | } 116 | 117 | 118 | //////////////////////////////////////////////////////////// 119 | template 120 | constexpr 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 | constexpr Vector2 operator /(const Vector2& left, T right) 132 | { 133 | return Vector2(left.x / right, left.y / right); 134 | } 135 | 136 | 137 | //////////////////////////////////////////////////////////// 138 | template 139 | constexpr 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 | constexpr 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 | constexpr bool operator !=(const Vector2& left, const Vector2& right) 159 | { 160 | return (left.x != right.x) || (left.y != right.y); 161 | } 162 | -------------------------------------------------------------------------------- /include/SFML/System/Vector3.inl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | constexpr Vector3::Vector3() : 29 | x(0), 30 | y(0), 31 | z(0) 32 | { 33 | 34 | } 35 | 36 | 37 | //////////////////////////////////////////////////////////// 38 | template 39 | constexpr 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 | constexpr 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 | constexpr Vector3 operator -(const Vector3& left) 62 | { 63 | return Vector3(-left.x, -left.y, -left.z); 64 | } 65 | 66 | 67 | //////////////////////////////////////////////////////////// 68 | template 69 | constexpr 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 | constexpr 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 | constexpr 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 | constexpr 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 | constexpr 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 | constexpr 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 | constexpr 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 | constexpr 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 | constexpr 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 | constexpr 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 | constexpr 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 | -------------------------------------------------------------------------------- /include/SFML/Window.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /include/SFML/Window/Clipboard.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | 33 | 34 | namespace sf 35 | { 36 | class String; 37 | 38 | //////////////////////////////////////////////////////////// 39 | /// \brief Give access to the system clipboard 40 | /// 41 | //////////////////////////////////////////////////////////// 42 | class SFML_WINDOW_API Clipboard 43 | { 44 | public: 45 | 46 | //////////////////////////////////////////////////////////// 47 | /// \brief Get the content of the clipboard as string data 48 | /// 49 | /// This function returns the content of the clipboard 50 | /// as a string. If the clipboard does not contain string 51 | /// it returns an empty sf::String object. 52 | /// 53 | /// \return Clipboard contents as sf::String object 54 | /// 55 | //////////////////////////////////////////////////////////// 56 | static String getString(); 57 | 58 | //////////////////////////////////////////////////////////// 59 | /// \brief Set the content of the clipboard as string data 60 | /// 61 | /// This function sets the content of the clipboard as a 62 | /// string. 63 | /// 64 | /// \warning Due to limitations on some operating systems, 65 | /// setting the clipboard contents is only 66 | /// guaranteed to work if there is currently an 67 | /// open window for which events are being handled. 68 | /// 69 | /// \param text sf::String containing the data to be sent 70 | /// to the clipboard 71 | /// 72 | //////////////////////////////////////////////////////////// 73 | static void setString(const String& text); 74 | }; 75 | 76 | } // namespace sf 77 | 78 | 79 | #endif // SFML_CLIPBOARD_HPP 80 | 81 | 82 | //////////////////////////////////////////////////////////// 83 | /// \class sf::Clipboard 84 | /// \ingroup window 85 | /// 86 | /// sf::Clipboard provides an interface for getting and 87 | /// setting the contents of the system clipboard. 88 | /// 89 | /// It is important to note that due to limitations on some 90 | /// operating systems, setting the clipboard contents is 91 | /// only guaranteed to work if there is currently an open 92 | /// window for which events are being handled. 93 | /// 94 | /// Usage example: 95 | /// \code 96 | /// // get the clipboard content as a string 97 | /// sf::String string = sf::Clipboard::getString(); 98 | /// 99 | /// // or use it in the event loop 100 | /// sf::Event event; 101 | /// while(window.pollEvent(event)) 102 | /// { 103 | /// if(event.type == sf::Event::Closed) 104 | /// window.close(); 105 | /// if(event.type == sf::Event::KeyPressed) 106 | /// { 107 | /// // Using Ctrl + V to paste a string into SFML 108 | /// if(event.key.control && event.key.code == sf::Keyboard::V) 109 | /// string = sf::Clipboard::getString(); 110 | /// 111 | /// // Using Ctrl + C to copy a string out of SFML 112 | /// if(event.key.control && event.key.code == sf::Keyboard::C) 113 | /// sf::Clipboard::setString("Hello World!"); 114 | /// } 115 | /// } 116 | /// \endcode 117 | /// 118 | /// \see sf::String, sf::Event 119 | /// 120 | //////////////////////////////////////////////////////////// 121 | -------------------------------------------------------------------------------- /include/SFML/Window/Export.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /include/SFML/Window/GlResource.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | 33 | 34 | namespace sf 35 | { 36 | 37 | class Context; 38 | 39 | using ContextDestroyCallback = void (*)(void *); 40 | 41 | //////////////////////////////////////////////////////////// 42 | /// \brief Base class for classes that require an OpenGL context 43 | /// 44 | //////////////////////////////////////////////////////////// 45 | class SFML_WINDOW_API GlResource 46 | { 47 | protected: 48 | 49 | //////////////////////////////////////////////////////////// 50 | /// \brief Default constructor 51 | /// 52 | //////////////////////////////////////////////////////////// 53 | GlResource(); 54 | 55 | //////////////////////////////////////////////////////////// 56 | /// \brief Destructor 57 | /// 58 | //////////////////////////////////////////////////////////// 59 | ~GlResource(); 60 | 61 | //////////////////////////////////////////////////////////// 62 | /// \brief Register a function to be called when a context is destroyed 63 | /// 64 | /// This is used for internal purposes in order to properly 65 | /// clean up OpenGL resources that cannot be shared between 66 | /// contexts. 67 | /// 68 | /// \param callback Function to be called when a context is destroyed 69 | /// \param arg Argument to pass when calling the function 70 | /// 71 | //////////////////////////////////////////////////////////// 72 | static void registerContextDestroyCallback(ContextDestroyCallback callback, void* arg); 73 | 74 | //////////////////////////////////////////////////////////// 75 | /// \brief RAII helper class to temporarily lock an available context for use 76 | /// 77 | //////////////////////////////////////////////////////////// 78 | class SFML_WINDOW_API TransientContextLock 79 | { 80 | public: 81 | //////////////////////////////////////////////////////////// 82 | /// \brief Default constructor 83 | /// 84 | //////////////////////////////////////////////////////////// 85 | TransientContextLock(); 86 | 87 | //////////////////////////////////////////////////////////// 88 | /// \brief Destructor 89 | /// 90 | //////////////////////////////////////////////////////////// 91 | ~TransientContextLock(); 92 | 93 | //////////////////////////////////////////////////////////// 94 | /// \brief Deleted copy constructor 95 | /// 96 | //////////////////////////////////////////////////////////// 97 | TransientContextLock(const TransientContextLock&) = delete; 98 | 99 | //////////////////////////////////////////////////////////// 100 | /// \brief Deleted copy assignment 101 | /// 102 | //////////////////////////////////////////////////////////// 103 | TransientContextLock& operator=(const TransientContextLock&) = delete; 104 | }; 105 | }; 106 | 107 | } // namespace sf 108 | 109 | 110 | #endif // SFML_GLRESOURCE_HPP 111 | 112 | //////////////////////////////////////////////////////////// 113 | /// \class sf::GlResource 114 | /// \ingroup window 115 | /// 116 | /// This class is for internal use only, it must be the base 117 | /// of every class that requires a valid OpenGL context in 118 | /// order to work. 119 | /// 120 | //////////////////////////////////////////////////////////// 121 | -------------------------------------------------------------------------------- /include/SFML/Window/Sensor.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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_SENSOR_HPP 26 | #define SFML_SENSOR_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | 34 | 35 | namespace sf 36 | { 37 | //////////////////////////////////////////////////////////// 38 | /// \brief Give access to the real-time state of the sensors 39 | /// 40 | //////////////////////////////////////////////////////////// 41 | class SFML_WINDOW_API Sensor 42 | { 43 | public: 44 | 45 | //////////////////////////////////////////////////////////// 46 | /// \brief Sensor type 47 | /// 48 | //////////////////////////////////////////////////////////// 49 | enum Type 50 | { 51 | Accelerometer, //!< Measures the raw acceleration (m/s^2) 52 | Gyroscope, //!< Measures the raw rotation rates (degrees/s) 53 | Magnetometer, //!< Measures the ambient magnetic field (micro-teslas) 54 | Gravity, //!< Measures the direction and intensity of gravity, independent of device acceleration (m/s^2) 55 | UserAcceleration, //!< Measures the direction and intensity of device acceleration, independent of the gravity (m/s^2) 56 | Orientation, //!< Measures the absolute 3D orientation (degrees) 57 | 58 | Count //!< Keep last -- the total number of sensor types 59 | }; 60 | 61 | //////////////////////////////////////////////////////////// 62 | /// \brief Check if a sensor is available on the underlying platform 63 | /// 64 | /// \param sensor Sensor to check 65 | /// 66 | /// \return True if the sensor is available, false otherwise 67 | /// 68 | //////////////////////////////////////////////////////////// 69 | static bool isAvailable(Type sensor); 70 | 71 | //////////////////////////////////////////////////////////// 72 | /// \brief Enable or disable a sensor 73 | /// 74 | /// All sensors are disabled by default, to avoid consuming too 75 | /// much battery power. Once a sensor is enabled, it starts 76 | /// sending events of the corresponding type. 77 | /// 78 | /// This function does nothing if the sensor is unavailable. 79 | /// 80 | /// \param sensor Sensor to enable 81 | /// \param enabled True to enable, false to disable 82 | /// 83 | //////////////////////////////////////////////////////////// 84 | static void setEnabled(Type sensor, bool enabled); 85 | 86 | //////////////////////////////////////////////////////////// 87 | /// \brief Get the current sensor value 88 | /// 89 | /// \param sensor Sensor to read 90 | /// 91 | /// \return The current sensor value 92 | /// 93 | //////////////////////////////////////////////////////////// 94 | static Vector3f getValue(Type sensor); 95 | }; 96 | 97 | } // namespace sf 98 | 99 | 100 | #endif // SFML_SENSOR_HPP 101 | 102 | 103 | //////////////////////////////////////////////////////////// 104 | /// \class sf::Sensor 105 | /// \ingroup window 106 | /// 107 | /// sf::Sensor provides an interface to the state of the 108 | /// various sensors that a device provides. It only contains static 109 | /// functions, so it's not meant to be instantiated. 110 | /// 111 | /// This class allows users to query the sensors values at any 112 | /// time and directly, without having to deal with a window and 113 | /// its events. Compared to the SensorChanged event, sf::Sensor 114 | /// can retrieve the state of a sensor at any time (you don't need to 115 | /// store and update its current value on your side). 116 | /// 117 | /// Depending on the OS and hardware of the device (phone, tablet, ...), 118 | /// some sensor types may not be available. You should always check 119 | /// the availability of a sensor before trying to read it, with the 120 | /// sf::Sensor::isAvailable function. 121 | /// 122 | /// You may wonder why some sensor types look so similar, for example 123 | /// Accelerometer and Gravity / UserAcceleration. The first one 124 | /// is the raw measurement of the acceleration, and takes into account 125 | /// both the earth gravity and the user movement. The others are 126 | /// more precise: they provide these components separately, which is 127 | /// usually more useful. In fact they are not direct sensors, they 128 | /// are computed internally based on the raw acceleration and other sensors. 129 | /// This is exactly the same for Gyroscope vs Orientation. 130 | /// 131 | /// Because sensors consume a non-negligible amount of current, they are 132 | /// all disabled by default. You must call sf::Sensor::setEnabled for each 133 | /// sensor in which you are interested. 134 | /// 135 | /// Usage example: 136 | /// \code 137 | /// if (sf::Sensor::isAvailable(sf::Sensor::Gravity)) 138 | /// { 139 | /// // gravity sensor is available 140 | /// } 141 | /// 142 | /// // enable the gravity sensor 143 | /// sf::Sensor::setEnabled(sf::Sensor::Gravity, true); 144 | /// 145 | /// // get the current value of gravity 146 | /// sf::Vector3f gravity = sf::Sensor::getValue(sf::Sensor::Gravity); 147 | /// \endcode 148 | /// 149 | //////////////////////////////////////////////////////////// 150 | -------------------------------------------------------------------------------- /include/SFML/Window/Touch.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 WindowBase; 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 WindowBase& 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 | -------------------------------------------------------------------------------- /include/SFML/Window/Vulkan.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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_VULKAN_HPP 26 | #define SFML_VULKAN_HPP 27 | 28 | //////////////////////////////////////////////////////////// 29 | // Headers 30 | //////////////////////////////////////////////////////////// 31 | #include 32 | #include 33 | #include 34 | 35 | 36 | using VkInstance = struct VkInstance_T*; 37 | 38 | #if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) 39 | 40 | using VkSurfaceKHR = struct VkSurfaceKHR_T*; 41 | 42 | #else 43 | 44 | using VkSurfaceKHR = std::uint64_t; 45 | 46 | #endif 47 | 48 | struct VkAllocationCallbacks; 49 | 50 | 51 | namespace sf 52 | { 53 | 54 | using VulkanFunctionPointer = void (*)(); 55 | 56 | //////////////////////////////////////////////////////////// 57 | /// \brief Vulkan helper functions 58 | /// 59 | //////////////////////////////////////////////////////////// 60 | class SFML_WINDOW_API Vulkan 61 | { 62 | public: 63 | 64 | //////////////////////////////////////////////////////////// 65 | /// \brief Tell whether or not the system supports Vulkan 66 | /// 67 | /// This function should always be called before using 68 | /// the Vulkan features. If it returns false, then 69 | /// any attempt to use Vulkan will fail. 70 | /// 71 | /// If only compute is required, set \a requireGraphics 72 | /// to false to skip checking for the extensions necessary 73 | /// for graphics rendering. 74 | /// 75 | /// \param requireGraphics 76 | /// 77 | /// \return True if Vulkan is supported, false otherwise 78 | /// 79 | //////////////////////////////////////////////////////////// 80 | static bool isAvailable(bool requireGraphics = true); 81 | 82 | //////////////////////////////////////////////////////////// 83 | /// \brief Get the address of a Vulkan function 84 | /// 85 | /// \param name Name of the function to get the address of 86 | /// 87 | /// \return Address of the Vulkan function, 0 on failure 88 | /// 89 | //////////////////////////////////////////////////////////// 90 | static VulkanFunctionPointer getFunction(const char* name); 91 | 92 | //////////////////////////////////////////////////////////// 93 | /// \brief Get Vulkan instance extensions required for graphics 94 | /// 95 | /// \return Vulkan instance extensions required for graphics 96 | /// 97 | //////////////////////////////////////////////////////////// 98 | static const std::vector& getGraphicsRequiredInstanceExtensions(); 99 | }; 100 | 101 | } // namespace sf 102 | 103 | 104 | #endif // SFML_VULKAN_HPP 105 | 106 | 107 | //////////////////////////////////////////////////////////// 108 | /// \class sf::Vulkan 109 | /// \ingroup window 110 | /// 111 | /// 112 | /// 113 | //////////////////////////////////////////////////////////// 114 | -------------------------------------------------------------------------------- /include/SFML/Window/WindowHandle.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 type alias for 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 | using WindowHandle = HWND__ *; 44 | 45 | #elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) || defined(SFML_SYSTEM_OPENBSD) || defined(SFML_SYSTEM_NETBSD) 46 | 47 | // Window handle is Window (unsigned long) on Unix - X11 48 | using WindowHandle = unsigned long; 49 | 50 | #elif defined(SFML_SYSTEM_MACOS) 51 | 52 | // Window handle is NSWindow or NSView (void*) on Mac OS X - Cocoa 53 | using WindowHandle = void*; 54 | 55 | #elif defined(SFML_SYSTEM_IOS) 56 | 57 | // Window handle is UIWindow (void*) on iOS - UIKit 58 | using WindowHandle = void*; 59 | 60 | #elif defined(SFML_SYSTEM_ANDROID) 61 | 62 | // Window handle is ANativeWindow* (void*) on Android 63 | using WindowHandle = void*; 64 | 65 | #elif defined(SFML_DOXYGEN) 66 | 67 | // Define type alias symbol so that Doxygen can attach some documentation to it 68 | using WindowHandle = "platform-specific"; 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 | -------------------------------------------------------------------------------- /include/SFML/Window/WindowStyle.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////// 2 | // 3 | // SFML - Simple and Fast Multimedia Library 4 | // Copyright (C) 2007-2022 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 | -------------------------------------------------------------------------------- /libs/Debug/sfml-audio-s-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/Debug/sfml-audio-s-d.lib -------------------------------------------------------------------------------- /libs/Debug/sfml-graphics-s-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/Debug/sfml-graphics-s-d.lib -------------------------------------------------------------------------------- /libs/Debug/sfml-main-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/Debug/sfml-main-d.lib -------------------------------------------------------------------------------- /libs/Debug/sfml-network-s-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/Debug/sfml-network-s-d.lib -------------------------------------------------------------------------------- /libs/Debug/sfml-system-s-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/Debug/sfml-system-s-d.lib -------------------------------------------------------------------------------- /libs/Debug/sfml-window-s-d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/Debug/sfml-window-s-d.lib -------------------------------------------------------------------------------- /libs/PDB/sfml-audio-s-d.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/PDB/sfml-audio-s-d.pdb -------------------------------------------------------------------------------- /libs/PDB/sfml-audio-s.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/PDB/sfml-audio-s.pdb -------------------------------------------------------------------------------- /libs/PDB/sfml-graphics-s-d.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/PDB/sfml-graphics-s-d.pdb -------------------------------------------------------------------------------- /libs/PDB/sfml-graphics-s.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/PDB/sfml-graphics-s.pdb -------------------------------------------------------------------------------- /libs/PDB/sfml-main-d.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/PDB/sfml-main-d.pdb -------------------------------------------------------------------------------- /libs/PDB/sfml-main-s.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/PDB/sfml-main-s.pdb -------------------------------------------------------------------------------- /libs/PDB/sfml-network-s-d.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/PDB/sfml-network-s-d.pdb -------------------------------------------------------------------------------- /libs/PDB/sfml-network-s.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/PDB/sfml-network-s.pdb -------------------------------------------------------------------------------- /libs/PDB/sfml-system-s-d.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/PDB/sfml-system-s-d.pdb -------------------------------------------------------------------------------- /libs/PDB/sfml-system-s.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/PDB/sfml-system-s.pdb -------------------------------------------------------------------------------- /libs/PDB/sfml-window-s-d.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/PDB/sfml-window-s-d.pdb -------------------------------------------------------------------------------- /libs/PDB/sfml-window-s.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/PDB/sfml-window-s.pdb -------------------------------------------------------------------------------- /libs/Release/sfml-audio-s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/Release/sfml-audio-s.lib -------------------------------------------------------------------------------- /libs/Release/sfml-graphics-s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/Release/sfml-graphics-s.lib -------------------------------------------------------------------------------- /libs/Release/sfml-main.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/Release/sfml-main.lib -------------------------------------------------------------------------------- /libs/Release/sfml-network-s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/Release/sfml-network-s.lib -------------------------------------------------------------------------------- /libs/Release/sfml-system-s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/Release/sfml-system-s.lib -------------------------------------------------------------------------------- /libs/Release/sfml-window-s.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/Release/sfml-window-s.lib -------------------------------------------------------------------------------- /libs/extlibs/flac.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/extlibs/flac.lib -------------------------------------------------------------------------------- /libs/extlibs/freetype.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/extlibs/freetype.lib -------------------------------------------------------------------------------- /libs/extlibs/ogg.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/extlibs/ogg.lib -------------------------------------------------------------------------------- /libs/extlibs/openal32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/extlibs/openal32.lib -------------------------------------------------------------------------------- /libs/extlibs/vorbis.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/extlibs/vorbis.lib -------------------------------------------------------------------------------- /libs/extlibs/vorbisenc.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/extlibs/vorbisenc.lib -------------------------------------------------------------------------------- /libs/extlibs/vorbisfile.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/libs/extlibs/vorbisfile.lib -------------------------------------------------------------------------------- /premake5.lua: -------------------------------------------------------------------------------- 1 | -- premake5.lua 2 | workspace "Collision with SAT" 3 | startproject "SAT" 4 | architecture "x64" 5 | configurations { 6 | "Debug", 7 | "Release" 8 | } 9 | 10 | filter { "platforms:Win64" } 11 | system "Windows" 12 | 13 | include "SAT" -------------------------------------------------------------------------------- /vendor/license.readme: -------------------------------------------------------------------------------- 1 | Copyright (c) 2003-2019 Jason Perkins and individual contributors. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | 3. Neither the name of Premake nor the names of its contributors may be 15 | used to endorse or promote products derived from this software without 16 | specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /vendor/premake5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xSnapi/SAT-Collision/49eab4e6d67f74ba7e48d713e622bf3b915f58d4/vendor/premake5.exe --------------------------------------------------------------------------------