Commit Graph

933 Commits

Author SHA1 Message Date
kimci86
eb762db342 Fix sf::VideoMode usage example 2024-06-18 06:13:15 -06:00
Chris Thrasher
5580720ae0 Fix inconsistent factory function name 2024-06-17 10:10:00 -06:00
kimci86
f96bf1f300 Rename Rect comparison operands to avoid confusion 2024-06-16 02:48:53 +02:00
kimci86
58e83056bb Some simplifications taking advantage of Rect position and size members 2024-06-16 02:48:53 +02:00
kimci86
1fd510c4bf Update Rect documentation 2024-06-16 02:48:53 +02:00
kimci86
c371bc6816 Remove Rect getPosition and getSize methods 2024-06-16 02:48:53 +02:00
kimci86
7e5ed78219 Replace Rect members left, top, width, height by position and size 2024-06-16 02:48:53 +02:00
vittorioromeo
e7b23ffcd1 Add timeout parameter to waitEvent 2024-06-14 15:00:46 +02:00
vittorioromeo
51efe50ec4 Simplify sf::Sprite implementation and reduce branches 2024-06-13 00:31:49 +02:00
Chris Thrasher
2f54312481 Fix documentation bugs 2024-06-12 14:38:04 -05:00
Chris Thrasher
304a7c1d69 Remove default empty state of sf::FileInputStream 2024-06-11 07:31:09 -05:00
copyrat90
37ac80dbe5 Update documentation of creating Music and Cursor 2024-06-11 12:29:31 +02:00
vittorioromeo
a303cee386 Consistently print errors in factory functions 2024-06-10 20:00:53 +02:00
Chris Thrasher
366b119963 Remove default empty state of sf::MemoryInputStream 2024-06-10 08:11:28 -05:00
Chris Thrasher
de8430bb29 Use std::optional rather than sentinel values 2024-06-09 20:48:55 -05:00
vittorioromeo
52ce862a00 Remove default empty state of sf::Music 2024-06-08 20:54:10 +02:00
Paul Meffle
92bba1ed6f Add support for raw mouse input 2024-06-04 13:24:10 -06:00
Chris Thrasher
bfd65989e9 Remove default empty state of sf::Texture 2024-06-04 13:19:58 -06:00
Chris Thrasher
46a71e4fe8 Add clang-tidy readability-redundant-member-init check
This has to be silenced for `sf::Vertex` because in some places within
SFML we initialize only a subset of this aggregate type. If we remove
the `{}` from `texCoords` then we get a compiler warning from Clang. It
feels like these two clang-based tools are somewhat contradictory.

error: missing field 'texCoords' initializer [-Werror,-Wmissing-field-initializers]
            m_points.append({{x, y}, {r, g, b}});
2024-06-04 00:56:24 -06:00
binary1248
123270f7ad Added support for retrieving a list of audio playback devices, getting the default audio playback device and changing the audio playback device during runtime. 2024-05-28 10:54:01 -06:00
Chris Thrasher
55f0918c62 Remove sf::View::reset in favor of assignment operations
It's rare that a type truly needs a .reset function. Copy/move
assignment typically accomplishes the same thing with less code
and is easier to maintain since it doesn't require updating your
.reset() function as new data members are added.

