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
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 fb9fb941b4 Add missing sfSoundBufferRecorder functions inherited from sf::SoundRecorder
Backport of 34febc214f
2024-09-03 16:49:38 -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
Lukas Dürrenberger e153a8a4ce Update CSFML version to 2.6.1 2024-05-19 23:14:45 +02:00
Lukas Dürrenberger 17f42be80c Update copyright year to 2024 2024-05-19 23:14:45 +02:00
Lukas Dürrenberger 586fb28b9d Create release packages automatically 2024-05-19 22:51:57 +02:00
46 changed files with 1334 additions and 77 deletions

No files matched your search

+2 -3
View File
@@ -22,8 +22,6 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
platform: 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 x86, os: windows-2022, flags: -AWin32 }
- { name: Windows VS2022 x64, os: windows-2022, flags: -Ax64 } - { name: Windows VS2022 x64, os: windows-2022, flags: -Ax64 }
- { name: Windows ClangCL, os: windows-2022, flags: -T ClangCL } - { name: Windows ClangCL, os: windows-2022, flags: -T ClangCL }
@@ -42,11 +40,12 @@ jobs:
- name: Get CMake and Ninja - name: Get CMake and Ninja
uses: lukka/get-cmake@latest uses: lukka/get-cmake@latest
with: with:
cmakeVersion: ${{ runner.os == 'Windows' && '3.25' || '3.22' }}
ninjaVersion: latest ninjaVersion: latest
- name: Install Linux Dependencies - name: Install Linux Dependencies
if: runner.os == 'Linux' if: runner.os == 'Linux'
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 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
- name: Checkout SFML - name: Checkout SFML
uses: actions/checkout@v4 uses: actions/checkout@v4
+2 -2
View File
@@ -79,7 +79,7 @@ jobs:
path: CSFML path: CSFML
- name: Build in an ARM container - name: Build in an ARM container
uses: uraimo/run-on-arch-action@v2.7.2 uses: uraimo/run-on-arch-action@v2.8.1
with: with:
arch: armv7 arch: armv7
distro: ubuntu22.04 distro: ubuntu22.04
@@ -111,7 +111,7 @@ jobs:
path: CSFML path: CSFML
- name: Build in an ARM64 container - name: Build in an ARM64 container
uses: uraimo/run-on-arch-action@v2.7.2 uses: uraimo/run-on-arch-action@v2.8.1
with: with:
arch: aarch64 arch: aarch64
distro: ubuntu22.04 distro: ubuntu22.04
+314
View File
@@ -0,0 +1,314 @@
name: Release Builds
on:
push:
branches:
- master
- 2.6.x
tags:
- "**"
workflow_dispatch: {}
concurrency:
group: release-${{github.ref}}
cancel-in-progress: true
jobs:
windows-x86:
name: Windows x86
runs-on: windows-2022
steps:
- name: Cache MinGW x86
id: mingw-x86-cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/mingw32
key: 14.2.0posix-19.1.1-12.0.0-ucrt-r2-x86
- 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.2.0posix-19.1.1-12.0.0-ucrt-r2
with_clang: false
architecture: 32
destination: ${{ github.workspace }}
add_to_path: false
- name: Checkout SFML
uses: actions/checkout@v4
with:
repository: SFML/SFML
ref: 3.0.0
path: SFML
- 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 17 2022" -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 CSFML
run: |
cmake -S CSFML -B CSFML-build -A Win32 -G "Visual Studio 17 2022" -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: 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"
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"
& 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"
& 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"
& 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"
& 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
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-windows-32-bit
path: install/CSFML
windows-x64:
name: Windows x64
runs-on: windows-2022
steps:
- name: Cache MinGW x64
id: mingw-x64-cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/mingw64
key: 14.2.0posix-19.1.1-12.0.0-ucrt-r2-x64
- 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.2.0posix-19.1.1-12.0.0-ucrt-r2
with_clang: false
architecture: 64
destination: ${{ github.workspace }}
add_to_path: false
- name: Checkout SFML
uses: actions/checkout@v4
with:
repository: SFML/SFML
ref: 3.0.0
path: SFML
- name: Checkout CSFML
uses: actions/checkout@v4
with:
path: CSFML
- name: Build SFML
run: |
cmake -S SFML -B SFML-build -A x64 -G "Visual Studio 17 2022" -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 CSFML
run: |
cmake -S CSFML -B CSFML-build -A x64 -G "Visual Studio 17 2022" -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: Add MinGW to PATH
shell: bash
run: echo "${{ github.workspace }}\mingw64\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"
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"
& 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"
& 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"
& 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"
& 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
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-windows-64-bit
path: install/CSFML
macos-x64:
name: macOS x64
runs-on: macos-13
steps:
- name: Checkout SFML
uses: actions/checkout@v4
with:
repository: SFML/SFML
ref: 3.0.0
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=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@v4
with:
name: CSFML-macOS-clang-64-bit
path: CSFML-macOS-clang-64-bit.tar.gz
macos-arm64:
name: macOS ARM64
runs-on: macos-14
steps:
- name: Checkout SFML
uses: actions/checkout@v4
with:
repository: SFML/SFML
ref: 3.0.0
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=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@v4
with:
name: CSFML-macOS-clang-arm64
path: CSFML-macOS-clang-arm64.tar.gz
+2 -2
View File
@@ -38,8 +38,8 @@ add_custom_target(doc ALL
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
DESTINATION ${INSTALL_MISC_DIR}/doc DESTINATION ${INSTALL_MISC_DIR}/doc
COMPONENT doc) COMPONENT doc)
if(DOXYGEN_HHC_PROGRAM) if(DOXYGEN_GENERATE_HTMLHELP)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CSFML.chm install(FILES ${DOXYGEN_OUTPUT_DIR}/CSFML.chm
DESTINATION ${INSTALL_MISC_DIR}/doc DESTINATION ${INSTALL_MISC_DIR}/doc
COMPONENT doc) COMPONENT doc)
endif() endif()
+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); 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 /// \brief Change the title of a render window
/// ///
+2 -2
View File
@@ -150,7 +150,7 @@ CSFML_GRAPHICS_API void sfVertexArray_setPrimitiveType(sfVertexArray* vertexArra
/// \return Primitive type /// \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 /// \brief Compute the bounding rectangle of a vertex array
@@ -163,4 +163,4 @@ CSFML_GRAPHICS_API sfPrimitiveType sfVertexArray_getPrimitiveType(sfVertexArray*
/// \return Bounding rectangle of the vertex array /// \return Bounding rectangle of the vertex array
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfVertexArray_getBounds(sfVertexArray* vertexArray); CSFML_GRAPHICS_API sfFloatRect sfVertexArray_getBounds(const sfVertexArray* vertexArray);
+1 -1
View File
@@ -166,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 /// \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 /// \brief Set the type of primitives to draw
+3 -3
View File
@@ -191,7 +191,7 @@ CSFML_GRAPHICS_API sfFloatRect sfView_getViewport(const sfView* view);
CSFML_GRAPHICS_API sfFloatRect sfView_getScissor(const sfView* view); CSFML_GRAPHICS_API sfFloatRect sfView_getScissor(const sfView* view);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Move a view relatively to its current position /// \brief Move a view relative to its current position
/// ///
/// \param view View object /// \param view View object
/// \param offset Offset /// \param offset Offset
@@ -200,7 +200,7 @@ CSFML_GRAPHICS_API sfFloatRect sfView_getScissor(const sfView* view);
CSFML_GRAPHICS_API void sfView_move(sfView* view, sfVector2f offset); 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 view View object
/// \param angle Angle to rotate, in degrees /// \param angle Angle to rotate, in degrees
@@ -209,7 +209,7 @@ CSFML_GRAPHICS_API void sfView_move(sfView* view, sfVector2f offset);
CSFML_GRAPHICS_API void sfView_rotate(sfView* view, float angle); 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 /// Resizing the view simulates a zoom, as the zone displayed on
/// screen grows or shrinks. /// screen grows or shrinks.
+1 -1
View File
@@ -132,7 +132,7 @@ CSFML_NETWORK_API void sfIpAddress_toString(sfIpAddress address, char* string);
/// address, and should be used for optimization purposes only /// address, and should be used for optimization purposes only
/// (like sending the address through a socket). /// (like sending the address through a socket).
/// The integer produced by this function can then be converted /// The integer produced by this function can then be converted
/// back to a sfIpAddress with sfIpAddress_FromInteger. /// back to a sfIpAddress with sfIpAddress_fromInteger.
/// ///
/// \param address Address object /// \param address Address object
/// ///
+6
View File
@@ -75,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 /// The next read operation will read data from this position
/// ///
/// \param packet Packet object
///
/// \return The byte offset of the current read position /// \return The byte offset of the current read position
/// ///
/// \see append /// \see append
@@ -163,6 +165,8 @@ CSFML_NETWORK_API int16_t sfPacket_readInt16(sfPacket* packet);
CSFML_NETWORK_API uint16_t sfPacket_readUint16(sfPacket* packet); CSFML_NETWORK_API uint16_t sfPacket_readUint16(sfPacket* packet);
CSFML_NETWORK_API int32_t sfPacket_readInt32(sfPacket* packet); CSFML_NETWORK_API int32_t sfPacket_readInt32(sfPacket* packet);
CSFML_NETWORK_API uint32_t sfPacket_readUint32(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 float sfPacket_readFloat(sfPacket* packet);
CSFML_NETWORK_API double sfPacket_readDouble(sfPacket* packet); CSFML_NETWORK_API double sfPacket_readDouble(sfPacket* packet);
CSFML_NETWORK_API void sfPacket_readString(sfPacket* packet, char* string); CSFML_NETWORK_API void sfPacket_readString(sfPacket* packet, char* string);
@@ -181,6 +185,8 @@ 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_writeUint16(sfPacket* packet, uint16_t);
CSFML_NETWORK_API void sfPacket_writeInt32(sfPacket* packet, int32_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_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_writeFloat(sfPacket* packet, float);
CSFML_NETWORK_API void sfPacket_writeDouble(sfPacket* packet, double); 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_writeString(sfPacket* packet, const char* string);
+24
View File
@@ -99,6 +99,10 @@ CSFML_NETWORK_API unsigned short sfTcpListener_getLocalPort(const sfTcpListener*
/// If the socket was previously listening to another port, /// If the socket was previously listening to another port,
/// it will be stopped first and bound to the new 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 /// If there is no specific address to listen to, pass sfIpAddress_Any
/// ///
/// \param listener TCP listener object /// \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); 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 /// \brief Accept a new connection
/// ///
@@ -127,3 +142,12 @@ CSFML_NETWORK_API sfSocketStatus sfTcpListener_listen(sfTcpListener* listener, u
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_NETWORK_API sfSocketStatus sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket** connected); CSFML_NETWORK_API sfSocketStatus sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket** connected);
////////////////////////////////////////////////////////////
/// \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);
+13
View File
@@ -102,6 +102,10 @@ CSFML_NETWORK_API unsigned short sfUdpSocket_getLocalPort(const sfUdpSocket* soc
/// system to automatically pick an available port, and then /// system to automatically pick an available port, and then
/// call sfUdpSocket_getLocalPort to retrieve the chosen port. /// 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 /// If there is no specific address to listen to, pass sfIpAddress_Any
/// ///
/// \param socket UDP socket object /// \param socket UDP socket object
@@ -215,3 +219,12 @@ CSFML_NETWORK_API sfSocketStatus
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_NETWORK_API unsigned int sfUdpSocket_maxDatagramSize(void); CSFML_NETWORK_API unsigned int sfUdpSocket_maxDatagramSize(void);
////////////////////////////////////////////////////////////
/// \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);
+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); 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 /// \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); 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 /// \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) - Lukas Dürrenberger (eXpl0it3r@sfml-dev.org)
- Chris Thrasher (thrasher@sfml-dev.org) - Chris Thrasher (thrasher@sfml-dev.org)
- Zachariah Brown (contact@zbrown.net) - Zachariah Brown (contact@zbrown.net)
- And many other members of the SFML community
## Download ## 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) void sfRenderWindow_setTitle(sfRenderWindow* renderWindow, const char* title)
{ {
+2 -2
View File
@@ -104,7 +104,7 @@ void sfVertexArray_setPrimitiveType(sfVertexArray* vertexArray, sfPrimitiveType
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfPrimitiveType sfVertexArray_getPrimitiveType(sfVertexArray* vertexArray) sfPrimitiveType sfVertexArray_getPrimitiveType(const sfVertexArray* vertexArray)
{ {
assert(vertexArray); assert(vertexArray);
return static_cast<sfPrimitiveType>(vertexArray->getPrimitiveType()); return static_cast<sfPrimitiveType>(vertexArray->getPrimitiveType());
@@ -112,7 +112,7 @@ sfPrimitiveType sfVertexArray_getPrimitiveType(sfVertexArray* vertexArray)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfFloatRect sfVertexArray_getBounds(sfVertexArray* vertexArray) sfFloatRect sfVertexArray_getBounds(const sfVertexArray* vertexArray)
{ {
assert(vertexArray); assert(vertexArray);
return convertRect(vertexArray->getBounds()); return convertRect(vertexArray->getBounds());
+1 -1
View File
@@ -92,7 +92,7 @@ void sfVertexBuffer_swap(sfVertexBuffer* left, sfVertexBuffer* right)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
unsigned int sfVertexBuffer_getNativeHandle(sfVertexBuffer* vertexBuffer) unsigned int sfVertexBuffer_getNativeHandle(const sfVertexBuffer* vertexBuffer)
{ {
assert(vertexBuffer); assert(vertexBuffer);
return vertexBuffer->getNativeHandle(); return vertexBuffer->getNativeHandle();
+1 -1
View File
@@ -48,7 +48,7 @@ namespace
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const sfIpAddress sfIpAddress_None = sfIpAddress_fromBytes(0, 0, 0, 0); const sfIpAddress sfIpAddress_None = {{0}};
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
+24
View File
@@ -156,6 +156,20 @@ uint32_t sfPacket_readUint32(sfPacket* packet)
*packet >> value; *packet >> value;
return value; return value;
} }
int64_t sfPacket_readInt64(sfPacket* packet)
{
assert(packet);
int64_t value = 0;
*packet >> value;
return value;
}
uint64_t sfPacket_readUint64(sfPacket* packet)
{
assert(packet);
uint64_t value = 0;
*packet >> value;
return value;
}
float sfPacket_readFloat(sfPacket* packet) float sfPacket_readFloat(sfPacket* packet)
{ {
assert(packet); assert(packet);
@@ -219,6 +233,16 @@ void sfPacket_writeUint32(sfPacket* packet, uint32_t value)
assert(packet); assert(packet);
*packet << value; *packet << value;
} }
void sfPacket_writeInt64(sfPacket* packet, int64_t value)
{
assert(packet);
*packet << value;
}
void sfPacket_writeUint64(sfPacket* packet, uint64_t value)
{
assert(packet);
*packet << value;
}
void sfPacket_writeFloat(sfPacket* packet, float value) void sfPacket_writeFloat(sfPacket* packet, float value)
{ {
assert(packet); assert(packet);
+15
View File
@@ -86,6 +86,14 @@ sfSocketStatus sfTcpListener_listen(sfTcpListener* listener, unsigned short port
} }
////////////////////////////////////////////////////////////
void sfTcpListener_close(sfTcpListener* listener)
{
assert(listener);
listener->close();
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfSocketStatus sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket** connected) sfSocketStatus sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket** connected)
{ {
@@ -102,3 +110,10 @@ sfSocketStatus sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket** conne
return status; return status;
} }
////////////////////////////////////////////////////////////
unsigned short sfTcpListener_anyPort()
{
return 0;
}
+7
View File
@@ -203,3 +203,10 @@ unsigned int sfUdpSocket_maxDatagramSize()
{ {
return sf::UdpSocket::MaxDatagramSize; return sf::UdpSocket::MaxDatagramSize;
} }
////////////////////////////////////////////////////////////
unsigned short sfUdpSocket_anyPort()
{
return 0;
}
+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) void sfWindow_setTitle(sfWindow* window, const char* title)
{ {
+34
View File
@@ -34,6 +34,8 @@
#include <SFML/Window/VideoMode.hpp> #include <SFML/Window/VideoMode.hpp>
#include <optional>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfWindowBase* sfWindowBase_create(sfVideoMode mode, const char* title, uint32_t style, sfWindowState state) 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) void sfWindowBase_setTitle(sfWindowBase* windowBase, const char* title)
{ {
+9 -1
View File
@@ -48,11 +48,19 @@ add_executable(test-csfml-graphics
Graphics/BlendMode.test.cpp Graphics/BlendMode.test.cpp
Graphics/Color.test.cpp Graphics/Color.test.cpp
Graphics/CoordinateType.test.cpp Graphics/CoordinateType.test.cpp
Graphics/PrimitiveType.test.cpp
Graphics/Rect.test.cpp Graphics/Rect.test.cpp
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) target_link_libraries(test-csfml-graphics PRIVATE csfml-graphics Catch2::Catch2WithMain SFML::Graphics)
set_target_warnings(test-csfml-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 add_executable(test-csfml-network
Network/Ftp.test.cpp Network/Ftp.test.cpp
-7
View File
@@ -31,13 +31,6 @@ TEST_CASE("[Graphics] sfBlendMode")
SECTION("Construction") SECTION("Construction")
{ {
// 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
constexpr sfBlendMode blendMode{}; constexpr sfBlendMode blendMode{};
STATIC_CHECK(blendMode.colorSrcFactor == sfBlendFactorZero); STATIC_CHECK(blendMode.colorSrcFactor == sfBlendFactorZero);
STATIC_CHECK(blendMode.colorDstFactor == sfBlendFactorZero); STATIC_CHECK(blendMode.colorDstFactor == sfBlendFactorZero);
+15
View File
@@ -0,0 +1,15 @@
#include <CSFML/Graphics/PrimitiveType.h>
#include <SFML/Graphics/PrimitiveType.hpp>
#include <catch2/catch_test_macros.hpp>
TEST_CASE("[Graphics] sfPrimitiveType")
{
STATIC_CHECK(sfPoints == static_cast<int>(sf::PrimitiveType::Points));
STATIC_CHECK(sfLines == static_cast<int>(sf::PrimitiveType::Lines));
STATIC_CHECK(sfLineStrip == static_cast<int>(sf::PrimitiveType::LineStrip));
STATIC_CHECK(sfTriangles == static_cast<int>(sf::PrimitiveType::Triangles));
STATIC_CHECK(sfTriangleStrip == static_cast<int>(sf::PrimitiveType::TriangleStrip));
STATIC_CHECK(sfTriangleFan == static_cast<int>(sf::PrimitiveType::TriangleFan));
}
+41
View File
@@ -0,0 +1,41 @@
#include <CSFML/Graphics/RenderStates.h>
#include <SFML/Graphics/RenderStates.hpp>
#include <catch2/catch_test_macros.hpp>
#include "CSFML/Graphics/CoordinateType.h"
TEST_CASE("[Graphics] sfRenderStates")
{
SECTION("Construction")
{
constexpr sfRenderStates renderStates{};
STATIC_CHECK(renderStates.blendMode.colorSrcFactor == sfBlendFactorZero);
STATIC_CHECK(renderStates.blendMode.colorDstFactor == sfBlendFactorZero);
STATIC_CHECK(renderStates.blendMode.colorEquation == sfBlendEquationAdd);
STATIC_CHECK(renderStates.blendMode.alphaSrcFactor == sfBlendFactorZero);
STATIC_CHECK(renderStates.blendMode.alphaDstFactor == sfBlendFactorZero);
STATIC_CHECK(renderStates.blendMode.alphaEquation == sfBlendEquationAdd);
STATIC_CHECK(renderStates.stencilMode.stencilComparison == sfStencilComparisonNever);
STATIC_CHECK(renderStates.stencilMode.stencilUpdateOperation == sfStencilUpdateOperationKeep);
STATIC_CHECK(renderStates.stencilMode.stencilReference.value == 0);
STATIC_CHECK(renderStates.stencilMode.stencilMask.value == 0);
STATIC_CHECK(!renderStates.stencilMode.stencilOnly);
for (const auto element : renderStates.transform.matrix)
CHECK(element == 0);
STATIC_CHECK(renderStates.coordinateType == sfCoordinateTypeNormalized);
STATIC_CHECK(renderStates.texture == nullptr);
STATIC_CHECK(renderStates.shader == nullptr);
}
SECTION("sfRenderStates_default")
{
CHECK(sfRenderStates_default.blendMode.alphaDstFactor == sfBlendAlpha.alphaDstFactor);
CHECK(sfRenderStates_default.blendMode.colorDstFactor == sfBlendAlpha.colorDstFactor);
CHECK(sfRenderStates_default.blendMode.colorEquation == sfBlendAlpha.colorEquation);
CHECK(sfRenderStates_default.blendMode.alphaSrcFactor == sfBlendAlpha.alphaSrcFactor);
CHECK(sfRenderStates_default.blendMode.alphaDstFactor == sfBlendAlpha.alphaDstFactor);
CHECK(sfRenderStates_default.blendMode.alphaEquation == sfBlendAlpha.alphaEquation);
}
}
+107
View File
@@ -0,0 +1,107 @@
#include <CSFML/Graphics/Shape.h>
#include <catch2/catch_test_macros.hpp>
TEST_CASE("[Graphics] sfShape")
{
const auto getPointCount = [](void* userData) -> std::size_t
{ return static_cast<std::vector<sfVector2f>*>(userData)->size(); };
const auto getPoint = [](std::size_t index, void* userData) -> sfVector2f
{ return static_cast<std::vector<sfVector2f>*>(userData)->operator[](index); };
std::vector<sfVector2f> points = {{0, 0}, {30, 0}, {0, 30}};
SECTION("sfShape_create")
{
const sfShape* shape = sfShape_create(getPointCount, getPoint, &points);
const sfVector2f position = sfShape_getPosition(shape);
CHECK(position.x == 0);
CHECK(position.y == 0);
CHECK(sfShape_getRotation(shape) == 0);
const sfVector2f scale = sfShape_getScale(shape);
CHECK(scale.x == 1);
CHECK(scale.y == 1);
const sfVector2f origin = sfShape_getOrigin(shape);
CHECK(origin.x == 0);
CHECK(origin.y == 0);
const sfTransform transform = sfShape_getTransform(shape);
const std::vector matrix(std::data(transform.matrix), std::data(transform.matrix) + std::size(transform.matrix));
CHECK(matrix == std::vector<float>({1, 0, 0, 0, 1, 0, 0, 0, 1}));
const sfTransform inverseTransform = sfShape_getInverseTransform(shape);
const std::vector inverseMatrix(std::data(inverseTransform.matrix),
std::data(inverseTransform.matrix) + std::size(inverseTransform.matrix));
CHECK(inverseMatrix == std::vector<float>({1, 0, 0, 0, 1, 0, 0, 0, 1}));
CHECK(sfShape_getTexture(shape) == nullptr);
const sfIntRect textureRect = sfShape_getTextureRect(shape);
CHECK(textureRect.position.x == 0);
CHECK(textureRect.position.y == 0);
CHECK(textureRect.size.x == 0);
CHECK(textureRect.size.y == 0);
const sfColor fillColor = sfShape_getFillColor(shape);
CHECK(fillColor.r == sfWhite.r);
CHECK(fillColor.g == sfWhite.g);
CHECK(fillColor.b == sfWhite.b);
CHECK(fillColor.a == sfWhite.a);
const sfColor outlineColor = sfShape_getOutlineColor(shape);
CHECK(outlineColor.r == sfWhite.r);
CHECK(outlineColor.g == sfWhite.g);
CHECK(outlineColor.b == sfWhite.b);
CHECK(outlineColor.a == sfWhite.a);
CHECK(sfShape_getOutlineThickness(shape) == 0);
CHECK(sfShape_getPointCount(shape) == 3);
const sfVector2f point = sfShape_getPoint(shape, 0);
CHECK(point.x == 0);
CHECK(point.y == 0);
const sfVector2f geometricCenter = sfShape_getGeometricCenter(shape);
CHECK(geometricCenter.x == 10);
CHECK(geometricCenter.y == 10);
const sfFloatRect localBounds = sfShape_getLocalBounds(shape);
CHECK(localBounds.position.x == 0);
CHECK(localBounds.position.y == 0);
CHECK(localBounds.size.x == 0);
CHECK(localBounds.size.y == 0);
const sfFloatRect globalBounds = sfShape_getGlobalBounds(shape);
CHECK(globalBounds.position.x == 0);
CHECK(globalBounds.position.y == 0);
CHECK(globalBounds.size.x == 0);
CHECK(globalBounds.size.y == 0);
sfShape_destroy(shape);
}
SECTION("Set/get position")
{
sfShape* shape = sfShape_create(getPointCount, getPoint, &points);
sfShape_setPosition(shape, {10, 20});
const sfVector2f position = sfShape_getPosition(shape);
CHECK(position.x == 10);
CHECK(position.y == 20);
sfShape_destroy(shape);
}
SECTION("Set/get rotation")
{
sfShape* shape = sfShape_create(getPointCount, getPoint, &points);
sfShape_setRotation(shape, 45);
CHECK(sfShape_getRotation(shape) == 45);
sfShape_destroy(shape);
}
SECTION("Set/get scale")
{
sfShape* shape = sfShape_create(getPointCount, getPoint, &points);
sfShape_setScale(shape, {0.5f, 0.75f});
const sfVector2f scale = sfShape_getScale(shape);
CHECK(scale.x == 0.5f);
CHECK(scale.y == 0.75f);
sfShape_destroy(shape);
}
SECTION("Set/get origin")
{
sfShape* shape = sfShape_create(getPointCount, getPoint, &points);
sfShape_setOrigin(shape, {80, 90});
const sfVector2f origin = sfShape_getOrigin(shape);
CHECK(origin.x == 80);
CHECK(origin.y == 90);
sfShape_destroy(shape);
}
}
+55
View File
@@ -0,0 +1,55 @@
#include <CSFML/Graphics/StencilMode.h>
#include <SFML/Graphics/StencilMode.hpp>
#include <catch2/catch_test_macros.hpp>
TEST_CASE("[Graphics] sfStencilMode")
{
SECTION("sfStencilComparison")
{
STATIC_CHECK(sfStencilComparisonNever == static_cast<int>(sf::StencilComparison::Never));
STATIC_CHECK(sfStencilComparisonLess == static_cast<int>(sf::StencilComparison::Less));
STATIC_CHECK(sfStencilComparisonLessEqual == static_cast<int>(sf::StencilComparison::LessEqual));
STATIC_CHECK(sfStencilComparisonGreater == static_cast<int>(sf::StencilComparison::Greater));
STATIC_CHECK(sfStencilComparisonGreaterEqual == static_cast<int>(sf::StencilComparison::GreaterEqual));
STATIC_CHECK(sfStencilComparisonEqual == static_cast<int>(sf::StencilComparison::Equal));
STATIC_CHECK(sfStencilComparisonNotEqual == static_cast<int>(sf::StencilComparison::NotEqual));
STATIC_CHECK(sfStencilComparisonAlways == static_cast<int>(sf::StencilComparison::Always));
}
SECTION("sfStencilUpdateOperation")
{
STATIC_CHECK(sfStencilUpdateOperationKeep == static_cast<int>(sf::StencilUpdateOperation::Keep));
STATIC_CHECK(sfStencilUpdateOperationZero == static_cast<int>(sf::StencilUpdateOperation::Zero));
STATIC_CHECK(sfStencilUpdateOperationReplace == static_cast<int>(sf::StencilUpdateOperation::Replace));
STATIC_CHECK(sfStencilUpdateOperationIncrement == static_cast<int>(sf::StencilUpdateOperation::Increment));
STATIC_CHECK(sfStencilUpdateOperationDecrement == static_cast<int>(sf::StencilUpdateOperation::Decrement));
STATIC_CHECK(sfStencilUpdateOperationInvert == static_cast<int>(sf::StencilUpdateOperation::Invert));
}
SECTION("sfStencilValue")
{
constexpr sfStencilValue stencilValue{};
STATIC_CHECK(stencilValue.value == 0);
}
SECTION("sfStencilMode")
{
constexpr sfStencilMode stencilMode{};
STATIC_CHECK(stencilMode.stencilComparison == sfStencilComparisonNever);
STATIC_CHECK(stencilMode.stencilUpdateOperation == sfStencilUpdateOperationKeep);
STATIC_CHECK(stencilMode.stencilReference.value == 0);
STATIC_CHECK(stencilMode.stencilMask.value == 0);
STATIC_CHECK(!stencilMode.stencilOnly);
}
SECTION("sfStencilMode_default")
{
CHECK(sfStencilMode_default.stencilComparison == sfStencilComparisonAlways);
CHECK(sfStencilMode_default.stencilUpdateOperation == sfStencilUpdateOperationKeep);
CHECK(sfStencilMode_default.stencilReference.value == 0);
CHECK(sfStencilMode_default.stencilMask.value == ~0u);
CHECK(!sfStencilMode_default.stencilOnly);
}
}
+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);
}
}
+128
View File
@@ -0,0 +1,128 @@
#include <CSFML/Graphics/Transform.h>
#include <catch2/catch_test_macros.hpp>
#include <array>
TEST_CASE("[Graphics] sfTransform")
{
SECTION("Construction")
{
constexpr sfTransform transform{};
STATIC_CHECK(std::size(transform.matrix) == 9);
for (const auto element : transform.matrix)
CHECK(element == 0);
}
SECTION("sfTransform_Identity")
{
CHECK(sfTransform_Identity.matrix[0] == 1);
CHECK(sfTransform_Identity.matrix[1] == 0);
CHECK(sfTransform_Identity.matrix[2] == 0);
CHECK(sfTransform_Identity.matrix[3] == 0);
CHECK(sfTransform_Identity.matrix[4] == 1);
CHECK(sfTransform_Identity.matrix[5] == 0);
CHECK(sfTransform_Identity.matrix[6] == 0);
CHECK(sfTransform_Identity.matrix[7] == 0);
CHECK(sfTransform_Identity.matrix[8] == 1);
}
SECTION("sfTransform_fromMatrix")
{
const auto transform = sfTransform_fromMatrix(1, 2, 3, 4, 5, 6, 7, 8, 9);
CHECK(transform.matrix[0] == 1);
CHECK(transform.matrix[1] == 2);
CHECK(transform.matrix[2] == 3);
CHECK(transform.matrix[3] == 4);
CHECK(transform.matrix[4] == 5);
CHECK(transform.matrix[5] == 6);
CHECK(transform.matrix[6] == 7);
CHECK(transform.matrix[7] == 8);
CHECK(transform.matrix[8] == 9);
}
SECTION("sfTransform_getMatrix")
{
const auto transform = sfTransform_fromMatrix(1, 2, 3, 4, 5, 6, 7, 8, 9);
std::array<float, 16> matrix{};
matrix.fill(std::numeric_limits<float>::signaling_NaN());
sfTransform_getMatrix(&transform, matrix.data());
CHECK(matrix[0] == 1);
CHECK(matrix[1] == 4);
CHECK(matrix[2] == 0);
CHECK(matrix[3] == 7);
CHECK(matrix[4] == 2);
CHECK(matrix[5] == 5);
CHECK(matrix[6] == 0);
CHECK(matrix[7] == 8);
CHECK(matrix[8] == 0);
CHECK(matrix[9] == 0);
CHECK(matrix[10] == 1);
CHECK(matrix[11] == 0);
CHECK(matrix[12] == 3);
CHECK(matrix[13] == 6);
CHECK(matrix[14] == 0);
CHECK(matrix[15] == 9);
}
SECTION("sfTransform_getInverse")
{
SECTION("Identity")
{
const auto inverse = sfTransform_getInverse(&sfTransform_Identity);
for (std::size_t i = 0; i < std::size(inverse.matrix); ++i)
CHECK(inverse.matrix[0] == sfTransform_Identity.matrix[0]);
}
SECTION("Non-identity")
{
const auto transform = sfTransform_fromMatrix(1, 2, 3, 4, 5, 4, 3, 2, 1);
const auto inverse = sfTransform_getInverse(&transform);
CHECK(inverse.matrix[0] == 0.375f);
CHECK(inverse.matrix[1] == -0.5f);
CHECK(inverse.matrix[2] == 0.875f);
CHECK(inverse.matrix[3] == -1);
CHECK(inverse.matrix[4] == 1);
CHECK(inverse.matrix[5] == -1);
CHECK(inverse.matrix[6] == 0.875f);
CHECK(inverse.matrix[7] == -0.5f);
CHECK(inverse.matrix[8] == 0.375f);
}
}
SECTION("sfTransform_transformPoint")
{
}
SECTION("sfTransform_transformRect")
{
}
SECTION("sfTransform_combine")
{
}
SECTION("sfTransform_translate")
{
}
SECTION("sfTransform_rotate")
{
}
SECTION("sfTransform_rotateWithCenter")
{
}
SECTION("sfTransform_scale")
{
}
SECTION("sfTransform_scaleWithCenter")
{
}
SECTION("sfTransform_equal")
{
}
}
+116
View File
@@ -0,0 +1,116 @@
#include <CSFML/Graphics/VertexArray.h>
#include <catch2/catch_test_macros.hpp>
TEST_CASE("[Graphics] sfVertexArray")
{
SECTION("sfVertexArray_create")
{
const sfVertexArray* vertexArray = sfVertexArray_create();
CHECK(sfVertexArray_getVertexCount(vertexArray) == 0);
CHECK(sfVertexArray_getPrimitiveType(vertexArray) == sfPoints);
const sfFloatRect bounds = sfVertexArray_getBounds(vertexArray);
CHECK(bounds.position.x == 0);
CHECK(bounds.position.y == 0);
CHECK(bounds.size.x == 0);
CHECK(bounds.size.y == 0);
sfVertexArray_destroy(vertexArray);
}
SECTION("sfVertexArray_copy")
{
sfVertexArray* vertexArray1 = sfVertexArray_create();
sfVertexArray_resize(vertexArray1, 10);
sfVertexArray_setPrimitiveType(vertexArray1, sfLines);
const sfVertexArray* vertexArray2 = sfVertexArray_copy(vertexArray1);
CHECK(sfVertexArray_getVertexCount(vertexArray2) == 10);
CHECK(sfVertexArray_getPrimitiveType(vertexArray2) == sfLines);
sfVertexArray_destroy(vertexArray2);
sfVertexArray_destroy(vertexArray1);
}
SECTION("sfVertexArray_resize")
{
sfVertexArray* vertexArray = sfVertexArray_create();
sfVertexArray_resize(vertexArray, 42);
const auto vertexCount = sfVertexArray_getVertexCount(vertexArray);
CHECK(vertexCount == 42);
for (std::size_t i = 0; i < vertexCount; ++i)
{
const auto& vertex = *sfVertexArray_getVertex(vertexArray, i);
CHECK(vertex.position.x == 0);
CHECK(vertex.position.y == 0);
CHECK(+vertex.color.r == sfWhite.r);
CHECK(+vertex.color.g == sfWhite.g);
CHECK(+vertex.color.b == sfWhite.b);
CHECK(+vertex.color.a == sfWhite.a);
CHECK(vertex.texCoords.x == 0);
CHECK(vertex.texCoords.y == 0);
}
sfVertexArray_destroy(vertexArray);
}
SECTION("sfVertexArray_clear")
{
sfVertexArray* vertexArray = sfVertexArray_create();
sfVertexArray_resize(vertexArray, 13);
sfVertexArray_setPrimitiveType(vertexArray, sfLines);
sfVertexArray_clear(vertexArray);
CHECK(sfVertexArray_getVertexCount(vertexArray) == 0);
CHECK(sfVertexArray_getPrimitiveType(vertexArray) == sfLines);
sfVertexArray_destroy(vertexArray);
}
SECTION("sfVertexArray_append")
{
sfVertexArray* vertexArray = sfVertexArray_create();
sfVertexArray_append(vertexArray, {{1, 2}, {3, 4, 5, 6}, {7, 8}});
CHECK(sfVertexArray_getVertexCount(vertexArray) == 1);
const auto& vertex = *sfVertexArray_getVertex(vertexArray, 0);
CHECK(vertex.position.x == 1);
CHECK(vertex.position.y == 2);
CHECK(+vertex.color.r == 3);
CHECK(+vertex.color.g == 4);
CHECK(+vertex.color.b == 5);
CHECK(+vertex.color.a == 6);
CHECK(vertex.texCoords.x == 7);
CHECK(vertex.texCoords.y == 8);
sfVertexArray_destroy(vertexArray);
}
SECTION("sfVertexArray_getBounds")
{
sfVertexArray* vertexArray = sfVertexArray_create();
sfVertexArray_append(vertexArray, {{1, 1}, {}, {}});
sfVertexArray_append(vertexArray, {{2, 2}, {}, {}});
sfFloatRect bounds = sfVertexArray_getBounds(vertexArray);
CHECK(bounds.position.x == 1);
CHECK(bounds.position.y == 1);
CHECK(bounds.size.x == 1);
CHECK(bounds.size.y == 1);
*sfVertexArray_getVertex(vertexArray, 0) = {{0, 0}, {}, {}};
bounds = sfVertexArray_getBounds(vertexArray);
CHECK(bounds.position.x == 0);
CHECK(bounds.position.y == 0);
CHECK(bounds.size.x == 2);
CHECK(bounds.size.y == 2);
*sfVertexArray_getVertex(vertexArray, 0) = {{5, 5}, {}, {}};
bounds = sfVertexArray_getBounds(vertexArray);
CHECK(bounds.position.x == 2);
CHECK(bounds.position.y == 2);
CHECK(bounds.size.x == 3);
CHECK(bounds.size.y == 3);
sfVertexArray_append(vertexArray, {{10, 10}, {}, {}});
bounds = sfVertexArray_getBounds(vertexArray);
CHECK(bounds.position.x == 2);
CHECK(bounds.position.y == 2);
CHECK(bounds.size.x == 8);
CHECK(bounds.size.y == 8);
sfVertexArray_destroy(vertexArray);
}
}
+157
View File
@@ -0,0 +1,157 @@
#include <CSFML/Graphics/View.h>
#include <catch2/catch_test_macros.hpp>
TEST_CASE("[Graphics] sfView")
{
SECTION("sfView_create")
{
const sfView* view = sfView_create();
const sfVector2f center = sfView_getCenter(view);
CHECK(center.x == 500);
CHECK(center.y == 500);
const sfVector2f size = sfView_getSize(view);
CHECK(size.x == 1000);
CHECK(size.y == 1000);
CHECK(sfView_getRotation(view) == 0);
const sfFloatRect viewport = sfView_getViewport(view);
CHECK(viewport.position.x == 0);
CHECK(viewport.position.y == 0);
CHECK(viewport.size.x == 1);
CHECK(viewport.size.y == 1);
const sfFloatRect scissor = sfView_getScissor(view);
CHECK(scissor.position.x == 0);
CHECK(scissor.position.y == 0);
CHECK(scissor.size.x == 1);
CHECK(scissor.size.y == 1);
sfView_destroy(view);
}
SECTION("sfView_createFromRect")
{
const sfView* view = sfView_createFromRect({{50, 100}, {240, 360}});
const sfVector2f center = sfView_getCenter(view);
CHECK(center.x == 170);
CHECK(center.y == 280);
const sfVector2f size = sfView_getSize(view);
CHECK(size.x == 240);
CHECK(size.y == 360);
CHECK(sfView_getRotation(view) == 0);
const sfFloatRect viewport = sfView_getViewport(view);
CHECK(viewport.position.x == 0);
CHECK(viewport.position.y == 0);
CHECK(viewport.size.x == 1);
CHECK(viewport.size.y == 1);
const sfFloatRect scissor = sfView_getScissor(view);
CHECK(scissor.position.x == 0);
CHECK(scissor.position.y == 0);
CHECK(scissor.size.x == 1);
CHECK(scissor.size.y == 1);
sfView_destroy(view);
}
SECTION("sfView_copy")
{
sfView* view1 = sfView_createFromRect({{50, 100}, {240, 360}});
sfView_setViewport(view1, {{25, 40}, {100, 200}});
sfView_setScissor(view1, {{0.75f, 0.25f}, {0, 0.5f}});
const sfView* view2 = sfView_copy(view1);
const sfVector2f center = sfView_getCenter(view2);
CHECK(center.x == 170);
CHECK(center.y == 280);
const sfVector2f size = sfView_getSize(view2);
CHECK(size.x == 240);
CHECK(size.y == 360);
CHECK(sfView_getRotation(view2) == 0);
const sfFloatRect viewport = sfView_getViewport(view2);
CHECK(viewport.position.x == 25);
CHECK(viewport.position.y == 40);
CHECK(viewport.size.x == 100);
CHECK(viewport.size.y == 200);
const sfFloatRect scissor = sfView_getScissor(view2);
CHECK(scissor.position.x == 0.75f);
CHECK(scissor.position.y == 0.25f);
CHECK(scissor.size.x == 0);
CHECK(scissor.size.y == 0.5f);
sfView_destroy(view2);
sfView_destroy(view1);
}
SECTION("sfView_setCenter")
{
sfView* view = sfView_create();
sfView_setCenter(view, {400, 600});
const sfVector2f center = sfView_getCenter(view);
CHECK(center.x == 400);
CHECK(center.y == 600);
sfView_destroy(view);
}
SECTION("sfView_setSize")
{
sfView* view = sfView_create();
sfView_setSize(view, {150, 350});
const sfVector2f size = sfView_getSize(view);
CHECK(size.x == 150);
CHECK(size.y == 350);
sfView_destroy(view);
}
SECTION("sfView_setRotation")
{
sfView* view = sfView_create();
sfView_setRotation(view, 45);
CHECK(sfView_getRotation(view) == 45);
sfView_destroy(view);
}
SECTION("sfView_setViewport")
{
sfView* view = sfView_create();
sfView_setViewport(view, {{25, 40}, {100, 200}});
const sfFloatRect viewport = sfView_getViewport(view);
CHECK(viewport.position.x == 25);
CHECK(viewport.position.y == 40);
CHECK(viewport.size.x == 100);
CHECK(viewport.size.y == 200);
sfView_destroy(view);
}
SECTION("sfView_setScissor")
{
sfView* view = sfView_create();
sfView_setScissor(view, {{0.75f, 0.25f}, {0, 0.5f}});
const sfFloatRect scissor = sfView_getScissor(view);
CHECK(scissor.position.x == 0.75f);
CHECK(scissor.position.y == 0.25f);
CHECK(scissor.size.x == 0);
CHECK(scissor.size.y == 0.5f);
sfView_destroy(view);
}
SECTION("sfView_move, sfView_rotate, sfView_zoom")
{
sfView* view = sfView_create();
sfView_move(view, {15, 35});
sfView_rotate(view, 180);
sfView_zoom(view, 2);
const sfVector2f center = sfView_getCenter(view);
CHECK(center.x == 515);
CHECK(center.y == 535);
const sfVector2f size = sfView_getSize(view);
CHECK(size.x == 2000);
CHECK(size.y == 2000);
CHECK(sfView_getRotation(view) == 180);
const sfFloatRect viewport = sfView_getViewport(view);
CHECK(viewport.position.x == 0);
CHECK(viewport.position.y == 0);
CHECK(viewport.size.x == 1);
CHECK(viewport.size.y == 1);
const sfFloatRect scissor = sfView_getScissor(view);
CHECK(scissor.position.x == 0);
CHECK(scissor.position.y == 0);
CHECK(scissor.size.x == 1);
CHECK(scissor.size.y == 1);
sfView_destroy(view);
}
}
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.
+9 -1
View File
@@ -2,6 +2,8 @@
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include <cstring>
TEST_CASE("[Network] sfIpAddress") TEST_CASE("[Network] sfIpAddress")
{ {
SECTION("Constants") SECTION("Constants")
@@ -10,12 +12,18 @@ TEST_CASE("[Network] sfIpAddress")
CHECK(sfIpAddress_toInteger(sfIpAddress_Any) == 0); CHECK(sfIpAddress_toInteger(sfIpAddress_Any) == 0);
CHECK(sfIpAddress_toInteger(sfIpAddress_LocalHost) == 0x7F000001); CHECK(sfIpAddress_toInteger(sfIpAddress_LocalHost) == 0x7F000001);
CHECK(sfIpAddress_toInteger(sfIpAddress_Broadcast) == 0xFFFFFFFF); CHECK(sfIpAddress_toInteger(sfIpAddress_Broadcast) == 0xFFFFFFFF);
CHECK(std::strcmp(sfIpAddress_None.address, "") == 0);
CHECK(std::strcmp(sfIpAddress_Any.address, "0.0.0.0") == 0);
CHECK(std::strcmp(sfIpAddress_LocalHost.address, "127.0.0.1") == 0);
CHECK(std::strcmp(sfIpAddress_Broadcast.address, "255.255.255.255") == 0);
} }
SECTION("sfIpAddress_fromString") SECTION("sfIpAddress_fromString")
{ {
CHECK(sfIpAddress_toInteger(sfIpAddress_fromString("")) == 0); 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("192.168.0.1")) == 0xC0A80001);
CHECK(sfIpAddress_toInteger(sfIpAddress_fromString("8.8.8.8")) == 0x08080808); CHECK(sfIpAddress_toInteger(sfIpAddress_fromString("8.8.8.8")) == 0x08080808);
} }
+2 -2
View File
@@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
VERSION="2.6.1" VERSION="3.0.0"
VERSION_C="2.6.0" VERSION_C="3.0.0"
# BUILD_CSFML=FALSE # BUILD_CSFML=FALSE
BUILD_CSFML=TRUE BUILD_CSFML=TRUE
BUILD_SFML=FALSE BUILD_SFML=FALSE
+3 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>3.0.0</Version> <Version>3.0.0-rc.2</Version>
<Authors>Laurent Gomila</Authors> <Authors>Laurent Gomila</Authors>
<PackageTags>sfml csfml</PackageTags> <PackageTags>sfml csfml</PackageTags>
<Copyright>Copyright © Laurent Gomila</Copyright> <Copyright>Copyright © Laurent Gomila</Copyright>
@@ -13,6 +13,7 @@
<PackageProjectUrl>https://www.sfml-dev.org/</PackageProjectUrl> <PackageProjectUrl>https://www.sfml-dev.org/</PackageProjectUrl>
<PackageIconUrl>https://www.sfml-dev.org/images/sfml-icon.png</PackageIconUrl> <PackageIconUrl>https://www.sfml-dev.org/images/sfml-icon.png</PackageIconUrl>
<PackageIcon>sfml-icon.png</PackageIcon> <PackageIcon>sfml-icon.png</PackageIcon>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl> <PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeBuildOutput>false</IncludeBuildOutput> <IncludeBuildOutput>false</IncludeBuildOutput>
@@ -31,6 +32,7 @@
<None Pack="True" Include="runtimes/**" PackagePath="runtimes" /> <None Pack="True" Include="runtimes/**" PackagePath="runtimes" />
<None Pack="True" Include="build/**" PackagePath="build" /> <None Pack="True" Include="build/**" PackagePath="build" />
<None Pack="True" Include="sfml-icon.png" PackagePath="/" /> <None Pack="True" Include="sfml-icon.png" PackagePath="/" />
<None Pack="True" Include="readme.md" PackagePath="/" />
</ItemGroup> </ItemGroup>
</Project> </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.
+1 -1
View File
@@ -42,7 +42,7 @@ echo "Please note that all SFML dependencies must be installed and available to
RID="$1" RID="$1"
SFMLBranch="master" # The branch or tag of the SFML repository to be cloned SFMLBranch="3.0.0" # The branch or tag of the SFML repository to be cloned
CSFMLDir="$(realpath ../../)" # The directory of the source code of CSFML CSFMLDir="$(realpath ../../)" # The directory of the source code of CSFML
OutDir="./CSFML/runtimes/$RID/native" # The base directory of all CSFML modules, used to copy the final libraries OutDir="./CSFML/runtimes/$RID/native" # The base directory of all CSFML modules, used to copy the final libraries
+4 -33
View File
@@ -46,7 +46,7 @@ echo "Please note that all SFML dependencies must be installed and available to
RID="$1" RID="$1"
SFMLBranch="master" # The branch or tag of the SFML repository to be cloned SFMLBranch="3.0.0" # The branch or tag of the SFML repository to be cloned
CSFMLDir="$(grealpath "$(git rev-parse --show-toplevel)")" # The directory of the source code of CSFML CSFMLDir="$(grealpath "$(git rev-parse --show-toplevel)")" # The directory of the source code of CSFML
OutDir="./CSFML/runtimes/$RID/native" # The base directory of all CSFML modules, used to copy the final libraries OutDir="./CSFML/runtimes/$RID/native" # The base directory of all CSFML modules, used to copy the final libraries
@@ -146,39 +146,12 @@ cmake -E env \
"$CSFMLDir" "$CSFMLDir"
cmake --build . --config Release --target install cmake --build . --config Release --target install
# ============================ # # ======================================== #
# STEP 5: Fix RPATH references # # STEP 5: Copy result to the NuGet folders #
# ============================ # # ======================================== #
SFMLMajorMinor="3.0" SFMLMajorMinor="3.0"
SFMLMajorMinorPatch="$SFMLMajorMinor.0" SFMLMajorMinorPatch="$SFMLMajorMinor.0"
# SFML's framework dependencies will always reference @rpath/../Frameworks/<depedency>
# Which is not where we place the frameworks and where SFML should look for them
# This this fixes the dependency with install_name_tool
fixrpath()
{
MODULE="$1"
OLD="$2"
NEW="$3"
install_name_tool -change $OLD $NEW "$SFMLLibDir/libsfml-$MODULE.dylib"
install_name_tool -change $OLD $NEW "$SFMLLibDir/libsfml-$MODULE.$SFMLMajorMinor.dylib"
install_name_tool -change $OLD $NEW "$SFMLLibDir/libsfml-$MODULE.$SFMLMajorMinorPatch.dylib"
}
fixrpath audio "@rpath/../Frameworks/vorbisenc.framework/Versions/A/vorbisenc" "@rpath/vorbisenc.framework/Versions/A/vorbisen"
fixrpath audio "@rpath/../Frameworks/vorbisfile.framework/Versions/A/vorbisfile" "@rpath/vorbisfile.framework/Versions/A/vorbisfile"
fixrpath audio "@rpath/../Frameworks/vorbis.framework/Versions/A/vorbis" "@rpath/vorbis.framework/Versions/A/vorbis"
fixrpath audio "@rpath/../Frameworks/ogg.framework/Versions/A/ogg" "@rpath/ogg.framework/Versions/A/ogg"
fixrpath audio "@rpath/../Frameworks/FLAC.framework/Versions/A/FLAC" "@rpath/FLAC.framework/Versions/A/FLAC"
fixrpath graphics "@rpath/../Frameworks/freetype.framework/Versions/A/freetype" "@rpath/freetype.framework/Versions/A/freetype"
# ======================================== #
# STEP 6: Copy result to the NuGet folders #
# ======================================== #
CSFMLMajorMinor="3.0" CSFMLMajorMinor="3.0"
CSFMLMajorMinorPatch="$CSFMLMajorMinor.0" CSFMLMajorMinorPatch="$CSFMLMajorMinor.0"
@@ -208,8 +181,6 @@ copymodule graphics
copymodule system copymodule system
copymodule window copymodule window
cp -R "$SFMLLibDir/lib/"*.framework "$OutDir"
popd # Pop CSFML popd # Pop CSFML
popd # Pop $RID popd # Pop $RID
popd # Pop Build popd # Pop Build
+4 -13
View File
@@ -35,7 +35,7 @@ Write-Output "Building $RID"
Write-Output "Using $Generator as the cmake generator" Write-Output "Using $Generator as the cmake generator"
Write-Output "Using architecture $Architecture" Write-Output "Using architecture $Architecture"
$SFMLBranch = "master" # The branch or tag of the SFML repository to be cloned $SFMLBranch = "3.0.0" # The branch or tag of the SFML repository to be cloned
$CSFMLDir = (Get-Item (git rev-parse --show-toplevel)).FullName # The directory of the source code of CSFML $CSFMLDir = (Get-Item (git rev-parse --show-toplevel)).FullName # The directory of the source code of CSFML
$OutDir = "./CSFML/runtimes/$RID/native" # The directory of all CSFML modules, used to copy the final dlls $OutDir = "./CSFML/runtimes/$RID/native" # The directory of all CSFML modules, used to copy the final dlls
@@ -83,17 +83,9 @@ Push-Location "SFML"
$SFMLDir = (Get-Item .).FullName $SFMLDir = (Get-Item .).FullName
switch ($RID) { IF ($RID -ne 'win-x86' -and $RID -ne 'win-x64') {
'win-x86' { Write-Error "Unknown RID '$RID'"
$SFMLExtLibs = (Get-Item ./extlibs/libs-msvc-universal/x86).FullName exit
}
'win-x64' {
$SFMLExtLibs = (Get-Item ./extlibs/libs-msvc-universal/x64).FullName
}
Default {
Write-Error "Unknown RID '$RID'"
exit
}
} }
Pop-Location # Pop SFML Pop-Location # Pop SFML
@@ -142,7 +134,6 @@ $CSFMLLibDir = (Get-Item lib).FullName; # The directory where the final CSFML dl
cmake ` cmake `
"-DSFML_ROOT=$SFMLInstallDir" ` "-DSFML_ROOT=$SFMLInstallDir" `
'-DCSFML_LINK_SFML_STATICALLY=OFF' ` '-DCSFML_LINK_SFML_STATICALLY=OFF' `
"-DCMAKE_LIBRARY_PATH=$SFMLExtLibs" `
` `
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$CSFMLLibDir" ` "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$CSFMLLibDir" `
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=$CSFMLLibDir" ` "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=$CSFMLLibDir" `