222 Commits
Author SHA1 Message Date
Lukas Dürrenberger 904c98b058 Fix text creation in main page example 2026-10-04 22:12:01 +02:00
Lukas Dürrenberger fe8c6adb12 Add sfSftp as a secure replacement for sfFtp 2026-10-04 22:12:01 +02:00
Lukas Dürrenberger 63dc503d20 Add sfTimeoutWithPredicate 2026-10-04 22:12:01 +02:00
Lukas Dürrenberger 8208e90599 Add HTTPS verification and address type options to sfHttp 2026-10-04 22:12:01 +02:00
Lukas Dürrenberger af34a2890e Add readiness types and callbacks to sfSocketSelector 2026-10-04 22:12:01 +02:00
Lukas Dürrenberger d95f00f212 Add transport layer security to TCP sockets 2026-10-04 22:12:01 +02:00
Lukas Dürrenberger 917e811888 Add IPv6 support and sfDns
- Grow sfIpAddress to hold IPv6 addresses and add address types

- Make sfIpAddress_fromString not resolve network names anymore, matching sf::IpAddress::fromString, and add the deprecated sfIpAddress_resolve

- Add sfDns for resolving hostnames and querying NS, MX, SRV and TXT records
2026-10-04 22:12:01 +02:00
Lukas Dürrenberger 523c48cf98 Add sfPlaybackDevice to manage the audio playback device 2026-10-04 22:11:58 +02:00
Lukas Dürrenberger b4220b39ff Document QOI support for images 2026-10-04 22:10:41 +02:00
Lukas Dürrenberger e38e58c835 Add text shaping, alignment and orientation API 2026-10-04 22:10:41 +02:00
Lukas Dürrenberger 6d7cc360a1 Add font ascent, descent, glyph by ID and new font info 2026-10-04 22:10:41 +02:00
Lukas Dürrenberger a4c9ecec57 Add miter limit functions to all shapes 2026-10-04 22:10:41 +02:00
Lukas Dürrenberger a08585812d Add sfGetVersion to retrieve the runtime SFML version 2026-10-04 22:10:41 +02:00
Lukas Dürrenberger 0a4871cfbe Mark C functions of deprecated SFML APIs as deprecated
The deprecated functions remain available, matching SFML. Font kerning now calls the char32_t overload, since the std::uint32_t one is deprecated.
2026-10-04 22:10:41 +02:00
Lukas Dürrenberger 13935af42b Update to SFML 3.1.0
- Require CMake 3.28 to match SFML

- Install HarfBuzz, MbedTLS and libssh2 for Linux CI builds

- Bump CSFML and NuGet package version to 3.1.0
2026-10-04 22:10:41 +02:00
Lukas Dürrenberger 58d0990004 Resolve remaining zizmor findings in our workflows
- Pass matrix values and the workspace path to run steps through env
- Use bash as default shell for the release builds
- Drop the MinGW cache from the release builds to avoid cache poisoning
2026-10-04 21:46:35 +02:00
Lukas Dürrenberger fdef4c8747 Disable ClangCL CI jobs and pin clang-tidy to LLVM 18 2026-10-04 13:40:15 +02:00
Lukas Dürrenberger bad0295fb9 Harden our GitHub Actions workflows 2026-10-04 13:40:15 +02:00
Lukas Dürrenberger 9fe9c109af Update GitHub runner images and Actions versions
The new Windows runner images ship Visual Studio 2026, which requires CMake 4.2 or later.
2026-10-04 13:40:15 +02:00
Lukas Dürrenberger 24c8ddb1b5 Update version for the NuGet packages to 3.0.0
- Update State of Development
- Update release build references
2026-01-13 16:50:15 +01:00
Lukas Dürrenberger e6dfa35cfa Update GitHub Action images and actions 2026-01-13 16:50:15 +01:00
Lukas Dürrenberger e3cbd1e4c3 Update copyright year to 2026 2026-01-13 16:50:15 +01:00
Lukas Dürrenberger 7b9c1038cd Update SFML version to 3.0.2 2025-09-28 22:28:21 +02:00
Lukas Dürrenberger 603122a631 Update NuGet package version 2025-09-04 09:20:56 +02:00
Lukas Dürrenberger 2587099cd2 Package runtime DLLs for NuGet 2025-09-03 21:05:51 +02:00
JupiterRider 21bbf464b1 update copyright year to 2025 2025-09-03 08:44:16 +02:00
Lukas Dürrenberger a800f76d5e Split texture's resize function into sRGB and non-sRGB 2025-08-31 17:26:12 +02:00
Lukas Dürrenberger 08b22ee975 Remove fedora-x64 as NuGet target, as linux-x64 is preferred now 2025-08-29 16:10:50 +02:00
Lukas Dürrenberger 36ae53cde7 Run NuGet CI builds for any tag 2025-08-29 16:10:50 +02:00
Lukas Dürrenberger b23b723d83 Use our own dependencies for SFML in the CSFML NuGet 2025-08-29 13:32:23 +02:00
Lukas Dürrenberger 44974fe4e9 Update action to run under ARM 2025-08-29 13:32:23 +02:00
Lukas Dürrenberger 0abdaf8a0c Ignore enum class clang-tidy rule 2025-08-29 13:32:23 +02:00
Lukas Dürrenberger 46b72141d1 Add support for Windows ARM64 architecture 2025-08-29 13:32:23 +02:00
Lukas Dürrenberger 973c742602 Update WinLibs MinGW version 2025-08-29 13:32:23 +02:00
Lukas Dürrenberger 1428c23b6a Update SFML version used in CI scripts 2025-08-29 13:32:23 +02:00
Lukas Dürrenberger c5cfb7f878 Update to windows-2025 images 2025-08-29 13:32:23 +02:00
Lukas Dürrenberger 8ca866fbc7 Fix formatting of CI files 2025-08-29 13:32:23 +02:00
Chris Thrasher 5f25bee831 Improve readability of CI commands 2025-06-09 14:03:18 +02:00
Chris Thrasher eba1735c84 Add tests for sfImage 2025-06-08 22:38:53 -06:00
Shane Whitmire 8f44a6f424 Implement resize for Texture 2025-06-08 22:03:49 -06:00
Lukas Dürrenberger e39a0b1ab8 Add missing setMinimumSize and setMaximumSize window methods 2025-06-01 12:12:53 -06:00
Chris Thrasher aa236c2207 Remove VS2019 CI jobs 2025-06-01 12:12:43 -06:00
Chris Thrasher 17039984c5 Test with oldest possible CMake version 2025-06-01 11:20:59 -06:00
James Cowgill f1e6cccb56 Avoid doing a real name resolution in sfIpAddress_fromString test
On some PCs, resolving `invalid address` will perform a real name
resolution using the network. This is slows down the test and risks
the test failing if the resolution succeeds.

Use `localhost` instead which shold return a known value, and add an
invalid ip address test for good measure.
2025-02-16 10:23:08 -07:00
Lukas Dürrenberger 82884b379f Add ReadMe to the NuGet package project 2025-01-23 21:29:32 +00:00
Lukas Dürrenberger 2ca3a852cf Build shared libraries on Windows 2025-01-22 12:57:05 +00:00
Lukas Dürrenberger 06dd3bc9b8 Update release builds for SFML 3 2025-01-22 12:57:05 +00:00
Lukas Dürrenberger 862ab6a449 Remove extlibs references that are no longer needed 2025-01-15 07:31:55 +00:00
Lukas Dürrenberger 9329dd8b60 Update GitHub Actions 2025-01-15 07:31:55 +00:00
Lukas Dürrenberger c9bcd69cb7 Merge branch '2.6.x' into master 2025-01-14 14:44:13 +00:00
Miron Alexandru 58cd82b532 Update Network module code 2025-01-12 21:19:21 -07:00
Lukas Dürrenberger a7b113ac5b Merge branch '2.6.x' into master 2025-01-08 15:16:46 +01:00
Lukas Dürrenberger 72c1979aed Correct macOS rpath reference for vorbisenc 2025-01-08 14:04:00 +00:00
Lukas Dürrenberger 4f75550692 Update macOS image version for CI 2025-01-08 14:04:00 +00:00
Chris Thrasher 2adc2db065 Fix grammar 2025-01-01 11:32:59 -07:00
Chris Thrasher b607308b3f Add tests for sfShape 2024-12-24 11:29:54 -06:00
Chris Thrasher e37de74852 Remove leftover comment 2024-12-24 11:29:54 -06:00
Chris Thrasher 96d41a2459 Add tests for sfPrimitiveType 2024-12-24 11:29:54 -06:00
Chris Thrasher 112abc1ab7 Add tests for sfView 2024-12-24 11:29:54 -06:00
Chris Thrasher b0b4d253d2 Add tests for sfVertexArray 2024-12-24 11:29:54 -06:00
Chris Thrasher 82d0ff2012 Add missing Freetype dependency 2024-12-23 22:33:59 -06:00
Chris Thrasher 589b86d4c0 Fix const correctness issues 2024-12-23 16:17:45 -06:00
Chris Thrasher feb431a689 Add tests for sfRenderStates 2024-12-23 10:31:53 -06:00
Chris Thrasher f6949a5a06 Add tests for sfTransform 2024-12-23 10:31:53 -06:00
Chris Thrasher ed185c838d Add tests for sfStencilMode 2024-12-23 10:31:53 -06:00
Chris Thrasher ab1a1a2299 Add tests for sfCoordinateType 2024-12-22 17:28:57 -06:00
Chris Thrasher bb8a261bb8 Add tests for sfColor 2024-12-22 17:28:57 -06:00
Chris Thrasher b3e6e23ffd Add tests for sfBlendMode 2024-12-22 17:28:57 -06:00
Chris Thrasher e46663cf38 Add tests for sfRect 2024-12-22 17:28:57 -06:00
Chris Thrasher e7a41e864f Add tests for Audio module 2024-12-22 17:05:49 -06:00
Chris Thrasher ae540e2396 Fix README typo 2024-12-22 14:58:58 -06:00
Chris Thrasher 14e06ccea4 Centrally define SFML version 2024-12-21 20:38:26 -06:00
Chris Thrasher a185b440ef Use SFML 3.0.0 tag 2024-12-21 19:08:15 -06:00
Chris Thrasher 14378de263 Upgrade to clang-format-17 2024-11-01 15:03:09 -06:00
Lukas Dürrenberger 1fa7f3caec Add GitHub Sponsors and OpenCollective buttons 2024-10-10 19:30:35 +02:00
ZXShady b99a455873 Match parameter types with SFML types 2024-10-07 18:48:53 -06:00
Chris Thrasher d1708cbd65 Remove unused headers 2024-10-06 23:20:54 +02:00
Chris Thrasher a14d4322ac Remove references to sf:: types in public documentation 2024-10-06 23:20:19 +02:00
Chris Thrasher 5385f329c6 Clean up IpAddress implementation 2024-10-06 14:22:41 -06:00
Miron Alexandru fd8e6a0364 Align sfRenderStates with sf::RenderStates 2024-10-06 13:25:05 -06:00
ZXShady 884dcde3c3 Make enumeration counts constant expressions
This change allows now having these variables as array sizes that
are not Variable Length Arrays like in structs for example.

To note however that this changes the type from unsigned int to an
implementation defined type which usually `int` which is signed and
not unsigned.
2024-10-04 09:05:55 -06:00
ZXShady cc92ca36b7 Pass by reference if it is never null
sfEvent was not checked for null and was assumed to be non null in convertEvent so I made it a reference to reflect that
2024-10-03 10:42:15 -06:00
ZXShady 556ca510d4 Make ConvertEvent.hpp file in window module folder.
It is a window related module it makes more sense imo for it to be in it.

I also addded it to the cmake file so it appears in VIsual Studio
2024-10-03 10:33:51 -06:00
ZXShady 66e7af4993 check malloc return value for NULL and update docs
`sfFtpDirectoryResponse_getDirectory` can fail and return NULL becuase 'strdup' returns null on failure but `sfFtpDirectoryResponse_getDirectoryUnicode` didn't and just had UB due not checking return value of malloc.

typing NULL in the docs made me age 30 years btw
2024-09-29 11:51:53 -06:00
Chris Thrasher 6ce8f95553 Remove unnecessary static_casts 2024-09-28 21:20:14 -06:00
ZXShady b626f65ee5 Cast to larger type before doing arithmetic to avoid signed integer overflow
https://godbolt.org/z/soTad4zEq

this godbolt links shows that it is UB to multiply then cast if the amount is large enough
2024-09-28 19:45:28 -06:00
ZXShady f297287951 make static varaibles const via lamdbas
this pr also makes `sfSoundRecorder_getAvailableDevices` return a const pointer to a const char pointer so you can no longer modify where the pointers of the strings are pointing into becuase it doesn't make sense.
2024-09-28 19:21:25 -06:00
ZXShady ef81fbd337 use aggregate initialization 2024-09-27 18:42:48 -06:00
ZXShady 84f580e207 remove cstyle default init 2024-09-27 17:57:02 -06:00
ZXShady 4c818c31ed make sfTime const global variable 2024-09-27 15:11:41 -06:00
ZXShady 82e4518e93 remove unnecessary boolean comparson != 0 2024-09-27 14:41:21 -06:00
Chris Thrasher b8860362a3 Remove reference to C++ standard library 2024-09-27 14:19:37 -06:00
Chris Thrasher 37e78942ed Use functions from the C++ standard library 2024-09-27 14:19:37 -06:00
Chris Thrasher c74378bade Update enumerations to match SFML 3 2024-09-27 13:24:31 -06:00
Chris Thrasher fef1e09542 Prefix library options with CSFML_ 2024-09-24 15:08:30 -06:00
Chris Thrasher 1b082ac255 Simplify shader creation functions 2024-09-24 15:08:17 -06:00
Chris Thrasher 7b583b1aac Use inheritance to remove This data member
It's reasonable to say that, for example, sfImage _is_ an sf::Image.
This "is-a" relationship is what inheritance does a very good job
modeling. By using inheritance to implement CSFML types in terms of
their SFML counterpart, we get code that is simpler and easier to
read. We also avoid some of the extra "dancing" required to construct
a CSFML type from an SFML type. This improves the encapsulation of
our CSFML implementation.
2024-09-24 11:05:19 -06:00
Miron Alexandru 8113ed23b9 Implement new audio functions 2024-09-23 14:26:43 -06:00
Miron Alexandru eb0f2974ab Implement new graphics, system and window functions 2024-09-23 11:16:06 -06:00
ZXShady 70397c6131 make sfRenderStates_default an extern const variable 2024-09-20 18:28:20 -05:00
Chris Thrasher 4ef89bb387 Implement new sf::Clock functions 2024-09-20 17:08:32 -05:00
Chris Thrasher fbe6e6193f Implement getGeometricCenter 2024-09-20 16:29:34 -05:00
Chris Thrasher 77b3035308 Manually inline sfShapeImpl 2024-09-20 15:55:10 -05:00
Chris Thrasher 17f7982215 Remove unnecessary constructors 2024-09-18 11:59:18 -04:00
ZXShady 5275e589f5 add missing asserts in Font.cpp 2024-09-18 11:32:03 -04:00
Chris Thrasher 5b910f8761 Remove all delete calls outside of _destroy functions 2024-09-18 11:30:12 -04:00
ZXShady ac477cf8b2 fix clang tidy warning about reserved identifier in WindowHandle.h 2024-09-18 11:24:01 -04:00
ZXShady 082a90ec4f use unique_ptr to handle memory of sfTexture 2024-09-18 10:52:21 -04:00
Chris Thrasher 3826091357 Assert against arguments which would invoke UB 2024-09-17 18:34:06 -04:00
Chris Thrasher d26c691458 Assert string arguments are not null
For these functions, providing a null pointer argument would result
in invoking undefined behavior.
2024-09-16 21:52:54 -04:00
Chris Thrasher 21d4571d5b Assert that filepath strings are not null 2024-09-16 13:39:12 -04:00
Chris Thrasher 9765e30e2f Assert that shader uniform names are not null 2024-09-12 17:17:31 -06:00
Chris Thrasher 2638160548 Use standard CMake variables for Doxygen paths 2024-09-12 12:35:12 -06:00
Chris Thrasher b229329d31 Simplify how Doxygen CMake variables are set 2024-09-12 12:35:12 -06:00
Chris Thrasher 7182877105 Improve phrasing in docs 2024-09-12 12:35:12 -06:00
Chris Thrasher 360268ea39 Improve const correctness 2024-09-12 10:08:46 -06:00
Chris Thrasher 7f5807a6b5 Fix Doxygen warnings 2024-09-11 22:19:10 -06:00
Chris Thrasher 63beea6043 Add Doxygen CI job 2024-09-11 21:54:22 -06:00
Chris Thrasher 290e43ff66 Match return types with underlying SFML interface 2024-09-11 17:19:31 -06:00
Chris Thrasher 8cf074444f Stop using deprecated DOXYGEN_EXECUTABLE variable
This was deprecated in CMake 3.9.

See https://cmake.org/cmake/help/v3.22/module/FindDoxygen.html#variable:DOXYGEN_EXECUTABLE
2024-09-11 17:06:44 -06:00
Chris Thrasher a430c713e3 Remove redundant definition
This is already inherited as a usage requirement when linking to
SFML's CMake targets.
2024-09-11 16:17:14 -06:00
Chris Thrasher 574c6afe05 Use ON and OFF for CMake booleans 2024-09-11 14:36:23 -06:00
Lukas Dürrenberger 33fca5fd5d Fix NuGet build for master 2024-09-10 09:41:34 -06:00
Chris Thrasher 53bd3517db Update to new anti-aliasing naming 2024-09-09 23:42:05 -06:00
Chris Thrasher b05b1f1997 Add tests for sfContextAttribute 2024-09-08 12:08:43 -06:00
Chris Thrasher 8cc7537899 Add missing window state parameters 2024-09-08 10:45:11 -06:00
Chris Thrasher d971aada83 Add more tests for the Window module 2024-09-08 09:56:31 -06:00
Chris Thrasher 02d6d4937a Use modern CMake property to handle static runtime linking with MSVC
See https://github.com/SFML/SFML/pull/1834
2024-09-08 08:49:13 -06:00
Chris Thrasher b662349832 Enforce variable and parameter casing style 2024-09-07 21:26:36 -06:00
Chris Thrasher 055e69520f Support building CSFML as static libraries
Some languages can make use of C foreign function interfaces
compiled as static libraries so it's a good idea for CSFML to
support this use case.
2024-09-07 15:17:05 -06:00
Chris Thrasher e963079712 Remove unnecessary .gitignore entries 2024-09-07 09:45:13 -06:00
Chris Thrasher 5d158dbed6 Revert "Remove unnecessary extern from C function declarations"
This reverts commit dfaebc6b88.
2024-09-05 15:03:56 -06:00
Chris Thrasher e336d9fb77 Add missing sf prefix
This function pointer is within the `sf::` namespace of SFML so it
ought to have an `sf` prefix in CSFML.
2024-09-05 14:21:42 -06:00
Chris Thrasher 2d88625f4e Update copyright year 2024-09-05 14:06:13 -06:00
Chris Thrasher 34f95771d8 Move copyToChar32 to the one file where it's used 2024-09-05 13:41:26 -06:00
Chris Thrasher d50ff75b44 Use project-local CMake variables 2024-09-05 13:13:48 -06:00
Chris Thrasher 87289d57ea Use parentheses for constructor calls 2024-09-05 12:47:44 -06:00
Chris Thrasher b5e3cb6122 Clarify instructions for building CSFML 2024-09-04 16:17:56 -06:00
Chris Thrasher 53c364deec Copy SFML DLLs alongside test executables 2024-09-03 18:09:35 -06:00
Chris Thrasher 431c9641ea Add myself to authors list 2024-09-03 16:58:18 -06:00
Chris Thrasher fb9fb941b4 Add missing sfSoundBufferRecorder functions inherited from sf::SoundRecorder
Backport of 34febc214f
2024-09-03 16:49:38 -06:00
Chris Thrasher a9108a2e77 Document the current state of development 2024-09-03 16:44:32 -06:00
Chris Thrasher 1a95bf0807 Use more [[nodiscard]] 2024-09-03 14:45:19 -06:00
Chris Thrasher 4d23a89918 Add clang-tidy cppcoreguidelines-* checks 2024-09-03 12:15:01 -06:00
Chris Thrasher cc1b6f0c45 Ensure CMake options include CSFML_ prefix 2024-09-03 10:44:50 -06:00
Chris Thrasher 34febc214f Add missing sfSoundBufferRecorder functions inherited from sf::SoundRecorder 2024-09-03 09:38:22 -06:00
mgrojo cd778ff82f Documentation: Fix last value of index range in FTP listing response
- Wording and notation consistent with `sf*Shape_{g,s}etPoint()`
- Related case fix in `sfConvexShape_setPoint`
2024-09-02 21:38:02 -06:00
Chris Thrasher 725b00e6ae Simplify FTP types 2024-09-02 21:18:31 -06:00
Chris Thrasher 6035a5fa5a Use SFML_ROOT to find SFML installation
This is line with modern CMake convention where -D<PackageName>_ROOT
is used to locate a given package's installation.

https://cmake.org/cmake/help/latest/variable/PackageName_ROOT.html#variable:%3CPackageName%3E_ROOT
2024-09-02 21:03:54 -06:00
Chris Thrasher f9e67732e2 Put common configuration settings in a CMakePresets file 2024-09-02 20:48:16 -06:00
Chris Thrasher 9750455b76 Remove leading newlines 2024-09-02 20:47:35 -06:00
Chris Thrasher 479554024d Add tests for sfHttp 2024-09-02 20:04:06 -06:00
Chris Thrasher b5dc20260c Add tests for sfFtp 2024-09-02 20:04:06 -06:00
Chris Thrasher 10aaee1290 Add tests for sfSocketStatus 2024-09-02 20:04:06 -06:00
Chris Thrasher 84978f8acc Add tests for sfIpAddress 2024-09-02 20:04:06 -06:00
Chris Thrasher 497b261acd Add clang-tidy modernize- checks 2024-09-02 20:02:29 -06:00
Chris Thrasher afc07ec565 Simplify event conversion 2024-09-02 15:39:15 -06:00
Chris Thrasher 3c0931b744 Build with newer macOS image 2024-09-02 14:54:22 -06:00
Chris Thrasher fde5bd02d7 Fix typo in documentation 2024-09-02 11:53:58 -06:00
Chris Thrasher 00f78c1964 Use assert to protect against dereferencing null pointers 2024-09-02 11:49:10 -06:00
Chris Thrasher 6e654c8193 Fix documentation bug 2024-09-01 13:59:37 -06:00
Chris Thrasher dfaebc6b88 Remove unnecessary extern from C function declarations 2024-09-01 13:52:28 -06:00
Chris Thrasher b3a0ed815b Clean up implementation of sf<T>Rect_intersects 2024-09-01 12:56:29 -06:00
Chris Thrasher 54d28325b9 Run clang-format 2024-09-01 11:32:18 -06:00
Chris Thrasher 42aec92642 Add format target for running clang-format 2024-09-01 11:32:18 -06:00
Chris Thrasher 86d52f4712 Use vectors for pairs of scalar parameters 2024-08-31 12:03:21 -06:00
Chris Thrasher 10685c7d0d Stop leaving variables unused in release builds
In a Release build, macros like `CSFML_CHECK_RETURN` expand into
nothing more than a cast-to-void which is meant to silence compiler
warnings about unused variables.

By declaring a temporary inside the macro argument, we ensure that
debug builds behave the same as always but Release builds expand
these macros into truly no code thus ensuring these temporary
variables are never created in the first place so there is now
nothing that we have to cast to void.
2024-08-27 10:21:46 -06:00
Chris Thrasher 513a6c2fda Add missing apt package dependency 2024-08-27 07:00:13 +01:00
Chris Thrasher caabd98100 Add convenience functions for converting between SFML and CSFML types 2024-08-26 16:04:44 -06:00
Biswapriyo Nath 58b6342d1b CMake: Fix installing HTML Help with newer Doxygen version
HTML Help generation was disabled for doxygen version greater
than 1.10.0 in df75efa78d commit.
2024-08-26 09:10:13 -06:00
Chris Thrasher 3316223629 Add tidy target for running clang-tidy 2024-08-25 14:18:36 -06:00
Chris Thrasher fe8d8a972c Fix typos in public documentation
Typos found with codespell tool
2024-08-25 12:09:04 -06:00
Chris Thrasher 55fe064af4 Remove unnecessary (void) parameters from C++ implementations 2024-08-25 12:07:01 -06:00
Chris Thrasher e2e5ef1d31 Use .hpp as file extension for C++ headers 2024-08-25 10:11:32 -06:00
Chris Thrasher c5158c77b4 Move CSFML source files to CSFML/ directory
This helps make it easier to distinguish SFML files from CSFML files.
This is especially important for CSFML private headers which are
often C++ code with .hpp file extensions. This change means SFML and
CSFML can use headers with the same name without conflict.
2024-08-24 14:05:06 -06:00
Chris Thrasher 458da959f5 Remove deprecated interfaces 2024-08-24 11:32:56 -06:00
Chris Thrasher 620fdbc530 Remove references to removed types 2024-08-24 08:28:50 -06:00
Chris Thrasher 3536aeafd6 Switch to #pragma once 2024-08-24 07:40:26 -06:00
Chris Thrasher db4d5e4815 Reenable some MSVC warnings 2024-08-23 14:29:06 -06:00
Chris Thrasher 41a269faa9 Update Catch2 2024-08-23 14:14:25 -06:00
Chris Thrasher 379e26ac99 Delay test discovery to ensure all DLLs get copied first 2024-08-23 12:48:47 -06:00
Chris Thrasher 82ac0503b5 Revert "Temporarily lock SFML revision used in CI"
This reverts commit 36a6e7c5a6.
2024-08-23 12:48:47 -06:00
Chris Thrasher b778f44681 Update to latest SFML 3 API 2024-08-09 13:22:43 -06:00
Chris Thrasher a9c35c8e85 Remove references to OpenAL 2024-06-27 19:35:10 +02:00
Guillaume D 3c6054ce4e Fixed comment typo in Clipboard.h 2024-06-24 21:53:44 -06:00
Guillaume D ba471094c5 Fixed doc comment in Cursor.h 2024-06-24 21:53:44 -06:00
Chris Thrasher 9b96c2a797 Add sfJoystick tests
These are just copied from the SFML sf::Joystick tests with minor
changes to adhere to the CSFML API.
2024-06-24 20:50:07 -06:00
Chris Thrasher ed8babaf41 Update Catch2 2024-06-24 20:50:07 -06:00
Chris Thrasher 44380e7507 Fix API changes in SFML 3 2024-05-31 16:36:13 -06:00
Chris Thrasher 36a6e7c5a6 Temporarily lock SFML revision used in CI
The SFML 3 API is changing faster than I care to update in CSFML.
For now let's lock CSFML to a particular revision of SFML until
the SFML 3 API changes slow down and we can go back to tracking
the master branch.
2024-05-31 16:36:13 -06:00
Lukas Dürrenberger d4cba2529e Merging 2.6.x into master 2024-05-19 15:32:57 +02:00
Lukas Dürrenberger 315c207797 Merge branch '2.6.x' into feature/backmerge 2024-05-18 23:40:59 +02:00
Chris Thrasher 5fb7d4a0a1 Catch up with SFML 3 API changes 2024-05-18 23:35:57 +02:00
Chris Thrasher 330b423ee9 Add unit tests
Yay tests!
2024-04-15 15:24:51 -06:00
Lukas Dürrenberger 36c234fd90 Merge branch '2.6.x' into master 2024-04-15 23:06:45 +02:00
Chris Thrasher fce7450bbf Merge branch '2.6.x' into feature/backmerge 2024-03-30 20:44:49 -05:00
Chris Thrasher 671afabfc2 Use bash by default in all CI jobs 2024-03-30 12:41:28 +01:00
Chris Thrasher 5e3d87858f Set compiler warnings on a per-target basis 2024-03-29 09:58:28 -05:00
Chris Thrasher 65165dbc55 Remove $GITHUB_WORKSPACE where not needed 2024-03-29 09:58:13 -05:00
Miron Alexandru 61bcbc5906 Compile CSFML with SFML 3.0 2024-03-28 17:59:11 -06:00
Laiheau 0d292bdb3c [FIX] just a spelling mistake in the TcpSocket.h 2024-03-10 10:58:20 -06:00
Chris Thrasher b71e8c1dfc Remove unused code 2024-02-19 16:35:08 -07:00
Chris Thrasher e67340f1c5 Remove trailing whitespace 2024-02-19 22:55:18 +00:00
Chris Thrasher 2493f13baa Update checkout action to fix deprecation warnings 2024-02-19 23:30:30 +01:00
Chris Thrasher d007025e0f Use = default 2024-02-19 23:30:30 +01:00
Chris Thrasher 683677b5aa Use override 2024-02-19 23:30:30 +01:00
Chris Thrasher 907b0ca6ee Use std::vector::data 2024-02-19 23:30:30 +01:00
Chris Thrasher 3446239371 Allow for using unexpected compilers 2024-02-19 23:30:30 +01:00
Chris Thrasher 00303b7165 Remove unused code 2024-02-19 23:30:30 +01:00
Chris Thrasher d54f8e839e Remove macOS 10.5 detection
This also gets rid of exec_program which has been deprecated in
CMake.
2024-02-19 23:30:30 +01:00
Chris Thrasher 9f1619520e Use list(APPEND to append to lists 2024-02-19 23:30:30 +01:00
Chris Thrasher bb347c2c8c Remove deprecated APIs 2024-02-19 23:30:30 +01:00
Chris Thrasher 0ad43bc7d2 Enable MSVC's strict standards conformance mode 2024-02-19 23:30:30 +01:00
Chris Thrasher c7ac60f312 Require C11
This required silencing C5105 which emits warnings about system
headers which we can't change.

https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5105?view=msvc-170
2024-02-19 23:30:30 +01:00
Chris Thrasher a51c22a7a3 Use C standard library utilities for booleans and fixed-width ints 2024-02-19 23:30:30 +01:00
Chris Thrasher 46bc9a7ed8 Remove C++11 compiler warning 2024-02-19 23:30:30 +01:00
Chris Thrasher 3401cade6e Use ranged-for loops 2024-02-19 23:30:30 +01:00
Chris Thrasher 7676dfd95e Use nullptr 2024-02-19 23:30:30 +01:00
Chris Thrasher 2273672415 Remove workarounds for old compilers 2024-02-19 23:30:30 +01:00
Chris Thrasher 942f23ca0b Require C++17 2024-02-19 23:30:30 +01:00
Chris Thrasher f9cf6b935a Increase CMake requirement 2024-02-19 23:30:30 +01:00
Chris Thrasher 5b446077e6 Update project version 2024-02-19 23:30:30 +01:00
325 changed files with 19359 additions and 11268 deletions

No files matched your search

+173
View File
@@ -0,0 +1,173 @@
---
# Project
Standard: c++17
ColumnLimit: 120
# Indentation
AccessModifierOffset: -4
BitFieldColonSpacing: Both
ContinuationIndentWidth: 4
IndentCaseLabels: true
IndentCaseBlocks: false
IndentExternBlock: Indent
IndentPPDirectives: None
IndentRequires: true
IndentWidth: 4
IndentWrappedFunctionNames: true
TabWidth: 4
UseTab: Never
# Alignment
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveBitFields: Consecutive
AlignConsecutiveDeclarations: Consecutive
AlignConsecutiveMacros: Consecutive
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments: true
# Allow
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AllowShortLambdasOnASingleLine: All
# Break
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeConceptDeclarations: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakBeforeBinaryOperators: None
BreakInheritanceList: AfterColon
BreakStringLiterals: true
# Initializers & arguments
BinPackArguments: false
BinPackParameters: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 0
Cpp11BracedListStyle: true
# Braces
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: false
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
# Namespaces
CompactNamespaces: false
FixNamespaceComments: true
NamespaceIndentation: None
# Derive
DeriveLineEnding: false
DerivePointerAlignment: false
# Empty lines
EmptyLineBeforeAccessModifier: Always
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
# Sorting
IncludeBlocks: Regroup
IncludeCategories:
- Priority: 1
Regex: '^<CSFML\/Config.h>$'
- Priority: 2
Regex: '^<CSFML\/(.+)\/Export.h>$'
- Priority: 3
Regex: '^<CSFML\/'
- Priority: 4
Regex: '^<SFML\/'
- Priority: 5
Regex: '^<(catch2)'
- Priority: 6
Regex: '^<(.+)>$'
SortIncludes: true
SortUsingDeclarations: true
# Penalties
PenaltyBreakAssignment: 1000
PenaltyBreakBeforeFirstCallParameter: 1000
PenaltyBreakComment: 200
PenaltyBreakFirstLessLess: 100
PenaltyBreakString: 1
PenaltyBreakTemplateDeclaration: 0
PenaltyExcessCharacter: 5
PenaltyIndentedWhitespace: 1
PenaltyReturnTypeOnItsOwnLine: 500
# Pointer alignment
PointerAlignment: Left
# Comments
ReflowComments: false
# Spaces
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
# Line endings
UseCRLF: false
# Qualifiers (const, volatile, static, etc)
QualifierAlignment: Custom
QualifierOrder: ['static', 'inline', 'constexpr', 'const', 'volatile', 'type']
---
Language: ObjC
IndentWidth: 4
BreakBeforeBraces: Custom
BraceWrapping:
AfterObjCDeclaration: true
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 4
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: false
...
+38
View File
@@ -0,0 +1,38 @@
Checks: >
bugprone-*,
clang-analyzer-*,
cppcoreguidelines-*,
modernize-*,
readability-identifier-naming,
-bugprone-easily-swappable-parameters,
-bugprone-narrowing-conversions,
-clang-analyzer-core.NonNullParamChecker,
-clang-analyzer-security.insecureAPI.strcpy,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-macro-to-enum,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-narrowing-conversions,
-cppcoreguidelines-no-malloc,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-const-cast,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-special-member-functions,
-cppcoreguidelines-use-enum-class,
-modernize-avoid-c-arrays,
-modernize-macro-to-enum,
-modernize-redundant-void-arg,
-modernize-use-trailing-return-type,
-modernize-use-using,
CheckOptions:
- { key: readability-identifier-naming.VariableCase, value: camelBack }
- { key: readability-identifier-naming.GlobalVariableCase, value: aNy_CasE }
- { key: readability-identifier-naming.ParameterCase, value: camelBack }
HeaderFilterRegex: '.*'
WarningsAsErrors: '*'
UseColor: true
+2
View File
@@ -0,0 +1,2 @@
github: SFML
open_collective: sfml
+164 -22
View File
@@ -2,28 +2,38 @@ name: CI
on: [push, pull_request, workflow_dispatch]
permissions: {}
concurrency:
group: environment-${{github.ref}}
cancel-in-progress: true
env:
SFML_VERSION: 3.1.0
defaults:
run:
shell: bash
jobs:
build:
name: ${{ matrix.platform.name }} ${{ matrix.type.name }}
name: ${{ matrix.platform.name }} ${{ matrix.config.name }} ${{ matrix.type.name }}
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- { name: Windows VS2019 x86, os: windows-2019, flags: -AWin32 }
- { name: Windows VS2019 x64, os: windows-2019, flags: -Ax64 }
- { name: Windows VS2022 x86, os: windows-2022, flags: -AWin32 }
- { name: Windows VS2022 x64, os: windows-2022, flags: -Ax64 }
- { name: Windows ClangCL, os: windows-2022, flags: -T ClangCL }
- { name: Windows Clang, os: windows-2022, flags: -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
- { name: Linux GCC, os: ubuntu-22.04, flags: -GNinja }
- { name: Linux Clang, os: ubuntu-22.04, flags: -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
- { name: MacOS, os: macos-12, flags: -GNinja }
- { name: Windows VS2026 x86, os: windows-2025-vs2026, flags: -AWin32 }
- { name: Windows VS2026 x64, os: windows-2025-vs2026, flags: -Ax64 }
- { name: Windows ClangCL, os: windows-2025-vs2026, flags: -T ClangCL }
- { name: Windows Clang, os: windows-2025-vs2026, flags: -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
- { name: Linux GCC, os: ubuntu-24.04, flags: -GNinja }
- { name: Linux Clang, os: ubuntu-24.04, flags: -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
- { name: MacOS, os: macos-15, flags: -GNinja }
config:
- { name: Shared, flags: -DBUILD_SHARED_LIBS=ON, csfml_flags: -DCSFML_LINK_SFML_STATICALLY=OFF }
- { name: Static, flags: -DBUILD_SHARED_LIBS=OFF, csfml_flags: -DCSFML_LINK_SFML_STATICALLY=ON }
type:
- { name: Debug }
- { name: Release }
@@ -32,36 +42,168 @@ jobs:
- name: Get CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: ${{ runner.os == 'Windows' && '4.2' || '3.28' }} # Visual Studio 2026 generator requires CMake 4.2 or later
ninjaVersion: latest
- name: Install Linux Dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install libxrandr-dev libxcursor-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev
run: sudo apt-get update && sudo apt-get install libxrandr-dev libxcursor-dev libxi-dev libudev-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev libfreetype-dev libharfbuzz-dev libmbedtls-dev libssh2-1-dev
- name: Checkout SFML
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
persist-credentials: false
repository: SFML/SFML
ref: 2.6.1
ref: ${{env.SFML_VERSION}}
path: SFML
- name: Configure SFML CMake
shell: bash
run: cmake -S $GITHUB_WORKSPACE/SFML -B $GITHUB_WORKSPACE/SFML/build -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/SFML/install -DBUILD_SHARED_LIBS=TRUE -DSFML_BUILD_EXAMPLES=FALSE -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_VERBOSE_MAKEFILE=ON ${{matrix.platform.flags}} -DCMAKE_BUILD_TYPE=${{matrix.type.name}}
env:
BUILD_TYPE: ${{ matrix.type.name }}
CMAKE_FLAGS: ${{ matrix.platform.flags }} ${{ matrix.config.flags }}
run: |
# Let the installed SFML libraries find each other, same as tools/nuget/build.linux.sh
RPATH_FLAGS=()
if [ "$RUNNER_OS" = "Linux" ]; then RPATH_FLAGS=('-DCMAKE_INSTALL_RPATH=$ORIGIN'); fi
cmake -S SFML -B SFML/build \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DCMAKE_INSTALL_PREFIX=SFML/install \
"${RPATH_FLAGS[@]}" \
$CMAKE_FLAGS
- name: Build SFML
shell: bash
run: cmake --build $GITHUB_WORKSPACE/SFML/build --config ${{matrix.type.name}} --target install
env:
BUILD_TYPE: ${{ matrix.type.name }}
run: cmake --build SFML/build --config "$BUILD_TYPE" --target install
- name: Checkout CSFML
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
- name: Configure CSFML CMake
shell: bash
run: cmake -S $GITHUB_WORKSPACE/CSFML -B $GITHUB_WORKSPACE/CSFML/build -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/CSFML/install -DBUILD_SHARED_LIBS=TRUE -DCSFML_BUILD_EXAMPLES=TRUE -DCSFML_LINK_SFML_STATICALLY=FALSE -DSFML_DIR=$GITHUB_WORKSPACE/SFML/install/lib/cmake/SFML -DCMAKE_VERBOSE_MAKEFILE=ON -DWARNINGS_AS_ERRORS=TRUE ${{matrix.platform.flags}} -DCMAKE_BUILD_TYPE=${{matrix.type.name}}
env:
BUILD_TYPE: ${{ matrix.type.name }}
CMAKE_FLAGS: ${{ matrix.platform.flags }} ${{ matrix.config.flags }} ${{ matrix.config.csfml_flags }}
run: |
cmake --preset dev -S CSFML -B CSFML/build \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DCMAKE_INSTALL_PREFIX=CSFML/install \
-DSFML_ROOT=SFML/install \
-DCMAKE_VERBOSE_MAKEFILE=ON \
$CMAKE_FLAGS
- name: Build CSFML
shell: bash
run: cmake --build $GITHUB_WORKSPACE/CSFML/build --config ${{matrix.type.name}} --target install
env:
BUILD_TYPE: ${{ matrix.type.name }}
run: cmake --build CSFML/build --config "$BUILD_TYPE" --target install
- name: Test
env:
BUILD_TYPE: ${{ matrix.type.name }}
run: ctest --test-dir CSFML/build -C "$BUILD_TYPE" --output-on-failure
format:
name: Formatting
runs-on: ubuntu-24.04
steps:
- name: Install Clang Format
run: sudo apt-get install clang-format-17
- name: Checkout Code
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Format Code
run: cmake -DCLANG_FORMAT_EXECUTABLE=clang-format-17 -P cmake/Format.cmake
- name: Check Formatting
run: git diff --exit-code
tidy:
name: Analyze
runs-on: macos-15
steps:
- name: Get CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: ${{ runner.os == 'Windows' && '4.2' || '3.28' }} # Visual Studio 2026 generator requires CMake 4.2 or later
ninjaVersion: latest
- name: Install Dependencies
run: |
brew update
brew install llvm@18 ninja
echo "$(brew --prefix llvm@18)/bin" >> $GITHUB_PATH
- name: Checkout SFML
uses: actions/checkout@v7
with:
persist-credentials: false
repository: SFML/SFML
ref: ${{env.SFML_VERSION}}
path: SFML
- name: Configure SFML CMake
run: cmake -S SFML -B SFML/build -GNinja -DCMAKE_INSTALL_PREFIX=SFML/install -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug
- name: Build SFML
run: cmake --build SFML/build --target install
- name: Checkout CSFML
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
- name: Configure CSFML CMake
run: cmake --preset dev -S CSFML -B CSFML/build -DSFML_ROOT=SFML/install -DCMAKE_BUILD_TYPE=Debug
- name: Tidy
run: cmake --build CSFML/build --target tidy
docs:
name: Documentation
runs-on: macos-15
steps:
- name: Get CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: ${{ runner.os == 'Windows' && '4.2' || '3.28' }} # Visual Studio 2026 generator requires CMake 4.2 or later
ninjaVersion: latest
- name: Install Doxygen
run: |
brew update
brew install doxygen ninja || true
- name: Checkout SFML
uses: actions/checkout@v7
with:
persist-credentials: false
repository: SFML/SFML
ref: ${{env.SFML_VERSION}}
path: SFML
- name: Configure SFML
run: cmake -S SFML -B SFML/build -GNinja -DCMAKE_INSTALL_PREFIX=SFML/install
- name: Build SFML
run: cmake --build SFML/build --target install
- name: Checkout CSFML
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
- name: Configure CSFML
run: cmake -S CSFML -B CSFML/build -GNinja -DSFML_ROOT=SFML/install -DCSFML_BUILD_DOC=ON -DCSFML_LINK_SFML_STATICALLY=ON
- name: Build Doxygen Site
run: cmake --build CSFML/build --target doc
+216 -212
View File
@@ -1,252 +1,256 @@
name: NuGet Release
on:
push:
branches:
- master
- 2.6.x
workflow_dispatch: {}
push:
branches:
- master
- 2.6.x
tags:
- "**"
workflow_dispatch: {}
permissions: {}
concurrency:
group: nuget-${{github.ref}}
cancel-in-progress: true
group: nuget-${{github.ref}}
cancel-in-progress: true
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
jobs:
windows:
name: Windows VS2022
runs-on: windows-2022
windows-x86-x64:
name: Windows x86 x64
runs-on: windows-2025-vs2026
steps:
- name: Checkout CSFML
uses: actions/checkout@v4
with:
path: CSFML
steps:
- name: Checkout CSFML
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
- name: Build x86
shell: pwsh
run: |
cd CSFML/tools/nuget
./build.win.ps1 "win-x86"
- name: Build x86
shell: pwsh
run: |
cd CSFML/tools/nuget
./build.win.ps1 "win-x86"
- name: Build x64
shell: pwsh
run: |
cd CSFML/tools/nuget
./build.win.ps1 "win-x64"
- name: Build x64
shell: pwsh
run: |
cd CSFML/tools/nuget
./build.win.ps1 "win-x64"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: CSFML-win-x86-x64
path: CSFML/tools/nuget/CSFML/runtimes
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: CSFML-win-x86-x64
path: CSFML/tools/nuget/CSFML/runtimes
linux-x64:
name: Linux x64
runs-on: ubuntu-22.04
container:
image: ubuntu:22.04
windows-arm64:
name: Windows ARM64
runs-on: windows-11-vs2026-arm
steps:
- name: Checkout CSFML
uses: actions/checkout@v4
with:
path: CSFML
steps:
- name: Checkout CSFML
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
- name: Build
shell: bash
run: |
cd ./CSFML/tools/nuget
chmod +x ./docker.linux-x64.sh
./docker.linux-x64.sh
- name: Build ARM64
shell: pwsh
run: |
cd CSFML/tools/nuget
./build.win.ps1 "win-arm64"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: CSFML-linux-x64
path: CSFML/tools/nuget/CSFML/runtimes
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: CSFML-win-arm64
path: CSFML/tools/nuget/CSFML/runtimes
linux-arm:
name: Linux ARM
runs-on: ubuntu-22.04
linux-x64:
name: Linux x64
runs-on: ubuntu-24.04
container:
image: ubuntu:24.04
steps:
- name: Checkout CSFML
uses: actions/checkout@v4
with:
path: CSFML
steps:
- name: Checkout CSFML
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
- name: Build in an ARM container
uses: uraimo/run-on-arch-action@v2.7.2
with:
arch: armv7
distro: ubuntu22.04
githubToken: ${{ github.token }}
dockerRunArgs: |
--volume "${PWD}/CSFML:/CSFML"
install: |
apt-get update -y
apt-get install -y git libfreetype6-dev xorg-dev libxrandr-dev libxcursor-dev libudev-dev libgl1-mesa-dev libflac-dev libogg-dev libvorbis-dev libopenal-dev cmake g++
run: |
cd /CSFML/tools/nuget
chmod +x ./build.linux.sh
./build.linux.sh linux-arm
- name: Build
shell: bash
run: |
cd ./CSFML/tools/nuget
chmod +x ./docker.linux-x64.sh
./docker.linux-x64.sh
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: CSFML-linux-arm
path: CSFML/tools/nuget/CSFML/runtimes
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: CSFML-linux-x64
path: CSFML/tools/nuget/CSFML/runtimes
linux-arm64:
name: Linux ARM64
runs-on: ubuntu-22.04
linux-arm:
name: Linux ARM
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout CSFML
uses: actions/checkout@v4
with:
path: CSFML
steps:
- name: Checkout CSFML
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
- name: Build in an ARM64 container
uses: uraimo/run-on-arch-action@v2.7.2
with:
arch: aarch64
distro: ubuntu22.04
githubToken: ${{ github.token }}
dockerRunArgs: |
--volume "${PWD}/CSFML:/CSFML"
install: |
apt-get update -y
apt-get install -y git libfreetype6-dev xorg-dev libxrandr-dev libxcursor-dev libudev-dev libgl1-mesa-dev libflac-dev libogg-dev libvorbis-dev libopenal-dev cmake g++
run: |
cd /CSFML/tools/nuget
chmod +x ./build.linux.sh
./build.linux.sh linux-arm64
- name: Install dependencies & cross compiler
run: |
sudo dpkg --add-architecture armhf
sudo apt-get update
sudo apt-get install -y git libfreetype6-dev:armhf xorg-dev libxrandr-dev:armhf libxcursor-dev:armhf libxi-dev:armhf libudev-dev:armhf libgl1-mesa-dev:armhf libflac-dev:armhf libogg-dev:armhf libvorbis-dev:armhf cmake g++-arm-linux-gnueabihf gcc-arm-linux-gnueabihf
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: CSFML-linux-arm64
path: CSFML/tools/nuget/CSFML/runtimes
- name: Build
shell: bash
run: |
cd ./CSFML/tools/nuget
chmod +x ./build.linux.sh
./build.linux.sh linux-arm arm-linux-gnueabihf-g++ arm-linux-gnueabihf-gcc
linux-musl-x64:
name: Linux MUSL x64
runs-on: ubuntu-22.04
container:
image: alpine:3.15
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: CSFML-linux-arm
path: CSFML/tools/nuget/CSFML/runtimes
steps:
- name: Checkout CSFML
uses: actions/checkout@v4
with:
path: CSFML
linux-arm64:
name: Linux ARM64
runs-on: ubuntu-24.04-arm
- name: Build
shell: sh
run: |
cd ./CSFML/tools/nuget
chmod +x ./docker.linux-musl-x64.sh
./docker.linux-musl-x64.sh
steps:
- name: Checkout CSFML
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: CSFML-linux-musl-x64
path: CSFML/tools/nuget/CSFML/runtimes
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y git libfreetype6-dev xorg-dev libxrandr-dev libxcursor-dev libxi-dev libudev-dev libgl1-mesa-dev libflac-dev libogg-dev libvorbis-dev cmake gcc g++
fedora-x64:
name: Fedora x64
runs-on: ubuntu-22.04
container:
image: fedora:37
- name: Build
shell: bash
run: |
cd ./CSFML/tools/nuget
chmod +x ./build.linux.sh
./build.linux.sh linux-arm64
steps:
- name: Checkout CSFML
uses: actions/checkout@v4
with:
path: CSFML
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: CSFML-linux-arm64
path: CSFML/tools/nuget/CSFML/runtimes
- name: Build
shell: bash
run: |
cd ./CSFML/tools/nuget
chmod +x ./docker.fedora-x64.sh
./docker.fedora-x64.sh
linux-musl-x64:
name: Linux MUSL x64
runs-on: ubuntu-24.04
container:
image: alpine:3.20.7
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: CSFML-fedora-x64
path: CSFML/tools/nuget/CSFML/runtimes
steps:
- name: Checkout CSFML
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
macos:
name: macOS
runs-on: macos-14
- name: Build
shell: sh
run: |
cd ./CSFML/tools/nuget
chmod +x ./docker.linux-musl-x64.sh
./docker.linux-musl-x64.sh
steps:
- name: Checkout CSFML
uses: actions/checkout@v4
with:
path: CSFML
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: CSFML-linux-musl-x64
path: CSFML/tools/nuget/CSFML/runtimes
- name: Install necessary tooling
run: brew install coreutils
macos-x64-arm64:
name: macOS x64 and ARM64
runs-on: macos-15
- name: Build x64
run: |
cd CSFML/tools/nuget
./build.macos.sh "osx-x64"
steps:
- name: Checkout CSFML
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
- name: Build ARM64
run: |
cd CSFML/tools/nuget
./build.macos.sh "osx-arm64"
- name: Install necessary tooling
run: brew install coreutils
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: CSFML-macOS-x64-arm64
path: CSFML/tools/nuget/CSFML/runtimes
- name: Build x64
run: |
cd CSFML/tools/nuget
./build.macos.sh "osx-x64"
package:
name: Package Builds
runs-on: ubuntu-22.04
needs:
- windows
- linux-x64
- linux-arm
- linux-arm64
- linux-musl-x64
- fedora-x64
- macos
steps:
- name: Checkout CSFML
uses: actions/checkout@v4
with:
path: CSFML
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: CSFML/tools/nuget/CSFML/runtimes
merge-multiple: true
- name: Setup .NET 8 SDK
id: setup-dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Enforce SDK Version
run: dotnet new globaljson --sdk-version ${{ steps.setup-dotnet.outputs.dotnet-version }} --force
- name: Verify SDK Installation
run: dotnet --info
- name: Build NuGet Package
run: |
cd CSFML/tools/nuget
dotnet build --configuration Release --verbosity detailed
- name: Upload NuGet Package
uses: actions/upload-artifact@v4
with:
name: CSFML-NuGet-Package
path: CSFML/tools/nuget/CSFML/bin/Release/*.nupkg
- name: Build ARM64
run: |
cd CSFML/tools/nuget
./build.macos.sh "osx-arm64"
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: CSFML-macOS-x64-arm64
path: CSFML/tools/nuget/CSFML/runtimes
package:
name: Package Builds
runs-on: ubuntu-24.04
needs:
- windows-x86-x64
- windows-arm64
- linux-x64
- linux-arm
- linux-arm64
- linux-musl-x64
- macos-x64-arm64
steps:
- name: Checkout CSFML
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
- name: Download Artifacts
uses: actions/download-artifact@v8
with:
path: CSFML/tools/nuget/CSFML/runtimes
merge-multiple: true
- name: Setup .NET 10 SDK
id: setup-dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: Enforce SDK Version
env:
DOTNET_VERSION: ${{ steps.setup-dotnet.outputs.dotnet-version }}
run: dotnet new globaljson --sdk-version "$DOTNET_VERSION" --force
- name: Verify SDK Installation
run: dotnet --info
- name: Build NuGet Package
run: |
cd CSFML/tools/nuget
dotnet build --configuration Release --verbosity detailed
- name: Upload NuGet Package
uses: actions/upload-artifact@v7
with:
name: CSFML-NuGet-Package
path: CSFML/tools/nuget/CSFML/bin/Release/*.nupkg
+314 -274
View File
@@ -1,316 +1,356 @@
name: Release Builds
on:
push:
branches:
- master
- 2.6.x
tags:
- "**"
workflow_dispatch: {}
push:
branches:
- master
- 2.6.x
tags:
- "**"
workflow_dispatch: {}
permissions: {}
concurrency:
group: release-${{github.ref}}
cancel-in-progress: true
group: release-${{github.ref}}
cancel-in-progress: true
env:
SFML_VERSION: 3.1.0
defaults:
run:
shell: bash
jobs:
windows-x86:
name: Windows x86
runs-on: windows-2022
windows-x86:
name: Windows x86
runs-on: windows-2025-vs2026
steps:
- name: Cache MinGW x86
id: mingw-x86-cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/mingw32
key: 14.1.0posix-18.1.5-11.0.1-msvcrt-r1-x86
steps:
- name: Install MinGW x86
uses: bwoodsend/setup-winlibs-action@v1
id: winlibs-32
with:
tag: 15.2.0posix-13.0.0-ucrt-r1
with_clang: false
architecture: 32
destination: ${{ github.workspace }}
add_to_path: false
- name: Install MinGW x86
if: steps.mingw-x86-cache.outputs.cache-hit != 'true'
uses: bwoodsend/setup-winlibs-action@v1
id: winlibs-32
with:
tag: 14.1.0posix-18.1.5-11.0.1-msvcrt-r1
with_clang: false
architecture: 32
destination: ${{ github.workspace }}
add_to_path: false
- name: Checkout SFML
uses: actions/checkout@v7
with:
persist-credentials: false
repository: SFML/SFML
ref: ${{ env.SFML_VERSION }}
path: SFML
- name: Checkout SFML
uses: actions/checkout@v4
with:
repository: SFML/SFML
ref: 2.6.1
path: SFML
- name: Checkout CSFML
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
- name: Checkout CSFML
uses: actions/checkout@v4
with:
path: CSFML
- name: Build SFML
run: |
cmake -S SFML -B SFML-build -A Win32 -G "Visual Studio 18 2026" -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/SFML-install" -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build SFML-build --config Release --target install
- name: Build SFML
run: |
cmake -S SFML -B SFML-build -A Win32 -G "Visual Studio 17 2022" -DBUILD_SHARED_LIBS=FALSE -DSFML_USE_STATIC_STD_LIBS=TRUE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/SFML-install -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build SFML-build --config Release --target install
- name: Build CSFML
run: |
cmake -S CSFML -B CSFML-build -A Win32 -G "Visual Studio 18 2026" -DBUILD_SHARED_LIBS=ON -DCSFML_LINK_SFML_STATICALLY=OFF -DCMAKE_BUILD_TYPE=Release "-DSFML_ROOT=$GITHUB_WORKSPACE/SFML-install" "-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/CSFML-install" -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build CSFML-build --config Release --target install
- name: Build CSFML
run: |
cmake -S CSFML -B CSFML-build -A Win32 -G "Visual Studio 17 2022" -DBUILD_SHARED_LIBS=TRUE -DSTATIC_STD_LIBS=TRUE -DCSFML_LINK_SFML_STATICALLY=TRUE -DCMAKE_BUILD_TYPE=Release -DSFML_DIR=${{ github.workspace }}/SFML-install/lib/cmake/SFML -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/CSFML-install -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build CSFML-build --config Release --target install
- name: Add MinGW to PATH
shell: bash
run: echo "${{ github.workspace }}\mingw32\bin" >> $GITHUB_PATH
- name: Add MinGW to PATH
shell: bash
run: echo "$GITHUB_WORKSPACE\mingw32\bin" >> "$GITHUB_PATH"
- name: Generate Import Libs for MinGW
shell: pwsh
run: |
New-Item -ItemType "directory" -PATH "CSFML-install\lib\gcc"
New-Item -ItemType "directory" -PATH "CSFML-install\lib\msvc"
Move-Item -Path "CSFML-install\lib\*.lib" -Destination "CSFML-install\lib\msvc"
- name: Generate Import Libs for MinGW
shell: pwsh
run: |
New-Item -ItemType "directory" -PATH "CSFML-install\lib\gcc"
New-Item -ItemType "directory" -PATH "CSFML-install\lib\msvc"
Move-Item -Path "CSFML-install\lib\*.lib" -Destination "CSFML-install\lib\msvc"
Push-Location CSFML-install\lib\gcc
& gendef.exe "..\..\bin\csfml-graphics-2.dll"
& dlltool.exe -d "csfml-graphics-2.def" -D "..\..\bin\csfml-graphics-2.dll" -l "libcsfml-graphics.a"
Remove-Item -Path "csfml-graphics-2.def"
& gendef.exe "..\..\bin\csfml-window-2.dll"
& dlltool.exe -d "csfml-window-2.def" -D "..\..\bin\bin\csfml-window-2.dll" -l "libcsfml-window.a"
Remove-Item -Path "csfml-window-2.def"
& gendef.exe "..\..\bin\csfml-audio-2.dll"
& dlltool.exe -d "csfml-audio-2.def" -D "..\..\bin\bin\csfml-audio-2.dll" -l "libcsfml-audio.a"
Remove-Item -Path "csfml-audio-2.def"
& gendef.exe "..\..\bin\csfml-network-2.dll"
& dlltool.exe -d "csfml-network-2.def" -D "..\..\bin\bin\csfml-network-2.dll" -l "libcsfml-network.a"
Remove-Item -Path "csfml-network-2.def"
& gendef.exe "..\..\bin\csfml-system-2.dll"
& dlltool.exe -d "csfml-system-2.def" -D "..\..\bin\bin\csfml-system-2.dll" -l "libcsfml-system.a"
Remove-Item -Path "csfml-system-2.def"
Pop-Location
Push-Location CSFML-install\lib\gcc
& gendef.exe "..\..\bin\csfml-graphics-3.dll"
& dlltool.exe -d "csfml-graphics-3.def" -D "..\..\bin\csfml-graphics-3.dll" -l "libcsfml-graphics.a"
Remove-Item -Path "csfml-graphics-3.def"
New-Item -ItemType "directory" -PATH "install"
Move-Item -Path "CSFML-install\*" -Destination "install\CSFML"
& gendef.exe "..\..\bin\csfml-window-3.dll"
& dlltool.exe -d "csfml-window-3.def" -D "..\..\bin\csfml-window-3.dll" -l "libcsfml-window.a"
Remove-Item -Path "csfml-window-3.def"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: CSFML-windows-32-bit
path: install/CSFML
& gendef.exe "..\..\bin\csfml-audio-3.dll"
& dlltool.exe -d "csfml-audio-3.def" -D "..\..\bin\csfml-audio-3.dll" -l "libcsfml-audio.a"
Remove-Item -Path "csfml-audio-3.def"
windows-x64:
name: Windows x64
runs-on: windows-2022
& gendef.exe "..\..\bin\csfml-network-3.dll"
& dlltool.exe -d "csfml-network-3.def" -D "..\..\bin\csfml-network-3.dll" -l "libcsfml-network.a"
Remove-Item -Path "csfml-network-3.def"
steps:
- name: Cache MinGW x64
id: mingw-x64-cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/mingw64
key: 14.1.0posix-18.1.5-11.0.1-msvcrt-r1-x64
& gendef.exe "..\..\bin\csfml-system-3.dll"
& dlltool.exe -d "csfml-system-3.def" -D "..\..\bin\csfml-system-3.dll" -l "libcsfml-system.a"
Remove-Item -Path "csfml-system-3.def"
Pop-Location
- name: Install MinGW x64
if: steps.mingw-x64-cache.outputs.cache-hit != 'true'
uses: bwoodsend/setup-winlibs-action@v1
id: winlibs-64
with:
tag: 14.1.0posix-18.1.5-11.0.1-msvcrt-r1
with_clang: false
architecture: 64
destination: ${{ github.workspace }}
add_to_path: false
New-Item -ItemType "directory" -PATH "install\CSFML"
Move-Item -Path "CSFML-install\*" -Destination "install\CSFML"
- name: Checkout SFML
uses: actions/checkout@v4
with:
repository: SFML/SFML
ref: 2.6.1
path: SFML
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: CSFML-windows-32-bit
path: install/CSFML
- name: Checkout CSFML
uses: actions/checkout@v4
with:
path: CSFML
windows-x64:
name: Windows x64
runs-on: windows-2025-vs2026
- name: Build SFML
run: |
cmake -S SFML -B SFML-build -A x64 -G "Visual Studio 17 2022" -DBUILD_SHARED_LIBS=FALSE -DSFML_USE_STATIC_STD_LIBS=TRUE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/SFML-install -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build SFML-build --config Release --target install
steps:
- name: Install MinGW x64
uses: bwoodsend/setup-winlibs-action@v1
id: winlibs-64
with:
tag: 15.2.0posix-13.0.0-ucrt-r1
with_clang: false
architecture: 64
destination: ${{ github.workspace }}
add_to_path: false
- name: Build CSFML
run: |
cmake -S CSFML -B CSFML-build -A x64 -G "Visual Studio 17 2022" -DBUILD_SHARED_LIBS=TRUE -DSTATIC_STD_LIBS=TRUE -DCSFML_LINK_SFML_STATICALLY=TRUE -DCMAKE_BUILD_TYPE=Release -DSFML_DIR=${{ github.workspace }}/SFML-install/lib/cmake/SFML -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/CSFML-install -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build CSFML-build --config Release --target install
- name: Checkout SFML
uses: actions/checkout@v7
with:
persist-credentials: false
repository: SFML/SFML
ref: ${{ env.SFML_VERSION }}
path: SFML
- name: Add MinGW to PATH
shell: bash
run: echo "${{ github.workspace }}\mingw64\bin" >> $GITHUB_PATH
- name: Checkout CSFML
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
- name: Generate Import Libs for MinGW
shell: pwsh
run: |
New-Item -ItemType "directory" -PATH "CSFML-install\lib\gcc"
New-Item -ItemType "directory" -PATH "CSFML-install\lib\msvc"
Move-Item -Path "CSFML-install\lib\*.lib" -Destination "CSFML-install\lib\msvc"
- name: Build SFML
run: |
cmake -S SFML -B SFML-build -A x64 -G "Visual Studio 18 2026" -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/SFML-install" -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build SFML-build --config Release --target install
Push-Location CSFML-install\lib\gcc
& gendef.exe "..\..\bin\csfml-graphics-2.dll"
& dlltool.exe -d "csfml-graphics-2.def" -D "..\..\bin\csfml-graphics-2.dll" -l "libcsfml-graphics.a"
Remove-Item -Path "csfml-graphics-2.def"
& gendef.exe "..\..\bin\csfml-window-2.dll"
& dlltool.exe -d "csfml-window-2.def" -D "..\..\bin\bin\csfml-window-2.dll" -l "libcsfml-window.a"
Remove-Item -Path "csfml-window-2.def"
& gendef.exe "..\..\bin\csfml-audio-2.dll"
& dlltool.exe -d "csfml-audio-2.def" -D "..\..\bin\bin\csfml-audio-2.dll" -l "libcsfml-audio.a"
Remove-Item -Path "csfml-audio-2.def"
& gendef.exe "..\..\bin\csfml-network-2.dll"
& dlltool.exe -d "csfml-network-2.def" -D "..\..\bin\bin\csfml-network-2.dll" -l "libcsfml-network.a"
Remove-Item -Path "csfml-network-2.def"
& gendef.exe "..\..\bin\csfml-system-2.dll"
& dlltool.exe -d "csfml-system-2.def" -D "..\..\bin\bin\csfml-system-2.dll" -l "libcsfml-system.a"
Remove-Item -Path "csfml-system-2.def"
Pop-Location
- name: Build CSFML
run: |
cmake -S CSFML -B CSFML-build -A x64 -G "Visual Studio 18 2026" -DBUILD_SHARED_LIBS=ON -DCSFML_LINK_SFML_STATICALLY=OFF -DCMAKE_BUILD_TYPE=Release "-DSFML_ROOT=$GITHUB_WORKSPACE/SFML-install" "-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/CSFML-install" -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build CSFML-build --config Release --target install
New-Item -ItemType "directory" -PATH "install"
Move-Item -Path "CSFML-install\*" -Destination "install\CSFML"
- name: Add MinGW to PATH
shell: bash
run: echo "$GITHUB_WORKSPACE\mingw64\bin" >> "$GITHUB_PATH"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: CSFML-windows-64-bit
path: install/CSFML
- name: Generate Import Libs for MinGW
shell: pwsh
run: |
New-Item -ItemType "directory" -PATH "CSFML-install\lib\gcc"
New-Item -ItemType "directory" -PATH "CSFML-install\lib\msvc"
Move-Item -Path "CSFML-install\lib\*.lib" -Destination "CSFML-install\lib\msvc"
macos-x64:
name: macOS x64
runs-on: macos-12
Push-Location CSFML-install\lib\gcc
& gendef.exe "..\..\bin\csfml-graphics-3.dll"
& dlltool.exe -d "csfml-graphics-3.def" -D "..\..\bin\csfml-graphics-3.dll" -l "libcsfml-graphics.a"
Remove-Item -Path "csfml-graphics-3.def"
steps:
- name: Checkout SFML
uses: actions/checkout@v4
with:
repository: SFML/SFML
ref: 2.6.1
path: SFML
& gendef.exe "..\..\bin\csfml-window-3.dll"
& dlltool.exe -d "csfml-window-3.def" -D "..\..\bin\csfml-window-3.dll" -l "libcsfml-window.a"
Remove-Item -Path "csfml-window-3.def"
- name: Checkout CSFML
uses: actions/checkout@v4
with:
path: CSFML
& gendef.exe "..\..\bin\csfml-audio-3.dll"
& dlltool.exe -d "csfml-audio-3.def" -D "..\..\bin\csfml-audio-3.dll" -l "libcsfml-audio.a"
Remove-Item -Path "csfml-audio-3.def"
- name: Build SFML
run: |
cmake -S SFML -B SFML-build -G "Unix Makefiles" \
-DCMAKE_C_COMPILER="/usr/bin/clang" \
-DCMAKE_CXX_COMPILER="/usr/bin/clang++" \
-DCMAKE_C_FLAGS="-stdlib=libc++" \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DBUILD_SHARED_LIBS=TRUE \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/SFML-install/Library/Frameworks \
-DCMAKE_OSX_ARCHITECTURES=x86_64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \
-DSFML_BUILD_FRAMEWORKS=TRUE \
-DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build SFML-build --config Release --target install
& gendef.exe "..\..\bin\csfml-network-3.dll"
& dlltool.exe -d "csfml-network-3.def" -D "..\..\bin\csfml-network-3.dll" -l "libcsfml-network.a"
Remove-Item -Path "csfml-network-3.def"
- name: Build CSFML
run: |
cmake -S CSFML -B CSFML-build -G "Unix Makefiles" \
-DCMAKE_C_COMPILER="/usr/bin/clang" \
-DCMAKE_CXX_COMPILER="/usr/bin/clang++" \
-DCMAKE_C_FLAGS="-stdlib=libc++" \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DBUILD_SHARED_LIBS=TRUE \
-DCSFML_LINK_SFML_STATICALLY=FALSE \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/CSFML-install \
-DCMAKE_OSX_ARCHITECTURES=x86_64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \
-DSFML_DIR=${{ github.workspace }}/SFML-install/Library/Frameworks/SFML.framework/Resources/CMake \
-DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build CSFML-build --config Release --target install
& gendef.exe "..\..\bin\csfml-system-3.dll"
& dlltool.exe -d "csfml-system-3.def" -D "..\..\bin\csfml-system-3.dll" -l "libcsfml-system.a"
Remove-Item -Path "csfml-system-3.def"
Pop-Location
- name: Create Archive
run: |
mkdir CSFML-macOS-clang-64-bit
cp -R CSFML-install/include CSFML-macOS-clang-64-bit
cp -R CSFML-install/lib CSFML-macOS-clang-64-bit
cp CSFML-install/share/CSFML/* CSFML-macOS-clang-64-bit
tar -zcvf CSFML-macOS-clang-64-bit.tar.gz CSFML-macOS-clang-64-bit
New-Item -ItemType "directory" -PATH "install\CSFML"
Move-Item -Path "CSFML-install\*" -Destination "install\CSFML"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: CSFML-macOS-clang-64-bit
path: CSFML-macOS-clang-64-bit.tar.gz
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: CSFML-windows-64-bit
path: install/CSFML
macos-arm64:
name: macOS ARM64
runs-on: macos-14
windows-arm64:
name: Windows ARM64
runs-on: windows-2025-vs2026
steps:
- name: Checkout SFML
uses: actions/checkout@v4
with:
repository: SFML/SFML
ref: 2.6.1
path: SFML
steps:
- name: Checkout SFML
uses: actions/checkout@v7
with:
persist-credentials: false
repository: SFML/SFML
ref: ${{ env.SFML_VERSION }}
path: SFML
- name: Checkout CSFML
uses: actions/checkout@v4
with:
path: CSFML
- name: Build SFML
run: |
cmake -S SFML -B SFML-build -G "Unix Makefiles" \
-DCMAKE_C_COMPILER="/usr/bin/clang" \
-DCMAKE_CXX_COMPILER="/usr/bin/clang++" \
-DCMAKE_C_FLAGS="-stdlib=libc++" \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DBUILD_SHARED_LIBS=TRUE \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/SFML-install/Library/Frameworks \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-DSFML_BUILD_FRAMEWORKS=TRUE \
-DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build SFML-build --config Release --target install
- name: Checkout CSFML
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
- name: Build CSFML
run: |
cmake -S CSFML -B CSFML-build -G "Unix Makefiles" \
-DCMAKE_C_COMPILER="/usr/bin/clang" \
-DCMAKE_CXX_COMPILER="/usr/bin/clang++" \
-DCMAKE_C_FLAGS="-stdlib=libc++" \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DBUILD_SHARED_LIBS=TRUE \
-DCSFML_LINK_SFML_STATICALLY=FALSE \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/CSFML-install \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-DSFML_DIR=${{ github.workspace }}/SFML-install/Library/Frameworks/SFML.framework/Resources/CMake \
-DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build CSFML-build --config Release --target install
- name: Build SFML
run: |
cmake -S SFML -B SFML-build -A ARM64 -G "Visual Studio 18 2026" -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/SFML-install" -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build SFML-build --config Release --target install
- name: Create Archive
run: |
mkdir CSFML-macOS-clang-arm64
cp -R CSFML-install/include CSFML-macOS-clang-arm64
cp -R CSFML-install/lib CSFML-macOS-clang-arm64
cp CSFML-install/share/CSFML/* CSFML-macOS-clang-arm64
tar -zcvf CSFML-macOS-clang-arm64.tar.gz CSFML-macOS-clang-arm64
- name: Build CSFML
run: |
cmake -S CSFML -B CSFML-build -A ARM64 -G "Visual Studio 18 2026" -DBUILD_SHARED_LIBS=ON -DCSFML_LINK_SFML_STATICALLY=OFF -DCMAKE_BUILD_TYPE=Release "-DSFML_ROOT=$GITHUB_WORKSPACE/SFML-install" "-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/CSFML-install" -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build CSFML-build --config Release --target install
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: CSFML-macOS-clang-arm64
path: CSFML-macOS-clang-arm64.tar.gz
- name: Move Files
shell: pwsh
run: |
New-Item -ItemType "directory" -PATH "install\CSFML"
Move-Item -Path "CSFML-install\*" -Destination "install\CSFML"
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: CSFML-windows-arm64
path: install/CSFML
macos-x64:
name: macOS x64
runs-on: macos-15
steps:
- name: Checkout SFML
uses: actions/checkout@v7
with:
persist-credentials: false
repository: SFML/SFML
ref: ${{ env.SFML_VERSION }}
path: SFML
- name: Checkout CSFML
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
- name: Build SFML
run: |
cmake -S SFML -B SFML-build -G "Unix Makefiles" \
-DCMAKE_C_COMPILER="/usr/bin/clang" \
-DCMAKE_CXX_COMPILER="/usr/bin/clang++" \
-DCMAKE_C_FLAGS="-stdlib=libc++" \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
"-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/SFML-install" \
-DCMAKE_OSX_ARCHITECTURES=x86_64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \
-DSFML_BUILD_FRAMEWORKS=OFF \
-DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build SFML-build --config Release --target install
- name: Build CSFML
run: |
cmake -S CSFML -B CSFML-build -G "Unix Makefiles" \
-DCMAKE_C_COMPILER="/usr/bin/clang" \
-DCMAKE_CXX_COMPILER="/usr/bin/clang++" \
-DCMAKE_C_FLAGS="-stdlib=libc++" \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
"-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/CSFML-install" \
-DCMAKE_OSX_ARCHITECTURES=x86_64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \
"-DSFML_ROOT=$GITHUB_WORKSPACE/SFML-install" \
-DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build CSFML-build --config Release --target install
- name: Create Archive
run: |
mkdir CSFML-macOS-clang-64-bit
cp -R CSFML-install/include CSFML-macOS-clang-64-bit
cp -R CSFML-install/lib CSFML-macOS-clang-64-bit
cp CSFML-install/share/CSFML/* CSFML-macOS-clang-64-bit
tar -zcvf CSFML-macOS-clang-64-bit.tar.gz CSFML-macOS-clang-64-bit
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: CSFML-macOS-clang-64-bit
path: CSFML-macOS-clang-64-bit.tar.gz
macos-arm64:
name: macOS ARM64
runs-on: macos-15
steps:
- name: Checkout SFML
uses: actions/checkout@v7
with:
persist-credentials: false
repository: SFML/SFML
ref: ${{ env.SFML_VERSION }}
path: SFML
- name: Checkout CSFML
uses: actions/checkout@v7
with:
persist-credentials: false
path: CSFML
- name: Build SFML
run: |
cmake -S SFML -B SFML-build -G "Unix Makefiles" \
-DCMAKE_C_COMPILER="/usr/bin/clang" \
-DCMAKE_CXX_COMPILER="/usr/bin/clang++" \
-DCMAKE_C_FLAGS="-stdlib=libc++" \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
"-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/SFML-install" \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-DSFML_BUILD_FRAMEWORKS=OFF \
-DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build SFML-build --config Release --target install
- name: Build CSFML
run: |
cmake -S CSFML -B CSFML-build -G "Unix Makefiles" \
-DCMAKE_C_COMPILER="/usr/bin/clang" \
-DCMAKE_CXX_COMPILER="/usr/bin/clang++" \
-DCMAKE_C_FLAGS="-stdlib=libc++" \
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
"-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/CSFML-install" \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
"-DSFML_ROOT=$GITHUB_WORKSPACE/SFML-install" \
-DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build CSFML-build --config Release --target install
- name: Create Archive
run: |
mkdir CSFML-macOS-clang-arm64
cp -R CSFML-install/include CSFML-macOS-clang-arm64
cp -R CSFML-install/lib CSFML-macOS-clang-arm64
cp CSFML-install/share/CSFML/* CSFML-macOS-clang-arm64
tar -zcvf CSFML-macOS-clang-arm64.tar.gz CSFML-macOS-clang-arm64
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: CSFML-macOS-clang-arm64
path: CSFML-macOS-clang-arm64.tar.gz
+4 -42
View File
@@ -1,45 +1,7 @@
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
# Build folders
build/
cmake-build-*/
# Cache/IDE folders
.cache/
.vscode/
.idea/
.vs/
# System files
.DS_Store
.vscode/
build/
cmake-build-*/
CMakeUserPresets.json
+58 -31
View File
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.7.2)
cmake_minimum_required(VERSION 3.28)
# define a macro that helps defining an option
macro(csfml_set_option var default type docstring)
@@ -13,7 +13,7 @@ endmacro()
csfml_set_option(CMAKE_BUILD_TYPE Release STRING "Choose the type of build (Debug or Release)")
# project name
project(CSFML VERSION 2.6.1)
project(CSFML VERSION 3.1.0)
# we use the paths from the cmake GNUInstallDirs module as defaults
# you can override these if you like
@@ -24,59 +24,64 @@ include(GNUInstallDirs)
include(${PROJECT_SOURCE_DIR}/cmake/Config.cmake)
# add options to select which modules to build
csfml_set_option(CSFML_BUILD_WINDOW TRUE BOOL "TRUE to build CSFML's Window module. This setting is ignored, if the graphics module is built.")
csfml_set_option(CSFML_BUILD_GRAPHICS TRUE BOOL "TRUE to build CSFML's Graphics module.")
csfml_set_option(CSFML_BUILD_AUDIO TRUE BOOL "TRUE to build CSFML's Audio module.")
csfml_set_option(CSFML_BUILD_NETWORK TRUE BOOL "TRUE to build CSFML's Network module.")
csfml_set_option(CSFML_BUILD_WINDOW ON BOOL "ON to build CSFML's Window module. This setting is ignored, if the graphics module is built.")
csfml_set_option(CSFML_BUILD_GRAPHICS ON BOOL "ON to build CSFML's Graphics module.")
csfml_set_option(CSFML_BUILD_AUDIO ON BOOL "ON to build CSFML's Audio module.")
csfml_set_option(CSFML_BUILD_NETWORK ON BOOL "ON to build CSFML's Network module.")
# add an option for choosing the build type (shared or static)
csfml_set_option(BUILD_SHARED_LIBS TRUE BOOL "TRUE to build CSFML as shared libraries, FALSE to build it as static libraries")
csfml_set_option(BUILD_SHARED_LIBS ON BOOL "ON to build CSFML as shared libraries, OFF to build it as static libraries")
# add an option for building the API documentation
csfml_set_option(CSFML_BUILD_DOC FALSE BOOL "TRUE to generate the API documentation, FALSE to ignore it")
csfml_set_option(CSFML_BUILD_DOC OFF BOOL "ON to generate the API documentation, OFF to ignore it")
# add an option for linking to sfml either statically or dynamically
# default on windows to static and on other platforms to dynamic
if(SFML_OS_WINDOWS)
set(LINK_STATICALLY_DEFAULT TRUE)
set(LINK_STATICALLY_DEFAULT ON)
else()
set(LINK_STATICALLY_DEFAULT FALSE)
set(LINK_STATICALLY_DEFAULT OFF)
endif()
csfml_set_option(CSFML_LINK_SFML_STATICALLY ${LINK_STATICALLY_DEFAULT} BOOL "TRUE to link to a static version of SFML, FALSE to link dynamically")
# disable the rpath stuff
set(CMAKE_SKIP_BUILD_RPATH TRUE)
csfml_set_option(CSFML_LINK_SFML_STATICALLY ${LINK_STATICALLY_DEFAULT} BOOL "ON to link to a static version of SFML, OFF to link dynamically")
# define an option for choosing between static and dynamic C runtime (Windows only)
if(SFML_OS_WINDOWS)
set(STATIC_STD_LIBS FALSE CACHE BOOL "TRUE to statically link to the standard libraries, FALSE to use them as DLLs")
# for VC++, we can apply it globally by modifying the compiler flags
if(SFML_COMPILER_MSVC AND STATIC_STD_LIBS)
foreach(flag
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
endif()
endforeach()
endif()
csfml_set_option(CSFML_USE_STATIC_STD_LIBS OFF BOOL "ON to statically link to the standard libraries, OFF to use them as DLLs")
endif()
# find SFML libraries (C++)
if(CSFML_LINK_SFML_STATICALLY)
set(SFML_STATIC_LIBRARIES ON)
endif()
set(SFML_MODULES "System")
if(CSFML_BUILD_AUDIO)
list(PREPEND SFML_MODULES "Audio")
endif()
if(CSFML_BUILD_GRAPHICS)
list(PREPEND SFML_MODULES "Graphics")
endif()
if(CSFML_BUILD_WINDOW)
list(PREPEND SFML_MODULES "Window")
endif()
if(CSFML_BUILD_NETWORK)
list(PREPEND SFML_MODULES "Network")
endif()
find_package(SFML 3.1 COMPONENTS ${SFML_MODULES} REQUIRED)
# add the subdirectories
add_subdirectory(src/SFML)
add_subdirectory(src/CSFML)
if(CSFML_BUILD_DOC)
add_subdirectory(doc)
endif()
# on Linux and BSD-like OS, install pkg-config files by default
set(CSFML_INSTALL_PKGCONFIG_DEFAULT FALSE)
set(CSFML_INSTALL_PKGCONFIG_DEFAULT OFF)
if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD)
set(CSFML_INSTALL_PKGCONFIG_DEFAULT TRUE)
set(CSFML_INSTALL_PKGCONFIG_DEFAULT ON)
endif()
csfml_set_option(CSFML_INSTALL_PKGCONFIG_FILES ${CSFML_INSTALL_PKGCONFIG_DEFAULT} BOOL "TRUE to automatically install pkg-config files so other projects can find SFML")
csfml_set_option(CSFML_INSTALL_PKGCONFIG_FILES ${CSFML_INSTALL_PKGCONFIG_DEFAULT} BOOL "ON to automatically install pkg-config files so other projects can find SFML")
if(CSFML_INSTALL_PKGCONFIG_FILES)
csfml_set_option(CSFML_PKGCONFIG_INSTALL_DIR "${CSFML_PKGCONFIG_DIR}" PATH "Install directory for CSFML's pkg-config .pc files")
@@ -98,8 +103,30 @@ install(DIRECTORY include/
install(FILES license.md DESTINATION ${INSTALL_MISC_DIR})
install(FILES readme.md DESTINATION ${INSTALL_MISC_DIR})
# stop configuration if consuming CSFML as a subdirectory
if(NOT PROJECT_IS_TOP_LEVEL)
return()
endif()
# add an option for building the examples
csfml_set_option(CSFML_BUILD_EXAMPLES FALSE BOOL "TRUE to build the CSFML examples, FALSE to ignore them")
csfml_set_option(CSFML_BUILD_EXAMPLES OFF BOOL "ON to build the CSFML examples, OFF to ignore them")
if(CSFML_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
# add an option for building the tests
csfml_set_option(CSFML_BUILD_TEST_SUITE OFF BOOL "ON to build the CSFML test suite, OFF to ignore it")
if(CSFML_BUILD_TEST_SUITE)
enable_testing()
add_subdirectory(test)
endif()
csfml_set_option(CLANG_FORMAT_EXECUTABLE clang-format STRING "Override clang-format executable, requires version 17")
add_custom_target(format
COMMAND ${CMAKE_COMMAND} -DCLANG_FORMAT_EXECUTABLE=${CLANG_FORMAT_EXECUTABLE} -P ./cmake/Format.cmake
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} VERBATIM)
csfml_set_option(CLANG_TIDY_EXECUTABLE clang-tidy STRING "Override clang-tidy executable, requires minimum version 14")
add_custom_target(tidy
COMMAND ${CMAKE_COMMAND} -DCLANG_TIDY_EXECUTABLE=${CLANG_TIDY_EXECUTABLE} -DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR} -P ./cmake/Tidy.cmake
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} VERBATIM)
+19
View File
@@ -0,0 +1,19 @@
{
"version": 3,
"configurePresets":[
{
"name": "dev",
"binaryDir": "build",
"installDir": "${sourceDir}/build/install",
"cacheVariables": {
"CMAKE_C_EXTENSIONS": "OFF",
"CMAKE_CXX_EXTENSIONS": "OFF",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_RUNTIME_OUTPUT_DIRECTORY": "${sourceDir}/build/bin",
"CSFML_BUILD_EXAMPLES": "ON",
"CSFML_BUILD_TEST_SUITE": "ON",
"CSFML_WARNINGS_AS_ERRORS": "ON"
}
}
]
}
+11 -17
View File
@@ -2,9 +2,9 @@
#
# https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md
# Helper function to enable compiler warnings for a specific set of files
function(set_file_warnings)
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" FALSE)
# Helper function to enable compiler warnings for a specific target
function(set_target_warnings target)
option(CSFML_WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF)
set(MSVC_WARNINGS
/W4 # Baseline reasonable warnings
@@ -27,13 +27,11 @@ function(set_file_warnings)
/w14905 # wide string literal cast to 'LPSTR'
/w14906 # string literal cast to 'LPWSTR'
/w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied
# /permissive- # standards conformance mode for MSVC compiler. Disabled until all out-of-the-box Windows SDKs can successfully build with it.
/permissive- # standards conformance mode for MSVC compiler
# Disables, remove when appropriate
/wd4996 # disable warnings about deprecated functions
/wd4068 # disable warnings about unknown pragmas (e.g. #pragma GCC)
/wd4505 # disable warnings about unused functions that might be platform-specific
/wd4800 # disable warnings regarding implicit conversions to bool
/wd5105 # disable warning about expansion of 'defined' keyword
)
set(CLANG_AND_GCC_WARNINGS
@@ -57,18 +55,17 @@ function(set_file_warnings)
# Disable warnings as errors when using Clang on Windows to work around deprecation warnings in Windows APIs
if(SFML_OS_WINDOWS AND (SFML_COMPILER_CLANG OR SFML_COMPILER_CLANG_CL))
set(WARNINGS_AS_ERRORS FALSE)
set(CSFML_WARNINGS_AS_ERRORS OFF)
endif()
if(WARNINGS_AS_ERRORS)
set(CLANG_AND_GCC_WARNINGS ${CLANG_AND_GCC_WARNINGS} -Werror)
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
if(CSFML_WARNINGS_AS_ERRORS)
list(APPEND CLANG_AND_GCC_WARNINGS -Werror)
list(APPEND MSVC_WARNINGS /WX)
endif()
set(CLANG_WARNINGS
${CLANG_AND_GCC_WARNINGS}
-Wno-unknown-warning-option # do not warn on GCC-specific warning diagnostic pragmas
-Wno-c++11-long-long # do not warn on uses of long long
)
set(GCC_WARNINGS
@@ -82,8 +79,7 @@ function(set_file_warnings)
# Don't enable -Wduplicated-branches for GCC < 8.1 since it will lead to false positives
# https://github.com/gcc-mirror/gcc/commit/6bebae75035889a4844eb4d32a695bebf412bcd7
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1)
set(GCC_WARNINGS
${GCC_WARNINGS}
list(APPEND GCC_WARNINGS
-Wduplicated-branches # warn if if / else branches have duplicated code
)
endif()
@@ -98,7 +94,5 @@ function(set_file_warnings)
message(AUTHOR_WARNING "No compiler warnings set for '${CMAKE_CXX_COMPILER_ID}' compiler.")
endif()
foreach(WARNING ${FILE_WARNINGS})
set_property(SOURCE ${ARGV} APPEND_STRING PROPERTY COMPILE_FLAGS " ${WARNING}")
endforeach()
target_compile_options(${target} PRIVATE ${FILE_WARNINGS})
endfunction()
+1 -32
View File
@@ -1,32 +1,12 @@
# detect the OS
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(SFML_OS_WINDOWS 1)
# detect the architecture (note: this test won't work for cross-compilation)
include(CheckTypeSize)
check_type_size(void* SIZEOF_VOID_PTR)
if("${SIZEOF_VOID_PTR}" STREQUAL "4")
set(ARCH_32BITS 1)
elseif("${SIZEOF_VOID_PTR}" STREQUAL "8")
set(ARCH_64BITS 1)
else()
message(FATAL_ERROR "Unsupported architecture")
return()
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(SFML_OS_LINUX 1)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(SFML_OS_FREEBSD 1)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(SFML_OS_MACOSX 1)
# detect OS X version. (use '/usr/bin/sw_vers -productVersion' to extract V from '10.V.x'.)
EXEC_PROGRAM(/usr/bin/sw_vers ARGS -productVersion OUTPUT_VARIABLE MACOSX_VERSION_RAW)
STRING(REGEX REPLACE "10\\.([0-9]+).*" "\\1" MACOSX_VERSION "${MACOSX_VERSION_RAW}")
if(${MACOSX_VERSION} LESS 5)
message(FATAL_ERROR "Unsupported version of OS X : ${MACOSX_VERSION_RAW}")
return()
endif()
else()
message(FATAL_ERROR "Unsupported operating system")
return()
@@ -52,24 +32,13 @@ if(MSVC)
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(SFML_COMPILER_CLANG 1)
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE CLANG_VERSION_OUTPUT)
string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" SFML_CLANG_VERSION "${CLANG_VERSION_OUTPUT}")
elseif(CMAKE_COMPILER_IS_GNUCXX)
set(SFML_COMPILER_GCC 1)
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" SFML_GCC_VERSION "${GCC_VERSION_OUTPUT}")
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE GCC_COMPILER_VERSION)
string(REGEX MATCHALL ".*(tdm[64]*-[1-9]).*" SFML_COMPILER_GCC_TDM "${GCC_COMPILER_VERSION}")
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE)
string(STRIP "${GCC_MACHINE}" GCC_MACHINE)
if(GCC_MACHINE MATCHES ".*w64.*")
set(SFML_COMPILER_GCC_W64 1)
endif()
else()
message(FATAL_ERROR "Unsupported compiler")
message(WARNING "Unsupported compiler")
return()
endif()
+27
View File
@@ -0,0 +1,27 @@
# Check executable exists
if(NOT EXISTS ${CLANG_FORMAT_EXECUTABLE})
find_program(CLANG_FORMAT_EXEC_TEMP ${CLANG_FORMAT_EXECUTABLE})
if(CLANG_FORMAT_EXEC_TEMP)
set(CLANG_FORMAT_EXECUTABLE ${CLANG_FORMAT_EXEC_TEMP})
unset(CLANG_FORMAT_EXEC_TEMP)
else()
message(FATAL_ERROR "Unable to find clang-format executable: \"${CLANG_FORMAT_EXECUTABLE}\"")
endif()
endif()
# Check executable version
execute_process(COMMAND ${CLANG_FORMAT_EXECUTABLE} --version OUTPUT_VARIABLE CLANG_FORMAT_VERSION)
string(REGEX MATCH "clang-format version ([0-9]+)" CLANG_FORMAT_VERSION ${CLANG_FORMAT_VERSION})
unset(CLANG_FORMAT_VERSION)
if(NOT CMAKE_MATCH_1 EQUAL 17)
message(FATAL_ERROR "clang-format version ${CMAKE_MATCH_1} not supported. Must use version 17")
endif()
# Run
set(SOURCES "")
foreach(FOLDER IN ITEMS examples include src test)
file(GLOB_RECURSE folder_files "${FOLDER}/*.h" "${FOLDER}/*.hpp" "${FOLDER}/*.c" "${FOLDER}/*.cpp")
list(APPEND SOURCES ${folder_files})
endforeach()
execute_process(COMMAND ${CLANG_FORMAT_EXECUTABLE} -i ${SOURCES})
+36 -23
View File
@@ -17,25 +17,38 @@ macro(csfml_add_library target)
target_include_directories(${target} PUBLIC ${PROJECT_SOURCE_DIR}/include)
# add warnings
set_file_warnings(${THIS_SOURCES})
set_target_warnings(${target})
# require C11 and C++17
target_compile_features(${target} PUBLIC c_std_11 cxx_std_17)
# define the export symbol of the module
string(REPLACE "-" "_" NAME_UPPER "${target}")
string(TOUPPER "${NAME_UPPER}" NAME_UPPER)
set_target_properties(${target} PROPERTIES DEFINE_SYMBOL ${NAME_UPPER}_EXPORTS)
if(SFML_OS_WINDOWS)
# include the major version number in Windows shared library names (but not import library names)
if(BUILD_SHARED_LIBS)
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
set_target_properties(${target} PROPERTIES SUFFIX "-${PROJECT_VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}")
if(SFML_OS_WINDOWS)
# include the major version number in Windows shared library names (but not import library names)
set_target_properties(${target} PROPERTIES SUFFIX "-${PROJECT_VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}")
# on Windows/gcc get rid of "lib" prefix for shared libraries,
# and transform the ".dll.a" suffix into ".a" for import libraries
if (SFML_COMPILER_GCC OR SFML_COMPILER_CLANG)
set_target_properties(${target} PROPERTIES PREFIX "")
set_target_properties(${target} PROPERTIES IMPORT_SUFFIX ".a")
endif()
endif()
else()
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
endif()
if (SFML_OS_WINDOWS AND SFML_COMPILER_GCC)
# on Windows/gcc get rid of "lib" prefix for shared libraries,
# and transform the ".dll.a" suffix into ".a" for import libraries
set_target_properties(${target} PROPERTIES PREFIX "")
set_target_properties(${target} PROPERTIES IMPORT_SUFFIX ".a")
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -s-d)
set_target_properties(${target} PROPERTIES RELEASE_POSTFIX -s)
set_target_properties(${target} PROPERTIES MINSIZEREL_POSTFIX -s)
set_target_properties(${target} PROPERTIES RELWITHDEBINFO_POSTFIX -s)
if(CSFML_USE_STATIC_STD_LIBS)
set_property(TARGET ${target} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()
# set the version and soversion of the target (for compatible systems -- mostly Linuxes)
@@ -45,20 +58,17 @@ macro(csfml_add_library target)
# set the target's folder (for IDEs that support it, e.g. Visual Studio)
set_target_properties(${target} PROPERTIES FOLDER "CSFML")
# for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4")
if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
# apply the CSFML_USE_STATIC_STD_LIBS option if it is enabled
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC)
if(CSFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
elseif(NOT SFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM)
elseif(NOT CSFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM)
set_target_properties(${target} PROPERTIES LINK_FLAGS "-shared-libgcc -shared-libstdc++")
endif()
endif()
# if using gcc >= 4.0 or clang >= 3.0 on a non-Windows platform, we must hide public symbols by default
# (exported ones are explicitely marked)
if(NOT SFML_OS_WINDOWS AND ((SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4") OR (SFML_COMPILER_CLANG AND NOT SFML_CLANG_VERSION VERSION_LESS "3")))
set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fvisibility=hidden)
endif()
# ensure public symbols are hidden by default (exported ones are explicitly marked)
set_target_properties(${target} PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN YES)
# link the target to its external dependencies (C++ SFML libraries)
target_link_libraries(${target} PRIVATE ${THIS_DEPENDS})
@@ -66,9 +76,7 @@ macro(csfml_add_library target)
# build dylibs
if(SFML_OS_MACOSX AND BUILD_SHARED_LIBS)
# adapt install directory to allow distributing dylibs in user’s application bundle
set_target_properties(${target} PROPERTIES
BUILD_WITH_INSTALL_RPATH 1
INSTALL_NAME_DIR "@rpath")
set_target_properties(${target} PROPERTIES INSTALL_NAME_DIR "@rpath")
endif()
# add the install rule
@@ -77,4 +85,9 @@ macro(csfml_add_library target)
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel)
# define CSFML_STATIC if the build type is not set to 'shared'
if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(${target} PUBLIC CSFML_STATIC)
endif()
endmacro()
+34
View File
@@ -0,0 +1,34 @@
# Check executable exists
if(NOT EXISTS ${CLANG_TIDY_EXECUTABLE})
find_program(CLANG_TIDY_EXEC_TEMP ${CLANG_TIDY_EXECUTABLE})
if(CLANG_TIDY_EXEC_TEMP)
set(CLANG_TIDY_EXECUTABLE ${CLANG_TIDY_EXEC_TEMP})
unset(CLANG_TIDY_EXEC_TEMP)
else()
message(FATAL_ERROR "Unable to find clang-tidy executable: \"${CLANG_TIDY_EXECUTABLE}\"")
endif()
endif()
# Check executable version
execute_process(COMMAND ${CLANG_TIDY_EXECUTABLE} --version OUTPUT_VARIABLE CLANG_TIDY_VERSION)
string(REGEX MATCH "version ([0-9]+)" CLANG_TIDY_VERSION ${CLANG_TIDY_VERSION})
unset(CLANG_TIDY_VERSION)
if(CMAKE_MATCH_1 GREATER_EQUAL 14)
message(STATUS "Using clang-tidy version ${CMAKE_MATCH_1}")
else()
message(FATAL_ERROR "clang-tidy version ${CMAKE_MATCH_1} is too low")
endif()
# Find Python and run-clang-tidy script
find_package(Python 3 REQUIRED)
find_program(RUN_CLANG_TIDY run-clang-tidy)
if(NOT RUN_CLANG_TIDY)
message(FATAL_ERROR "Failed to find run-clang-tidy script")
endif()
# Run
execute_process(COMMAND ${Python_EXECUTABLE} ${RUN_CLANG_TIDY} -clang-tidy-binary ${CLANG_TIDY_EXECUTABLE} -quiet -p ${PROJECT_BINARY_DIR} RESULTS_VARIABLE EXIT_CODE)
if(NOT EXIT_CODE STREQUAL 0)
message(FATAL_ERROR "Analysis failed")
endif()
+10 -20
View File
@@ -1,12 +1,9 @@
# find doxygen
find_package(Doxygen REQUIRED)
# set the input and output documentation paths
set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR})
set(DOXYGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/doc)
# see if we can generate the CHM documentation
set(DOXYGEN_HHC_PROGRAM)
set(DOXYGEN_GENERATE_HTMLHELP NO)
if(SFML_OS_WINDOWS)
# if HHC is found, we can generate the CHM (compressed HTML) output
find_program(DOXYGEN_HHC_PROGRAM
@@ -18,37 +15,30 @@ if(SFML_OS_WINDOWS)
set(DOXYGEN_GENERATE_HTMLHELP YES)
else()
message("Due to conflicts with the HTML output settings in Doxygen ${DOXYGEN_VERSION}, the HTML Help generation will be disabled")
set(DOXYGEN_GENERATE_HTMLHELP NO)
endif()
else()
set(DOXYGEN_GENERATE_HTMLHELP NO)
endif()
else()
set(DOXYGEN_HHC_PROGRAM)
set(DOXYGEN_GENERATE_HTMLHELP NO)
endif()
# configure the source Doxyfile by copying it and replacing all @variables@
set(DOXYGEN_CONFIGURED_INPUT ${DOXYGEN_OUTPUT_DIR}/doxyfile)
configure_file(${DOXYGEN_INPUT_DIR}/doc/doxyfile.in ${DOXYGEN_CONFIGURED_INPUT} @ONLY)
configure_file(${DOXYGEN_INPUT_DIR}/doc/header.html.in ${DOXYGEN_OUTPUT_DIR}/header.html @ONLY)
configure_file(doxyfile.in doxyfile @ONLY)
configure_file(header.html.in header.html @ONLY)
# copy the files needed by the documentation
configure_file(${DOXYGEN_INPUT_DIR}/doc/doxygen.css ${DOXYGEN_OUTPUT_DIR}/html/doxygen.css COPYONLY)
configure_file(${DOXYGEN_INPUT_DIR}/doc/searchOverrides.css ${DOXYGEN_OUTPUT_DIR}/html/searchOverrides.css COPYONLY)
configure_file(doxygen.css html/doxygen.css COPYONLY)
configure_file(searchOverrides.css html/searchOverrides.css COPYONLY)
# target setup
add_custom_target(doc ALL
COMMAND ${CMAKE_COMMAND} -E echo_append "Building API Documentation..."
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_CONFIGURED_INPUT}
COMMAND Doxygen::doxygen ${CMAKE_CURRENT_BINARY_DIR}/doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "Done."
WORKING_DIRECTORY ${DOXYGEN_INPUT_DIR})
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
# setup install rules
install(DIRECTORY ${DOXYGEN_OUTPUT_DIR}/html
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
DESTINATION ${INSTALL_MISC_DIR}/doc
COMPONENT doc)
if(DOXYGEN_HHC_PROGRAM)
if(DOXYGEN_GENERATE_HTMLHELP)
install(FILES ${DOXYGEN_OUTPUT_DIR}/CSFML.chm
DESTINATION ${INSTALL_MISC_DIR}/doc
COMPONENT doc)
+9 -9
View File
@@ -74,7 +74,7 @@ PROJECT_ICON =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.
OUTPUT_DIRECTORY = "@DOXYGEN_OUTPUT_DIR@"
OUTPUT_DIRECTORY = "@CMAKE_CURRENT_BINARY_DIR@"
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096
# sub-directories (in 2 levels) under the output directory of each output format
@@ -199,7 +199,7 @@ STRIP_FROM_PATH =
# specify the list of include paths that are normally passed to the compiler
# using the -I flag.
STRIP_FROM_INC_PATH = "@DOXYGEN_INPUT_DIR@/include"
STRIP_FROM_INC_PATH = "@PROJECT_SOURCE_DIR@/include"
# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
# less readable) file names. This can be useful is your file systems doesn't
@@ -924,7 +924,7 @@ WARN_IF_UNDOC_ENUM_VAL = NO
# Possible values are: NO, YES, FAIL_ON_WARNINGS and FAIL_ON_WARNINGS_PRINT.
# The default value is: NO.
WARN_AS_ERROR = NO
WARN_AS_ERROR = YES
# The WARN_FORMAT tag determines the format of the warning messages that doxygen
# can produce. The string should contain the $file, $line, and $text tags, which
@@ -966,8 +966,8 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
INPUT = "@DOXYGEN_INPUT_DIR@/include/SFML" \
"@DOXYGEN_INPUT_DIR@/doc/mainpage.hpp"
INPUT = "@PROJECT_SOURCE_DIR@/include/CSFML" \
"@PROJECT_SOURCE_DIR@/doc/mainpage.hpp"
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -1341,7 +1341,7 @@ HTML_FILE_EXTENSION = .html
# of the possible markers and block names see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_HEADER = "@DOXYGEN_OUTPUT_DIR@/header.html"
HTML_HEADER = "@CMAKE_CURRENT_BINARY_DIR@/header.html"
# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
# generated HTML page. If the tag is left blank doxygen will generate a standard
@@ -1351,7 +1351,7 @@ HTML_HEADER = "@DOXYGEN_OUTPUT_DIR@/header.html"
# that doxygen normally uses.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_FOOTER = "@DOXYGEN_INPUT_DIR@/doc/footer.html"
HTML_FOOTER = "@PROJECT_SOURCE_DIR@/doc/footer.html"
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
# sheet that is used by each HTML page. It can be used to fine-tune the look of
@@ -1363,7 +1363,7 @@ HTML_FOOTER = "@DOXYGEN_INPUT_DIR@/doc/footer.html"
# obsolete.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_STYLESHEET = "@DOXYGEN_INPUT_DIR@/doc/doxygen.css"
HTML_STYLESHEET = "@PROJECT_SOURCE_DIR@/doc/doxygen.css"
# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
# cascading style sheets that are included after the standard style sheets
@@ -2491,7 +2491,7 @@ TAGFILES =
# tag file that is based on the input files it reads. See section "Linking to
# external documentation" for more information about the usage of tag files.
GENERATE_TAGFILE = @DOXYGEN_OUTPUT_DIR@/CSFML.tag
GENERATE_TAGFILE = @CMAKE_CURRENT_BINARY_DIR@/CSFML.tag
# If the ALLEXTERNALS tag is set to YES, all external classes and namespaces
# will be listed in the class and namespace index. If set to NO, only the
+15 -16
View File
@@ -12,12 +12,12 @@
///
/// \code
///
/// #include <SFML/Audio.h>
/// #include <SFML/Graphics.h>
///
/// #include <CSFML/Audio.h>
/// #include <CSFML/Graphics.h>
///
/// int main()
/// {
/// sfVideoMode mode = {800, 600, 32};
/// sfVideoMode mode = {{800, 600}, 32};
/// sfRenderWindow* window;
/// sfTexture* texture;
/// sfSprite* sprite;
@@ -36,17 +36,16 @@
/// if (!texture)
/// return EXIT_FAILURE;
/// sprite = sfSprite_create();
/// sfSprite_setTexture(sprite, texture, sfTrue);
///
/// sfSprite_setTexture(sprite, texture, true);
///
/// /* Create a graphical text to display */
/// font = sfFont_createFromFile("arial.ttf");
/// if (!font)
/// return EXIT_FAILURE;
/// text = sfText_create();
/// text = sfText_create(font);
/// sfText_setString(text, "Hello SFML");
/// sfText_setFont(text, font);
/// sfText_setCharacterSize(text, 50);
///
///
/// /* Load a music to play */
/// music = sfMusic_createFromFile("nice_music.ogg");
/// if (!music)
@@ -54,7 +53,7 @@
///
/// /* Play the music */
/// sfMusic_play(music);
///
///
/// /* Start the game loop */
/// while (sfRenderWindow_isOpen(window))
/// {
@@ -65,20 +64,20 @@
/// if (event.type == sfEvtClosed)
/// sfRenderWindow_close(window);
/// }
///
///
/// /* Clear the screen */
/// sfRenderWindow_clear(window, sfBlack);
///
///
/// /* Draw the sprite */
/// sfRenderWindow_drawSprite(window, sprite, NULL);
///
///
/// /* Draw the text */
/// sfRenderWindow_drawText(window, text, NULL);
///
///
/// /* Update the window */
/// sfRenderWindow_display(window);
/// }
///
///
/// /* Cleanup resources */
/// sfMusic_destroy(music);
/// sfText_destroy(text);
@@ -86,7 +85,7 @@
/// sfSprite_destroy(sprite);
/// sfTexture_destroy(texture);
/// sfRenderWindow_destroy(window);
///
///
/// return EXIT_SUCCESS;
/// }
/// \endcode
+2 -4
View File
@@ -1,5 +1,3 @@
set(SRC example.c)
add_executable(example ${SRC})
add_executable(example example.c)
target_link_libraries(example PRIVATE csfml-graphics csfml-audio)
set_file_warnings(${SRC})
set_target_warnings(example)
+8 -10
View File
@@ -1,30 +1,29 @@
#include <SFML/Audio.h>
#include <SFML/Graphics.h>
#include <CSFML/Audio.h>
#include <CSFML/Graphics.h>
#include <stdlib.h>
int main(void)
{
// Create the main window
const sfVideoMode mode = {800, 600, 32};
sfRenderWindow* window = sfRenderWindow_create(mode, "SFML window", sfResize | sfClose, NULL);
const sfVideoMode mode = {{800, 600}, 32};
sfRenderWindow* window = sfRenderWindow_create(mode, "SFML window", sfResize | sfClose, sfWindowed, NULL);
if (!window)
return EXIT_FAILURE;
// Load a sprite to display
sfTexture* texture = sfTexture_createFromFile("sfml_logo.png", NULL);
const sfTexture* texture = sfTexture_createFromFile("sfml_logo.png", NULL);
if (!texture)
{
sfRenderWindow_destroy(window);
return EXIT_FAILURE;
}
sfSprite* sprite = sfSprite_create();
sfSprite_setTexture(sprite, texture, sfTrue);
sfSprite* sprite = sfSprite_create(texture);
const sfVector2f spritePosition = {200, 200};
sfSprite_setPosition(sprite, spritePosition);
// Create a graphical text to display
sfFont* font = sfFont_createFromFile("tuffy.ttf");
const sfFont* font = sfFont_createFromFile("tuffy.ttf");
if (!font)
{
sfSprite_destroy(sprite);
@@ -32,9 +31,8 @@ int main(void)
sfRenderWindow_destroy(window);
return EXIT_FAILURE;
}
sfText* text = sfText_create();
sfText* text = sfText_create(font);
sfText_setString(text, "Hello, SFML!");
sfText_setFont(text, font);
sfText_setCharacterSize(text, 50);
// Load a music to play
+40
View File
@@ -0,0 +1,40 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <CSFML/Audio/Listener.h>
#include <CSFML/Audio/Music.h>
#include <CSFML/Audio/PlaybackDevice.h>
#include <CSFML/Audio/Sound.h>
#include <CSFML/Audio/SoundBuffer.h>
#include <CSFML/Audio/SoundBufferRecorder.h>
#include <CSFML/Audio/SoundRecorder.h>
#include <CSFML/Audio/SoundStatus.h>
#include <CSFML/Audio/SoundStream.h>
#include <CSFML/System.h>
+106
View File
@@ -0,0 +1,106 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
/// \brief Callable that is provided with sound data for processing
///
/// When the audio engine sources sound data from sound
/// sources it will pass the data through an effects
/// processor if one is set. The sound data will already be
/// converted to the internal floating point format.
///
/// Sound data that is processed this way is provided in
/// frames. Each frame contains 1 floating point sample per
/// channel. If e.g. the data source provides stereo data,
/// each frame will contain 2 floats.
///
/// The effects processor function takes 4 parameters:
/// - The input data frames, channels interleaved
/// - The number of input data frames available
/// - The buffer to write output data frames to, channels interleaved
/// - The number of output data frames that the output buffer can hold
/// - The channel count
///
/// The input and output frame counts are in/out parameters.
///
/// When this function is called, the input count will
/// contain the number of frames available in the input
/// buffer. The output count will contain the size of the
/// output buffer i.e. the maximum number of frames that
/// can be written to the output buffer.
///
/// Attempting to read more frames than the input frame
/// count or write more frames than the output frame count
/// will result in undefined behaviour.
///
/// It is important to note that the channel count of the
/// audio engine currently sourcing data from this sound
/// will always be provided in `frameChannelCount`. This can
/// be different from the channel count of the sound source
/// so make sure to size necessary processing buffers
/// according to the engine channel count and not the sound
/// source channel count.
///
/// When done processing the frames, the input and output
/// frame counts must be updated to reflect the actual
/// number of frames that were read from the input and
/// written to the output.
///
/// The processing function should always try to process as
/// much sound data as possible i.e. always try to fill the
/// output buffer to the maximum. In certain situations for
/// specific effects it can be possible that the input frame
/// count and output frame count aren't equal. As long as
/// the frame counts are updated accordingly this is
/// perfectly valid.
///
/// If the audio engine determines that no audio data is
/// available from the data source, the input data frames
/// pointer is set to `NULL` and the input frame count is
/// set to 0. In this case it is up to the function to
/// decide how to handle the situation. For specific effects
/// e.g. Echo/Delay buffered data might still be able to be
/// written to the output buffer even if there is no longer
/// any input data.
///
/// An important thing to remember is that this function is
/// directly called by the audio engine. Because the audio
/// engine runs on an internal thread of its own, make sure
/// access to shared data is synchronized appropriately.
///
/// Because this function is stored by the `SoundSource`
/// object it will be able to be called as long as the
/// `SoundSource` object hasn't yet been destroyed. Make sure
/// that any data this function references outlives the
/// SoundSource object otherwise use-after-free errors will
/// occur.
///
////////////////////////////////////////////////////////////
typedef void (*sfEffectProcessor)(const float* inputFrames,
unsigned int* inputFrameCount,
float* outputFrames,
unsigned int* outputFrameCount,
unsigned int frameChannelCount);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,13 +22,12 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_AUDIO_EXPORT_H
#define SFML_AUDIO_EXPORT_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <CSFML/Config.h>
////////////////////////////////////////////////////////////
@@ -36,13 +35,10 @@
////////////////////////////////////////////////////////////
#if defined(CSFML_AUDIO_EXPORTS)
#define CSFML_AUDIO_API CSFML_API_EXPORT
#define CSFML_AUDIO_API CSFML_API_EXPORT
#else
#define CSFML_AUDIO_API CSFML_API_IMPORT
#define CSFML_AUDIO_API CSFML_API_IMPORT
#endif
#endif // SFML_AUDIO_EXPORT_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,14 +22,33 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_LISTENER_H
#define SFML_LISTENER_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.h>
#include <SFML/System/Vector3.h>
#include <CSFML/Audio/Export.h>
#include <CSFML/System/Vector3.h>
////////////////////////////////////////////////////////////
/// \brief Structure defining the properties of a directional cone
///
/// Sounds will play at gain 1 when they are positioned
/// within the inner angle of the cone. Sounds will play
/// at `outerGain` when they are positioned outside the
/// outer angle of the cone. The gain declines linearly
/// from 1 to `outerGain` as the sound moves from the inner
/// angle to the outer angle.
///
////////////////////////////////////////////////////////////
typedef struct
{
float innerAngle; //!< Inner angle, in degrees
float outerAngle; //!< Outer angle, in degrees
float outerGain; //!< Outer gain
} sfListenerCone;
////////////////////////////////////////////////////////////
@@ -93,6 +112,43 @@ CSFML_AUDIO_API void sfListener_setDirection(sfVector3f direction);
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfVector3f sfListener_getDirection(void);
////////////////////////////////////////////////////////////
/// \brief Set the velocity of the listener in the scene
///
/// The default listener's velocity is (0, 0, -1).
///
/// \param velocity New listener's velocity
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfListener_setVelocity(sfVector3f velocity);
////////////////////////////////////////////////////////////
/// \brief Get the current forward vector of the listener in the scene
///
/// \return Listener's velocity
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfVector3f sfListener_getVelocity(void);
////////////////////////////////////////////////////////////
/// \brief Set the cone properties of the listener in the audio scene
///
/// The cone defines how directional attenuation is applied.
/// The default cone of a sound is (2 * PI, 2 * PI, 1).
///
/// \param cone Cone properties of the listener in the scene
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfListener_setCone(sfListenerCone cone);
////////////////////////////////////////////////////////////
/// \brief Get the cone properties of the listener in the audio scene
///
/// \return Cone properties of the listener
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfListenerCone sfListener_getCone(void);
////////////////////////////////////////////////////////////
/// \brief Set the upward vector of the listener in the scene
///
@@ -115,6 +171,3 @@ CSFML_AUDIO_API void sfListener_setUpVector(sfVector3f upVector);
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfVector3f sfListener_getUpVector(void);
#endif // SFML_LISTENER_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,18 +22,22 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_MUSIC_H
#define SFML_MUSIC_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.h>
#include <SFML/Audio/SoundStatus.h>
#include <SFML/Audio/Types.h>
#include <SFML/System/InputStream.h>
#include <SFML/System/Time.h>
#include <SFML/System/Vector3.h>
#include <CSFML/Audio/Export.h>
#include <CSFML/Audio/EffectProcessor.h>
#include <CSFML/Audio/SoundChannel.h>
#include <CSFML/Audio/SoundSourceCone.h>
#include <CSFML/Audio/SoundStatus.h>
#include <CSFML/Audio/Types.h>
#include <CSFML/System/InputStream.h>
#include <CSFML/System/Time.h>
#include <CSFML/System/Vector3.h>
#include <stddef.h>
@@ -103,31 +107,43 @@ CSFML_AUDIO_API sfMusic* sfMusic_createFromStream(sfInputStream* stream);
/// \param music Music to destroy
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_destroy(sfMusic* music);
CSFML_AUDIO_API void sfMusic_destroy(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Set whether or not a music should loop after reaching the end
///
/// If set, the music will restart from beginning after
/// reaching the end and so on, until it is stopped or
/// sfMusic_setLoop(music, sfFalse) is called.
/// sfMusic_setLooping(music, false) is called.
/// The default looping state for musics is false.
///
/// \param music Music object
/// \param loop sfTrue to play in loop, sfFalse to play once
/// \param loop true to play in loop, false to play once
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setLoop(sfMusic* music, sfBool loop);
CSFML_AUDIO_API void sfMusic_setLooping(sfMusic* music, bool loop);
////////////////////////////////////////////////////////////
/// \brief Tell whether or not a music is in loop mode
///
/// \param music Music object
///
/// \return sfTrue if the music is looping, sfFalse otherwise
/// \return true if the music is looping, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfMusic_getLoop(const sfMusic* music);
CSFML_AUDIO_API bool sfMusic_isLooping(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Set the effect processor to be applied to the sound
///
/// The effect processor is a callable that will be called
/// with sound data to be processed.
///
/// \param music Music object
/// \param effectProcessor The effect processor to attach to this sound, attach a null processor to disable processing
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setEffectProcessor(sfMusic* music, sfEffectProcessor effectProcessor);
////////////////////////////////////////////////////////////
/// \brief Get the total duration of a music
@@ -142,6 +158,8 @@ CSFML_AUDIO_API sfTime sfMusic_getDuration(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Get the positions of the of the sound's looping sequence
///
/// \param music Music object
///
/// \return Loop Time position class.
///
/// \warning Since sfMusic_setLoopPoints() performs some adjustments on the
@@ -157,7 +175,7 @@ CSFML_AUDIO_API sfTime sfMusic_getDuration(const sfMusic* music);
CSFML_AUDIO_API sfTimeSpan sfMusic_getLoopPoints(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Sets the beginning and end of the sound's looping sequence using sf::Time
/// \brief Sets the beginning and end of the sound's looping sequence using sfTime
///
/// Loop points allow one to specify a pair of positions such that, when the music
/// is enabled for looping, it will seamlessly seek to the beginning whenever it
@@ -171,6 +189,7 @@ CSFML_AUDIO_API sfTimeSpan sfMusic_getLoopPoints(const sfMusic* music);
/// \warning Setting the loop points while the stream's status is Paused
/// will set its status to Stopped. The playing offset will be unaffected.
///
/// \param music Music object
/// \param timePoints The definition of the loop. Can be any time points within the sound's length
///
/// \see getLoopPoints
@@ -240,6 +259,20 @@ CSFML_AUDIO_API unsigned int sfMusic_getChannelCount(const sfMusic* music);
////////////////////////////////////////////////////////////
CSFML_AUDIO_API unsigned int sfMusic_getSampleRate(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Get the map of position in sample frame to sound channel
///
/// This is used to map a sample in the sample stream to a
/// position during spatialization.
///
/// \param music Music object
/// \param count Pointer to a variable that will be filled with the number of channels in the map
///
/// \return Map of position in sample frame to sound channel
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API const sfSoundChannel* sfMusic_getChannelMap(const sfMusic* music, size_t* count);
////////////////////////////////////////////////////////////
/// \brief Get the current status of a music (stopped, paused, playing)
///
@@ -275,6 +308,20 @@ CSFML_AUDIO_API sfTime sfMusic_getPlayingOffset(const sfMusic* music);
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setPitch(sfMusic* music, float pitch);
////////////////////////////////////////////////////////////
/// \brief Set the pan of the sound
///
/// Using panning, a mono sound can be panned between
/// stereo channels. When the pan is set to -1, the sound
/// is played only on the left channel, when the pan is set
/// to +1, the sound is played only on the right channel.
///
/// \param music Music object
/// \param pan New pan to apply to the sound [-1, +1]
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setPan(sfMusic* music, float pan);
////////////////////////////////////////////////////////////
/// \brief Set the volume of a music
///
@@ -287,6 +334,20 @@ CSFML_AUDIO_API void sfMusic_setPitch(sfMusic* music, float pitch);
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setVolume(sfMusic* music, float volume);
////////////////////////////////////////////////////////////
/// \brief Set whether spatialization of the sound is enabled
///
/// Spatialization is the application of various effects to
/// simulate a sound being emitted at a virtual position in
/// 3D space and exhibiting various physical phenomena such as
/// directional attenuation and doppler shift.
///
/// \param music Music object
/// \param enabled `true` to enable spatialization, `false` to disable
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setSpatializationEnabled(sfMusic* music, bool enabled);
////////////////////////////////////////////////////////////
/// \brief Set the 3D position of a music in the audio scene
///
@@ -300,6 +361,74 @@ CSFML_AUDIO_API void sfMusic_setVolume(sfMusic* music, float volume);
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setPosition(sfMusic* music, sfVector3f position);
////////////////////////////////////////////////////////////
/// \brief Set the 3D direction of the sound in the audio scene
///
/// The direction defines where the sound source is facing
/// in 3D space. It will affect how the sound is attenuated
/// if facing away from the listener.
/// The default direction of a sound is (0, 0, -1).
///
/// \param music Music object
/// \param direction Direction of the sound in the scene
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setDirection(sfMusic* music, sfVector3f direction);
////////////////////////////////////////////////////////////
/// \brief Set the cone properties of the sound in the audio scene
///
/// The cone defines how directional attenuation is applied.
/// The default cone of a sound is (2 * PI, 2 * PI, 1).
///
/// \param music Music object
/// \param cone Cone properties of the sound in the scene
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setCone(sfMusic* music, sfSoundSourceCone cone);
////////////////////////////////////////////////////////////
/// \brief Set the 3D velocity of the sound in the audio scene
///
/// The velocity is used to determine how to doppler shift
/// the sound. Sounds moving towards the listener will be
/// perceived to have a higher pitch and sounds moving away
/// from the listener will be perceived to have a lower pitch.
///
/// \param music Music object
/// \param velocity Velocity of the sound in the scene
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setVelocity(sfMusic* music, sfVector3f velocity);
////////////////////////////////////////////////////////////
/// \brief Set the doppler factor of the sound
///
/// The doppler factor determines how strong the doppler
/// shift will be.
///
/// \param music Music object
/// \param factor New doppler factor to apply to the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setDopplerFactor(sfMusic* music, float factor);
////////////////////////////////////////////////////////////
/// \brief Set the directional attenuation factor of the sound
///
/// Depending on the virtual position of an output channel
/// relative to the listener (such as in surround sound
/// setups), sounds will be attenuated when emitting them
/// from certain channels. This factor determines how strong
/// the attenuation based on output channel position
/// relative to the listener is.
///
/// \param music Music object
/// \param factor New directional attenuation factor to apply to the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setDirectionalAttenuationFactor(sfMusic* music, float factor);
////////////////////////////////////////////////////////////
/// \brief Make a musics's position relative to the listener or absolute
///
@@ -310,10 +439,10 @@ CSFML_AUDIO_API void sfMusic_setPosition(sfMusic* music, sfVector3f position);
/// The default value is false (position is absolute).
///
/// \param music Music object
/// \param relative sfTrue to set the position relative, sfFalse to set it absolute
/// \param relative true to set the position relative, false to set it absolute
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setRelativeToListener(sfMusic* music, sfBool relative);
CSFML_AUDIO_API void sfMusic_setRelativeToListener(sfMusic* music, bool relative);
////////////////////////////////////////////////////////////
/// \brief Set the minimum distance of a music
@@ -331,6 +460,48 @@ CSFML_AUDIO_API void sfMusic_setRelativeToListener(sfMusic* music, sfBool relati
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setMinDistance(sfMusic* music, float distance);
////////////////////////////////////////////////////////////
/// \brief Set the maximum distance of the sound
///
/// The "maximum distance" of a sound is the minimum
/// distance at which it is heard at its minimum volume. Closer
/// than the maximum distance, it will start to fade in according
/// to its attenuation factor.
/// The default value of the maximum distance is the maximum
/// value a float can represent.
///
/// \param music Music object
/// \param distance New maximum distance of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setMaxDistance(sfMusic* music, float distance);
////////////////////////////////////////////////////////////
/// \brief Set the minimum gain of the sound
///
/// When the sound is further away from the listener than
/// the "maximum distance" the attenuated gain is clamped
/// so it cannot go below the minimum gain value.
///
/// \param music Music object
/// \param gain New minimum gain of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setMinGain(sfMusic* music, float gain);
////////////////////////////////////////////////////////////
/// \brief Set the maximum gain of the sound
///
/// When the sound is closer from the listener than
/// the "minimum distance" the attenuated gain is clamped
/// so it cannot go above the maximum gain value.
///
/// \param music Music object
/// \param gain New maximum gain of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfMusic_setMaxGain(sfMusic* music, float gain);
////////////////////////////////////////////////////////////
/// \brief Set the attenuation factor of a music
///
@@ -371,6 +542,26 @@ CSFML_AUDIO_API void sfMusic_setPlayingOffset(sfMusic* music, sfTime timeOffset)
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfMusic_getPitch(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Get the pan of the sound
///
/// \param music Music object
///
/// \return Pan of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfMusic_getPan(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Tell whether spatialization of the sound is enabled
///
/// \param music Music object
///
/// \return `true` if spatialization is enabled, `false` if it's disabled
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API bool sfMusic_isSpatializationEnabled(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Get the volume of a music
///
@@ -391,16 +582,66 @@ CSFML_AUDIO_API float sfMusic_getVolume(const sfMusic* music);
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfVector3f sfMusic_getPosition(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Get the 3D direction of the sound in the audio scene
///
/// \param music Music object
///
/// \return Direction of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfVector3f sfMusic_getDirection(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Get the cone properties of the sound in the audio scene
///
/// \param music Music object
///
/// \return Cone properties of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfSoundSourceCone sfMusic_getCone(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Get the 3D velocity of the sound in the audio scene
///
/// \param music Music object
///
/// \return Velocity of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfVector3f sfMusic_getVelocity(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Get the doppler factor of the sound
///
/// \param music Music object
///
/// \return Doppler factor of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfMusic_getDopplerFactor(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Get the directional attenuation factor of the sound
///
/// \param music Music object
///
/// \return Directional attenuation factor of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfMusic_getDirectionalAttenuationFactor(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Tell whether a music's position is relative to the
/// listener or is absolute
///
/// \param music Music object
///
/// \return sfTrue if the position is relative, sfFalse if it's absolute
/// \return true if the position is relative, false if it's absolute
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfMusic_isRelativeToListener(const sfMusic* music);
CSFML_AUDIO_API bool sfMusic_isRelativeToListener(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Get the minimum distance of a music
@@ -412,6 +653,36 @@ CSFML_AUDIO_API sfBool sfMusic_isRelativeToListener(const sfMusic* music);
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfMusic_getMinDistance(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Get the maximum distance of the sound
///
/// \param music Music object
///
/// \return Maximum distance of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfMusic_getMaxDistance(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Get the minimum gain of the sound
///
/// \param music Music object
///
/// \return Minimum gain of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfMusic_getMinGain(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Get the maximum gain of the sound
///
/// \param music Music object
///
/// \return Maximum gain of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfMusic_getMaxGain(const sfMusic* music);
////////////////////////////////////////////////////////////
/// \brief Get the attenuation factor of a music
///
@@ -421,6 +692,3 @@ CSFML_AUDIO_API float sfMusic_getMinDistance(const sfMusic* music);
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfMusic_getAttenuation(const sfMusic* music);
#endif // SFML_MUSIC_H
+205
View File
@@ -0,0 +1,205 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <CSFML/Audio/Export.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
////////////////////////////////////////////////////////////
/// \brief Enumeration of the playback device notifications
///
////////////////////////////////////////////////////////////
typedef enum
{
sfPlaybackDeviceStarted, ///< Playback device has been started
sfPlaybackDeviceStopped, ///< Playback device has been stopped
sfPlaybackDeviceRerouted, ///< Playback device has been rerouted (Generated on platforms that support automatic stream routing)
sfPlaybackDeviceInterruptionBegan, ///< Playback device interruption has begun (Generated on Apple mobile platforms)
sfPlaybackDeviceInterruptionEnded, ///< Playback device interruption has ended (Generated on Apple mobile platforms)
sfPlaybackDeviceUnlocked ///< Playback device has been unlocked (Generated by Emscripten/WebAudio)
} sfPlaybackDeviceNotification;
////////////////////////////////////////////////////////////
/// \brief Callback that is called to notify of changes to the playback device state
///
/// \param notification The notification
/// \param userData User data passed to sfPlaybackDevice_setNotificationCallback
///
////////////////////////////////////////////////////////////
typedef void (*sfPlaybackDeviceNotificationCallback)(sfPlaybackDeviceNotification notification, void* userData);
////////////////////////////////////////////////////////////
/// \brief Get a list of the names of all available audio playback devices
///
/// If the operating system reports multiple devices with
/// the same name, a number will be appended to the name
/// of all subsequent devices to distinguish them from each
/// other. This guarantees that every entry returned by this
/// function will represent a unique device.
///
/// The default device, if one is marked as such, will be
/// placed at the beginning of the list.
///
/// The returned array and strings stay valid until the next
/// call to this function.
///
/// \param count Pointer to a variable that will be filled with the number of devices
///
/// \return An array of strings containing the device names or NULL if no devices are available
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API const char* const* sfPlaybackDevice_getAvailableDevices(size_t* count);
////////////////////////////////////////////////////////////
/// \brief Get the name of the default audio playback device
///
/// Note that depending on when this function is called, the
/// default device reported by the operating system might
/// change e.g. when a USB audio device is plugged into or
/// unplugged from the system.
///
/// The returned string stays valid until the next call to
/// this function.
///
/// \return The name of the default audio playback device or NULL if there is none
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API const char* sfPlaybackDevice_getDefaultDevice(void);
////////////////////////////////////////////////////////////
/// \brief Set the audio playback device
///
/// This function sets the audio playback device to the device
/// with the given name. It can be called on the fly (i.e:
/// while sounds are playing).
///
/// If there are sounds playing when the audio playback
/// device is switched, the sounds will continue playing
/// uninterrupted on the new audio playback device.
///
/// \param name The name of the audio playback device
///
/// \return True, if it was able to set the requested device
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API bool sfPlaybackDevice_setDevice(const char* name);
////////////////////////////////////////////////////////////
/// \brief Set the audio playback device to the default
///
/// This function sets the audio playback device to the
/// default device. It can be called on the fly (i.e:
/// while sounds are playing).
///
/// When certain backends are used, using the default device
/// will enable automatic stream routing. When automatic
/// stream routing is enabled, audio data is automatically
/// sent to whichever physical audio device is currently
/// marked as the default on the system.
///
/// Automatic stream routing is currently supported when using
/// the WASAPI or DirectSound backend on Windows or the
/// Core Audio backend on macOS and iOS.
///
/// \return True, if it was able to set the audio playback device to the default device
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API bool sfPlaybackDevice_setDeviceToDefault(void);
////////////////////////////////////////////////////////////
/// \brief Set the audio playback device to the null device
///
/// This function sets the audio playback device to the
/// null device. It can be called on the fly (i.e:
/// while sounds are playing).
///
/// Audio data routed to the null device will be discarded
/// by the backend. This can be used to keep sounds playing
/// without having them actually output on a physical
/// audio playback device.
///
/// \return True, if it was able to set the audio playback device to the null device
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API bool sfPlaybackDevice_setDeviceToNull(void);
////////////////////////////////////////////////////////////
/// \brief Get the name of the current audio playback device
///
/// The returned string stays valid until the next call to
/// this function.
///
/// \return The name of the current audio playback device or NULL if there is none
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API const char* sfPlaybackDevice_getDevice(void);
////////////////////////////////////////////////////////////
/// \brief Get the sample rate of the current audio playback device
///
/// \return The sample rate of the current audio playback device or 0 if there is none
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API uint32_t sfPlaybackDevice_getDeviceSampleRate(void);
////////////////////////////////////////////////////////////
/// \brief Check if the current playback device is the default device
///
/// This function will return false if there is no
/// current playback device.
///
/// \return True, if the current playback device is the default device
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API bool sfPlaybackDevice_isDefaultDevice(void);
////////////////////////////////////////////////////////////
/// \brief Set a callback that should be called to notify of changes to the playback device state
///
/// Warning: Do not attempt to alter the device state from
/// within this callback. This includes changing the device
/// and even creating/destroying sound objects since that
/// could indirectly cause the playback device to be
/// created/destroyed. Also do not attempt to set the
/// notification callback from within this callback. Doing
/// so will result in a deadlock.
///
/// When receiving a notification via this callback, store
/// the information somewhere and react on it from another
/// thread e.g. the main thread within the application.
///
/// \param callback The callback to be called, pass NULL to remove the current callback
/// \param userData User data that will be passed to the callback
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfPlaybackDevice_setNotificationCallback(sfPlaybackDeviceNotificationCallback callback, void* userData);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,26 +22,30 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOUND_H
#define SFML_SOUND_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.h>
#include <SFML/Audio/SoundStatus.h>
#include <SFML/Audio/Types.h>
#include <SFML/System/Time.h>
#include <SFML/System/Vector3.h>
#include <CSFML/Audio/Export.h>
#include <CSFML/Audio/EffectProcessor.h>
#include <CSFML/Audio/SoundSourceCone.h>
#include <CSFML/Audio/SoundStatus.h>
#include <CSFML/Audio/Types.h>
#include <CSFML/System/Time.h>
#include <CSFML/System/Vector3.h>
////////////////////////////////////////////////////////////
/// \brief Create a new sound
///
/// \param buffer Sound buffer containing the audio data to play with the sound
///
/// \return A new sfSound object
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfSound* sfSound_create(void);
CSFML_AUDIO_API sfSound* sfSound_create(const sfSoundBuffer* buffer);
////////////////////////////////////////////////////////////
/// \brief Create a new sound by copying an existing one
@@ -59,7 +63,7 @@ CSFML_AUDIO_API sfSound* sfSound_copy(const sfSound* sound);
/// \param sound Sound to destroy
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_destroy(sfSound* sound);
CSFML_AUDIO_API void sfSound_destroy(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Start or resume playing a sound
@@ -126,24 +130,24 @@ CSFML_AUDIO_API const sfSoundBuffer* sfSound_getBuffer(const sfSound* sound);
///
/// If set, the sound will restart from beginning after
/// reaching the end and so on, until it is stopped or
/// sfSound_setLoop(sound, sfFalse) is called.
/// sfSound_setLooping(sound, false) is called.
/// The default looping state for sounds is false.
///
/// \param sound Sound object
/// \param loop sfTrue to play in loop, sfFalse to play once
/// \param loop true to play in loop, false to play once
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setLoop(sfSound* sound, sfBool loop);
CSFML_AUDIO_API void sfSound_setLooping(sfSound* sound, bool loop);
////////////////////////////////////////////////////////////
/// \brief Tell whether or not a sound is in loop mode
///
/// \param sound Sound object
///
/// \return sfTrue if the sound is looping, sfFalse otherwise
/// \return true if the sound is looping, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfSound_getLoop(const sfSound* sound);
CSFML_AUDIO_API bool sfSound_isLooping(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Get the current status of a sound (stopped, paused, playing)
@@ -170,6 +174,21 @@ CSFML_AUDIO_API sfSoundStatus sfSound_getStatus(const sfSound* sound);
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setPitch(sfSound* sound, float pitch);
////////////////////////////////////////////////////////////
/// \brief Set the pan of the sound
///
/// Using panning, a mono sound can be panned between
/// stereo channels. When the pan is set to -1, the sound
/// is played only on the left channel, when the pan is set
/// to +1, the sound is played only on the right channel.
///
/// \param sound Sound object
/// \param pan New pan to apply to the sound [-1, +1]
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setPan(sfSound* sound, float pan);
////////////////////////////////////////////////////////////
/// \brief Set the volume of a sound
///
@@ -182,6 +201,20 @@ CSFML_AUDIO_API void sfSound_setPitch(sfSound* sound, float pitch);
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setVolume(sfSound* sound, float volume);
////////////////////////////////////////////////////////////
/// \brief Set whether spatialization of the sound is enabled
///
/// Spatialization is the application of various effects to
/// simulate a sound being emitted at a virtual position in
/// 3D space and exhibiting various physical phenomena such as
/// directional attenuation and doppler shift.
///
/// \param sound Sound object
/// \param enabled `true` to enable spatialization, `false` to disable
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setSpatializationEnabled(sfSound* sound, bool enabled);
////////////////////////////////////////////////////////////
/// \brief Set the 3D position of a sound in the audio scene
///
@@ -195,6 +228,74 @@ CSFML_AUDIO_API void sfSound_setVolume(sfSound* sound, float volume);
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setPosition(sfSound* sound, sfVector3f position);
////////////////////////////////////////////////////////////
/// \brief Set the 3D direction of the sound in the audio scene
///
/// The direction defines where the sound source is facing
/// in 3D space. It will affect how the sound is attenuated
/// if facing away from the listener.
/// The default direction of a sound is (0, 0, -1).
///
/// \param sound Sound object
/// \param direction Direction of the sound in the scene
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setDirection(sfSound* sound, sfVector3f direction);
////////////////////////////////////////////////////////////
/// \brief Set the cone properties of the sound in the audio scene
///
/// The cone defines how directional attenuation is applied.
/// The default cone of a sound is (2 * PI, 2 * PI, 1).
///
/// \param sound Sound object
/// \param cone Cone properties of the sound in the scene
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setCone(sfSound* sound, sfSoundSourceCone cone);
////////////////////////////////////////////////////////////
/// \brief Set the 3D velocity of the sound in the audio scene
///
/// The velocity is used to determine how to doppler shift
/// the sound. Sounds moving towards the listener will be
/// perceived to have a higher pitch and sounds moving away
/// from the listener will be perceived to have a lower pitch.
///
/// \param sound Sound object
/// \param velocity Velocity of the sound in the scene
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setVelocity(sfSound* sound, sfVector3f velocity);
////////////////////////////////////////////////////////////
/// \brief Set the doppler factor of the sound
///
/// The doppler factor determines how strong the doppler
/// shift will be.
///
/// \param sound Sound object
/// \param factor New doppler factor to apply to the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setDopplerFactor(sfSound* sound, float factor);
////////////////////////////////////////////////////////////
/// \brief Set the directional attenuation factor of the sound
///
/// Depending on the virtual position of an output channel
/// relative to the listener (such as in surround sound
/// setups), sounds will be attenuated when emitting them
/// from certain channels. This factor determines how strong
/// the attenuation based on output channel position
/// relative to the listener is.
///
/// \param sound Sound object
/// \param factor New directional attenuation factor to apply to the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setDirectionalAttenuationFactor(sfSound* sound, float factor);
////////////////////////////////////////////////////////////
/// \brief Make the sound's position relative to the listener or absolute
///
@@ -205,10 +306,10 @@ CSFML_AUDIO_API void sfSound_setPosition(sfSound* sound, sfVector3f position);
/// The default value is false (position is absolute).
///
/// \param sound Sound object
/// \param relative sfTrue to set the position relative, sfFalse to set it absolute
/// \param relative true to set the position relative, false to set it absolute
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setRelativeToListener(sfSound* sound, sfBool relative);
CSFML_AUDIO_API void sfSound_setRelativeToListener(sfSound* sound, bool relative);
////////////////////////////////////////////////////////////
/// \brief Set the minimum distance of a sound
@@ -226,6 +327,49 @@ CSFML_AUDIO_API void sfSound_setRelativeToListener(sfSound* sound, sfBool relati
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setMinDistance(sfSound* sound, float distance);
////////////////////////////////////////////////////////////
/// \brief Set the maximum distance of the sound
///
/// The "maximum distance" of a sound is the minimum
/// distance at which it is heard at its minimum volume. Closer
/// than the maximum distance, it will start to fade in according
/// to its attenuation factor.
/// The default value of the maximum distance is the maximum
/// value a float can represent.
///
/// \param sound Sound object
/// \param distance New maximum distance of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setMaxDistance(sfSound* sound, float distance);
////////////////////////////////////////////////////////////
/// \brief Set the minimum gain of the sound
///
/// When the sound is further away from the listener than
/// the "maximum distance" the attenuated gain is clamped
/// so it cannot go below the minimum gain value.
///
/// \param sound Sound object
/// \param gain New minimum gain of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setMinGain(sfSound* sound, float gain);
////////////////////////////////////////////////////////////
/// \brief Set the maximum gain of the sound
///
/// When the sound is closer from the listener than
/// the "minimum distance" the attenuated gain is clamped
/// so it cannot go above the maximum gain value.
///
///
/// \param sound Sound object
/// \param gain New maximum gain of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setMaxGain(sfSound* sound, float gain);
////////////////////////////////////////////////////////////
/// \brief Set the attenuation factor of a sound
///
@@ -256,6 +400,18 @@ CSFML_AUDIO_API void sfSound_setAttenuation(sfSound* sound, float attenuation);
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setPlayingOffset(sfSound* sound, sfTime timeOffset);
////////////////////////////////////////////////////////////
/// \brief Set the effect processor to be applied to the sound
///
/// The effect processor is a callable that will be called
/// with sound data to be processed.
///
/// \param sound Sound object
/// \param effectProcessor The effect processor to attach to this sound, attach an empty processor to disable processing
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSound_setEffectProcessor(sfSound* sound, sfEffectProcessor effectProcessor);
////////////////////////////////////////////////////////////
/// \brief Get the pitch of a sound
///
@@ -266,6 +422,16 @@ CSFML_AUDIO_API void sfSound_setPlayingOffset(sfSound* sound, sfTime timeOffset)
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSound_getPitch(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Get the pan of the sound
///
/// \param sound Sound object
///
/// \return Pan of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSound_getPan(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Get the volume of a sound
///
@@ -276,6 +442,16 @@ CSFML_AUDIO_API float sfSound_getPitch(const sfSound* sound);
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSound_getVolume(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Tell whether spatialization of the sound is enabled
///
/// \param sound Sound object
///
/// \return `true` if spatialization is enabled, `false` if it's disabled
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API bool sfSound_isSpatializationEnabled(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Get the 3D position of a sound in the audio scene
///
@@ -286,16 +462,66 @@ CSFML_AUDIO_API float sfSound_getVolume(const sfSound* sound);
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfVector3f sfSound_getPosition(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Get the 3D direction of the sound in the audio scene
///
/// \param sound Sound object
///
/// \return Direction of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfVector3f sfSound_getDirection(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Get the cone properties of the sound in the audio scene
///
/// \param sound Sound object
///
/// \return Cone properties of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfSoundSourceCone sfSound_getCone(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Get the 3D velocity of the sound in the audio scene
///
/// \param sound Sound object
///
/// \return Velocity of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfVector3f sfSound_getVelocity(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Get the doppler factor of the sound
///
/// \param sound Sound object
///
/// \return Doppler factor of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSound_getDopplerFactor(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Get the directional attenuation factor of the sound
///
/// \param sound Sound object
///
/// \return Directional attenuation factor of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSound_getDirectionalAttenuationFactor(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Tell whether a sound's position is relative to the
/// listener or is absolute
///
/// \param sound Sound object
///
/// \return sfTrue if the position is relative, sfFalse if it's absolute
/// \return true if the position is relative, false if it's absolute
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfSound_isRelativeToListener(const sfSound* sound);
CSFML_AUDIO_API bool sfSound_isRelativeToListener(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Get the minimum distance of a sound
@@ -307,6 +533,36 @@ CSFML_AUDIO_API sfBool sfSound_isRelativeToListener(const sfSound* sound);
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSound_getMinDistance(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Get the maximum distance of the sound
///
/// \param sound Sound object
///
/// \return Maximum distance of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSound_getMaxDistance(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Get the minimum gain of the sound
///
/// \param sound Sound object
///
/// \return Minimum gain of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSound_getMinGain(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Get the maximum gain of the sound
///
/// \param sound Sound object
///
/// \return Maximum gain of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSound_getMaxGain(const sfSound* sound);
////////////////////////////////////////////////////////////
/// \brief Get the attenuation factor of a sound
///
@@ -326,6 +582,3 @@ CSFML_AUDIO_API float sfSound_getAttenuation(const sfSound* sound);
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfTime sfSound_getPlayingOffset(const sfSound* sound);
#endif // SFML_SOUND_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,16 +22,18 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOUNDBUFFER_H
#define SFML_SOUNDBUFFER_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.h>
#include <SFML/Audio/Types.h>
#include <SFML/System/InputStream.h>
#include <SFML/System/Time.h>
#include <CSFML/Audio/Export.h>
#include <CSFML/Audio/SoundChannel.h>
#include <CSFML/Audio/Types.h>
#include <CSFML/System/InputStream.h>
#include <CSFML/System/Time.h>
#include <stddef.h>
@@ -82,17 +84,25 @@ CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromStream(sfInputStream* str
/// \brief Create a new sound buffer and load it from an array of samples in memory
///
/// The assumed format of the audio samples is 16 bits signed integer
/// (sfInt16).
/// (int16_t).
///
/// \param samples Pointer to the array of samples in memory
/// \param sampleCount Number of samples in the array
/// \param channelCount Number of channels (1 = mono, 2 = stereo, ...)
/// \param sampleRate Sample rate (number of samples to play per second)
/// \param samples Pointer to the array of samples in memory
/// \param sampleCount Number of samples in the array
/// \param channelCount Number of channels (1 = mono, 2 = stereo, ...)
/// \param sampleRate Sample rate (number of samples to play per second)
/// \param channelMapData Pointer to the array of channel map data
/// \param channelMapSize Size of channel map data array
///
/// \return A new sfSoundBuffer object (NULL if failed)
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromSamples(const sfInt16* samples, sfUint64 sampleCount, unsigned int channelCount, unsigned int sampleRate);
CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromSamples(
const int16_t* samples,
uint64_t sampleCount,
unsigned int channelCount,
unsigned int sampleRate,
sfSoundChannel* channelMapData,
size_t channelMapSize);
////////////////////////////////////////////////////////////
/// \brief Create a new sound buffer by copying an existing one
@@ -110,7 +120,7 @@ CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_copy(const sfSoundBuffer* soundBuff
/// \param soundBuffer Sound buffer to destroy
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundBuffer_destroy(sfSoundBuffer* soundBuffer);
CSFML_AUDIO_API void sfSoundBuffer_destroy(const sfSoundBuffer* soundBuffer);
////////////////////////////////////////////////////////////
/// \brief Save a sound buffer to an audio file
@@ -122,16 +132,16 @@ CSFML_AUDIO_API void sfSoundBuffer_destroy(sfSoundBuffer* soundBuffer);
/// \param soundBuffer Sound buffer object
/// \param filename Path of the sound file to write
///
/// \return sfTrue if saving succeeded, sfFalse if it failed
/// \return true if saving succeeded, false if it failed
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfSoundBuffer_saveToFile(const sfSoundBuffer* soundBuffer, const char* filename);
CSFML_AUDIO_API bool sfSoundBuffer_saveToFile(const sfSoundBuffer* soundBuffer, const char* filename);
////////////////////////////////////////////////////////////
/// \brief Get the array of audio samples stored in a sound buffer
///
/// The format of the returned samples is 16 bits signed integer
/// (sfInt16). The total number of samples in this array
/// (int16_t). The total number of samples in this array
/// is given by the sfSoundBuffer_getSampleCount function.
///
/// \param soundBuffer Sound buffer object
@@ -139,7 +149,7 @@ CSFML_AUDIO_API sfBool sfSoundBuffer_saveToFile(const sfSoundBuffer* soundBuffer
/// \return Read-only pointer to the array of sound samples
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API const sfInt16* sfSoundBuffer_getSamples(const sfSoundBuffer* soundBuffer);
CSFML_AUDIO_API const int16_t* sfSoundBuffer_getSamples(const sfSoundBuffer* soundBuffer);
////////////////////////////////////////////////////////////
/// \brief Get the number of samples stored in a sound buffer
@@ -152,7 +162,7 @@ CSFML_AUDIO_API const sfInt16* sfSoundBuffer_getSamples(const sfSoundBuffer* sou
/// \return Number of samples
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfUint64 sfSoundBuffer_getSampleCount(const sfSoundBuffer* soundBuffer);
CSFML_AUDIO_API uint64_t sfSoundBuffer_getSampleCount(const sfSoundBuffer* soundBuffer);
////////////////////////////////////////////////////////////
/// \brief Get the sample rate of a sound buffer
@@ -181,6 +191,20 @@ CSFML_AUDIO_API unsigned int sfSoundBuffer_getSampleRate(const sfSoundBuffer* so
////////////////////////////////////////////////////////////
CSFML_AUDIO_API unsigned int sfSoundBuffer_getChannelCount(const sfSoundBuffer* soundBuffer);
////////////////////////////////////////////////////////////
/// \brief Get the map of position in sample frame to sound channel
///
/// This is used to map a sample in the sample stream to a
/// position during spatialization.
///
/// \param soundBuffer Sound buffer object
/// \param count Pointer to a variable that will be filled with the number of channels in the map
///
/// \return Map of position in sample frame to sound channel
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfSoundChannel* sfSoundBuffer_getChannelMap(const sfSoundBuffer* soundBuffer, size_t* count);
////////////////////////////////////////////////////////////
/// \brief Get the total duration of a sound buffer
///
@@ -190,6 +214,3 @@ CSFML_AUDIO_API unsigned int sfSoundBuffer_getChannelCount(const sfSoundBuffer*
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfTime sfSoundBuffer_getDuration(const sfSoundBuffer* soundBuffer);
#endif // SFML_SOUNDBUFFER_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,14 +22,14 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOUNDBUFFERRECORDER_H
#define SFML_SOUNDBUFFERRECORDER_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.h>
#include <SFML/Audio/Types.h>
#include <CSFML/Audio/Export.h>
#include <CSFML/Audio/Types.h>
////////////////////////////////////////////////////////////
@@ -46,7 +46,7 @@ CSFML_AUDIO_API sfSoundBufferRecorder* sfSoundBufferRecorder_create(void);
/// \param soundBufferRecorder Sound buffer recorder to destroy
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundBufferRecorder_destroy(sfSoundBufferRecorder* soundBufferRecorder);
CSFML_AUDIO_API void sfSoundBufferRecorder_destroy(const sfSoundBufferRecorder* soundBufferRecorder);
////////////////////////////////////////////////////////////
/// \brief Start the capture of a sound recorder recorder
@@ -61,10 +61,10 @@ CSFML_AUDIO_API void sfSoundBufferRecorder_destroy(sfSoundBufferRecorder* soundB
/// \param soundBufferRecorder Sound buffer recorder object
/// \param sampleRate Desired capture rate, in number of samples per second
///
/// \return sfTrue, if it was able to start recording
/// \return true, if it was able to start recording
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfSoundBufferRecorder_start(sfSoundBufferRecorder* soundBufferRecorder, unsigned int sampleRate);
CSFML_AUDIO_API bool sfSoundBufferRecorder_start(sfSoundBufferRecorder* soundBufferRecorder, unsigned int sampleRate);
////////////////////////////////////////////////////////////
/// \brief Stop the capture of a sound recorder
@@ -114,10 +114,10 @@ CSFML_AUDIO_API const sfSoundBuffer* sfSoundBufferRecorder_getBuffer(const sfSou
/// \param soundBufferRecorder Sound buffer recorder object
/// \param name The name of the audio capture device
///
/// \return sfTrue, if it was able to set the requested device
/// \return true, if it was able to set the requested device
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfSoundBufferRecorder_setDevice(sfSoundBufferRecorder* soundBufferRecorder, const char* name);
CSFML_AUDIO_API bool sfSoundBufferRecorder_setDevice(sfSoundBufferRecorder* soundBufferRecorder, const char* name);
////////////////////////////////////////////////////////////
/// \brief Get the name of the current audio capture device
@@ -129,5 +129,34 @@ CSFML_AUDIO_API sfBool sfSoundBufferRecorder_setDevice(sfSoundBufferRecorder* so
////////////////////////////////////////////////////////////
CSFML_AUDIO_API const char* sfSoundBufferRecorder_getDevice(sfSoundBufferRecorder* soundBufferRecorder);
////////////////////////////////////////////////////////////
/// \brief Set the channel count of the audio capture device
///
/// This method allows you to specify the number of channels
/// used for recording. Currently only 16-bit mono and
/// 16-bit stereo are supported.
///
/// \param soundBufferRecorder Sound buffer recorder object
/// \param channelCount Number of channels. Currently only
/// mono (1) and stereo (2) are supported.
///
/// \see sfSoundBufferRecorder_getChannelCount
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundBufferRecorder_setChannelCount(sfSoundBufferRecorder* soundBufferRecorder,
unsigned int channelCount);
#endif // SFML_SOUNDBUFFERRECORDER_H
////////////////////////////////////////////////////////////
/// \brief Get the number of channels used by this recorder
///
/// Currently only mono and stereo are supported, so the
/// value is either 1 (for mono) or 2 (for stereo).
///
/// \param soundBufferRecorder Sound buffer recorder object
///
/// \return Number of channels
///
/// \see sfSoundBufferRecorder_setChannelCount
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API unsigned int sfSoundBufferRecorder_getChannelCount(const sfSoundBufferRecorder* soundBufferRecorder);
+60
View File
@@ -0,0 +1,60 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
/// \brief Types of sound channels that can be read/written from sound buffers/files
///
/// In multi-channel audio, each sound channel can be
/// assigned a position. The position of the channel is
/// used to determine where to place a sound when it
/// is spatialised. Assigning an incorrect sound channel
/// will result in multi-channel audio being positioned
/// incorrectly when using spatialisation.
///
////////////////////////////////////////////////////////////
typedef enum
{
sfSoundChannelUnspecified,
sfSoundChannelMono,
sfSoundChannelFrontLeft,
sfSoundChannelFrontRight,
sfSoundChannelFrontCenter,
sfSoundChannelFrontLeftOfCenter,
sfSoundChannelFrontRightOfCenter,
sfSoundChannelLowFrequencyEffects,
sfSoundChannelBackLeft,
sfSoundChannelBackRight,
sfSoundChannelBackCenter,
sfSoundChannelSideLeft,
sfSoundChannelSideRight,
sfSoundChannelTopCenter,
sfSoundChannelTopFrontLeft,
sfSoundChannelTopFrontRight,
sfSoundChannelTopFrontCenter,
sfSoundChannelTopBackLeft,
sfSoundChannelTopBackRight,
sfSoundChannelTopBackCenter
} sfSoundChannel;
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,21 +22,23 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOUNDRECORDER_H
#define SFML_SOUNDRECORDER_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.h>
#include <SFML/Audio/Types.h>
#include <SFML/System/Time.h>
#include <CSFML/Audio/Export.h>
#include <CSFML/Audio/SoundChannel.h>
#include <CSFML/Audio/Types.h>
#include <CSFML/System/Time.h>
#include <stddef.h>
typedef sfBool (*sfSoundRecorderStartCallback)(void*); ///< Type of the callback used when starting a capture
typedef sfBool (*sfSoundRecorderProcessCallback)(const sfInt16*, size_t, void*); ///< Type of the callback used to process audio data
typedef void (*sfSoundRecorderStopCallback)(void*); ///< Type of the callback used when stopping a capture
typedef bool (*sfSoundRecorderStartCallback)(void*); ///< Type of the callback used when starting a capture
typedef bool (*sfSoundRecorderProcessCallback)(const int16_t*, size_t, void*); ///< Type of the callback used to process audio data
typedef void (*sfSoundRecorderStopCallback)(void*); ///< Type of the callback used when stopping a capture
////////////////////////////////////////////////////////////
@@ -61,7 +63,7 @@ CSFML_AUDIO_API sfSoundRecorder* sfSoundRecorder_create(sfSoundRecorderStartCall
/// \param soundRecorder Sound recorder to destroy
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundRecorder_destroy(sfSoundRecorder* soundRecorder);
CSFML_AUDIO_API void sfSoundRecorder_destroy(const sfSoundRecorder* soundRecorder);
////////////////////////////////////////////////////////////
/// \brief Start the capture of a sound recorder
@@ -79,7 +81,7 @@ CSFML_AUDIO_API void sfSoundRecorder_destroy(sfSoundRecorder* soundRecorder);
/// \return True, if start of capture was successful
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfSoundRecorder_start(sfSoundRecorder* soundRecorder, unsigned int sampleRate);
CSFML_AUDIO_API bool sfSoundRecorder_start(sfSoundRecorder* soundRecorder, unsigned int sampleRate);
////////////////////////////////////////////////////////////
/// \brief Stop the capture of a sound recorder
@@ -110,29 +112,10 @@ CSFML_AUDIO_API unsigned int sfSoundRecorder_getSampleRate(const sfSoundRecorder
/// the audio capture features. If it returns false, then
/// any attempt to use sfSoundRecorder will fail.
///
/// \return sfTrue if audio capture is supported, sfFalse otherwise
/// \return true if audio capture is supported, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfSoundRecorder_isAvailable(void);
////////////////////////////////////////////////////////////
/// \brief Set the processing interval
///
/// The processing interval controls the period
/// between calls to the onProcessSamples function. You may
/// want to use a small interval if you want to process the
/// recorded data in real time, for example.
///
/// Note: this is only a hint, the actual period may vary.
/// So don't rely on this parameter to implement precise timing.
///
/// The default processing interval is 100 ms.
///
/// \param soundRecorder Sound recorder object
/// \param interval Processing interval
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundRecorder_setProcessingInterval(sfSoundRecorder* soundRecorder, sfTime interval);
CSFML_AUDIO_API bool sfSoundRecorder_isAvailable(void);
////////////////////////////////////////////////////////////
/// \brief Get a list of the names of all available audio capture devices
@@ -146,7 +129,7 @@ CSFML_AUDIO_API void sfSoundRecorder_setProcessingInterval(sfSoundRecorder* soun
/// \return An array of strings containing the names
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API const char** sfSoundRecorder_getAvailableDevices(size_t* count);
CSFML_AUDIO_API const char* const* sfSoundRecorder_getAvailableDevices(size_t* count);
////////////////////////////////////////////////////////////
/// \brief Get the name of the default audio capture device
@@ -170,10 +153,10 @@ CSFML_AUDIO_API const char* sfSoundRecorder_getDefaultDevice(void);
/// \param soundRecorder Sound recorder object
/// \param name The name of the audio capture device
///
/// \return sfTrue, if it was able to set the requested device
/// \return true, if it was able to set the requested device
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfBool sfSoundRecorder_setDevice(sfSoundRecorder* soundRecorder, const char* name);
CSFML_AUDIO_API bool sfSoundRecorder_setDevice(sfSoundRecorder* soundRecorder, const char* name);
////////////////////////////////////////////////////////////
/// \brief Get the name of the current audio capture device
@@ -192,8 +175,9 @@ CSFML_AUDIO_API const char* sfSoundRecorder_getDevice(sfSoundRecorder* soundReco
/// used for recording. Currently only 16-bit mono and
/// 16-bit stereo are supported.
///
/// \param channelCount Number of channels. Currently only
/// mono (1) and stereo (2) are supported.
/// \param soundRecorder Sound recorder object
/// \param channelCount Number of channels. Currently only
/// mono (1) and stereo (2) are supported.
///
/// \see sfSoundRecorder_getChannelCount
///
@@ -213,5 +197,16 @@ CSFML_AUDIO_API void sfSoundRecorder_setChannelCount(sfSoundRecorder* soundRecor
////////////////////////////////////////////////////////////
CSFML_AUDIO_API unsigned int sfSoundRecorder_getChannelCount(const sfSoundRecorder* soundRecorder);
#endif // SFML_SOUNDRECORDER_H
////////////////////////////////////////////////////////////
/// \brief Get the map of position in sample frame to sound channel
///
/// This is used to map a sample in the sample stream to a
/// position during spatialization.
///
/// \param soundRecorder Sound recorder object
/// \param count Pointer to a variable that will be filled with the number of channels in the map
///
/// \return Map of position in sample frame to sound channel
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfSoundChannel* sfSoundRecorder_getChannelMap(const sfSoundRecorder* soundRecorder, size_t* count);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,25 +22,22 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOUNDBUFFERRECORDERSTRUCT_H
#define SFML_SOUNDBUFFERRECORDERSTRUCT_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
/// \brief Structure defining the properties of a directional cone
///
/// Sounds will play at gain 1 when the listener
/// is positioned within the inner angle of the cone.
/// Sounds will play at `outerGain` when the listener is
/// positioned outside the outer angle of the cone.
/// The gain declines linearly from 1 to `outerGain` as the
/// listener moves from the inner angle to the outer angle.
///
////////////////////////////////////////////////////////////
#include <SFML/Audio/SoundBufferRecorder.hpp>
#include <SFML/Audio/SoundBufferStruct.h>
////////////////////////////////////////////////////////////
// Internal structure of sfSoundBufferRecorder
////////////////////////////////////////////////////////////
struct sfSoundBufferRecorder
typedef struct
{
sf::SoundBufferRecorder This;
mutable sfSoundBuffer SoundBuffer;
std::string DeviceName;
};
#endif // SFML_SOUNDBUFFERRECORDERSTRUCT_H
float innerAngle; //!< Inner angle, in degrees
float outerAngle; //!< Outer angle, in degrees
float outerGain; //!< Outer gain
} sfSoundSourceCone;
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,13 +22,12 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOUNDSTATUS_H
#define SFML_SOUNDSTATUS_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.h>
#include <CSFML/Audio/Export.h>
////////////////////////////////////////////////////////////
@@ -41,6 +40,3 @@ typedef enum
sfPaused, ///< Sound / music is paused
sfPlaying ///< Sound / music is playing
} sfSoundStatus;
#endif // SFML_SOUNDSTATUS_H
+618
View File
@@ -0,0 +1,618 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <CSFML/Audio/Export.h>
#include <CSFML/Audio/EffectProcessor.h>
#include <CSFML/Audio/SoundChannel.h>
#include <CSFML/Audio/SoundSourceCone.h>
#include <CSFML/Audio/SoundStatus.h>
#include <CSFML/Audio/Types.h>
#include <CSFML/System/Time.h>
#include <CSFML/System/Vector3.h>
#include <stddef.h>
////////////////////////////////////////////////////////////
/// \brief defines the data to fill by the OnGetData callback
///
////////////////////////////////////////////////////////////
typedef struct
{
int16_t* samples; ///< Pointer to the audio samples
unsigned int sampleCount; ///< Number of samples pointed by Samples
} sfSoundStreamChunk;
typedef bool (*sfSoundStreamGetDataCallback)(sfSoundStreamChunk*, void*); ///< Type of the callback used to get a sound stream data
typedef void (*sfSoundStreamSeekCallback)(sfTime, void*); ///< Type of the callback used to seek in a sound stream
////////////////////////////////////////////////////////////
/// \brief Create a new sound stream
///
/// \param onGetData Function called when the stream needs more data (can't be NULL)
/// \param onSeek Function called when the stream seeks (can't be NULL)
/// \param channelCount Number of channels to use (1 = mono, 2 = stereo)
/// \param sampleRate Sample rate of the sound (44100 = CD quality)
/// \param channelMapData Pointer to the array of channel map data
/// \param channelMapSize Size of channel map data array
/// \param userData Data to pass to the callback functions
///
/// \return A new sfSoundStream object
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfSoundStream* sfSoundStream_create(
sfSoundStreamGetDataCallback onGetData,
sfSoundStreamSeekCallback onSeek,
unsigned int channelCount,
unsigned int sampleRate,
sfSoundChannel* channelMapData,
size_t channelMapSize,
void* userData);
////////////////////////////////////////////////////////////
/// \brief Destroy a sound stream
///
/// \param soundStream Sound stream to destroy
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_destroy(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Start or resume playing a sound stream
///
/// This function starts the stream if it was stopped, resumes
/// it if it was paused, and restarts it from beginning if it
/// was it already playing.
/// This function uses its own thread so that it doesn't block
/// the rest of the program while the music is played.
///
/// \param soundStream Sound stream object
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_play(sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Pause a sound stream
///
/// This function pauses the stream if it was playing,
/// otherwise (stream already paused or stopped) it has no effect.
///
/// \param soundStream Sound stream object
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_pause(sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Stop playing a sound stream
///
/// This function stops the stream if it was playing or paused,
/// and does nothing if it was already stopped.
/// It also resets the playing position (unlike sfSoundStream_pause).
///
/// \param soundStream Sound stream object
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_stop(sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the current status of a sound stream (stopped, paused, playing)
///
/// \param soundStream Sound stream object
///
/// \return Current status
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfSoundStatus sfSoundStream_getStatus(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Return the number of channels of a sound stream
///
/// 1 channel means a mono sound, 2 means stereo, etc.
///
/// \param soundStream Sound stream object
///
/// \return Number of channels
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API unsigned int sfSoundStream_getChannelCount(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the sample rate of a sound stream
///
/// The sample rate is the number of audio samples played per
/// second. The higher, the better the quality.
///
/// \param soundStream Sound stream object
///
/// \return Sample rate, in number of samples per second
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API unsigned int sfSoundStream_getSampleRate(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the map of position in sample frame to sound channel
///
/// This is used to map a sample in the sample stream to a
/// position during spatialization.
///
/// \param soundStream Sound stream object
/// \param count Pointer to a variable that will be filled with the number of channels in the map
///
/// \return Map of position in sample frame to sound channel
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfSoundChannel* sfSoundStream_getChannelMap(const sfSoundStream* soundStream, size_t* count);
////////////////////////////////////////////////////////////
/// \brief Set the pitch of a sound stream
///
/// The pitch represents the perceived fundamental frequency
/// of a sound; thus you can make a stream more acute or grave
/// by changing its pitch. A side effect of changing the pitch
/// is to modify the playing speed of the stream as well.
/// The default value for the pitch is 1.
///
/// \param soundStream Sound stream object
/// \param pitch New pitch to apply to the stream
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setPitch(sfSoundStream* soundStream, float pitch);
////////////////////////////////////////////////////////////
/// \brief Set the pan of the sound
///
/// Using panning, a mono sound can be panned between
/// stereo channels. When the pan is set to -1, the sound
/// is played only on the left channel, when the pan is set
/// to +1, the sound is played only on the right channel.
///
/// \param soundStream Sound stream object
/// \param pan New pan to apply to the sound [-1, +1]
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setPan(sfSoundStream* soundStream, float pan);
////////////////////////////////////////////////////////////
/// \brief Set the volume of a sound stream
///
/// The volume is a value between 0 (mute) and 100 (full volume).
/// The default value for the volume is 100.
///
/// \param soundStream Sound stream object
/// \param volume Volume of the stream
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setVolume(sfSoundStream* soundStream, float volume);
////////////////////////////////////////////////////////////
/// \brief Set whether spatialization of the sound is enabled
///
/// Spatialization is the application of various effects to
/// simulate a sound being emitted at a virtual position in
/// 3D space and exhibiting various physical phenomena such as
/// directional attenuation and doppler shift.
///
/// \param soundStream Sound stream object
/// \param enabled `true` to enable spatialization, `false` to disable
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setSpatializationEnabled(sfSoundStream* soundStream, bool enabled);
////////////////////////////////////////////////////////////
/// \brief Set the 3D position of a sound stream in the audio scene
///
/// Only streams with one channel (mono streams) can be
/// spatialized.
/// The default position of a stream is (0, 0, 0).
///
/// \param soundStream Sound stream object
/// \param position Position of the stream in the scene
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setPosition(sfSoundStream* soundStream, sfVector3f position);
////////////////////////////////////////////////////////////
/// \brief Set the 3D direction of the sound in the audio scene
///
/// The direction defines where the sound source is facing
/// in 3D space. It will affect how the sound is attenuated
/// if facing away from the listener.
/// The default direction of a sound is (0, 0, -1).
///
/// \param soundStream Sound stream object
/// \param direction Direction of the sound in the scene
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setDirection(sfSoundStream* soundStream, sfVector3f direction);
////////////////////////////////////////////////////////////
/// \brief Set the cone properties of the sound in the audio scene
///
/// The cone defines how directional attenuation is applied.
/// The default cone of a sound is (2 * PI, 2 * PI, 1).
///
/// \param soundStream Sound stream object
/// \param cone Cone properties of the sound in the scene
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setCone(sfSoundStream* soundStream, sfSoundSourceCone cone);
////////////////////////////////////////////////////////////
/// \brief Set the 3D velocity of the sound in the audio scene
///
/// The velocity is used to determine how to doppler shift
/// the sound. Sounds moving towards the listener will be
/// perceived to have a higher pitch and sounds moving away
/// from the listener will be perceived to have a lower pitch.
///
/// \param soundStream Sound stream object
/// \param velocity Velocity of the sound in the scene
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setVelocity(sfSoundStream* soundStream, sfVector3f velocity);
////////////////////////////////////////////////////////////
/// \brief Set the doppler factor of the sound
///
/// The doppler factor determines how strong the doppler
/// shift will be.
///
/// \param soundStream Sound stream object
/// \param factor New doppler factor to apply to the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setDopplerFactor(sfSoundStream* soundStream, float factor);
////////////////////////////////////////////////////////////
/// \brief Set the directional attenuation factor of the sound
///
/// Depending on the virtual position of an output channel
/// relative to the listener (such as in surround sound
/// setups), sounds will be attenuated when emitting them
/// from certain channels. This factor determines how strong
/// the attenuation based on output channel position
/// relative to the listener is.
///
/// \param soundStream Sound stream object
/// \param factor New directional attenuation factor to apply to the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setDirectionalAttenuationFactor(sfSoundStream* soundStream, float factor);
////////////////////////////////////////////////////////////
/// \brief Make a sound stream's position relative to the listener or absolute
///
/// Making a stream relative to the listener will ensure that it will always
/// be played the same way regardless the position of the listener.
/// This can be useful for non-spatialized streams, streams that are
/// produced by the listener, or streams attached to it.
/// The default value is false (position is absolute).
///
/// \param soundStream Sound stream object
/// \param relative true to set the position relative, false to set it absolute
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setRelativeToListener(sfSoundStream* soundStream, bool relative);
////////////////////////////////////////////////////////////
/// \brief Set the minimum distance of a sound stream
///
/// The "minimum distance" of a stream is the maximum
/// distance at which it is heard at its maximum volume. Further
/// than the minimum distance, it will start to fade out according
/// to its attenuation factor. A value of 0 ("inside the head
/// of the listener") is an invalid value and is forbidden.
/// The default value of the minimum distance is 1.
///
/// \param soundStream Sound stream object
/// \param distance New minimum distance of the stream
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setMinDistance(sfSoundStream* soundStream, float distance);
////////////////////////////////////////////////////////////
/// \brief Set the maximum distance of the sound
///
/// The "maximum distance" of a sound is the minimum
/// distance at which it is heard at its minimum volume. Closer
/// than the maximum distance, it will start to fade in according
/// to its attenuation factor.
/// The default value of the maximum distance is the maximum
/// value a float can represent.
///
/// \param soundStream Sound stream object
/// \param distance New maximum distance of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setMaxDistance(sfSoundStream* soundStream, float distance);
////////////////////////////////////////////////////////////
/// \brief Set the minimum gain of the sound
///
/// When the sound is further away from the listener than
/// the "maximum distance" the attenuated gain is clamped
/// so it cannot go below the minimum gain value.
///
/// \param soundStream Sound stream object
/// \param gain New minimum gain of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setMinGain(sfSoundStream* soundStream, float gain);
////////////////////////////////////////////////////////////
/// \brief Set the maximum gain of the sound
///
/// When the sound is closer from the listener than
/// the "minimum distance" the attenuated gain is clamped
/// so it cannot go above the maximum gain value.
///
/// \param soundStream Sound stream object
/// \param gain New maximum gain of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setMaxGain(sfSoundStream* soundStream, float gain);
////////////////////////////////////////////////////////////
/// \brief Set the attenuation factor of a sound stream
///
/// The attenuation is a multiplicative factor which makes
/// the stream more or less loud according to its distance
/// from the listener. An attenuation of 0 will produce a
/// non-attenuated stream, i.e. its volume will always be the same
/// whether it is heard from near or from far. On the other hand,
/// an attenuation value such as 100 will make the stream fade out
/// very quickly as it gets further from the listener.
/// The default value of the attenuation is 1.
///
/// \param soundStream Sound stream object
/// \param attenuation New attenuation factor of the stream
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setAttenuation(sfSoundStream* soundStream, float attenuation);
////////////////////////////////////////////////////////////
/// \brief Change the current playing position of a sound stream
///
/// The playing position can be changed when the stream is
/// either paused or playing.
///
/// \param soundStream Sound stream object
/// \param timeOffset New playing position
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setPlayingOffset(sfSoundStream* soundStream, sfTime timeOffset);
////////////////////////////////////////////////////////////
/// \brief Set whether or not a sound stream should loop after reaching the end
///
/// If set, the stream will restart from beginning after
/// reaching the end and so on, until it is stopped or
/// sfSoundStream_setLooping(stream, false) is called.
/// The default looping state for sound streams is false.
///
/// \param soundStream Sound stream object
/// \param loop true to play in loop, false to play once
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setLooping(sfSoundStream* soundStream, bool loop);
////////////////////////////////////////////////////////////
/// \brief Get the pitch of a sound stream
///
/// \param soundStream Sound stream object
///
/// \return Pitch of the stream
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSoundStream_getPitch(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the pan of the sound
///
/// \param soundStream Sound stream object
///
/// \return Pan of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSoundStream_getPan(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the volume of a sound stream
///
/// \param soundStream Sound stream object
///
/// \return Volume of the stream, in the range [0, 100]
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSoundStream_getVolume(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Tell whether spatialization of the sound is enabled
///
/// \param soundStream Sound stream object
///
/// \return `true` if spatialization is enabled, `false` if it's disabled
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API bool sfSoundStream_isSpatializationEnabled(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the 3D position of a sound stream in the audio scene
///
/// \param soundStream Sound stream object
///
/// \return Position of the stream in the world
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfVector3f sfSoundStream_getPosition(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the 3D direction of the sound in the audio scene
///
/// \param soundStream Sound stream object
///
/// \return Direction of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfVector3f sfSoundStream_getDirection(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the cone properties of the sound in the audio scene
///
/// \param soundStream Sound stream object
///
/// \return Cone properties of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfSoundSourceCone sfSoundStream_getCone(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the 3D velocity of the sound in the audio scene
///
/// \param soundStream Sound stream object
///
/// \return Velocity of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfVector3f sfSoundStream_getVelocity(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the doppler factor of the sound
///
/// \param soundStream Sound stream object
///
/// \return Doppler factor of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSoundStream_getDopplerFactor(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the directional attenuation factor of the sound
///
/// \param soundStream Sound stream object
///
/// \return Directional attenuation factor of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSoundStream_getDirectionalAttenuationFactor(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Tell whether a sound stream's position is relative to the
/// listener or is absolute
///
/// \param soundStream Sound stream object
///
/// \return true if the position is relative, false if it's absolute
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API bool sfSoundStream_isRelativeToListener(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the minimum distance of a sound stream
///
/// \param soundStream Sound stream object
///
/// \return Minimum distance of the stream
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSoundStream_getMinDistance(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the maximum distance of the sound
///
/// \param soundStream Sound stream object
///
/// \return Maximum distance of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSoundStream_getMaxDistance(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the minimum gain of the sound
///
/// \param soundStream Sound stream object
///
/// \return Minimum gain of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSoundStream_getMinGain(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the maximum gain of the sound
///
/// \param soundStream Sound stream object
///
/// \return Maximum gain of the sound
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSoundStream_getMaxGain(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Get the attenuation factor of a sound stream
///
/// \param soundStream Sound stream object
///
/// \return Attenuation factor of the stream
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API float sfSoundStream_getAttenuation(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Tell whether or not a sound stream is in loop mode
///
/// \param soundStream Sound stream object
///
/// \return true if the music is looping, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API bool sfSoundStream_isLooping(const sfSoundStream* soundStream);
////////////////////////////////////////////////////////////
/// \brief Set the effect processor to be applied to the sound
///
/// The effect processor is a callable that will be called
/// with sound data to be processed.
///
/// \param soundStream Sound stream object
/// \param effectProcessor The effect processor to attach to this sound, attach an empty processor to disable processing
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API void sfSoundStream_setEffectProcessor(sfSoundStream* soundStream, sfEffectProcessor effectProcessor);
////////////////////////////////////////////////////////////
/// \brief Get the current playing position of a sound stream
///
/// \param soundStream Sound stream object
///
/// \return Current playing position
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfTime sfSoundStream_getPlayingOffset(const sfSoundStream* soundStream);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,16 +22,11 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_AUDIO_TYPES_H
#define SFML_AUDIO_TYPES_H
#pragma once
typedef struct sfMusic sfMusic;
typedef struct sfSound sfSound;
typedef struct sfSoundBuffer sfSoundBuffer;
typedef struct sfMusic sfMusic;
typedef struct sfSound sfSound;
typedef struct sfSoundBuffer sfSoundBuffer;
typedef struct sfSoundBufferRecorder sfSoundBufferRecorder;
typedef struct sfSoundRecorder sfSoundRecorder;
typedef struct sfSoundStream sfSoundStream;
#endif // SFML_AUDIO_TYPES_H
typedef struct sfSoundRecorder sfSoundRecorder;
typedef struct sfSoundStream sfSoundStream;
+161
View File
@@ -0,0 +1,161 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <stdbool.h>
#include <stdint.h>
////////////////////////////////////////////////////////////
// Define the CSFML version
////////////////////////////////////////////////////////////
#define CSFML_VERSION_MAJOR 3
#define CSFML_VERSION_MINOR 1
#define CSFML_VERSION_PATCH 0
////////////////////////////////////////////////////////////
// Check if we need to mark functions as extern "C"
////////////////////////////////////////////////////////////
#ifdef __cplusplus
#define CSFML_EXTERN_C extern "C"
#else
#define CSFML_EXTERN_C extern
#endif
////////////////////////////////////////////////////////////
// Identify the operating system
////////////////////////////////////////////////////////////
#if defined(_WIN32) || defined(__WIN32__)
// Windows
#define CSFML_SYSTEM_WINDOWS
#elif defined(linux) || defined(__linux)
// Linux
#define CSFML_SYSTEM_LINUX
#elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh)
// MacOS
#define CSFML_SYSTEM_MACOS
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
// FreeBSD
#define CSFML_SYSTEM_FREEBSD
#else
// Unsupported system
#error This operating system is not supported by SFML library
#endif
////////////////////////////////////////////////////////////
// Define helpers to create portable import / export macros for each module
////////////////////////////////////////////////////////////
#if !defined(CSFML_STATIC)
#if defined(CSFML_SYSTEM_WINDOWS)
// Windows compilers need specific (and different) keywords for export and import
#define CSFML_API_EXPORT extern "C" __declspec(dllexport)
#define CSFML_API_IMPORT CSFML_EXTERN_C __declspec(dllimport)
// For Visual C++ compilers, we also need to turn off this annoying C4251 warning
#ifdef _MSC_VER
#pragma warning(disable : 4251)
#endif
#else // Linux, FreeBSD, Mac OS X
#define CSFML_API_EXPORT extern "C" __attribute__((__visibility__("default")))
#define CSFML_API_IMPORT CSFML_EXTERN_C __attribute__((__visibility__("default")))
#endif
#else
// Static build doesn't need import/export macros
#define CSFML_API_EXPORT extern "C"
#define CSFML_API_IMPORT CSFML_EXTERN_C
#endif
////////////////////////////////////////////////////////////
// Cross-platform warning for deprecated functions and classes
//
// Usage:
// struct CSFML_DEPRECATED MyStruct
// {
// ...
// };
//
// CSFML_DEPRECATED void globalFunc(void);
////////////////////////////////////////////////////////////
#if defined(CSFML_NO_DEPRECATED_WARNINGS)
// User explicitly requests to disable deprecation warnings
#define CSFML_DEPRECATED
#elif defined(_MSC_VER)
// Microsoft C++ compiler
// Note: On newer MSVC versions, using deprecated functions causes a compiler error. In order to
// trigger a warning instead of an error, the compiler flag /sdl- (instead of /sdl) must be specified.
#define CSFML_DEPRECATED __declspec(deprecated)
#elif defined(__GNUC__)
// g++ and Clang
#define CSFML_DEPRECATED __attribute__((deprecated))
#else
// Other compilers are not supported, leave class or function as-is.
// With a bit of luck, the #pragma directive works, otherwise users get a warning (no error!) for unrecognized #pragma.
#pragma message("CSFML_DEPRECATED is not supported for your compiler, please contact the CSFML team")
#define CSFML_DEPRECATED
#endif
////////////////////////////////////////////////////////////
/// Define sfChar32
///
/// Work around macOS not providing <uchar.h>
////////////////////////////////////////////////////////////
#include <stdint.h>
typedef uint32_t sfChar32;
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,14 +22,12 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_GPUPREFERENCE_H
#define SFML_GPUPREFERENCE_H
#pragma once
////////////////////////////////////////////////////////////
/// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <CSFML/Config.h>
////////////////////////////////////////////////////////////
@@ -60,15 +58,12 @@
////////////////////////////////////////////////////////////
#if defined(SFML_SYSTEM_WINDOWS)
#define SFML_DEFINE_DISCRETE_GPU_PREFERENCE \
CSFML_EXTERN_C __declspec(dllexport) unsigned long NvOptimusEnablement = 1; \
CSFML_EXTERN_C __declspec(dllexport) unsigned long AmdPowerXpressRequestHighPerformance = 1;
#define SFML_DEFINE_DISCRETE_GPU_PREFERENCE \
CSFML_EXTERN_C __declspec(dllexport) unsigned long NvOptimusEnablement = 1; \
CSFML_EXTERN_C __declspec(dllexport) unsigned long AmdPowerXpressRequestHighPerformance = 1;
#else
#define SFML_DEFINE_DISCRETE_GPU_PREFERENCE
#define SFML_DEFINE_DISCRETE_GPU_PREFERENCE
#endif
#endif // SFML_GPUPREFERENCE_H
+56
View File
@@ -0,0 +1,56 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <CSFML/Graphics/BlendMode.h>
#include <CSFML/Graphics/CircleShape.h>
#include <CSFML/Graphics/Color.h>
#include <CSFML/Graphics/ConvexShape.h>
#include <CSFML/Graphics/Font.h>
#include <CSFML/Graphics/FontInfo.h>
#include <CSFML/Graphics/Glyph.h>
#include <CSFML/Graphics/Image.h>
#include <CSFML/Graphics/PrimitiveType.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/RectangleShape.h>
#include <CSFML/Graphics/RenderStates.h>
#include <CSFML/Graphics/RenderTexture.h>
#include <CSFML/Graphics/RenderWindow.h>
#include <CSFML/Graphics/Shader.h>
#include <CSFML/Graphics/Shape.h>
#include <CSFML/Graphics/Sprite.h>
#include <CSFML/Graphics/Text.h>
#include <CSFML/Graphics/Texture.h>
#include <CSFML/Graphics/Transform.h>
#include <CSFML/Graphics/Transformable.h>
#include <CSFML/Graphics/Vertex.h>
#include <CSFML/Graphics/VertexArray.h>
#include <CSFML/Graphics/VertexBuffer.h>
#include <CSFML/Graphics/View.h>
#include <CSFML/Window.h>
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,13 +22,12 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_BLENDMODE_H
#define SFML_BLENDMODE_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <CSFML/Graphics/Export.h>
////////////////////////////////////////////////////////////
@@ -70,12 +69,12 @@ typedef enum
////////////////////////////////////////////////////////////
typedef struct
{
sfBlendFactor colorSrcFactor; ///< Source blending factor for the color channels
sfBlendFactor colorDstFactor; ///< Destination blending factor for the color channels
sfBlendEquation colorEquation; ///< Blending equation for the color channels
sfBlendFactor alphaSrcFactor; ///< Source blending factor for the alpha channel
sfBlendFactor alphaDstFactor; ///< Destination blending factor for the alpha channel
sfBlendEquation alphaEquation; ///< Blending equation for the alpha channel
sfBlendFactor colorSrcFactor; ///< Source blending factor for the color channels
sfBlendFactor colorDstFactor; ///< Destination blending factor for the color channels
sfBlendEquation colorEquation; ///< Blending equation for the color channels
sfBlendFactor alphaSrcFactor; ///< Source blending factor for the alpha channel
sfBlendFactor alphaDstFactor; ///< Destination blending factor for the alpha channel
sfBlendEquation alphaEquation; ///< Blending equation for the alpha channel
} sfBlendMode;
@@ -85,6 +84,3 @@ CSFML_GRAPHICS_API const sfBlendMode sfBlendMultiply; ///< Multiply source and d
CSFML_GRAPHICS_API const sfBlendMode sfBlendMin; ///< Take minimum between source and dest
CSFML_GRAPHICS_API const sfBlendMode sfBlendMax; ///< Take maximum between source and dest
CSFML_GRAPHICS_API const sfBlendMode sfBlendNone; ///< Overwrite dest with source
#endif // SFML_BLENDMODE_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,18 +22,19 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_CIRCLESHAPE_H
#define SFML_CIRCLESHAPE_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Types.h>
#include <SFML/System/Vector2.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/Color.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/Transform.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/System/Vector2.h>
#include <stddef.h>
@@ -61,7 +62,7 @@ CSFML_GRAPHICS_API sfCircleShape* sfCircleShape_copy(const sfCircleShape* shape)
/// \param shape Shape to delete
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfCircleShape_destroy(sfCircleShape* shape);
CSFML_GRAPHICS_API void sfCircleShape_destroy(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Set the position of a circle shape
@@ -235,7 +236,7 @@ CSFML_GRAPHICS_API sfTransform sfCircleShape_getInverseTransform(const sfCircleS
/// \param resetRect Should the texture rect be reset to the size of the new texture?
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfCircleShape_setTexture(sfCircleShape* shape, const sfTexture* texture, sfBool resetRect);
CSFML_GRAPHICS_API void sfCircleShape_setTexture(sfCircleShape* shape, const sfTexture* texture, bool resetRect);
////////////////////////////////////////////////////////////
/// \brief Set the sub-rectangle of the texture that a circle shape will display
@@ -291,6 +292,36 @@ CSFML_GRAPHICS_API void sfCircleShape_setOutlineColor(sfCircleShape* shape, sfCo
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfCircleShape_setOutlineThickness(sfCircleShape* shape, float thickness);
////////////////////////////////////////////////////////////
/// \brief Set the limit on the ratio between miter length and outline thickness of a circle shape
///
/// Outline segments around each corner are joined either
/// with a miter or a bevel join.
/// - A miter join is formed by extending outline segments until
/// they intersect. The distance between the point of
/// intersection and the shape's corner is the miter length.
/// - A bevel join is formed by connecting outline segments with
/// a straight line perpendicular to the corner's bisector.
///
/// The miter limit is used to determine whether outline segments
/// around a corner are joined with a bevel or a miter.
/// When the ratio between the miter length and outline thickness
/// exceeds the miter limit, a bevel is used instead of a miter.
///
/// The miter limit is linked to the maximum inner angle of a
/// corner below which a bevel is used by the following formula:
///
/// miterLimit = 1 / sin(angle / 2)
///
/// The miter limit must be greater than or equal to 1.
/// By default, the miter limit is 10.
///
/// \param shape Shape object
/// \param miterLimit New miter limit
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfCircleShape_setMiterLimit(sfCircleShape* shape, float miterLimit);
////////////////////////////////////////////////////////////
/// \brief Get the source texture of a circle shape
///
@@ -345,6 +376,16 @@ CSFML_GRAPHICS_API sfColor sfCircleShape_getOutlineColor(const sfCircleShape* sh
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API float sfCircleShape_getOutlineThickness(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the limit on the ratio between miter length and outline thickness of a circle shape
///
/// \param shape Shape object
///
/// \return Limit on the ratio between miter length and outline thickness
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API float sfCircleShape_getMiterLimit(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the total number of points of a circle shape
///
@@ -368,6 +409,20 @@ CSFML_GRAPHICS_API size_t sfCircleShape_getPointCount(const sfCircleShape* shape
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfCircleShape_getPoint(const sfCircleShape* shape, size_t index);
////////////////////////////////////////////////////////////
/// \brief Get the geometric center of the circle
///
/// The returned point is in local coordinates, that is,
/// the shape's transforms (position, rotation, scale) are
/// not taken into account.
///
/// \param shape Shape object
///
/// \return The geometric center of the shape
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfCircleShape_getGeometricCenter(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Set the radius of a circle
///
@@ -427,6 +482,3 @@ CSFML_GRAPHICS_API sfFloatRect sfCircleShape_getLocalBounds(const sfCircleShape*
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfCircleShape_getGlobalBounds(const sfCircleShape* shape);
#endif // SFML_CIRCLESHAPE_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,13 +22,12 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_COLOR_H
#define SFML_COLOR_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <CSFML/Graphics/Export.h>
////////////////////////////////////////////////////////////
@@ -37,22 +36,22 @@
////////////////////////////////////////////////////////////
typedef struct
{
sfUint8 r;
sfUint8 g;
sfUint8 b;
sfUint8 a;
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
} sfColor;
CSFML_GRAPHICS_API sfColor sfBlack; ///< Black predefined color
CSFML_GRAPHICS_API sfColor sfWhite; ///< White predefined color
CSFML_GRAPHICS_API sfColor sfRed; ///< Red predefined color
CSFML_GRAPHICS_API sfColor sfGreen; ///< Green predefined color
CSFML_GRAPHICS_API sfColor sfBlue; ///< Blue predefined color
CSFML_GRAPHICS_API sfColor sfYellow; ///< Yellow predefined color
CSFML_GRAPHICS_API sfColor sfMagenta; ///< Magenta predefined color
CSFML_GRAPHICS_API sfColor sfCyan; ///< Cyan predefined color
CSFML_GRAPHICS_API sfColor sfTransparent; ///< Transparent (black) predefined color
CSFML_GRAPHICS_API const sfColor sfBlack; ///< Black predefined color
CSFML_GRAPHICS_API const sfColor sfWhite; ///< White predefined color
CSFML_GRAPHICS_API const sfColor sfRed; ///< Red predefined color
CSFML_GRAPHICS_API const sfColor sfGreen; ///< Green predefined color
CSFML_GRAPHICS_API const sfColor sfBlue; ///< Blue predefined color
CSFML_GRAPHICS_API const sfColor sfYellow; ///< Yellow predefined color
CSFML_GRAPHICS_API const sfColor sfMagenta; ///< Magenta predefined color
CSFML_GRAPHICS_API const sfColor sfCyan; ///< Cyan predefined color
CSFML_GRAPHICS_API const sfColor sfTransparent; ///< Transparent (black) predefined color
////////////////////////////////////////////////////////////
@@ -65,7 +64,7 @@ CSFML_GRAPHICS_API sfColor sfTransparent; ///< Transparent (black) predefined co
/// \return sfColor constructed from the components
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfColor sfColor_fromRGB(sfUint8 red, sfUint8 green, sfUint8 blue);
CSFML_GRAPHICS_API sfColor sfColor_fromRGB(uint8_t red, uint8_t green, uint8_t blue);
////////////////////////////////////////////////////////////
/// \brief Construct a color from its 4 RGBA components
@@ -78,7 +77,7 @@ CSFML_GRAPHICS_API sfColor sfColor_fromRGB(sfUint8 red, sfUint8 green, sfUint8 b
/// \return sfColor constructed from the components
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfColor sfColor_fromRGBA(sfUint8 red, sfUint8 green, sfUint8 blue, sfUint8 alpha);
CSFML_GRAPHICS_API sfColor sfColor_fromRGBA(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha);
////////////////////////////////////////////////////////////
/// \brief Construct the color from 32-bit unsigned integer
@@ -88,7 +87,7 @@ CSFML_GRAPHICS_API sfColor sfColor_fromRGBA(sfUint8 red, sfUint8 green, sfUint8
/// \return sfColor constructed from the 32-bit unsigned integer
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfColor sfColor_fromInteger(sfUint32 color);
CSFML_GRAPHICS_API sfColor sfColor_fromInteger(uint32_t color);
////////////////////////////////////////////////////////////
/// \brief Convert a color to a 32-bit unsigned integer
@@ -96,7 +95,7 @@ CSFML_GRAPHICS_API sfColor sfColor_fromInteger(sfUint32 color);
/// \return Color represented as a 32-bit unsigned integer
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfUint32 sfColor_toInteger(sfColor color);
CSFML_GRAPHICS_API uint32_t sfColor_toInteger(sfColor color);
////////////////////////////////////////////////////////////
/// \brief Add two colors
@@ -130,6 +129,3 @@ CSFML_GRAPHICS_API sfColor sfColor_subtract(sfColor color1, sfColor color2);
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfColor sfColor_modulate(sfColor color1, sfColor color2);
#endif // SFML_COLOR_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,18 +22,19 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_CONVEXSHAPE_H
#define SFML_CONVEXSHAPE_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Types.h>
#include <SFML/System/Vector2.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/Color.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/Transform.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/System/Vector2.h>
#include <stddef.h>
@@ -61,7 +62,7 @@ CSFML_GRAPHICS_API sfConvexShape* sfConvexShape_copy(const sfConvexShape* shape)
/// \param shape Shape to delete
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfConvexShape_destroy(sfConvexShape* shape);
CSFML_GRAPHICS_API void sfConvexShape_destroy(const sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Set the position of a convex shape
@@ -235,7 +236,7 @@ CSFML_GRAPHICS_API sfTransform sfConvexShape_getInverseTransform(const sfConvexS
/// \param resetRect Should the texture rect be reset to the size of the new texture?
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfConvexShape_setTexture(sfConvexShape* shape, const sfTexture* texture, sfBool resetRect);
CSFML_GRAPHICS_API void sfConvexShape_setTexture(sfConvexShape* shape, const sfTexture* texture, bool resetRect);
////////////////////////////////////////////////////////////
/// \brief Set the sub-rectangle of the texture that a convex shape will display
@@ -291,6 +292,36 @@ CSFML_GRAPHICS_API void sfConvexShape_setOutlineColor(sfConvexShape* shape, sfCo
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfConvexShape_setOutlineThickness(sfConvexShape* shape, float thickness);
////////////////////////////////////////////////////////////
/// \brief Set the limit on the ratio between miter length and outline thickness of a convex shape
///
/// Outline segments around each corner are joined either
/// with a miter or a bevel join.
/// - A miter join is formed by extending outline segments until
/// they intersect. The distance between the point of
/// intersection and the shape's corner is the miter length.
/// - A bevel join is formed by connecting outline segments with
/// a straight line perpendicular to the corner's bisector.
///
/// The miter limit is used to determine whether outline segments
/// around a corner are joined with a bevel or a miter.
/// When the ratio between the miter length and outline thickness
/// exceeds the miter limit, a bevel is used instead of a miter.
///
/// The miter limit is linked to the maximum inner angle of a
/// corner below which a bevel is used by the following formula:
///
/// miterLimit = 1 / sin(angle / 2)
///
/// The miter limit must be greater than or equal to 1.
/// By default, the miter limit is 10.
///
/// \param shape Shape object
/// \param miterLimit New miter limit
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfConvexShape_setMiterLimit(sfConvexShape* shape, float miterLimit);
////////////////////////////////////////////////////////////
/// \brief Get the source texture of a convex shape
///
@@ -345,6 +376,16 @@ CSFML_GRAPHICS_API sfColor sfConvexShape_getOutlineColor(const sfConvexShape* sh
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API float sfConvexShape_getOutlineThickness(const sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the limit on the ratio between miter length and outline thickness of a convex shape
///
/// \param shape Shape object
///
/// \return Limit on the ratio between miter length and outline thickness
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API float sfConvexShape_getMiterLimit(const sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the total number of points of a convex shape
///
@@ -368,6 +409,20 @@ CSFML_GRAPHICS_API size_t sfConvexShape_getPointCount(const sfConvexShape* shape
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfConvexShape_getPoint(const sfConvexShape* shape, size_t index);
////////////////////////////////////////////////////////////
/// \brief Get the geometric center of a convex shape
///
/// The returned point is in local coordinates, that is,
/// the shape's transforms (position, rotation, scale) are
/// not taken into account.
///
/// \param shape Shape object
///
/// \return The geometric center of the shape
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfConvexShape_getGeometricCenter(const sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Set the number of points of a convex shap
///
@@ -389,7 +444,7 @@ CSFML_GRAPHICS_API void sfConvexShape_setPointCount(sfConvexShape* shape, size_t
/// of the valid range.
///
/// \param shape Shape object
/// \param index Index of the point to change, in range [0 .. GetPointCount() - 1]
/// \param index Index of the point to change, in range [0 .. getPointCount() - 1]
/// \param point New point
///
////////////////////////////////////////////////////////////
@@ -426,6 +481,3 @@ CSFML_GRAPHICS_API sfFloatRect sfConvexShape_getLocalBounds(const sfConvexShape*
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfConvexShape_getGlobalBounds(const sfConvexShape* shape);
#endif // SFML_CONVEXSHAPE_H
+35
View File
@@ -0,0 +1,35 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
/// \brief Types of texture coordinates that can be used for rendering.
///
////////////////////////////////////////////////////////////
typedef enum
{
sfCoordinateTypeNormalized, ///< sfTexture coordinates in range [0 .. 1].
sfCoordinateTypePixels ///< sfTexture coordinates in range [0 .. size].
} sfCoordinateType;
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,13 +22,12 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_GRAPHICS_EXPORT_H
#define SFML_GRAPHICS_EXPORT_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <CSFML/Config.h>
////////////////////////////////////////////////////////////
@@ -36,13 +35,10 @@
////////////////////////////////////////////////////////////
#if defined(CSFML_GRAPHICS_EXPORTS)
#define CSFML_GRAPHICS_API CSFML_API_EXPORT
#define CSFML_GRAPHICS_API CSFML_API_EXPORT
#else
#define CSFML_GRAPHICS_API CSFML_API_IMPORT
#define CSFML_GRAPHICS_API CSFML_API_IMPORT
#endif
#endif // SFML_GRAPHICS_EXPORT_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,17 +22,18 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_FONT_H
#define SFML_FONT_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/FontInfo.h>
#include <SFML/Graphics/Glyph.h>
#include <SFML/Graphics/Types.h>
#include <SFML/System/InputStream.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/FontInfo.h>
#include <CSFML/Graphics/Glyph.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/System/InputStream.h>
#include <stddef.h>
@@ -83,7 +84,7 @@ CSFML_GRAPHICS_API sfFont* sfFont_copy(const sfFont* font);
/// \param font Font to delete
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfFont_destroy(sfFont* font);
CSFML_GRAPHICS_API void sfFont_destroy(const sfFont* font);
////////////////////////////////////////////////////////////
/// \brief Get a glyph in a font
@@ -97,7 +98,33 @@ CSFML_GRAPHICS_API void sfFont_destroy(sfFont* font);
/// \return The corresponding glyph
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfGlyph sfFont_getGlyph(const sfFont* font, sfUint32 codePoint, unsigned int characterSize, sfBool bold, float outlineThickness);
CSFML_GRAPHICS_API sfGlyph
sfFont_getGlyph(const sfFont* font, uint32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness);
////////////////////////////////////////////////////////////
/// \brief Get a glyph in a font by glyph ID
///
/// If the font is a bitmap font, not all character sizes
/// might be available. If the glyph is not available at the
/// requested size, an empty glyph is returned.
///
/// Glyph IDs are font specific and are for example
/// provided by the shaped glyphs of a text.
///
/// Be aware that using a negative value for the outline
/// thickness will cause distorted rendering.
///
/// \param font Source font
/// \param id ID of the glyph to get
/// \param characterSize Character size, in pixels
/// \param bold Retrieve the bold version or the regular one?
/// \param outlineThickness Thickness of outline (when != 0 the glyph will not be filled)
///
/// \return The corresponding glyph
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfGlyph
sfFont_getGlyphById(const sfFont* font, uint32_t id, unsigned int characterSize, bool bold, float outlineThickness);
////////////////////////////////////////////////////////////
/// \brief Determine if this font has a glyph representing the requested code point
@@ -113,10 +140,10 @@ CSFML_GRAPHICS_API sfGlyph sfFont_getGlyph(const sfFont* font, sfUint32 codePoin
/// \param font Source font
/// \param codePoint Unicode code point to check
///
/// \return sfTrue if the codepoint has a glyph representation, sfFalse otherwise
/// \return True if the codepoint has a glyph representation, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfFont_hasGlyph(const sfFont* font, sfUint32 codePoint);
CSFML_GRAPHICS_API bool sfFont_hasGlyph(const sfFont* font, uint32_t codePoint);
////////////////////////////////////////////////////////////
/// \brief Get the kerning value corresponding to a given pair of characters in a font
@@ -129,7 +156,7 @@ CSFML_GRAPHICS_API sfBool sfFont_hasGlyph(const sfFont* font, sfUint32 codePoint
/// \return Kerning offset, in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API float sfFont_getKerning(const sfFont* font, sfUint32 first, sfUint32 second, unsigned int characterSize);
CSFML_GRAPHICS_API float sfFont_getKerning(const sfFont* font, uint32_t first, uint32_t second, unsigned int characterSize);
////////////////////////////////////////////////////////////
/// \brief Get the bold kerning value corresponding to a given pair of characters in a font
@@ -142,7 +169,7 @@ CSFML_GRAPHICS_API float sfFont_getKerning(const sfFont* font, sfUint32 first, s
/// \return Kerning offset, in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API float sfFont_getBoldKerning(const sfFont* font, sfUint32 first, sfUint32 second, unsigned int characterSize);
CSFML_GRAPHICS_API float sfFont_getBoldKerning(const sfFont* font, uint32_t first, uint32_t second, unsigned int characterSize);
////////////////////////////////////////////////////////////
/// \brief Get the line spacing value
@@ -155,6 +182,44 @@ CSFML_GRAPHICS_API float sfFont_getBoldKerning(const sfFont* font, sfUint32 firs
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API float sfFont_getLineSpacing(const sfFont* font, unsigned int characterSize);
////////////////////////////////////////////////////////////
/// \brief Get the ascent of a font
///
/// The ascent is the largest distance between the baseline and
/// the top of all glyphs in the font.
///
/// Be aware that there is no uniform definition of how the
/// ascent is calculated. It can vary from font to font.
///
/// \param font Source font
/// \param characterSize Reference character size
///
/// \return Ascent, in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API float sfFont_getAscent(const sfFont* font, unsigned int characterSize);
////////////////////////////////////////////////////////////
/// \brief Get the descent of a font
///
/// The descent is the largest distance between the baseline and
/// the bottom of all glyphs in the font.
///
/// Be aware that there is no uniform definition of how the
/// descent is calculated. It can vary from font to font.
///
/// The descent shares the same coordinate system as the
/// ascent. This means that it will be negative for distances
/// below the baseline.
///
/// \param font Source font
/// \param characterSize Reference character size
///
/// \return Descent, in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API float sfFont_getDescent(const sfFont* font, unsigned int characterSize);
////////////////////////////////////////////////////////////
/// \brief Get the position of the underline
///
@@ -203,24 +268,24 @@ CSFML_GRAPHICS_API const sfTexture* sfFont_getTexture(sfFont* font, unsigned int
/// The smooth filter is enabled by default.
///
/// \param font Source font
/// \param smooth sfTrue to enable smoothing, sfFalse to disable it
/// \param smooth true to enable smoothing, false to disable it
///
/// \see isSmooth
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfFont_setSmooth(sfFont* font, sfBool smooth);
CSFML_GRAPHICS_API void sfFont_setSmooth(sfFont* font, bool smooth);
////////////////////////////////////////////////////////////
/// \brief Tell whether the smooth filter is enabled or disabled
///
/// \param font Source font
///
/// \return sfTrue if smoothing is enabled, sfFalse if it is disabled
/// \return true if smoothing is enabled, false if it is disabled
///
/// \see setSmooth
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfFont_isSmooth(const sfFont* font);
CSFML_GRAPHICS_API bool sfFont_isSmooth(const sfFont* font);
////////////////////////////////////////////////////////////
/// \brief Get the font information
@@ -235,6 +300,3 @@ CSFML_GRAPHICS_API sfBool sfFont_isSmooth(const sfFont* font);
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFontInfo sfFont_getInfo(const sfFont* font);
#endif // SFML_FONT_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,21 +22,23 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_FONTINFO_H
#define SFML_FONTINFO_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <CSFML/Graphics/Export.h>
#include <stdbool.h>
#include <stdint.h>
////////////////////////////////////////////////////////////
/// sfFontInfo holds various information about a font
////////////////////////////////////////////////////////////
typedef struct
{
const char* family;
uint64_t id; ///< A unique ID that identifies the font
const char* family; ///< The font family
bool hasKerning; ///< Has kerning information
bool hasVerticalMetrics; ///< Has native vertical metrics
} sfFontInfo;
#endif // SFML_FONTINFO_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,16 +22,15 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_GLSL_H
#define SFML_GLSL_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Color.h>
#include <SFML/System/Vector2.h>
#include <SFML/System/Vector3.h>
#include <CSFML/Graphics/Color.h>
#include <CSFML/Graphics/Transform.h>
#include <CSFML/System/Vector2.h>
#include <CSFML/System/Vector3.h>
// 2D vectors
typedef sfVector2f sfGlslVec2;
@@ -39,8 +38,8 @@ typedef sfVector2i sfGlslIvec2;
typedef struct
{
sfBool x;
sfBool y;
bool x;
bool y;
} sfGlslBvec2;
// 3D vectors
@@ -55,9 +54,9 @@ typedef struct
typedef struct
{
sfBool x;
sfBool y;
sfBool z;
bool x;
bool y;
bool z;
} sfGlslBvec3;
// 4D vectors
@@ -79,10 +78,10 @@ typedef struct
typedef struct
{
sfBool x;
sfBool y;
sfBool z;
sfBool w;
bool x;
bool y;
bool z;
bool w;
} sfGlslBvec4;
// matrices
@@ -95,6 +94,3 @@ typedef struct
{
float array[4 * 4];
} sfGlslMat4;
#endif // SFML_GLSL_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,13 +22,12 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_GLYPH_H
#define SFML_GLYPH_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Rect.h>
#include <CSFML/Graphics/Rect.h>
////////////////////////////////////////////////////////////
@@ -41,6 +40,3 @@ typedef struct
sfFloatRect bounds; ///< Bounding rectangle of the glyph, in coordinates relative to the baseline
sfIntRect textureRect; ///< Texture coordinates of the glyph inside the font's image
} sfGlyph;
#endif // SFML_GLYPH_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,19 +22,20 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_IMAGE_H
#define SFML_IMAGE_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
#include <SFML/System/Buffer.h>
#include <SFML/System/InputStream.h>
#include <SFML/System/Vector2.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/Color.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/System/Buffer.h>
#include <CSFML/System/InputStream.h>
#include <CSFML/System/Vector2.h>
#include <stddef.h>
@@ -43,25 +44,23 @@
///
/// This image is filled with black pixels.
///
/// \param width Width of the image
/// \param height Height of the image
/// \param size Size of the image
///
/// \return A new sfImage object
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfImage* sfImage_create(unsigned int width, unsigned int height);
CSFML_GRAPHICS_API sfImage* sfImage_create(sfVector2u size);
////////////////////////////////////////////////////////////
/// \brief Create an image and fill it with a unique color
///
/// \param width Width of the image
/// \param height Height of the image
/// \param color Fill color
/// \param size Size of the image
/// \param color Fill color
///
/// \return A new sfImage object
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfImage* sfImage_createFromColor(unsigned int width, unsigned int height, sfColor color);
CSFML_GRAPHICS_API sfImage* sfImage_createFromColor(sfVector2u size, sfColor color);
////////////////////////////////////////////////////////////
/// \brief Create an image from an array of pixels
@@ -71,21 +70,20 @@ CSFML_GRAPHICS_API sfImage* sfImage_createFromColor(unsigned int width, unsigned
/// an undefined behaviour.
/// If \a pixels is null, an empty image is created.
///
/// \param width Width of the image
/// \param height Height of the image
/// \param size Size of the image
/// \param pixels Array of pixels to copy to the image
///
/// \return A new sfImage object
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfImage* sfImage_createFromPixels(unsigned int width, unsigned int height, const sfUint8* pixels);
CSFML_GRAPHICS_API sfImage* sfImage_createFromPixels(sfVector2u size, const uint8_t* pixels);
////////////////////////////////////////////////////////////
/// \brief Create an image from a file on disk
///
/// The supported image formats are bmp, png, tga, jpg, gif,
/// psd, hdr and pic. Some format options are not supported,
/// like progressive jpeg.
/// psd, hdr, pic, pnm and qoi. Some format options are not supported,
/// like jpeg with arithmetic coding or ASCII pnm.
/// If this function fails, the image is left unchanged.
///
/// \param filename Path of the image file to load
@@ -99,8 +97,8 @@ CSFML_GRAPHICS_API sfImage* sfImage_createFromFile(const char* filename);
/// \brief Create an image from a file in memory
///
/// The supported image formats are bmp, png, tga, jpg, gif,
/// psd, hdr and pic. Some format options are not supported,
/// like progressive jpeg.
/// psd, hdr, pic, pnm and qoi. Some format options are not supported,
/// like jpeg with arithmetic coding or ASCII pnm.
/// If this function fails, the image is left unchanged.
///
/// \param data Pointer to the file data in memory
@@ -115,8 +113,8 @@ CSFML_GRAPHICS_API sfImage* sfImage_createFromMemory(const void* data, size_t si
/// \brief Create an image from a custom stream
///
/// The supported image formats are bmp, png, tga, jpg, gif,
/// psd, hdr and pic. Some format options are not supported,
/// like progressive jpeg.
/// psd, hdr, pic, pnm and qoi. Some format options are not supported,
/// like jpeg with arithmetic coding or ASCII pnm.
/// If this function fails, the image is left unchanged.
///
/// \param stream Source stream to read from
@@ -142,31 +140,31 @@ CSFML_GRAPHICS_API sfImage* sfImage_copy(const sfImage* image);
/// \param image Image to delete
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfImage_destroy(sfImage* image);
CSFML_GRAPHICS_API void sfImage_destroy(const sfImage* image);
////////////////////////////////////////////////////////////
/// \brief Save an image to a file on disk
///
/// The format of the image is automatically deduced from
/// the extension. The supported image formats are bmp, png,
/// tga and jpg. The destination file is overwritten
/// tga, jpg and qoi. The destination file is overwritten
/// if it already exists. This function fails if the image is empty.
///
/// \param image Image object
/// \param filename Path of the file to save
///
/// \return sfTrue if saving was successful
/// \return true if saving was successful
///
/// \see sfImage_saveToMemory
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfImage_saveToFile(const sfImage* image, const char* filename);
CSFML_GRAPHICS_API bool sfImage_saveToFile(const sfImage* image, const char* filename);
////////////////////////////////////////////////////////////
/// \brief Save the image to a buffer in memory
///
/// The format of the image must be specified.
/// The supported image formats are bmp, png, tga and jpg.
/// The supported image formats are bmp, png, tga, jpg and qoi.
/// This function fails if the image is empty, or if
/// the format was invalid.
///
@@ -174,12 +172,12 @@ CSFML_GRAPHICS_API sfBool sfImage_saveToFile(const sfImage* image, const char* f
/// \param output Buffer to fill with encoded data
/// \param format Encoding format to use
///
/// \return sfTrue if saving was successful
/// \return true if saving was successful
///
/// \see sfImage_saveToFile
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfImage_saveToMemory(const sfImage* image, sfBuffer* output, const char* format);
CSFML_GRAPHICS_API bool sfImage_saveToMemory(const sfImage* image, sfBuffer* output, const char* format);
////////////////////////////////////////////////////////////
/// \brief Return the size of an image
@@ -203,7 +201,7 @@ CSFML_GRAPHICS_API sfVector2u sfImage_getSize(const sfImage* image);
/// \param alpha Alpha value to assign to transparent pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfImage_createMaskFromColor(sfImage* image, sfColor color, sfUint8 alpha);
CSFML_GRAPHICS_API void sfImage_createMaskFromColor(sfImage* image, sfColor color, uint8_t alpha);
////////////////////////////////////////////////////////////
/// \brief Copy pixels from an image onto another
@@ -220,13 +218,14 @@ CSFML_GRAPHICS_API void sfImage_createMaskFromColor(sfImage* image, sfColor colo
///
/// \param image Image object
/// \param source Source image to copy
/// \param destX X coordinate of the destination position
/// \param destY Y coordinate of the destination position
/// \param dest Coordinates of the destination position
/// \param sourceRect Sub-rectangle of the source image to copy
/// \param applyAlpha Should the copy take in account the source transparency?
///
/// \return True if the operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfImage_copyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect, sfBool applyAlpha);
CSFML_GRAPHICS_API bool sfImage_copyImage(sfImage* image, const sfImage* source, sfVector2u dest, sfIntRect sourceRect, bool applyAlpha);
////////////////////////////////////////////////////////////
/// \brief Change the color of a pixel in an image
@@ -235,13 +234,12 @@ CSFML_GRAPHICS_API void sfImage_copyImage(sfImage* image, const sfImage* source,
/// coordinates, using out-of-range values will result in
/// an undefined behaviour.
///
/// \param image Image object
/// \param x X coordinate of pixel to change
/// \param y Y coordinate of pixel to change
/// \param color New color of the pixel
/// \param image Image object
/// \param coords Coordinates of pixel to change
/// \param color New color of the pixel
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfImage_setPixel(sfImage* image, unsigned int x, unsigned int y, sfColor color);
CSFML_GRAPHICS_API void sfImage_setPixel(sfImage* image, sfVector2u coords, sfColor color);
////////////////////////////////////////////////////////////
/// \brief Get the color of a pixel in an image
@@ -250,14 +248,13 @@ CSFML_GRAPHICS_API void sfImage_setPixel(sfImage* image, unsigned int x, unsigne
/// coordinates, using out-of-range values will result in
/// an undefined behaviour.
///
/// \param image Image object
/// \param x X coordinate of pixel to get
/// \param y Y coordinate of pixel to get
/// \param image Image object
/// \param coords Coordinates of pixel to get
///
/// \return Color of the pixel at coordinates (x, y)
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfColor sfImage_getPixel(const sfImage* image, unsigned int x, unsigned int y);
CSFML_GRAPHICS_API sfColor sfImage_getPixel(const sfImage* image, sfVector2u coords);
////////////////////////////////////////////////////////////
/// \brief Get a read-only pointer to the array of pixels of an image
@@ -274,7 +271,7 @@ CSFML_GRAPHICS_API sfColor sfImage_getPixel(const sfImage* image, unsigned int x
/// \return Read-only pointer to the array of pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfUint8* sfImage_getPixelsPtr(const sfImage* image);
CSFML_GRAPHICS_API const uint8_t* sfImage_getPixelsPtr(const sfImage* image);
////////////////////////////////////////////////////////////
/// \brief Flip an image horizontally (left <-> right)
@@ -291,6 +288,3 @@ CSFML_GRAPHICS_API void sfImage_flipHorizontally(sfImage* image);
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfImage_flipVertically(sfImage* image);
#endif // SFML_IMAGE_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,17 +22,16 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_PRIMITIVETYPE_H
#define SFML_PRIMITIVETYPE_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <CSFML/Graphics/Export.h>
////////////////////////////////////////////////////////////
/// \brief Types of primitives that a sf::VertexArray can render
/// \brief Types of primitives that an sfVertexArray can render
///
/// Points and lines have no area, therefore their thickness
/// will always be 1 pixel, regardless the current transform
@@ -46,13 +45,5 @@ typedef enum
sfLineStrip, ///< List of connected lines, a point uses the previous point to form a line
sfTriangles, ///< List of individual triangles
sfTriangleStrip, ///< List of connected triangles, a point uses the two previous points to form a triangle
sfTriangleFan, ///< List of connected triangles, a point uses the common center and the previous point to form a triangle
sfQuads, ///< List of individual quads
sfLinesStrip = sfLineStrip, ///< \deprecated Use sfLineStrip instead
sfTrianglesStrip = sfTriangleStrip, ///< \deprecated Use sfTriangleStrip instead
sfTrianglesFan = sfTriangleFan ///< \deprecated Use sfTriangleFan instead
sfTriangleFan, ///< List of connected triangles, a point uses the common center and the previous point to form a triangle
} sfPrimitiveType;
#endif // SFML_BLENDMODE_H
+74
View File
@@ -0,0 +1,74 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <CSFML/Graphics/Export.h>
#include <CSFML/System/Vector2.h>
////////////////////////////////////////////////////////////
/// sfFloatRect and sfIntRect are utility classes for
/// manipulating rectangles.
////////////////////////////////////////////////////////////
typedef struct
{
sfVector2f position;
sfVector2f size;
} sfFloatRect;
typedef struct
{
sfVector2i position;
sfVector2i size;
} sfIntRect;
////////////////////////////////////////////////////////////
/// \brief Check if a point is inside a rectangle's area
///
/// \param rect Rectangle to test
/// \param point Coordinates of the point to test
///
/// \return true if the point is inside
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API bool sfFloatRect_contains(const sfFloatRect* rect, sfVector2f point);
CSFML_GRAPHICS_API bool sfIntRect_contains(const sfIntRect* rect, sfVector2i point);
////////////////////////////////////////////////////////////
/// \brief Check intersection between two rectangles
///
/// \param rect1 First rectangle to test
/// \param rect2 Second rectangle to test
/// \param intersection Rectangle to be filled with overlapping rect (can be NULL)
///
/// \return true if rectangles overlap
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API bool sfFloatRect_intersects(const sfFloatRect* rect1, const sfFloatRect* rect2, sfFloatRect* intersection);
CSFML_GRAPHICS_API bool sfIntRect_intersects(const sfIntRect* rect1, const sfIntRect* rect2, sfIntRect* intersection);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,18 +22,19 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_RECTANGLESHAPE_H
#define SFML_RECTANGLESHAPE_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Types.h>
#include <SFML/System/Vector2.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/Color.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/Transform.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/System/Vector2.h>
#include <stddef.h>
@@ -61,7 +62,7 @@ CSFML_GRAPHICS_API sfRectangleShape* sfRectangleShape_copy(const sfRectangleShap
/// \param shape Shape to delete
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRectangleShape_destroy(sfRectangleShape* shape);
CSFML_GRAPHICS_API void sfRectangleShape_destroy(const sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Set the position of a rectangle shape
@@ -235,7 +236,7 @@ CSFML_GRAPHICS_API sfTransform sfRectangleShape_getInverseTransform(const sfRect
/// \param resetRect Should the texture rect be reset to the size of the new texture?
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRectangleShape_setTexture(sfRectangleShape* shape, const sfTexture* texture, sfBool resetRect);
CSFML_GRAPHICS_API void sfRectangleShape_setTexture(sfRectangleShape* shape, const sfTexture* texture, bool resetRect);
////////////////////////////////////////////////////////////
/// \brief Set the sub-rectangle of the texture that a rectangle shape will display
@@ -291,6 +292,36 @@ CSFML_GRAPHICS_API void sfRectangleShape_setOutlineColor(sfRectangleShape* shape
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRectangleShape_setOutlineThickness(sfRectangleShape* shape, float thickness);
////////////////////////////////////////////////////////////
/// \brief Set the limit on the ratio between miter length and outline thickness of a rectangle shape
///
/// Outline segments around each corner are joined either
/// with a miter or a bevel join.
/// - A miter join is formed by extending outline segments until
/// they intersect. The distance between the point of
/// intersection and the shape's corner is the miter length.
/// - A bevel join is formed by connecting outline segments with
/// a straight line perpendicular to the corner's bisector.
///
/// The miter limit is used to determine whether outline segments
/// around a corner are joined with a bevel or a miter.
/// When the ratio between the miter length and outline thickness
/// exceeds the miter limit, a bevel is used instead of a miter.
///
/// The miter limit is linked to the maximum inner angle of a
/// corner below which a bevel is used by the following formula:
///
/// miterLimit = 1 / sin(angle / 2)
///
/// The miter limit must be greater than or equal to 1.
/// By default, the miter limit is 10.
///
/// \param shape Shape object
/// \param miterLimit New miter limit
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRectangleShape_setMiterLimit(sfRectangleShape* shape, float miterLimit);
////////////////////////////////////////////////////////////
/// \brief Get the source texture of a rectangle shape
///
@@ -345,6 +376,16 @@ CSFML_GRAPHICS_API sfColor sfRectangleShape_getOutlineColor(const sfRectangleSha
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API float sfRectangleShape_getOutlineThickness(const sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the limit on the ratio between miter length and outline thickness of a rectangle shape
///
/// \param shape Shape object
///
/// \return Limit on the ratio between miter length and outline thickness
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API float sfRectangleShape_getMiterLimit(const sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the total number of points of a rectangle shape
///
@@ -368,6 +409,20 @@ CSFML_GRAPHICS_API size_t sfRectangleShape_getPointCount(const sfRectangleShape*
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfRectangleShape_getPoint(const sfRectangleShape* shape, size_t index);
////////////////////////////////////////////////////////////
/// \brief Get the geometric center of the rectangle
///
/// The returned point is in local coordinates, that is,
/// the shape's transforms (position, rotation, scale) are
/// not taken into account.
///
/// \param shape Shape object
///
/// \return The geometric center of the shape
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfRectangleShape_getGeometricCenter(const sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Set the size of a rectangle shape
///
@@ -418,6 +473,3 @@ CSFML_GRAPHICS_API sfFloatRect sfRectangleShape_getLocalBounds(const sfRectangle
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfRectangleShape_getGlobalBounds(const sfRectangleShape* shape);
#endif // SFML_RECTANGLESHAPE_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,16 +22,18 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_RENDERSTATES_H
#define SFML_RENDERSTATES_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/BlendMode.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Types.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/BlendMode.h>
#include <CSFML/Graphics/CoordinateType.h>
#include <CSFML/Graphics/StencilMode.h>
#include <CSFML/Graphics/Transform.h>
#include <CSFML/Graphics/Types.h>
////////////////////////////////////////////////////////////
@@ -40,16 +42,16 @@
////////////////////////////////////////////////////////////
typedef struct
{
sfBlendMode blendMode; ///< Blending mode
sfTransform transform; ///< Transform
const sfTexture* texture; ///< Texture
const sfShader* shader; ///< Shader
sfBlendMode blendMode; ///< Blending mode
sfStencilMode stencilMode; //!< Stencil mode
sfTransform transform; ///< Transform
sfCoordinateType coordinateType; //!< Texture coordinate type
const sfTexture* texture; ///< Texture
const sfShader* shader; ///< Shader
} sfRenderStates;
////////////////////////////////////////////////////////////
/// \brief Define the default values for a RenderState
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfRenderStates sfRenderStates_default(void);
#endif // SFML_RENDERSTATES_H
CSFML_GRAPHICS_API const sfRenderStates sfRenderStates_default;
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,50 +22,36 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_RENDERTEXTURE_H
#define SFML_RENDERTEXTURE_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
#include <SFML/Graphics/PrimitiveType.h>
#include <SFML/Graphics/RenderStates.h>
#include <SFML/Graphics/Vertex.h>
#include <SFML/Window/Window.h>
#include <SFML/System/Vector2.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/Color.h>
#include <CSFML/Graphics/PrimitiveType.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/RenderStates.h>
#include <CSFML/Graphics/StencilMode.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/Graphics/Vertex.h>
#include <CSFML/System/Vector2.h>
#include <CSFML/Window/Window.h>
#include <stddef.h>
////////////////////////////////////////////////////////////
/// \brief Construct a new render texture
///
/// \param width Width of the render texture
/// \param height Height of the render texture
/// \param depthBuffer Do you want a depth-buffer attached? (useful only if you're doing 3D OpenGL on the rendertexture)
///
/// \return A new sfRenderTexture object, or NULL if it failed
///
/// \deprecated
/// Use sfRenderTexture_createWithSettings instead.
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_create(unsigned int width, unsigned int height, sfBool depthBuffer);
////////////////////////////////////////////////////////////
/// \brief Construct a new render texture
///
/// \param width Width of the render texture
/// \param height Height of the render texture
/// \param size Size of the render texture
/// \param settings Settings of the render texture
///
/// \return A new sfRenderTexture object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_createWithSettings(unsigned int width, unsigned int height, const sfContextSettings* settings);
CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_create(sfVector2u size, const sfContextSettings* settings);
////////////////////////////////////////////////////////////
/// \brief Destroy an existing render texture
@@ -73,7 +59,7 @@ CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_createWithSettings(unsigned
/// \param renderTexture Render texture to destroy
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderTexture_destroy(sfRenderTexture* renderTexture);
CSFML_GRAPHICS_API void sfRenderTexture_destroy(const sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// \brief Get the size of the rendering region of a render texture
@@ -90,21 +76,21 @@ CSFML_GRAPHICS_API sfVector2u sfRenderTexture_getSize(const sfRenderTexture* ren
///
/// \param renderTexture Render texture object
///
/// \return sfTrue if the render texture use sRGB encoding, sfFalse otherwise
/// \return true if the render texture use sRGB encoding, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfRenderTexture_isSrgb(const sfRenderTexture* renderTexture);
CSFML_GRAPHICS_API bool sfRenderTexture_isSrgb(const sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// \brief Activate or deactivate a render texture as the current target for rendering
///
/// \param renderTexture Render texture object
/// \param active sfTrue to activate, sfFalse to deactivate
/// \param active true to activate, false to deactivate
///
/// \return True if operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfRenderTexture_setActive(sfRenderTexture* renderTexture, sfBool active);
CSFML_GRAPHICS_API bool sfRenderTexture_setActive(sfRenderTexture* renderTexture, bool active);
////////////////////////////////////////////////////////////
/// \brief Update the contents of the target texture
@@ -123,6 +109,33 @@ CSFML_GRAPHICS_API void sfRenderTexture_display(sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderTexture_clear(sfRenderTexture* renderTexture, sfColor color);
////////////////////////////////////////////////////////////
/// \brief Clear the stencil buffer to a specific value
///
/// The specified value is truncated to the bit width of
/// the current stencil buffer.
///
/// \param renderTexture Render texture object
/// \param stencilValue Stencil value to clear to
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderTexture_clearStencil(sfRenderTexture* renderTexture, sfStencilValue stencilValue);
////////////////////////////////////////////////////////////
/// \brief Clear the entire target with a single color and stencil value
///
/// The specified stencil value is truncated to the bit
/// width of the current stencil buffer.
///
/// \param renderTexture Render texture object
/// \param color Fill color to use to clear the render target
/// \param stencilValue Stencil value to clear to
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderTexture_clearColorAndStencil(sfRenderTexture* renderTexture,
sfColor color,
sfStencilValue stencilValue);
////////////////////////////////////////////////////////////
/// \brief Change the current active view of a render texture
///
@@ -163,6 +176,22 @@ CSFML_GRAPHICS_API const sfView* sfRenderTexture_getDefaultView(const sfRenderTe
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfIntRect sfRenderTexture_getViewport(const sfRenderTexture* renderTexture, const sfView* view);
////////////////////////////////////////////////////////////
/// \brief Get the scissor rectangle of a view, applied to this render target
///
/// The scissor rectangle is defined in the view as a ratio. This
/// function simply applies this ratio to the current dimensions
/// of the render target to calculate the pixels rectangle
/// that the scissor rectangle actually covers in the target.
///
/// \param renderTexture Render texture object
/// \param view The view for which we want to compute the scissor rectangle
///
/// \return Scissor rectangle, expressed in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfIntRect sfRenderTexture_getScissor(const sfRenderTexture* renderTexture, const sfView* view);
////////////////////////////////////////////////////////////
/// \brief Convert a point from texture coordinates to world coordinates
///
@@ -188,7 +217,8 @@ CSFML_GRAPHICS_API sfIntRect sfRenderTexture_getViewport(const sfRenderTexture*
/// \return The converted point, in "world" units
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfRenderTexture_mapPixelToCoords(const sfRenderTexture* renderTexture, sfVector2i point, const sfView* view);
CSFML_GRAPHICS_API sfVector2f
sfRenderTexture_mapPixelToCoords(const sfRenderTexture* renderTexture, sfVector2i point, const sfView* view);
////////////////////////////////////////////////////////////
/// \brief Convert a point from world coordinates to texture coordinates
@@ -214,7 +244,8 @@ CSFML_GRAPHICS_API sfVector2f sfRenderTexture_mapPixelToCoords(const sfRenderTex
/// \return The converted point, in target coordinates (pixels)
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2i sfRenderTexture_mapCoordsToPixel(const sfRenderTexture* renderTexture, sfVector2f point, const sfView* view);
CSFML_GRAPHICS_API sfVector2i
sfRenderTexture_mapCoordsToPixel(const sfRenderTexture* renderTexture, sfVector2f point, const sfView* view);
////////////////////////////////////////////////////////////
/// \brief Draw a drawable object to the render-target
@@ -224,14 +255,30 @@ CSFML_GRAPHICS_API sfVector2i sfRenderTexture_mapCoordsToPixel(const sfRenderTex
/// \param states Render states to use for drawing (NULL to use the default states)
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderTexture_drawSprite(sfRenderTexture* renderTexture, const sfSprite* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawText(sfRenderTexture* renderTexture, const sfText* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawShape(sfRenderTexture* renderTexture, const sfShape* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawCircleShape(sfRenderTexture* renderTexture, const sfCircleShape* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawConvexShape(sfRenderTexture* renderTexture, const sfConvexShape* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawRectangleShape(sfRenderTexture* renderTexture, const sfRectangleShape* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawVertexArray(sfRenderTexture* renderTexture, const sfVertexArray* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawVertexBuffer(sfRenderTexture* renderTexture, const sfVertexBuffer* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawSprite(sfRenderTexture* renderTexture,
const sfSprite* object,
const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawText(sfRenderTexture* renderTexture,
const sfText* object,
const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawShape(sfRenderTexture* renderTexture,
const sfShape* object,
const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawCircleShape(sfRenderTexture* renderTexture,
const sfCircleShape* object,
const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawConvexShape(sfRenderTexture* renderTexture,
const sfConvexShape* object,
const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawRectangleShape(sfRenderTexture* renderTexture,
const sfRectangleShape* object,
const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawVertexArray(sfRenderTexture* renderTexture,
const sfVertexArray* object,
const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawVertexBuffer(sfRenderTexture* renderTexture,
const sfVertexBuffer* object,
const sfRenderStates* states);
////////////////////////////////////////////////////////////
/// \brief Draw primitives defined by a vertex buffer.
@@ -243,9 +290,12 @@ CSFML_GRAPHICS_API void sfRenderTexture_drawVertexBuffer(sfRenderTexture* render
/// \param states Render states to use for drawing
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderTexture_drawVertexBufferRange(sfRenderTexture* renderTexture,
const sfVertexBuffer* object, size_t firstVertex,
size_t vertexCount, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawVertexBufferRange(
sfRenderTexture* renderTexture,
const sfVertexBuffer* object,
size_t firstVertex,
size_t vertexCount,
const sfRenderStates* states);
////////////////////////////////////////////////////////////
/// \brief Draw primitives defined by an array of vertices to a render texture
@@ -257,9 +307,12 @@ CSFML_GRAPHICS_API void sfRenderTexture_drawVertexBufferRange(sfRenderTexture* r
/// \param states Render states to use for drawing (NULL to use the default states)
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderTexture_drawPrimitives(sfRenderTexture* renderTexture,
const sfVertex* vertices, size_t vertexCount,
sfPrimitiveType type, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderTexture_drawPrimitives(
sfRenderTexture* renderTexture,
const sfVertex* vertices,
size_t vertexCount,
sfPrimitiveType type,
const sfRenderStates* states);
////////////////////////////////////////////////////////////
/// \brief Save the current OpenGL render states and matrices
@@ -326,45 +379,45 @@ CSFML_GRAPHICS_API const sfTexture* sfRenderTexture_getTexture(const sfRenderTex
/// \return The maximum anti-aliasing level supported by the system
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API unsigned int sfRenderTexture_getMaximumAntialiasingLevel(void);
CSFML_GRAPHICS_API unsigned int sfRenderTexture_getMaximumAntiAliasingLevel(void);
////////////////////////////////////////////////////////////
/// \brief Enable or disable the smooth filter on a render texture
///
/// \param renderTexture Render texture object
/// \param smooth sfTrue to enable smoothing, sfFalse to disable it
/// \param smooth true to enable smoothing, false to disable it
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderTexture_setSmooth(sfRenderTexture* renderTexture, sfBool smooth);
CSFML_GRAPHICS_API void sfRenderTexture_setSmooth(sfRenderTexture* renderTexture, bool smooth);
////////////////////////////////////////////////////////////
/// \brief Tell whether the smooth filter is enabled or not for a render texture
///
/// \param renderTexture Render texture object
///
/// \return sfTrue if smoothing is enabled, sfFalse if it is disabled
/// \return true if smoothing is enabled, false if it is disabled
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfRenderTexture_isSmooth(const sfRenderTexture* renderTexture);
CSFML_GRAPHICS_API bool sfRenderTexture_isSmooth(const sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// \brief Enable or disable texture repeating
///
/// \param renderTexture Render texture object
/// \param repeated sfTrue to enable repeating, sfFalse to disable it
/// \param repeated true to enable repeating, false to disable it
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderTexture_setRepeated(sfRenderTexture* renderTexture, sfBool repeated);
CSFML_GRAPHICS_API void sfRenderTexture_setRepeated(sfRenderTexture* renderTexture, bool repeated);
////////////////////////////////////////////////////////////
/// \brief Tell whether the texture is repeated or not
///
/// \param renderTexture Render texture object
///
/// \return sfTrue if repeat mode is enabled, sfFalse if it is disabled
/// \return true if repeat mode is enabled, false if it is disabled
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfRenderTexture_isRepeated(const sfRenderTexture* renderTexture);
CSFML_GRAPHICS_API bool sfRenderTexture_isRepeated(const sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// \brief Generate a mipmap using the current texture data
@@ -377,10 +430,7 @@ CSFML_GRAPHICS_API sfBool sfRenderTexture_isRepeated(const sfRenderTexture* rend
/// after subsequent drawing will lead to undefined behavior if a mipmap
/// had been previously generated.
///
/// \return sfTrue if mipmap generation was successful, sfFalse if unsuccessful
/// \return true if mipmap generation was successful, false if unsuccessful
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfRenderTexture_generateMipmap(sfRenderTexture* renderTexture);
#endif // SFML_RENDERTEXTURE_H
CSFML_GRAPHICS_API bool sfRenderTexture_generateMipmap(sfRenderTexture* renderTexture);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,24 +22,27 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_RENDERWINDOW_H
#define SFML_RENDERWINDOW_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
#include <SFML/Graphics/PrimitiveType.h>
#include <SFML/Graphics/RenderStates.h>
#include <SFML/Graphics/Vertex.h>
#include <SFML/Window/Event.h>
#include <SFML/Window/VideoMode.h>
#include <SFML/Window/WindowHandle.h>
#include <SFML/Window/Window.h>
#include <SFML/System/Vector2.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/Color.h>
#include <CSFML/Graphics/PrimitiveType.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/RenderStates.h>
#include <CSFML/Graphics/StencilMode.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/Graphics/Vertex.h>
#include <CSFML/System/Time.h>
#include <CSFML/System/Vector2.h>
#include <CSFML/Window/Event.h>
#include <CSFML/Window/VideoMode.h>
#include <CSFML/Window/Window.h>
#include <CSFML/Window/WindowHandle.h>
#include <stddef.h>
@@ -49,10 +52,16 @@
/// \param mode Video mode to use
/// \param title Title of the window
/// \param style Window style
/// \param state Window state
/// \param settings Creation settings (pass NULL to use default values)
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_create(sfVideoMode mode, const char* title, sfUint32 style, const sfContextSettings* settings);
CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_create(
sfVideoMode mode,
const char* title,
uint32_t style,
sfWindowState state,
const sfContextSettings* settings);
////////////////////////////////////////////////////////////
/// \brief Construct a new render window (with a UTF-32 title)
@@ -60,10 +69,16 @@ CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_create(sfVideoMode mode, const
/// \param mode Video mode to use
/// \param title Title of the window (UTF-32)
/// \param style Window style
/// \param state Window state
/// \param settings Creation settings (pass NULL to use default values)
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_createUnicode(sfVideoMode mode, const sfUint32* title, sfUint32 style, const sfContextSettings* settings);
CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_createUnicode(
sfVideoMode mode,
const sfChar32* title,
uint32_t style,
sfWindowState state,
const sfContextSettings* settings);
////////////////////////////////////////////////////////////
/// \brief Construct a render window from an existing control
@@ -80,7 +95,7 @@ CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_createFromHandle(sfWindowHandl
/// \param renderWindow Render window to destroy
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_destroy(sfRenderWindow* renderWindow);
CSFML_GRAPHICS_API void sfRenderWindow_destroy(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Close a render window (but doesn't destroy the internal data)
@@ -96,7 +111,7 @@ CSFML_GRAPHICS_API void sfRenderWindow_close(sfRenderWindow* renderWindow);
/// \param renderWindow Render window object
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfRenderWindow_isOpen(const sfRenderWindow* renderWindow);
CSFML_GRAPHICS_API bool sfRenderWindow_isOpen(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Get the creation settings of a render window
@@ -109,26 +124,47 @@ CSFML_GRAPHICS_API sfBool sfRenderWindow_isOpen(const sfRenderWindow* renderWind
CSFML_GRAPHICS_API sfContextSettings sfRenderWindow_getSettings(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Get the event on top of event queue of a render window, if any, and pop it
/// \brief Pop the event on top of event queue, if any, and return it
///
/// This function is not blocking: if there's no pending event then
/// it will return false and leave \a event unmodified.
/// Note that more than one event may be present in the event queue,
/// thus you should always call this function in a loop
/// to make sure that you process every pending event.
///
/// \param renderWindow Render window object
/// \param event Event to fill, if any
///
/// \return sfTrue if an event was returned, sfFalse if event queue was empty
/// \return true if an event was returned, or false if the event queue was empty
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfRenderWindow_pollEvent(sfRenderWindow* renderWindow, sfEvent* event);
CSFML_GRAPHICS_API bool sfRenderWindow_pollEvent(sfRenderWindow* renderWindow, sfEvent* event);
////////////////////////////////////////////////////////////
/// \brief Wait for an event and return it
///
/// \param renderWindow Render window object
/// \param event Event to fill
/// This function is blocking: if there's no pending event then
/// it will wait until an event is received or until the provided
/// timeout elapses. Only if an error or a timeout occurs the
/// function returns `false`.
/// This function is typically used when you have a thread that is
/// dedicated to events handling: you want to make this thread sleep
/// as long as no new event is received.
/// \code
/// while (sfRenderWindow_waitEvent(renderWindow, timeout, &event))
/// {
/// // process event...
/// }
/// \endcode
///
/// \return sfFalse if an error occured
/// \param renderWindow Render window object
/// \param timeout Maximum time to wait (`sfTime_Zero` for infinite)
/// \param event Event to fill, if any
///
/// \return true if an event was returned, false if event queue was empty or function timed out
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfRenderWindow_waitEvent(sfRenderWindow* renderWindow, sfEvent* event);
CSFML_GRAPHICS_API bool sfRenderWindow_waitEvent(sfRenderWindow* renderWindow, sfTime timeout, sfEvent* event);
////////////////////////////////////////////////////////////
/// \brief Get the position of a render window
@@ -166,10 +202,10 @@ CSFML_GRAPHICS_API sfVector2u sfRenderWindow_getSize(const sfRenderWindow* rende
///
/// \param renderWindow Render window object
///
/// \return sfTrue if the render window use sRGB encoding, sfFalse otherwise
/// \return true if the render window use sRGB encoding, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfRenderWindow_isSrgb(const sfRenderWindow* renderWindow);
CSFML_GRAPHICS_API bool sfRenderWindow_isSrgb(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Change the size of the rendering region of a render window
@@ -180,6 +216,28 @@ CSFML_GRAPHICS_API sfBool sfRenderWindow_isSrgb(const sfRenderWindow* renderWind
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_setSize(sfRenderWindow* renderWindow, sfVector2u size);
////////////////////////////////////////////////////////////
/// \brief Set the minimum window rendering region size
///
/// Pass a `NULL` vector to unset the minimum size
///
/// \param renderWindow Render window object
/// \param minimumSize New minimum size, in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_setMinimumSize(sfRenderWindow* renderWindow, const sfVector2u* minimumSize);
////////////////////////////////////////////////////////////
/// \brief Set the maximum window rendering region size
///
/// Pass a `NULL` vector to unset the maximum size
///
/// \param renderWindow Render window object
/// \param maximumSize New maximum size, in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_setMaximumSize(sfRenderWindow* renderWindow, const sfVector2u* maximumSize);
////////////////////////////////////////////////////////////
/// \brief Change the title of a render window
///
@@ -196,45 +254,44 @@ CSFML_GRAPHICS_API void sfRenderWindow_setTitle(sfRenderWindow* renderWindow, co
/// \param title New title
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_setUnicodeTitle(sfRenderWindow* renderWindow, const sfUint32* title);
CSFML_GRAPHICS_API void sfRenderWindow_setUnicodeTitle(sfRenderWindow* renderWindow, const sfChar32* title);
////////////////////////////////////////////////////////////
/// \brief Change a render window's icon
///
/// \param renderWindow Render window object
/// \param width Icon's width, in pixels
/// \param height Icon's height, in pixels
/// \param size Icon's size, in pixels
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfUint8* pixels);
CSFML_GRAPHICS_API void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, sfVector2u size, const uint8_t* pixels);
////////////////////////////////////////////////////////////
/// \brief Show or hide a render window
///
/// \param renderWindow Render window object
/// \param visible sfTrue to show the window, sfFalse to hide it
/// \param visible true to show the window, false to hide it
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_setVisible(sfRenderWindow* renderWindow, sfBool visible);
CSFML_GRAPHICS_API void sfRenderWindow_setVisible(sfRenderWindow* renderWindow, bool visible);
////////////////////////////////////////////////////////////
/// \brief Enable / disable vertical synchronization on a render window
///
/// \param renderWindow Render window object
/// \param enabled sfTrue to enable v-sync, sfFalse to deactivate
/// \param enabled true to enable v-sync, false to deactivate
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_setVerticalSyncEnabled(sfRenderWindow* renderWindow, sfBool enabled);
CSFML_GRAPHICS_API void sfRenderWindow_setVerticalSyncEnabled(sfRenderWindow* renderWindow, bool enabled);
////////////////////////////////////////////////////////////
/// \brief Show or hide the mouse cursor on a render window
///
/// \param renderWindow Render window object
/// \param show sfTrue to show, sfFalse to hide
/// \param show true to show, false to hide
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursorVisible(sfRenderWindow* renderWindow, sfBool show);
CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursorVisible(sfRenderWindow* renderWindow, bool show);
////////////////////////////////////////////////////////////
/// \brief Grab or release the mouse cursor
@@ -246,10 +303,11 @@ CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursorVisible(sfRenderWindow* ren
/// won't have any effect (fullscreen windows always grab the
/// cursor).
///
/// \param grabbed sfTrue to enable, sfFalse to disable
/// \param renderWindow Render window object
/// \param grabbed true to enable, false to disable
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursorGrabbed(sfRenderWindow* renderWindow, sfBool grabbed);
CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursorGrabbed(sfRenderWindow* renderWindow, bool grabbed);
////////////////////////////////////////////////////////////
/// \brief Set the displayed cursor to a native system cursor
@@ -262,13 +320,14 @@ CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursorGrabbed(sfRenderWindow* ren
/// \warning Features related to Cursor are not supported on
/// iOS and Android.
///
/// \param cursor Native system cursor type to display
/// \param renderWindow Render window object
/// \param cursor Native system cursor type to display
///
/// \see sfCursor_createFromSystem
/// \see sfCursor_createFromPixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursor(sfRenderWindow* window, const sfCursor* cursor);
CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursor(sfRenderWindow* renderWindow, const sfCursor* cursor);
////////////////////////////////////////////////////////////
/// \brief Enable or disable automatic key-repeat for keydown events
@@ -276,10 +335,10 @@ CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursor(sfRenderWindow* window, co
/// Automatic key-repeat is enabled by default
///
/// \param renderWindow Render window object
/// \param enabled sfTrue to enable, sfFalse to disable
/// \param enabled true to enable, false to disable
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_setKeyRepeatEnabled(sfRenderWindow* renderWindow, sfBool enabled);
CSFML_GRAPHICS_API void sfRenderWindow_setKeyRepeatEnabled(sfRenderWindow* renderWindow, bool enabled);
////////////////////////////////////////////////////////////
/// \brief Limit the framerate to a maximum fixed frequency for a render window
@@ -303,12 +362,12 @@ CSFML_GRAPHICS_API void sfRenderWindow_setJoystickThreshold(sfRenderWindow* rend
/// \brief Activate or deactivate a render window as the current target for rendering
///
/// \param renderWindow Render window object
/// \param active sfTrue to activate, sfFalse to deactivate
/// \param active true to activate, false to deactivate
///
/// \return True if operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfRenderWindow_setActive(sfRenderWindow* renderWindow, sfBool active);
CSFML_GRAPHICS_API bool sfRenderWindow_setActive(sfRenderWindow* renderWindow, bool active);
///////////////////////////////////////////////////////////
/// \brief Request the current render window to be made the active
@@ -334,7 +393,7 @@ CSFML_GRAPHICS_API void sfRenderWindow_requestFocus(sfRenderWindow* renderWindow
/// \return True if window has focus, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfRenderWindow_hasFocus(const sfRenderWindow* renderWindow);
CSFML_GRAPHICS_API bool sfRenderWindow_hasFocus(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Display a render window on screen
@@ -352,7 +411,7 @@ CSFML_GRAPHICS_API void sfRenderWindow_display(sfRenderWindow* renderWindow);
/// \return Window handle
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfWindowHandle sfRenderWindow_getSystemHandle(const sfRenderWindow* renderWindow);
CSFML_GRAPHICS_API sfWindowHandle sfRenderWindow_getNativeHandle(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Clear a render window with the given color
@@ -363,6 +422,31 @@ CSFML_GRAPHICS_API sfWindowHandle sfRenderWindow_getSystemHandle(const sfRenderW
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_clear(sfRenderWindow* renderWindow, sfColor color);
////////////////////////////////////////////////////////////
/// \brief Clear the stencil buffer to a specific value
///
/// The specified value is truncated to the bit width of
/// the current stencil buffer.
///
/// \param renderWindow Render window object
/// \param stencilValue Stencil value to clear to
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_clearStencil(sfRenderWindow* renderWindow, sfStencilValue stencilValue);
////////////////////////////////////////////////////////////
/// \brief Clear the entire target with a single color and stencil value
///
/// The specified stencil value is truncated to the bit
/// width of the current stencil buffer.
///
/// \param renderWindow Render window object
/// \param color Fill color to use to clear the render target
/// \param stencilValue Stencil value to clear to
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_clearColorAndStencil(sfRenderWindow* renderWindow, sfColor color, sfStencilValue stencilValue);
////////////////////////////////////////////////////////////
/// \brief Change the current active view of a render window
///
@@ -403,6 +487,22 @@ CSFML_GRAPHICS_API const sfView* sfRenderWindow_getDefaultView(const sfRenderWin
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfIntRect sfRenderWindow_getViewport(const sfRenderWindow* renderWindow, const sfView* view);
////////////////////////////////////////////////////////////
/// \brief Get the scissor rectangle of a view, applied to this render target
///
/// The scissor rectangle is defined in the view as a ratio. This
/// function simply applies this ratio to the current dimensions
/// of the render target to calculate the pixels rectangle
/// that the scissor rectangle actually covers in the target.
///
/// \param renderWindow Render window object
/// \param view The view for which we want to compute the scissor rectangle
///
/// \return Scissor rectangle, expressed in pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfIntRect sfRenderWindow_getScissor(const sfRenderWindow* renderWindow, const sfView* view);
////////////////////////////////////////////////////////////
/// \brief Convert a point from window coordinates to world coordinates
///
@@ -431,7 +531,8 @@ CSFML_GRAPHICS_API sfIntRect sfRenderWindow_getViewport(const sfRenderWindow* re
/// \return The converted point, in "world" units
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfRenderWindow_mapPixelToCoords(const sfRenderWindow* renderWindow, sfVector2i point, const sfView* view);
CSFML_GRAPHICS_API sfVector2f
sfRenderWindow_mapPixelToCoords(const sfRenderWindow* renderWindow, sfVector2i point, const sfView* view);
////////////////////////////////////////////////////////////
/// \brief Convert a point from world coordinates to window coordinates
@@ -457,7 +558,8 @@ CSFML_GRAPHICS_API sfVector2f sfRenderWindow_mapPixelToCoords(const sfRenderWind
/// \return The converted point, in target coordinates (pixels)
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2i sfRenderWindow_mapCoordsToPixel(const sfRenderWindow* renderWindow, sfVector2f point, const sfView* view);
CSFML_GRAPHICS_API sfVector2i
sfRenderWindow_mapCoordsToPixel(const sfRenderWindow* renderWindow, sfVector2f point, const sfView* view);
////////////////////////////////////////////////////////////
/// \brief Draw a drawable object to the render-target
@@ -467,14 +569,26 @@ CSFML_GRAPHICS_API sfVector2i sfRenderWindow_mapCoordsToPixel(const sfRenderWind
/// \param states Render states to use for drawing (NULL to use the default states)
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_drawSprite(sfRenderWindow* renderWindow, const sfSprite* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderWindow_drawSprite(sfRenderWindow* renderWindow,
const sfSprite* object,
const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderWindow_drawText(sfRenderWindow* renderWindow, const sfText* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderWindow_drawShape(sfRenderWindow* renderWindow, const sfShape* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderWindow_drawCircleShape(sfRenderWindow* renderWindow, const sfCircleShape* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderWindow_drawConvexShape(sfRenderWindow* renderWindow, const sfConvexShape* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderWindow_drawRectangleShape(sfRenderWindow* renderWindow, const sfRectangleShape* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderWindow_drawVertexArray(sfRenderWindow* renderWindow, const sfVertexArray* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderWindow_drawVertexBuffer(sfRenderWindow* renderWindow, const sfVertexBuffer* object, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderWindow_drawCircleShape(sfRenderWindow* renderWindow,
const sfCircleShape* object,
const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderWindow_drawConvexShape(sfRenderWindow* renderWindow,
const sfConvexShape* object,
const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderWindow_drawRectangleShape(sfRenderWindow* renderWindow,
const sfRectangleShape* object,
const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderWindow_drawVertexArray(sfRenderWindow* renderWindow,
const sfVertexArray* object,
const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderWindow_drawVertexBuffer(sfRenderWindow* renderWindow,
const sfVertexBuffer* object,
const sfRenderStates* states);
////////////////////////////////////////////////////////////
/// \brief Draw primitives defined by a vertex buffer.
@@ -486,9 +600,12 @@ CSFML_GRAPHICS_API void sfRenderWindow_drawVertexBuffer(sfRenderWindow* renderWi
/// \param states Render states to use for drawing
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_drawVertexBufferRange(sfRenderWindow* renderWindow,
const sfVertexBuffer* object, size_t firstVertex,
size_t vertexCount, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderWindow_drawVertexBufferRange(
sfRenderWindow* renderWindow,
const sfVertexBuffer* object,
size_t firstVertex,
size_t vertexCount,
const sfRenderStates* states);
////////////////////////////////////////////////////////////
/// \brief Draw primitives defined by an array of vertices to a render window
@@ -500,9 +617,12 @@ CSFML_GRAPHICS_API void sfRenderWindow_drawVertexBufferRange(sfRenderWindow* ren
/// \param states Render states to use for drawing (NULL to use the default states)
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_drawPrimitives(sfRenderWindow* renderWindow,
const sfVertex* vertices, size_t vertexCount,
sfPrimitiveType type, const sfRenderStates* states);
CSFML_GRAPHICS_API void sfRenderWindow_drawPrimitives(
sfRenderWindow* renderWindow,
const sfVertex* vertices,
size_t vertexCount,
sfPrimitiveType type,
const sfRenderStates* states);
////////////////////////////////////////////////////////////
/// \brief Save the current OpenGL render states and matrices
@@ -552,33 +672,6 @@ CSFML_GRAPHICS_API void sfRenderWindow_popGLStates(sfRenderWindow* renderWindow)
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_resetGLStates(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Copy the current contents of the window to an image
///
/// \deprecated
/// Use a sfTexture and its
/// sfTexture_updateFromRenderWindow(sfTexture*, const sfRenderWindow*, unsigned int, unsigned int)
/// function and copy its contents into an sfImage instead.
/// \code
/// sfVector2u windowSize = sfRenderWindow_getSize(window);
/// sfTexture* texture = sfTexture_create(windowSize.x, windowSize.y);
/// sfTexture_updateFromRenderWindow(texture, window, windowSize.x, windowSize.y);
/// sfImage* screenshot = sfTexture_copyToImage(texture);
/// \endcode
///
/// This is a slow operation, whose main purpose is to make
/// screenshots of the application. If you want to update an
/// image with the contents of the window and then use it for
/// drawing, you should rather use a sfTexture and the
/// sfTexture_updateFromWindow(sfTexture*, const sfWindow*, unsigned int, unsigned int) function.
/// You can also draw things directly to a texture with the
/// sfRenderTexture class.
///
/// \return sfImage containing the captured contents.
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API CSFML_DEPRECATED sfImage* sfRenderWindow_capture(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Get the current position of the mouse relative to a render-window
///
@@ -615,8 +708,11 @@ CSFML_GRAPHICS_API void sfMouse_setPositionRenderWindow(sfVector2i position, con
///
/// \return Current position of \a finger, or undefined if it's not down
///
/// \deprecated Use the position of the touch events (sfEvtTouchBegan, sfEvtTouchMoved and sfEvtTouchEnded) instead
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2i sfTouch_getPositionRenderWindow(unsigned int finger, const sfRenderWindow* relativeTo);
CSFML_GRAPHICS_API CSFML_DEPRECATED sfVector2i sfTouch_getPositionRenderWindow(unsigned int finger,
const sfRenderWindow* relativeTo);
////////////////////////////////////////////////////////////
/// \brief Create a Vulkan rendering surface
@@ -629,7 +725,8 @@ CSFML_GRAPHICS_API sfVector2i sfTouch_getPositionRenderWindow(unsigned int finge
/// \return True if surface creation was successful, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfRenderWindow_createVulkanSurface(sfRenderWindow* renderWindow, const VkInstance* instance, VkSurfaceKHR* surface, const VkAllocationCallbacks* allocator);
#endif // SFML_RENDERWINDOW_H
CSFML_GRAPHICS_API bool sfRenderWindow_createVulkanSurface(
sfRenderWindow* renderWindow,
const VkInstance* instance,
VkSurfaceKHR* surface,
const VkAllocationCallbacks* allocator);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,20 +22,21 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_SHADER_H
#define SFML_SHADER_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Glsl.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Types.h>
#include <SFML/System/InputStream.h>
#include <SFML/System/Vector2.h>
#include <SFML/System/Vector3.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/Color.h>
#include <CSFML/Graphics/Glsl.h>
#include <CSFML/Graphics/Transform.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/System/InputStream.h>
#include <CSFML/System/Vector2.h>
#include <CSFML/System/Vector3.h>
#include <stddef.h>
@@ -57,7 +58,9 @@
/// \return A new sfShader object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfShader* sfShader_createFromFile(const char* vertexShaderFilename, const char* geometryShaderFilename, const char* fragmentShaderFilename);
CSFML_GRAPHICS_API sfShader* sfShader_createFromFile(const char* vertexShaderFilename,
const char* geometryShaderFilename,
const char* fragmentShaderFilename);
////////////////////////////////////////////////////////////
/// \brief Load the vertex, geometry and fragment shaders from source code in memory
@@ -77,7 +80,9 @@ CSFML_GRAPHICS_API sfShader* sfShader_createFromFile(const char* vertexShaderFil
/// \return A new sfShader object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfShader* sfShader_createFromMemory(const char* vertexShader, const char* geometryShader, const char* fragmentShader);
CSFML_GRAPHICS_API sfShader* sfShader_createFromMemory(const char* vertexShader,
const char* geometryShader,
const char* fragmentShader);
////////////////////////////////////////////////////////////
/// \brief Load the vertex, geometry and fragment shaders from custom streams
@@ -97,7 +102,9 @@ CSFML_GRAPHICS_API sfShader* sfShader_createFromMemory(const char* vertexShader,
/// \return A new sfShader object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfShader* sfShader_createFromStream(sfInputStream* vertexShaderStream, sfInputStream* geometryShaderStream, sfInputStream* fragmentShaderStream);
CSFML_GRAPHICS_API sfShader* sfShader_createFromStream(sfInputStream* vertexShaderStream,
sfInputStream* geometryShaderStream,
sfInputStream* fragmentShaderStream);
////////////////////////////////////////////////////////////
/// \brief Destroy an existing shader
@@ -105,7 +112,7 @@ CSFML_GRAPHICS_API sfShader* sfShader_createFromStream(sfInputStream* vertexShad
/// \param shader Shader to delete
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfShader_destroy(sfShader* shader);
CSFML_GRAPHICS_API void sfShader_destroy(const sfShader* shader);
////////////////////////////////////////////////////////////
/// \brief Specify value for \p float uniform
@@ -221,7 +228,7 @@ CSFML_GRAPHICS_API void sfShader_setIntColorUniform(sfShader* shader, const char
/// \param x Value of the bool scalar
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfShader_setBoolUniform(sfShader* shader, const char* name, sfBool x);
CSFML_GRAPHICS_API void sfShader_setBoolUniform(sfShader* shader, const char* name, bool x);
////////////////////////////////////////////////////////////
/// \brief Specify value for \p bvec2 uniform
@@ -398,253 +405,6 @@ CSFML_GRAPHICS_API void sfShader_setMat3UniformArray(sfShader* shader, const cha
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfShader_setMat4UniformArray(sfShader* shader, const char* name, const sfGlslMat4* matrixArray, size_t length);
////////////////////////////////////////////////////////////
/// \brief Change a float parameter of a shader
///
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a float
/// (float GLSL type).
///
/// Example:
/// \code
/// uniform float myparam; // this is the variable in the shader
/// \endcode
/// \code
/// sfShader_setFloatParameter(shader, "myparam", 5.2f);
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the parameter in the shader
/// \param x Value to assign
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setFloatParameter(sfShader* shader, const char* name, float x);
////////////////////////////////////////////////////////////
/// \brief Change a 2-components vector parameter of a shader
///
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a 2x1 vector
/// (vec2 GLSL type).
///
/// Example:
/// \code
/// uniform vec2 myparam; // this is the variable in the shader
/// \endcode
/// \code
/// sfShader_setFloat2Parameter(shader, "myparam", 5.2f, 6.0f);
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the parameter in the shader
/// \param x First component of the value to assign
/// \param y Second component of the value to assign
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setFloat2Parameter(sfShader* shader, const char* name, float x, float y);
////////////////////////////////////////////////////////////
/// \brief Change a 3-components vector parameter of a shader
///
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a 3x1 vector
/// (vec3 GLSL type).
///
/// Example:
/// \code
/// uniform vec3 myparam; // this is the variable in the shader
/// \endcode
/// \code
/// sfShader_setFloat3Parameter(shader, "myparam", 5.2f, 6.0f, -8.1f);
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the parameter in the shader
/// \param x First component of the value to assign
/// \param y Second component of the value to assign
/// \param z Third component of the value to assign
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setFloat3Parameter(sfShader* shader, const char* name, float x, float y, float z);
////////////////////////////////////////////////////////////
/// \brief Change a 4-components vector parameter of a shader
///
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a 4x1 vector
/// (vec4 GLSL type).
///
/// Example:
/// \code
/// uniform vec4 myparam; // this is the variable in the shader
/// \endcode
/// \code
/// sfShader_setFloat4Parameter(shader, "myparam", 5.2f, 6.0f, -8.1f, 0.4f);
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the parameter in the shader
/// \param x First component of the value to assign
/// \param y Second component of the value to assign
/// \param z Third component of the value to assign
/// \param w Fourth component of the value to assign
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setFloat4Parameter(sfShader* shader, const char* name, float x, float y, float z, float w);
////////////////////////////////////////////////////////////
/// \brief Change a 2-components vector parameter of a shader
///
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a 2x1 vector
/// (vec2 GLSL type).
///
/// Example:
/// \code
/// uniform vec2 myparam; // this is the variable in the shader
/// \endcode
/// \code
/// sfVector2f vec = {5.2f, 6.0f};
/// sfShader_setVector2Parameter(shader, "myparam", vec);
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the parameter in the shader
/// \param vector Vector to assign
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setVector2Parameter(sfShader* shader, const char* name, sfVector2f vector);
////////////////////////////////////////////////////////////
/// \brief Change a 3-components vector parameter of a shader
///
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a 3x1 vector
/// (vec3 GLSL type).
///
/// Example:
/// \code
/// uniform vec3 myparam; // this is the variable in the shader
/// \endcode
/// \code
/// sfVector3f vec = {5.2f, 6.0f, -8.1f};
/// sfShader_setVector3Parameter(shader, "myparam", vec);
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the parameter in the shader
/// \param vector Vector to assign
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setVector3Parameter(sfShader* shader, const char* name, sfVector3f vector);
////////////////////////////////////////////////////////////
/// \brief Change a color parameter of a shader
///
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a 4x1 vector
/// (vec4 GLSL type).
///
/// It is important to note that the components of the color are
/// normalized before being passed to the shader. Therefore,
/// they are converted from range [0 .. 255] to range [0 .. 1].
/// For example, a sf::Color(255, 125, 0, 255) will be transformed
/// to a vec4(1.0, 0.5, 0.0, 1.0) in the shader.
///
/// Example:
/// \code
/// uniform vec4 color; // this is the variable in the shader
/// \endcode
/// \code
/// sfShader_setColorParameter(shader, "color", sfColor_fromRGB(255, 128, 0));
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the parameter in the shader
/// \param color Color to assign
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setColorParameter(sfShader* shader, const char* name, sfColor color);
////////////////////////////////////////////////////////////
/// \brief Change a matrix parameter of a shader
///
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a 4x4 matrix
/// (mat4 GLSL type).
///
/// Example:
/// \code
/// uniform mat4 matrix; // this is the variable in the shader
/// \endcode
/// \code
/// @todo
/// sfShader_setTransformParameter(shader, "matrix", transform);
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the parameter in the shader
/// \param transform Transform to assign
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setTransformParameter(sfShader* shader, const char* name, sfTransform transform);
////////////////////////////////////////////////////////////
/// \brief Change a texture parameter of a shader
///
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a 2D texture
/// (sampler2D GLSL type).
///
/// Example:
/// \code
/// uniform sampler2D the_texture; // this is the variable in the shader
/// \endcode
/// \code
/// sf::Texture texture;
/// ...
/// sfShader_setTextureParameter(shader, "the_texture", texture);
/// \endcode
/// It is important to note that \a texture must remain alive as long
/// as the shader uses it, no copy is made internally.
///
/// To use the texture of the object being draw, which cannot be
/// known in advance, you can use the special function
/// sfShader_setCurrentTextureParameter:
/// \code
/// sfShader_setCurrentTextureParameter(shader, "the_texture").
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the texture in the shader
/// \param texture Texture to assign
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setTextureParameter(sfShader* shader, const char* name, const sfTexture* texture);
////////////////////////////////////////////////////////////
/// \brief Change a texture parameter of a shader
///
/// This function maps a shader texture variable to the
/// texture of the object being drawn, which cannot be
/// known in advance.
/// The corresponding parameter in the shader must be a 2D texture
/// (sampler2D GLSL type).
///
/// Example:
/// \code
/// uniform sampler2D current; // this is the variable in the shader
/// \endcode
/// \code
/// sfShader_setCurrentTextureParameter(shader, "current");
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the texture in the shader
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setCurrentTextureParameter(sfShader* shader, const char* name);
////////////////////////////////////////////////////////////
/// \brief Get the underlying OpenGL handle of the shader.
///
@@ -689,10 +449,10 @@ CSFML_GRAPHICS_API void sfShader_bind(const sfShader* shader);
/// the shader features. If it returns false, then
/// any attempt to use sfShader will fail.
///
/// \return sfTrue if the system can use shaders, sfFalse otherwise
/// \return true if the system can use shaders, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfShader_isAvailable(void);
CSFML_GRAPHICS_API bool sfShader_isAvailable(void);
////////////////////////////////////////////////////////////
/// \brief Tell whether or not the system supports geometry shaders
@@ -711,6 +471,4 @@ CSFML_GRAPHICS_API sfBool sfShader_isAvailable(void);
/// \return True if geometry shaders are supported, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfShader_isGeometryAvailable(void);
#endif // SFML_SHADER_H
CSFML_GRAPHICS_API bool sfShader_isGeometryAvailable(void);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,22 +22,23 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_SHAPE_H
#define SFML_SHAPE_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Types.h>
#include <SFML/System/Vector2.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/Color.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/Transform.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/System/Vector2.h>
#include <stddef.h>
typedef size_t (*sfShapeGetPointCountCallback)(void*); ///< Type of the callback used to get the number of points in a shape
typedef size_t (*sfShapeGetPointCountCallback)(void*); ///< Type of the callback used to get the number of points in a shape
typedef sfVector2f (*sfShapeGetPointCallback)(size_t, void*); ///< Type of the callback used to get a point of a shape
////////////////////////////////////////////////////////////
@@ -51,8 +52,8 @@ typedef sfVector2f (*sfShapeGetPointCallback)(size_t, void*); ///< Type of the c
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfShape* sfShape_create(sfShapeGetPointCountCallback getPointCount,
sfShapeGetPointCallback getPoint,
void* userData);
sfShapeGetPointCallback getPoint,
void* userData);
////////////////////////////////////////////////////////////
/// \brief Destroy an existing shape
@@ -60,7 +61,7 @@ CSFML_GRAPHICS_API sfShape* sfShape_create(sfShapeGetPointCountCallback getPoint
/// \param shape Shape to delete
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfShape_destroy(sfShape* shape);
CSFML_GRAPHICS_API void sfShape_destroy(const sfShape* shape);
////////////////////////////////////////////////////////////
/// \brief Set the position of a shape
@@ -234,7 +235,7 @@ CSFML_GRAPHICS_API sfTransform sfShape_getInverseTransform(const sfShape* shape)
/// \param resetRect Should the texture rect be reset to the size of the new texture?
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfShape_setTexture(sfShape* shape, const sfTexture* texture, sfBool resetRect);
CSFML_GRAPHICS_API void sfShape_setTexture(sfShape* shape, const sfTexture* texture, bool resetRect);
////////////////////////////////////////////////////////////
/// \brief Set the sub-rectangle of the texture that a shape will display
@@ -290,6 +291,36 @@ CSFML_GRAPHICS_API void sfShape_setOutlineColor(sfShape* shape, sfColor color);
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfShape_setOutlineThickness(sfShape* shape, float thickness);
////////////////////////////////////////////////////////////
/// \brief Set the limit on the ratio between miter length and outline thickness of a shape
///
/// Outline segments around each corner are joined either
/// with a miter or a bevel join.
/// - A miter join is formed by extending outline segments until
/// they intersect. The distance between the point of
/// intersection and the shape's corner is the miter length.
/// - A bevel join is formed by connecting outline segments with
/// a straight line perpendicular to the corner's bisector.
///
/// The miter limit is used to determine whether outline segments
/// around a corner are joined with a bevel or a miter.
/// When the ratio between the miter length and outline thickness
/// exceeds the miter limit, a bevel is used instead of a miter.
///
/// The miter limit is linked to the maximum inner angle of a
/// corner below which a bevel is used by the following formula:
///
/// miterLimit = 1 / sin(angle / 2)
///
/// The miter limit must be greater than or equal to 1.
/// By default, the miter limit is 10.
///
/// \param shape Shape object
/// \param miterLimit New miter limit
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfShape_setMiterLimit(sfShape* shape, float miterLimit);
////////////////////////////////////////////////////////////
/// \brief Get the source texture of a shape
///
@@ -344,6 +375,16 @@ CSFML_GRAPHICS_API sfColor sfShape_getOutlineColor(const sfShape* shape);
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API float sfShape_getOutlineThickness(const sfShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the limit on the ratio between miter length and outline thickness of a shape
///
/// \param shape Shape object
///
/// \return Limit on the ratio between miter length and outline thickness
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API float sfShape_getMiterLimit(const sfShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the total number of points of a shape
///
@@ -367,6 +408,20 @@ CSFML_GRAPHICS_API size_t sfShape_getPointCount(const sfShape* shape);
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfShape_getPoint(const sfShape* shape, size_t index);
////////////////////////////////////////////////////////////
/// \brief Get the geometric center of the shape
///
/// The returned point is in local coordinates, that is,
/// the shape's transforms (position, rotation, scale) are
/// not taken into account.
///
/// \param shape Shape object
///
/// \return The geometric center of the shape
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfShape_getGeometricCenter(const sfShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the local bounding rectangle of a shape
///
@@ -403,11 +458,8 @@ CSFML_GRAPHICS_API sfFloatRect sfShape_getGlobalBounds(const sfShape* shape);
/// \brief Recompute the internal geometry of a shape
///
/// This function must be called by specialized shape objects
/// everytime their points change (ie. the result of either
/// every time their points change (ie. the result of either
/// the getPointCount or getPoint callbacks is different).
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfShape_update(sfShape* shape);
#endif // SFML_SHAPE_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,28 +22,30 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_SPRITE_H
#define SFML_SPRITE_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/BlendMode.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Types.h>
#include <SFML/System/Vector2.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/BlendMode.h>
#include <CSFML/Graphics/Color.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/Transform.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/System/Vector2.h>
////////////////////////////////////////////////////////////
/// \brief Create a new sprite
///
/// \param texture Source texture
///
/// \return A new sfSprite object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfSprite* sfSprite_create(void);
CSFML_GRAPHICS_API sfSprite* sfSprite_create(const sfTexture* texture);
////////////////////////////////////////////////////////////
/// \brief Copy an existing sprite
@@ -61,7 +63,7 @@ CSFML_GRAPHICS_API sfSprite* sfSprite_copy(const sfSprite* sprite);
/// \param sprite Sprite to delete
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfSprite_destroy(sfSprite* sprite);
CSFML_GRAPHICS_API void sfSprite_destroy(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// \brief Set the position of a sprite
@@ -234,7 +236,7 @@ CSFML_GRAPHICS_API sfTransform sfSprite_getInverseTransform(const sfSprite* spri
/// \param resetRect Should the texture rect be reset to the size of the new texture?
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfSprite_setTexture(sfSprite* sprite, const sfTexture* texture, sfBool resetRect);
CSFML_GRAPHICS_API void sfSprite_setTexture(sfSprite* sprite, const sfTexture* texture, bool resetRect);
////////////////////////////////////////////////////////////
/// \brief Set the sub-rectangle of the texture that a sprite will display
@@ -328,6 +330,3 @@ CSFML_GRAPHICS_API sfFloatRect sfSprite_getLocalBounds(const sfSprite* sprite);
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfSprite_getGlobalBounds(const sfSprite* sprite);
#endif // SFML_SPRITE_H
+96
View File
@@ -0,0 +1,96 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <CSFML/Graphics/Export.h>
////////////////////////////////////////////////////////
/// \brief Enumeration of the stencil test comparisons that can be performed
///
/// The comparisons are mapped directly to their OpenGL equivalents,
/// specified by `glStencilFunc()`.
////////////////////////////////////////////////////////
typedef enum
{
sfStencilComparisonNever, //!< The stencil test never passes
sfStencilComparisonLess, //!< The stencil test passes if the new value is less than the value in the stencil buffer
sfStencilComparisonLessEqual, //!< The stencil test passes if the new value is less than or equal to the value in the stencil buffer
sfStencilComparisonGreater, //!< The stencil test passes if the new value is greater than the value in the stencil buffer
sfStencilComparisonGreaterEqual, //!< The stencil test passes if the new value is greater than or equal to the value in the stencil buffer
sfStencilComparisonEqual, //!< The stencil test passes if the new value is strictly equal to the value in the stencil buffer
sfStencilComparisonNotEqual, //!< The stencil test passes if the new value is strictly unequal to the value in the stencil buffer
sfStencilComparisonAlways //!< The stencil test always passes
} sfStencilComparison;
////////////////////////////////////////////////////////
/// \brief Enumeration of the stencil buffer update operations
///
/// The update operations are mapped directly to their OpenGL equivalents,
/// specified by `glStencilOp()`.
////////////////////////////////////////////////////////
typedef enum
{
sfStencilUpdateOperationKeep, //!< If the stencil test passes, the value in the stencil buffer is not modified
sfStencilUpdateOperationZero, //!< If the stencil test passes, the value in the stencil buffer is set to zero
sfStencilUpdateOperationReplace, //!< If the stencil test passes, the value in the stencil buffer is set to the new value
sfStencilUpdateOperationIncrement, //!< If the stencil test passes, the value in the stencil buffer is incremented and if required clamped
sfStencilUpdateOperationDecrement, //!< If the stencil test passes, the value in the stencil buffer is decremented and if required clamped
sfStencilUpdateOperationInvert, //!< If the stencil test passes, the value in the stencil buffer is bitwise inverted
} sfStencilUpdateOperation;
////////////////////////////////////////////////////////
/// \brief Stencil value type (also used as a mask)
///
////////////////////////////////////////////////////////
typedef struct
{
unsigned int value; //!< The stored stencil value
} sfStencilValue;
////////////////////////////////////////////////////////////
/// \brief Stencil modes for drawing
///
////////////////////////////////////////////////////////////
typedef struct
{
sfStencilComparison stencilComparison; //!< The comparison we're performing the stencil test with
sfStencilUpdateOperation stencilUpdateOperation; //!< The update operation to perform if the stencil test passes
sfStencilValue stencilReference; //!< The reference value we're performing the stencil test with
sfStencilValue stencilMask; //!< The mask to apply to both the reference value and the value in the stencil buffer
bool stencilOnly; //!< Whether we should update the color buffer in addition to the stencil buffer
} sfStencilMode;
////////////////////////////////////////////////////////////
/// \brief Define the default values for a StencilMode
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfStencilMode sfStencilMode_default;
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,19 +22,23 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_TEXT_H
#define SFML_TEXT_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/System/Vector2.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/Color.h>
#include <CSFML/Graphics/Glyph.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/Transform.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/Graphics/Vertex.h>
#include <CSFML/System/Vector2.h>
#include <stddef.h>
#include <stdint.h>
////////////////////////////////////////////////////////////
@@ -49,14 +53,112 @@ typedef enum
sfTextStrikeThrough = 1 << 3 ///< Strike through characters
} sfTextStyle;
////////////////////////////////////////////////////////////
/// \brief Line alignment of a multi-line text
///
////////////////////////////////////////////////////////////
typedef enum
{
sfTextLineAlignmentDefault, ///< Automatically align lines by script direction, left-align left-to-right text and right-align right-to-left text
sfTextLineAlignmentLeft, ///< Force align all lines to the left, regardless of script direction
sfTextLineAlignmentCenter, ///< Force align all lines centrally
sfTextLineAlignmentRight ///< Force align lines to the right, regardless of script direction
} sfTextLineAlignment;
////////////////////////////////////////////////////////////
/// \brief Cluster grouping algorithm
///
////////////////////////////////////////////////////////////
typedef enum
{
sfTextClusterGroupingGrapheme, ///< Group clusters by grapheme
sfTextClusterGroupingCharacter, ///< Group clusters by character
sfTextClusterGroupingNone ///< Do not group clusters
} sfTextClusterGrouping;
////////////////////////////////////////////////////////////
/// \brief Direction of the text a glyph belongs to
///
////////////////////////////////////////////////////////////
typedef enum
{
sfTextDirectionUnspecified, ///< Unspecified
sfTextDirectionLeftToRight, ///< Left-to-right
sfTextDirectionRightToLeft, ///< Right-to-left
sfTextDirectionTopToBottom, ///< Top-to-bottom
sfTextDirectionBottomToTop ///< Bottom-to-top
} sfTextDirection;
////////////////////////////////////////////////////////////
/// \brief Text orientation
///
////////////////////////////////////////////////////////////
typedef enum
{
sfTextOrientationDefault, ///< Default (left-to-right or right-to-left depending on detected script)
sfTextOrientationTopToBottom, ///< Top-to-bottom
sfTextOrientationBottomToTop ///< Bottom-to-top
} sfTextOrientation;
////////////////////////////////////////////////////////////
/// \brief Glyph that has been positioned by the shaper
///
////////////////////////////////////////////////////////////
typedef struct
{
sfGlyph glyph; ///< The glyph
sfVector2f position; ///< Position of the glyph within a text
uint32_t cluster; ///< Cluster ID
sfTextDirection textDirection; ///< Text direction
float baseline; ///< The baseline position of the line this glyph is a part of
size_t vertexOffset; ///< Starting offset of the vertex data belonging to this glyph
size_t vertexCount; ///< Count of vertices belonging to this glyph
} sfShapedGlyph;
////////////////////////////////////////////////////////////
/// \brief Callback that is provided with glyph data for pre-processing
///
/// The callback is called once per glyph whenever the text
/// geometry is regenerated, in the order in which the glyph
/// geometry is generated. The style, fill color, outline color
/// and outline thickness of the glyph can be modified through
/// the given pointers.
///
/// To map glyphs back to the input string, use the cluster
/// value of the shaped glyph. See sf::Text::GlyphPreProcessor
/// in the SFML documentation for a detailed explanation.
///
/// Changing the style or outline thickness might lead to
/// slight inconsistencies of the text bounds, changing the
/// fill or outline color is always safe. It is not safe to
/// query the text bounds from within the callback.
///
/// \param shapedGlyph The shaped glyph to pre-process
/// \param style Style of the glyph (see sfTextStyle enum)
/// \param fillColor Fill color of the glyph
/// \param outlineColor Outline color of the glyph
/// \param outlineThickness Outline thickness of the glyph
/// \param userData User data passed to sfText_setGlyphPreProcessor
///
////////////////////////////////////////////////////////////
typedef void (*sfGlyphPreProcessor)(
const sfShapedGlyph* shapedGlyph,
uint32_t* style,
sfColor* fillColor,
sfColor* outlineColor,
float* outlineThickness,
void* userData);
////////////////////////////////////////////////////////////
/// \brief Create a new text
///
/// \param font Font used to draw the string
///
/// \return A new sfText object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfText* sfText_create(void);
CSFML_GRAPHICS_API sfText* sfText_create(const sfFont* font);
////////////////////////////////////////////////////////////
/// \brief Copy an existing text
@@ -74,7 +176,7 @@ CSFML_GRAPHICS_API sfText* sfText_copy(const sfText* text);
/// \param text Text to delete
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfText_destroy(sfText* text);
CSFML_GRAPHICS_API void sfText_destroy(const sfText* text);
////////////////////////////////////////////////////////////
/// \brief Set the position of a text
@@ -247,7 +349,7 @@ CSFML_GRAPHICS_API void sfText_setString(sfText* text, const char* string);
/// \param string New string
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfText_setUnicodeString(sfText* text, const sfUint32* string);
CSFML_GRAPHICS_API void sfText_setUnicodeString(sfText* text, const sfChar32* string);
////////////////////////////////////////////////////////////
/// \brief Set the font of a text
@@ -276,7 +378,7 @@ CSFML_GRAPHICS_API void sfText_setFont(sfText* text, const sfFont* font);
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfText_setCharacterSize(sfText* text, unsigned int size);
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
/// \brief Set the line spacing factor
///
/// The default spacing between lines is defined by the font.
@@ -322,23 +424,7 @@ CSFML_GRAPHICS_API void sfText_setLetterSpacing(sfText* text, float spacingFacto
/// \param style New style
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfText_setStyle(sfText* text, sfUint32 style);
////////////////////////////////////////////////////////////
/// \brief Set the fill color of a text
///
/// By default, the text's fill color is opaque white.
/// Setting the fill color to a transparent color with an outline
/// will cause the outline to be displayed in the fill area of the text.
///
/// \param text Text object
/// \param color New fill color of the text
///
/// \deprecated This function is deprecated and may be removed in future releases.
/// Use sfText_setFillColor instead.
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfText_setColor(sfText* text, sfColor color);
CSFML_GRAPHICS_API void sfText_setStyle(sfText* text, uint32_t style);
////////////////////////////////////////////////////////////
/// \brief Set the fill color of a text
@@ -372,6 +458,7 @@ CSFML_GRAPHICS_API void sfText_setOutlineColor(sfText* text, sfColor color);
/// Be aware that using a negative value for the outline
/// thickness will cause distorted rendering.
///
/// \param text Text object
/// \param thickness New outline thickness, in pixels
///
/// \see getOutlineThickness
@@ -379,6 +466,31 @@ CSFML_GRAPHICS_API void sfText_setOutlineColor(sfText* text, sfColor color);
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfText_setOutlineThickness(sfText* text, float thickness);
////////////////////////////////////////////////////////////
/// \brief Set the line alignment for a multi-line text
///
/// By default, the line alignment is sfTextLineAlignmentDefault.
///
/// \param text Text object
/// \param lineAlignment New line alignment
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfText_setLineAlignment(sfText* text, sfTextLineAlignment lineAlignment);
////////////////////////////////////////////////////////////
/// \brief Set the text orientation
///
/// By default, the text orientation is sfTextOrientationDefault.
///
/// Vertical text orientations require the font to provide
/// vertical metrics, see sfFontInfo.
///
/// \param text Text object
/// \param textOrientation New text orientation
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfText_setTextOrientation(sfText* text, sfTextOrientation textOrientation);
////////////////////////////////////////////////////////////
/// \brief Get the string of a text (returns an ANSI string)
///
@@ -397,7 +509,7 @@ CSFML_GRAPHICS_API const char* sfText_getString(const sfText* text);
/// \return String as UTF-32
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfUint32* sfText_getUnicodeString(const sfText* text);
CSFML_GRAPHICS_API const sfChar32* sfText_getUnicodeString(const sfText* text);
////////////////////////////////////////////////////////////
/// \brief Get the font used by a text
@@ -455,20 +567,7 @@ CSFML_GRAPHICS_API float sfText_getLineSpacing(const sfText* text);
/// \return Current string style (see sfTextStyle enum)
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfUint32 sfText_getStyle(const sfText* text);
////////////////////////////////////////////////////////////
/// \brief Get the fill color of a text
///
/// \param text Text object
///
/// \return Fill color of the text
///
/// \deprecated This function is deprecated and may be removed in future releases.
/// Use sfText_getFillColor instead.
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfColor sfText_getColor(const sfText* text);
CSFML_GRAPHICS_API uint32_t sfText_getStyle(const sfText* text);
////////////////////////////////////////////////////////////
/// \brief Get the fill color of a text
@@ -500,6 +599,26 @@ CSFML_GRAPHICS_API sfColor sfText_getOutlineColor(const sfText* text);
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API float sfText_getOutlineThickness(const sfText* text);
////////////////////////////////////////////////////////////
/// \brief Get the line alignment for a multi-line text
///
/// \param text Text object
///
/// \return Line alignment
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfTextLineAlignment sfText_getLineAlignment(const sfText* text);
////////////////////////////////////////////////////////////
/// \brief Get the text orientation
///
/// \param text Text object
///
/// \return Text orientation
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfTextOrientation sfText_getTextOrientation(const sfText* text);
////////////////////////////////////////////////////////////
/// \brief Return the position of the \a index-th character in a text
///
@@ -515,8 +634,113 @@ CSFML_GRAPHICS_API float sfText_getOutlineThickness(const sfText* text);
///
/// \return Position of the character
///
/// \deprecated Use sfText_getShapedGlyphs instead
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfText_findCharacterPos(const sfText* text, size_t index);
CSFML_GRAPHICS_API CSFML_DEPRECATED sfVector2f sfText_findCharacterPos(const sfText* text, size_t index);
////////////////////////////////////////////////////////////
/// \brief Get the shaped glyphs that make up a text
///
/// The result of shaping, i.e. positioning individual glyphs
/// based on the properties of the font and the input text,
/// is a sequence of shaped glyphs. In addition to the glyph
/// information that is available by looking up a glyph from
/// a font, the glyph position, glyph cluster ID and direction
/// of the text represented by the glyph is provided.
///
/// When positioning e.g. a cursor within the text, grapheme
/// clusters can be treated as the basic units of which the
/// text is composed. See sfText_setClusterGrouping.
///
/// The returned glyph positions are in local coordinates
/// (translation, rotation, scale and origin are not applied).
///
/// The returned array is owned by the text and stays valid
/// until the next call to this function or until the text
/// is destroyed.
///
/// \param text Text object
/// \param count Pointer to a variable that will be filled with the number of shaped glyphs
///
/// \return Pointer to the array of shaped glyphs
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfShapedGlyph* sfText_getShapedGlyphs(const sfText* text, size_t* count);
////////////////////////////////////////////////////////////
/// \brief Get the cluster grouping algorithm in use
///
/// \param text Text object
///
/// \return The cluster grouping algorithm in use
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfTextClusterGrouping sfText_getClusterGrouping(const sfText* text);
////////////////////////////////////////////////////////////
/// \brief Set the cluster grouping algorithm to use
///
/// By default, character cluster grouping is used.
///
/// Character cluster grouping is good enough to be able to
/// position cursors in most scenarios. If more coarse-grained
/// grouping is required, grapheme grouping can be selected.
///
/// Cluster grouping can also be disabled if necessary.
///
/// \param text Text object
/// \param clusterGrouping The cluster grouping algorithm to use
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfText_setClusterGrouping(sfText* text, sfTextClusterGrouping clusterGrouping);
////////////////////////////////////////////////////////////
/// \brief Set the glyph pre-processor to be called per glyph
///
/// The glyph pre-processor is called with glyph data to be
/// pre-processed whenever the text geometry is regenerated.
///
/// \param text Text object
/// \param glyphPreProcessor The glyph pre-processor to be called per glyph, pass NULL to disable pre-processing
/// \param userData User data that will be passed to the glyph pre-processor
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfText_setGlyphPreProcessor(sfText* text, sfGlyphPreProcessor glyphPreProcessor, void* userData);
////////////////////////////////////////////////////////////
/// \brief Get the vertex data of a text
///
/// The vertices form triangles (sfTriangles).
///
/// The vertex data is regenerated by the text whenever it is
/// necessary. Any changes made to the vertex data will be
/// discarded whenever this happens.
///
/// \param text Text object
/// \param count Pointer to a variable that will be filled with the number of vertices
///
/// \return Pointer to the vertex data of the text
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVertex* sfText_getVertexData(const sfText* text, size_t* count);
////////////////////////////////////////////////////////////
/// \brief Get the outline vertex data of a text
///
/// The vertices form triangles (sfTriangles).
///
/// The outline vertex data is regenerated by the text whenever
/// it is necessary. Any changes made to the outline vertex data
/// will be discarded whenever this happens.
///
/// \param text Text object
/// \param count Pointer to a variable that will be filled with the number of vertices
///
/// \return Pointer to the outline vertex data of the text
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVertex* sfText_getOutlineVertexData(const sfText* text, size_t* count);
////////////////////////////////////////////////////////////
/// \brief Get the local bounding rectangle of a text
@@ -549,6 +773,3 @@ CSFML_GRAPHICS_API sfFloatRect sfText_getLocalBounds(const sfText* text);
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfText_getGlobalBounds(const sfText* text);
#endif // SFML_TEXT_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,40 +22,41 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_TEXTURE_H
#define SFML_TEXTURE_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
#include <SFML/Window/Types.h>
#include <SFML/System/InputStream.h>
#include <SFML/System/Vector2.h>
#include <stddef.h>
#include <CSFML/Graphics/Export.h>
////////////////////////////////////////////////////////////
/// \brief Types of texture coordinates that can be used for rendering.
///
////////////////////////////////////////////////////////////
typedef enum
{
sfTextureNormalized, ///< sfTexture coordinates in range [0 .. 1].
sfTexturePixels ///< sfTexture coordinates in range [0 .. size].
} sfTextureCoordinateType;
#include <CSFML/Graphics/CoordinateType.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/System/InputStream.h>
#include <CSFML/System/Vector2.h>
#include <CSFML/Window/Types.h>
#include <stddef.h>
////////////////////////////////////////////////////////////
/// \brief Create a new texture
///
/// \param width Texture width
/// \param height Texture height
/// \param size Texture size
///
/// \return A new sfTexture object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfTexture* sfTexture_create(unsigned int width, unsigned int height);
CSFML_GRAPHICS_API sfTexture* sfTexture_create(sfVector2u size);
////////////////////////////////////////////////////////////
/// \brief Create a new sRGB-enabled texture
///
/// \param size Texture size
///
/// \return A new sfTexture object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfTexture* sfTexture_createSrgb(sfVector2u size);
////////////////////////////////////////////////////////////
/// \brief Create a new texture from a file
@@ -175,7 +176,33 @@ CSFML_GRAPHICS_API sfTexture* sfTexture_copy(const sfTexture* texture);
/// \param texture Texture to delete
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_destroy(sfTexture* texture);
CSFML_GRAPHICS_API void sfTexture_destroy(const sfTexture* texture);
////////////////////////////////////////////////////////////
/// \brief Resize the texture
///
/// If this function fails, the texture is left unchanged.
///
/// \param texture Texture to resize
/// \param size Width and height of the texture
///
/// \return `true` if resizing was successful, `false` if it failed
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API bool sfTexture_resize(sfTexture* texture, sfVector2u size);
////////////////////////////////////////////////////////////
/// \brief Resize the texture with sRGB-enabled
///
/// If this function fails, the texture is left unchanged.
///
/// \param texture Texture to resize
/// \param size Width and height of the texture
///
/// \return `true` if resizing was successful, `false` if it failed
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API bool sfTexture_resizeSrgb(sfTexture* texture, sfVector2u size);
////////////////////////////////////////////////////////////
/// \brief Return the size of the texture
@@ -202,13 +229,11 @@ CSFML_GRAPHICS_API sfImage* sfTexture_copyToImage(const sfTexture* texture);
///
/// \param texture Texture to update
/// \param pixels Array of pixels to copy to the texture
/// \param width Width of the pixel region contained in \a pixels
/// \param height Height of the pixel region contained in \a pixels
/// \param x X offset in the texture where to copy the source pixels
/// \param y Y offset in the texture where to copy the source pixels
/// \param size size of the pixel region contained in \a pixels
/// \param offset Offset in the texture where to copy the source pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_updateFromPixels(sfTexture* texture, const sfUint8* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y);
CSFML_GRAPHICS_API void sfTexture_updateFromPixels(sfTexture* texture, const uint8_t* pixels, sfVector2u size, sfVector2u offset);
////////////////////////////////////////////////////////////
/// \brief Update a part of this texture from another texture
@@ -222,63 +247,59 @@ CSFML_GRAPHICS_API void sfTexture_updateFromPixels(sfTexture* texture, const sfU
///
/// \param destination Destination texture to copy source texture to
/// \param source Source texture to copy to destination texture
/// \param x X offset in this texture where to copy the source texture
/// \param y Y offset in this texture where to copy the source texture
/// \param offset Offset in this texture where to copy the source texture
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_updateFromTexture(sfTexture* destination, const sfTexture* source, unsigned int x, unsigned int y);
CSFML_GRAPHICS_API void sfTexture_updateFromTexture(sfTexture* destination, const sfTexture* source, sfVector2u offset);
////////////////////////////////////////////////////////////
/// \brief Update a texture from an image
///
/// \param texture Texture to update
/// \param image Image to copy to the texture
/// \param x X offset in the texture where to copy the source pixels
/// \param y Y offset in the texture where to copy the source pixels
/// \param offset Offset in the texture where to copy the source pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_updateFromImage(sfTexture* texture, const sfImage* image, unsigned int x, unsigned int y);
CSFML_GRAPHICS_API void sfTexture_updateFromImage(sfTexture* texture, const sfImage* image, sfVector2u offset);
////////////////////////////////////////////////////////////
/// \brief Update a texture from the contents of a window
///
/// \param texture Texture to update
/// \param window Window to copy to the texture
/// \param x X offset in the texture where to copy the source pixels
/// \param y Y offset in the texture where to copy the source pixels
/// \param offset Offset in the texture where to copy the source pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_updateFromWindow(sfTexture* texture, const sfWindow* window, unsigned int x, unsigned int y);
CSFML_GRAPHICS_API void sfTexture_updateFromWindow(sfTexture* texture, const sfWindow* window, sfVector2u offset);
////////////////////////////////////////////////////////////
/// \brief Update a texture from the contents of a render-window
///
/// \param texture Texture to update
/// \param renderWindow Render-window to copy to the texture
/// \param x X offset in the texture where to copy the source pixels
/// \param y Y offset in the texture where to copy the source pixels
/// \param offset Offset in the texture where to copy the source pixels
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_updateFromRenderWindow(sfTexture* texture, const sfRenderWindow* renderWindow, unsigned int x, unsigned int y);
CSFML_GRAPHICS_API void sfTexture_updateFromRenderWindow(sfTexture* texture, const sfRenderWindow* renderWindow, sfVector2u offset);
////////////////////////////////////////////////////////////
/// \brief Enable or disable the smooth filter on a texture
///
/// \param texture The texture object
/// \param smooth sfTrue to enable smoothing, sfFalse to disable it
/// \param smooth true to enable smoothing, false to disable it
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_setSmooth(sfTexture* texture, sfBool smooth);
CSFML_GRAPHICS_API void sfTexture_setSmooth(sfTexture* texture, bool smooth);
////////////////////////////////////////////////////////////
/// \brief Tell whether the smooth filter is enabled or not for a texture
///
/// \param texture The texture object
///
/// \return sfTrue if smoothing is enabled, sfFalse if it is disabled
/// \return true if smoothing is enabled, false if it is disabled
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfTexture_isSmooth(const sfTexture* texture);
CSFML_GRAPHICS_API bool sfTexture_isSmooth(const sfTexture* texture);
////////////////////////////////////////////////////////////
/// \brief Tell whether the texture source is converted from sRGB or not
@@ -291,7 +312,7 @@ CSFML_GRAPHICS_API sfBool sfTexture_isSmooth(const sfTexture* texture);
/// \see sfTexture_createSrgbFromImage
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfTexture_isSrgb(const sfTexture* texture);
CSFML_GRAPHICS_API bool sfTexture_isSrgb(const sfTexture* texture);
////////////////////////////////////////////////////////////
/// \brief Enable or disable repeating for a texture
@@ -314,17 +335,17 @@ CSFML_GRAPHICS_API sfBool sfTexture_isSrgb(const sfTexture* texture);
/// \param repeated True to repeat the texture, false to disable repeating
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_setRepeated(sfTexture* texture, sfBool repeated);
CSFML_GRAPHICS_API void sfTexture_setRepeated(sfTexture* texture, bool repeated);
////////////////////////////////////////////////////////////
/// \brief Tell whether a texture is repeated or not
///
/// \param texture The texture object
///
/// \return sfTrue if repeat mode is enabled, sfFalse if it is disabled
/// \return true if repeat mode is enabled, false if it is disabled
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfTexture_isRepeated(const sfTexture* texture);
CSFML_GRAPHICS_API bool sfTexture_isRepeated(const sfTexture* texture);
////////////////////////////////////////////////////////////
/// \brief Generate a mipmap using the current texture data
@@ -346,10 +367,10 @@ CSFML_GRAPHICS_API sfBool sfTexture_isRepeated(const sfTexture* texture);
/// modified, at which point this function will have to be called again to
/// regenerate it.
///
/// \return sfTrue if mipmap generation was successful, sfFalse if unsuccessful
/// \return true if mipmap generation was successful, false if unsuccessful
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfTexture_generateMipmap(sfTexture* texture);
CSFML_GRAPHICS_API bool sfTexture_generateMipmap(sfTexture* texture);
////////////////////////////////////////////////////////////
/// \brief Swap the contents of a texture with those of another
@@ -393,9 +414,10 @@ CSFML_GRAPHICS_API unsigned int sfTexture_getNativeHandle(const sfTexture* textu
/// \endcode
///
/// \param texture Pointer to the texture to bind, can be null to use no texture
/// \param type Type of texture coordinates to use
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_bind(const sfTexture* texture, sfTextureCoordinateType type);
CSFML_GRAPHICS_API void sfTexture_bind(const sfTexture* texture, sfCoordinateType type);
////////////////////////////////////////////////////////////
/// \brief Get the maximum texture size allowed
@@ -404,6 +426,3 @@ CSFML_GRAPHICS_API void sfTexture_bind(const sfTexture* texture, sfTextureCoordi
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API unsigned int sfTexture_getMaximumSize(void);
#endif // SFML_TEXTURE_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,17 +22,16 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_TRANSFORM_H
#define SFML_TRANSFORM_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
#include <SFML/System/Vector2.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/System/Vector2.h>
////////////////////////////////////////////////////////////
@@ -67,9 +66,8 @@ CSFML_GRAPHICS_API const sfTransform sfTransform_Identity;
/// \return A new sfTransform object
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfTransform sfTransform_fromMatrix(float a00, float a01, float a02,
float a10, float a11, float a12,
float a20, float a21, float a22);
CSFML_GRAPHICS_API sfTransform
sfTransform_fromMatrix(float a00, float a01, float a02, float a10, float a11, float a12, float a20, float a21, float a22);
////////////////////////////////////////////////////////////
/// \brief Return the 4x4 matrix of a transform
@@ -148,11 +146,10 @@ CSFML_GRAPHICS_API void sfTransform_combine(sfTransform* transform, const sfTran
/// \brief Combine a transform with a translation
///
/// \param transform Transform object
/// \param x Offset to apply on X axis
/// \param y Offset to apply on Y axis
/// \param offset Offset to apply
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTransform_translate(sfTransform* transform, float x, float y);
CSFML_GRAPHICS_API void sfTransform_translate(sfTransform* transform, sfVector2f offset);
////////////////////////////////////////////////////////////
/// \brief Combine the current transform with a rotation
@@ -173,21 +170,19 @@ CSFML_GRAPHICS_API void sfTransform_rotate(sfTransform* transform, float angle);
///
/// \param transform Transform object
/// \param angle Rotation angle, in degrees
/// \param centerX X coordinate of the center of rotation
/// \param centerY Y coordinate of the center of rotation
/// \param center Coordinates of the center of rotation
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTransform_rotateWithCenter(sfTransform* transform, float angle, float centerX, float centerY);
CSFML_GRAPHICS_API void sfTransform_rotateWithCenter(sfTransform* transform, float angle, sfVector2f center);
////////////////////////////////////////////////////////////
/// \brief Combine the current transform with a scaling
///
/// \param transform Transform object
/// \param scaleX Scaling factor on the X axis
/// \param scaleY Scaling factor on the Y axis
/// \param scale Scaling factor
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTransform_scale(sfTransform* transform, float scaleX, float scaleY);
CSFML_GRAPHICS_API void sfTransform_scale(sfTransform* transform, sfVector2f scale);
////////////////////////////////////////////////////////////
/// \brief Combine the current transform with a scaling
@@ -198,13 +193,11 @@ CSFML_GRAPHICS_API void sfTransform_scale(sfTransform* transform, float scaleX,
/// [translate(-center), scale(factors), translate(center)]
///
/// \param transform Transform object
/// \param scaleX Scaling factor on X axis
/// \param scaleY Scaling factor on Y axis
/// \param centerX X coordinate of the center of scaling
/// \param centerY Y coordinate of the center of scaling
/// \param scale Scaling factor
/// \param center Coordinates of the center of scaling
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTransform_scaleWithCenter(sfTransform* transform, float scaleX, float scaleY, float centerX, float centerY);
CSFML_GRAPHICS_API void sfTransform_scaleWithCenter(sfTransform* transform, sfVector2f scale, sfVector2f center);
////////////////////////////////////////////////////////////
/// \brief Compare two transforms for equality
@@ -218,6 +211,4 @@ CSFML_GRAPHICS_API void sfTransform_scaleWithCenter(sfTransform* transform, floa
/// \return true if the transforms are equal, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfTransform_equal(sfTransform* left, sfTransform* right);
#endif // SFML_TRANSFORM_H
CSFML_GRAPHICS_API bool sfTransform_equal(sfTransform* left, sfTransform* right);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,16 +22,16 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_TRANSFORMABLE_H
#define SFML_TRANSFORMABLE_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Types.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/System/Vector2.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/Transform.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/System/Vector2.h>
////////////////////////////////////////////////////////////
@@ -58,7 +58,7 @@ CSFML_GRAPHICS_API sfTransformable* sfTransformable_copy(const sfTransformable*
/// \param transformable Transformable to delete
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTransformable_destroy(sfTransformable* transformable);
CSFML_GRAPHICS_API void sfTransformable_destroy(const sfTransformable* transformable);
////////////////////////////////////////////////////////////
/// \brief Set the position of a transformable
@@ -212,6 +212,3 @@ CSFML_GRAPHICS_API sfTransform sfTransformable_getTransform(const sfTransformabl
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfTransform sfTransformable_getInverseTransform(const sfTransformable* transformable);
#endif // SFML_TRANSFORMABLE_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,26 +22,22 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_GRAPHICS_TYPES_H
#define SFML_GRAPHICS_TYPES_H
#pragma once
typedef struct sfCircleShape sfCircleShape;
typedef struct sfConvexShape sfConvexShape;
typedef struct sfFont sfFont;
typedef struct sfImage sfImage;
typedef struct sfShader sfShader;
typedef struct sfCircleShape sfCircleShape;
typedef struct sfConvexShape sfConvexShape;
typedef struct sfFont sfFont;
typedef struct sfImage sfImage;
typedef struct sfShader sfShader;
typedef struct sfRectangleShape sfRectangleShape;
typedef struct sfRenderTexture sfRenderTexture;
typedef struct sfRenderWindow sfRenderWindow;
typedef struct sfShape sfShape;
typedef struct sfSprite sfSprite;
typedef struct sfText sfText;
typedef struct sfTexture sfTexture;
typedef struct sfTransformable sfTransformable;
typedef struct sfVertexArray sfVertexArray;
typedef struct sfVertexBuffer sfVertexBuffer;
typedef struct sfView sfView;
#endif // SFML_GRAPHICS_TYPES_H
typedef struct sfRenderTexture sfRenderTexture;
typedef struct sfRenderWindow sfRenderWindow;
typedef struct sfShape sfShape;
typedef struct sfSprite sfSprite;
typedef struct sfText sfText;
typedef struct sfTexture sfTexture;
typedef struct sfTransformable sfTransformable;
typedef struct sfVertexArray sfVertexArray;
typedef struct sfVertexBuffer sfVertexBuffer;
typedef struct sfView sfView;
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,15 +22,15 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_VERTEX_H
#define SFML_VERTEX_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h>
#include <SFML/System/Vector2.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/Color.h>
#include <CSFML/System/Vector2.h>
////////////////////////////////////////////////////////////
@@ -42,6 +42,3 @@ typedef struct
sfColor color; ///< Color of the vertex
sfVector2f texCoords; ///< Coordinates of the texture's pixel to map to the vertex
} sfVertex;
#endif // SFML_VERTEX_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,17 +22,18 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_VERTEXARRAY_H
#define SFML_VERTEXARRAY_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/PrimitiveType.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
#include <SFML/Graphics/Vertex.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/PrimitiveType.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/Graphics/Vertex.h>
#include <stddef.h>
@@ -60,7 +61,7 @@ CSFML_GRAPHICS_API sfVertexArray* sfVertexArray_copy(const sfVertexArray* vertex
/// \param vertexArray Vertex array to delete
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfVertexArray_destroy(sfVertexArray* vertexArray);
CSFML_GRAPHICS_API void sfVertexArray_destroy(const sfVertexArray* vertexArray);
////////////////////////////////////////////////////////////
/// \brief Return the vertex count of a vertex array
@@ -109,7 +110,7 @@ CSFML_GRAPHICS_API void sfVertexArray_clear(sfVertexArray* vertexArray);
/// If \a vertexCount is less than the current size, existing vertices
/// are removed from the array.
///
/// \param vertexArray Vertex array objet
/// \param vertexArray Vertex array object
/// \param vertexCount New size of the array (number of vertices)
///
////////////////////////////////////////////////////////////
@@ -118,7 +119,7 @@ CSFML_GRAPHICS_API void sfVertexArray_resize(sfVertexArray* vertexArray, size_t
////////////////////////////////////////////////////////////
/// \brief Add a vertex to a vertex array array
///
/// \param vertexArray Vertex array objet
/// \param vertexArray Vertex array object
/// \param vertex Vertex to add
///
////////////////////////////////////////////////////////////
@@ -135,7 +136,7 @@ CSFML_GRAPHICS_API void sfVertexArray_append(sfVertexArray* vertexArray, sfVerte
/// \li As quads
/// The default primitive type is sfPoints.
///
/// \param vertexArray Vertex array objet
/// \param vertexArray Vertex array object
/// \param type Type of primitive
///
////////////////////////////////////////////////////////////
@@ -144,12 +145,12 @@ CSFML_GRAPHICS_API void sfVertexArray_setPrimitiveType(sfVertexArray* vertexArra
////////////////////////////////////////////////////////////
/// \brief Get the type of primitives drawn by a vertex array
///
/// \param vertexArray Vertex array objet
/// \param vertexArray Vertex array object
///
/// \return Primitive type
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfPrimitiveType sfVertexArray_getPrimitiveType(sfVertexArray* vertexArray);
CSFML_GRAPHICS_API sfPrimitiveType sfVertexArray_getPrimitiveType(const sfVertexArray* vertexArray);
////////////////////////////////////////////////////////////
/// \brief Compute the bounding rectangle of a vertex array
@@ -157,12 +158,9 @@ CSFML_GRAPHICS_API sfPrimitiveType sfVertexArray_getPrimitiveType(sfVertexArray*
/// This function returns the axis-aligned rectangle that
/// contains all the vertices of the array.
///
/// \param vertexArray Vertex array objet
/// \param vertexArray Vertex array object
///
/// \return Bounding rectangle of the vertex array
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfVertexArray_getBounds(sfVertexArray* vertexArray);
#endif // SFML_VERTEXARRAY_H
CSFML_GRAPHICS_API sfFloatRect sfVertexArray_getBounds(const sfVertexArray* vertexArray);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,16 +22,17 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_VERTEXBUFFER_H
#define SFML_VERTEXBUFFER_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/PrimitiveType.h>
#include <SFML/Graphics/Types.h>
#include <SFML/Graphics/Vertex.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/PrimitiveType.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/Graphics/Vertex.h>
#include <stddef.h>
@@ -57,7 +58,7 @@ typedef enum
/// \brief Create a new vertex buffer with a specific
/// sfPrimitiveType and usage specifier.
///
/// Creates the vertex buffer, allocating enough graphcis
/// Creates the vertex buffer, allocating enough graphics
/// memory to hold \p vertexCount vertices, and sets its
/// primitive type to \p type and usage to \p usage.
///
@@ -68,7 +69,7 @@ typedef enum
/// \return A new sfVertexBuffer object
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVertexBuffer* sfVertexBuffer_create(unsigned int vertexCount, sfPrimitiveType type, sfVertexBufferUsage usage);
CSFML_GRAPHICS_API sfVertexBuffer* sfVertexBuffer_create(size_t vertexCount, sfPrimitiveType type, sfVertexBufferUsage usage);
////////////////////////////////////////////////////////////
/// \brief Copy an existing vertex buffer
@@ -86,7 +87,7 @@ CSFML_GRAPHICS_API sfVertexBuffer* sfVertexBuffer_copy(const sfVertexBuffer* ver
/// \param vertexBuffer Vertex buffer to delete
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfVertexBuffer_destroy(sfVertexBuffer* vertexBuffer);
CSFML_GRAPHICS_API void sfVertexBuffer_destroy(const sfVertexBuffer* vertexBuffer);
////////////////////////////////////////////////////////////
/// \brief Return the vertex count
@@ -96,7 +97,7 @@ CSFML_GRAPHICS_API void sfVertexBuffer_destroy(sfVertexBuffer* vertexBuffer);
/// \return Number of vertices in the vertex buffer
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API unsigned int sfVertexBuffer_getVertexCount(const sfVertexBuffer* vertexBuffer);
CSFML_GRAPHICS_API size_t sfVertexBuffer_getVertexCount(const sfVertexBuffer* vertexBuffer);
////////////////////////////////////////////////////////////
/// \brief Update a part of the buffer from an array of vertices
@@ -122,14 +123,18 @@ CSFML_GRAPHICS_API unsigned int sfVertexBuffer_getVertexCount(const sfVertexBuff
/// array, passing invalid arguments will lead to undefined
/// behavior.
///
/// \param vertices Array of vertices to copy to the buffer
/// \param vertexCount Number of vertices to copy
/// \param offset Offset in the buffer to copy to
/// \param vertexBuffer Vertex buffer object
/// \param vertices Array of vertices to copy to the buffer
/// \param vertexCount Number of vertices to copy
/// \param offset Offset in the buffer to copy to
///
/// \return sfTrue if the update was successful
/// \return true if the update was successful
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfVertexBuffer_update(sfVertexBuffer* vertexBuffer, const sfVertex* vertices, unsigned int vertexCount, unsigned int offset);
CSFML_GRAPHICS_API bool sfVertexBuffer_update(sfVertexBuffer* vertexBuffer,
const sfVertex* vertices,
unsigned int vertexCount,
unsigned int offset);
////////////////////////////////////////////////////////////
/// \brief Copy the contents of another buffer into this buffer
@@ -137,10 +142,10 @@ CSFML_GRAPHICS_API sfBool sfVertexBuffer_update(sfVertexBuffer* vertexBuffer, co
/// \param vertexBuffer Vertex buffer object
/// \param other Vertex buffer whose contents to copy into first vertex buffer
///
/// \return sfTrue if the copy was successful
/// \return true if the copy was successful
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfVertexBuffer_updateFromVertexBuffer(sfVertexBuffer* vertexBuffer, const sfVertexBuffer* other);
CSFML_GRAPHICS_API bool sfVertexBuffer_updateFromVertexBuffer(sfVertexBuffer* vertexBuffer, const sfVertexBuffer* other);
////////////////////////////////////////////////////////////
/// \brief Swap the contents of this vertex buffer with those of another
@@ -161,7 +166,7 @@ CSFML_GRAPHICS_API void sfVertexBuffer_swap(sfVertexBuffer* left, sfVertexBuffer
/// \return OpenGL handle of the vertex buffer or 0 if not yet created
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API unsigned int sfVertexBuffer_getNativeHandle(sfVertexBuffer* vertexBuffer);
CSFML_GRAPHICS_API unsigned int sfVertexBuffer_getNativeHandle(const sfVertexBuffer* vertexBuffer);
////////////////////////////////////////////////////////////
/// \brief Set the type of primitives to draw
@@ -169,7 +174,7 @@ CSFML_GRAPHICS_API unsigned int sfVertexBuffer_getNativeHandle(sfVertexBuffer* v
/// This function defines how the vertices must be interpreted
/// when it's time to draw them.
///
/// The default primitive type is sf::Points.
/// The default primitive type is sfPoints.
///
/// \param vertexBuffer Vertex buffer object
/// \param type Type of primitive
@@ -243,12 +248,9 @@ CSFML_GRAPHICS_API void sfVertexBuffer_bind(const sfVertexBuffer* vertexBuffer);
///
/// This function should always be called before using
/// the vertex buffer features. If it returns false, then
/// any attempt to use sf::VertexBuffer will fail.
/// any attempt to use sfVertexBuffer will fail.
///
/// \return True if vertex buffers are supported, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfVertexBuffer_isAvailable(void);
#endif // SFML_VERTEXBUFFER_H
CSFML_GRAPHICS_API bool sfVertexBuffer_isAvailable(void);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,16 +22,16 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_VIEW_H
#define SFML_VIEW_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
#include <SFML/System/Vector2.h>
#include <CSFML/Graphics/Export.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/System/Vector2.h>
////////////////////////////////////////////////////////////
@@ -70,7 +70,7 @@ CSFML_GRAPHICS_API sfView* sfView_copy(const sfView* view);
/// \param view View to destroy
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfView_destroy(sfView* view);
CSFML_GRAPHICS_API void sfView_destroy(const sfView* view);
////////////////////////////////////////////////////////////
/// \brief Set the center of a view
@@ -118,15 +118,27 @@ CSFML_GRAPHICS_API void sfView_setRotation(sfView* view, float angle);
CSFML_GRAPHICS_API void sfView_setViewport(sfView* view, sfFloatRect viewport);
////////////////////////////////////////////////////////////
/// \brief Reset a view to the given rectangle
/// \brief Set the target scissor rectangle
///
/// Note that this function resets the rotation angle to 0.
/// The scissor rectangle, expressed as a factor (between 0 and 1) of
/// the RenderTarget, specifies the region of the RenderTarget whose
/// pixels are able to be modified by draw or clear operations.
/// Any pixels which lie outside of the scissor rectangle will
/// not be modified by draw or clear operations.
/// For example, a scissor rectangle which only allows modifications
/// to the right side of the target would be defined
/// with `sfView_setScissor(view, (sfFloatRect){{0.5f, 0.f}, {0.5f, 1.f}})`.
/// By default, a view has a scissor rectangle which allows
/// modifications to the entire target. This is equivalent to
/// disabling the scissor test entirely. Passing the default
/// scissor rectangle to this function will also disable
/// scissor testing.
///
/// \param view View object
/// \param rectangle Rectangle defining the zone to display
/// \param view View object
/// \param scissor New scissor rectangle
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfView_reset(sfView* view, sfFloatRect rectangle);
CSFML_GRAPHICS_API void sfView_setScissor(sfView* view, sfFloatRect scissor);
////////////////////////////////////////////////////////////
/// \brief Get the center of a view
@@ -169,7 +181,17 @@ CSFML_GRAPHICS_API float sfView_getRotation(const sfView* view);
CSFML_GRAPHICS_API sfFloatRect sfView_getViewport(const sfView* view);
////////////////////////////////////////////////////////////
/// \brief Move a view relatively to its current position
/// \brief Get the scissor rectangle of the view
///
/// \param view View object
///
/// \return Scissor rectangle, expressed as a factor of the target size
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfView_getScissor(const sfView* view);
////////////////////////////////////////////////////////////
/// \brief Move a view relative to its current position
///
/// \param view View object
/// \param offset Offset
@@ -178,7 +200,7 @@ CSFML_GRAPHICS_API sfFloatRect sfView_getViewport(const sfView* view);
CSFML_GRAPHICS_API void sfView_move(sfView* view, sfVector2f offset);
////////////////////////////////////////////////////////////
/// \brief Rotate a view relatively to its current orientation
/// \brief Rotate a view relative to its current orientation
///
/// \param view View object
/// \param angle Angle to rotate, in degrees
@@ -187,7 +209,7 @@ CSFML_GRAPHICS_API void sfView_move(sfView* view, sfVector2f offset);
CSFML_GRAPHICS_API void sfView_rotate(sfView* view, float angle);
////////////////////////////////////////////////////////////
/// \brief Resize a view rectangle relatively to its current size
/// \brief Resize a view rectangle relative to its current size
///
/// Resizing the view simulates a zoom, as the zone displayed on
/// screen grows or shrinks.
@@ -201,6 +223,3 @@ CSFML_GRAPHICS_API void sfView_rotate(sfView* view, float angle);
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfView_zoom(sfView* view, float factor);
#endif // SFML_VIEW_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,23 +22,21 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_NETWORK_H
#define SFML_NETWORK_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System.h>
#include <SFML/Network/Ftp.h>
#include <SFML/Network/Http.h>
#include <SFML/Network/IpAddress.h>
#include <SFML/Network/Packet.h>
#include <SFML/Network/SocketSelector.h>
#include <SFML/Network/SocketStatus.h>
#include <SFML/Network/TcpListener.h>
#include <SFML/Network/TcpSocket.h>
#include <SFML/Network/UdpSocket.h>
#endif // SFML_NETWORK_H
#include <CSFML/Network/Dns.h>
#include <CSFML/Network/Ftp.h>
#include <CSFML/Network/Http.h>
#include <CSFML/Network/IpAddress.h>
#include <CSFML/Network/Packet.h>
#include <CSFML/Network/Sftp.h>
#include <CSFML/Network/SocketSelector.h>
#include <CSFML/Network/SocketStatus.h>
#include <CSFML/Network/TcpListener.h>
#include <CSFML/Network/TcpSocket.h>
#include <CSFML/Network/UdpSocket.h>
#include <CSFML/System.h>
+288
View File
@@ -0,0 +1,288 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <CSFML/Network/Export.h>
#include <CSFML/Network/IpAddress.h>
#include <CSFML/Network/Types.h>
#include <CSFML/System/Time.h>
#include <stddef.h>
#include <stdint.h>
////////////////////////////////////////////////////////////
/// \brief A DNS MX record
///
////////////////////////////////////////////////////////////
typedef struct
{
const char* exchange; ///< Host willing to act as mail exchange
uint16_t preference; ///< Preference of this record among others, lower values are preferred
} sfDnsMxRecord;
////////////////////////////////////////////////////////////
/// \brief A DNS SRV record
///
////////////////////////////////////////////////////////////
typedef struct
{
const char* target; ///< The domain name of the target host
uint16_t port; ///< The port on the target host of the service
uint16_t weight; ///< Server selection mechanism, larger weights should be given a proportionately higher probability of being selected
uint16_t priority; ///< The priority of the target host, a client must attempt to contact the target host with the lowest-numbered priority it can reach
} sfDnsSrvRecord;
////////////////////////////////////////////////////////////
/// \brief Resolve a hostname into a list of IP addresses
///
/// The returned array must be freed with sfFree.
///
/// \param hostname Hostname to resolve, encoded in UTF-8
/// \param servers The list of servers to query, NULL to use the default servers
/// \param serverCount Number of servers in \a servers
/// \param timeout Query timeout if using a provided list of servers, use 0 to wait forever
/// \param count Pointer to a variable that will be filled with the number of addresses
///
/// \return Array of IP addresses the given hostname resolves to, NULL if name resolution fails or no address was found
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfIpAddress* sfDns_resolve(
const char* hostname,
const sfIpAddress* servers,
size_t serverCount,
sfTime timeout,
size_t* count);
////////////////////////////////////////////////////////////
/// \brief Query NS records for a hostname
///
/// \param hostname Hostname to query NS records for, encoded in UTF-8
/// \param servers The list of servers to query, NULL to use the default servers
/// \param serverCount Number of servers in \a servers
/// \param timeout Query timeout if using a provided list of servers, use 0 to wait forever
///
/// \return New list of NS records, which can be empty
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfDnsNsRecords* sfDns_queryNs(const char* hostname, const sfIpAddress* servers, size_t serverCount, sfTime timeout);
////////////////////////////////////////////////////////////
/// \brief Query MX records for a hostname
///
/// \param hostname Hostname to query MX records for, encoded in UTF-8
/// \param servers The list of servers to query, NULL to use the default servers
/// \param serverCount Number of servers in \a servers
/// \param timeout Query timeout if using a provided list of servers, use 0 to wait forever
///
/// \return New list of MX records, which can be empty
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfDnsMxRecords* sfDns_queryMx(const char* hostname, const sfIpAddress* servers, size_t serverCount, sfTime timeout);
////////////////////////////////////////////////////////////
/// \brief Query SRV records for a hostname
///
/// \param hostname Hostname to query SRV records for, encoded in UTF-8
/// \param servers The list of servers to query, NULL to use the default servers
/// \param serverCount Number of servers in \a servers
/// \param timeout Query timeout if using a provided list of servers, use 0 to wait forever
///
/// \return New list of SRV records, which can be empty
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfDnsSrvRecords* sfDns_querySrv(const char* hostname, const sfIpAddress* servers, size_t serverCount, sfTime timeout);
////////////////////////////////////////////////////////////
/// \brief Query TXT records for a hostname
///
/// \param hostname Hostname to query TXT records for, encoded in UTF-8
/// \param servers The list of servers to query, NULL to use the default servers
/// \param serverCount Number of servers in \a servers
/// \param timeout Query timeout if using a provided list of servers, use 0 to wait forever
///
/// \return New list of TXT records, which can be empty
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfDnsTxtRecords* sfDns_queryTxt(const char* hostname, const sfIpAddress* servers, size_t serverCount, sfTime timeout);
////////////////////////////////////////////////////////////
/// \brief Get the computer's public address via DNS
///
/// The public address is the address of the computer from the
/// point of view of the internet, i.e. something like 89.54.1.169
/// or 2600:1901:0:13e0::1 as opposed to a private or local address
/// like 192.168.1.56 or fe80::1234:5678:9abc.
///
/// This function depends on both your network connection and
/// the server, and may be very slow. You should try to use it
/// as little as possible.
///
/// \param timeout Maximum time to wait, use 0 to wait forever
/// \param type The type of public address to get
///
/// \return Public IP address of the computer on success, sfIpAddress_None otherwise
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfIpAddress sfDns_getPublicAddress(sfTime timeout, sfIpAddressType type);
////////////////////////////////////////////////////////////
/// \brief Destroy a list of NS records
///
/// \param records List of NS records to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfDnsNsRecords_destroy(const sfDnsNsRecords* records);
////////////////////////////////////////////////////////////
/// \brief Get the number of NS records in a list
///
/// \param records List of NS records
///
/// \return Number of NS records
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API size_t sfDnsNsRecords_getCount(const sfDnsNsRecords* records);
////////////////////////////////////////////////////////////
/// \brief Get a NS record of a list
///
/// \param records List of NS records
/// \param index Index of the NS record to get
///
/// \return The NS record, encoded in UTF-8
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const char* sfDnsNsRecords_getRecord(const sfDnsNsRecords* records, size_t index);
////////////////////////////////////////////////////////////
/// \brief Destroy a list of MX records
///
/// \param records List of MX records to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfDnsMxRecords_destroy(const sfDnsMxRecords* records);
////////////////////////////////////////////////////////////
/// \brief Get the number of MX records in a list
///
/// \param records List of MX records
///
/// \return Number of MX records
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API size_t sfDnsMxRecords_getCount(const sfDnsMxRecords* records);
////////////////////////////////////////////////////////////
/// \brief Get a MX record of a list
///
/// The strings of the record stay valid until the list
/// is destroyed.
///
/// \param records List of MX records
/// \param index Index of the MX record to get
///
/// \return The MX record
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfDnsMxRecord sfDnsMxRecords_getRecord(const sfDnsMxRecords* records, size_t index);
////////////////////////////////////////////////////////////
/// \brief Destroy a list of SRV records
///
/// \param records List of SRV records to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfDnsSrvRecords_destroy(const sfDnsSrvRecords* records);
////////////////////////////////////////////////////////////
/// \brief Get the number of SRV records in a list
///
/// \param records List of SRV records
///
/// \return Number of SRV records
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API size_t sfDnsSrvRecords_getCount(const sfDnsSrvRecords* records);
////////////////////////////////////////////////////////////
/// \brief Get a SRV record of a list
///
/// The strings of the record stay valid until the list
/// is destroyed.
///
/// \param records List of SRV records
/// \param index Index of the SRV record to get
///
/// \return The SRV record
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfDnsSrvRecord sfDnsSrvRecords_getRecord(const sfDnsSrvRecords* records, size_t index);
////////////////////////////////////////////////////////////
/// \brief Destroy a list of TXT records
///
/// \param records List of TXT records to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfDnsTxtRecords_destroy(const sfDnsTxtRecords* records);
////////////////////////////////////////////////////////////
/// \brief Get the number of TXT records in a list
///
/// \param records List of TXT records
///
/// \return Number of TXT records
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API size_t sfDnsTxtRecords_getCount(const sfDnsTxtRecords* records);
////////////////////////////////////////////////////////////
/// \brief Get the number of strings in a TXT record
///
/// \param records List of TXT records
/// \param index Index of the TXT record
///
/// \return Number of strings in the TXT record
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API size_t sfDnsTxtRecords_getStringCount(const sfDnsTxtRecords* records, size_t index);
////////////////////////////////////////////////////////////
/// \brief Get a string of a TXT record
///
/// \param records List of TXT records
/// \param index Index of the TXT record
/// \param stringIndex Index of the string within the TXT record
///
/// \return The string, encoded in UTF-8
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const char* sfDnsTxtRecords_getString(const sfDnsTxtRecords* records, size_t index, size_t stringIndex);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,13 +22,12 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_NETWORK_EXPORT_H
#define SFML_NETWORK_EXPORT_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <CSFML/Config.h>
////////////////////////////////////////////////////////////
@@ -36,13 +35,10 @@
////////////////////////////////////////////////////////////
#if defined(CSFML_NETWORK_EXPORTS)
#define CSFML_NETWORK_API CSFML_API_EXPORT
#define CSFML_NETWORK_API CSFML_API_EXPORT
#else
#define CSFML_NETWORK_API CSFML_API_IMPORT
#define CSFML_NETWORK_API CSFML_API_IMPORT
#endif
#endif // SFML_NETWORK_EXPORT_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,15 +22,16 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_FTP_H
#define SFML_FTP_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.h>
#include <SFML/Network/IpAddress.h>
#include <SFML/Network/Types.h>
#include <CSFML/Network/Export.h>
#include <CSFML/Network/IpAddress.h>
#include <CSFML/Network/Types.h>
#include <stddef.h>
@@ -40,7 +41,7 @@
////////////////////////////////////////////////////////////
typedef enum
{
sfFtpBinary, ///< Binary mode (file is transfered as a sequence of bytes)
sfFtpBinary, ///< Binary mode (file is transferred as a sequence of bytes)
sfFtpAscii, ///< Text mode using ASCII encoding
sfFtpEbcdic ///< Text mode using EBCDIC encoding
} sfFtpTransferMode;
@@ -60,13 +61,13 @@ typedef enum
sfFtpOpeningDataConnection = 150, ///< File status ok, about to open data connection
// 2xx: the requested action has been successfully completed
sfFtpOk = 200, ///< Command ok
sfFtpPointlessCommand = 202, ///< Command not implemented
sfFtpSystemStatus = 211, ///< System status, or system help reply
sfFtpDirectoryStatus = 212, ///< Directory status
sfFtpFileStatus = 213, ///< File status
sfFtpHelpMessage = 214, ///< Help message
sfFtpSystemType = 215, ///< NAME system type, where NAME is an official system name from the list in the Assigned Numbers document
sfFtpOk = 200, ///< Command ok
sfFtpPointlessCommand = 202, ///< Command not implemented
sfFtpSystemStatus = 211, ///< System status, or system help reply
sfFtpDirectoryStatus = 212, ///< Directory status
sfFtpFileStatus = 213, ///< File status
sfFtpHelpMessage = 214, ///< Help message
sfFtpSystemType = 215, ///< NAME system type, where NAME is an official system name from the list in the Assigned Numbers document
sfFtpServiceReady = 220, ///< Service ready for new user
sfFtpClosingConnection = 221, ///< Service closing control connection
sfFtpDataConnectionOpened = 225, ///< Data connection open, no transfer in progress
@@ -89,7 +90,7 @@ typedef enum
sfFtpTransferAborted = 426, ///< Connection closed, transfer aborted
sfFtpFileActionAborted = 450, ///< Requested file action not taken
sfFtpLocalError = 451, ///< Requested action aborted, local error in processing
sfFtpInsufficientStorageSpace = 452, ///< Requested action not taken; insufficient storage space in system, file unavailable
sfFtpInsufficientStorageSpace = 452, ///< Requested action not taken; insufficient storage space in system, file unavailable
// 5xx: the command was not accepted and
// the requested action did not take place
@@ -118,8 +119,10 @@ typedef enum
///
/// \param ftpListingResponse Ftp listing response to destroy
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfFtpListingResponse_destroy(sfFtpListingResponse* ftpListingResponse);
CSFML_NETWORK_API CSFML_DEPRECATED void sfFtpListingResponse_destroy(const sfFtpListingResponse* ftpListingResponse);
////////////////////////////////////////////////////////////
/// \brief Check if a FTP listing response status code means a success
@@ -129,10 +132,12 @@ CSFML_NETWORK_API void sfFtpListingResponse_destroy(sfFtpListingResponse* ftpLis
///
/// \param ftpListingResponse Ftp listing response
///
/// \return sfTrue if the status is a success, sfFalse if it is a failure
/// \return true if the status is a success, false if it is a failure
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfBool sfFtpListingResponse_isOk(const sfFtpListingResponse* ftpListingResponse);
CSFML_NETWORK_API CSFML_DEPRECATED bool sfFtpListingResponse_isOk(const sfFtpListingResponse* ftpListingResponse);
////////////////////////////////////////////////////////////
/// \brief Get the status code of a FTP listing response
@@ -141,8 +146,10 @@ CSFML_NETWORK_API sfBool sfFtpListingResponse_isOk(const sfFtpListingResponse* f
///
/// \return Status code
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpStatus sfFtpListingResponse_getStatus(const sfFtpListingResponse* ftpListingResponse);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpStatus sfFtpListingResponse_getStatus(const sfFtpListingResponse* ftpListingResponse);
////////////////////////////////////////////////////////////
/// \brief Get the full message contained in a FTP listing response
@@ -151,8 +158,10 @@ CSFML_NETWORK_API sfFtpStatus sfFtpListingResponse_getStatus(const sfFtpListingR
///
/// \return The response message
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const char* sfFtpListingResponse_getMessage(const sfFtpListingResponse* ftpListingResponse);
CSFML_NETWORK_API CSFML_DEPRECATED const char* sfFtpListingResponse_getMessage(const sfFtpListingResponse* ftpListingResponse);
////////////////////////////////////////////////////////////
/// \brief Return the number of directory/file names contained in a FTP listing response
@@ -161,27 +170,34 @@ CSFML_NETWORK_API const char* sfFtpListingResponse_getMessage(const sfFtpListing
///
/// \return Total number of names available
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API size_t sfFtpListingResponse_getCount(const sfFtpListingResponse* ftpListingResponse);
CSFML_NETWORK_API CSFML_DEPRECATED size_t sfFtpListingResponse_getCount(const sfFtpListingResponse* ftpListingResponse);
////////////////////////////////////////////////////////////
/// \brief Return a directory/file name contained in a FTP listing response
///
/// \param ftpListingResponse Ftp listing response
/// \param index Index of the name to get (in range [0 .. getCount])
/// \param index Index of the name to get, in range [0 .. getCount() - 1]
///
/// \return The requested name
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const char* sfFtpListingResponse_getName(const sfFtpListingResponse* ftpListingResponse, size_t index);
CSFML_NETWORK_API CSFML_DEPRECATED const char* sfFtpListingResponse_getName(const sfFtpListingResponse* ftpListingResponse,
size_t index);
////////////////////////////////////////////////////////////
/// \brief Destroy a FTP directory response
///
/// \param ftpDirectoryResponse Ftp directory response to destroy
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfFtpDirectoryResponse_destroy(sfFtpDirectoryResponse* ftpDirectoryResponse);
CSFML_NETWORK_API CSFML_DEPRECATED void sfFtpDirectoryResponse_destroy(const sfFtpDirectoryResponse* ftpDirectoryResponse);
////////////////////////////////////////////////////////////
/// \brief Check if a FTP directory response status code means a success
@@ -191,10 +207,12 @@ CSFML_NETWORK_API void sfFtpDirectoryResponse_destroy(sfFtpDirectoryResponse* ft
///
/// \param ftpDirectoryResponse Ftp directory response
///
/// \return sfTrue if the status is a success, sfFalse if it is a failure
/// \return true if the status is a success, false if it is a failure
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfBool sfFtpDirectoryResponse_isOk(const sfFtpDirectoryResponse* ftpDirectoryResponse);
CSFML_NETWORK_API CSFML_DEPRECATED bool sfFtpDirectoryResponse_isOk(const sfFtpDirectoryResponse* ftpDirectoryResponse);
////////////////////////////////////////////////////////////
/// \brief Get the status code of a FTP directory response
@@ -203,8 +221,11 @@ CSFML_NETWORK_API sfBool sfFtpDirectoryResponse_isOk(const sfFtpDirectoryRespons
///
/// \return Status code
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpStatus sfFtpDirectoryResponse_getStatus(const sfFtpDirectoryResponse* ftpDirectoryResponse);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpStatus
sfFtpDirectoryResponse_getStatus(const sfFtpDirectoryResponse* ftpDirectoryResponse);
////////////////////////////////////////////////////////////
/// \brief Get the full message contained in a FTP directory response
@@ -213,18 +234,44 @@ CSFML_NETWORK_API sfFtpStatus sfFtpDirectoryResponse_getStatus(const sfFtpDirect
///
/// \return The response message
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const char* sfFtpDirectoryResponse_getMessage(const sfFtpDirectoryResponse* ftpDirectoryResponse);
CSFML_NETWORK_API CSFML_DEPRECATED const char* sfFtpDirectoryResponse_getMessage(
const sfFtpDirectoryResponse* ftpDirectoryResponse);
////////////////////////////////////////////////////////////
/// \brief Get the directory returned in a FTP directory response
///
/// The returned const char* owns the string and must be freed to
/// avoid memory leaks.
///
/// \param ftpDirectoryResponse Ftp directory response
///
/// \return Directory name
/// \return Directory name or NULL if it failed
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const char* sfFtpDirectoryResponse_getDirectory(const sfFtpDirectoryResponse* ftpDirectoryResponse);
CSFML_NETWORK_API CSFML_DEPRECATED const char* sfFtpDirectoryResponse_getDirectory(
const sfFtpDirectoryResponse* ftpDirectoryResponse);
////////////////////////////////////////////////////////////
/// \brief Get the directory returned in a FTP directory response
///
/// The returned const sfChar32* owns the string and must be freed to
/// avoid memory leaks.
///
/// \param ftpDirectoryResponse Ftp directory response
///
/// \return Directory name or NULL if it failed
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API CSFML_DEPRECATED const sfChar32* sfFtpDirectoryResponse_getDirectoryUnicode(
const sfFtpDirectoryResponse* ftpDirectoryResponse);
////////////////////////////////////////////////////////////
@@ -232,8 +279,10 @@ CSFML_NETWORK_API const char* sfFtpDirectoryResponse_getDirectory(const sfFtpDir
///
/// \param ftpResponse Ftp response to destroy
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfFtpResponse_destroy(sfFtpResponse* ftpResponse);
CSFML_NETWORK_API CSFML_DEPRECATED void sfFtpResponse_destroy(const sfFtpResponse* ftpResponse);
////////////////////////////////////////////////////////////
/// \brief Check if a FTP response status code means a success
@@ -243,10 +292,12 @@ CSFML_NETWORK_API void sfFtpResponse_destroy(sfFtpResponse* ftpResponse);
///
/// \param ftpResponse Ftp response object
///
/// \return sfTrue if the status is a success, sfFalse if it is a failure
/// \return true if the status is a success, false if it is a failure
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfBool sfFtpResponse_isOk(const sfFtpResponse* ftpResponse);
CSFML_NETWORK_API CSFML_DEPRECATED bool sfFtpResponse_isOk(const sfFtpResponse* ftpResponse);
////////////////////////////////////////////////////////////
/// \brief Get the status code of a FTP response
@@ -255,8 +306,10 @@ CSFML_NETWORK_API sfBool sfFtpResponse_isOk(const sfFtpResponse* ftpResponse);
///
/// \return Status code
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpStatus sfFtpResponse_getStatus(const sfFtpResponse* ftpResponse);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpStatus sfFtpResponse_getStatus(const sfFtpResponse* ftpResponse);
////////////////////////////////////////////////////////////
/// \brief Get the full message contained in a FTP response
@@ -265,24 +318,30 @@ CSFML_NETWORK_API sfFtpStatus sfFtpResponse_getStatus(const sfFtpResponse* ftpRe
///
/// \return The response message
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const char* sfFtpResponse_getMessage(const sfFtpResponse* ftpResponse);
CSFML_NETWORK_API CSFML_DEPRECATED const char* sfFtpResponse_getMessage(const sfFtpResponse* ftpResponse);
////////////////////////////////////////////////////////////
/// \brief Create a new Ftp object
///
/// \return A new sfFtp object
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtp* sfFtp_create(void);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtp* sfFtp_create(void);
////////////////////////////////////////////////////////////
/// \brief Destroy a Ftp object
///
/// \param ftp Ftp object to destroy
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfFtp_destroy(sfFtp* ftp);
CSFML_NETWORK_API CSFML_DEPRECATED void sfFtp_destroy(const sfFtp* ftp);
////////////////////////////////////////////////////////////
/// \brief Connect to the specified FTP server
@@ -303,8 +362,10 @@ CSFML_NETWORK_API void sfFtp_destroy(sfFtp* ftp);
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpResponse* sfFtp_connect(sfFtp* ftp, sfIpAddress server, unsigned short port, sfTime timeout);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpResponse* sfFtp_connect(sfFtp* ftp, sfIpAddress server, unsigned short port, sfTime timeout);
////////////////////////////////////////////////////////////
/// \brief Log in using an anonymous account
@@ -316,8 +377,10 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_connect(sfFtp* ftp, sfIpAddress server, u
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpResponse* sfFtp_loginAnonymous(sfFtp* ftp);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpResponse* sfFtp_loginAnonymous(sfFtp* ftp);
////////////////////////////////////////////////////////////
/// \brief Log in using a username and a password
@@ -331,8 +394,10 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_loginAnonymous(sfFtp* ftp);
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpResponse* sfFtp_login(sfFtp* ftp, const char* name, const char* password);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpResponse* sfFtp_login(sfFtp* ftp, const char* name, const char* password);
////////////////////////////////////////////////////////////
/// \brief Close the connection with the server
@@ -341,8 +406,10 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_login(sfFtp* ftp, const char* name, const
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpResponse* sfFtp_disconnect(sfFtp* ftp);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpResponse* sfFtp_disconnect(sfFtp* ftp);
////////////////////////////////////////////////////////////
/// \brief Send a null command to keep the connection alive
@@ -354,8 +421,10 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_disconnect(sfFtp* ftp);
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpResponse* sfFtp_keepAlive(sfFtp* ftp);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpResponse* sfFtp_keepAlive(sfFtp* ftp);
////////////////////////////////////////////////////////////
/// \brief Get the current working directory
@@ -367,8 +436,10 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_keepAlive(sfFtp* ftp);
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpDirectoryResponse* sfFtp_getWorkingDirectory(sfFtp* ftp);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpDirectoryResponse* sfFtp_getWorkingDirectory(sfFtp* ftp);
////////////////////////////////////////////////////////////
/// \brief Get the contents of the given directory
@@ -383,8 +454,10 @@ CSFML_NETWORK_API sfFtpDirectoryResponse* sfFtp_getWorkingDirectory(sfFtp* ftp);
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpListingResponse* sfFtp_getDirectoryListing(sfFtp* ftp, const char* directory);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpListingResponse* sfFtp_getDirectoryListing(sfFtp* ftp, const char* directory);
////////////////////////////////////////////////////////////
/// \brief Change the current working directory
@@ -396,8 +469,10 @@ CSFML_NETWORK_API sfFtpListingResponse* sfFtp_getDirectoryListing(sfFtp* ftp, co
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpResponse* sfFtp_changeDirectory(sfFtp* ftp, const char* directory);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpResponse* sfFtp_changeDirectory(sfFtp* ftp, const char* directory);
////////////////////////////////////////////////////////////
/// \brief Go to the parent directory of the current one
@@ -406,8 +481,10 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_changeDirectory(sfFtp* ftp, const char* d
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpResponse* sfFtp_parentDirectory(sfFtp* ftp);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpResponse* sfFtp_parentDirectory(sfFtp* ftp);
////////////////////////////////////////////////////////////
/// \brief Create a new directory
@@ -420,8 +497,10 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_parentDirectory(sfFtp* ftp);
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpResponse* sfFtp_createDirectory(sfFtp* ftp, const char* name);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpResponse* sfFtp_createDirectory(sfFtp* ftp, const char* name);
////////////////////////////////////////////////////////////
/// \brief Remove an existing directory
@@ -436,8 +515,10 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_createDirectory(sfFtp* ftp, const char* n
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpResponse* sfFtp_deleteDirectory(sfFtp* ftp, const char* name);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpResponse* sfFtp_deleteDirectory(sfFtp* ftp, const char* name);
////////////////////////////////////////////////////////////
/// \brief Rename an existing file
@@ -451,8 +532,10 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_deleteDirectory(sfFtp* ftp, const char* n
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpResponse* sfFtp_renameFile(sfFtp* ftp, const char* file, const char* newName);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpResponse* sfFtp_renameFile(sfFtp* ftp, const char* file, const char* newName);
////////////////////////////////////////////////////////////
/// \brief Remove an existing file
@@ -467,8 +550,10 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_renameFile(sfFtp* ftp, const char* file,
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpResponse* sfFtp_deleteFile(sfFtp* ftp, const char* name);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpResponse* sfFtp_deleteFile(sfFtp* ftp, const char* name);
////////////////////////////////////////////////////////////
/// \brief Download a file from a FTP server
@@ -485,8 +570,14 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_deleteFile(sfFtp* ftp, const char* name);
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpResponse* sfFtp_download(sfFtp* ftp, const char* remoteFile, const char* localPath, sfFtpTransferMode mode);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpResponse* sfFtp_download(
sfFtp* ftp,
const char* remoteFile,
const char* localPath,
sfFtpTransferMode mode);
////////////////////////////////////////////////////////////
/// \brief Upload a file to a FTP server
@@ -500,12 +591,19 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_download(sfFtp* ftp, const char* remoteFi
/// \param localFile Path of the local file to upload
/// \param remotePath Where to put to file on the server
/// \param mode Transfer mode
/// \param append Pass sfTrue to append to or sfFalse to overwrite the remote file if it already exists
/// \param append Pass true to append to or false to overwrite the remote file if it already exists
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpResponse* sfFtp_upload(sfFtp* ftp, const char* localFile, const char* remotePath, sfFtpTransferMode mode, sfBool append);
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpResponse* sfFtp_upload(
sfFtp* ftp,
const char* localFile,
const char* remotePath,
sfFtpTransferMode mode,
bool append);
////////////////////////////////////////////////////////////
/// \brief Send a command to the FTP server
@@ -524,8 +622,7 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_upload(sfFtp* ftp, const char* localFile,
///
/// \return Server response to the request
///
/// \deprecated Use sfSftp if possible
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfFtpResponse* sfFtp_sendCommand(sfFtp* ftp, const char* command, const char* parameter);
#endif // SFML_FTP_H
CSFML_NETWORK_API CSFML_DEPRECATED sfFtpResponse* sfFtp_sendCommand(sfFtp* ftp, const char* command, const char* parameter);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,15 +22,18 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_HTTP_H
#define SFML_HTTP_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.h>
#include <SFML/Network/Types.h>
#include <SFML/System/Time.h>
#include <CSFML/Network/Export.h>
#include <CSFML/Network/IpAddress.h>
#include <CSFML/Network/Types.h>
#include <CSFML/System/Time.h>
#include <stdbool.h>
////////////////////////////////////////////////////////////
@@ -54,18 +57,18 @@ typedef enum
typedef enum
{
// 2xx: success
sfHttpOk = 200, ///< Most common code returned when operation was successful
sfHttpCreated = 201, ///< The resource has successfully been created
sfHttpAccepted = 202, ///< The request has been accepted, but will be processed later by the server
sfHttpNoContent = 204, ///< Sent when the server didn't send any data in return
sfHttpResetContent = 205, ///< The server informs the client that it should clear the view (form) that caused the request to be sent
sfHttpOk = 200, ///< Most common code returned when operation was successful
sfHttpCreated = 201, ///< The resource has successfully been created
sfHttpAccepted = 202, ///< The request has been accepted, but will be processed later by the server
sfHttpNoContent = 204, ///< Sent when the server didn't send any data in return
sfHttpResetContent = 205, ///< The server informs the client that it should clear the view (form) that caused the request to be sent
sfHttpPartialContent = 206, ///< The server has sent a part of the resource, as a response to a partial GET request
// 3xx: redirection
sfHttpMultipleChoices = 300, ///< The requested page can be accessed from several locations
sfHttpMovedPermanently = 301, ///< The requested page has permanently moved to a new location
sfHttpMovedTemporarily = 302, ///< The requested page has temporarily moved to a new location
sfHttpNotModified = 304, ///< For conditional requests, means the requested page hasn't changed and doesn't need to be refreshed
sfHttpNotModified = 304, ///< For conditional requests, means the requested page hasn't changed and doesn't need to be refreshed
// 4xx: client error
sfHttpBadRequest = 400, ///< The server couldn't understand the request (syntax error)
@@ -102,7 +105,7 @@ CSFML_NETWORK_API sfHttpRequest* sfHttpRequest_create(void);
/// \param httpRequest HTTP request to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfHttpRequest_destroy(sfHttpRequest* httpRequest);
CSFML_NETWORK_API void sfHttpRequest_destroy(const sfHttpRequest* httpRequest);
////////////////////////////////////////////////////////////
/// \brief Set the value of a header field of a HTTP request
@@ -124,7 +127,7 @@ CSFML_NETWORK_API void sfHttpRequest_setField(sfHttpRequest* httpRequest, const
/// \brief Set a HTTP request method
///
/// See the sfHttpMethod enumeration for a complete list of all
/// the availale methods.
/// the available methods.
/// The method is sfHttpGet by default.
///
/// \param httpRequest HTTP request
@@ -177,7 +180,7 @@ CSFML_NETWORK_API void sfHttpRequest_setBody(sfHttpRequest* httpRequest, const c
/// \param httpResponse HTTP response to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfHttpResponse_destroy(sfHttpResponse* httpResponse);
CSFML_NETWORK_API void sfHttpResponse_destroy(const sfHttpResponse* httpResponse);
////////////////////////////////////////////////////////////
/// \brief Get the value of a field of a HTTP response
@@ -195,7 +198,7 @@ CSFML_NETWORK_API void sfHttpResponse_destroy(sfHttpResponse* httpResponse);
CSFML_NETWORK_API const char* sfHttpResponse_getField(const sfHttpResponse* httpResponse, const char* field);
////////////////////////////////////////////////////////////
/// \brief Get the status code of a HTTP reponse
/// \brief Get the status code of a HTTP response
///
/// The status code should be the first thing to be checked
/// after receiving a response, it defines whether it is a
@@ -259,7 +262,7 @@ CSFML_NETWORK_API sfHttp* sfHttp_create(void);
/// \param http Http object to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfHttp_destroy(sfHttp* http);
CSFML_NETWORK_API void sfHttp_destroy(const sfHttp* http);
////////////////////////////////////////////////////////////
/// \brief Set the target host of a HTTP object
@@ -272,12 +275,35 @@ CSFML_NETWORK_API void sfHttp_destroy(sfHttp* http);
/// leave it like this unless you really need a port other
/// than the standard one, or use an unknown protocol.
///
/// The host is resolved immediately. To use HTTPS, prefix
/// the host with "https://".
///
/// \param http Http object
/// \param host Web server to connect to
/// \param port Port to use for connection
///
/// \return True if the host has been resolved and is valid, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfHttp_setHost(sfHttp* http, const char* host, unsigned short port);
CSFML_NETWORK_API bool sfHttp_setHost(sfHttp* http, const char* host, unsigned short port);
////////////////////////////////////////////////////////////
/// \brief Set the target host of a HTTP object with a given address type
///
/// See sfHttp_setHost for details.
///
/// \param http Http object
/// \param host Web server to connect to
/// \param port Port to use for connection
/// \param addressType Address type to use for the connection, NULL to specify no preference
///
/// \return True if the host has been resolved and is valid, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API bool sfHttp_setHostWithAddressType(sfHttp* http,
const char* host,
unsigned short port,
const sfIpAddressType* addressType);
////////////////////////////////////////////////////////////
/// \brief Send a HTTP request and return the server's response.
@@ -288,7 +314,7 @@ CSFML_NETWORK_API void sfHttp_setHost(sfHttp* http, const char* host, unsigned s
/// Warning: this function waits for the server's response and may
/// not return instantly; use a thread if you don't want to block your
/// application, or use a timeout to limit the time to wait. A value
/// of 0 means that the client will use the system defaut timeout
/// of 0 means that the client will use the system default timeout
/// (which is usually pretty long).
///
/// \param http Http object
@@ -300,5 +326,22 @@ CSFML_NETWORK_API void sfHttp_setHost(sfHttp* http, const char* host, unsigned s
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfHttpResponse* sfHttp_sendRequest(sfHttp* http, const sfHttpRequest* request, sfTime timeout);
#endif // SFML_HTTP_H
////////////////////////////////////////////////////////////
/// \brief Send a HTTP request and return the server's response, optionally without verifying the server
///
/// See sfHttp_sendRequest for details. sfHttp_sendRequest
/// always verifies the server when using HTTPS.
///
/// \param http Http object
/// \param request Request to send
/// \param timeout Maximum time to wait
/// \param verifyServer Verify the server if using HTTPS
///
/// \return Server's response
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfHttpResponse* sfHttp_sendRequestWithVerification(
const sfHttp* http,
const sfHttpRequest* request,
sfTime timeout,
bool verifyServer);
+342
View File
@@ -0,0 +1,342 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <CSFML/Network/Export.h>
#include <CSFML/System/Time.h>
#include <stdbool.h>
#include <stdint.h>
////////////////////////////////////////////////////////////
/// \brief Encapsulate an IPv4 or IPv6 network address
///
/// The address is stored as its string representation,
/// which is large enough to hold any IPv6 address.
///
////////////////////////////////////////////////////////////
typedef struct
{
char address[46];
} sfIpAddress;
////////////////////////////////////////////////////////////
/// \brief Type of an IP address
///
////////////////////////////////////////////////////////////
typedef enum
{
sfIpAddressV4, ///< IPv4 address
sfIpAddressV6 ///< IPv6 address
} sfIpAddressType;
////////////////////////////////////////////////////////////
/// \brief Empty object that represents invalid addresses
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const sfIpAddress sfIpAddress_None;
////////////////////////////////////////////////////////////
/// \brief The same as sfIpAddress_AnyV4
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const sfIpAddress sfIpAddress_Any;
////////////////////////////////////////////////////////////
/// \brief The same as sfIpAddress_LocalHostV4
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const sfIpAddress sfIpAddress_LocalHost;
////////////////////////////////////////////////////////////
/// \brief The same as sfIpAddress_BroadcastV4
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const sfIpAddress sfIpAddress_Broadcast;
////////////////////////////////////////////////////////////
/// \brief Value representing any IPv4 address (0.0.0.0)
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const sfIpAddress sfIpAddress_AnyV4;
////////////////////////////////////////////////////////////
/// \brief Local host IPv4 address (127.0.0.1)
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const sfIpAddress sfIpAddress_LocalHostV4;
////////////////////////////////////////////////////////////
/// \brief UDP broadcast IPv4 address (255.255.255.255)
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const sfIpAddress sfIpAddress_BroadcastV4;
////////////////////////////////////////////////////////////
/// \brief Value representing any IPv6 address (::)
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const sfIpAddress sfIpAddress_AnyV6;
////////////////////////////////////////////////////////////
/// \brief Local host IPv6 address (::1)
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const sfIpAddress sfIpAddress_LocalHostV6;
////////////////////////////////////////////////////////////
/// \brief Create an address from a string representation
///
/// Here \a address can be either an IPv4 address in
/// dotted-decimal notation (ex: "192.168.1.56") or an IPv6
/// address in standard notation (ex: "2606:4700:4700::1111").
/// Network names are not resolved, use sfDns_resolve or
/// sfIpAddress_resolve for that.
///
/// \param address IP address string
///
/// \return Resulting address or sfIpAddress_None if the string is not a valid address
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfIpAddress sfIpAddress_fromString(const char* address);
////////////////////////////////////////////////////////////
/// \brief Create an IPv4 address from a string or by resolving a network name
///
/// Here \a address can be either a decimal address
/// (ex: "192.168.1.56") or a network name (ex: "localhost").
/// Only IPv4 addresses are returned.
///
/// \param address IP address or network name
///
/// \return Resulting address or sfIpAddress_None if the address could not be resolved
///
/// \deprecated Use sfDns_resolve instead
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API CSFML_DEPRECATED sfIpAddress sfIpAddress_resolve(const char* address);
////////////////////////////////////////////////////////////
/// \brief Create an address from 4 bytes
///
/// Calling sfIpAddress_fromBytes(a, b, c, d) is equivalent
/// to calling sfIpAddress_fromString("a.b.c.d"), but safer
/// as it doesn't have to parse a string to get the address
/// components.
///
/// \param byte0 First byte of the address
/// \param byte1 Second byte of the address
/// \param byte2 Third byte of the address
/// \param byte3 Fourth byte of the address
///
/// \return Resulting address
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfIpAddress sfIpAddress_fromBytes(uint8_t byte0, uint8_t byte1, uint8_t byte2, uint8_t byte3);
////////////////////////////////////////////////////////////
/// \brief Construct an address from a 32-bits integer
///
/// This function uses the internal representation of
/// the address directly. It should be used for optimization
/// purposes, and only if you got that representation from
/// sfIpAddress_toInteger.
///
/// \param address 4 bytes of the address packed into a 32-bits integer
///
/// \return Resulting address
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfIpAddress sfIpAddress_fromInteger(uint32_t address);
////////////////////////////////////////////////////////////
/// \brief Create an IPv6 address from 16 bytes
///
/// \param bytes Array of 16 bytes containing the address
///
/// \return Resulting address
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfIpAddress sfIpAddress_fromV6Bytes(const uint8_t bytes[16]);
////////////////////////////////////////////////////////////
/// \brief Get a string representation of an address
///
/// The returned string is the decimal representation of the
/// IPv4 address (like "192.168.1.56") or the standard
/// representation of the IPv6 address (like "2606:4700:4700::1111"),
/// even if it was constructed from a host name.
/// The string must be able to hold at least 46 characters.
///
/// \param address Address object
/// \param string String where the string representation will be stored
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfIpAddress_toString(sfIpAddress address, char* string);
////////////////////////////////////////////////////////////
/// \brief Get an integer representation of the address
///
/// The returned number is the internal representation of the
/// address, and should be used for optimization purposes only
/// (like sending the address through a socket).
/// The integer produced by this function can then be converted
/// back to a sfIpAddress with sfIpAddress_fromInteger.
///
/// Only IPv4 addresses can be converted to an integer, 0 is
/// returned for IPv6 addresses.
///
/// \param address Address object
///
/// \return 32-bits unsigned integer representation of the address
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API uint32_t sfIpAddress_toInteger(sfIpAddress address);
////////////////////////////////////////////////////////////
/// \brief Get a 16-byte representation of an IPv6 address
///
/// The bytes produced by this function can then be converted
/// back to a sfIpAddress with sfIpAddress_fromV6Bytes.
///
/// \param address Address object
/// \param bytes Array of 16 bytes that will be filled with the address
///
/// \return True if the address is a valid IPv6 address and the bytes have been written, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API bool sfIpAddress_toV6Bytes(sfIpAddress address, uint8_t bytes[16]);
////////////////////////////////////////////////////////////
/// \brief Get the type of an address
///
/// \param address Address object
///
/// \return The type of the address, sfIpAddressV4 is returned for invalid addresses
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfIpAddressType sfIpAddress_getType(sfIpAddress address);
////////////////////////////////////////////////////////////
/// \brief Check if an address is a valid IPv4 address
///
/// \param address Address object
///
/// \return True if the address is a valid IPv4 address
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API bool sfIpAddress_isV4(sfIpAddress address);
////////////////////////////////////////////////////////////
/// \brief Check if an address is a valid IPv6 address
///
/// \param address Address object
///
/// \return True if the address is a valid IPv6 address
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API bool sfIpAddress_isV6(sfIpAddress address);
////////////////////////////////////////////////////////////
/// \brief Get the computer's local address
///
/// The local address is the address of the computer from the
/// LAN point of view, i.e. something like 192.168.1.56. It is
/// meaningful only for communications over the local network.
/// Unlike sfIpAddress_getPublicAddress, this function is fast
/// and may be used safely anywhere.
///
/// This returns the local IPv4 address.
///
/// \return Local IP address of the computer
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfIpAddress sfIpAddress_getLocalAddress(void);
////////////////////////////////////////////////////////////
/// \brief Get the computer's local address of a given type
///
/// The local address is the address of the computer from the
/// LAN point of view, i.e. something like 192.168.1.56 or
/// fe80::1234:5678:9abc. It is meaningful only for
/// communications over the local network.
///
/// \param type The type of local address to get
///
/// \return Local IP address of the computer or sfIpAddress_None if there is none
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfIpAddress sfIpAddress_getLocalAddressOfType(sfIpAddressType type);
////////////////////////////////////////////////////////////
/// \brief Get the computer's public address
///
/// The public address is the address of the computer from the
/// internet point of view, i.e. something like 89.54.1.169.
/// It is necessary for communications over the world wide web.
/// The only way to get a public address is to ask it to a
/// distant website; as a consequence, this function depends on
/// both your network connection and the server, and may be
/// very slow. You should use it as few as possible. Because
/// this function depends on the network connection and on a distant
/// server, you may use a time limit if you don't want your program
/// to be possibly stuck waiting in case there is a problem; use
/// 0 to deactivate this limit.
///
/// This returns the public IPv4 address.
///
/// \param timeout Maximum time to wait
///
/// \return Public IP address of the computer
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfIpAddress sfIpAddress_getPublicAddress(sfTime timeout);
////////////////////////////////////////////////////////////
/// \brief Get the computer's public address of a given type
///
/// The public address is the address of the computer from the
/// internet point of view, i.e. something like 89.54.1.169 or
/// 2600:1901:0:13e0::1. See sfIpAddress_getPublicAddress for
/// details.
///
/// If tamper resistance is required, setting \a secure to true
/// will make use of verified HTTPS connections to get the address.
///
/// \param timeout Maximum time to wait, use 0 to deactivate the limit
/// \param type The type of public address to get, NULL to specify no preference
/// \param secure True to retrieve the public address via a secure HTTPS connection, false to retrieve via DNS or an insecure connection
///
/// \return Public IP address of the computer or sfIpAddress_None on failure
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfIpAddress sfIpAddress_getPublicAddressOfType(sfTime timeout, const sfIpAddressType* type, bool secure);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,14 +22,15 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_PACKET_H
#define SFML_PACKET_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.h>
#include <SFML/Network/Types.h>
#include <CSFML/Network/Export.h>
#include <CSFML/Network/Types.h>
#include <stddef.h>
@@ -57,7 +58,7 @@ CSFML_NETWORK_API sfPacket* sfPacket_copy(const sfPacket* packet);
/// \param packet Packet to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfPacket_destroy(sfPacket* packet);
CSFML_NETWORK_API void sfPacket_destroy(const sfPacket* packet);
////////////////////////////////////////////////////////////
/// \brief Append data to the end of a packet
@@ -74,6 +75,8 @@ CSFML_NETWORK_API void sfPacket_append(sfPacket* packet, const void* data, size_
///
/// The next read operation will read data from this position
///
/// \param packet Packet object
///
/// \return The byte offset of the current read position
///
/// \see append
@@ -128,15 +131,15 @@ CSFML_NETWORK_API size_t sfPacket_getDataSize(const sfPacket* packet);
///
/// \param packet Packet object
///
/// \return sfTrue if all data was read, sfFalse otherwise
/// \return true if all data was read, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfBool sfPacket_endOfPacket(const sfPacket* packet);
CSFML_NETWORK_API bool sfPacket_endOfPacket(const sfPacket* packet);
////////////////////////////////////////////////////////////
/// \brief Test the validity of a packet, for reading
///
/// This function allows to test the packet, to check if
/// This function allows for testing the packet, to check if
/// a reading operation was successful.
///
/// A packet will be in an invalid state if it has no more
@@ -144,10 +147,10 @@ CSFML_NETWORK_API sfBool sfPacket_endOfPacket(const sfPacket* packet);
///
/// \param packet Packet object
///
/// \return sfTrue if last data extraction from packet was successful
/// \return true if last data extraction from packet was successful
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfBool sfPacket_canRead(const sfPacket* packet);
CSFML_NETWORK_API bool sfPacket_canRead(const sfPacket* packet);
////////////////////////////////////////////////////////////
/// \brief Functions to extract data from a packet
@@ -155,13 +158,15 @@ CSFML_NETWORK_API sfBool sfPacket_canRead(const sfPacket* packet);
/// \param packet Packet object
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfBool sfPacket_readBool(sfPacket* packet);
CSFML_NETWORK_API sfInt8 sfPacket_readInt8(sfPacket* packet);
CSFML_NETWORK_API sfUint8 sfPacket_readUint8(sfPacket* packet);
CSFML_NETWORK_API sfInt16 sfPacket_readInt16(sfPacket* packet);
CSFML_NETWORK_API sfUint16 sfPacket_readUint16(sfPacket* packet);
CSFML_NETWORK_API sfInt32 sfPacket_readInt32(sfPacket* packet);
CSFML_NETWORK_API sfUint32 sfPacket_readUint32(sfPacket* packet);
CSFML_NETWORK_API bool sfPacket_readBool(sfPacket* packet);
CSFML_NETWORK_API int8_t sfPacket_readInt8(sfPacket* packet);
CSFML_NETWORK_API uint8_t sfPacket_readUint8(sfPacket* packet);
CSFML_NETWORK_API int16_t sfPacket_readInt16(sfPacket* packet);
CSFML_NETWORK_API uint16_t sfPacket_readUint16(sfPacket* packet);
CSFML_NETWORK_API int32_t sfPacket_readInt32(sfPacket* packet);
CSFML_NETWORK_API uint32_t sfPacket_readUint32(sfPacket* packet);
CSFML_NETWORK_API int64_t sfPacket_readInt64(sfPacket* packet);
CSFML_NETWORK_API uint64_t sfPacket_readUint64(sfPacket* packet);
CSFML_NETWORK_API float sfPacket_readFloat(sfPacket* packet);
CSFML_NETWORK_API double sfPacket_readDouble(sfPacket* packet);
CSFML_NETWORK_API void sfPacket_readString(sfPacket* packet, char* string);
@@ -173,17 +178,16 @@ CSFML_NETWORK_API void sfPacket_readWideString(sfPacket* packet, wchar_t* st
/// \param packet Packet object
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfPacket_writeBool(sfPacket* packet, sfBool);
CSFML_NETWORK_API void sfPacket_writeInt8(sfPacket* packet, sfInt8);
CSFML_NETWORK_API void sfPacket_writeUint8(sfPacket* packet, sfUint8);
CSFML_NETWORK_API void sfPacket_writeInt16(sfPacket* packet, sfInt16);
CSFML_NETWORK_API void sfPacket_writeUint16(sfPacket* packet, sfUint16);
CSFML_NETWORK_API void sfPacket_writeInt32(sfPacket* packet, sfInt32);
CSFML_NETWORK_API void sfPacket_writeUint32(sfPacket* packet, sfUint32);
CSFML_NETWORK_API void sfPacket_writeBool(sfPacket* packet, bool);
CSFML_NETWORK_API void sfPacket_writeInt8(sfPacket* packet, int8_t);
CSFML_NETWORK_API void sfPacket_writeUint8(sfPacket* packet, uint8_t);
CSFML_NETWORK_API void sfPacket_writeInt16(sfPacket* packet, int16_t);
CSFML_NETWORK_API void sfPacket_writeUint16(sfPacket* packet, uint16_t);
CSFML_NETWORK_API void sfPacket_writeInt32(sfPacket* packet, int32_t);
CSFML_NETWORK_API void sfPacket_writeUint32(sfPacket* packet, uint32_t);
CSFML_NETWORK_API void sfPacket_writeInt64(sfPacket* packet, int64_t);
CSFML_NETWORK_API void sfPacket_writeUint64(sfPacket* packet, uint64_t);
CSFML_NETWORK_API void sfPacket_writeFloat(sfPacket* packet, float);
CSFML_NETWORK_API void sfPacket_writeDouble(sfPacket* packet, double);
CSFML_NETWORK_API void sfPacket_writeString(sfPacket* packet, const char* string);
CSFML_NETWORK_API void sfPacket_writeWideString(sfPacket* packet, const wchar_t* string);
#endif // SFML_PACKET_H
+778
View File
@@ -0,0 +1,778 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <CSFML/Network/Export.h>
#include <CSFML/Network/IpAddress.h>
#include <CSFML/Network/Types.h>
#include <CSFML/System/TimeoutWithPredicate.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
////////////////////////////////////////////////////////////
/// \brief Values of a SFTP result
///
////////////////////////////////////////////////////////////
typedef enum
{
// General result values
sfSftpSuccess, ///< Operation completed successfully
sfSftpDisconnected, ///< The TCP socket has been disconnected
sfSftpTimeout, ///< Operation timed out
sfSftpRefused, ///< Connection refused
sfSftpError, ///< Generic error
// SSH result values
sfSftpBannerReceive, ///< Error during banner receive
sfSftpBannerSend, ///< Error during banner send
sfSftpInvalidMac, ///< Invalid message authentication code
sfSftpAllocationFailure, ///< Allocation failure
sfSftpSocketSend, ///< Error sending on socket
sfSftpKeyExchangeFailure, ///< Key exchange failed
sfSftpHostKeyInitialization, ///< Host key initialization failed
sfSftpHostKeySign, ///< Host key signing failed
sfSftpDecryptError, ///< Decryption failed
sfSftpProtocolError, ///< SSH protocol error
sfSftpPasswordExpired, ///< Password expired
sfSftpFileError, ///< File error
sfSftpMethodNone, ///< No method found
sfSftpAuthenticationFailed, ///< Authentication failed
sfSftpPublicKeyUnverified, ///< Public key unverified
sfSftpChannelOutOfOrder, ///< Channel out of order
sfSftpChannelFailure, ///< Channel failure
sfSftpChannelRequestDenied, ///< Channel request denied
sfSftpChannelUnknown, ///< Channel unknown
sfSftpChannelWindowExceeded, ///< Channel window exceeded
sfSftpChannelPacketExceeded, ///< Channel packet exceeded
sfSftpChannelClosed, ///< Channel closed
sfSftpChannelEofSent, ///< Channel EOF sent
sfSftpScpProtocol, ///< SCP protocol error
sfSftpZlibError, ///< Zlib error
sfSftpRequestDenied, ///< Request denied
sfSftpMethodNotSupported, ///< Method not supported
sfSftpInvalidData, ///< Invalid data
sfSftpPublicKeyProtocol, ///< Public key protocol error
sfSftpBufferTooSmall, ///< Buffer too small
sfSftpBadUse, ///< Bad usage
sfSftpCompressError, ///< Compression error
sfSftpOutOfBoundary, ///< Out of boundary
sfSftpAgentProtocol, ///< Agent protocol error
sfSftpSocketRecv, ///< Socket receive error
sfSftpEncryptError, ///< Encryption failed
sfSftpBadSocket, ///< Bad socket
sfSftpKnownHosts, ///< Known hosts error
sfSftpChannelWindowFull, ///< Channel window full
sfSftpKeyFileAuthenticationFailed, ///< Key file authentication failed
// SFTP result values
sfSftpEndOfFile, ///< End of file
sfSftpNoSuchFile, ///< No such file
sfSftpPermissionDenied, ///< Permission denied
sfSftpFailure, ///< Failure
sfSftpBadMessage, ///< Bad message
sfSftpNoConnection, ///< No connection
sfSftpConnectionLost, ///< Connection lost
sfSftpOperationUnsupported, ///< Operation unsupported
sfSftpInvalidHandle, ///< Invalid handle
sfSftpNoSuchPath, ///< No such path
sfSftpFileAlreadyExists, ///< File already exists
sfSftpWriteProtect, ///< Write protect
sfSftpNoMedia, ///< No media
sfSftpNoSpaceOnFileSystem, ///< No space on filesystem
sfSftpQuotaExceeded, ///< Quota exceeded
sfSftpUnknownPrincipal, ///< Unknown principal
sfSftpLockConflict, ///< Lock conflict
sfSftpDirectoryNotEmpty, ///< Directory not empty
sfSftpNotADirectory, ///< Not a directory
sfSftpInvalidFilename, ///< Invalid filename
sfSftpLinkLoop, ///< Link loop
sfSftpSftpError ///< Generic SFTP error
} sfSftpResultValue;
////////////////////////////////////////////////////////////
/// \brief Type of a remote file system entry
///
////////////////////////////////////////////////////////////
typedef enum
{
sfSftpFileNone, ///< No type
sfSftpFileNotFound, ///< The file does not exist
sfSftpFileRegular, ///< Regular file
sfSftpFileDirectory, ///< Directory
sfSftpFileSymlink, ///< Symbolic link
sfSftpFileBlock, ///< Block special file
sfSftpFileCharacter, ///< Character special file
sfSftpFileFifo, ///< FIFO or pipe
sfSftpFileSocket, ///< Socket
sfSftpFileUnknown ///< Unknown type
} sfSftpFileType;
////////////////////////////////////////////////////////////
/// \brief Attributes of a remote file system entry
///
/// Each attribute is only valid if the corresponding
/// has-flag is set.
///
/// Permissions use the POSIX permission bits, e.g. 0755.
/// Times are given in seconds since the Unix epoch.
///
////////////////////////////////////////////////////////////
typedef struct
{
const char* path; ///< Path to the entry, encoded in UTF-8
uint64_t size; ///< Size of the entry
uint64_t userId; ///< Owner user ID
uint64_t groupId; ///< Group ID
int64_t accessTime; ///< Last access time
int64_t modificationTime; ///< Last modification time
sfSftpFileType type; ///< Type of the entry
uint32_t permissions; ///< Permissions
bool hasType; ///< Whether the type is available
bool hasSize; ///< Whether the size is available
bool hasPermissions; ///< Whether the permissions are available
bool hasUserId; ///< Whether the owner user ID is available
bool hasGroupId; ///< Whether the group ID is available
bool hasAccessTime; ///< Whether the last access time is available
bool hasModificationTime; ///< Whether the last modification time is available
} sfSftpAttributes;
////////////////////////////////////////////////////////////
/// \brief Type of a SSH host key
///
////////////////////////////////////////////////////////////
typedef enum
{
sfSftpHostKeyUnknown, ///< Unknown key type
sfSftpHostKeyRsa, ///< RSA
sfSftpHostKeyDsa, ///< DSA
sfSftpHostKeyEcdsa256, ///< NIST P-256 ECDSA
sfSftpHostKeyEcdsa384, ///< NIST P-384 ECDSA
sfSftpHostKeyEcdsa521, ///< NIST P-521 ECDSA
sfSftpHostKeyEd25519 ///< ED25519
} sfSftpHostKeyType;
////////////////////////////////////////////////////////////
/// \brief SSH session information
///
/// The algorithm identifiers follow the RFC 4253 specification.
///
////////////////////////////////////////////////////////////
typedef struct
{
sfSftpHostKeyType hostKeyType; ///< Host key type
const uint8_t* hostKeyData; ///< Host key data
size_t hostKeySize; ///< Size of the host key data
uint8_t hostKeySha1[20]; ///< Host key SHA1 hash
uint8_t hostKeySha256[32]; ///< Host key SHA256 hash
const char* keyExchangeAlgorithm; ///< Key exchange algorithm used in the session
const char* hostKeyAlgorithm; ///< Host key algorithm used in the session
const char* clientToServerEncryptionAlgorithm; ///< Client to server encryption algorithm used in the session
const char* serverToClientEncryptionAlgorithm; ///< Server to client encryption algorithm used in the session
const char* clientToServerMacAlgorithm; ///< Client to server message authentication code algorithm used in the session
const char* serverToClientMacAlgorithm; ///< Server to client message authentication code algorithm used in the session
const char* clientToServerCompressionAlgorithm; ///< Client to server compression algorithm used in the session
const char* serverToClientCompressionAlgorithm; ///< Server to client compression algorithm used in the session
} sfSftpSessionInfo;
////////////////////////////////////////////////////////////
/// \brief Callback receiving the data of a downloaded file
///
/// The data is transferred in sequential blocks. The size of
/// the blocks can change over time.
///
/// \param data Pointer to the received data block
/// \param size Size of the received data block
/// \param userData User data passed to sfSftp_download
///
/// \return True to continue the transfer, false to abort it
///
////////////////////////////////////////////////////////////
typedef bool (*sfSftpDownloadCallback)(const void* data, size_t size, void* userData);
////////////////////////////////////////////////////////////
/// \brief Callback providing the data of a file to upload
///
/// Data to be sent should be copied into the data block and
/// \a size set to the actual number of bytes copied. When
/// called, \a size contains the size of the data block, which
/// can change over time.
///
/// \param data Pointer to the data block to fill
/// \param size Size of the data block, to be set to the number of bytes copied
/// \param userData User data passed to sfSftp_upload
///
/// \return True to continue the transfer, false to stop it e.g. because there is no more data to send
///
////////////////////////////////////////////////////////////
typedef bool (*sfSftpUploadCallback)(void* data, size_t* size, void* userData);
////////////////////////////////////////////////////////////
/// \brief Destroy a SFTP result
///
/// \param result SFTP result to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfSftpResult_destroy(const sfSftpResult* result);
////////////////////////////////////////////////////////////
/// \brief Check if a SFTP result is a success
///
/// \param result SFTP result
///
/// \return True if the result is sfSftpSuccess
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API bool sfSftpResult_isOk(const sfSftpResult* result);
////////////////////////////////////////////////////////////
/// \brief Get the value of a SFTP result
///
/// \param result SFTP result
///
/// \return Result value
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpResultValue sfSftpResult_getValue(const sfSftpResult* result);
////////////////////////////////////////////////////////////
/// \brief Get the message of a SFTP result
///
/// \param result SFTP result
///
/// \return The result message
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const char* sfSftpResult_getMessage(const sfSftpResult* result);
////////////////////////////////////////////////////////////
/// \brief Destroy a SFTP path result
///
/// \param result SFTP path result to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfSftpPathResult_destroy(const sfSftpPathResult* result);
////////////////////////////////////////////////////////////
/// \brief Check if a SFTP path result is a success
///
/// \param result SFTP path result
///
/// \return True if the result is sfSftpSuccess
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API bool sfSftpPathResult_isOk(const sfSftpPathResult* result);
////////////////////////////////////////////////////////////
/// \brief Get the value of a SFTP path result
///
/// \param result SFTP path result
///
/// \return Result value
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpResultValue sfSftpPathResult_getValue(const sfSftpPathResult* result);
////////////////////////////////////////////////////////////
/// \brief Get the message of a SFTP path result
///
/// \param result SFTP path result
///
/// \return The result message
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const char* sfSftpPathResult_getMessage(const sfSftpPathResult* result);
////////////////////////////////////////////////////////////
/// \brief Get the path of a SFTP path result
///
/// \param result SFTP path result
///
/// \return The path, encoded in UTF-8
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const char* sfSftpPathResult_getPath(const sfSftpPathResult* result);
////////////////////////////////////////////////////////////
/// \brief Destroy a SFTP attributes result
///
/// \param result SFTP attributes result to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfSftpAttributesResult_destroy(const sfSftpAttributesResult* result);
////////////////////////////////////////////////////////////
/// \brief Check if a SFTP attributes result is a success
///
/// \param result SFTP attributes result
///
/// \return True if the result is sfSftpSuccess
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API bool sfSftpAttributesResult_isOk(const sfSftpAttributesResult* result);
////////////////////////////////////////////////////////////
/// \brief Get the value of a SFTP attributes result
///
/// \param result SFTP attributes result
///
/// \return Result value
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpResultValue sfSftpAttributesResult_getValue(const sfSftpAttributesResult* result);
////////////////////////////////////////////////////////////
/// \brief Get the message of a SFTP attributes result
///
/// \param result SFTP attributes result
///
/// \return The result message
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const char* sfSftpAttributesResult_getMessage(const sfSftpAttributesResult* result);
////////////////////////////////////////////////////////////
/// \brief Get the attributes of a SFTP attributes result
///
/// The strings of the attributes stay valid until the
/// result is destroyed.
///
/// \param result SFTP attributes result
///
/// \return The attributes
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpAttributes sfSftpAttributesResult_getAttributes(const sfSftpAttributesResult* result);
////////////////////////////////////////////////////////////
/// \brief Destroy a SFTP listing result
///
/// \param result SFTP listing result to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfSftpListingResult_destroy(const sfSftpListingResult* result);
////////////////////////////////////////////////////////////
/// \brief Check if a SFTP listing result is a success
///
/// \param result SFTP listing result
///
/// \return True if the result is sfSftpSuccess
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API bool sfSftpListingResult_isOk(const sfSftpListingResult* result);
////////////////////////////////////////////////////////////
/// \brief Get the value of a SFTP listing result
///
/// \param result SFTP listing result
///
/// \return Result value
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpResultValue sfSftpListingResult_getValue(const sfSftpListingResult* result);
////////////////////////////////////////////////////////////
/// \brief Get the message of a SFTP listing result
///
/// \param result SFTP listing result
///
/// \return The result message
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const char* sfSftpListingResult_getMessage(const sfSftpListingResult* result);
////////////////////////////////////////////////////////////
/// \brief Get the number of entries in a SFTP listing result
///
/// \param result SFTP listing result
///
/// \return Number of directory entries
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API size_t sfSftpListingResult_getCount(const sfSftpListingResult* result);
////////////////////////////////////////////////////////////
/// \brief Get the attributes of an entry in a SFTP listing result
///
/// The strings of the attributes stay valid until the
/// result is destroyed.
///
/// \param result SFTP listing result
/// \param index Index of the entry to get
///
/// \return The attributes of the entry
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpAttributes sfSftpListingResult_getAttributes(const sfSftpListingResult* result, size_t index);
////////////////////////////////////////////////////////////
/// \brief Create a new SFTP object
///
/// \return A new sfSftp object
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftp* sfSftp_create(void);
////////////////////////////////////////////////////////////
/// \brief Destroy an existing SFTP object
///
/// \param sftp SFTP object to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfSftp_destroy(const sfSftp* sftp);
////////////////////////////////////////////////////////////
/// \brief Connect to the specified SFTP server
///
/// \param sftp SFTP object
/// \param server Address of the server to connect to
/// \param port Port used for the connection, the default SFTP port is 22
/// \param timeout Maximum time to wait, optionally a predicate can be provided for more fine-grained control
///
/// \return Result of the connection attempt
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpResult* sfSftp_connect(sfSftp* sftp, sfIpAddress server, unsigned short port, sfTimeoutWithPredicate timeout);
////////////////////////////////////////////////////////////
/// \brief Disconnect the connection with the server
///
/// \param sftp SFTP object
/// \param timeout Maximum time to wait, optionally a predicate can be provided for more fine-grained control
///
/// \return Result of disconnecting the connection with the server
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpResult* sfSftp_disconnect(sfSftp* sftp, sfTimeoutWithPredicate timeout);
////////////////////////////////////////////////////////////
/// \brief Get SSH session information
///
/// After connecting to the server and before actually
/// logging in the SSH session information of the underlying
/// connection will be available.
///
/// The session information contains among other things the
/// public key identifying the remote host and the connection
/// parameters such as encryption and compression used.
///
/// Relying on the user to check the authenticity of the host
/// key is the typical method used to verify the connection
/// to the legitimate host. If connection security is a high
/// priority, examining the parameters and aborting the
/// connection if any weak algorithms are used is also possible.
///
/// The pointers in the session information stay valid until
/// the next call to this function or until the SFTP object
/// is destroyed.
///
/// \param sftp SFTP object
/// \param info Session information to fill
///
/// \return True if the session information is available, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API bool sfSftp_getSessionInfo(const sfSftp* sftp, sfSftpSessionInfo* info);
////////////////////////////////////////////////////////////
/// \brief Log in using a username and a password
///
/// Logging in is mandatory after connecting to the server.
/// Users that are not logged in cannot perform any operation.
///
/// \param sftp SFTP object
/// \param name User name
/// \param password Password
/// \param timeout Maximum time to wait, optionally a predicate can be provided for more fine-grained control
///
/// \return Result of attempting to log in to the server
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpResult* sfSftp_login(sfSftp* sftp, const char* name, const char* password, sfTimeoutWithPredicate timeout);
////////////////////////////////////////////////////////////
/// \brief Log in using a public/private key pair
///
/// Logging in is mandatory after connecting to the server.
/// Users that are not logged in cannot perform any operation.
///
/// The public and private key data should be provided in PEM
/// format. Even though it is technically possible to derive
/// the public key from the private key, due to backend
/// limitations, providing a pre-generated public key as well
/// is necessary for this function to be able to succeed.
///
/// If the private key is not protected by a passphrase the
/// passphrase should be set to the empty string or NULL.
///
/// \param sftp SFTP object
/// \param name User name
/// \param publicKeyData Public key data
/// \param publicKeyLength Public key data length
/// \param privateKeyData Private key data
/// \param privateKeyLength Private key data length
/// \param privateKeyPassphrase Private key passphrase, NULL terminated
/// \param timeout Maximum time to wait, optionally a predicate can be provided for more fine-grained control
///
/// \return Result of attempting to log in to the server
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpResult* sfSftp_loginWithKey(
sfSftp* sftp,
const char* name,
const char* publicKeyData,
size_t publicKeyLength,
const char* privateKeyData,
size_t privateKeyLength,
const char* privateKeyPassphrase,
sfTimeoutWithPredicate timeout);
////////////////////////////////////////////////////////////
/// \brief Resolve a remote path into an absolute remote path
///
/// Paths can contain links and other reserved path identifiers
/// such as . and .. referring to the current directory and
/// parent directory respectively. This function determines
/// the absolute path, which does not contain links or . or ..
///
/// Resolving "." will return the absolute path to the current
/// working directory of the user after logging in to the SFTP
/// server.
///
/// \param sftp SFTP object
/// \param path Path to convert into an absolute path, encoded in UTF-8
/// \param timeout Maximum time to wait, optionally a predicate can be provided for more fine-grained control
///
/// \return Result of converting the path into an absolute path
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpPathResult* sfSftp_resolvePath(sfSftp* sftp, const char* path, sfTimeoutWithPredicate timeout);
////////////////////////////////////////////////////////////
/// \brief Get the current working directory on the server
///
/// This is an alias for calling sfSftp_resolvePath with ".".
///
/// \param sftp SFTP object
/// \param timeout Maximum time to wait, optionally a predicate can be provided for more fine-grained control
///
/// \return Result of getting the current working directory
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpPathResult* sfSftp_getWorkingDirectory(sfSftp* sftp, sfTimeoutWithPredicate timeout);
////////////////////////////////////////////////////////////
/// \brief Get the attributes of a remote file or directory
///
/// Depending on whether \a path refers to a file or directory,
/// the attributes can contain e.g. the type of file, the file
/// owner, group, file size, modification and access times.
///
/// If links are not to be followed, \a followLinks can be set
/// to false. In this case the attributes of the link itself
/// will be returned.
///
/// \param sftp SFTP object
/// \param path Path to the remote file or directory whose attributes to get, encoded in UTF-8
/// \param followLinks True to follow links, false to return attributes of the link itself
/// \param timeout Maximum time to wait, optionally a predicate can be provided for more fine-grained control
///
/// \return Result of getting the attributes
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpAttributesResult* sfSftp_getAttributes(
sfSftp* sftp,
const char* path,
bool followLinks,
sfTimeoutWithPredicate timeout);
////////////////////////////////////////////////////////////
/// \brief Get the contents of the given directory
///
/// This function retrieves the sub-directories and files
/// contained in the given directory. It is not recursive.
///
/// \param sftp SFTP object
/// \param path Path of the directory whose contents to list, encoded in UTF-8
/// \param timeout Maximum time to wait, optionally a predicate can be provided for more fine-grained control
///
/// \return Result of getting the contents of the given directory
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpListingResult* sfSftp_getDirectoryListing(sfSftp* sftp, const char* path, sfTimeoutWithPredicate timeout);
////////////////////////////////////////////////////////////
/// \brief Create a new directory
///
/// The new directory is created as a child of the current
/// working directory.
///
/// A common permissions value is 0755 (rwxr-xr-x).
///
/// \param sftp SFTP object
/// \param path Path of the directory to create, encoded in UTF-8
/// \param permissions POSIX permissions of the directory to create
/// \param timeout Maximum time to wait, optionally a predicate can be provided for more fine-grained control
///
/// \return Result of creating the directory
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpResult* sfSftp_createDirectory(sfSftp* sftp,
const char* path,
uint32_t permissions,
sfTimeoutWithPredicate timeout);
////////////////////////////////////////////////////////////
/// \brief Remove an existing directory
///
/// Use this function with caution, the directory will
/// be removed permanently!
///
/// \param sftp SFTP object
/// \param path Path of the directory to remove, encoded in UTF-8
/// \param timeout Maximum time to wait, optionally a predicate can be provided for more fine-grained control
///
/// \return Result of removing the directory
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpResult* sfSftp_deleteDirectory(sfSftp* sftp, const char* path, sfTimeoutWithPredicate timeout);
////////////////////////////////////////////////////////////
/// \brief Rename an existing file or directory
///
/// In POSIX renaming and moving are synonymous. If you want
/// to move a file or directory from one place to another
/// you rename it from an old to a new path.
///
/// If a file exists at the specified new path, depending
/// on whether \a overwrite is set to true, the rename operation
/// will overwrite it or not. Non-empty directories cannot be
/// overwritten by this operation.
///
/// \param sftp SFTP object
/// \param oldPath Old path to the file or directory, encoded in UTF-8
/// \param newPath New path to the file or directory, encoded in UTF-8
/// \param overwrite True to allow overwriting a file that exists at \a newPath
/// \param timeout Maximum time to wait, optionally a predicate can be provided for more fine-grained control
///
/// \return Result of the operation
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpResult* sfSftp_rename(
sfSftp* sftp,
const char* oldPath,
const char* newPath,
bool overwrite,
sfTimeoutWithPredicate timeout);
////////////////////////////////////////////////////////////
/// \brief Remove an existing file
///
/// Use this function with caution, the file will be
/// removed permanently!
///
/// \param sftp SFTP object
/// \param path Path to the file to remove, encoded in UTF-8
/// \param timeout Maximum time to wait, optionally a predicate can be provided for more fine-grained control
///
/// \return Result of removing the file
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpResult* sfSftp_deleteFile(sfSftp* sftp, const char* path, sfTimeoutWithPredicate timeout);
////////////////////////////////////////////////////////////
/// \brief Download a file from the server
///
/// The file data is transferred in sequential blocks. For
/// every block of data transferred, the provided callback
/// is called.
///
/// The function returns once all the data in the remote file
/// has been transferred or an error occurs or the function
/// times out.
///
/// \param sftp SFTP object
/// \param remotePath Path of the remote file whose data to download, encoded in UTF-8
/// \param callback Callback to be called for every available data block
/// \param userData User data that will be passed to the callback
/// \param offset Byte offset into the remote file at which reading should start
/// \param timeout Maximum time to wait, optionally a predicate can be provided for more fine-grained control
///
/// \return Result of downloading the file
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpResult* sfSftp_download(
sfSftp* sftp,
const char* remotePath,
sfSftpDownloadCallback callback,
void* userData,
uint64_t offset,
sfTimeoutWithPredicate timeout);
////////////////////////////////////////////////////////////
/// \brief Upload a file to the server
///
/// The file data is transferred in sequential blocks. Every
/// time the function wants to send a new block of data the
/// provided callback is called.
///
/// The function returns once all the data has been sent or
/// an error occurs or the function times out.
///
/// If a file does not exist at the remote path yet, it will
/// be created with the provided permissions. A common
/// permissions value is 0644 (rw-r--r--).
///
/// \param sftp SFTP object
/// \param remotePath Path of the remote file in which to upload the data, encoded in UTF-8
/// \param callback Callback to be called for every data block to send
/// \param userData User data that will be passed to the callback
/// \param permissions POSIX permissions of the remote file if it has to be created
/// \param truncate True to truncate the remote file if it already exists
/// \param append True to append to the remote file if it already exists
/// \param offset Byte offset into the remote file at which writing should start
/// \param timeout Maximum time to wait, optionally a predicate can be provided for more fine-grained control
///
/// \return Result of uploading the file
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSftpResult* sfSftp_upload(
sfSftp* sftp,
const char* remotePath,
sfSftpUploadCallback callback,
void* userData,
uint32_t permissions,
bool truncate,
bool append,
uint64_t offset,
sfTimeoutWithPredicate timeout);
+256
View File
@@ -0,0 +1,256 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <CSFML/Network/Export.h>
#include <CSFML/Network/Types.h>
#include <CSFML/System/Time.h>
#include <stdbool.h>
#include <stdint.h>
////////////////////////////////////////////////////////////
/// \brief Readiness types a socket selector can check for
///
/// The values can be combined with a bitwise OR.
///
////////////////////////////////////////////////////////////
typedef enum
{
sfSocketSelectorReceive = 1 << 0, ///< Check if sockets are ready to be received from
sfSocketSelectorSend = 1 << 1 ///< Check if sockets are ready to be sent to
} sfSocketSelectorReadiness;
////////////////////////////////////////////////////////////
/// \brief Callback that is called when a socket is ready
///
/// \param readiness Readiness of the socket, a combination of sfSocketSelectorReadiness values
/// \param userData User data passed when adding the socket
///
////////////////////////////////////////////////////////////
typedef void (*sfSocketSelectorCallback)(uint32_t readiness, void* userData);
////////////////////////////////////////////////////////////
/// \brief Create a new selector
///
/// \return A new sfSocketSelector object
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSocketSelector* sfSocketSelector_create(void);
////////////////////////////////////////////////////////////
/// \brief Create a new socket selector by copying an existing one
///
/// \param selector Socket selector to copy
///
/// \return A new sfSocketSelector object which is a copy of \a selector
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSocketSelector* sfSocketSelector_copy(const sfSocketSelector* selector);
////////////////////////////////////////////////////////////
/// \brief Destroy a socket selector
///
/// \param selector Socket selector to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfSocketSelector_destroy(const sfSocketSelector* selector);
////////////////////////////////////////////////////////////
/// \brief Add a new socket to a socket selector
///
/// This function keeps a weak pointer to the socket,
/// so you have to make sure that the socket is not destroyed
/// while it is stored in the selector.
///
/// The socket is checked for being ready to receive.
///
/// \param selector Socket selector object
/// \param socket Pointer to the socket to add
///
/// \return True if the socket was successfully added
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API bool sfSocketSelector_addTcpListener(sfSocketSelector* selector, sfTcpListener* socket);
CSFML_NETWORK_API bool sfSocketSelector_addTcpSocket(sfSocketSelector* selector, sfTcpSocket* socket);
CSFML_NETWORK_API bool sfSocketSelector_addUdpSocket(sfSocketSelector* selector, sfUdpSocket* socket);
////////////////////////////////////////////////////////////
/// \brief Add a new socket to a socket selector with the readiness to check for and an optional callback
///
/// This function keeps a weak pointer to the socket,
/// so you have to make sure that the socket is not destroyed
/// while it is stored in the selector.
///
/// The readiness to wait for can be specified as a combination
/// of sfSocketSelectorReceive and sfSocketSelectorSend.
///
/// If a callback is provided, it will be called with the
/// readiness of the socket when sfSocketSelector_dispatchReadyCallbacks
/// is called after sfSocketSelector_wait returned true. Using
/// callbacks scales better than checking every socket with
/// sfSocketSelector_isXxxReadyFor.
///
/// Adding a socket that has already been added updates its
/// readiness and callback.
///
/// \param selector Socket selector object
/// \param socket Pointer to the socket to add
/// \param readiness Readiness to wait for, combination of sfSocketSelectorReadiness values
/// \param callback Callback to call when the socket is ready, can be NULL
/// \param userData User data that will be passed to the callback
///
/// \return True if the socket was successfully added
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API bool sfSocketSelector_addTcpListenerWithReadiness(
sfSocketSelector* selector,
sfTcpListener* socket,
uint32_t readiness,
sfSocketSelectorCallback callback,
void* userData);
CSFML_NETWORK_API bool sfSocketSelector_addTcpSocketWithReadiness(
sfSocketSelector* selector,
sfTcpSocket* socket,
uint32_t readiness,
sfSocketSelectorCallback callback,
void* userData);
CSFML_NETWORK_API bool sfSocketSelector_addUdpSocketWithReadiness(
sfSocketSelector* selector,
sfUdpSocket* socket,
uint32_t readiness,
sfSocketSelectorCallback callback,
void* userData);
////////////////////////////////////////////////////////////
/// \brief Remove a socket from a socket selector
///
/// This function doesn't destroy the socket, it simply
/// removes the pointer that the selector has to it.
///
/// \param selector Socket selector object
/// \param socket Pointer to the socket to remove
///
/// \return True if the socket was successfully removed
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API bool sfSocketSelector_removeTcpListener(sfSocketSelector* selector, sfTcpListener* socket);
CSFML_NETWORK_API bool sfSocketSelector_removeTcpSocket(sfSocketSelector* selector, sfTcpSocket* socket);
CSFML_NETWORK_API bool sfSocketSelector_removeUdpSocket(sfSocketSelector* selector, sfUdpSocket* socket);
////////////////////////////////////////////////////////////
/// \brief Remove all the sockets stored in a selector
///
/// This function doesn't destroy any instance, it simply
/// removes all the pointers that the selector has to
/// external sockets.
///
/// \param selector Socket selector object
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfSocketSelector_clear(sfSocketSelector* selector);
////////////////////////////////////////////////////////////
/// \brief Wait until one or more sockets are ready
///
/// This function returns as soon as at least one socket is
/// ready for the readiness it was added with (by default
/// having some data available to be received). To know which
/// sockets are ready, use the sfSocketSelector_isXxxReady
/// functions or sfSocketSelector_dispatchReadyCallbacks.
/// If you use a timeout and no socket is ready before the timeout
/// is over, the function returns false.
///
/// \param selector Socket selector object
/// \param timeout Maximum time to wait (use sfTimeZero for infinity)
///
/// \return true if there are sockets ready, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API bool sfSocketSelector_wait(sfSocketSelector* selector, sfTime timeout);
////////////////////////////////////////////////////////////
/// \brief Test a socket to know if it is ready to receive data
///
/// This function must be used after a call to
/// sfSocketSelector_wait, to know which sockets are ready to
/// receive data. If a socket is ready, a call to Receive will
/// never block because we know that there is data available to read.
/// Note that if this function returns true for a sfTcpListener,
/// this means that it is ready to accept a new connection.
///
/// \param selector Socket selector object
/// \param socket Socket to test
///
/// \return true if the socket is ready to read, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API bool sfSocketSelector_isTcpListenerReady(const sfSocketSelector* selector, sfTcpListener* socket);
CSFML_NETWORK_API bool sfSocketSelector_isTcpSocketReady(const sfSocketSelector* selector, sfTcpSocket* socket);
CSFML_NETWORK_API bool sfSocketSelector_isUdpSocketReady(const sfSocketSelector* selector, sfUdpSocket* socket);
////////////////////////////////////////////////////////////
/// \brief Test a socket to know if it is ready for the given readiness
///
/// This function must be used after a call to
/// sfSocketSelector_wait, to know which sockets are ready.
///
/// \param selector Socket selector object
/// \param socket Socket to test
/// \param readiness Readiness to check for, combination of sfSocketSelectorReadiness values
///
/// \return true if the socket is ready, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API bool sfSocketSelector_isTcpListenerReadyFor(const sfSocketSelector* selector,
sfTcpListener* socket,
uint32_t readiness);
CSFML_NETWORK_API bool sfSocketSelector_isTcpSocketReadyFor(const sfSocketSelector* selector,
sfTcpSocket* socket,
uint32_t readiness);
CSFML_NETWORK_API bool sfSocketSelector_isUdpSocketReadyFor(const sfSocketSelector* selector,
sfUdpSocket* socket,
uint32_t readiness);
////////////////////////////////////////////////////////////
/// \brief Call the callbacks of all sockets that are ready
///
/// After sfSocketSelector_wait returned true, at least one
/// socket is ready. Calling this function will call the
/// callbacks of all the sockets that became ready during
/// the wait. Calling this function multiple times after a
/// single call to sfSocketSelector_wait will run the callbacks
/// multiple times.
///
/// \param selector Socket selector object
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfSocketSelector_dispatchReadyCallbacks(sfSocketSelector* selector);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,9 +22,7 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOCKETSTATUS_H
#define SFML_SOCKETSTATUS_H
#pragma once
////////////////////////////////////////////////////////////
/// \brief Define the status that can be returned by the socket functions
@@ -37,8 +35,4 @@ typedef enum
sfSocketPartial, ///< The socket sent a part of the data
sfSocketDisconnected, ///< The TCP socket has been disconnected
sfSocketError ///< An unexpected error happened
} sfSocketStatus;
#endif // SFML_SOCKETSTATUS_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,16 +22,16 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_TCPLISTENER_H
#define SFML_TCPLISTENER_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.h>
#include <SFML/Network/SocketStatus.h>
#include <SFML/Network/IpAddress.h>
#include <SFML/Network/Types.h>
#include <CSFML/Network/Export.h>
#include <CSFML/Network/IpAddress.h>
#include <CSFML/Network/SocketStatus.h>
#include <CSFML/Network/Types.h>
////////////////////////////////////////////////////////////
@@ -48,7 +48,7 @@ CSFML_NETWORK_API sfTcpListener* sfTcpListener_create(void);
/// \param listener TCP listener to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfTcpListener_destroy(sfTcpListener* listener);
CSFML_NETWORK_API void sfTcpListener_destroy(const sfTcpListener* listener);
////////////////////////////////////////////////////////////
/// \brief Set the blocking state of a TCP listener
@@ -63,20 +63,20 @@ CSFML_NETWORK_API void sfTcpListener_destroy(sfTcpListener* listener);
/// By default, all sockets are blocking.
///
/// \param listener TCP listener object
/// \param blocking sfTrue to set the socket as blocking, sfFalse for non-blocking
/// \param blocking true to set the socket as blocking, false for non-blocking
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfTcpListener_setBlocking(sfTcpListener* listener, sfBool blocking);
CSFML_NETWORK_API void sfTcpListener_setBlocking(sfTcpListener* listener, bool blocking);
////////////////////////////////////////////////////////////
/// \brief Tell whether a TCP listener is in blocking or non-blocking mode
///
/// \param listener TCP listener object
///
/// \return sfTrue if the socket is blocking, sfFalse otherwise
/// \return true if the socket is blocking, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfBool sfTcpListener_isBlocking(const sfTcpListener* listener);
CSFML_NETWORK_API bool sfTcpListener_isBlocking(const sfTcpListener* listener);
////////////////////////////////////////////////////////////
/// \brief Get the port to which a TCP listener is bound locally
@@ -99,6 +99,10 @@ CSFML_NETWORK_API unsigned short sfTcpListener_getLocalPort(const sfTcpListener*
/// If the socket was previously listening to another port,
/// it will be stopped first and bound to the new port.
///
/// When providing `sfTcpListener_anyPort()` as port, the listener
/// will request an available port from the system.
/// The chosen port can be retrieved by calling `sfTcpListener_getLocalPort()`.
///
/// If there is no specific address to listen to, pass sfIpAddress_Any
///
/// \param listener TCP listener object
@@ -110,6 +114,17 @@ CSFML_NETWORK_API unsigned short sfTcpListener_getLocalPort(const sfTcpListener*
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSocketStatus sfTcpListener_listen(sfTcpListener* listener, unsigned short port, sfIpAddress address);
////////////////////////////////////////////////////////////
/// \brief Stop listening and close the socket
///
/// This function gracefully stops the listener. If the
/// socket is not listening, this function has no effect.
///
/// \param listener TCP listener object
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfTcpListener_close(sfTcpListener* listener);
////////////////////////////////////////////////////////////
/// \brief Accept a new connection
///
@@ -128,5 +143,11 @@ CSFML_NETWORK_API sfSocketStatus sfTcpListener_listen(sfTcpListener* listener, u
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSocketStatus sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket** connected);
#endif // SFML_TCPLISTENER_H
////////////////////////////////////////////////////////////
/// \brief Return the special value that tells the system
/// to pick any available port
///
/// \return The value to use for any port
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API unsigned short sfTcpListener_anyPort(void);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,20 +22,35 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_TCPSOCKET_H
#define SFML_TCPSOCKET_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.h>
#include <SFML/Network/IpAddress.h>
#include <SFML/Network/SocketStatus.h>
#include <SFML/Network/Types.h>
#include <SFML/System/Time.h>
#include <CSFML/Network/Export.h>
#include <CSFML/Network/IpAddress.h>
#include <CSFML/Network/SocketStatus.h>
#include <CSFML/Network/Types.h>
#include <CSFML/System/Time.h>
#include <stdbool.h>
#include <stddef.h>
////////////////////////////////////////////////////////////
/// \brief Transport layer security status codes
///
////////////////////////////////////////////////////////////
typedef enum
{
sfTlsNotConnected, ///< TCP connection not yet connected
sfTlsHandshakeStarted, ///< TLS handshake has been started
sfTlsHandshakeComplete, ///< TLS handshake is complete, stream is encrypted
sfTlsError ///< An unexpected error happened
} sfTlsStatus;
////////////////////////////////////////////////////////////
/// \brief Create a new TCP socket
///
@@ -50,7 +65,7 @@ CSFML_NETWORK_API sfTcpSocket* sfTcpSocket_create(void);
/// \param socket TCP socket to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfTcpSocket_destroy(sfTcpSocket* socket);
CSFML_NETWORK_API void sfTcpSocket_destroy(const sfTcpSocket* socket);
////////////////////////////////////////////////////////////
/// \brief Set the blocking state of a TCP listener
@@ -65,20 +80,20 @@ CSFML_NETWORK_API void sfTcpSocket_destroy(sfTcpSocket* socket);
/// By default, all sockets are blocking.
///
/// \param socket TCP socket object
/// \param blocking sfTrue to set the socket as blocking, sfFalse for non-blocking
/// \param blocking true to set the socket as blocking, false for non-blocking
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfTcpSocket_setBlocking(sfTcpSocket* socket, sfBool blocking);
CSFML_NETWORK_API void sfTcpSocket_setBlocking(sfTcpSocket* socket, bool blocking);
////////////////////////////////////////////////////////////
/// \brief Tell whether a TCP socket is in blocking or non-blocking mode
///
/// \param socket TCP socket object
///
/// \return sfTrue if the socket is blocking, sfFalse otherwise
/// \return true if the socket is blocking, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfBool sfTcpSocket_isBlocking(const sfTcpSocket* socket);
CSFML_NETWORK_API bool sfTcpSocket_isBlocking(const sfTcpSocket* socket);
////////////////////////////////////////////////////////////
/// \brief Get the port to which a TCP socket is bound locally
@@ -95,7 +110,7 @@ CSFML_NETWORK_API unsigned short sfTcpSocket_getLocalPort(const sfTcpSocket* soc
////////////////////////////////////////////////////////////
/// \brief Get the address of the connected peer of a TCP socket
///
/// It the socket is not connected, this function returns
/// If the socket is not connected, this function returns
/// sfIpAddress_None.
///
/// \param socket TCP socket object
@@ -134,7 +149,8 @@ CSFML_NETWORK_API unsigned short sfTcpSocket_getRemotePort(const sfTcpSocket* so
/// \return Status code
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSocketStatus sfTcpSocket_connect(sfTcpSocket* socket, sfIpAddress remoteAddress, unsigned short remotePort, sfTime timeout);
CSFML_NETWORK_API sfSocketStatus
sfTcpSocket_connect(sfTcpSocket* socket, sfIpAddress remoteAddress, unsigned short remotePort, sfTime timeout);
////////////////////////////////////////////////////////////
/// \brief Disconnect a TCP socket from its remote peer
@@ -151,7 +167,7 @@ CSFML_NETWORK_API void sfTcpSocket_disconnect(sfTcpSocket* socket);
/// \brief Send raw data to the remote peer of a TCP socket
///
/// To be able to handle partial sends over non-blocking
/// sockets, use the sfTcpSocket_sendPartial(sfTcpSocket*, const void*, std::size_t, size_t*)
/// sockets, use the sfTcpSocket_sendPartial(sfTcpSocket*, const void*, size_t, size_t*)
/// overload instead.
/// This function will fail if the socket is not connected.
///
@@ -228,5 +244,120 @@ CSFML_NETWORK_API sfSocketStatus sfTcpSocket_sendPacket(sfTcpSocket* socket, sfP
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSocketStatus sfTcpSocket_receivePacket(sfTcpSocket* socket, sfPacket* packet);
////////////////////////////////////////////////////////////
/// \brief Set up transport layer security as a client
///
/// Once the TCP connection is connected, transport layer
/// security can be set up.
///
/// If this function is called before the TCP connection is
/// connected, it will return sfTlsNotConnected and must be
/// called again once the TCP connection is connected.
///
/// If this function started TLS setup but could not finish
/// it within this call e.g. because this socket was set to
/// non-blocking, it will return sfTlsHandshakeStarted and
/// this function will have to be called repeatedly until
/// sfTlsHandshakeComplete is returned. If this socket is
/// blocking, sfTlsHandshakeComplete should be returned
/// within the same function call if TLS setup was successful.
///
/// If sfTlsError is returned, something went wrong with TLS
/// setup and the connection must be reconnected and TLS setup
/// reattempted after it is connected again.
///
/// If verification is enabled, this function verifies the peer
/// using the system provided certificate store. If the peer
/// does not have a certificate that was signed by a certificate
/// authority i.e. a self-signed certificate, the entire certificate
/// chain can be provided using sfTcpSocket_setupTlsClientWithCertificate.
///
/// The hostname is sent to the server via server name indication
/// (SNI) and used to verify the certificate chain returned by the
/// server.
///
/// \param socket TCP socket object
/// \param hostname Hostname of the remote peer, encoded in UTF-8, used for verification
/// \param verifyPeer True to enable peer verification, false to disable it
///
/// \return TLS status code
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfTlsStatus sfTcpSocket_setupTlsClient(sfTcpSocket* socket, const char* hostname, bool verifyPeer);
#endif // SFML_TCPSOCKET_H
////////////////////////////////////////////////////////////
/// \brief Set up transport layer security as a client with a given certificate chain
///
/// When calling this function, the certificate chain to verify
/// the host with has to be provided. Verification is always
/// enabled when calling this function.
///
/// The certificate data can be provided in PEM or DER format.
///
/// See sfTcpSocket_setupTlsClient for details on the returned
/// status codes.
///
/// \param socket TCP socket object
/// \param hostname Hostname of the remote peer, encoded in UTF-8, used for verification
/// \param certificateChainData Certificate chain data in PEM or DER encoding
/// \param certificateChainSize Size of the certificate chain data
///
/// \return TLS status code
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfTlsStatus sfTcpSocket_setupTlsClientWithCertificate(
sfTcpSocket* socket,
const char* hostname,
const void* certificateChainData,
size_t certificateChainSize);
////////////////////////////////////////////////////////////
/// \brief Set up transport layer security as a server
///
/// Once the TCP connection is connected, transport layer
/// security can be set up.
///
/// As a server, a certificate chain as well as a private key
/// must be provided. The certificate and private key data can
/// be provided in PEM or DER format. If the private key is
/// secured by a password, the password must be provided.
///
/// If sfTlsError is returned, something went wrong with TLS
/// setup and the connection must be disconnected. The client
/// must reconnect and reattempt TLS setup again.
///
/// See sfTcpSocket_setupTlsClient for details on the other
/// returned status codes.
///
/// \param socket TCP socket object
/// \param certificateChainData Certificate chain data in PEM or DER encoding
/// \param certificateChainSize Size of the certificate chain data
/// \param privateKeyData Private key data in PEM or DER encoding
/// \param privateKeySize Size of the private key data
/// \param privateKeyPasswordData Private key password data, can be NULL if there is no password
/// \param privateKeyPasswordSize Size of the private key password data
///
/// \return TLS status code
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfTlsStatus sfTcpSocket_setupTlsServer(
sfTcpSocket* socket,
const void* certificateChainData,
size_t certificateChainSize,
const void* privateKeyData,
size_t privateKeySize,
const void* privateKeyPasswordData,
size_t privateKeyPasswordSize);
////////////////////////////////////////////////////////////
/// \brief Get the name of the TLS ciphersuite currently in use
///
/// The returned string stays valid until the next call to
/// this function or until the socket is destroyed.
///
/// \param socket TCP socket object
///
/// \return TLS ciphersuite currently in use or NULL if TLS is not set up
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const char* sfTcpSocket_getCurrentCiphersuiteName(const sfTcpSocket* socket);
+48
View File
@@ -0,0 +1,48 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
typedef struct sfDnsMxRecords sfDnsMxRecords;
typedef struct sfDnsNsRecords sfDnsNsRecords;
typedef struct sfDnsSrvRecords sfDnsSrvRecords;
typedef struct sfDnsTxtRecords sfDnsTxtRecords;
typedef struct sfFtpDirectoryResponse sfFtpDirectoryResponse;
typedef struct sfFtpListingResponse sfFtpListingResponse;
typedef struct sfFtpResponse sfFtpResponse;
typedef struct sfFtp sfFtp;
typedef struct sfHttpRequest sfHttpRequest;
typedef struct sfHttpResponse sfHttpResponse;
typedef struct sfHttp sfHttp;
typedef struct sfPacket sfPacket;
typedef struct sfSftpAttributesResult sfSftpAttributesResult;
typedef struct sfSftpListingResult sfSftpListingResult;
typedef struct sfSftpPathResult sfSftpPathResult;
typedef struct sfSftpResult sfSftpResult;
typedef struct sfSftp sfSftp;
typedef struct sfSocketSelector sfSocketSelector;
typedef struct sfTcpListener sfTcpListener;
typedef struct sfTcpSocket sfTcpSocket;
typedef struct sfUdpSocket sfUdpSocket;
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,16 +22,17 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_UDPSOCKET_H
#define SFML_UDPSOCKET_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.h>
#include <SFML/Network/IpAddress.h>
#include <SFML/Network/SocketStatus.h>
#include <SFML/Network/Types.h>
#include <CSFML/Network/Export.h>
#include <CSFML/Network/IpAddress.h>
#include <CSFML/Network/SocketStatus.h>
#include <CSFML/Network/Types.h>
#include <stddef.h>
@@ -49,7 +50,7 @@ CSFML_NETWORK_API sfUdpSocket* sfUdpSocket_create(void);
/// \param socket UDP socket to destroy
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfUdpSocket_destroy(sfUdpSocket* socket);
CSFML_NETWORK_API void sfUdpSocket_destroy(const sfUdpSocket* socket);
////////////////////////////////////////////////////////////
/// \brief Set the blocking state of a UDP listener
@@ -64,20 +65,20 @@ CSFML_NETWORK_API void sfUdpSocket_destroy(sfUdpSocket* socket);
/// By default, all sockets are blocking.
///
/// \param socket UDP socket object
/// \param blocking sfTrue to set the socket as blocking, sfFalse for non-blocking
/// \param blocking true to set the socket as blocking, false for non-blocking
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API void sfUdpSocket_setBlocking(sfUdpSocket* socket, sfBool blocking);
CSFML_NETWORK_API void sfUdpSocket_setBlocking(sfUdpSocket* socket, bool blocking);
////////////////////////////////////////////////////////////
/// \brief Tell whether a UDP socket is in blocking or non-blocking mode
///
/// \param socket UDP socket object
///
/// \return sfTrue if the socket is blocking, sfFalse otherwise
/// \return true if the socket is blocking, false otherwise
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfBool sfUdpSocket_isBlocking(const sfUdpSocket* socket);
CSFML_NETWORK_API bool sfUdpSocket_isBlocking(const sfUdpSocket* socket);
////////////////////////////////////////////////////////////
/// \brief Get the port to which a UDP socket is bound locally
@@ -101,6 +102,10 @@ CSFML_NETWORK_API unsigned short sfUdpSocket_getLocalPort(const sfUdpSocket* soc
/// system to automatically pick an available port, and then
/// call sfUdpSocket_getLocalPort to retrieve the chosen port.
///
/// When providing `sfUdpSocket_anyPort()` as port, the listener
/// will request an available port from the system.
/// The chosen port can be retrieved by calling `sfUdpSocket_getLocalPort()`.
///
/// If there is no specific address to listen to, pass sfIpAddress_Any
///
/// \param socket UDP socket object
@@ -140,7 +145,8 @@ CSFML_NETWORK_API void sfUdpSocket_unbind(sfUdpSocket* socket);
/// \return Status code
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSocketStatus sfUdpSocket_send(sfUdpSocket* socket, const void* data, size_t size, sfIpAddress remoteAddress, unsigned short remotePort);
CSFML_NETWORK_API sfSocketStatus
sfUdpSocket_send(sfUdpSocket* socket, const void* data, size_t size, sfIpAddress remoteAddress, unsigned short remotePort);
////////////////////////////////////////////////////////////
/// \brief Receive raw data from a remote peer with a UDP socket
@@ -162,7 +168,13 @@ CSFML_NETWORK_API sfSocketStatus sfUdpSocket_send(sfUdpSocket* socket, const voi
/// \return Status code
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSocketStatus sfUdpSocket_receive(sfUdpSocket* socket, void* data, size_t size, size_t* received, sfIpAddress* remoteAddress, unsigned short* remotePort);
CSFML_NETWORK_API sfSocketStatus sfUdpSocket_receive(
sfUdpSocket* socket,
void* data,
size_t size,
size_t* received,
sfIpAddress* remoteAddress,
unsigned short* remotePort);
////////////////////////////////////////////////////////////
/// \brief Send a formatted packet of data to a remote peer with a UDP socket
@@ -179,7 +191,8 @@ CSFML_NETWORK_API sfSocketStatus sfUdpSocket_receive(sfUdpSocket* socket, void*
/// \return Status code
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSocketStatus sfUdpSocket_sendPacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress remoteAddress, unsigned short remotePort);
CSFML_NETWORK_API sfSocketStatus
sfUdpSocket_sendPacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress remoteAddress, unsigned short remotePort);
////////////////////////////////////////////////////////////
/// \brief Receive a formatted packet of data from a remote peer with a UDP socket
@@ -187,6 +200,7 @@ CSFML_NETWORK_API sfSocketStatus sfUdpSocket_sendPacket(sfUdpSocket* socket, sfP
/// In blocking mode, this function will wait until the whole packet
/// has been received.
///
/// \param socket UDP socket object
/// \param packet Packet to fill with the received data
/// \param remoteAddress Address of the peer that sent the data
/// \param remotePort Port of the peer that sent the data
@@ -194,7 +208,8 @@ CSFML_NETWORK_API sfSocketStatus sfUdpSocket_sendPacket(sfUdpSocket* socket, sfP
/// \return Status code
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSocketStatus sfUdpSocket_receivePacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress* remoteAddress, unsigned short* remotePort);
CSFML_NETWORK_API sfSocketStatus
sfUdpSocket_receivePacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress* remoteAddress, unsigned short* remotePort);
////////////////////////////////////////////////////////////
/// \brief Return the maximum number of bytes that can be
@@ -205,5 +220,11 @@ CSFML_NETWORK_API sfSocketStatus sfUdpSocket_receivePacket(sfUdpSocket* socket,
////////////////////////////////////////////////////////////
CSFML_NETWORK_API unsigned int sfUdpSocket_maxDatagramSize(void);
#endif // SFML_UDPSOCKET_H
////////////////////////////////////////////////////////////
/// \brief Return the special value that tells the system
/// to pick any available port
///
/// \return The value to use for any port
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API unsigned short sfUdpSocket_anyPort(void);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,14 +22,12 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_OPENGL_H
#define SFML_OPENGL_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <CSFML/Config.h>
////////////////////////////////////////////////////////////
@@ -38,21 +36,18 @@
////////////////////////////////////////////////////////////
#if defined(CSFML_SYSTEM_WINDOWS)
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <windows.h>
#elif defined(CSFML_SYSTEM_LINUX) || defined(CSFML_SYSTEM_FREEBSD)
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include <GL/glu.h>
#elif defined(CSFML_SYSTEM_MACOS)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#endif
#endif // SFML_OPENGL_H
+41
View File
@@ -0,0 +1,41 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <CSFML/Config.h>
#include <CSFML/System/Buffer.h>
#include <CSFML/System/Clock.h>
#include <CSFML/System/InputStream.h>
#include <CSFML/System/Sleep.h>
#include <CSFML/System/Time.h>
#include <CSFML/System/TimeoutWithPredicate.h>
#include <CSFML/System/Vector2.h>
#include <CSFML/System/Vector3.h>
#include <CSFML/System/Version.h>
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,13 +22,12 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_ALLOC_H
#define SFML_ALLOC_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.h>
#include <CSFML/System/Export.h>
////////////////////////////////////////////////////////////
@@ -36,14 +35,11 @@
///
/// This function deallocates the memory being pointed to
/// using the free function from the C standard library.
///
///
/// The memory must have been previously allocated using a call
/// to malloc.
///
/// \param ptr Pointer to the memory to deallocate
///
/// \param ptr Pointer to the memory to deallocate
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API void sfFree(void* ptr);
#endif // SFML_ALLOC_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,14 +22,15 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_BUFFER_H
#define SFML_BUFFER_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.h>
#include <SFML/System/Types.h>
#include <CSFML/System/Export.h>
#include <CSFML/System/Types.h>
#include <stddef.h>
@@ -47,7 +48,7 @@ CSFML_SYSTEM_API sfBuffer* sfBuffer_create(void);
/// \param buffer Buffer to delete
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API void sfBuffer_destroy(sfBuffer* buffer);
CSFML_SYSTEM_API void sfBuffer_destroy(const sfBuffer* buffer);
////////////////////////////////////////////////////////////
/// \brief Return the size of a buffer
@@ -67,7 +68,4 @@ CSFML_SYSTEM_API size_t sfBuffer_getSize(const sfBuffer* buffer);
/// \return Read-only pointer to the array of bytes
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API const sfUint8* sfBuffer_getData(const sfBuffer* buffer);
#endif // SFML_BUFFER_H
CSFML_SYSTEM_API const uint8_t* sfBuffer_getData(const sfBuffer* buffer);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,15 +22,15 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_CLOCK_H
#define SFML_CLOCK_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.h>
#include <SFML/System/Time.h>
#include <SFML/System/Types.h>
#include <CSFML/System/Export.h>
#include <CSFML/System/Time.h>
#include <CSFML/System/Types.h>
////////////////////////////////////////////////////////////
@@ -57,7 +57,7 @@ CSFML_SYSTEM_API sfClock* sfClock_copy(const sfClock* clock);
/// \param clock Clock to destroy
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API void sfClock_destroy(sfClock* clock);
CSFML_SYSTEM_API void sfClock_destroy(const sfClock* clock);
////////////////////////////////////////////////////////////
/// \brief Get the time elapsed in a clock
@@ -73,6 +73,36 @@ CSFML_SYSTEM_API void sfClock_destroy(sfClock* clock);
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API sfTime sfClock_getElapsedTime(const sfClock* clock);
////////////////////////////////////////////////////////////
/// \brief Check whether the clock is running
///
/// \param clock Clock object
///
/// \return `true` if the clock is running, `false` otherwise
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API bool sfClock_isRunning(const sfClock* clock);
////////////////////////////////////////////////////////////
/// \brief Start the clock
///
/// \param clock Clock object
///
/// \see `stop`
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API void sfClock_start(sfClock* clock);
////////////////////////////////////////////////////////////
/// \brief Stop the clock
///
/// \param clock Clock object
///
/// \see `start`
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API void sfClock_stop(sfClock* clock);
////////////////////////////////////////////////////////////
/// \brief Restart a clock
///
@@ -86,5 +116,17 @@ CSFML_SYSTEM_API sfTime sfClock_getElapsedTime(const sfClock* clock);
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API sfTime sfClock_restart(sfClock* clock);
#endif // SFML_CLOCK_H
////////////////////////////////////////////////////////////
/// \brief Reset the clock
///
/// This function puts the time counter back to zero, returns
/// the elapsed time, and leaves the clock in a paused state.
///
/// \param clock Clock object
///
/// \return Time elapsed
///
/// \see `restart`
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API sfTime sfClock_reset(sfClock* clock);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,13 +22,12 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_SYSTEM_EXPORT_H
#define SFML_SYSTEM_EXPORT_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <CSFML/Config.h>
////////////////////////////////////////////////////////////
@@ -36,13 +35,10 @@
////////////////////////////////////////////////////////////
#if defined(CSFML_SYSTEM_EXPORTS)
#define CSFML_SYSTEM_API CSFML_API_EXPORT
#define CSFML_SYSTEM_API CSFML_API_EXPORT
#else
#define CSFML_SYSTEM_API CSFML_API_IMPORT
#define CSFML_SYSTEM_API CSFML_API_IMPORT
#endif
#endif // SFML_SYSTEM_EXPORT_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,19 +22,20 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_INPUTSTREAM_H
#define SFML_INPUTSTREAM_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.h>
#include <CSFML/System/Export.h>
#include <stdlib.h>
typedef sfInt64 (*sfInputStreamReadFunc)(void* data, sfInt64 size, void* userData);
typedef sfInt64 (*sfInputStreamSeekFunc)(sfInt64 position, void* userData);
typedef sfInt64 (*sfInputStreamTellFunc)(void* userData);
typedef sfInt64 (*sfInputStreamGetSizeFunc)(void* userData);
typedef int64_t (*sfInputStreamReadFunc)(void* data, size_t size, void* userData);
typedef int64_t (*sfInputStreamSeekFunc)(size_t position, void* userData);
typedef int64_t (*sfInputStreamTellFunc)(void* userData);
typedef int64_t (*sfInputStreamGetSizeFunc)(void* userData);
////////////////////////////////////////////////////////////
@@ -49,6 +50,3 @@ typedef struct sfInputStream
sfInputStreamGetSizeFunc getSize; ///< Function to get the total number of bytes in the stream
void* userData; ///< User data that will be passed to the callbacks
} sfInputStream;
#endif // SFML_INPUTSTREAM_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,14 +22,14 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_SLEEP_H
#define SFML_SLEEP_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.h>
#include <SFML/System/Time.h>
#include <CSFML/System/Export.h>
#include <CSFML/System/Time.h>
////////////////////////////////////////////////////////////
@@ -42,6 +42,3 @@
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API void sfSleep(sfTime duration);
#endif // SFML_SLEEP_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,13 +22,12 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_TIME_H
#define SFML_TIME_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.h>
#include <CSFML/System/Export.h>
////////////////////////////////////////////////////////////
@@ -37,14 +36,14 @@
////////////////////////////////////////////////////////////
typedef struct
{
sfInt64 microseconds;
int64_t microseconds;
} sfTime;
////////////////////////////////////////////////////////////
/// \brief Predefined "zero" time value
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API sfTime sfTime_Zero;
CSFML_SYSTEM_API const sfTime sfTime_Zero;
////////////////////////////////////////////////////////////
/// \brief Return a time value as a number of seconds
@@ -64,7 +63,7 @@ CSFML_SYSTEM_API float sfTime_asSeconds(sfTime time);
/// \return Time in milliseconds
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API sfInt32 sfTime_asMilliseconds(sfTime time);
CSFML_SYSTEM_API int32_t sfTime_asMilliseconds(sfTime time);
////////////////////////////////////////////////////////////
/// \brief Return a time value as a number of microseconds
@@ -74,7 +73,7 @@ CSFML_SYSTEM_API sfInt32 sfTime_asMilliseconds(sfTime time);
/// \return Time in microseconds
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API sfInt64 sfTime_asMicroseconds(sfTime time);
CSFML_SYSTEM_API int64_t sfTime_asMicroseconds(sfTime time);
////////////////////////////////////////////////////////////
/// \brief Construct a time value from a number of seconds
@@ -94,7 +93,7 @@ CSFML_SYSTEM_API sfTime sfSeconds(float amount);
/// \return Time value constructed from the amount of milliseconds
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API sfTime sfMilliseconds(sfInt32 amount);
CSFML_SYSTEM_API sfTime sfMilliseconds(int32_t amount);
////////////////////////////////////////////////////////////
/// \brief Construct a time value from a number of microseconds
@@ -104,7 +103,4 @@ CSFML_SYSTEM_API sfTime sfMilliseconds(sfInt32 amount);
/// \return Time value constructed from the amount of microseconds
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API sfTime sfMicroseconds(sfInt64 amount);
#endif // SFML_TIME_H
CSFML_SYSTEM_API sfTime sfMicroseconds(int64_t amount);
@@ -0,0 +1,66 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <CSFML/System/Time.h>
#include <stdbool.h>
////////////////////////////////////////////////////////////
/// \brief Predicate that returns true to continue or false to time out
///
/// \param userData User data stored in the sfTimeoutWithPredicate
///
/// \return True to continue, false to time out
///
////////////////////////////////////////////////////////////
typedef bool (*sfTimeoutPredicate)(void* userData);
////////////////////////////////////////////////////////////
/// \brief Hybrid of a timeout and a continuation predicate
///
/// Functions taking a timeout parameter that is specified
/// solely by a time cannot be easily interrupted. A predicate
/// allows interrupting the operation at any time, e.g. when
/// the user cancels it.
///
/// If \a predicate is NULL, the operation times out after
/// \a timeout (0 meaning no timeout). If \a predicate is set,
/// \a timeout is ignored and the operation times out once the
/// predicate returns false. The predicate is checked every
/// \a period, a period of 0 checks it every millisecond.
///
////////////////////////////////////////////////////////////
typedef struct
{
sfTime timeout; ///< Time to time out after, if no predicate is set
sfTimeoutPredicate predicate; ///< Predicate that returns true to continue or false to time out, can be NULL
void* userData; ///< User data passed to the predicate
sfTime period; ///< The period between checks of the predicate
} sfTimeoutWithPredicate;
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,14 +22,8 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_SYSTEM_TYPES_H
#define SFML_SYSTEM_TYPES_H
#pragma once
typedef struct sfBuffer sfBuffer;
typedef struct sfClock sfClock;
typedef struct sfMutex sfMutex;
typedef struct sfThread sfThread;
#endif // SFML_SYSTEM_TYPES_H
typedef struct sfClock sfClock;
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,13 +22,12 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_VECTOR2_H
#define SFML_VECTOR2_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.h>
#include <CSFML/System/Export.h>
////////////////////////////////////////////////////////////
@@ -62,6 +61,3 @@ typedef struct
float x;
float y;
} sfVector2f;
#endif // SFML_VECTOR2_H
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,13 +22,12 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_VECTOR3_H
#define SFML_VECTOR3_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.h>
#include <CSFML/System/Export.h>
////////////////////////////////////////////////////////////
@@ -41,6 +40,3 @@ typedef struct
float y;
float z;
} sfVector3f;
#endif // SFML_VECTOR3_H
+64
View File
@@ -0,0 +1,64 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <CSFML/System/Export.h>
#include <stdbool.h>
#include <stdint.h>
////////////////////////////////////////////////////////////
/// \brief Version information of the SFML library
///
////////////////////////////////////////////////////////////
typedef struct
{
int8_t major; ///< SFML major version
int8_t minor; ///< SFML minor version
int8_t patch; ///< SFML patch version
bool isRelease; ///< true if this is a release version, false if this is a development version
const char* string; ///< String representation of the SFML version, e.g. 3.1.0 or 3.1.0-dev
} sfVersion;
////////////////////////////////////////////////////////////
/// \brief Get the version of the SFML library loaded at runtime
///
/// This is the version of the SFML library CSFML is linked
/// against at runtime, which can differ from the version
/// CSFML was compiled with (see CSFML_VERSION_MAJOR,
/// CSFML_VERSION_MINOR and CSFML_VERSION_PATCH).
///
/// The returned string is owned by SFML and stays valid
/// for the whole lifetime of the program.
///
/// \return Version information of the SFML library
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API sfVersion sfGetVersion(void);
+15 -15
View File
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,22 +22,22 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_AUDIO_H
#define SFML_AUDIO_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System.h>
#include <SFML/Audio/Listener.h>
#include <SFML/Audio/Music.h>
#include <SFML/Audio/Sound.h>
#include <SFML/Audio/SoundBuffer.h>
#include <SFML/Audio/SoundBufferRecorder.h>
#include <SFML/Audio/SoundRecorder.h>
#include <SFML/Audio/SoundStatus.h>
#include <SFML/Audio/SoundStream.h>
#endif // SFML_AUDIO_H
#include <CSFML/System.h>
#include <CSFML/Window/Clipboard.h>
#include <CSFML/Window/Context.h>
#include <CSFML/Window/Cursor.h>
#include <CSFML/Window/Event.h>
#include <CSFML/Window/Joystick.h>
#include <CSFML/Window/JoystickIdentification.h>
#include <CSFML/Window/Keyboard.h>
#include <CSFML/Window/Mouse.h>
#include <CSFML/Window/Sensor.h>
#include <CSFML/Window/Touch.h>
#include <CSFML/Window/VideoMode.h>
#include <CSFML/Window/Window.h>
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,14 +22,14 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_CLIPBOARD_H
#define SFML_CLIPBOARD_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/Export.h>
#include <SFML/Window/Types.h>
#include <CSFML/Window/Export.h>
#include <CSFML/Window/Types.h>
////////////////////////////////////////////////////////////
@@ -55,7 +55,7 @@ CSFML_WINDOW_API const char* sfClipboard_getString(void);
/// \return Clipboard contents as UTF-32
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API const sfUint32* sfClipboard_getUnicodeString(void);
CSFML_WINDOW_API const sfChar32* sfClipboard_getUnicodeString(void);
////////////////////////////////////////////////////////////
/// \brief Set the content of the clipboard as ANSI string data
@@ -79,7 +79,4 @@ CSFML_WINDOW_API void sfClipboard_setString(const char* text);
/// to the clipboard
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfClipboard_setUnicodeString(const sfUint32* text);
#endif // SFML_CURSOR_H
CSFML_WINDOW_API void sfClipboard_setUnicodeString(const sfChar32* text);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,17 +22,17 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_CONTEXT_H
#define SFML_CONTEXT_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/Export.h>
#include <SFML/Window/Types.h>
#include <SFML/Window/Window.h>
#include <CSFML/Window/Export.h>
typedef void (*GlFunctionPointer)(void);
#include <CSFML/Window/Types.h>
#include <CSFML/Window/Window.h>
typedef void (*sfGlFunctionPointer)(void);
////////////////////////////////////////////////////////////
/// \brief Create a new context
@@ -50,7 +50,7 @@ CSFML_WINDOW_API sfContext* sfContext_create(void);
/// \param context Context to destroy
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfContext_destroy(sfContext* context);
CSFML_WINDOW_API void sfContext_destroy(const sfContext* context);
////////////////////////////////////////////////////////////
/// \brief Check whether a given OpenGL extension is available.
@@ -60,18 +60,18 @@ CSFML_WINDOW_API void sfContext_destroy(sfContext* context);
/// \return True if available, false if unavailable
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfBool sfContext_isExtensionAvailable(const char* name);
CSFML_WINDOW_API bool sfContext_isExtensionAvailable(const char* name);
////////////////////////////////////////////////////////////
/// \brief Activate or deactivate explicitely a context
/// \brief Activate or deactivate explicitly a context
///
/// \param context Context object
/// \param active sfTrue to activate, sfFalse to deactivate
/// \param active true to activate, false to deactivate
///
/// \return sfTrue on success, sfFalse on failure
/// \return true on success, false on failure
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfBool sfContext_setActive(sfContext* context, sfBool active);
CSFML_WINDOW_API bool sfContext_setActive(sfContext* context, bool active);
////////////////////////////////////////////////////////////
/// \brief Get the address of an OpenGL function.
@@ -81,7 +81,7 @@ CSFML_WINDOW_API sfBool sfContext_setActive(sfContext* context, sfBool active);
/// \return Address of the OpenGL function, 0 on failure
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API GlFunctionPointer sfContext_getFunction(const char* name);
CSFML_WINDOW_API sfGlFunctionPointer sfContext_getFunction(const char* name);
////////////////////////////////////////////////////////////
/// \brief Get the settings of the context.
@@ -106,6 +106,4 @@ CSFML_WINDOW_API sfContextSettings sfContext_getSettings(const sfContext* contex
/// \return The active context's ID or 0 if no context is currently active
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfUint64 sfContext_getActiveContextId(void);
#endif // SFML_CONTEXT_H
CSFML_WINDOW_API uint64_t sfContext_getActiveContextId(void);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,15 +22,15 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_CURSOR_H
#define SFML_CURSOR_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Vector2.h>
#include <SFML/Window/Export.h>
#include <SFML/Window/Types.h>
#include <CSFML/Window/Export.h>
#include <CSFML/System/Vector2.h>
#include <CSFML/Window/Types.h>
////////////////////////////////////////////////////////////
@@ -79,14 +79,14 @@ typedef enum
sfCursorSizeRight, ///< Right arrow cursor on Linux, same as SizeHorizontal on other platforms
sfCursorSizeTop, ///< Up arrow cursor on Linux, same as SizeVertical on other platforms
sfCursorSizeBottom, ///< Down arrow cursor on Linux, same as SizeVertical on other platforms
sfCursorSizeTopLeft, ///< Top-left arrow cursor on Linux, same as SizeTopLeftBottomRight on other platforms
sfCursorSizeBottomRight, ///< Bottom-right arrow cursor on Linux, same as SizeTopLeftBottomRight on other platforms
sfCursorSizeBottomLeft, ///< Bottom-left arrow cursor on Linux, same as SizeBottomLeftTopRight on other platforms
sfCursorSizeTopRight, ///< Top-right arrow cursor on Linux, same as SizeBottomLeftTopRight on other platforms
sfCursorSizeAll, ///< Combination of SizeHorizontal and SizeVertical
sfCursorCross, ///< Crosshair cursor
sfCursorHelp, ///< Help cursor
sfCursorNotAllowed ///< Action not allowed cursor
sfCursorSizeTopLeft, ///< Top-left arrow cursor on Linux, same as SizeTopLeftBottomRight on other platforms
sfCursorSizeBottomRight, ///< Bottom-right arrow cursor on Linux, same as SizeTopLeftBottomRight on other platforms
sfCursorSizeBottomLeft, ///< Bottom-left arrow cursor on Linux, same as SizeBottomLeftTopRight on other platforms
sfCursorSizeTopRight, ///< Top-right arrow cursor on Linux, same as SizeBottomLeftTopRight on other platforms
sfCursorSizeAll, ///< Combination of SizeHorizontal and SizeVertical
sfCursorCross, ///< Crosshair cursor
sfCursorHelp, ///< Help cursor
sfCursorNotAllowed ///< Action not allowed cursor
} sfCursorType;
@@ -97,8 +97,7 @@ typedef enum
/// in 32-bit RGBA format. If not, this will cause undefined behavior.
///
/// If \a pixels is null or either \a width or \a height are 0,
/// the current cursor is left unchanged and the function will
/// return false.
/// the function will return no new cursor (nullptr).
///
/// In addition to specifying the pixel data, you can also
/// specify the location of the hotspot of the cursor. The
@@ -118,7 +117,7 @@ typedef enum
/// \return A new sfCursor object
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfCursor* sfCursor_createFromPixels(const sfUint8* pixels, sfVector2u size, sfVector2u hotspot);
CSFML_WINDOW_API sfCursor* sfCursor_createFromPixels(const uint8_t* pixels, sfVector2u size, sfVector2u hotspot);
////////////////////////////////////////////////////////////
@@ -142,7 +141,4 @@ CSFML_WINDOW_API sfCursor* sfCursor_createFromSystem(sfCursorType type);
/// \param cursor Cursor to destroy
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfCursor_destroy(sfCursor* cursor);
#endif // SFML_CURSOR_H
CSFML_WINDOW_API void sfCursor_destroy(const sfCursor* cursor);
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,17 +22,17 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_EVENT_H
#define SFML_EVENT_H
#pragma once
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/Export.h>
#include <SFML/Window/Joystick.h>
#include <SFML/Window/Keyboard.h>
#include <SFML/Window/Mouse.h>
#include <SFML/Window/Sensor.h>
#include <CSFML/Window/Export.h>
#include <CSFML/Window/Joystick.h>
#include <CSFML/Window/Keyboard.h>
#include <CSFML/Window/Mouse.h>
#include <CSFML/Window/Sensor.h>
////////////////////////////////////////////////////////////
@@ -43,16 +43,16 @@ typedef enum
{
sfEvtClosed, ///< The window requested to be closed (no data)
sfEvtResized, ///< The window was resized (data in event.size)
sfEvtLostFocus, ///< The window lost the focus (no data)
sfEvtGainedFocus, ///< The window gained the focus (no data)
sfEvtFocusLost, ///< The window lost the focus (no data)
sfEvtFocusGained, ///< The window gained the focus (no data)
sfEvtTextEntered, ///< A character was entered (data in event.text)
sfEvtKeyPressed, ///< A key was pressed (data in event.key)
sfEvtKeyReleased, ///< A key was released (data in event.key)
sfEvtMouseWheelMoved, ///< The mouse wheel was scrolled (data in event.mouseWheel) (deprecated)
sfEvtMouseWheelScrolled, ///< The mouse wheel was scrolled (data in event.mouseWheelScroll)
sfEvtMouseButtonPressed, ///< A mouse button was pressed (data in event.mouseButton)
sfEvtMouseButtonReleased, ///< A mouse button was released (data in event.mouseButton)
sfEvtMouseMoved, ///< The mouse cursor moved (data in event.mouseMove)
sfEvtMouseMovedRaw, ///< The mouse cursor moved (data in event.mouseMove)
sfEvtMouseEntered, ///< The mouse cursor entered the area of the window (no data)
sfEvtMouseLeft, ///< The mouse cursor left the area of the window (no data)
sfEvtJoystickButtonPressed, ///< A joystick button was pressed (data in event.joystickButton)
@@ -65,7 +65,7 @@ typedef enum
sfEvtTouchEnded, ///< A touch event ended (data in event.touch)
sfEvtSensorChanged, ///< A sensor value changed (data in event.sensor)
sfEvtCount ///< Keep last -- the total number of event types
sfEvtCount ///< Keep last -- the total number of event types
} sfEventType;
@@ -78,10 +78,10 @@ typedef struct
sfEventType type;
sfKeyCode code;
sfScancode scancode;
sfBool alt;
sfBool control;
sfBool shift;
sfBool system;
bool alt;
bool control;
bool shift;
bool system;
} sfKeyEvent;
////////////////////////////////////////////////////////////
@@ -91,7 +91,7 @@ typedef struct
typedef struct
{
sfEventType type;
sfUint32 unicode;
uint32_t unicode;
} sfTextEvent;
////////////////////////////////////////////////////////////
@@ -101,10 +101,19 @@ typedef struct
typedef struct
{
sfEventType type;
int x;
int y;
sfVector2i position;
} sfMouseMoveEvent;
////////////////////////////////////////////////////////////
/// \brief Mouse move raw event parameters
///
////////////////////////////////////////////////////////////
typedef struct
{
sfEventType type;
sfVector2i delta;
} sfMouseMoveRawEvent;
////////////////////////////////////////////////////////////
/// \brief Mouse buttons events parameters
///
@@ -113,25 +122,9 @@ typedef struct
{
sfEventType type;
sfMouseButton button;
int x;
int y;
sfVector2i position;
} sfMouseButtonEvent;
////////////////////////////////////////////////////////////
/// \brief Mouse wheel events parameters
///
/// \deprecated
/// Use sfMouseWheelScrollEvent instead.
///
////////////////////////////////////////////////////////////
typedef struct CSFML_DEPRECATED
{
sfEventType type;
int delta;
int x;
int y;
} sfMouseWheelEvent;
////////////////////////////////////////////////////////////
/// \brief Mouse wheel events parameters
///
@@ -141,8 +134,7 @@ typedef struct
sfEventType type;
sfMouseWheel wheel;
float delta;
int x;
int y;
sfVector2i position;
} sfMouseWheelScrollEvent;
////////////////////////////////////////////////////////////
@@ -184,9 +176,8 @@ typedef struct
////////////////////////////////////////////////////////////
typedef struct
{
sfEventType type;
unsigned int width;
unsigned int height;
sfEventType type;
sfVector2u size;
} sfSizeEvent;
////////////////////////////////////////////////////////////
@@ -197,8 +188,7 @@ typedef struct
{
sfEventType type;
unsigned int finger;
int x;
int y;
sfVector2i position;
} sfTouchEvent;
////////////////////////////////////////////////////////////
@@ -209,9 +199,7 @@ typedef struct
{
sfEventType type;
sfSensorType sensorType;
float x;
float y;
float z;
sfVector3f value;
} sfSensorEvent;
////////////////////////////////////////////////////////////
@@ -225,8 +213,8 @@ typedef union
sfKeyEvent key; ///< Key event parameters
sfTextEvent text; ///< Text event parameters
sfMouseMoveEvent mouseMove; ///< Mouse move event parameters
sfMouseMoveRawEvent mouseMoveRaw; ///< Mouse move raw event parameters
sfMouseButtonEvent mouseButton; ///< Mouse button event parameters
sfMouseWheelEvent mouseWheel; ///< Mouse wheel event parameters (deprecated)
sfMouseWheelScrollEvent mouseWheelScroll; ///< Mouse wheel event parameters
sfJoystickMoveEvent joystickMove; ///< Joystick move event parameters
sfJoystickButtonEvent joystickButton; ///< Joystick button event parameters
@@ -234,6 +222,3 @@ typedef union
sfTouchEvent touch; ///< Touch events parameters
sfSensorEvent sensor; ///< Sensor event parameters
} sfEvent;
#endif // SFML_EVENT_H
Loaded 100 of 325 files, more files were not shown because too many files have changed in this diff. Show more