To reset a type is conceptually the same thing as simply assigning
from a newly constructed instance of the same type.
2024-05-26 10:23:52 -06:00
vittorioromeo
e53f4d62af Turn 'ContextSettings' into an aggregate and update usages 2024-05-25 00:56:37 +02:00
Chris Thrasher
b583eaf160 Replace const char* with std::string_view 2024-05-24 12:01:27 +02:00
Chris Thrasher
cc87ef7a3c Use std::string_view to construct sf::Shaders without allocations 2024-05-23 19:26:13 -06:00
Chris Thrasher
fdcd899d2b Remove default empty state of sf::RenderTexture 2024-05-22 23:37:42 -06:00
Chris Thrasher
e6d4ee7ad1 Fix sound file docs 2024-05-22 18:32:55 -06:00
vittorioromeo
8b36da3625 Use '{}' for default parameter initialization 2024-05-22 11:54:49 -06:00
Chris Thrasher
e9fadbbcb3 Remove default empty state of sf::InputSoundFile and sf::OutputSoundFile 2024-05-22 09:46:37 -06:00
Chris Thrasher
53ade4baf1 Remove default empty state of sf::Cursor 2024-05-21 01:09:09 -06:00
Chris Thrasher
7234fc149b Remove default empty state of sf::Shader 2024-05-19 20:58:58 -06:00
Chris Thrasher
504b850f03 Remove default empty state of sf::Font 2024-05-19 14:01:54 -06:00
Chris Thrasher
0ac278b2d6 Remove default empty state of sf::Image 2024-05-19 13:25:34 -06:00
Chris Thrasher
add6422e6b Remove default empty state of sf::SoundBuffer 2024-05-19 13:09:38 -06:00
binary1248
002b8953fa Added support for user defined sound effect implementations. 2024-05-16 21:52:16 -06:00
vittorioromeo
884206ce0c Store angles internally as radians 2024-05-14 13:07:40 -06:00
Chris Thrasher
593c4fe173 Replace C arrays with std::array 2024-05-14 12:47:19 -05:00
Chris Thrasher
207b54e445
Merge branch '2.6.x' into feature/backmerge 2024-05-13 21:07:03 -06:00
Chris Thrasher
3acc332de0 Use American spellings 2024-05-13 00:44:27 -05:00
Chris Thrasher
8c9fa1087e Remove misplaced comma 2024-05-13 00:44:27 -05:00
Chris Thrasher
742dffa0de Remove reference to old API
0785093 changed the API to use a vector instead of two scalar values
2024-05-13 00:44:27 -05:00
Chris Thrasher
b9b8366a45 Fix run-on sentences 2024-05-13 00:44:27 -05:00
Lukas Dürrenberger
1a4003fcc0 Add clarification about the RenderTexture state after creation 2024-05-12 19:35:14 -05:00
vittorioromeo
ae269e1149 Make 'Event.inl' self-contained 2024-05-06 04:44:28 +00:00
binary1248
4daeac6459 Fall back to stdio when performing file input on Android without an activity. 2024-05-04 17:22:12 +00:00
trustytrojan
ca0a231b35 Add operator bool() to sf::Event for checking if the event type is not Empty 2024-05-03 22:50:59 +00:00
Andrei
9534c000f6 Added missing \param field from sf::Keyboard::getDescription(Scancode code) in docs 2024-05-03 07:25:50 +00:00
Chris Thrasher
b7c526efc2 Fix API documentation bugs 2024-05-03 01:36:55 +00:00
Chris Thrasher
59447dd8e5 Rewrite sf::Event API to improve type safety
This new API is built on top of std::variant. This allows us to
store many different event types in a space-efficient way and access
the active event type in a type-safe manner that eliminates the
categories of UB that are possible with unions.

Co-authored-by: kimci86 <kimci86@hotmail.fr>
2024-05-01 18:00:58 +00:00
Chris Thrasher
73126c93a3 Use std::optional to express functions that may not return a value 2024-04-29 19:09:39 +00:00
kimci86
71395e746e Define SoundStream::NoLoop as constexpr instead of enum 2024-04-28 16:36:57 +00:00
kimci86
bdd348c142 Make Sound::Status a scoped enumeration 2024-04-28 16:36:57 +00:00
Chris Thrasher
249caa2fb2 Require that variables are initialized 2024-04-27 19:20:52 +00:00
binary1248
34fde883b9 Replaced OpenAL with miniaudio.
Co-authored-by: Chris Thrasher <chrisjthrasher@gmail.com>
Co-authored-by: kimci86 <kimci86@hotmail.fr>
Co-authored-by: vittorioromeo <mail@vittorioromeo.com>
2024-04-25 10:24:11 +02:00
Chris Thrasher
a05daa62b7 Use more C++17 inline variables 2024-04-23 09:35:46 -06:00
Chris Thrasher
4315c3d290 Revert change to Drawable::draw function signature
This change was made in 359fe90 due to recommendations from tooling.
On its face this change makes sense since it removes a copy that
isn't always necessary. In practice it caused ergonomic issues due
to now being forced to make a copy of the render states when needed.

