mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-24 21:53:37 +02:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80c362cb86 |
No files matched your search
@@ -23,7 +23,6 @@ Checks: >
|
||||
-cppcoreguidelines-pro-type-const-cast,
|
||||
-cppcoreguidelines-pro-type-reinterpret-cast,
|
||||
-cppcoreguidelines-special-member-functions,
|
||||
-cppcoreguidelines-use-enum-class,
|
||||
-modernize-avoid-c-arrays,
|
||||
-modernize-macro-to-enum,
|
||||
-modernize-redundant-void-arg,
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
github: SFML
|
||||
open_collective: sfml
|
||||
+14
-32
@@ -6,9 +6,6 @@ concurrency:
|
||||
group: environment-${{github.ref}}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
SFML_VERSION: 3.0.1
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
@@ -22,10 +19,12 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform:
|
||||
- { name: Windows VS2022 x86, os: windows-2025, flags: -AWin32 }
|
||||
- { name: Windows VS2022 x64, os: windows-2025, flags: -Ax64 }
|
||||
- { name: Windows ClangCL, os: windows-2025, flags: -T ClangCL }
|
||||
- { name: Windows Clang, os: windows-2025, flags: -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
|
||||
- { name: Windows VS2019 x86, os: windows-2019, flags: -AWin32 }
|
||||
- { name: Windows VS2019 x64, os: windows-2019, flags: -Ax64 }
|
||||
- { name: Windows VS2022 x86, os: windows-2022, flags: -AWin32 }
|
||||
- { name: Windows VS2022 x64, os: windows-2022, flags: -Ax64 }
|
||||
- { name: Windows ClangCL, os: windows-2022, flags: -T ClangCL }
|
||||
- { name: Windows Clang, os: windows-2022, flags: -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
|
||||
- { name: Linux GCC, os: ubuntu-22.04, flags: -GNinja }
|
||||
- { name: Linux Clang, os: ubuntu-22.04, flags: -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
|
||||
- { name: MacOS, os: macos-14, flags: -GNinja }
|
||||
@@ -40,27 +39,21 @@ 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
|
||||
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 libfreetype-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
|
||||
|
||||
- name: Checkout SFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: SFML/SFML
|
||||
ref: ${{env.SFML_VERSION}}
|
||||
ref: master
|
||||
path: SFML
|
||||
|
||||
- name: Configure SFML CMake
|
||||
run: |
|
||||
cmake -S SFML -B SFML/build \
|
||||
-DCMAKE_BUILD_TYPE=${{matrix.type.name}} \
|
||||
-DCMAKE_INSTALL_PREFIX=SFML/install \
|
||||
${{matrix.platform.flags}} \
|
||||
${{matrix.config.flags}}
|
||||
run: cmake -S SFML -B SFML/build -DCMAKE_INSTALL_PREFIX=SFML/install ${{matrix.platform.flags}} ${{matrix.config.flags}} -DCMAKE_BUILD_TYPE=${{matrix.type.name}}
|
||||
|
||||
- name: Build SFML
|
||||
run: cmake --build SFML/build --config ${{matrix.type.name}} --target install
|
||||
@@ -71,15 +64,7 @@ jobs:
|
||||
path: CSFML
|
||||
|
||||
- name: Configure CSFML CMake
|
||||
run: |
|
||||
cmake --preset dev -S CSFML -B CSFML/build \
|
||||
-DCMAKE_BUILD_TYPE=${{matrix.type.name}} \
|
||||
-DCMAKE_INSTALL_PREFIX=CSFML/install \
|
||||
-DSFML_ROOT=SFML/install \
|
||||
-DCMAKE_VERBOSE_MAKEFILE=ON \
|
||||
${{matrix.platform.flags}} \
|
||||
${{matrix.config.flags}} \
|
||||
${{matrix.config.csfml_flags}}
|
||||
run: cmake --preset dev -S CSFML -B CSFML/build -DCMAKE_INSTALL_PREFIX=CSFML/install -DSFML_ROOT=SFML/install -DCMAKE_VERBOSE_MAKEFILE=ON ${{matrix.platform.flags}} ${{matrix.config.flags}} ${{matrix.config.csfml_flags}} -DCMAKE_BUILD_TYPE=${{matrix.type.name}}
|
||||
|
||||
- name: Build CSFML
|
||||
run: cmake --build CSFML/build --config ${{matrix.type.name}} --target install
|
||||
@@ -89,17 +74,14 @@ jobs:
|
||||
|
||||
format:
|
||||
name: Formatting
|
||||
runs-on: ubuntu-24.04
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Install Clang Format
|
||||
run: sudo apt-get install clang-format-17
|
||||
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Format Code
|
||||
run: cmake -DCLANG_FORMAT_EXECUTABLE=clang-format-17 -P cmake/Format.cmake
|
||||
run: cmake -DCLANG_FORMAT_EXECUTABLE=clang-format-14 -P cmake/Format.cmake
|
||||
|
||||
- name: Check Formatting
|
||||
run: git diff --exit-code
|
||||
@@ -119,7 +101,7 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: SFML/SFML
|
||||
ref: ${{env.SFML_VERSION}}
|
||||
ref: master
|
||||
path: SFML
|
||||
|
||||
- name: Configure SFML CMake
|
||||
@@ -153,7 +135,7 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: SFML/SFML
|
||||
ref: ${{env.SFML_VERSION}}
|
||||
ref: master
|
||||
path: SFML
|
||||
|
||||
- name: Configure SFML
|
||||
|
||||
+215
-197
@@ -1,234 +1,252 @@
|
||||
name: NuGet Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 2.6.x
|
||||
tags:
|
||||
- "**"
|
||||
workflow_dispatch: {}
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 2.6.x
|
||||
workflow_dispatch: {}
|
||||
|
||||
concurrency:
|
||||
group: nuget-${{github.ref}}
|
||||
cancel-in-progress: true
|
||||
group: nuget-${{github.ref}}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
DOTNET_CLI_TELEMETRY_OPTOUT: 1
|
||||
DOTNET_CLI_TELEMETRY_OPTOUT: 1
|
||||
|
||||
jobs:
|
||||
windows:
|
||||
name: Windows VS2022
|
||||
runs-on: windows-2025
|
||||
windows:
|
||||
name: Windows VS2022
|
||||
runs-on: windows-2022
|
||||
|
||||
steps:
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
steps:
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
|
||||
- name: Build x86
|
||||
shell: pwsh
|
||||
run: |
|
||||
cd CSFML/tools/nuget
|
||||
./build.win.ps1 "win-x86"
|
||||
- name: Build x86
|
||||
shell: pwsh
|
||||
run: |
|
||||
cd CSFML/tools/nuget
|
||||
./build.win.ps1 "win-x86"
|
||||
|
||||
- name: Build x64
|
||||
shell: pwsh
|
||||
run: |
|
||||
cd CSFML/tools/nuget
|
||||
./build.win.ps1 "win-x64"
|
||||
- name: Build x64
|
||||
shell: pwsh
|
||||
run: |
|
||||
cd CSFML/tools/nuget
|
||||
./build.win.ps1 "win-x64"
|
||||
|
||||
- name: Build ARM64
|
||||
shell: pwsh
|
||||
run: |
|
||||
cd CSFML/tools/nuget
|
||||
./build.win.ps1 "win-arm64"
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-win-x86-x64
|
||||
path: CSFML/tools/nuget/CSFML/runtimes
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-win-x86-x64-arm64
|
||||
path: CSFML/tools/nuget/CSFML/runtimes
|
||||
linux-x64:
|
||||
name: Linux x64
|
||||
runs-on: ubuntu-22.04
|
||||
container:
|
||||
image: ubuntu:22.04
|
||||
|
||||
linux-x64:
|
||||
name: Linux x64
|
||||
runs-on: ubuntu-22.04
|
||||
container:
|
||||
image: ubuntu:22.04
|
||||
steps:
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
|
||||
steps:
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
- name: Build
|
||||
shell: bash
|
||||
run: |
|
||||
cd ./CSFML/tools/nuget
|
||||
chmod +x ./docker.linux-x64.sh
|
||||
./docker.linux-x64.sh
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
run: |
|
||||
cd ./CSFML/tools/nuget
|
||||
chmod +x ./docker.linux-x64.sh
|
||||
./docker.linux-x64.sh
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-linux-x64
|
||||
path: CSFML/tools/nuget/CSFML/runtimes
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-linux-x64
|
||||
path: CSFML/tools/nuget/CSFML/runtimes
|
||||
linux-arm:
|
||||
name: Linux ARM
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
linux-arm:
|
||||
name: Linux ARM
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
|
||||
steps:
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
- name: Build in an ARM container
|
||||
uses: uraimo/run-on-arch-action@v2.7.2
|
||||
with:
|
||||
arch: armv7
|
||||
distro: ubuntu22.04
|
||||
githubToken: ${{ github.token }}
|
||||
dockerRunArgs: |
|
||||
--volume "${PWD}/CSFML:/CSFML"
|
||||
install: |
|
||||
apt-get update -y
|
||||
apt-get install -y git libfreetype6-dev xorg-dev libxrandr-dev libxcursor-dev libxi-dev libudev-dev libgl1-mesa-dev libflac-dev libogg-dev libvorbis-dev cmake g++
|
||||
run: |
|
||||
cd /CSFML/tools/nuget
|
||||
chmod +x ./build.linux.sh
|
||||
./build.linux.sh linux-arm
|
||||
|
||||
- name: Build in an ARM container
|
||||
uses: uraimo/run-on-arch-action@v3.0.1
|
||||
with:
|
||||
arch: armv7
|
||||
distro: ubuntu22.04
|
||||
githubToken: ${{ github.token }}
|
||||
dockerRunArgs: |
|
||||
--volume "${PWD}/CSFML:/CSFML"
|
||||
install: |
|
||||
apt-get update -y
|
||||
apt-get install -y git libfreetype6-dev xorg-dev libxrandr-dev libxcursor-dev libxi-dev libudev-dev libgl1-mesa-dev libflac-dev libogg-dev libvorbis-dev cmake g++
|
||||
run: |
|
||||
cd /CSFML/tools/nuget
|
||||
chmod +x ./build.linux.sh
|
||||
./build.linux.sh linux-arm
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-linux-arm
|
||||
path: CSFML/tools/nuget/CSFML/runtimes
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-linux-arm
|
||||
path: CSFML/tools/nuget/CSFML/runtimes
|
||||
linux-arm64:
|
||||
name: Linux ARM64
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
linux-arm64:
|
||||
name: Linux ARM64
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
|
||||
steps:
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
- name: Build in an ARM64 container
|
||||
uses: uraimo/run-on-arch-action@v2.7.2
|
||||
with:
|
||||
arch: aarch64
|
||||
distro: ubuntu22.04
|
||||
githubToken: ${{ github.token }}
|
||||
dockerRunArgs: |
|
||||
--volume "${PWD}/CSFML:/CSFML"
|
||||
install: |
|
||||
apt-get update -y
|
||||
apt-get install -y git libfreetype6-dev xorg-dev libxrandr-dev libxcursor-dev libudev-dev libgl1-mesa-dev libflac-dev libogg-dev libvorbis-dev cmake g++
|
||||
run: |
|
||||
cd /CSFML/tools/nuget
|
||||
chmod +x ./build.linux.sh
|
||||
./build.linux.sh linux-arm64
|
||||
|
||||
- name: Build in an ARM64 container
|
||||
uses: uraimo/run-on-arch-action@v3.0.1
|
||||
with:
|
||||
arch: aarch64
|
||||
distro: ubuntu22.04
|
||||
githubToken: ${{ github.token }}
|
||||
dockerRunArgs: |
|
||||
--volume "${PWD}/CSFML:/CSFML"
|
||||
install: |
|
||||
apt-get update -y
|
||||
apt-get install -y git libfreetype6-dev xorg-dev libxrandr-dev libxcursor-dev libudev-dev libgl1-mesa-dev libflac-dev libogg-dev libvorbis-dev cmake g++
|
||||
run: |
|
||||
cd /CSFML/tools/nuget
|
||||
chmod +x ./build.linux.sh
|
||||
./build.linux.sh linux-arm64
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-linux-arm64
|
||||
path: CSFML/tools/nuget/CSFML/runtimes
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-linux-arm64
|
||||
path: CSFML/tools/nuget/CSFML/runtimes
|
||||
linux-musl-x64:
|
||||
name: Linux MUSL x64
|
||||
runs-on: ubuntu-22.04
|
||||
container:
|
||||
image: alpine:3.20.3
|
||||
|
||||
linux-musl-x64:
|
||||
name: Linux MUSL x64
|
||||
runs-on: ubuntu-22.04
|
||||
container:
|
||||
image: alpine:3.20.7
|
||||
steps:
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
|
||||
steps:
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
- name: Build
|
||||
shell: sh
|
||||
run: |
|
||||
cd ./CSFML/tools/nuget
|
||||
chmod +x ./docker.linux-musl-x64.sh
|
||||
./docker.linux-musl-x64.sh
|
||||
|
||||
- name: Build
|
||||
shell: sh
|
||||
run: |
|
||||
cd ./CSFML/tools/nuget
|
||||
chmod +x ./docker.linux-musl-x64.sh
|
||||
./docker.linux-musl-x64.sh
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-linux-musl-x64
|
||||
path: CSFML/tools/nuget/CSFML/runtimes
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-linux-musl-x64
|
||||
path: CSFML/tools/nuget/CSFML/runtimes
|
||||
fedora-x64:
|
||||
name: Fedora x64
|
||||
runs-on: ubuntu-22.04
|
||||
container:
|
||||
image: fedora:37
|
||||
|
||||
macos:
|
||||
name: macOS
|
||||
runs-on: macos-14
|
||||
steps:
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
|
||||
steps:
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
- name: Build
|
||||
shell: bash
|
||||
run: |
|
||||
cd ./CSFML/tools/nuget
|
||||
chmod +x ./docker.fedora-x64.sh
|
||||
./docker.fedora-x64.sh
|
||||
|
||||
- name: Install necessary tooling
|
||||
run: brew install coreutils
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-fedora-x64
|
||||
path: CSFML/tools/nuget/CSFML/runtimes
|
||||
|
||||
- name: Build x64
|
||||
run: |
|
||||
cd CSFML/tools/nuget
|
||||
./build.macos.sh "osx-x64"
|
||||
macos:
|
||||
name: macOS
|
||||
runs-on: macos-14
|
||||
|
||||
- name: Build ARM64
|
||||
run: |
|
||||
cd CSFML/tools/nuget
|
||||
./build.macos.sh "osx-arm64"
|
||||
steps:
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-macOS-x64-arm64
|
||||
path: CSFML/tools/nuget/CSFML/runtimes
|
||||
- name: Install necessary tooling
|
||||
run: brew install coreutils
|
||||
|
||||
package:
|
||||
name: Package Builds
|
||||
runs-on: ubuntu-24.04
|
||||
needs:
|
||||
- windows
|
||||
- linux-x64
|
||||
- linux-arm
|
||||
- linux-arm64
|
||||
- linux-musl-x64
|
||||
- macos
|
||||
steps:
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
- name: Download Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: CSFML/tools/nuget/CSFML/runtimes
|
||||
merge-multiple: true
|
||||
- name: Setup .NET 8 SDK
|
||||
id: setup-dotnet
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
- name: Enforce SDK Version
|
||||
run: dotnet new globaljson --sdk-version ${{ steps.setup-dotnet.outputs.dotnet-version }} --force
|
||||
- name: Verify SDK Installation
|
||||
run: dotnet --info
|
||||
- name: Build NuGet Package
|
||||
run: |
|
||||
cd CSFML/tools/nuget
|
||||
dotnet build --configuration Release --verbosity detailed
|
||||
- name: Upload NuGet Package
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-NuGet-Package
|
||||
path: CSFML/tools/nuget/CSFML/bin/Release/*.nupkg
|
||||
- name: Build x64
|
||||
run: |
|
||||
cd CSFML/tools/nuget
|
||||
./build.macos.sh "osx-x64"
|
||||
|
||||
- name: Build ARM64
|
||||
run: |
|
||||
cd CSFML/tools/nuget
|
||||
./build.macos.sh "osx-arm64"
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-macOS-x64-arm64
|
||||
path: CSFML/tools/nuget/CSFML/runtimes
|
||||
|
||||
package:
|
||||
name: Package Builds
|
||||
runs-on: ubuntu-22.04
|
||||
needs:
|
||||
- windows
|
||||
- linux-x64
|
||||
- linux-arm
|
||||
- linux-arm64
|
||||
- linux-musl-x64
|
||||
- fedora-x64
|
||||
- macos
|
||||
steps:
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
- name: Download Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: CSFML/tools/nuget/CSFML/runtimes
|
||||
merge-multiple: true
|
||||
- name: Setup .NET 8 SDK
|
||||
id: setup-dotnet
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
- name: Enforce SDK Version
|
||||
run: dotnet new globaljson --sdk-version ${{ steps.setup-dotnet.outputs.dotnet-version }} --force
|
||||
- name: Verify SDK Installation
|
||||
run: dotnet --info
|
||||
- name: Build NuGet Package
|
||||
run: |
|
||||
cd CSFML/tools/nuget
|
||||
dotnet build --configuration Release --verbosity detailed
|
||||
- name: Upload NuGet Package
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-NuGet-Package
|
||||
path: CSFML/tools/nuget/CSFML/bin/Release/*.nupkg
|
||||
@@ -1,356 +0,0 @@
|
||||
name: Release Builds
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 2.6.x
|
||||
tags:
|
||||
- "**"
|
||||
workflow_dispatch: {}
|
||||
|
||||
concurrency:
|
||||
group: release-${{github.ref}}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
SFML_VERSION: 3.0.1
|
||||
|
||||
jobs:
|
||||
windows-x86:
|
||||
name: Windows x86
|
||||
runs-on: windows-2025
|
||||
|
||||
steps:
|
||||
- name: Cache MinGW x86
|
||||
id: mingw-x86-cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ github.workspace }}/mingw32
|
||||
key: 15.2.0posix-13.0.0-ucrt-r1-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: 15.2.0posix-13.0.0-ucrt-r1
|
||||
with_clang: false
|
||||
architecture: 32
|
||||
destination: ${{ github.workspace }}
|
||||
add_to_path: false
|
||||
|
||||
- name: Checkout SFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: SFML/SFML
|
||||
ref: ${{ env.SFML_VERSION }}
|
||||
path: SFML
|
||||
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
|
||||
- name: Build SFML
|
||||
run: |
|
||||
cmake -S SFML -B SFML-build -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-2025
|
||||
|
||||
steps:
|
||||
- name: Cache MinGW x64
|
||||
id: mingw-x64-cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ github.workspace }}/mingw64
|
||||
key: 15.2.0posix-13.0.0-ucrt-r1-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: 15.2.0posix-13.0.0-ucrt-r1
|
||||
with_clang: false
|
||||
architecture: 64
|
||||
destination: ${{ github.workspace }}
|
||||
add_to_path: false
|
||||
|
||||
- name: Checkout SFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: SFML/SFML
|
||||
ref: ${{ env.SFML_VERSION }}
|
||||
path: SFML
|
||||
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
|
||||
- name: Build SFML
|
||||
run: |
|
||||
cmake -S SFML -B SFML-build -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
|
||||
|
||||
windows-arm64:
|
||||
name: Windows ARM64
|
||||
runs-on: windows-2025
|
||||
|
||||
steps:
|
||||
- name: Checkout SFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: SFML/SFML
|
||||
ref: ${{ env.SFML_VERSION }}
|
||||
path: SFML
|
||||
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
|
||||
- name: Build SFML
|
||||
run: |
|
||||
cmake -S SFML -B SFML-build -A ARM64 -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 ARM64 -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: Move Files
|
||||
shell: pwsh
|
||||
run: |
|
||||
New-Item -ItemType "directory" -PATH "install\CSFML"
|
||||
Move-Item -Path "CSFML-install\*" -Destination "install\CSFML"
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: CSFML-windows-arm64
|
||||
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: ${{ env.SFML_VERSION }}
|
||||
path: SFML
|
||||
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
|
||||
- name: Build SFML
|
||||
run: |
|
||||
cmake -S SFML -B SFML-build -G "Unix Makefiles" \
|
||||
-DCMAKE_C_COMPILER="/usr/bin/clang" \
|
||||
-DCMAKE_CXX_COMPILER="/usr/bin/clang++" \
|
||||
-DCMAKE_C_FLAGS="-stdlib=libc++" \
|
||||
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
|
||||
-DBUILD_SHARED_LIBS=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: ${{ env.SFML_VERSION }}
|
||||
path: SFML
|
||||
|
||||
- name: Checkout CSFML
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: CSFML
|
||||
- name: Build SFML
|
||||
run: |
|
||||
cmake -S SFML -B SFML-build -G "Unix Makefiles" \
|
||||
-DCMAKE_C_COMPILER="/usr/bin/clang" \
|
||||
-DCMAKE_CXX_COMPILER="/usr/bin/clang++" \
|
||||
-DCMAKE_C_FLAGS="-stdlib=libc++" \
|
||||
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
|
||||
-DBUILD_SHARED_LIBS=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
@@ -46,7 +46,7 @@ csfml_set_option(CSFML_LINK_SFML_STATICALLY ${LINK_STATICALLY_DEFAULT} BOOL "ON
|
||||
|
||||
# define an option for choosing between static and dynamic C runtime (Windows only)
|
||||
if(SFML_OS_WINDOWS)
|
||||
csfml_set_option(CSFML_USE_STATIC_STD_LIBS OFF BOOL "ON to statically link to the standard libraries, OFF to use them as DLLs")
|
||||
set(STATIC_STD_LIBS OFF CACHE BOOL "ON to statically link to the standard libraries, OFF to use them as DLLs")
|
||||
endif()
|
||||
|
||||
# find SFML libraries (C++)
|
||||
@@ -121,7 +121,7 @@ if(CSFML_BUILD_TEST_SUITE)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
csfml_set_option(CLANG_FORMAT_EXECUTABLE clang-format STRING "Override clang-format executable, requires version 17")
|
||||
csfml_set_option(CLANG_FORMAT_EXECUTABLE clang-format STRING "Override clang-format executable, requires version 14")
|
||||
add_custom_target(format
|
||||
COMMAND ${CMAKE_COMMAND} -DCLANG_FORMAT_EXECUTABLE=${CLANG_FORMAT_EXECUTABLE} -P ./cmake/Format.cmake
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} VERBATIM)
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@ endif()
|
||||
execute_process(COMMAND ${CLANG_FORMAT_EXECUTABLE} --version OUTPUT_VARIABLE CLANG_FORMAT_VERSION)
|
||||
string(REGEX MATCH "clang-format version ([0-9]+)" CLANG_FORMAT_VERSION ${CLANG_FORMAT_VERSION})
|
||||
unset(CLANG_FORMAT_VERSION)
|
||||
if(NOT CMAKE_MATCH_1 EQUAL 17)
|
||||
message(FATAL_ERROR "clang-format version ${CMAKE_MATCH_1} not supported. Must use version 17")
|
||||
if(NOT CMAKE_MATCH_1 EQUAL 14)
|
||||
message(FATAL_ERROR "clang-format version ${CMAKE_MATCH_1} not supported. Must use version 14")
|
||||
endif()
|
||||
|
||||
# Run
|
||||
|
||||
+4
-4
@@ -46,7 +46,7 @@ macro(csfml_add_library target)
|
||||
set_target_properties(${target} PROPERTIES MINSIZEREL_POSTFIX -s)
|
||||
set_target_properties(${target} PROPERTIES RELWITHDEBINFO_POSTFIX -s)
|
||||
|
||||
if(CSFML_USE_STATIC_STD_LIBS)
|
||||
if(STATIC_STD_LIBS)
|
||||
set_property(TARGET ${target} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
endif()
|
||||
endif()
|
||||
@@ -58,11 +58,11 @@ macro(csfml_add_library target)
|
||||
# set the target's folder (for IDEs that support it, e.g. Visual Studio)
|
||||
set_target_properties(${target} PROPERTIES FOLDER "CSFML")
|
||||
|
||||
# apply the CSFML_USE_STATIC_STD_LIBS option if it is enabled
|
||||
# apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
|
||||
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC)
|
||||
if(CSFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
|
||||
if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
|
||||
elseif(NOT CSFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM)
|
||||
elseif(NOT SFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-shared-libgcc -shared-libstdc++")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
+2
-2
@@ -38,8 +38,8 @@ add_custom_target(doc ALL
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
|
||||
DESTINATION ${INSTALL_MISC_DIR}/doc
|
||||
COMPONENT doc)
|
||||
if(DOXYGEN_GENERATE_HTMLHELP)
|
||||
install(FILES ${DOXYGEN_OUTPUT_DIR}/CSFML.chm
|
||||
if(DOXYGEN_HHC_PROGRAM)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CSFML.chm
|
||||
DESTINATION ${INSTALL_MISC_DIR}/doc
|
||||
COMPONENT doc)
|
||||
endif()
|
||||
@@ -175,7 +175,7 @@ CSFML_AUDIO_API sfTime sfMusic_getDuration(const sfMusic* music);
|
||||
CSFML_AUDIO_API sfTimeSpan sfMusic_getLoopPoints(const sfMusic* music);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Sets the beginning and end of the sound's looping sequence using sfTime
|
||||
/// \brief Sets the beginning and end of the sound's looping sequence using sf::Time
|
||||
///
|
||||
/// Loop points allow one to specify a pair of positions such that, when the music
|
||||
/// is enabled for looping, it will seamlessly seek to the beginning whenever it
|
||||
|
||||
@@ -129,7 +129,7 @@ CSFML_AUDIO_API bool sfSoundRecorder_isAvailable(void);
|
||||
/// \return An array of strings containing the names
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_AUDIO_API const char* const* sfSoundRecorder_getAvailableDevices(size_t* count);
|
||||
CSFML_AUDIO_API const char** sfSoundRecorder_getAvailableDevices(size_t* count);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the name of the default audio capture device
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Types of texture coordinates that can be used for rendering.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
typedef enum
|
||||
{
|
||||
sfCoordinateTypeNormalized, ///< sfTexture coordinates in range [0 .. 1].
|
||||
sfCoordinateTypePixels ///< sfTexture coordinates in range [0 .. size].
|
||||
} sfCoordinateType;
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Types of primitives that an sfVertexArray can render
|
||||
/// \brief Types of primitives that a sf::VertexArray can render
|
||||
///
|
||||
/// Points and lines have no area, therefore their thickness
|
||||
/// will always be 1 pixel, regardless the current transform
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include <CSFML/Graphics/Export.h>
|
||||
|
||||
#include <CSFML/Graphics/BlendMode.h>
|
||||
#include <CSFML/Graphics/CoordinateType.h>
|
||||
#include <CSFML/Graphics/StencilMode.h>
|
||||
#include <CSFML/Graphics/Transform.h>
|
||||
#include <CSFML/Graphics/Types.h>
|
||||
|
||||
@@ -42,12 +40,10 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
typedef struct
|
||||
{
|
||||
sfBlendMode blendMode; ///< Blending mode
|
||||
sfStencilMode stencilMode; //!< Stencil mode
|
||||
sfTransform transform; ///< Transform
|
||||
sfCoordinateType coordinateType; //!< Texture coordinate type
|
||||
const sfTexture* texture; ///< Texture
|
||||
const sfShader* shader; ///< Shader
|
||||
sfBlendMode blendMode; ///< Blending mode
|
||||
sfTransform transform; ///< Transform
|
||||
const sfTexture* texture; ///< Texture
|
||||
const sfShader* shader; ///< Shader
|
||||
} sfRenderStates;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -216,28 +216,6 @@ 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
|
||||
///
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <CSFML/Graphics/Export.h>
|
||||
|
||||
#include <CSFML/Graphics/CoordinateType.h>
|
||||
#include <CSFML/Graphics/Rect.h>
|
||||
#include <CSFML/Graphics/Types.h>
|
||||
#include <CSFML/System/InputStream.h>
|
||||
@@ -38,6 +37,16 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Types of texture coordinates that can be used for rendering.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
typedef enum
|
||||
{
|
||||
sfTextureNormalized, ///< sfTexture coordinates in range [0 .. 1].
|
||||
sfTexturePixels ///< sfTexture coordinates in range [0 .. size].
|
||||
} sfTextureCoordinateType;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create a new texture
|
||||
///
|
||||
@@ -178,20 +187,6 @@ CSFML_GRAPHICS_API sfTexture* sfTexture_copy(const sfTexture* texture);
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_GRAPHICS_API void sfTexture_destroy(const sfTexture* texture);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Resize the texture
|
||||
///
|
||||
/// If this function fails, the texture is left unchanged.
|
||||
///
|
||||
/// \param texture Texture to resize
|
||||
/// \param size Width and height of the texture
|
||||
/// \param sRgb `true` to enable sRGB conversion, `false` to disable it
|
||||
///
|
||||
/// \return `true` if resizing was successful, `false` if it failed
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_GRAPHICS_API bool sfTexture_resize(sfTexture* texture, sfVector2u size, bool sRgb);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return the size of the texture
|
||||
///
|
||||
@@ -405,7 +400,7 @@ CSFML_GRAPHICS_API unsigned int sfTexture_getNativeHandle(const sfTexture* textu
|
||||
/// \param type Type of texture coordinates to use
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_GRAPHICS_API void sfTexture_bind(const sfTexture* texture, sfCoordinateType type);
|
||||
CSFML_GRAPHICS_API void sfTexture_bind(const sfTexture* texture, sfTextureCoordinateType type);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the maximum texture size allowed
|
||||
|
||||
@@ -150,7 +150,7 @@ CSFML_GRAPHICS_API void sfVertexArray_setPrimitiveType(sfVertexArray* vertexArra
|
||||
/// \return Primitive type
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_GRAPHICS_API sfPrimitiveType sfVertexArray_getPrimitiveType(const sfVertexArray* vertexArray);
|
||||
CSFML_GRAPHICS_API sfPrimitiveType sfVertexArray_getPrimitiveType(sfVertexArray* vertexArray);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Compute the bounding rectangle of a vertex array
|
||||
@@ -163,4 +163,4 @@ CSFML_GRAPHICS_API sfPrimitiveType sfVertexArray_getPrimitiveType(const sfVertex
|
||||
/// \return Bounding rectangle of the vertex array
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_GRAPHICS_API sfFloatRect sfVertexArray_getBounds(const sfVertexArray* vertexArray);
|
||||
CSFML_GRAPHICS_API sfFloatRect sfVertexArray_getBounds(sfVertexArray* vertexArray);
|
||||
@@ -69,7 +69,7 @@ typedef enum
|
||||
/// \return A new sfVertexBuffer object
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_GRAPHICS_API sfVertexBuffer* sfVertexBuffer_create(size_t vertexCount, sfPrimitiveType type, sfVertexBufferUsage usage);
|
||||
CSFML_GRAPHICS_API sfVertexBuffer* sfVertexBuffer_create(unsigned int vertexCount, sfPrimitiveType type, sfVertexBufferUsage usage);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Copy an existing vertex buffer
|
||||
@@ -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
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_GRAPHICS_API unsigned int sfVertexBuffer_getNativeHandle(const sfVertexBuffer* vertexBuffer);
|
||||
CSFML_GRAPHICS_API unsigned int sfVertexBuffer_getNativeHandle(sfVertexBuffer* vertexBuffer);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the type of primitives to draw
|
||||
@@ -174,7 +174,7 @@ CSFML_GRAPHICS_API unsigned int sfVertexBuffer_getNativeHandle(const sfVertexBuf
|
||||
/// This function defines how the vertices must be interpreted
|
||||
/// when it's time to draw them.
|
||||
///
|
||||
/// The default primitive type is sfPoints.
|
||||
/// The default primitive type is sf::Points.
|
||||
///
|
||||
/// \param vertexBuffer Vertex buffer object
|
||||
/// \param type Type of primitive
|
||||
@@ -248,7 +248,7 @@ CSFML_GRAPHICS_API void sfVertexBuffer_bind(const sfVertexBuffer* vertexBuffer);
|
||||
///
|
||||
/// This function should always be called before using
|
||||
/// the vertex buffer features. If it returns false, then
|
||||
/// any attempt to use sfVertexBuffer will fail.
|
||||
/// any attempt to use sf::VertexBuffer will fail.
|
||||
///
|
||||
/// \return True if vertex buffers are supported, false otherwise
|
||||
///
|
||||
|
||||
@@ -191,7 +191,7 @@ CSFML_GRAPHICS_API sfFloatRect sfView_getViewport(const sfView* view);
|
||||
CSFML_GRAPHICS_API sfFloatRect sfView_getScissor(const sfView* view);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Move a view relative to its current position
|
||||
/// \brief Move a view relatively to its current position
|
||||
///
|
||||
/// \param view View object
|
||||
/// \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);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Rotate a view relative to its current orientation
|
||||
/// \brief Rotate a view relatively to its current orientation
|
||||
///
|
||||
/// \param view View object
|
||||
/// \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);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Resize a view rectangle relative to its current size
|
||||
/// \brief Resize a view rectangle relatively to its current size
|
||||
///
|
||||
/// Resizing the view simulates a zoom, as the zone displayed on
|
||||
/// screen grows or shrinks.
|
||||
|
||||
@@ -225,7 +225,7 @@ CSFML_NETWORK_API const char* sfFtpDirectoryResponse_getMessage(const sfFtpDirec
|
||||
///
|
||||
/// \param ftpDirectoryResponse Ftp directory response
|
||||
///
|
||||
/// \return Directory name or NULL if it failed
|
||||
/// \return Directory name
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_NETWORK_API const char* sfFtpDirectoryResponse_getDirectory(const sfFtpDirectoryResponse* ftpDirectoryResponse);
|
||||
@@ -239,7 +239,7 @@ CSFML_NETWORK_API const char* sfFtpDirectoryResponse_getDirectory(const sfFtpDir
|
||||
///
|
||||
/// \param ftpDirectoryResponse Ftp directory response
|
||||
///
|
||||
/// \return Directory name or NULL if it failed
|
||||
/// \return Directory name
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_NETWORK_API const sfChar32* sfFtpDirectoryResponse_getDirectoryUnicode(const sfFtpDirectoryResponse* ftpDirectoryResponse);
|
||||
|
||||
@@ -132,7 +132,7 @@ CSFML_NETWORK_API void sfIpAddress_toString(sfIpAddress address, char* string);
|
||||
/// address, and should be used for optimization purposes only
|
||||
/// (like sending the address through a socket).
|
||||
/// The integer produced by this function can then be converted
|
||||
/// back to a sfIpAddress with sfIpAddress_fromInteger.
|
||||
/// back to a sfIpAddress with sfIpAddress_FromInteger.
|
||||
///
|
||||
/// \param address Address object
|
||||
///
|
||||
|
||||
@@ -75,8 +75,6 @@ CSFML_NETWORK_API void sfPacket_append(sfPacket* packet, const void* data, size_
|
||||
///
|
||||
/// The next read operation will read data from this position
|
||||
///
|
||||
/// \param packet Packet object
|
||||
///
|
||||
/// \return The byte offset of the current read position
|
||||
///
|
||||
/// \see append
|
||||
@@ -165,8 +163,6 @@ CSFML_NETWORK_API int16_t sfPacket_readInt16(sfPacket* packet);
|
||||
CSFML_NETWORK_API uint16_t sfPacket_readUint16(sfPacket* packet);
|
||||
CSFML_NETWORK_API int32_t sfPacket_readInt32(sfPacket* packet);
|
||||
CSFML_NETWORK_API uint32_t sfPacket_readUint32(sfPacket* packet);
|
||||
CSFML_NETWORK_API int64_t sfPacket_readInt64(sfPacket* packet);
|
||||
CSFML_NETWORK_API uint64_t sfPacket_readUint64(sfPacket* packet);
|
||||
CSFML_NETWORK_API float sfPacket_readFloat(sfPacket* packet);
|
||||
CSFML_NETWORK_API double sfPacket_readDouble(sfPacket* packet);
|
||||
CSFML_NETWORK_API void sfPacket_readString(sfPacket* packet, char* string);
|
||||
@@ -185,8 +181,6 @@ CSFML_NETWORK_API void sfPacket_writeInt16(sfPacket* packet, int16_t);
|
||||
CSFML_NETWORK_API void sfPacket_writeUint16(sfPacket* packet, uint16_t);
|
||||
CSFML_NETWORK_API void sfPacket_writeInt32(sfPacket* packet, int32_t);
|
||||
CSFML_NETWORK_API void sfPacket_writeUint32(sfPacket* packet, uint32_t);
|
||||
CSFML_NETWORK_API void sfPacket_writeInt64(sfPacket* packet, int64_t);
|
||||
CSFML_NETWORK_API void sfPacket_writeUint64(sfPacket* packet, uint64_t);
|
||||
CSFML_NETWORK_API void sfPacket_writeFloat(sfPacket* packet, float);
|
||||
CSFML_NETWORK_API void sfPacket_writeDouble(sfPacket* packet, double);
|
||||
CSFML_NETWORK_API void sfPacket_writeString(sfPacket* packet, const char* string);
|
||||
|
||||
@@ -99,10 +99,6 @@ CSFML_NETWORK_API unsigned short sfTcpListener_getLocalPort(const sfTcpListener*
|
||||
/// If the socket was previously listening to another port,
|
||||
/// it will be stopped first and bound to the new port.
|
||||
///
|
||||
/// When providing `sfTcpListener_anyPort()` as port, the listener
|
||||
/// will request an available port from the system.
|
||||
/// The chosen port can be retrieved by calling `sfTcpListener_getLocalPort()`.
|
||||
///
|
||||
/// If there is no specific address to listen to, pass sfIpAddress_Any
|
||||
///
|
||||
/// \param listener TCP listener object
|
||||
@@ -114,17 +110,6 @@ CSFML_NETWORK_API unsigned short sfTcpListener_getLocalPort(const sfTcpListener*
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_NETWORK_API sfSocketStatus sfTcpListener_listen(sfTcpListener* listener, unsigned short port, sfIpAddress address);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Stop listening and close the socket
|
||||
///
|
||||
/// This function gracefully stops the listener. If the
|
||||
/// socket is not listening, this function has no effect.
|
||||
///
|
||||
/// \param listener TCP listener object
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_NETWORK_API void sfTcpListener_close(sfTcpListener* listener);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Accept a new connection
|
||||
///
|
||||
@@ -142,12 +127,3 @@ CSFML_NETWORK_API void sfTcpListener_close(sfTcpListener* listener);
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
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);
|
||||
@@ -153,7 +153,7 @@ CSFML_NETWORK_API void sfTcpSocket_disconnect(sfTcpSocket* socket);
|
||||
/// \brief Send raw data to the remote peer of a TCP socket
|
||||
///
|
||||
/// To be able to handle partial sends over non-blocking
|
||||
/// sockets, use the sfTcpSocket_sendPartial(sfTcpSocket*, const void*, size_t, size_t*)
|
||||
/// sockets, use the sfTcpSocket_sendPartial(sfTcpSocket*, const void*, std::size_t, size_t*)
|
||||
/// overload instead.
|
||||
/// This function will fail if the socket is not connected.
|
||||
///
|
||||
|
||||
@@ -102,10 +102,6 @@ CSFML_NETWORK_API unsigned short sfUdpSocket_getLocalPort(const sfUdpSocket* soc
|
||||
/// system to automatically pick an available port, and then
|
||||
/// call sfUdpSocket_getLocalPort to retrieve the chosen port.
|
||||
///
|
||||
/// When providing `sfUdpSocket_anyPort()` as port, the listener
|
||||
/// will request an available port from the system.
|
||||
/// The chosen port can be retrieved by calling `sfUdpSocket_getLocalPort()`.
|
||||
///
|
||||
/// If there is no specific address to listen to, pass sfIpAddress_Any
|
||||
///
|
||||
/// \param socket UDP socket object
|
||||
@@ -219,12 +215,3 @@ CSFML_NETWORK_API sfSocketStatus
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
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);
|
||||
@@ -43,7 +43,7 @@ typedef struct
|
||||
/// \brief Predefined "zero" time value
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_SYSTEM_API const sfTime sfTime_Zero;
|
||||
CSFML_SYSTEM_API sfTime sfTime_Zero;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return a time value as a number of seconds
|
||||
|
||||
@@ -142,12 +142,10 @@ typedef enum
|
||||
sfKeyF14, ///< The F14 key
|
||||
sfKeyF15, ///< The F15 key
|
||||
sfKeyPause, ///< The Pause key
|
||||
|
||||
sfKeyCount, ///< Keep last -- the total number of keyboard keys
|
||||
} sfKeyCode;
|
||||
|
||||
enum
|
||||
{
|
||||
sfKeyCount = sfKeyPause + 1 ///< The total number of keyboard keys
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Scancodes
|
||||
@@ -312,12 +310,10 @@ typedef enum
|
||||
sfScanLaunchApplication2, //!< Keyboard Launch Application 2 key
|
||||
sfScanLaunchMail, //!< Keyboard Launch Mail key
|
||||
sfScanLaunchMediaSelect, //!< Keyboard Launch Media Select key
|
||||
|
||||
sfScancodeCount //!< Keep last -- the total number of scancodes
|
||||
} sfScancode;
|
||||
|
||||
enum
|
||||
{
|
||||
sfScancodeCount = sfScanLaunchMediaSelect + 1 //!< The total number of scancodes
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if a key is pressed
|
||||
|
||||
@@ -39,17 +39,14 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
typedef enum
|
||||
{
|
||||
sfMouseLeft, ///< The left mouse button
|
||||
sfMouseRight, ///< The right mouse button
|
||||
sfMouseMiddle, ///< The middle (wheel) mouse button
|
||||
sfMouseButtonExtra1, ///< The first extra mouse button
|
||||
sfMouseButtonExtra2, ///< The second extra mouse button
|
||||
} sfMouseButton;
|
||||
sfMouseLeft, ///< The left mouse button
|
||||
sfMouseRight, ///< The right mouse button
|
||||
sfMouseMiddle, ///< The middle (wheel) mouse button
|
||||
sfMouseXButton1, ///< The first extra mouse button
|
||||
sfMouseXButton2, ///< The second extra mouse button
|
||||
|
||||
enum
|
||||
{
|
||||
sfMouseButtonCount = sfMouseButtonExtra2 + 1 ///< The total number of mouse buttons
|
||||
};
|
||||
sfMouseButtonCount ///< Keep last -- the total number of mouse buttons
|
||||
} sfMouseButton;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Mouse wheels
|
||||
|
||||
@@ -45,12 +45,10 @@ typedef enum
|
||||
sfSensorGravity, ///< Measures the direction and intensity of gravity, independent of device acceleration (m/s^2)
|
||||
sfSensorUserAcceleration, ///< Measures the direction and intensity of device acceleration, independent of the gravity (m/s^2)
|
||||
sfSensorOrientation, ///< Measures the absolute 3D orientation (degrees)
|
||||
|
||||
sfSensorCount ///< Keep last -- the total number of sensor types
|
||||
} sfSensorType;
|
||||
|
||||
enum
|
||||
{
|
||||
sfSensorCount = sfSensorOrientation + 1 ///< The total number of sensor types
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if a sensor is available on the underlying platform
|
||||
|
||||
@@ -280,28 +280,6 @@ 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
|
||||
///
|
||||
|
||||
@@ -236,28 +236,6 @@ 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
|
||||
///
|
||||
|
||||
@@ -9,7 +9,7 @@ SFML is a simple, fast, cross-platform and object-oriented multimedia API. It pr
|
||||
Development is focused on the next major version in the `master` branch. No more features are planned for the 2.x release series.
|
||||
|
||||
- The [`master`](https://github.com/SFML/CSFML/tree/master) branch contains work in progress for the next major version CSFML 3. As such it's considered unstable, but any testing and feedback is highly appreciated.
|
||||
- The [`2.6.1`](https://github.com/SFML/CSFML/tree/2.6.1) tag is the latest official CSFML release and will be the last minor release in the 2.x series.
|
||||
- The [`2.6.1`](https://github.com/SFML/CSFML/tree/2.6.1) tag is the latest official SFML release and will be the last minor release in the 2.x series.
|
||||
- The [`2.6.x`](https://github.com/SFML/CSFML/tree/2.6.x) branch contains the latest bugfix work on CSFML 2.6.x, matching SFML's `2.6.x` branch.
|
||||
|
||||
## Authors
|
||||
@@ -18,7 +18,6 @@ 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
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ void sfMusic_destroy(const sfMusic* music)
|
||||
void sfMusic_setLooping(sfMusic* music, bool loop)
|
||||
{
|
||||
assert(music);
|
||||
music->setLooping(loop);
|
||||
music->setLooping(loop != 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -81,17 +81,18 @@ bool sfSoundRecorder_isAvailable()
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const char* const* sfSoundRecorder_getAvailableDevices(size_t* count)
|
||||
const char** sfSoundRecorder_getAvailableDevices(size_t* count)
|
||||
{
|
||||
static const auto cstringDevices = []
|
||||
static std::vector<std::string> stringDevices = sf::SoundRecorder::getAvailableDevices();
|
||||
static std::vector<const char*> cstringDevices;
|
||||
|
||||
if (cstringDevices.empty() && !stringDevices.empty())
|
||||
{
|
||||
static const std::vector<std::string> stringDevices = sf::SoundRecorder::getAvailableDevices();
|
||||
std::vector<const char*> devices;
|
||||
devices.reserve(stringDevices.size());
|
||||
for (const auto& stringDevice : stringDevices)
|
||||
devices.push_back(stringDevice.c_str());
|
||||
return devices;
|
||||
}();
|
||||
{
|
||||
cstringDevices.push_back(stringDevice.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (count)
|
||||
*count = cstringDevices.size();
|
||||
@@ -103,7 +104,7 @@ const char* const* sfSoundRecorder_getAvailableDevices(size_t* count)
|
||||
////////////////////////////////////////////////////////////
|
||||
const char* sfSoundRecorder_getDefaultDevice()
|
||||
{
|
||||
static const std::string defaultDevice = sf::SoundRecorder::getDefaultDevice();
|
||||
static std::string defaultDevice = sf::SoundRecorder::getDefaultDevice();
|
||||
|
||||
return !defaultDevice.empty() ? defaultDevice.c_str() : nullptr;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <CSFML/System/ConvertVector2.hpp>
|
||||
#include <CSFML/System/ConvertVector3.hpp>
|
||||
#include <CSFML/Window/Event.h>
|
||||
|
||||
#include <SFML/Window/Event.hpp>
|
||||
|
||||
#include <optional>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Convert sf::Event to sfEvent
|
||||
////////////////////////////////////////////////////////////
|
||||
[[nodiscard]] inline bool convertEvent(const std::optional<sf::Event>& sfmlEvent, sfEvent* event)
|
||||
{
|
||||
if (!sfmlEvent)
|
||||
return false;
|
||||
|
||||
if (sfmlEvent->is<sf::Event::Closed>())
|
||||
{
|
||||
event->type = sfEvtClosed;
|
||||
}
|
||||
else if (const auto* resized = sfmlEvent->getIf<sf::Event::Resized>())
|
||||
{
|
||||
event->type = sfEvtResized;
|
||||
event->size.size = convertVector2(resized->size);
|
||||
}
|
||||
else if (sfmlEvent->is<sf::Event::FocusLost>())
|
||||
{
|
||||
event->type = sfEvtFocusLost;
|
||||
}
|
||||
else if (sfmlEvent->is<sf::Event::FocusGained>())
|
||||
{
|
||||
event->type = sfEvtFocusGained;
|
||||
}
|
||||
else if (const auto* textEntered = sfmlEvent->getIf<sf::Event::TextEntered>())
|
||||
{
|
||||
event->type = sfEvtTextEntered;
|
||||
event->text.unicode = textEntered->unicode;
|
||||
}
|
||||
else if (const auto* keyReleased = sfmlEvent->getIf<sf::Event::KeyReleased>())
|
||||
{
|
||||
event->type = sfEvtKeyReleased;
|
||||
event->key.code = static_cast<sfKeyCode>(keyReleased->code);
|
||||
event->key.scancode = static_cast<sfScancode>(keyReleased->scancode);
|
||||
event->key.alt = keyReleased->alt;
|
||||
event->key.control = keyReleased->control;
|
||||
event->key.shift = keyReleased->shift;
|
||||
event->key.system = keyReleased->system;
|
||||
}
|
||||
else if (const auto* keyPressed = sfmlEvent->getIf<sf::Event::KeyPressed>())
|
||||
{
|
||||
event->type = sfEvtKeyPressed;
|
||||
event->key.code = static_cast<sfKeyCode>(keyPressed->code);
|
||||
event->key.scancode = static_cast<sfScancode>(keyPressed->scancode);
|
||||
event->key.alt = keyPressed->alt;
|
||||
event->key.control = keyPressed->control;
|
||||
event->key.shift = keyPressed->shift;
|
||||
event->key.system = keyPressed->system;
|
||||
}
|
||||
else if (const auto* mouseWheelScrolled = sfmlEvent->getIf<sf::Event::MouseWheelScrolled>())
|
||||
{
|
||||
event->type = sfEvtMouseWheelScrolled;
|
||||
event->mouseWheelScroll.wheel = static_cast<sfMouseWheel>(mouseWheelScrolled->wheel);
|
||||
event->mouseWheelScroll.delta = mouseWheelScrolled->delta;
|
||||
event->mouseWheelScroll.position = convertVector2(mouseWheelScrolled->position);
|
||||
}
|
||||
else if (const auto* mouseButtonPressed = sfmlEvent->getIf<sf::Event::MouseButtonPressed>())
|
||||
{
|
||||
event->type = sfEvtMouseButtonPressed;
|
||||
event->mouseButton.button = static_cast<sfMouseButton>(mouseButtonPressed->button);
|
||||
event->mouseButton.position = convertVector2(mouseButtonPressed->position);
|
||||
}
|
||||
else if (const auto* mouseButtonReleased = sfmlEvent->getIf<sf::Event::MouseButtonReleased>())
|
||||
{
|
||||
event->type = sfEvtMouseButtonReleased;
|
||||
event->mouseButton.button = static_cast<sfMouseButton>(mouseButtonReleased->button);
|
||||
event->mouseButton.position = convertVector2(mouseButtonReleased->position);
|
||||
}
|
||||
else if (const auto* mouseMoved = sfmlEvent->getIf<sf::Event::MouseMoved>())
|
||||
{
|
||||
event->type = sfEvtMouseMoved;
|
||||
event->mouseMove.position = convertVector2(mouseMoved->position);
|
||||
}
|
||||
else if (const auto* mouseMovedRaw = sfmlEvent->getIf<sf::Event::MouseMovedRaw>())
|
||||
{
|
||||
event->type = sfEvtMouseMovedRaw;
|
||||
event->mouseMoveRaw.delta = convertVector2(mouseMovedRaw->delta);
|
||||
}
|
||||
else if (sfmlEvent->is<sf::Event::MouseEntered>())
|
||||
{
|
||||
event->type = sfEvtMouseEntered;
|
||||
}
|
||||
else if (sfmlEvent->is<sf::Event::MouseLeft>())
|
||||
{
|
||||
event->type = sfEvtMouseLeft;
|
||||
}
|
||||
else if (const auto* joystickButtonPressed = sfmlEvent->getIf<sf::Event::JoystickButtonPressed>())
|
||||
{
|
||||
event->type = sfEvtJoystickButtonPressed;
|
||||
event->joystickButton.joystickId = joystickButtonPressed->joystickId;
|
||||
event->joystickButton.button = joystickButtonPressed->button;
|
||||
}
|
||||
else if (const auto* joystickButtonReleased = sfmlEvent->getIf<sf::Event::JoystickButtonReleased>())
|
||||
{
|
||||
event->type = sfEvtJoystickButtonReleased;
|
||||
event->joystickButton.joystickId = joystickButtonReleased->joystickId;
|
||||
event->joystickButton.button = joystickButtonReleased->button;
|
||||
}
|
||||
else if (const auto* joystickMoved = sfmlEvent->getIf<sf::Event::JoystickMoved>())
|
||||
{
|
||||
event->type = sfEvtJoystickMoved;
|
||||
event->joystickMove.joystickId = joystickMoved->joystickId;
|
||||
event->joystickMove.axis = static_cast<sfJoystickAxis>(joystickMoved->axis);
|
||||
event->joystickMove.position = joystickMoved->position;
|
||||
}
|
||||
else if (const auto* joystickConnected = sfmlEvent->getIf<sf::Event::JoystickConnected>())
|
||||
{
|
||||
event->type = sfEvtJoystickConnected;
|
||||
event->joystickConnect.joystickId = joystickConnected->joystickId;
|
||||
}
|
||||
else if (const auto* joystickDisconnected = sfmlEvent->getIf<sf::Event::JoystickDisconnected>())
|
||||
{
|
||||
event->type = sfEvtJoystickDisconnected;
|
||||
event->joystickConnect.joystickId = joystickDisconnected->joystickId;
|
||||
}
|
||||
else if (const auto* touchBegan = sfmlEvent->getIf<sf::Event::TouchBegan>())
|
||||
{
|
||||
event->type = sfEvtTouchBegan;
|
||||
event->touch.finger = touchBegan->finger;
|
||||
event->touch.position = convertVector2(touchBegan->position);
|
||||
}
|
||||
else if (const auto* touchMoved = sfmlEvent->getIf<sf::Event::TouchMoved>())
|
||||
{
|
||||
event->type = sfEvtTouchMoved;
|
||||
event->touch.finger = touchMoved->finger;
|
||||
event->touch.position = convertVector2(touchMoved->position);
|
||||
}
|
||||
else if (const auto* touchEnded = sfmlEvent->getIf<sf::Event::TouchEnded>())
|
||||
{
|
||||
event->type = sfEvtTouchEnded;
|
||||
event->touch.finger = touchEnded->finger;
|
||||
event->touch.position = convertVector2(touchEnded->position);
|
||||
}
|
||||
else if (const auto* sensorChanged = sfmlEvent->getIf<sf::Event::SensorChanged>())
|
||||
{
|
||||
event->type = sfEvtSensorChanged;
|
||||
event->sensor.sensorType = static_cast<sfSensorType>(sensorChanged->type);
|
||||
event->sensor.value = convertVector3(sensorChanged->value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -19,7 +19,6 @@ set(SRC
|
||||
${SRCROOT}/ConvexShape.cpp
|
||||
${SRCROOT}/ConvexShapeStruct.hpp
|
||||
${INCROOT}/ConvexShape.h
|
||||
${INCROOT}/CoordinateType.h
|
||||
${SRCROOT}/Font.cpp
|
||||
${SRCROOT}/FontStruct.hpp
|
||||
${INCROOT}/Font.h
|
||||
|
||||
@@ -170,7 +170,7 @@ sfTransform sfCircleShape_getInverseTransform(const sfCircleShape* shape)
|
||||
void sfCircleShape_setTexture(sfCircleShape* shape, const sfTexture* texture, bool resetRect)
|
||||
{
|
||||
assert(shape);
|
||||
shape->setTexture(texture ? texture->This : nullptr, resetRect);
|
||||
shape->setTexture(texture, resetRect);
|
||||
shape->Texture = texture;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,26 +45,33 @@ const sfColor sfTransparent = sfColor_fromRGBA(0, 0, 0, 0);
|
||||
////////////////////////////////////////////////////////////
|
||||
sfColor sfColor_fromRGB(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
return {red, green, blue, 255};
|
||||
return sfColor_fromRGBA(red, green, blue, 255);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfColor sfColor_fromRGBA(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
|
||||
{
|
||||
return {red, green, blue, alpha};
|
||||
sfColor color;
|
||||
|
||||
color.r = red;
|
||||
color.g = green;
|
||||
color.b = blue;
|
||||
color.a = alpha;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfColor sfColor_fromInteger(uint32_t color)
|
||||
{
|
||||
return {
|
||||
static_cast<uint8_t>((color & 0xff000000) >> 24),
|
||||
static_cast<uint8_t>((color & 0x00ff0000) >> 16),
|
||||
static_cast<uint8_t>((color & 0x0000ff00) >> 8),
|
||||
static_cast<uint8_t>((color & 0x000000ff) >> 0),
|
||||
};
|
||||
auto red = static_cast<uint8_t>((color & 0xff000000) >> 24);
|
||||
auto green = static_cast<uint8_t>((color & 0x00ff0000) >> 16);
|
||||
auto blue = static_cast<uint8_t>((color & 0x0000ff00) >> 8);
|
||||
auto alpha = static_cast<uint8_t>((color & 0x000000ff) >> 0);
|
||||
|
||||
return sfColor_fromRGBA(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,34 +85,43 @@ uint32_t sfColor_toInteger(sfColor color)
|
||||
////////////////////////////////////////////////////////////
|
||||
sfColor sfColor_add(sfColor color1, sfColor color2)
|
||||
{
|
||||
return {
|
||||
static_cast<uint8_t>(std::min(color1.r + color2.r, 255)),
|
||||
static_cast<uint8_t>(std::min(color1.g + color2.g, 255)),
|
||||
static_cast<uint8_t>(std::min(color1.b + color2.b, 255)),
|
||||
static_cast<uint8_t>(std::min(color1.a + color2.a, 255)),
|
||||
};
|
||||
int red = std::min(color1.r + color2.r, 255);
|
||||
int green = std::min(color1.g + color2.g, 255);
|
||||
int blue = std::min(color1.b + color2.b, 255);
|
||||
int alpha = std::min(color1.a + color2.a, 255);
|
||||
|
||||
return sfColor_fromRGBA(static_cast<uint8_t>(red),
|
||||
static_cast<uint8_t>(green),
|
||||
static_cast<uint8_t>(blue),
|
||||
static_cast<uint8_t>(alpha));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfColor sfColor_subtract(sfColor color1, sfColor color2)
|
||||
{
|
||||
return {
|
||||
static_cast<uint8_t>(std::max(color1.r - color2.r, 0)),
|
||||
static_cast<uint8_t>(std::max(color1.g - color2.g, 0)),
|
||||
static_cast<uint8_t>(std::max(color1.b - color2.b, 0)),
|
||||
static_cast<uint8_t>(std::max(color1.a - color2.a, 0)),
|
||||
};
|
||||
int red = std::max(color1.r - color2.r, 0);
|
||||
int green = std::max(color1.g - color2.g, 0);
|
||||
int blue = std::max(color1.b - color2.b, 0);
|
||||
int alpha = std::max(color1.a - color2.a, 0);
|
||||
|
||||
return sfColor_fromRGBA(static_cast<uint8_t>(red),
|
||||
static_cast<uint8_t>(green),
|
||||
static_cast<uint8_t>(blue),
|
||||
static_cast<uint8_t>(alpha));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfColor sfColor_modulate(sfColor color1, sfColor color2)
|
||||
{
|
||||
return {
|
||||
static_cast<uint8_t>(color1.r * color2.r / 255),
|
||||
static_cast<uint8_t>(color1.g * color2.g / 255),
|
||||
static_cast<uint8_t>(color1.b * color2.b / 255),
|
||||
static_cast<uint8_t>(color1.a * color2.a / 255),
|
||||
};
|
||||
int red = color1.r * color2.r / 255;
|
||||
int green = color1.g * color2.g / 255;
|
||||
int blue = color1.b * color2.b / 255;
|
||||
int alpha = color1.a * color2.a / 255;
|
||||
|
||||
return sfColor_fromRGBA(static_cast<uint8_t>(red),
|
||||
static_cast<uint8_t>(green),
|
||||
static_cast<uint8_t>(blue),
|
||||
static_cast<uint8_t>(alpha));
|
||||
}
|
||||
@@ -50,15 +50,8 @@
|
||||
renderStates.blendMode.alphaSrcFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.alphaSrcFactor);
|
||||
renderStates.blendMode.alphaDstFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.alphaDstFactor);
|
||||
renderStates.blendMode.alphaEquation = static_cast<sf::BlendMode::Equation>(states->blendMode.alphaEquation);
|
||||
renderStates.stencilMode.stencilComparison = static_cast<sf::StencilComparison>(states->stencilMode.stencilComparison);
|
||||
renderStates.stencilMode.stencilUpdateOperation = static_cast<sf::StencilUpdateOperation>(
|
||||
states->stencilMode.stencilUpdateOperation);
|
||||
renderStates.stencilMode.stencilReference.value = states->stencilMode.stencilReference.value;
|
||||
renderStates.stencilMode.stencilMask.value = states->stencilMode.stencilMask.value;
|
||||
renderStates.stencilMode.stencilOnly = states->stencilMode.stencilOnly;
|
||||
renderStates.transform = convertTransform(states->transform);
|
||||
renderStates.coordinateType = static_cast<sf::CoordinateType>(states->coordinateType);
|
||||
renderStates.texture = states->texture ? states->texture->This : nullptr;
|
||||
renderStates.shader = states->shader;
|
||||
renderStates.transform = convertTransform(states->transform);
|
||||
renderStates.texture = states->texture;
|
||||
renderStates.shader = states->shader;
|
||||
return renderStates;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ sfTransform sfConvexShape_getInverseTransform(const sfConvexShape* shape)
|
||||
void sfConvexShape_setTexture(sfConvexShape* shape, const sfTexture* texture, bool resetRect)
|
||||
{
|
||||
assert(shape);
|
||||
shape->setTexture(texture ? texture->This : nullptr, resetRect);
|
||||
shape->setTexture(texture, resetRect);
|
||||
shape->Texture = texture;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ const sfTexture* sfFont_getTexture(sfFont* font, unsigned int characterSize)
|
||||
{
|
||||
assert(font);
|
||||
|
||||
*font->Textures[characterSize].This = font->getTexture(characterSize);
|
||||
font->Textures[characterSize] = sfTexture{font->getTexture(characterSize)};
|
||||
|
||||
return &font->Textures[characterSize];
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ sfTransform sfRectangleShape_getInverseTransform(const sfRectangleShape* shape)
|
||||
void sfRectangleShape_setTexture(sfRectangleShape* shape, const sfTexture* texture, bool resetRect)
|
||||
{
|
||||
assert(shape);
|
||||
shape->setTexture(texture ? texture->This : nullptr, resetRect);
|
||||
shape->setTexture(texture, resetRect);
|
||||
shape->Texture = texture;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,7 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
const sfRenderStates sfRenderStates_default = {
|
||||
sfBlendAlpha,
|
||||
sfStencilMode_default,
|
||||
sfTransform_Identity,
|
||||
sfCoordinateTypePixels,
|
||||
nullptr,
|
||||
nullptr,
|
||||
};
|
||||
@@ -54,7 +54,7 @@ sfRenderTexture* sfRenderTexture_create(sfVector2u size, const sfContextSettings
|
||||
if (!renderTexture->resize(convertVector2(size), params))
|
||||
return nullptr;
|
||||
|
||||
renderTexture->Target = std::make_unique<sfTexture>(const_cast<sf::Texture*>(&renderTexture->getTexture()));
|
||||
renderTexture->Target = sfTexture{renderTexture->getTexture()};
|
||||
renderTexture->DefaultView = sfView{renderTexture->getDefaultView()};
|
||||
renderTexture->CurrentView = sfView{renderTexture->getView()};
|
||||
|
||||
@@ -300,7 +300,7 @@ void sfRenderTexture_resetGLStates(sfRenderTexture* renderTexture)
|
||||
const sfTexture* sfRenderTexture_getTexture(const sfRenderTexture* renderTexture)
|
||||
{
|
||||
assert(renderTexture);
|
||||
return renderTexture->Target.get();
|
||||
return &renderTexture->Target;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,15 +32,13 @@
|
||||
|
||||
#include <SFML/Graphics/RenderTexture.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Internal structure of sfRenderTexture
|
||||
////////////////////////////////////////////////////////////
|
||||
struct sfRenderTexture : sf::RenderTexture
|
||||
{
|
||||
std::unique_ptr<const sfTexture> Target;
|
||||
sfView DefaultView;
|
||||
sfView CurrentView;
|
||||
sfTexture Target;
|
||||
sfView DefaultView;
|
||||
sfView CurrentView;
|
||||
};
|
||||
@@ -25,6 +25,7 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <CSFML/ConvertEvent.hpp>
|
||||
#include <CSFML/Graphics/CircleShapeStruct.hpp>
|
||||
#include <CSFML/Graphics/ConvertColor.hpp>
|
||||
#include <CSFML/Graphics/ConvertRect.hpp>
|
||||
@@ -42,7 +43,6 @@
|
||||
#include <CSFML/Graphics/VertexBufferStruct.hpp>
|
||||
#include <CSFML/System/ConvertVector2.hpp>
|
||||
#include <CSFML/Window/ConvertContextSettings.hpp>
|
||||
#include <CSFML/Window/ConvertEvent.hpp>
|
||||
#include <CSFML/Window/ConvertVideoMode.hpp>
|
||||
#include <CSFML/Window/CursorStruct.hpp>
|
||||
|
||||
@@ -145,7 +145,7 @@ bool sfRenderWindow_pollEvent(sfRenderWindow* renderWindow, sfEvent* event)
|
||||
{
|
||||
assert(renderWindow);
|
||||
assert(event);
|
||||
return convertEvent(renderWindow->pollEvent(), *event);
|
||||
return convertEvent(renderWindow->pollEvent(), event);
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ bool sfRenderWindow_waitEvent(sfRenderWindow* renderWindow, sfTime timeout, sfEv
|
||||
{
|
||||
assert(renderWindow);
|
||||
assert(event);
|
||||
return convertEvent(renderWindow->waitEvent(sf::microseconds(timeout.microseconds)), *event);
|
||||
return convertEvent(renderWindow->waitEvent(sf::microseconds(timeout.microseconds)), event);
|
||||
}
|
||||
|
||||
|
||||
@@ -198,38 +198,6 @@ 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)
|
||||
{
|
||||
|
||||
+116
-88
@@ -37,28 +37,41 @@ sfShader* sfShader_createFromFile(const char* vertexShaderFilename,
|
||||
const char* geometryShaderFilename,
|
||||
const char* fragmentShaderFilename)
|
||||
{
|
||||
// At least one shader must be provided
|
||||
if (!(vertexShaderFilename || geometryShaderFilename || fragmentShaderFilename))
|
||||
return nullptr;
|
||||
|
||||
bool success = false;
|
||||
auto shader = std::make_unique<sfShader>();
|
||||
|
||||
if (!geometryShaderFilename)
|
||||
if (vertexShaderFilename || geometryShaderFilename || fragmentShaderFilename)
|
||||
{
|
||||
if (!vertexShaderFilename) // fragment shader only
|
||||
success = shader->loadFromFile(fragmentShaderFilename, sf::Shader::Type::Fragment);
|
||||
else if (!fragmentShaderFilename) // vertex shader only
|
||||
success = shader->loadFromFile(vertexShaderFilename, sf::Shader::Type::Vertex);
|
||||
else // vertex + fragment shaders
|
||||
success = shader->loadFromFile(vertexShaderFilename, fragmentShaderFilename);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!vertexShaderFilename && !fragmentShaderFilename) // geometry shader only
|
||||
success = shader->loadFromFile(geometryShaderFilename, sf::Shader::Type::Geometry);
|
||||
else // vertex + geometry + fragment shaders
|
||||
success = shader->loadFromFile(vertexShaderFilename, geometryShaderFilename, fragmentShaderFilename);
|
||||
if (!geometryShaderFilename)
|
||||
{
|
||||
if (!vertexShaderFilename)
|
||||
{
|
||||
// fragment shader only
|
||||
success = shader->loadFromFile(fragmentShaderFilename, sf::Shader::Type::Fragment);
|
||||
}
|
||||
else if (!fragmentShaderFilename)
|
||||
{
|
||||
// vertex shader only
|
||||
success = shader->loadFromFile(vertexShaderFilename, sf::Shader::Type::Vertex);
|
||||
}
|
||||
else
|
||||
{
|
||||
// vertex + fragment shaders
|
||||
success = shader->loadFromFile(vertexShaderFilename, fragmentShaderFilename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!vertexShaderFilename && !fragmentShaderFilename)
|
||||
{
|
||||
// geometry shader only
|
||||
success = shader->loadFromFile(geometryShaderFilename, sf::Shader::Type::Geometry);
|
||||
}
|
||||
else
|
||||
{
|
||||
// vertex + geometry + fragment shaders
|
||||
success = shader->loadFromFile(vertexShaderFilename, geometryShaderFilename, fragmentShaderFilename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!success)
|
||||
@@ -71,28 +84,41 @@ sfShader* sfShader_createFromFile(const char* vertexShaderFilename,
|
||||
////////////////////////////////////////////////////////////
|
||||
sfShader* sfShader_createFromMemory(const char* vertexShader, const char* geometryShader, const char* fragmentShader)
|
||||
{
|
||||
// At least one shader must be provided
|
||||
if (!(vertexShader || geometryShader || fragmentShader))
|
||||
return nullptr;
|
||||
|
||||
bool success = false;
|
||||
auto shader = std::make_unique<sfShader>();
|
||||
|
||||
if (!geometryShader)
|
||||
if (vertexShader || geometryShader || fragmentShader)
|
||||
{
|
||||
if (!vertexShader) // fragment shader only
|
||||
success = shader->loadFromMemory(fragmentShader, sf::Shader::Type::Fragment);
|
||||
else if (!fragmentShader) // vertex shader only
|
||||
success = shader->loadFromMemory(vertexShader, sf::Shader::Type::Vertex);
|
||||
else // vertex + fragment shaders
|
||||
success = shader->loadFromMemory(vertexShader, fragmentShader);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!vertexShader && !fragmentShader) // geometry shader only
|
||||
success = shader->loadFromMemory(geometryShader, sf::Shader::Type::Geometry);
|
||||
else // vertex + geometry + fragment shaders
|
||||
success = shader->loadFromMemory(vertexShader, geometryShader, fragmentShader);
|
||||
if (!geometryShader)
|
||||
{
|
||||
if (!vertexShader)
|
||||
{
|
||||
// fragment shader only
|
||||
success = shader->loadFromMemory(fragmentShader, sf::Shader::Type::Fragment);
|
||||
}
|
||||
else if (!fragmentShader)
|
||||
{
|
||||
// vertex shader only
|
||||
success = shader->loadFromMemory(vertexShader, sf::Shader::Type::Vertex);
|
||||
}
|
||||
else
|
||||
{
|
||||
// vertex + fragment shaders
|
||||
success = shader->loadFromMemory(vertexShader, fragmentShader);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!vertexShader && !fragmentShader)
|
||||
{
|
||||
// geometry shader only
|
||||
success = shader->loadFromMemory(geometryShader, sf::Shader::Type::Geometry);
|
||||
}
|
||||
else
|
||||
{
|
||||
// vertex + geometry + fragment shaders
|
||||
success = shader->loadFromMemory(vertexShader, geometryShader, fragmentShader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!success)
|
||||
@@ -107,44 +133,47 @@ sfShader* sfShader_createFromStream(sfInputStream* vertexShaderStream,
|
||||
sfInputStream* geometryShaderStream,
|
||||
sfInputStream* fragmentShaderStream)
|
||||
{
|
||||
// At least one shader must be provided
|
||||
if (!(vertexShaderStream || geometryShaderStream || fragmentShaderStream))
|
||||
return nullptr;
|
||||
|
||||
bool success = false;
|
||||
auto shader = std::make_unique<sfShader>();
|
||||
|
||||
if (!geometryShaderStream)
|
||||
if (vertexShaderStream || geometryShaderStream || fragmentShaderStream)
|
||||
{
|
||||
if (!vertexShaderStream) // fragment shader only
|
||||
if (!geometryShaderStream)
|
||||
{
|
||||
CallbackStream stream(fragmentShaderStream);
|
||||
success = shader->loadFromStream(stream, sf::Shader::Type::Fragment);
|
||||
if (!vertexShaderStream)
|
||||
{
|
||||
// fragment shader only
|
||||
CallbackStream stream(fragmentShaderStream);
|
||||
success = shader->loadFromStream(stream, sf::Shader::Type::Fragment);
|
||||
}
|
||||
else if (!fragmentShaderStream)
|
||||
{
|
||||
// vertex shader only
|
||||
CallbackStream stream(vertexShaderStream);
|
||||
success = shader->loadFromStream(stream, sf::Shader::Type::Vertex);
|
||||
}
|
||||
else
|
||||
{
|
||||
// vertex + fragment shaders
|
||||
CallbackStream vertexStream(vertexShaderStream);
|
||||
CallbackStream fragmentStream(fragmentShaderStream);
|
||||
success = shader->loadFromStream(vertexStream, fragmentStream);
|
||||
}
|
||||
}
|
||||
else if (!fragmentShaderStream) // vertex shader only
|
||||
else
|
||||
{
|
||||
CallbackStream stream(vertexShaderStream);
|
||||
success = shader->loadFromStream(stream, sf::Shader::Type::Vertex);
|
||||
}
|
||||
else // vertex + fragment shaders
|
||||
{
|
||||
CallbackStream vertexStream(vertexShaderStream);
|
||||
CallbackStream fragmentStream(fragmentShaderStream);
|
||||
success = shader->loadFromStream(vertexStream, fragmentStream);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CallbackStream geometryStream(geometryShaderStream);
|
||||
if (!vertexShaderStream && !fragmentShaderStream) // geometry shader only
|
||||
{
|
||||
success = shader->loadFromStream(geometryStream, sf::Shader::Type::Geometry);
|
||||
}
|
||||
else // vertex + geometry + fragment shaders
|
||||
{
|
||||
CallbackStream vertexStream(vertexShaderStream);
|
||||
CallbackStream fragmentStream(fragmentShaderStream);
|
||||
success = shader->loadFromStream(vertexStream, geometryStream, fragmentStream);
|
||||
CallbackStream geometryStream(geometryShaderStream);
|
||||
if (!vertexShaderStream && !fragmentShaderStream)
|
||||
{
|
||||
// geometry shader only
|
||||
success = shader->loadFromStream(geometryStream, sf::Shader::Type::Geometry);
|
||||
}
|
||||
else
|
||||
{
|
||||
// vertex + geometry + fragment shaders
|
||||
CallbackStream vertexStream(vertexShaderStream);
|
||||
CallbackStream fragmentStream(fragmentShaderStream);
|
||||
success = shader->loadFromStream(vertexStream, geometryStream, fragmentStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,14 +230,13 @@ void sfShader_setVec4Uniform(sfShader* shader, const char* name, sfGlslVec4 vect
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfShader_setColorUniform(sfShader* shader, const char* name, sfColor color)
|
||||
{
|
||||
sfShader_setVec4Uniform(shader,
|
||||
name,
|
||||
{
|
||||
color.r / 255.f,
|
||||
color.g / 255.f,
|
||||
color.b / 255.f,
|
||||
color.a / 255.f,
|
||||
});
|
||||
sfGlslVec4 vec4;
|
||||
vec4.x = color.r / 255.f;
|
||||
vec4.y = color.g / 255.f;
|
||||
vec4.z = color.b / 255.f;
|
||||
vec4.w = color.a / 255.f;
|
||||
|
||||
sfShader_setVec4Uniform(shader, name, vec4);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@@ -250,14 +278,13 @@ void sfShader_setIvec4Uniform(sfShader* shader, const char* name, sfGlslIvec4 ve
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfShader_setIntColorUniform(sfShader* shader, const char* name, sfColor color)
|
||||
{
|
||||
sfShader_setIvec4Uniform(shader,
|
||||
name,
|
||||
{
|
||||
color.r,
|
||||
color.g,
|
||||
color.b,
|
||||
color.a,
|
||||
});
|
||||
sfGlslIvec4 ivec4;
|
||||
ivec4.x = static_cast<int>(color.r);
|
||||
ivec4.y = static_cast<int>(color.g);
|
||||
ivec4.z = static_cast<int>(color.b);
|
||||
ivec4.w = static_cast<int>(color.a);
|
||||
|
||||
sfShader_setIvec4Uniform(shader, name, ivec4);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@@ -319,7 +346,8 @@ void sfShader_setTextureUniform(sfShader* shader, const char* name, const sfText
|
||||
{
|
||||
assert(shader);
|
||||
assert(name);
|
||||
shader->setUniform(name, *texture->This);
|
||||
assert(texture);
|
||||
shader->setUniform(name, *texture);
|
||||
}
|
||||
|
||||
|
||||
@@ -392,7 +420,7 @@ void sfShader_setTextureParameter(sfShader* shader, const char* name, const sfTe
|
||||
assert(shader);
|
||||
assert(name);
|
||||
assert(texture);
|
||||
shader->setUniform(name, *texture->This);
|
||||
shader->setUniform(name, *texture);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ sfTransform sfShape_getInverseTransform(const sfShape* shape)
|
||||
void sfShape_setTexture(sfShape* shape, const sfTexture* texture, bool resetRect)
|
||||
{
|
||||
assert(shape);
|
||||
shape->setTexture(texture ? texture->This : nullptr, resetRect);
|
||||
shape->setTexture(texture, resetRect);
|
||||
shape->Texture = texture;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,7 @@
|
||||
sfSprite* sfSprite_create(const sfTexture* texture)
|
||||
{
|
||||
assert(texture);
|
||||
assert(texture->This);
|
||||
auto sprite = new sfSprite(*texture->This);
|
||||
auto sprite = new sfSprite(*texture);
|
||||
sprite->Texture = texture;
|
||||
return sprite;
|
||||
}
|
||||
@@ -171,10 +170,10 @@ sfTransform sfSprite_getInverseTransform(const sfSprite* sprite)
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfSprite_setTexture(sfSprite* sprite, const sfTexture* texture, bool resetRect)
|
||||
{
|
||||
if (texture && texture->This)
|
||||
if (texture)
|
||||
{
|
||||
assert(sprite);
|
||||
sprite->setTexture(*texture->This, resetRect);
|
||||
sprite->setTexture(*texture, resetRect);
|
||||
sprite->Texture = texture;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
sfTexture* sfTexture_create(sfVector2u size)
|
||||
{
|
||||
auto texture = std::make_unique<sfTexture>();
|
||||
if (!texture->This->resize(convertVector2(size)))
|
||||
if (!texture->resize(convertVector2(size)))
|
||||
return nullptr;
|
||||
|
||||
return texture.release();
|
||||
@@ -52,7 +52,7 @@ sfTexture* sfTexture_create(sfVector2u size)
|
||||
sfTexture* sfTexture_createSrgb(sfVector2u size)
|
||||
{
|
||||
auto texture = std::make_unique<sfTexture>();
|
||||
if (!texture->This->resize(convertVector2(size), true))
|
||||
if (!texture->resize(convertVector2(size), true))
|
||||
return nullptr;
|
||||
|
||||
return texture.release();
|
||||
@@ -65,7 +65,7 @@ sfTexture* sfTexture_createFromFile(const char* filename, const sfIntRect* area)
|
||||
assert(filename);
|
||||
|
||||
auto texture = std::make_unique<sfTexture>();
|
||||
if (!texture->This->loadFromFile(filename, false, area ? convertRect(*area) : sf::IntRect()))
|
||||
if (!texture->loadFromFile(filename, false, area ? convertRect(*area) : sf::IntRect()))
|
||||
return nullptr;
|
||||
|
||||
return texture.release();
|
||||
@@ -77,7 +77,7 @@ sfTexture* sfTexture_createSrgbFromFile(const char* filename, const sfIntRect* a
|
||||
assert(filename);
|
||||
|
||||
auto texture = std::make_unique<sfTexture>();
|
||||
if (!texture->This->loadFromFile(filename, true, area ? convertRect(*area) : sf::IntRect()))
|
||||
if (!texture->loadFromFile(filename, true, area ? convertRect(*area) : sf::IntRect()))
|
||||
return nullptr;
|
||||
|
||||
return texture.release();
|
||||
@@ -87,7 +87,7 @@ sfTexture* sfTexture_createSrgbFromFile(const char* filename, const sfIntRect* a
|
||||
sfTexture* sfTexture_createFromMemory(const void* data, size_t sizeInBytes, const sfIntRect* area)
|
||||
{
|
||||
auto texture = std::make_unique<sfTexture>();
|
||||
if (!texture->This->loadFromMemory(data, sizeInBytes, false, area ? convertRect(*area) : sf::IntRect()))
|
||||
if (!texture->loadFromMemory(data, sizeInBytes, false, area ? convertRect(*area) : sf::IntRect()))
|
||||
return nullptr;
|
||||
|
||||
return texture.release();
|
||||
@@ -97,7 +97,7 @@ sfTexture* sfTexture_createFromMemory(const void* data, size_t sizeInBytes, cons
|
||||
sfTexture* sfTexture_createSrgbFromMemory(const void* data, size_t sizeInBytes, const sfIntRect* area)
|
||||
{
|
||||
auto texture = std::make_unique<sfTexture>();
|
||||
if (!texture->This->loadFromMemory(data, sizeInBytes, true, area ? convertRect(*area) : sf::IntRect()))
|
||||
if (!texture->loadFromMemory(data, sizeInBytes, true, area ? convertRect(*area) : sf::IntRect()))
|
||||
return nullptr;
|
||||
|
||||
return texture.release();
|
||||
@@ -111,7 +111,7 @@ sfTexture* sfTexture_createFromStream(sfInputStream* stream, const sfIntRect* ar
|
||||
|
||||
CallbackStream sfmlStream(stream);
|
||||
auto texture = std::make_unique<sfTexture>();
|
||||
if (!texture->This->loadFromStream(sfmlStream, false, area ? convertRect(*area) : sf::IntRect()))
|
||||
if (!texture->loadFromStream(sfmlStream, false, area ? convertRect(*area) : sf::IntRect()))
|
||||
return nullptr;
|
||||
|
||||
return texture.release();
|
||||
@@ -124,7 +124,7 @@ sfTexture* sfTexture_createSrgbFromStream(sfInputStream* stream, const sfIntRect
|
||||
|
||||
CallbackStream sfmlStream(stream);
|
||||
auto texture = std::make_unique<sfTexture>();
|
||||
if (!texture->This->loadFromStream(sfmlStream, true, area ? convertRect(*area) : sf::IntRect()))
|
||||
if (!texture->loadFromStream(sfmlStream, true, area ? convertRect(*area) : sf::IntRect()))
|
||||
return nullptr;
|
||||
|
||||
return texture.release();
|
||||
@@ -137,7 +137,7 @@ sfTexture* sfTexture_createFromImage(const sfImage* image, const sfIntRect* area
|
||||
assert(image);
|
||||
|
||||
auto texture = std::make_unique<sfTexture>();
|
||||
if (!texture->This->loadFromImage(*image, false, area ? convertRect(*area) : sf::IntRect()))
|
||||
if (!texture->loadFromImage(*image, false, area ? convertRect(*area) : sf::IntRect()))
|
||||
return nullptr;
|
||||
|
||||
return texture.release();
|
||||
@@ -149,7 +149,7 @@ sfTexture* sfTexture_createSrgbFromImage(const sfImage* image, const sfIntRect*
|
||||
assert(image);
|
||||
|
||||
auto texture = std::make_unique<sfTexture>();
|
||||
if (!texture->This->loadFromImage(*image, true, area ? convertRect(*area) : sf::IntRect()))
|
||||
if (!texture->loadFromImage(*image, true, area ? convertRect(*area) : sf::IntRect()))
|
||||
return nullptr;
|
||||
|
||||
return texture.release();
|
||||
@@ -170,20 +170,11 @@ void sfTexture_destroy(const sfTexture* texture)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool sfTexture_resize(sfTexture* texture, sfVector2u size, bool sRgb)
|
||||
{
|
||||
assert(texture);
|
||||
assert(texture->This);
|
||||
return texture->This->resize(convertVector2(size), sRgb);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfVector2u sfTexture_getSize(const sfTexture* texture)
|
||||
{
|
||||
assert(texture);
|
||||
return convertVector2(texture->This->getSize());
|
||||
return convertVector2(texture->getSize());
|
||||
}
|
||||
|
||||
|
||||
@@ -191,8 +182,7 @@ sfVector2u sfTexture_getSize(const sfTexture* texture)
|
||||
sfImage* sfTexture_copyToImage(const sfTexture* texture)
|
||||
{
|
||||
assert(texture);
|
||||
assert(texture->This);
|
||||
return new sfImage{texture->This->copyToImage()};
|
||||
return new sfImage{texture->copyToImage()};
|
||||
}
|
||||
|
||||
|
||||
@@ -200,7 +190,7 @@ sfImage* sfTexture_copyToImage(const sfTexture* texture)
|
||||
void sfTexture_updateFromPixels(sfTexture* texture, const uint8_t* pixels, sfVector2u size, sfVector2u offset)
|
||||
{
|
||||
assert(texture);
|
||||
texture->This->update(pixels, convertVector2(size), convertVector2(offset));
|
||||
texture->update(pixels, convertVector2(size), convertVector2(offset));
|
||||
}
|
||||
|
||||
|
||||
@@ -209,8 +199,7 @@ void sfTexture_updateFromTexture(sfTexture* destination, const sfTexture* textur
|
||||
{
|
||||
assert(destination);
|
||||
assert(texture);
|
||||
assert(texture->This);
|
||||
destination->This->update(*texture->This, convertVector2(offset));
|
||||
destination->update(*texture, convertVector2(offset));
|
||||
}
|
||||
|
||||
|
||||
@@ -219,7 +208,7 @@ void sfTexture_updateFromImage(sfTexture* texture, const sfImage* image, sfVecto
|
||||
{
|
||||
assert(texture);
|
||||
assert(image);
|
||||
texture->This->update(*image, convertVector2(offset));
|
||||
texture->update(*image, convertVector2(offset));
|
||||
}
|
||||
|
||||
|
||||
@@ -228,7 +217,7 @@ void sfTexture_updateFromWindow(sfTexture* texture, const sfWindow* window, sfVe
|
||||
{
|
||||
assert(texture);
|
||||
assert(window);
|
||||
texture->This->update(*window, convertVector2(offset));
|
||||
texture->update(*window, convertVector2(offset));
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +226,7 @@ void sfTexture_updateFromRenderWindow(sfTexture* texture, const sfRenderWindow*
|
||||
{
|
||||
assert(texture);
|
||||
assert(renderWindow);
|
||||
texture->This->update(*renderWindow, convertVector2(offset));
|
||||
texture->update(*renderWindow, convertVector2(offset));
|
||||
}
|
||||
|
||||
|
||||
@@ -245,7 +234,7 @@ void sfTexture_updateFromRenderWindow(sfTexture* texture, const sfRenderWindow*
|
||||
void sfTexture_setSmooth(sfTexture* texture, bool smooth)
|
||||
{
|
||||
assert(texture);
|
||||
texture->This->setSmooth(smooth);
|
||||
texture->setSmooth(smooth);
|
||||
}
|
||||
|
||||
|
||||
@@ -253,15 +242,14 @@ void sfTexture_setSmooth(sfTexture* texture, bool smooth)
|
||||
bool sfTexture_isSmooth(const sfTexture* texture)
|
||||
{
|
||||
assert(texture);
|
||||
assert(texture->This);
|
||||
return texture->This->isSmooth();
|
||||
return texture->isSmooth();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool sfTexture_isSrgb(const sfTexture* texture)
|
||||
{
|
||||
assert(texture);
|
||||
return texture->This->isSrgb();
|
||||
return texture->isSrgb();
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +257,7 @@ bool sfTexture_isSrgb(const sfTexture* texture)
|
||||
void sfTexture_setRepeated(sfTexture* texture, bool repeated)
|
||||
{
|
||||
assert(texture);
|
||||
texture->This->setRepeated(repeated);
|
||||
texture->setRepeated(repeated);
|
||||
}
|
||||
|
||||
|
||||
@@ -277,8 +265,7 @@ void sfTexture_setRepeated(sfTexture* texture, bool repeated)
|
||||
bool sfTexture_isRepeated(const sfTexture* texture)
|
||||
{
|
||||
assert(texture);
|
||||
assert(texture->This);
|
||||
return texture->This->isRepeated();
|
||||
return texture->isRepeated();
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +273,7 @@ bool sfTexture_isRepeated(const sfTexture* texture)
|
||||
bool sfTexture_generateMipmap(sfTexture* texture)
|
||||
{
|
||||
assert(texture);
|
||||
return texture->This->generateMipmap();
|
||||
return texture->generateMipmap();
|
||||
}
|
||||
|
||||
|
||||
@@ -295,7 +282,7 @@ void sfTexture_swap(sfTexture* left, sfTexture* right)
|
||||
{
|
||||
assert(left);
|
||||
assert(right);
|
||||
left->This->swap(*right->This);
|
||||
left->swap(*right);
|
||||
}
|
||||
|
||||
|
||||
@@ -303,14 +290,14 @@ void sfTexture_swap(sfTexture* left, sfTexture* right)
|
||||
unsigned int sfTexture_getNativeHandle(const sfTexture* texture)
|
||||
{
|
||||
assert(texture);
|
||||
return texture->This->getNativeHandle();
|
||||
return texture->getNativeHandle();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfTexture_bind(const sfTexture* texture, sfCoordinateType type)
|
||||
void sfTexture_bind(const sfTexture* texture, sfTextureCoordinateType type)
|
||||
{
|
||||
sf::Texture::bind(texture ? texture->This : nullptr, static_cast<sf::CoordinateType>(type));
|
||||
sf::Texture::bind(texture, static_cast<sf::CoordinateType>(type));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,24 +33,6 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
// Internal structure of sfTexture
|
||||
////////////////////////////////////////////////////////////
|
||||
struct sfTexture
|
||||
struct sfTexture : sf::Texture
|
||||
{
|
||||
sfTexture() = default;
|
||||
|
||||
sfTexture(sf::Texture* texture) : This(texture), OwnInstance(false)
|
||||
{
|
||||
}
|
||||
|
||||
sfTexture(const sfTexture& texture) : This(texture.This ? new sf::Texture(*texture.This) : nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
~sfTexture()
|
||||
{
|
||||
if (OwnInstance)
|
||||
delete This;
|
||||
}
|
||||
|
||||
sf::Texture* This{new sf::Texture};
|
||||
bool OwnInstance{true};
|
||||
};
|
||||
@@ -48,13 +48,8 @@ const sfTransform sfTransform_Identity = {
|
||||
////////////////////////////////////////////////////////////
|
||||
sfTransform sfTransform_fromMatrix(float a00, float a01, float a02, float a10, float a11, float a12, float a20, float a21, float a22)
|
||||
{
|
||||
// clang-format off
|
||||
return {
|
||||
a00, a01, a02,
|
||||
a10, a11, a12,
|
||||
a20, a21, a22,
|
||||
};
|
||||
// clang-format on
|
||||
sfTransform transform = {a00, a01, a02, a10, a11, a12, a20, a21, a22};
|
||||
return transform;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,9 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
sfTransformable* sfTransformable_create()
|
||||
{
|
||||
return new sfTransformable;
|
||||
auto* transformable = new sfTransformable;
|
||||
|
||||
return transformable;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ void sfVertexArray_setPrimitiveType(sfVertexArray* vertexArray, sfPrimitiveType
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfPrimitiveType sfVertexArray_getPrimitiveType(const sfVertexArray* vertexArray)
|
||||
sfPrimitiveType sfVertexArray_getPrimitiveType(sfVertexArray* vertexArray)
|
||||
{
|
||||
assert(vertexArray);
|
||||
return static_cast<sfPrimitiveType>(vertexArray->getPrimitiveType());
|
||||
@@ -112,7 +112,7 @@ sfPrimitiveType sfVertexArray_getPrimitiveType(const sfVertexArray* vertexArray)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfFloatRect sfVertexArray_getBounds(const sfVertexArray* vertexArray)
|
||||
sfFloatRect sfVertexArray_getBounds(sfVertexArray* vertexArray)
|
||||
{
|
||||
assert(vertexArray);
|
||||
return convertRect(vertexArray->getBounds());
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfVertexBuffer* sfVertexBuffer_create(size_t vertexCount, sfPrimitiveType type, sfVertexBufferUsage usage)
|
||||
sfVertexBuffer* sfVertexBuffer_create(unsigned int vertexCount, sfPrimitiveType type, sfVertexBufferUsage usage)
|
||||
{
|
||||
auto buffer = std::make_unique<sfVertexBuffer>();
|
||||
if (!buffer->create(vertexCount))
|
||||
@@ -92,7 +92,7 @@ void sfVertexBuffer_swap(sfVertexBuffer* left, sfVertexBuffer* right)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int sfVertexBuffer_getNativeHandle(const sfVertexBuffer* vertexBuffer)
|
||||
unsigned int sfVertexBuffer_getNativeHandle(sfVertexBuffer* vertexBuffer)
|
||||
{
|
||||
assert(vertexBuffer);
|
||||
return vertexBuffer->getNativeHandle();
|
||||
|
||||
@@ -51,8 +51,6 @@ static_assert(alignof(sfChar32) == alignof(char32_t));
|
||||
{
|
||||
const std::size_t byteCount = sizeof(sfChar32) * str.getSize();
|
||||
auto* utf32 = static_cast<sfChar32*>(std::malloc(byteCount + sizeof(sfChar32)));
|
||||
if (!utf32)
|
||||
return nullptr;
|
||||
std::memcpy(utf32, str.getData(), byteCount);
|
||||
utf32[str.getSize()] = 0;
|
||||
|
||||
|
||||
@@ -37,18 +37,26 @@ namespace
|
||||
// Helper function for converting a SFML address to a CSFML one
|
||||
[[nodiscard]] sfIpAddress fromSFMLAddress(std::optional<sf::IpAddress> address)
|
||||
{
|
||||
if (!address)
|
||||
return sfIpAddress_None;
|
||||
sfIpAddress result = {0};
|
||||
|
||||
if (address)
|
||||
{
|
||||
strncpy(result.address, address->toString().c_str(), 15);
|
||||
}
|
||||
|
||||
sfIpAddress result{};
|
||||
std::strncpy(result.address, address->toString().c_str(), 15);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Helper function for converting a CSFML address to a SFML one
|
||||
[[nodiscard]] std::optional<sf::IpAddress> toSFMLAddress(sfIpAddress address)
|
||||
{
|
||||
return sf::IpAddress::resolve(address.address);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const sfIpAddress sfIpAddress_None = {{0}};
|
||||
const sfIpAddress sfIpAddress_None = sfIpAddress_fromBytes(0, 0, 0, 0);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@@ -89,14 +97,14 @@ sfIpAddress sfIpAddress_fromInteger(uint32_t address)
|
||||
void sfIpAddress_toString(sfIpAddress address, char* string)
|
||||
{
|
||||
if (string)
|
||||
std::strcpy(string, address.address);
|
||||
strcpy(string, address.address);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
uint32_t sfIpAddress_toInteger(sfIpAddress address)
|
||||
{
|
||||
const auto sfmlAddress = sf::IpAddress::resolve(address.address);
|
||||
auto sfmlAddress = toSFMLAddress(address);
|
||||
return sfmlAddress ? sfmlAddress->toInteger() : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ bool sfPacket_endOfPacket(const sfPacket* packet)
|
||||
bool sfPacket_canRead(const sfPacket* packet)
|
||||
{
|
||||
assert(packet);
|
||||
return bool{*packet};
|
||||
return static_cast<bool>(*packet);
|
||||
}
|
||||
|
||||
|
||||
@@ -156,20 +156,6 @@ uint32_t sfPacket_readUint32(sfPacket* packet)
|
||||
*packet >> 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)
|
||||
{
|
||||
assert(packet);
|
||||
@@ -233,16 +219,6 @@ void sfPacket_writeUint32(sfPacket* packet, uint32_t value)
|
||||
assert(packet);
|
||||
*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)
|
||||
{
|
||||
assert(packet);
|
||||
|
||||
@@ -86,14 +86,6 @@ sfSocketStatus sfTcpListener_listen(sfTcpListener* listener, unsigned short port
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfTcpListener_close(sfTcpListener* listener)
|
||||
{
|
||||
assert(listener);
|
||||
listener->close();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfSocketStatus sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket** connected)
|
||||
{
|
||||
@@ -110,10 +102,3 @@ sfSocketStatus sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket** conne
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned short sfTcpListener_anyPort()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ sfIpAddress sfTcpSocket_getRemoteAddress(const sfTcpSocket* socket)
|
||||
sfIpAddress result = sfIpAddress_None;
|
||||
if (address)
|
||||
{
|
||||
std::strncpy(result.address, address->toString().c_str(), 15);
|
||||
strncpy(result.address, address->toString().c_str(), 15);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -139,7 +139,7 @@ sfSocketStatus sfUdpSocket_receive(sfUdpSocket* socket,
|
||||
|
||||
if (address)
|
||||
{
|
||||
std::strncpy(remoteAddress->address, address->toString().c_str(), 15);
|
||||
strncpy(remoteAddress->address, address->toString().c_str(), 15);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ sfSocketStatus sfUdpSocket_receivePacket(sfUdpSocket* socket, sfPacket* packet,
|
||||
|
||||
if (address)
|
||||
{
|
||||
std::strncpy(remoteAddress->address, address->toString().c_str(), 15);
|
||||
strncpy(remoteAddress->address, address->toString().c_str(), 15);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,10 +203,3 @@ unsigned int sfUdpSocket_maxDatagramSize()
|
||||
{
|
||||
return sf::UdpSocket::MaxDatagramSize;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned short sfUdpSocket_anyPort()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -33,5 +33,5 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfFree(void* ptr)
|
||||
{
|
||||
std::free(ptr);
|
||||
free(ptr);
|
||||
}
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const sfTime sfTime_Zero = {0};
|
||||
sfTime sfTime_Zero = {0};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@@ -56,19 +56,25 @@ int64_t sfTime_asMicroseconds(sfTime time)
|
||||
////////////////////////////////////////////////////////////
|
||||
sfTime sfSeconds(float amount)
|
||||
{
|
||||
return {static_cast<int64_t>(amount * 1000000)};
|
||||
sfTime time;
|
||||
time.microseconds = static_cast<int64_t>(amount * 1000000);
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfTime sfMilliseconds(int32_t amount)
|
||||
{
|
||||
return {int64_t{amount} * 1000};
|
||||
sfTime time;
|
||||
time.microseconds = static_cast<int64_t>(amount) * 1000;
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfTime sfMicroseconds(int64_t amount)
|
||||
{
|
||||
return {amount};
|
||||
sfTime time;
|
||||
time.microseconds = amount;
|
||||
return time;
|
||||
}
|
||||
@@ -13,7 +13,6 @@ set(SRC
|
||||
${SRCROOT}/ContextStruct.hpp
|
||||
${INCROOT}/Context.h
|
||||
${SRCROOT}/ConvertContextSettings.hpp
|
||||
${SRCROOT}/ConvertEvent.hpp
|
||||
${SRCROOT}/ConvertVideoMode.hpp
|
||||
${INCROOT}/Event.h
|
||||
${SRCROOT}/Joystick.cpp
|
||||
|
||||
@@ -1,181 +0,0 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <CSFML/System/ConvertVector2.hpp>
|
||||
#include <CSFML/System/ConvertVector3.hpp>
|
||||
#include <CSFML/Window/Event.h>
|
||||
|
||||
#include <SFML/Window/Event.hpp>
|
||||
|
||||
#include <optional>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Convert sf::Event to sfEvent
|
||||
////////////////////////////////////////////////////////////
|
||||
[[nodiscard]] inline bool convertEvent(const std::optional<sf::Event>& sfmlEvent, sfEvent& event)
|
||||
{
|
||||
if (!sfmlEvent)
|
||||
return false;
|
||||
|
||||
if (sfmlEvent->is<sf::Event::Closed>())
|
||||
{
|
||||
event.type = sfEvtClosed;
|
||||
}
|
||||
else if (const auto* resized = sfmlEvent->getIf<sf::Event::Resized>())
|
||||
{
|
||||
event.type = sfEvtResized;
|
||||
event.size.size = convertVector2(resized->size);
|
||||
}
|
||||
else if (sfmlEvent->is<sf::Event::FocusLost>())
|
||||
{
|
||||
event.type = sfEvtFocusLost;
|
||||
}
|
||||
else if (sfmlEvent->is<sf::Event::FocusGained>())
|
||||
{
|
||||
event.type = sfEvtFocusGained;
|
||||
}
|
||||
else if (const auto* textEntered = sfmlEvent->getIf<sf::Event::TextEntered>())
|
||||
{
|
||||
event.type = sfEvtTextEntered;
|
||||
event.text.unicode = textEntered->unicode;
|
||||
}
|
||||
else if (const auto* keyReleased = sfmlEvent->getIf<sf::Event::KeyReleased>())
|
||||
{
|
||||
event.type = sfEvtKeyReleased;
|
||||
event.key.code = static_cast<sfKeyCode>(keyReleased->code);
|
||||
event.key.scancode = static_cast<sfScancode>(keyReleased->scancode);
|
||||
event.key.alt = keyReleased->alt;
|
||||
event.key.control = keyReleased->control;
|
||||
event.key.shift = keyReleased->shift;
|
||||
event.key.system = keyReleased->system;
|
||||
}
|
||||
else if (const auto* keyPressed = sfmlEvent->getIf<sf::Event::KeyPressed>())
|
||||
{
|
||||
event.type = sfEvtKeyPressed;
|
||||
event.key.code = static_cast<sfKeyCode>(keyPressed->code);
|
||||
event.key.scancode = static_cast<sfScancode>(keyPressed->scancode);
|
||||
event.key.alt = keyPressed->alt;
|
||||
event.key.control = keyPressed->control;
|
||||
event.key.shift = keyPressed->shift;
|
||||
event.key.system = keyPressed->system;
|
||||
}
|
||||
else if (const auto* mouseWheelScrolled = sfmlEvent->getIf<sf::Event::MouseWheelScrolled>())
|
||||
{
|
||||
event.type = sfEvtMouseWheelScrolled;
|
||||
event.mouseWheelScroll.wheel = static_cast<sfMouseWheel>(mouseWheelScrolled->wheel);
|
||||
event.mouseWheelScroll.delta = mouseWheelScrolled->delta;
|
||||
event.mouseWheelScroll.position = convertVector2(mouseWheelScrolled->position);
|
||||
}
|
||||
else if (const auto* mouseButtonPressed = sfmlEvent->getIf<sf::Event::MouseButtonPressed>())
|
||||
{
|
||||
event.type = sfEvtMouseButtonPressed;
|
||||
event.mouseButton.button = static_cast<sfMouseButton>(mouseButtonPressed->button);
|
||||
event.mouseButton.position = convertVector2(mouseButtonPressed->position);
|
||||
}
|
||||
else if (const auto* mouseButtonReleased = sfmlEvent->getIf<sf::Event::MouseButtonReleased>())
|
||||
{
|
||||
event.type = sfEvtMouseButtonReleased;
|
||||
event.mouseButton.button = static_cast<sfMouseButton>(mouseButtonReleased->button);
|
||||
event.mouseButton.position = convertVector2(mouseButtonReleased->position);
|
||||
}
|
||||
else if (const auto* mouseMoved = sfmlEvent->getIf<sf::Event::MouseMoved>())
|
||||
{
|
||||
event.type = sfEvtMouseMoved;
|
||||
event.mouseMove.position = convertVector2(mouseMoved->position);
|
||||
}
|
||||
else if (const auto* mouseMovedRaw = sfmlEvent->getIf<sf::Event::MouseMovedRaw>())
|
||||
{
|
||||
event.type = sfEvtMouseMovedRaw;
|
||||
event.mouseMoveRaw.delta = convertVector2(mouseMovedRaw->delta);
|
||||
}
|
||||
else if (sfmlEvent->is<sf::Event::MouseEntered>())
|
||||
{
|
||||
event.type = sfEvtMouseEntered;
|
||||
}
|
||||
else if (sfmlEvent->is<sf::Event::MouseLeft>())
|
||||
{
|
||||
event.type = sfEvtMouseLeft;
|
||||
}
|
||||
else if (const auto* joystickButtonPressed = sfmlEvent->getIf<sf::Event::JoystickButtonPressed>())
|
||||
{
|
||||
event.type = sfEvtJoystickButtonPressed;
|
||||
event.joystickButton.joystickId = joystickButtonPressed->joystickId;
|
||||
event.joystickButton.button = joystickButtonPressed->button;
|
||||
}
|
||||
else if (const auto* joystickButtonReleased = sfmlEvent->getIf<sf::Event::JoystickButtonReleased>())
|
||||
{
|
||||
event.type = sfEvtJoystickButtonReleased;
|
||||
event.joystickButton.joystickId = joystickButtonReleased->joystickId;
|
||||
event.joystickButton.button = joystickButtonReleased->button;
|
||||
}
|
||||
else if (const auto* joystickMoved = sfmlEvent->getIf<sf::Event::JoystickMoved>())
|
||||
{
|
||||
event.type = sfEvtJoystickMoved;
|
||||
event.joystickMove.joystickId = joystickMoved->joystickId;
|
||||
event.joystickMove.axis = static_cast<sfJoystickAxis>(joystickMoved->axis);
|
||||
event.joystickMove.position = joystickMoved->position;
|
||||
}
|
||||
else if (const auto* joystickConnected = sfmlEvent->getIf<sf::Event::JoystickConnected>())
|
||||
{
|
||||
event.type = sfEvtJoystickConnected;
|
||||
event.joystickConnect.joystickId = joystickConnected->joystickId;
|
||||
}
|
||||
else if (const auto* joystickDisconnected = sfmlEvent->getIf<sf::Event::JoystickDisconnected>())
|
||||
{
|
||||
event.type = sfEvtJoystickDisconnected;
|
||||
event.joystickConnect.joystickId = joystickDisconnected->joystickId;
|
||||
}
|
||||
else if (const auto* touchBegan = sfmlEvent->getIf<sf::Event::TouchBegan>())
|
||||
{
|
||||
event.type = sfEvtTouchBegan;
|
||||
event.touch.finger = touchBegan->finger;
|
||||
event.touch.position = convertVector2(touchBegan->position);
|
||||
}
|
||||
else if (const auto* touchMoved = sfmlEvent->getIf<sf::Event::TouchMoved>())
|
||||
{
|
||||
event.type = sfEvtTouchMoved;
|
||||
event.touch.finger = touchMoved->finger;
|
||||
event.touch.position = convertVector2(touchMoved->position);
|
||||
}
|
||||
else if (const auto* touchEnded = sfmlEvent->getIf<sf::Event::TouchEnded>())
|
||||
{
|
||||
event.type = sfEvtTouchEnded;
|
||||
event.touch.finger = touchEnded->finger;
|
||||
event.touch.position = convertVector2(touchEnded->position);
|
||||
}
|
||||
else if (const auto* sensorChanged = sfmlEvent->getIf<sf::Event::SensorChanged>())
|
||||
{
|
||||
event.type = sfEvtSensorChanged;
|
||||
event.sensor.sensorType = static_cast<sfSensorType>(sensorChanged->type);
|
||||
event.sensor.value = convertVector3(sensorChanged->value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -41,13 +41,14 @@ sfVideoMode sfVideoMode_getDesktopMode()
|
||||
////////////////////////////////////////////////////////////
|
||||
const sfVideoMode* sfVideoMode_getFullscreenModes(size_t* count)
|
||||
{
|
||||
static const auto modes = []
|
||||
static std::vector<sfVideoMode> modes;
|
||||
|
||||
// Populate the array on first call
|
||||
if (modes.empty())
|
||||
{
|
||||
std::vector<sfVideoMode> videomodes;
|
||||
for (const auto& mode : sf::VideoMode::getFullscreenModes())
|
||||
videomodes.push_back(convertVideoMode(mode));
|
||||
return videomodes;
|
||||
}();
|
||||
modes.push_back(convertVideoMode(mode));
|
||||
}
|
||||
|
||||
if (count)
|
||||
*count = modes.size();
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
|
||||
#include <SFML/Window/Vulkan.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool sfVulkan_isAvailable(bool requireGraphics)
|
||||
@@ -49,7 +52,7 @@ sfVulkanFunctionPointer sfVulkan_getFunction(const char* name)
|
||||
////////////////////////////////////////////////////////////
|
||||
const char* const* sfVulkan_getGraphicsRequiredInstanceExtensions(size_t* count)
|
||||
{
|
||||
static const std::vector<const char*> extensions = sf::Vulkan::getGraphicsRequiredInstanceExtensions();
|
||||
static std::vector<const char*> extensions = sf::Vulkan::getGraphicsRequiredInstanceExtensions();
|
||||
|
||||
if (count)
|
||||
*count = extensions.size();
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <CSFML/ConvertEvent.hpp>
|
||||
#include <CSFML/System/ConvertVector2.hpp>
|
||||
#include <CSFML/Window/ConvertContextSettings.hpp>
|
||||
#include <CSFML/Window/ConvertEvent.hpp>
|
||||
#include <CSFML/Window/ConvertVideoMode.hpp>
|
||||
#include <CSFML/Window/CursorStruct.hpp>
|
||||
#include <CSFML/Window/Window.h>
|
||||
@@ -114,7 +114,7 @@ bool sfWindow_pollEvent(sfWindow* window, sfEvent* event)
|
||||
{
|
||||
assert(window);
|
||||
assert(event);
|
||||
return convertEvent(window->pollEvent(), *event);
|
||||
return convertEvent(window->pollEvent(), event);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ bool sfWindow_waitEvent(sfWindow* window, sfTime timeout, sfEvent* event)
|
||||
{
|
||||
assert(window);
|
||||
assert(event);
|
||||
return convertEvent(window->waitEvent(sf::microseconds(timeout.microseconds)), *event);
|
||||
return convertEvent(window->waitEvent(sf::microseconds(timeout.microseconds)), event);
|
||||
}
|
||||
|
||||
|
||||
@@ -159,38 +159,6 @@ 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)
|
||||
{
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <CSFML/ConvertEvent.hpp>
|
||||
#include <CSFML/System/ConvertVector2.hpp>
|
||||
#include <CSFML/Window/ConvertEvent.hpp>
|
||||
#include <CSFML/Window/ConvertVideoMode.hpp>
|
||||
#include <CSFML/Window/CursorStruct.hpp>
|
||||
#include <CSFML/Window/WindowBase.h>
|
||||
@@ -34,8 +34,6 @@
|
||||
|
||||
#include <SFML/Window/VideoMode.hpp>
|
||||
|
||||
#include <optional>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfWindowBase* sfWindowBase_create(sfVideoMode mode, const char* title, uint32_t style, sfWindowState state)
|
||||
@@ -98,7 +96,7 @@ bool sfWindowBase_pollEvent(sfWindowBase* windowBase, sfEvent* event)
|
||||
{
|
||||
assert(windowBase);
|
||||
assert(event);
|
||||
return convertEvent(windowBase->pollEvent(), *event);
|
||||
return convertEvent(windowBase->pollEvent(), event);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +105,7 @@ bool sfWindowBase_waitEvent(sfWindowBase* windowBase, sfTime timeout, sfEvent* e
|
||||
{
|
||||
assert(windowBase);
|
||||
assert(event);
|
||||
return convertEvent(windowBase->waitEvent(sf::microseconds(timeout.microseconds)), *event);
|
||||
return convertEvent(windowBase->waitEvent(sf::microseconds(timeout.microseconds)), event);
|
||||
}
|
||||
|
||||
|
||||
@@ -143,38 +141,6 @@ 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)
|
||||
{
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#include <CSFML/Audio/SoundChannel.h>
|
||||
|
||||
#include <SFML/Audio/SoundChannel.hpp>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE("[Audio] sfSoundChannel")
|
||||
{
|
||||
STATIC_CHECK(sfSoundChannelUnspecified == static_cast<int>(sf::SoundChannel::Unspecified));
|
||||
STATIC_CHECK(sfSoundChannelMono == static_cast<int>(sf::SoundChannel::Mono));
|
||||
STATIC_CHECK(sfSoundChannelFrontLeft == static_cast<int>(sf::SoundChannel::FrontLeft));
|
||||
STATIC_CHECK(sfSoundChannelFrontRight == static_cast<int>(sf::SoundChannel::FrontRight));
|
||||
STATIC_CHECK(sfSoundChannelFrontCenter == static_cast<int>(sf::SoundChannel::FrontCenter));
|
||||
STATIC_CHECK(sfSoundChannelFrontLeftOfCenter == static_cast<int>(sf::SoundChannel::FrontLeftOfCenter));
|
||||
STATIC_CHECK(sfSoundChannelFrontRightOfCenter == static_cast<int>(sf::SoundChannel::FrontRightOfCenter));
|
||||
STATIC_CHECK(sfSoundChannelLowFrequencyEffects == static_cast<int>(sf::SoundChannel::LowFrequencyEffects));
|
||||
STATIC_CHECK(sfSoundChannelBackLeft == static_cast<int>(sf::SoundChannel::BackLeft));
|
||||
STATIC_CHECK(sfSoundChannelBackRight == static_cast<int>(sf::SoundChannel::BackRight));
|
||||
STATIC_CHECK(sfSoundChannelBackCenter == static_cast<int>(sf::SoundChannel::BackCenter));
|
||||
STATIC_CHECK(sfSoundChannelSideLeft == static_cast<int>(sf::SoundChannel::SideLeft));
|
||||
STATIC_CHECK(sfSoundChannelSideRight == static_cast<int>(sf::SoundChannel::SideRight));
|
||||
STATIC_CHECK(sfSoundChannelTopCenter == static_cast<int>(sf::SoundChannel::TopCenter));
|
||||
STATIC_CHECK(sfSoundChannelTopFrontLeft == static_cast<int>(sf::SoundChannel::TopFrontLeft));
|
||||
STATIC_CHECK(sfSoundChannelTopFrontRight == static_cast<int>(sf::SoundChannel::TopFrontRight));
|
||||
STATIC_CHECK(sfSoundChannelTopFrontCenter == static_cast<int>(sf::SoundChannel::TopFrontCenter));
|
||||
STATIC_CHECK(sfSoundChannelTopBackLeft == static_cast<int>(sf::SoundChannel::TopBackLeft));
|
||||
STATIC_CHECK(sfSoundChannelTopBackRight == static_cast<int>(sf::SoundChannel::TopBackRight));
|
||||
STATIC_CHECK(sfSoundChannelTopBackCenter == static_cast<int>(sf::SoundChannel::TopBackCenter));
|
||||
}
|
||||
@@ -44,24 +44,6 @@ target_link_libraries(test-csfml-window PRIVATE csfml-window Catch2::Catch2WithM
|
||||
set_target_warnings(test-csfml-window)
|
||||
catch_discover_tests(test-csfml-window)
|
||||
|
||||
add_executable(test-csfml-graphics
|
||||
Graphics/BlendMode.test.cpp
|
||||
Graphics/Color.test.cpp
|
||||
Graphics/CoordinateType.test.cpp
|
||||
Graphics/Image.test.cpp
|
||||
Graphics/PrimitiveType.test.cpp
|
||||
Graphics/Rect.test.cpp
|
||||
Graphics/RenderStates.test.cpp
|
||||
Graphics/Shape.test.cpp
|
||||
Graphics/StencilMode.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 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
add_executable(test-csfml-network
|
||||
Network/Ftp.test.cpp
|
||||
Network/Http.test.cpp
|
||||
@@ -72,13 +54,6 @@ target_link_libraries(test-csfml-network PRIVATE csfml-network Catch2::Catch2Wit
|
||||
set_target_warnings(test-csfml-network)
|
||||
catch_discover_tests(test-csfml-network)
|
||||
|
||||
add_executable(test-csfml-audio
|
||||
Audio/SoundChannel.test.cpp
|
||||
)
|
||||
target_link_libraries(test-csfml-audio PRIVATE csfml-audio Catch2::Catch2WithMain SFML::Audio)
|
||||
set_target_warnings(test-csfml-audio)
|
||||
catch_discover_tests(test-csfml-audio)
|
||||
|
||||
# Copy DLLs into the same directory
|
||||
if(SFML_OS_WINDOWS AND NOT CSFML_LINK_SFML_STATICALLY)
|
||||
foreach(SFML_TARGET SFML::System SFML::Window SFML::Graphics SFML::Audio SFML::Network)
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
#include <CSFML/Graphics/BlendMode.h>
|
||||
|
||||
#include <SFML/Graphics/BlendMode.hpp>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE("[Graphics] sfBlendMode")
|
||||
{
|
||||
SECTION("sfBlendFactor")
|
||||
{
|
||||
STATIC_CHECK(sfBlendFactorZero == static_cast<int>(sf::BlendMode::Factor::Zero));
|
||||
STATIC_CHECK(sfBlendFactorOne == static_cast<int>(sf::BlendMode::Factor::One));
|
||||
STATIC_CHECK(sfBlendFactorSrcColor == static_cast<int>(sf::BlendMode::Factor::SrcColor));
|
||||
STATIC_CHECK(sfBlendFactorOneMinusSrcColor == static_cast<int>(sf::BlendMode::Factor::OneMinusSrcColor));
|
||||
STATIC_CHECK(sfBlendFactorDstColor == static_cast<int>(sf::BlendMode::Factor::DstColor));
|
||||
STATIC_CHECK(sfBlendFactorOneMinusDstColor == static_cast<int>(sf::BlendMode::Factor::OneMinusDstColor));
|
||||
STATIC_CHECK(sfBlendFactorSrcAlpha == static_cast<int>(sf::BlendMode::Factor::SrcAlpha));
|
||||
STATIC_CHECK(sfBlendFactorOneMinusSrcAlpha == static_cast<int>(sf::BlendMode::Factor::OneMinusSrcAlpha));
|
||||
STATIC_CHECK(sfBlendFactorDstAlpha == static_cast<int>(sf::BlendMode::Factor::DstAlpha));
|
||||
STATIC_CHECK(sfBlendFactorOneMinusDstAlpha == static_cast<int>(sf::BlendMode::Factor::OneMinusDstAlpha));
|
||||
}
|
||||
|
||||
SECTION("sfBlendEquation")
|
||||
{
|
||||
STATIC_CHECK(sfBlendEquationAdd == static_cast<int>(sf::BlendMode::Equation::Add));
|
||||
STATIC_CHECK(sfBlendEquationSubtract == static_cast<int>(sf::BlendMode::Equation::Subtract));
|
||||
STATIC_CHECK(sfBlendEquationReverseSubtract == static_cast<int>(sf::BlendMode::Equation::ReverseSubtract));
|
||||
STATIC_CHECK(sfBlendEquationMin == static_cast<int>(sf::BlendMode::Equation::Min));
|
||||
STATIC_CHECK(sfBlendEquationMax == static_cast<int>(sf::BlendMode::Equation::Max));
|
||||
}
|
||||
|
||||
SECTION("Construction")
|
||||
{
|
||||
constexpr sfBlendMode blendMode{};
|
||||
STATIC_CHECK(blendMode.colorSrcFactor == sfBlendFactorZero);
|
||||
STATIC_CHECK(blendMode.colorDstFactor == sfBlendFactorZero);
|
||||
STATIC_CHECK(blendMode.colorEquation == sfBlendEquationAdd);
|
||||
STATIC_CHECK(blendMode.alphaSrcFactor == sfBlendFactorZero);
|
||||
STATIC_CHECK(blendMode.alphaDstFactor == sfBlendFactorZero);
|
||||
STATIC_CHECK(blendMode.alphaEquation == sfBlendEquationAdd);
|
||||
}
|
||||
|
||||
SECTION("Constants")
|
||||
{
|
||||
SECTION("sfBlendAlpha")
|
||||
{
|
||||
CHECK(sfBlendAlpha.colorSrcFactor == sfBlendFactorSrcAlpha);
|
||||
CHECK(sfBlendAlpha.colorDstFactor == sfBlendFactorOneMinusSrcAlpha);
|
||||
CHECK(sfBlendAlpha.colorEquation == sfBlendEquationAdd);
|
||||
CHECK(sfBlendAlpha.alphaSrcFactor == sfBlendFactorOne);
|
||||
CHECK(sfBlendAlpha.alphaDstFactor == sfBlendFactorOneMinusSrcAlpha);
|
||||
CHECK(sfBlendAlpha.alphaEquation == sfBlendEquationAdd);
|
||||
}
|
||||
|
||||
SECTION("sfBlendAdd")
|
||||
{
|
||||
CHECK(sfBlendAdd.colorSrcFactor == sfBlendFactorSrcAlpha);
|
||||
CHECK(sfBlendAdd.colorDstFactor == sfBlendFactorOne);
|
||||
CHECK(sfBlendAdd.colorEquation == sfBlendEquationAdd);
|
||||
CHECK(sfBlendAdd.alphaSrcFactor == sfBlendFactorOne);
|
||||
CHECK(sfBlendAdd.alphaDstFactor == sfBlendFactorOne);
|
||||
CHECK(sfBlendAdd.alphaEquation == sfBlendEquationAdd);
|
||||
}
|
||||
|
||||
SECTION("sfBlendMultiply")
|
||||
{
|
||||
CHECK(sfBlendMultiply.colorSrcFactor == sfBlendFactorDstColor);
|
||||
CHECK(sfBlendMultiply.colorDstFactor == sfBlendFactorZero);
|
||||
CHECK(sfBlendMultiply.colorEquation == sfBlendEquationAdd);
|
||||
CHECK(sfBlendMultiply.alphaSrcFactor == sfBlendFactorDstColor);
|
||||
CHECK(sfBlendMultiply.alphaDstFactor == sfBlendFactorZero);
|
||||
CHECK(sfBlendMultiply.alphaEquation == sfBlendEquationAdd);
|
||||
}
|
||||
|
||||
SECTION("sfBlendMin")
|
||||
{
|
||||
CHECK(sfBlendMin.colorSrcFactor == sfBlendFactorOne);
|
||||
CHECK(sfBlendMin.colorDstFactor == sfBlendFactorOne);
|
||||
CHECK(sfBlendMin.colorEquation == sfBlendEquationMin);
|
||||
CHECK(sfBlendMin.alphaSrcFactor == sfBlendFactorOne);
|
||||
CHECK(sfBlendMin.alphaDstFactor == sfBlendFactorOne);
|
||||
CHECK(sfBlendMin.alphaEquation == sfBlendEquationMin);
|
||||
}
|
||||
|
||||
SECTION("sfBlendMax")
|
||||
{
|
||||
CHECK(sfBlendMax.colorSrcFactor == sfBlendFactorOne);
|
||||
CHECK(sfBlendMax.colorDstFactor == sfBlendFactorOne);
|
||||
CHECK(sfBlendMax.colorEquation == sfBlendEquationMax);
|
||||
CHECK(sfBlendMax.alphaSrcFactor == sfBlendFactorOne);
|
||||
CHECK(sfBlendMax.alphaDstFactor == sfBlendFactorOne);
|
||||
CHECK(sfBlendMax.alphaEquation == sfBlendEquationMax);
|
||||
}
|
||||
|
||||
SECTION("sfBlendNone")
|
||||
{
|
||||
CHECK(sfBlendNone.colorSrcFactor == sfBlendFactorOne);
|
||||
CHECK(sfBlendNone.colorDstFactor == sfBlendFactorZero);
|
||||
CHECK(sfBlendNone.colorEquation == sfBlendEquationAdd);
|
||||
CHECK(sfBlendNone.alphaSrcFactor == sfBlendFactorOne);
|
||||
CHECK(sfBlendNone.alphaDstFactor == sfBlendFactorZero);
|
||||
CHECK(sfBlendNone.alphaEquation == sfBlendEquationAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,229 +0,0 @@
|
||||
#include <CSFML/Graphics/Color.h>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE("[Graphics] sfColor")
|
||||
{
|
||||
SECTION("Construction")
|
||||
{
|
||||
constexpr sfColor color{};
|
||||
STATIC_CHECK(color.r == 0);
|
||||
STATIC_CHECK(color.g == 0);
|
||||
STATIC_CHECK(color.b == 0);
|
||||
STATIC_CHECK(color.a == 0);
|
||||
}
|
||||
|
||||
SECTION("Constants")
|
||||
{
|
||||
SECTION("sfBlack")
|
||||
{
|
||||
CHECK(sfBlack.r == 0);
|
||||
CHECK(sfBlack.g == 0);
|
||||
CHECK(sfBlack.b == 0);
|
||||
CHECK(sfBlack.a == 255);
|
||||
}
|
||||
|
||||
SECTION("sfWhite")
|
||||
{
|
||||
CHECK(sfWhite.r == 255);
|
||||
CHECK(sfWhite.g == 255);
|
||||
CHECK(sfWhite.b == 255);
|
||||
CHECK(sfWhite.a == 255);
|
||||
}
|
||||
|
||||
SECTION("sfRed")
|
||||
{
|
||||
CHECK(sfRed.r == 255);
|
||||
CHECK(sfRed.g == 0);
|
||||
CHECK(sfRed.b == 0);
|
||||
CHECK(sfRed.a == 255);
|
||||
}
|
||||
|
||||
SECTION("sfGreen")
|
||||
{
|
||||
CHECK(sfGreen.r == 0);
|
||||
CHECK(sfGreen.g == 255);
|
||||
CHECK(sfGreen.b == 0);
|
||||
CHECK(sfGreen.a == 255);
|
||||
}
|
||||
|
||||
SECTION("sfBlue")
|
||||
{
|
||||
CHECK(sfBlue.r == 0);
|
||||
CHECK(sfBlue.g == 0);
|
||||
CHECK(sfBlue.b == 255);
|
||||
CHECK(sfBlue.a == 255);
|
||||
}
|
||||
|
||||
SECTION("sfYellow")
|
||||
{
|
||||
CHECK(sfYellow.r == 255);
|
||||
CHECK(sfYellow.g == 255);
|
||||
CHECK(sfYellow.b == 0);
|
||||
CHECK(sfYellow.a == 255);
|
||||
}
|
||||
|
||||
SECTION("sfMagenta")
|
||||
{
|
||||
CHECK(sfMagenta.r == 255);
|
||||
CHECK(sfMagenta.g == 0);
|
||||
CHECK(sfMagenta.b == 255);
|
||||
CHECK(sfMagenta.a == 255);
|
||||
}
|
||||
|
||||
SECTION("sfCyan")
|
||||
{
|
||||
CHECK(sfCyan.r == 0);
|
||||
CHECK(sfCyan.g == 255);
|
||||
CHECK(sfCyan.b == 255);
|
||||
CHECK(sfCyan.a == 255);
|
||||
}
|
||||
|
||||
SECTION("sfTransparent")
|
||||
{
|
||||
CHECK(sfTransparent.r == 0);
|
||||
CHECK(sfTransparent.g == 0);
|
||||
CHECK(sfTransparent.b == 0);
|
||||
CHECK(sfTransparent.a == 0);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("sfColor_fromRGB")
|
||||
{
|
||||
const sfColor color = sfColor_fromRGB(1, 2, 3);
|
||||
CHECK(color.r == 1);
|
||||
CHECK(color.g == 2);
|
||||
CHECK(color.b == 3);
|
||||
CHECK(color.a == 255);
|
||||
}
|
||||
|
||||
SECTION("sfColor_fromRGBA")
|
||||
{
|
||||
const sfColor color = sfColor_fromRGBA(4, 5, 6, 7);
|
||||
CHECK(color.r == 4);
|
||||
CHECK(color.g == 5);
|
||||
CHECK(color.b == 6);
|
||||
CHECK(color.a == 7);
|
||||
}
|
||||
|
||||
SECTION("sfColor_fromInteger")
|
||||
{
|
||||
sfColor color = sfColor_fromInteger(0);
|
||||
CHECK(color.r == 0);
|
||||
CHECK(color.g == 0);
|
||||
CHECK(color.b == 0);
|
||||
CHECK(color.a == 0);
|
||||
|
||||
color = sfColor_fromInteger(1'000);
|
||||
CHECK(color.r == 0);
|
||||
CHECK(color.g == 0);
|
||||
CHECK(color.b == 3);
|
||||
CHECK(color.a == 232);
|
||||
|
||||
color = sfColor_fromInteger(1'000'000);
|
||||
CHECK(color.r == 0);
|
||||
CHECK(color.g == 15);
|
||||
CHECK(color.b == 66);
|
||||
CHECK(color.a == 64);
|
||||
|
||||
color = sfColor_fromInteger(1'000'000'000);
|
||||
CHECK(color.r == 59);
|
||||
CHECK(color.g == 154);
|
||||
CHECK(color.b == 202);
|
||||
CHECK(color.a == 0);
|
||||
|
||||
color = sfColor_fromInteger(std::numeric_limits<std::uint32_t>::max());
|
||||
CHECK(color.r == 255);
|
||||
CHECK(color.g == 255);
|
||||
CHECK(color.b == 255);
|
||||
CHECK(color.a == 255);
|
||||
}
|
||||
|
||||
SECTION("sfColor_toInteger")
|
||||
{
|
||||
CHECK(sfColor_toInteger(sfBlack) == 255);
|
||||
CHECK(sfColor_toInteger(sfWhite) == 4'294'967'295);
|
||||
CHECK(sfColor_toInteger(sfRed) == 4'278'190'335);
|
||||
CHECK(sfColor_toInteger(sfGreen) == 16'711'935);
|
||||
CHECK(sfColor_toInteger(sfBlue) == 65'535);
|
||||
CHECK(sfColor_toInteger(sfYellow) == 4'294'902'015);
|
||||
CHECK(sfColor_toInteger(sfMagenta) == 4'278'255'615);
|
||||
CHECK(sfColor_toInteger(sfYellow) == 4'294'902'015);
|
||||
CHECK(sfColor_toInteger(sfTransparent) == 0);
|
||||
}
|
||||
|
||||
SECTION("sfColor_add")
|
||||
{
|
||||
sfColor color = sfColor_add({}, {});
|
||||
CHECK(color.r == 0);
|
||||
CHECK(color.g == 0);
|
||||
CHECK(color.b == 0);
|
||||
CHECK(color.a == 0);
|
||||
|
||||
color = sfColor_add({1, 2, 3, 4}, {5, 6, 7, 8});
|
||||
CHECK(color.r == 6);
|
||||
CHECK(color.g == 8);
|
||||
CHECK(color.b == 10);
|
||||
CHECK(color.a == 12);
|
||||
|
||||
color = sfColor_add({10, 20, 30, 40}, {200, 210, 220, 230});
|
||||
CHECK(color.r == 210);
|
||||
CHECK(color.g == 230);
|
||||
CHECK(color.b == 250);
|
||||
CHECK(color.a == 255);
|
||||
|
||||
color = sfColor_add({255, 255, 255, 255}, {255, 255, 255, 25});
|
||||
CHECK(color.r == 255);
|
||||
CHECK(color.g == 255);
|
||||
CHECK(color.b == 255);
|
||||
CHECK(color.a == 255);
|
||||
}
|
||||
|
||||
SECTION("sfColor_subtract")
|
||||
{
|
||||
sfColor color = sfColor_subtract({}, {});
|
||||
CHECK(color.r == 0);
|
||||
CHECK(color.g == 0);
|
||||
CHECK(color.b == 0);
|
||||
CHECK(color.a == 0);
|
||||
|
||||
color = sfColor_subtract({}, {10, 20, 30, 40});
|
||||
CHECK(color.r == 0);
|
||||
CHECK(color.g == 0);
|
||||
CHECK(color.b == 0);
|
||||
CHECK(color.a == 0);
|
||||
|
||||
color = sfColor_subtract({100, 90, 80, 70}, {30, 40, 50, 60});
|
||||
CHECK(color.r == 70);
|
||||
CHECK(color.g == 50);
|
||||
CHECK(color.b == 30);
|
||||
CHECK(color.a == 10);
|
||||
}
|
||||
|
||||
SECTION("sfColor_modulate")
|
||||
{
|
||||
sfColor color = sfColor_modulate({}, {});
|
||||
CHECK(color.r == 0);
|
||||
CHECK(color.g == 0);
|
||||
CHECK(color.b == 0);
|
||||
CHECK(color.a == 0);
|
||||
|
||||
color = sfColor_modulate({}, {1, 2, 3, 4});
|
||||
CHECK(color.r == 0);
|
||||
CHECK(color.g == 0);
|
||||
CHECK(color.b == 0);
|
||||
CHECK(color.a == 0);
|
||||
|
||||
color = sfColor_modulate({5, 6, 7, 8}, {1, 2, 3, 4});
|
||||
CHECK(color.r == 0);
|
||||
CHECK(color.g == 0);
|
||||
CHECK(color.b == 0);
|
||||
CHECK(color.a == 0);
|
||||
|
||||
color = sfColor_modulate({128, 196, 216, 255}, {0, 128, 255, 128});
|
||||
CHECK(color.r == 0);
|
||||
CHECK(color.g == 98);
|
||||
CHECK(color.b == 216);
|
||||
CHECK(color.a == 128);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#include <CSFML/Graphics/CoordinateType.h>
|
||||
|
||||
#include <SFML/Graphics/CoordinateType.hpp>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE("[Graphics] sfCoordinateType")
|
||||
{
|
||||
STATIC_CHECK(sfCoordinateTypeNormalized == static_cast<int>(sf::CoordinateType::Normalized));
|
||||
STATIC_CHECK(sfCoordinateTypePixels == static_cast<int>(sf::CoordinateType::Pixels));
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
#include <CSFML/Graphics/Image.h>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
TEST_CASE("[Graphics] sfImage")
|
||||
{
|
||||
SECTION("sfImage_create")
|
||||
{
|
||||
const sfImage* image = sfImage_create({100, 100});
|
||||
REQUIRE(image);
|
||||
const auto size = sfImage_getSize(image);
|
||||
CHECK(size.x == 100);
|
||||
CHECK(size.y == 100);
|
||||
const auto pixel = sfImage_getPixel(image, {50, 50});
|
||||
CHECK(pixel.r == sfBlack.r);
|
||||
CHECK(pixel.g == sfBlack.g);
|
||||
CHECK(pixel.b == sfBlack.b);
|
||||
CHECK(pixel.a == sfBlack.a);
|
||||
CHECK(sfImage_getPixelsPtr(image));
|
||||
sfImage_destroy(image);
|
||||
}
|
||||
|
||||
SECTION("sfImage_createFromColor")
|
||||
{
|
||||
const sfImage* image = sfImage_createFromColor({100, 100}, sfMagenta);
|
||||
REQUIRE(image);
|
||||
const auto size = sfImage_getSize(image);
|
||||
CHECK(size.x == 100);
|
||||
CHECK(size.y == 100);
|
||||
const auto pixel = sfImage_getPixel(image, {50, 50});
|
||||
CHECK(pixel.r == sfMagenta.r);
|
||||
CHECK(pixel.g == sfMagenta.g);
|
||||
CHECK(pixel.b == sfMagenta.b);
|
||||
CHECK(pixel.a == sfMagenta.a);
|
||||
CHECK(sfImage_getPixelsPtr(image));
|
||||
sfImage_destroy(image);
|
||||
}
|
||||
|
||||
SECTION("sfImage_createFromFile")
|
||||
{
|
||||
const auto filename = std::string("Graphics/sfml-logo-big.") + GENERATE("bmp", "gif", "jpg", "png", "psd");
|
||||
INFO("Filename: " << filename);
|
||||
const sfImage* image = sfImage_createFromFile(filename.c_str());
|
||||
REQUIRE(image);
|
||||
const auto size = sfImage_getSize(image);
|
||||
CHECK(size.x == 1001);
|
||||
CHECK(size.y == 304);
|
||||
const auto pixel = sfImage_getPixel(image, {0, 0});
|
||||
CHECK(pixel.r == sfWhite.r);
|
||||
CHECK(pixel.g == sfWhite.g);
|
||||
CHECK(pixel.b == sfWhite.b);
|
||||
CHECK(sfImage_getPixelsPtr(image));
|
||||
sfImage_destroy(image);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#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));
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
#include <CSFML/Graphics/Rect.h>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE("[Graphics] sfRect")
|
||||
{
|
||||
SECTION("Construction")
|
||||
{
|
||||
SECTION("float")
|
||||
{
|
||||
const sfFloatRect rect{};
|
||||
CHECK(rect.position.x == 0.f);
|
||||
CHECK(rect.position.y == 0.f);
|
||||
CHECK(rect.size.x == 0.f);
|
||||
CHECK(rect.size.y == 0.f);
|
||||
}
|
||||
|
||||
SECTION("int")
|
||||
{
|
||||
const sfFloatRect rect{};
|
||||
CHECK(rect.position.x == 0);
|
||||
CHECK(rect.position.y == 0);
|
||||
CHECK(rect.size.x == 0);
|
||||
CHECK(rect.size.y == 0);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("contains(Vector2)")
|
||||
{
|
||||
SECTION("float")
|
||||
{
|
||||
const sfFloatRect rect{{0, 0}, {10, 10}};
|
||||
CHECK(sfFloatRect_contains(&rect, {0, 0}));
|
||||
CHECK(sfFloatRect_contains(&rect, {9, 0}));
|
||||
CHECK(sfFloatRect_contains(&rect, {0, 9}));
|
||||
CHECK(sfFloatRect_contains(&rect, {9, 9}));
|
||||
CHECK(!sfFloatRect_contains(&rect, {9, 10}));
|
||||
CHECK(!sfFloatRect_contains(&rect, {10, 9}));
|
||||
CHECK(!sfFloatRect_contains(&rect, {10, 10}));
|
||||
CHECK(!sfFloatRect_contains(&rect, {15, 15}));
|
||||
}
|
||||
|
||||
SECTION("int")
|
||||
{
|
||||
const sfIntRect rect{{0, 0}, {10, 10}};
|
||||
CHECK(sfIntRect_contains(&rect, {0, 0}));
|
||||
CHECK(sfIntRect_contains(&rect, {9, 0}));
|
||||
CHECK(sfIntRect_contains(&rect, {0, 9}));
|
||||
CHECK(sfIntRect_contains(&rect, {9, 9}));
|
||||
CHECK(!sfIntRect_contains(&rect, {9, 10}));
|
||||
CHECK(!sfIntRect_contains(&rect, {10, 9}));
|
||||
CHECK(!sfIntRect_contains(&rect, {10, 10}));
|
||||
CHECK(!sfIntRect_contains(&rect, {15, 15}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
#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);
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
#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);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
#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);
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
#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")
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
#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);
|
||||
}
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
#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.
|
Before Width: | Height: | Size: 892 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 35 KiB |
Binary file not shown.
@@ -2,8 +2,6 @@
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
TEST_CASE("[Network] sfIpAddress")
|
||||
{
|
||||
SECTION("Constants")
|
||||
@@ -12,18 +10,12 @@ TEST_CASE("[Network] sfIpAddress")
|
||||
CHECK(sfIpAddress_toInteger(sfIpAddress_Any) == 0);
|
||||
CHECK(sfIpAddress_toInteger(sfIpAddress_LocalHost) == 0x7F000001);
|
||||
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")
|
||||
{
|
||||
CHECK(sfIpAddress_toInteger(sfIpAddress_fromString("")) == 0);
|
||||
CHECK(sfIpAddress_toInteger(sfIpAddress_fromString("256.256.256.256")) == 0);
|
||||
CHECK(sfIpAddress_toInteger(sfIpAddress_fromString("localhost")) == 0x7F000001);
|
||||
CHECK(sfIpAddress_toInteger(sfIpAddress_fromString("invalid address")) == 0);
|
||||
CHECK(sfIpAddress_toInteger(sfIpAddress_fromString("192.168.0.1")) == 0xC0A80001);
|
||||
CHECK(sfIpAddress_toInteger(sfIpAddress_fromString("8.8.8.8")) == 0x08080808);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,4 @@ TEST_CASE("[System] sfTime")
|
||||
CHECK(sfSeconds(10).microseconds == 10'000'000);
|
||||
CHECK(sfMilliseconds(10).microseconds == 10'000);
|
||||
CHECK(sfMicroseconds(10).microseconds == 10);
|
||||
|
||||
CHECK(sfMilliseconds(std::numeric_limits<int32_t>::max()).microseconds == 2'147'483'647'000);
|
||||
CHECK(sfMicroseconds(std::numeric_limits<int64_t>::max()).microseconds == std::numeric_limits<int64_t>::max());
|
||||
}
|
||||
@@ -30,7 +30,7 @@ TEST_CASE("[Window] sfJoystick")
|
||||
// no joysticks will be detected. This is how we can ensure these
|
||||
// tests are portable and reliable.
|
||||
|
||||
const auto joystick = GENERATE(range(0u, unsigned{sfJoystickCount - 1}));
|
||||
const auto joystick = GENERATE(range(0u, static_cast<unsigned int>(sfJoystickCount - 1)));
|
||||
|
||||
SECTION("sfJoystick_isConnected()")
|
||||
{
|
||||
@@ -56,7 +56,7 @@ TEST_CASE("[Window] sfJoystick")
|
||||
|
||||
SECTION("sfJoystick_isButtonPressed()")
|
||||
{
|
||||
const auto button = GENERATE(range(0u, unsigned{sfJoystickButtonCount - 1}));
|
||||
const auto button = GENERATE(range(0u, static_cast<unsigned int>(sfJoystickButtonCount - 1)));
|
||||
CHECK(!sfJoystick_isButtonPressed(joystick, button));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ TEST_CASE("[Window] sfMouse")
|
||||
STATIC_CHECK(sfMouseLeft == static_cast<int>(sf::Mouse::Button::Left));
|
||||
STATIC_CHECK(sfMouseRight == static_cast<int>(sf::Mouse::Button::Right));
|
||||
STATIC_CHECK(sfMouseMiddle == static_cast<int>(sf::Mouse::Button::Middle));
|
||||
STATIC_CHECK(sfMouseButtonExtra1 == static_cast<int>(sf::Mouse::Button::Extra1));
|
||||
STATIC_CHECK(sfMouseButtonExtra2 == static_cast<int>(sf::Mouse::Button::Extra2));
|
||||
STATIC_CHECK(sfMouseXButton1 == static_cast<int>(sf::Mouse::Button::Extra1));
|
||||
STATIC_CHECK(sfMouseXButton2 == static_cast<int>(sf::Mouse::Button::Extra2));
|
||||
STATIC_CHECK(sfMouseButtonCount == sf::Mouse::ButtonCount);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
VERSION="3.0.0"
|
||||
VERSION_C="3.0.0"
|
||||
VERSION="2.6.1"
|
||||
VERSION_C="2.6.0"
|
||||
# BUILD_CSFML=FALSE
|
||||
BUILD_CSFML=TRUE
|
||||
BUILD_SFML=FALSE
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
|
||||
<Version>3.0.0-rc.2</Version>
|
||||
<Version>3.0.0</Version>
|
||||
<Authors>Laurent Gomila</Authors>
|
||||
<PackageTags>sfml csfml</PackageTags>
|
||||
<Copyright>Copyright © Laurent Gomila</Copyright>
|
||||
@@ -13,7 +13,6 @@
|
||||
<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>
|
||||
@@ -32,7 +31,6 @@
|
||||
<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>
|
||||
@@ -1,33 +0,0 @@
|
||||
# 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.
|
||||
@@ -42,7 +42,7 @@ echo "Please note that all SFML dependencies must be installed and available to
|
||||
|
||||
RID="$1"
|
||||
|
||||
SFMLBranch="3.0.1" # The branch or tag of the SFML repository to be cloned
|
||||
SFMLBranch="master" # The branch or tag of the SFML repository to be cloned
|
||||
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
|
||||
@@ -94,7 +94,6 @@ cmake -E env LDFLAGS="-z origin" \
|
||||
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$SFMLLibDir" \
|
||||
'-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON' \
|
||||
'-DCMAKE_INSTALL_RPATH=$ORIGIN' \
|
||||
'-DSFML_USE_SYSTEM_DEPS=OFF' \
|
||||
'-DSFML_BUILD_NETWORK=OFF' \
|
||||
"$SFMLDir"
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ echo "Please note that all SFML dependencies must be installed and available to
|
||||
|
||||
RID="$1"
|
||||
|
||||
SFMLBranch="3.0.1" # The branch or tag of the SFML repository to be cloned
|
||||
SFMLBranch="master" # 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
|
||||
|
||||
OutDir="./CSFML/runtimes/$RID/native" # The base directory of all CSFML modules, used to copy the final libraries
|
||||
@@ -146,12 +146,39 @@ cmake -E env \
|
||||
"$CSFMLDir"
|
||||
cmake --build . --config Release --target install
|
||||
|
||||
# ======================================== #
|
||||
# STEP 5: Copy result to the NuGet folders #
|
||||
# ======================================== #
|
||||
# ============================ #
|
||||
# STEP 5: Fix RPATH references #
|
||||
# ============================ #
|
||||
|
||||
SFMLMajorMinor="3.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"
|
||||
CSFMLMajorMinorPatch="$CSFMLMajorMinor.0"
|
||||
|
||||
@@ -181,6 +208,8 @@ copymodule graphics
|
||||
copymodule system
|
||||
copymodule window
|
||||
|
||||
cp -R "$SFMLLibDir/lib/"*.framework "$OutDir"
|
||||
|
||||
popd # Pop CSFML
|
||||
popd # Pop $RID
|
||||
popd # Pop Build
|
||||
@@ -18,7 +18,6 @@ if (-not $RID) {
|
||||
|
||||
$Generator = 'Visual Studio 17 2022'
|
||||
|
||||
# See also: https://learn.microsoft.com/en-us/dotnet/core/rid-catalog#known-rids
|
||||
switch ($RID) {
|
||||
'win-x86' {
|
||||
$Architecture = 'Win32'
|
||||
@@ -26,9 +25,6 @@ switch ($RID) {
|
||||
'win-x64' {
|
||||
$Architecture = 'x64'
|
||||
}
|
||||
'win-arm64' {
|
||||
$Architecture = 'ARM64'
|
||||
}
|
||||
Default {
|
||||
Write-Error "Unknown RID '$RID'"
|
||||
exit
|
||||
@@ -39,7 +35,7 @@ Write-Output "Building $RID"
|
||||
Write-Output "Using $Generator as the cmake generator"
|
||||
Write-Output "Using architecture $Architecture"
|
||||
|
||||
$SFMLBranch = "3.0.1" # The branch or tag of the SFML repository to be cloned
|
||||
$SFMLBranch = "master" # 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
|
||||
|
||||
$OutDir = "./CSFML/runtimes/$RID/native" # The directory of all CSFML modules, used to copy the final dlls
|
||||
@@ -87,9 +83,17 @@ Push-Location "SFML"
|
||||
|
||||
$SFMLDir = (Get-Item .).FullName
|
||||
|
||||
IF ($RID -ne 'win-x86' -and $RID -ne 'win-x64' -and $RID -ne 'win-arm64') {
|
||||
Write-Error "Unknown RID '$RID'"
|
||||
exit
|
||||
switch ($RID) {
|
||||
'win-x86' {
|
||||
$SFMLExtLibs = (Get-Item ./extlibs/libs-msvc-universal/x86).FullName
|
||||
}
|
||||
'win-x64' {
|
||||
$SFMLExtLibs = (Get-Item ./extlibs/libs-msvc-universal/x64).FullName
|
||||
}
|
||||
Default {
|
||||
Write-Error "Unknown RID '$RID'"
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
Pop-Location # Pop SFML
|
||||
@@ -138,6 +142,7 @@ $CSFMLLibDir = (Get-Item lib).FullName; # The directory where the final CSFML dl
|
||||
cmake `
|
||||
"-DSFML_ROOT=$SFMLInstallDir" `
|
||||
'-DCSFML_LINK_SFML_STATICALLY=OFF' `
|
||||
"-DCMAKE_LIBRARY_PATH=$SFMLExtLibs" `
|
||||
`
|
||||
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$CSFMLLibDir" `
|
||||
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=$CSFMLLibDir" `
|
||||
@@ -149,7 +154,7 @@ cmake `
|
||||
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=$CSFMLLibDir" `
|
||||
`
|
||||
'-DCMAKE_SYSTEM_VERSION=8.1' `
|
||||
'-DCSFML_USE_STATIC_STD_LIBS=OFF' `
|
||||
'-DSTATIC_STD_LIBS=OFF' `
|
||||
`
|
||||
'-DBUILD_SHARED_LIBS=ON' `
|
||||
'-DCMAKE_BUILD_TYPE=Release' `
|
||||
|
||||
Reference in new issue
Block a user