Author SHA1 Message Date
Chris Thrasher cf80a809f3 Add tests for sfTexture 2025-06-08 21:27:12 -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
18 changed files with 271 additions and 5 deletions

No files matched your search

+1 -2
View File
@@ -22,8 +22,6 @@ jobs:
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 }
@@ -42,6 +40,7 @@ jobs:
- name: Get CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: ${{ runner.os == 'Windows' && '3.25' || '3.22' }}
ninjaVersion: latest
- name: Install Linux Dependencies
+22
View File
@@ -216,6 +216,28 @@ CSFML_GRAPHICS_API bool sfRenderWindow_isSrgb(const sfRenderWindow* renderWindow
////////////////////////////////////////////////////////////
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
///
+22
View File
@@ -280,6 +280,28 @@ CSFML_WINDOW_API sfVector2u sfWindow_getSize(const sfWindow* window);
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_setSize(sfWindow* window, sfVector2u size);
////////////////////////////////////////////////////////////
/// \brief Set the minimum window rendering region size
///
/// Pass a `NULL` vector to unset the minimum size
///
/// \param window Window object
/// \param minimumSize New minimum size, in pixels
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_setMinimumSize(sfWindow* window, const sfVector2u* minimumSize);
////////////////////////////////////////////////////////////
/// \brief Set the maximum window rendering region size
///
/// Pass a `NULL` vector to unset the maximum size
///
/// \param window Window object
/// \param maximumSize New maximum size, in pixels
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_setMaximumSize(sfWindow* window, const sfVector2u* maximumSize);
////////////////////////////////////////////////////////////
/// \brief Change the title of a window
///
+22
View File
@@ -236,6 +236,28 @@ CSFML_WINDOW_API sfVector2u sfWindowBase_getSize(const sfWindowBase* windowBase)
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setSize(sfWindowBase* windowBase, sfVector2u size);
////////////////////////////////////////////////////////////
/// \brief Set the minimum window rendering region size
///
/// Pass a `NULL` vector to unset the minimum size
///
/// \param windowBase Window object
/// \param minimumSize New minimum size, in pixels
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setMinimumSize(sfWindowBase* windowBase, const sfVector2u* minimumSize);
////////////////////////////////////////////////////////////
/// \brief Set the maximum window rendering region size
///
/// Pass a `NULL` vector to unset the maximum size
///
/// \param windowBase Window object
/// \param maximumSize New maximum size, in pixels
///
////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setMaximumSize(sfWindowBase* windowBase, const sfVector2u* maximumSize);
////////////////////////////////////////////////////////////
/// \brief Change the title of a window
///
+1
View File
@@ -18,6 +18,7 @@ Development is focused on the next major version in the `master` branch. No more
- Lukas Dürrenberger (eXpl0it3r@sfml-dev.org)
- Chris Thrasher (thrasher@sfml-dev.org)
- Zachariah Brown (contact@zbrown.net)
- And many other members of the SFML community
## Download
+32
View File
@@ -198,6 +198,38 @@ void sfRenderWindow_setSize(sfRenderWindow* renderWindow, sfVector2u size)
}
////////////////////////////////////////////////////////////
void sfRenderWindow_setMinimumSize(sfRenderWindow* renderWindow, const sfVector2u* minimumSize)
{
assert(renderWindow);
if (minimumSize == nullptr)
{
renderWindow->setMinimumSize(std::nullopt);
}
else
{
renderWindow->setMinimumSize(convertVector2(*minimumSize));
}
}
////////////////////////////////////////////////////////////
void sfRenderWindow_setMaximumSize(sfRenderWindow* renderWindow, const sfVector2u* maximumSize)
{
assert(renderWindow);
if (maximumSize == nullptr)
{
renderWindow->setMaximumSize(std::nullopt);
}
else
{
renderWindow->setMaximumSize(convertVector2(*maximumSize));
}
}
////////////////////////////////////////////////////////////
void sfRenderWindow_setTitle(sfRenderWindow* renderWindow, const char* title)
{
+32
View File
@@ -159,6 +159,38 @@ void sfWindow_setSize(sfWindow* window, sfVector2u size)
}
////////////////////////////////////////////////////////////
void sfWindow_setMinimumSize(sfWindow* window, const sfVector2u* minimumSize)
{
assert(window);
if (minimumSize == nullptr)
{
window->setMinimumSize(std::nullopt);
}
else
{
window->setMinimumSize(convertVector2(*minimumSize));
}
}
////////////////////////////////////////////////////////////
void sfWindow_setMaximumSize(sfWindow* window, const sfVector2u* maximumSize)
{
assert(window);
if (maximumSize == nullptr)
{
window->setMaximumSize(std::nullopt);
}
else
{
window->setMaximumSize(convertVector2(*maximumSize));
}
}
////////////////////////////////////////////////////////////
void sfWindow_setTitle(sfWindow* window, const char* title)
{
+34
View File
@@ -34,6 +34,8 @@
#include <SFML/Window/VideoMode.hpp>
#include <optional>
////////////////////////////////////////////////////////////
sfWindowBase* sfWindowBase_create(sfVideoMode mode, const char* title, uint32_t style, sfWindowState state)
@@ -141,6 +143,38 @@ void sfWindowBase_setSize(sfWindowBase* windowBase, sfVector2u size)
}
////////////////////////////////////////////////////////////
void sfWindowBase_setMinimumSize(sfWindowBase* windowBase, const sfVector2u* minimumSize)
{
assert(windowBase);
if (minimumSize == nullptr)
{
windowBase->setMinimumSize(std::nullopt);
}
else
{
windowBase->setMinimumSize(convertVector2(*minimumSize));
}
}
////////////////////////////////////////////////////////////
void sfWindowBase_setMaximumSize(sfWindowBase* windowBase, const sfVector2u* maximumSize)
{
assert(windowBase);
if (maximumSize == nullptr)
{
windowBase->setMaximumSize(std::nullopt);
}
else
{
windowBase->setMaximumSize(convertVector2(*maximumSize));
}
}
////////////////////////////////////////////////////////////
void sfWindowBase_setTitle(sfWindowBase* windowBase, const char* title)
{
+2 -1
View File
@@ -53,13 +53,14 @@ add_executable(test-csfml-graphics
Graphics/RenderStates.test.cpp
Graphics/Shape.test.cpp
Graphics/StencilMode.test.cpp
Graphics/Texture.test.cpp
Graphics/Transform.test.cpp
Graphics/VertexArray.test.cpp
Graphics/View.test.cpp
)
target_link_libraries(test-csfml-graphics PRIVATE csfml-graphics Catch2::Catch2WithMain SFML::Graphics)
set_target_warnings(test-csfml-graphics)
catch_discover_tests(test-csfml-graphics)
catch_discover_tests(test-csfml-graphics WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(test-csfml-network
Network/Ftp.test.cpp
+65
View File
@@ -0,0 +1,65 @@
#include <CSFML/Graphics/Texture.h>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
TEST_CASE("[Graphics] sfTexture")
{
SECTION("sfTexture_create")
{
const sfTexture* texture = sfTexture_create({100, 100});
REQUIRE(texture);
CHECK(sfTexture_getSize(texture).x == 100);
CHECK(sfTexture_getSize(texture).y == 100);
CHECK(!sfTexture_isSmooth(texture));
CHECK(!sfTexture_isSrgb(texture));
CHECK(!sfTexture_isRepeated(texture));
CHECK(sfTexture_getNativeHandle(texture) != 0);
sfTexture_destroy(texture);
}
SECTION("sfTexture_createSrgb")
{
const sfTexture* texture = sfTexture_createSrgb({100, 100});
REQUIRE(texture);
CHECK(sfTexture_getSize(texture).x == 100);
CHECK(sfTexture_getSize(texture).y == 100);
CHECK(!sfTexture_isSmooth(texture));
CHECK(sfTexture_isSrgb(texture));
CHECK(!sfTexture_isRepeated(texture));
CHECK(sfTexture_getNativeHandle(texture) != 0);
sfTexture_destroy(texture);
}
SECTION("sfTexture_createFromFile")
{
const char* fileExtension = GENERATE("bmp", "gif", "jpg", "png", "psd");
const auto filename = std::string("Graphics/sfml-logo-big.") + fileExtension;
INFO("Filename: " << filename);
const sfTexture* texture = sfTexture_createFromFile(filename.c_str(), nullptr);
REQUIRE(texture);
CHECK(sfTexture_getSize(texture).x > 0);
CHECK(sfTexture_getSize(texture).y > 0);
CHECK(!sfTexture_isSmooth(texture));
CHECK(!sfTexture_isSrgb(texture));
CHECK(!sfTexture_isRepeated(texture));
CHECK(sfTexture_getNativeHandle(texture) != 0);
sfTexture_destroy(texture);
}
SECTION("sfTexture_createSrgbFromFile")
{
const char* fileExtension = GENERATE("bmp", "gif", "jpg", "png", "psd");
const auto filename = std::string("Graphics/sfml-logo-big.") + fileExtension;
INFO("Filename: " << filename);
const sfTexture* texture = sfTexture_createSrgbFromFile(filename.c_str(), nullptr);
REQUIRE(texture);
CHECK(sfTexture_getSize(texture).x > 0);
CHECK(sfTexture_getSize(texture).y > 0);
CHECK(!sfTexture_isSmooth(texture));
CHECK(sfTexture_isSrgb(texture));
CHECK(!sfTexture_isRepeated(texture));
CHECK(sfTexture_getNativeHandle(texture) != 0);
sfTexture_destroy(texture);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 892 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.
+2 -1
View File
@@ -22,7 +22,8 @@ TEST_CASE("[Network] sfIpAddress")
SECTION("sfIpAddress_fromString")
{
CHECK(sfIpAddress_toInteger(sfIpAddress_fromString("")) == 0);
CHECK(sfIpAddress_toInteger(sfIpAddress_fromString("invalid address")) == 0);
CHECK(sfIpAddress_toInteger(sfIpAddress_fromString("256.256.256.256")) == 0);
CHECK(sfIpAddress_toInteger(sfIpAddress_fromString("localhost")) == 0x7F000001);
CHECK(sfIpAddress_toInteger(sfIpAddress_fromString("192.168.0.1")) == 0xC0A80001);
CHECK(sfIpAddress_toInteger(sfIpAddress_fromString("8.8.8.8")) == 0x08080808);
}
+3 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>3.0.0</Version>
<Version>3.0.0-rc.2</Version>
<Authors>Laurent Gomila</Authors>
<PackageTags>sfml csfml</PackageTags>
<Copyright>Copyright © Laurent Gomila</Copyright>
@@ -13,6 +13,7 @@
<PackageProjectUrl>https://www.sfml-dev.org/</PackageProjectUrl>
<PackageIconUrl>https://www.sfml-dev.org/images/sfml-icon.png</PackageIconUrl>
<PackageIcon>sfml-icon.png</PackageIcon>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeBuildOutput>false</IncludeBuildOutput>
@@ -31,6 +32,7 @@
<None Pack="True" Include="runtimes/**" PackagePath="runtimes" />
<None Pack="True" Include="build/**" PackagePath="build" />
<None Pack="True" Include="sfml-icon.png" PackagePath="/" />
<None Pack="True" Include="readme.md" PackagePath="/" />
</ItemGroup>
</Project>
+33
View File
@@ -0,0 +1,33 @@
# CSFML - Simple and Fast Multimedia Library for C
SFML is a simple, fast, cross-platform and object-oriented multimedia API.
It provides access to windowing, graphics, audio and network.
It is originally written in C++, and this project is its official binding for the C language.
This NuGet package is designed to provide the required native CSFML libraries for SFML.Net.
## Authors
- Laurent Gomila (laurent@sfml-dev.org)
- Lukas Dürrenberger (eXpl0it3r@sfml-dev.org)
- Chris Thrasher (thrasher@sfml-dev.org)
- Zachariah Brown (contact@zbrown.net)
- And many other members of the SFML community
## Learn
There is no tutorial for CSFML, but since it's a binding you can use the C++ resources:
* The [official tutorials](https://www.sfml-dev.org/tutorials/)
* The [online API documentation](https://www.sfml-dev.org/documentation/)
* The [community wiki](https://github.com/SFML/SFML/wiki/)
* The [community forum](https://en.sfml-dev.org/forums/) (or [French](https://fr.sfml-dev.org/forums/))
Of course, you can also find the CSFML API documentation in the SDK.
## Contribute
SFML and CSFML are open-source projects, and they need your help to go on growing and improving.
Don't hesitate to post suggestions or bug reports on [the forum](https://en.sfml-dev.org/forums/), or post new bugs/features requests on the [issue tracker](https://github.com/SFML/CSFML/issues/).
You can even fork the project on GitHub, maintain your own version and send us pull requests periodically to merge your work.