The performance gains of eliding this copy are unsubstantiated. We
have not done any profiling to measure its impact. For lack of such
measurements I'd rather err on the side of improved user experience.
If future benchmarks prove this copy is rather expensive then we
can reconsider removing it with that evidence in mind.
2024-04-18 13:18:49 +02:00
Chris Thrasher
d6e1961112 Ensure struct data members are given an initial value
While I don't suspect there are any uninitialize variable bugs
present, it's still good to err on the side of safety and provide
an initial value nonetheless.
2024-04-16 19:14:38 -06:00
Chris Thrasher
6eaf300918 constexpr-fy sf::priv::Vector4 2024-04-11 09:05:28 -06:00
Chris Thrasher
b0e25088a2 Initialize all sf::Glyph members
This silences an MSVC warning about lsbDelta and rsbDelta not being
initialized. Whether or not this fixes any bugs, it provides a
better user experience if nobody sees those warnings.
2024-04-07 12:34:37 -06:00
Chris Thrasher
d00ab43ea6 Return nullptr when sf::Context::getFunction is called on Windows without an active context
This converts termination in Debug and a SEGFAULT in Release builds
into defined behavior.
2024-04-02 21:40:09 -05:00
vittorioromeo
23c26f9b70 Turn 'sf::Vertex' into an aggregate 'struct' 2024-02-19 16:44:06 +00:00
vittorioromeo
b552148e26 Header cleanup guided by IWYU 2024-02-09 12:52:23 +01:00
vittorioromeo
ee13dfbd3b 'SoundFileFactory' implementation overhaul 2024-02-05 17:11:23 +01:00
vittorioromeo
4ff70c87d3 Self-contained '.inl' headers + minor refactoring 2024-02-05 13:45:01 +01:00
Vittorio Romeo
76295f2624 Improve SocketSelector in-documentation example 2024-02-04 20:41:52 +01:00
vittorioromeo
368ff9dace Header include clean-up and minor refactoring 2024-02-03 23:58:44 +01:00
Kipernal
eb07e1e6c5 Added support for stencil testing.
Co-authored-by: binary1248 <binary1248@hotmail.com>
Co-authored-by: Chris Thrasher <chrisjthrasher@gmail.com>
2024-01-29 08:13:14 -07:00
Chris Thrasher
9022d9564d Define character traits for std::uint8_t
Character traits are only standardized for character types of which
std::uint8_t is not. All major C++ implementations happen to define
this specialization but because it is not standard C++ they are
allowed to remove it as LLVM has done by deprecating this specialization
in LLVM 18. It is slated for removal in LLVM 19. To avoid compilation
errors and to get ahead of any deprecation warnings when LLVM 18 ships
we need to define our own std::uint8_t character traits.

SFML 4 will have access to C++20's std::u8string which should let us
remove this code.
2024-01-28 10:24:02 -07:00
kimci86
a7f054712a Update PrimitiveType values occurrences in documentation
because PrimitiveType is a scoped enumeration.
2024-01-27 15:31:30 -07:00
kimci86
0d3c7f1c32 Make VertexBuffer::Usage a scoped enumeration 2024-01-27 15:31:30 -07:00
kimci86
a019b5167b Make Shader::Type a scoped enumeration 2024-01-27 15:31:30 -07:00
kimci86
b496877c90 Make BlendMode::Factor and BlendMode::Equation scoped enumerations 2024-01-27 15:31:30 -07:00
Miron Alexandru
3ca42c9a45 Update copyright year 2024-01-26 12:00:22 -07:00
Corentin Schreiber
ebf485737f Add texture coordinate type to sf::RenderStates 2024-01-25 23:45:00 -07:00
Chris Thrasher
b234ede61e Use struct for data type with exclusively public contents 2024-01-24 21:59:00 -07:00
Chris Thrasher
a2c003b2b7 Add sf::State for specifying fullscreen or floating windows 2024-01-15 23:08:33 -07:00
Chris Thrasher
0d49fab1a6 Remove unnecessary private operators
Equality operations are not automatically generated by the compiler
so we can omit this.
2024-01-09 22:17:55 -07:00
Chris Thrasher
4346b9a8bc Remove unnecessary default destructor
sf::RenderWindow still inherits a virtual destructor from a base
class so there's no need to explicitly declare a virtual destructor.
I added a test to ensure this property was not broken.
2024-01-08 12:26:28 -07:00
Chris Thrasher
a9d9ef6d83 Deduplicate Window{Base}::create implementations
Co-authored-by: binary1248 <binary1248@hotmail.com>
2024-01-01 12:57:57 -07:00
Chris Thrasher
8509f0fddd Use struct for type with exclusively public contents 2023-12-23 18:36:41 -06:00
Chris Thrasher
ffe9cc0671 Fix incorrect assertion comment 2023-12-22 16:00:39 -06:00
kimci86
39da2b829c Make Keyboard::Key a scoped enumeration 2023-12-22 10:47:30 -06:00
kimci86
82ee0f79ac Remove Key::Last and Scan::Last enumerators
The purpose of those was to make it obvious that an action is needed to
update KeyCount or ScancodeCount when adding more enumerators, but we
rarely touch those enumerations so it is not worth adding those
technical names to the public API.
2023-12-19 22:37:13 +01:00
Chris Thrasher
674d68faa6 Remove unhelpful return values 2023-12-17 17:48:11 -07:00
kimci86
faaceb5b5b Define KeyCount and ScancodeCount out of enums
Those values are not valid Key or Scancode values, so it doesn't make
sense for them to have Key or Scancode type.
Moving them out of their enum makes it possible to write exhaustive
switch case statement without having to write a case for those values.
Making them unsigned int allows to use them as array size without having
to do a static_cast.
2023-12-17 15:47:47 -07:00
kimci86
b20376813c Rename XButton1 and XButton2 into Extra1 and Extra2
This is to avoid repeating Button when using those values now that the
sf::Mouse::Button enumeration is a scoped enumeration.
2023-12-16 12:14:43 -07:00
kimci86
eab8f426e7 Make Sensor::Type a scoped enumeration 2023-12-15 15:18:25 -07:00
kimci86
3fb0ffce51 Make Mouse::Button and Mouse::Wheel scoped enumerations 2023-12-15 15:18:25 -07:00
kimci86
ebf190b660 Make Joystick::Axis a scoped enumeration 2023-12-15 15:18:25 -07:00
kimci86
df2f56fe83 Make Cursor::Type a scoped enumeration 2023-12-15 15:18:25 -07:00
Chris Thrasher
04a7184ab4 Simplify sf::View construction 2023-12-11 19:33:20 -07:00
Chris Thrasher
e11154e7f7 Define default special member functions in headers 2023-12-10 10:28:42 -07:00
Chris Thrasher
7f5d87dcd5 Add move semantics to sf::Context 2023-12-09 10:27:57 -07:00
Chris Thrasher
c89c5eae69 Replace raw loops with standard algorithm 2023-11-28 09:41:28 -07:00
Chris Thrasher
c6919e28fc Prefer std::optional return types over output parameters 2023-11-28 09:37:03 -07:00
Chris Thrasher
0a1090c89d Let compiler define default constructors 2023-11-27 10:49:51 -05:00
Chris Thrasher
fca84e4011 Implicitly define default constructors 2023-11-20 21:31:40 -07:00
Chris Thrasher
1e4cdf89b6 Use std::array to reduce code duplication
std::array lets us have a single source of truth for array size
rather than needing separate constants or magic numbers that have
to stay in sync with the underlying array.
2023-11-20 12:14:21 -07:00
binary1248
5a2f30c5ae Added support for scissor testing. 2023-11-20 11:01:33 -07:00
Chris Thrasher
08eca7c9a4 Default all sf::Font special member functions 2023-11-18 20:52:17 -07:00
Chris Thrasher
ec50a7332b Fix sf::Rect docs 2023-11-15 15:58:01 -07:00