Compare commits
211 commits
feature/dr
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c10c458169 | ||
![]() |
59df9d0d88 | ||
![]() |
a96057866d | ||
![]() |
0d82b99c7d | ||
![]() |
77145c130f | ||
![]() |
a2fde65113 | ||
![]() |
9cb67520c7 | ||
![]() |
d93cd6dd30 | ||
![]() |
603bc9ee41 | ||
![]() |
aaf8ef1c89 | ||
![]() |
54ac286a67 | ||
![]() |
fc573bc584 | ||
![]() |
9b596cc8d9 | ||
![]() |
d4ebba3aaf | ||
![]() |
5eea8032db | ||
![]() |
241b542ca3 | ||
![]() |
3557c46ae6 | ||
![]() |
95c98093e9 | ||
![]() |
0337568846 | ||
![]() |
43187455e4 | ||
![]() |
f93372f98a | ||
![]() |
f57d4620ab | ||
![]() |
50e173e403 | ||
![]() |
632a015663 | ||
![]() |
1d20edebc7 | ||
![]() |
110fb75513 | ||
![]() |
519e1f9572 | ||
![]() |
bf98acc61f | ||
![]() |
a1d4bc80c2 | ||
![]() |
80c3bdc23c | ||
![]() |
6a79ebf1b3 | ||
![]() |
689f468e36 | ||
![]() |
6272f853c1 | ||
![]() |
8886134156 | ||
![]() |
2eb70c6537 | ||
![]() |
f2b8e6397b | ||
![]() |
ea71dd2fe0 | ||
![]() |
ca21695521 | ||
![]() |
27a4c83ebc | ||
![]() |
81a1da6a59 | ||
![]() |
b00317e90c | ||
![]() |
86672a3724 | ||
![]() |
4043f71156 | ||
![]() |
6d8143088e | ||
![]() |
7e7216f598 | ||
![]() |
1d768839e7 | ||
![]() |
53972ed5f2 | ||
![]() |
2c3a321afd | ||
![]() |
c626332e03 | ||
![]() |
d53858afb1 | ||
![]() |
bc7258006c | ||
![]() |
d3a072fb63 | ||
![]() |
a88e854dc3 | ||
![]() |
d402ce5a5d | ||
![]() |
7d496095a5 | ||
![]() |
11b3fe4283 | ||
![]() |
c3e5a35a6e | ||
![]() |
620c9989d6 | ||
![]() |
5b08f8133f | ||
![]() |
a85dc6dabb | ||
![]() |
3d46e39e6d | ||
![]() |
9c8cc19f96 | ||
![]() |
4dfad062e4 | ||
![]() |
0980e90ee4 | ||
![]() |
bf92efe9a4 | ||
![]() |
353c846c87 | ||
![]() |
9f4a0c3c4f | ||
![]() |
5ab36271c7 | ||
![]() |
1272b704d6 | ||
![]() |
82c2f4c05e | ||
![]() |
b516a3ae2b | ||
![]() |
7e40f80f52 | ||
![]() |
53d8f66d43 | ||
![]() |
195f5d7409 | ||
![]() |
489482a630 | ||
![]() |
ae337952a9 | ||
![]() |
04131e1607 | ||
![]() |
db80f6a60f | ||
![]() |
b9fdaf487f | ||
![]() |
1bf3ae77b9 | ||
![]() |
b81de898bf | ||
![]() |
fbc0f17198 | ||
![]() |
077af21f37 | ||
![]() |
119195ac20 | ||
![]() |
2be4e54d4a | ||
![]() |
1159ac5c52 | ||
![]() |
de0ba77d3b | ||
![]() |
ac98be760b | ||
![]() |
3f4bc3683b | ||
![]() |
d1d788fcb3 | ||
![]() |
ae0ec9d552 | ||
![]() |
a5d45b910f | ||
![]() |
3aa156c278 | ||
![]() |
8554d210df | ||
![]() |
5e10e1f0c9 | ||
![]() |
46ce05cd9c | ||
![]() |
87aaa9e145 | ||
![]() |
be3556d76a | ||
![]() |
2bba983f1d | ||
![]() |
aeca3dce41 | ||
![]() |
0bcb2992a7 | ||
![]() |
1cd7ad6a24 | ||
![]() |
83d05ea822 | ||
![]() |
43f0292cb8 | ||
![]() |
e3c65090ea | ||
![]() |
9712bb1ec8 | ||
![]() |
ff87e1c922 | ||
![]() |
f4f7ef0d70 | ||
![]() |
dc0dfd601a | ||
![]() |
bcb013b45b | ||
![]() |
44d3e26766 | ||
![]() |
ac38b17827 | ||
![]() |
8d96976e4b | ||
![]() |
bc570b22bf | ||
![]() |
2853b6b629 | ||
![]() |
f22b9b7b71 | ||
![]() |
235abae134 | ||
![]() |
b97a5be615 | ||
![]() |
ff011dc51d | ||
![]() |
93ad872f9e | ||
![]() |
d2ececed05 | ||
![]() |
1dcad60878 | ||
![]() |
b012266258 | ||
![]() |
bb3bd05823 | ||
![]() |
88bb3f89a5 | ||
![]() |
c828314d12 | ||
![]() |
192eb968a4 | ||
![]() |
859db83af7 | ||
![]() |
8a0d9b414f | ||
![]() |
de2d49e3af | ||
![]() |
b21039452e | ||
![]() |
f2ccc64536 | ||
![]() |
35725cd2df | ||
![]() |
ceee41eaf4 | ||
![]() |
d7fffae727 | ||
![]() |
3da81aeecb | ||
![]() |
4c4e961f39 | ||
![]() |
cd1387479e | ||
![]() |
ee957f3420 | ||
![]() |
b922b04b5e | ||
![]() |
5ebfef4803 | ||
![]() |
f25589e309 | ||
![]() |
2cd4797557 | ||
![]() |
9bdd6d46dd | ||
![]() |
9da895da8b | ||
![]() |
763a9fb44e | ||
![]() |
4d0d331272 | ||
![]() |
f4c25ac3fa | ||
![]() |
1e800d9551 | ||
![]() |
3a96024f6b | ||
![]() |
0adde249ec | ||
![]() |
c706f11f29 | ||
![]() |
d032050ccf | ||
![]() |
fe1407b6b5 | ||
![]() |
a1065737db | ||
![]() |
15d0f789c7 | ||
![]() |
7be2111d61 | ||
![]() |
fc655f52b9 | ||
![]() |
09e24adf2e | ||
![]() |
a94b3e9e24 | ||
![]() |
ee08e18726 | ||
![]() |
fc02cf004a | ||
![]() |
949e7aecae | ||
![]() |
421e8bb812 | ||
![]() |
b0f3611ab9 | ||
![]() |
5c20c67469 | ||
![]() |
49d611ee69 | ||
![]() |
8b7a50a914 | ||
![]() |
f963faa694 | ||
![]() |
910458cfb3 | ||
![]() |
b196aac5c7 | ||
![]() |
0118776b7e | ||
![]() |
deeb3a95f3 | ||
![]() |
186294607f | ||
![]() |
66369645b5 | ||
![]() |
806813e937 | ||
![]() |
0da25a0b87 | ||
![]() |
989367e345 | ||
![]() |
5d7843c58a | ||
![]() |
22f1b85515 | ||
![]() |
d972216c57 | ||
![]() |
511c16329e | ||
![]() |
14dd503c8a | ||
![]() |
1062e95e39 | ||
![]() |
d6c6345d4c | ||
![]() |
6d4e870e32 | ||
![]() |
6d122e96e1 | ||
![]() |
341bc2a130 | ||
![]() |
65d26be74d | ||
![]() |
73892dfa12 | ||
![]() |
7ef1cff5d1 | ||
![]() |
812dea70d0 | ||
![]() |
9e2f2eb27f | ||
![]() |
e31b925234 | ||
![]() |
61cdcd47ca | ||
![]() |
fe39af4ec8 | ||
![]() |
ce7ced5488 | ||
![]() |
777ec2c04d | ||
![]() |
c24de5fcaf | ||
![]() |
b6c1acab3c | ||
![]() |
bba5808717 | ||
![]() |
30ec3edd8b | ||
![]() |
247b03172c | ||
![]() |
6f3282623f | ||
![]() |
714ed41b6f | ||
![]() |
5a135a3b7d | ||
![]() |
883ec9391d | ||
![]() |
dd307cc23e | ||
![]() |
c352f5228b | ||
![]() |
8a02dc0ad5 | ||
![]() |
3871e01a9f |
54
.github/ISSUE_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
Thanks for raising your issue here! 🙂
|
||||
|
||||
Before you submit the issue however, we'd like you to consider the follow points.
|
||||
|
||||
* We like to use the issue tracker for confirmed issues.
|
||||
* If you're stuck with SFML, please use [the forum](https://en.sfml-dev.org/forums/index.php#c3) to get help.
|
||||
|
||||
----
|
||||
|
||||
## Subject of the issue
|
||||
|
||||
Describe your issue here.
|
||||
|
||||
## Your environment
|
||||
|
||||
* Your OS / distro / window manager used
|
||||
* Your version of SFML (2.5.0, git master, etc)
|
||||
* Your compiler and compiler version used
|
||||
* Special compiler flags used
|
||||
|
||||
## Steps to reproduce
|
||||
|
||||
Tell us how to reproduce this issue. Please provide a [minimal, complete and verifiable example](https://stackoverflow.com/help/mcve), you can use the follow template as a start:
|
||||
|
||||
```cpp
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
sf::RenderWindow window(sf::VideoMode(1280, 720), "Minimal, complete and verifiable example");
|
||||
window.setFramerateLimit(60);
|
||||
|
||||
while (window.isOpen())
|
||||
{
|
||||
sf::Event event;
|
||||
while (window.pollEvent(event))
|
||||
{
|
||||
if (event.type == sf::Event::Closed)
|
||||
window.close();
|
||||
}
|
||||
|
||||
window.clear();
|
||||
window.display();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Expected behavior
|
||||
|
||||
Tell us what should happen
|
||||
|
||||
## Actual behavior
|
||||
|
||||
Tell us what happens instead
|
51
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
Thanks a lot for making a contribution to SFML! 🙂
|
||||
|
||||
Before you create the pull request, we ask you to check the follow boxes. (For small changes not everything needs to ticked, but the more the better!)
|
||||
|
||||
* [ ] Has this change been discussed on [the forum](https://en.sfml-dev.org/forums/index.php#c3) or in an issue before?
|
||||
* [ ] Does the code follow the SFML [Code Style Guide](https://www.sfml-dev.org/style.php)?
|
||||
* [ ] Have you provided some example/test code for your changes?
|
||||
* [ ] If you have additional steps which need to be performed list them as tasks!
|
||||
|
||||
----
|
||||
|
||||
## Description
|
||||
|
||||
Please describe your pull request.
|
||||
|
||||
This PR is related to the issue #
|
||||
|
||||
## Tasks
|
||||
|
||||
* [ ] Tested on Linux
|
||||
* [ ] Tested on Windows
|
||||
* [ ] Tested on macOS
|
||||
* [ ] Tested on iOS
|
||||
* [ ] Tested on Android
|
||||
|
||||
## How to test this PR?
|
||||
|
||||
Describe how to best test these changes. Please provide a [minimal, complete and verifiable example](https://stackoverflow.com/help/mcve) if possible, you can use the follow template as a start:
|
||||
|
||||
```cpp
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
sf::RenderWindow window(sf::VideoMode(1280, 720), "Minimal, complete and verifiable example");
|
||||
window.setFramerateLimit(60);
|
||||
|
||||
while (window.isOpen())
|
||||
{
|
||||
sf::Event event;
|
||||
while (window.pollEvent(event))
|
||||
{
|
||||
if (event.type == sf::Event::Closed)
|
||||
window.close();
|
||||
}
|
||||
|
||||
window.clear();
|
||||
window.display();
|
||||
}
|
||||
}
|
||||
```
|
55
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
name: CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: ${{ matrix.platform.name }} ${{ matrix.config.name }}
|
||||
runs-on: ${{ matrix.platform.os }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
platform:
|
||||
- { name: Windows VS2017, os: windows-2016 }
|
||||
- { name: Windows VS2019, os: windows-latest }
|
||||
- { name: Linux GCC, os: ubuntu-latest }
|
||||
- { name: Linux Clang, os: ubuntu-latest, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
|
||||
- { name: MacOS XCode, os: macos-latest }
|
||||
config:
|
||||
- { name: Shared, flags: -DBUILD_SHARED_LIBS=TRUE }
|
||||
- { name: Static, flags: -DBUILD_SHARED_LIBS=FALSE }
|
||||
|
||||
include:
|
||||
- platform: { name: MacOS XCode, os: macos-latest }
|
||||
config: { name: Frameworks, flags: -DSFML_BUILD_FRAMEWORKS=TRUE }
|
||||
- platform: { name: MacOS XCode, os: macos-latest }
|
||||
config: { name: iOS, flags: -DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/cmake/toolchains/iOS.toolchain.cmake -DIOS_PLATFORM=SIMULATOR }
|
||||
- platform: { name: Android, os: ubuntu-latest }
|
||||
config: { name: x86, flags: -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_SYSTEM_NAME=Android -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_ANDROID_NDK=$GITHUB_WORKSPACE/android-ndk-r18b -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang -DCMAKE_ANDROID_STL_TYPE=c++_shared -DCMAKE_ANDROID_API=26 }
|
||||
- platform: { name: Android, os: ubuntu-latest }
|
||||
config: { name: armeabi-v7a, flags: -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_SYSTEM_NAME=Android -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_ANDROID_NDK=$GITHUB_WORKSPACE/android-ndk-r18b -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang -DCMAKE_ANDROID_STL_TYPE=c++_shared -DCMAKE_ANDROID_API=26 }
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install Linux Dependencies
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get install libxrandr-dev libxcursor-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev
|
||||
|
||||
|
||||
- name: Install Android Components
|
||||
if: matrix.platform.name == 'Android'
|
||||
run: |
|
||||
echo "y" | /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "cmake;3.10.2.4988404" --sdk_root=ANDROID_SDK_ROOT
|
||||
sudo ln -sf /usr/local/lib/android/sdk/cmake/3.10.2.4988404/bin/cmake /usr/bin/cmake
|
||||
wget -nv https://dl.google.com/android/repository/android-ndk-r18b-linux-x86_64.zip -P $GITHUB_WORKSPACE
|
||||
unzip -qq -d $GITHUB_WORKSPACE android-ndk-r18b-linux-x86_64.zip
|
||||
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
run: cmake -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/install -DSFML_BUILD_EXAMPLES=TRUE -DCMAKE_VERBOSE_MAKEFILE=ON -DSFML_BUILD_TEST_SUITE=TRUE ${{matrix.platform.flags}} ${{matrix.config.flags}}
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
run: cmake --build $GITHUB_WORKSPACE/build --config Release --target install
|
134
.travis.yml
Normal file
|
@ -0,0 +1,134 @@
|
|||
language: cpp
|
||||
|
||||
addons:
|
||||
apt_packages:
|
||||
- cmake
|
||||
- libxrandr-dev
|
||||
- libxcursor-dev
|
||||
- libudev-dev
|
||||
- libopenal-dev
|
||||
- libflac-dev
|
||||
- libvorbis-dev
|
||||
- g++
|
||||
- clang
|
||||
- libgl1-mesa-dev
|
||||
|
||||
before_script:
|
||||
- mkdir build && cd build
|
||||
- cmake .. $CMAKE_FLAGS -DCMAKE_INSTALL_PREFIX=../install -DSFML_BUILD_EXAMPLES=TRUE -DCMAKE_VERBOSE_MAKEFILE=ON
|
||||
|
||||
script:
|
||||
- cmake --build . --target install
|
||||
|
||||
matrix:
|
||||
include:
|
||||
|
||||
- name: "Linux gcc Dynamic"
|
||||
os: linux
|
||||
dist: xenial
|
||||
compiler: gcc
|
||||
env:
|
||||
- CMAKE_FLAGS="-DSFML_BUILD_TEST_SUITE=TRUE"
|
||||
|
||||
- name: "Linux gcc Static"
|
||||
os: linux
|
||||
dist: xenial
|
||||
compiler: gcc
|
||||
env:
|
||||
- CMAKE_FLAGS="-DBUILD_SHARED_LIBS=FALSE -DSFML_BUILD_TEST_SUITE=TRUE"
|
||||
|
||||
- name: "Linux clang Dynamic"
|
||||
os: linux
|
||||
dist: xenial
|
||||
compiler: clang
|
||||
env:
|
||||
- CMAKE_FLAGS="-DSFML_BUILD_TEST_SUITE=TRUE"
|
||||
|
||||
- name: "Linux clang Static"
|
||||
os: linux
|
||||
dist: xenial
|
||||
compiler: clang
|
||||
env:
|
||||
- CMAKE_FLAGS="-DBUILD_SHARED_LIBS=FALSE -DSFML_BUILD_TEST_SUITE=TRUE"
|
||||
|
||||
- name: "macOS Xcode 10 Dynamic"
|
||||
os: osx
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- CMAKE_FLAGS="-DSFML_BUILD_TEST_SUITE=TRUE"
|
||||
|
||||
- name: "macOS Xcode 10 Frameworks"
|
||||
os: osx
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- CMAKE_FLAGS="-DSFML_BUILD_TEST_SUITE=TRUE -DSFML_BUILD_FRAMEWORKS=TRUE"
|
||||
|
||||
- name: "macOS Xcode 10 Static"
|
||||
os: osx
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- CMAKE_FLAGS="-DSFML_BUILD_TEST_SUITE=TRUE -DBUILD_SHARED_LIBS=FALSE"
|
||||
|
||||
- name: "iOS Xcode 10"
|
||||
os: osx
|
||||
osx_image: xcode10
|
||||
env:
|
||||
- CMAKE_FLAGS="-GXcode -DSFML_BUILD_TEST_SUITE=TRUE -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/iOS.toolchain.cmake -DIOS_PLATFORM=SIMULATOR"
|
||||
|
||||
- name: "Visual Studio 15 2017 Dynamic"
|
||||
os: windows
|
||||
env:
|
||||
- CMAKE_FLAGS="-DSFML_BUILD_TEST_SUITE=FALSE"
|
||||
|
||||
- name: "Visual Studio 15 2017 Static"
|
||||
os: windows
|
||||
env:
|
||||
- CMAKE_FLAGS="-DBUILD_SHARED_LIBS=FALSE -DSFML_BUILD_TEST_SUITE=TRUE"
|
||||
|
||||
- name: "Visual Studio 16 2019 Dynamic"
|
||||
os: windows
|
||||
env:
|
||||
- CMAKE_FLAGS="-DSFML_BUILD_TEST_SUITE=FALSE"
|
||||
- MSBUILD_PATH="C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin"
|
||||
- VS160COMNTOOLS="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools"
|
||||
- PATH=$MSBUILD_PATH:$PATH
|
||||
install:
|
||||
- choco install visualstudio2019buildtools --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64"
|
||||
- choco install visualstudio2019-workload-nativedesktop
|
||||
|
||||
- name: "Visual Studio 16 2019 Static"
|
||||
os: windows
|
||||
env:
|
||||
- CMAKE_FLAGS="-DBUILD_SHARED_LIBS=FALSE -DSFML_BUILD_TEST_SUITE=TRUE"
|
||||
- MSBUILD_PATH="C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin"
|
||||
- VS160COMNTOOLS="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools"
|
||||
- PATH=$MSBUILD_PATH:$PATH
|
||||
install:
|
||||
- choco install visualstudio2019buildtools --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64"
|
||||
- choco install visualstudio2019-workload-nativedesktop
|
||||
|
||||
- name: "Android armeabi-v7a"
|
||||
language: android
|
||||
android: &androidComponents
|
||||
components:
|
||||
- tools
|
||||
- platform-tools
|
||||
- build-tools-26.0.1
|
||||
env:
|
||||
- CMAKE_FLAGS="-DCMAKE_SYSTEM_NAME=Android -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_ANDROID_NDK=$TRAVIS_BUILD_DIR/android-ndk-r18b -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang -DCMAKE_ANDROID_STL_TYPE=c++_shared -DCMAKE_ANDROID_API=26"
|
||||
|
||||
install: &androidInstall
|
||||
- echo y | sdkmanager "cmake;3.10.2.4988404"
|
||||
- sudo ln -sf /usr/local/android-sdk/cmake/3.10.2.4988404/bin/cmake /usr/bin/cmake
|
||||
- wget https://dl.google.com/android/repository/android-ndk-r18b-linux-x86_64.zip
|
||||
- unzip -qq android-ndk-r18b-linux-x86_64.zip
|
||||
|
||||
- name: "Android x86"
|
||||
language: android
|
||||
android: *androidComponents
|
||||
env:
|
||||
- CMAKE_FLAGS="-DCMAKE_SYSTEM_NAME=Android -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_ANDROID_NDK=$TRAVIS_BUILD_DIR/android-ndk-r18b -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang -DCMAKE_ANDROID_STL_TYPE=c++_shared -DCMAKE_ANDROID_API=26"
|
||||
install: *androidInstall
|
||||
|
||||
notifications:
|
||||
email: false
|
237
CMakeLists.txt
|
@ -1,4 +1,9 @@
|
|||
cmake_minimum_required(VERSION 2.8.3)
|
||||
# CMake's built-in Android support requires 3.7.0
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
cmake_minimum_required(VERSION 3.7.2)
|
||||
else()
|
||||
cmake_minimum_required(VERSION 3.0.2)
|
||||
endif()
|
||||
|
||||
# define a macro that helps defining an option
|
||||
macro(sfml_set_option var default type docstring)
|
||||
|
@ -17,8 +22,9 @@ sfml_set_option(CMAKE_BUILD_TYPE Release STRING "Choose the type of build (Debug
|
|||
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
|
||||
|
||||
# Suppress Mac OS X RPATH warnings and adopt new related behaviors
|
||||
if(NOT CMAKE_VERSION VERSION_LESS 3.0)
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
if (NOT CMAKE_VERSION VERSION_LESS 3.9)
|
||||
cmake_policy(SET CMP0068 NEW)
|
||||
endif()
|
||||
|
||||
# add some default value for some additional macOS variable
|
||||
|
@ -26,9 +32,6 @@ endif()
|
|||
if(NOT CMAKE_OSX_ARCHITECTURES)
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "macOS architecture to build; 64-bit is expected" FORCE)
|
||||
endif()
|
||||
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "macOS deployement target; 10.7+ is expected" FORCE)
|
||||
endif()
|
||||
if(NOT CMAKE_OSX_SYSROOT)
|
||||
# query the path to the default SDK, will fail on non-macOS, but it's okay.
|
||||
execute_process(COMMAND xcodebuild -sdk macosx -version Path
|
||||
|
@ -38,39 +41,21 @@ if(NOT CMAKE_OSX_SYSROOT)
|
|||
ERROR_QUIET)
|
||||
endif()
|
||||
|
||||
# set Android specific options
|
||||
|
||||
# define the minimum API level to be used
|
||||
sfml_set_option(ANDROID_API_MIN 9 STRING "Choose the Android API level to be used (minimum 9)")
|
||||
# mirror the setting for the toolchain file
|
||||
set(ANDROID_NATIVE_API_LEVEL ${ANDROID_API_MIN})
|
||||
|
||||
# define the path to the Android NDK
|
||||
sfml_set_option(ANDROID_NDK "$ENV{ANDROID_NDK}" PATH "Path to the Android NDK")
|
||||
|
||||
# define the STL implementation to be used
|
||||
sfml_set_option(ANDROID_STL c++_shared STRING "Choose the STL implementation to be used (experimental)")
|
||||
|
||||
# default the ABI to ARM v7a for hardware floating point
|
||||
if(NOT ANDROID_ABI)
|
||||
set(ANDROID_ABI armeabi-v7a)
|
||||
endif()
|
||||
|
||||
#end of Android specific options
|
||||
|
||||
# project name
|
||||
project(SFML)
|
||||
|
||||
# include the configuration file
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake)
|
||||
|
||||
# we use the paths from the cmake GNUInstallDirs module as defaults
|
||||
# you can override these if you like
|
||||
# https://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# setup version numbers
|
||||
set(VERSION_MAJOR 2)
|
||||
set(VERSION_MINOR 4)
|
||||
set(VERSION_PATCH 2)
|
||||
|
||||
# add the SFML header path
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
set(VERSION_MINOR 5)
|
||||
set(VERSION_PATCH 1)
|
||||
|
||||
# add an option for choosing the build type (shared or static)
|
||||
if(NOT (SFML_OS_IOS OR SFML_OS_ANDROID))
|
||||
|
@ -84,7 +69,7 @@ else()
|
|||
endif()
|
||||
|
||||
# add an option for building the examples
|
||||
if(NOT (SFML_OS_IOS OR SFML_OS_ANDROID))
|
||||
if(NOT SFML_OS_ANDROID)
|
||||
sfml_set_option(SFML_BUILD_EXAMPLES FALSE BOOL "TRUE to build the SFML examples, FALSE to ignore them")
|
||||
else()
|
||||
set(SFML_BUILD_EXAMPLES FALSE)
|
||||
|
@ -93,9 +78,7 @@ endif()
|
|||
# add options to select which modules to build
|
||||
sfml_set_option(SFML_BUILD_WINDOW TRUE BOOL "TRUE to build SFML's Window module. This setting is ignored, if the graphics module is built.")
|
||||
sfml_set_option(SFML_BUILD_GRAPHICS TRUE BOOL "TRUE to build SFML's Graphics module.")
|
||||
if(NOT SFML_OS_IOS)
|
||||
sfml_set_option(SFML_BUILD_AUDIO TRUE BOOL "TRUE to build SFML's Audio module.")
|
||||
endif()
|
||||
sfml_set_option(SFML_BUILD_AUDIO TRUE BOOL "TRUE to build SFML's Audio module.")
|
||||
sfml_set_option(SFML_BUILD_NETWORK TRUE BOOL "TRUE to build SFML's Network module.")
|
||||
|
||||
# add an option for building the API documentation
|
||||
|
@ -106,27 +89,31 @@ if(SFML_BUILD_WINDOW)
|
|||
sfml_set_option(SFML_OPENGL_ES ${OPENGL_ES} BOOL "TRUE to use an OpenGL ES implementation, FALSE to use a desktop OpenGL implementation")
|
||||
endif()
|
||||
|
||||
# Mac OS X specific options
|
||||
# add an option for building the test suite
|
||||
sfml_set_option(SFML_BUILD_TEST_SUITE FALSE BOOL "TRUE to build the SFML test suite, FALSE to ignore it")
|
||||
|
||||
# macOS specific options
|
||||
if(SFML_OS_MACOSX)
|
||||
# add an option to build frameworks instead of dylibs (release only)
|
||||
sfml_set_option(SFML_BUILD_FRAMEWORKS FALSE BOOL "TRUE to build SFML as frameworks libraries (release only), FALSE to build according to BUILD_SHARED_LIBS")
|
||||
|
||||
# add an option to let the user specify a custom directory for frameworks installation (SFML, FLAC, ...)
|
||||
sfml_set_option(CMAKE_INSTALL_FRAMEWORK_PREFIX "/Library/Frameworks" STRING "Frameworks installation directory")
|
||||
|
||||
# add an option to automatically install Xcode templates
|
||||
sfml_set_option(SFML_INSTALL_XCODE_TEMPLATES FALSE BOOL "TRUE to automatically install the Xcode templates, FALSE to do nothing about it. The templates are compatible with Xcode 4 and 5.")
|
||||
endif()
|
||||
|
||||
# iOS specific options
|
||||
if(SFML_OS_IOS)
|
||||
# At the moment the minimal deployement target version is 10.2 only because the externals for iOS were built with that requirement.
|
||||
sfml_set_option(SFML_IOS_DEPLOYMENT_TARGET "10.2" STRING "The minimal iOS version that will be able to run the built binaries. Cannot be lower than 10.2.")
|
||||
|
||||
sfml_set_option(SFML_CODE_SIGN_IDENTITY "iPhone Developer" STRING "The code signing identity to use when building for a real device")
|
||||
endif()
|
||||
|
||||
# Android options
|
||||
if(SFML_OS_ANDROID)
|
||||
# make sure there's the android library available
|
||||
if (${ANDROID_API_MIN} LESS 9)
|
||||
message(FATAL_ERROR "Android API level must be equal or greater than 9. Please adjust the CMake variable 'ANDROID_API_MIN'.")
|
||||
endif()
|
||||
|
||||
if(NOT ANDROID_NDK)
|
||||
message(FATAL_ERROR "The Android NDK couldn't be found. Please adjust the CMake variable 'ANDROID_NDK' to point to the NDK directory.")
|
||||
if (CMAKE_ANDROID_API LESS 14)
|
||||
message(FATAL_ERROR "Android API level (${CMAKE_ANDROID_API}) must be equal or greater than 14.")
|
||||
endif()
|
||||
|
||||
# CMake doesn't support defining the STL to be used with Nsight Tegra, so warn the user
|
||||
|
@ -135,31 +122,39 @@ if(SFML_OS_ANDROID)
|
|||
endif()
|
||||
|
||||
# install everything in $NDK/sources/ because this path is appended by the NDK (convenient)
|
||||
set(CMAKE_INSTALL_PREFIX ${ANDROID_NDK}/sources/sfml)
|
||||
|
||||
# we install libs in a subdirectory named after the ABI (lib/mips/*.so)
|
||||
set(LIB_SUFFIX "/${ANDROID_ABI}")
|
||||
set(CMAKE_INSTALL_PREFIX ${CMAKE_ANDROID_NDK}/sources/third_party/sfml)
|
||||
|
||||
# we install libs in a subdirectory named after the ABI
|
||||
set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${CMAKE_ANDROID_ARCH_ABI}")
|
||||
# pass shared STL configuration (if any)
|
||||
if (ANDROID_STL MATCHES "_shared")
|
||||
add_definitions("-DSTL_LIBRARY=${ANDROID_STL}")
|
||||
if (CMAKE_ANDROID_STL_TYPE MATCHES "_shared")
|
||||
add_definitions("-DSTL_LIBRARY=${CMAKE_ANDROID_STL_TYPE}")
|
||||
# if(NOT CMAKE_ANDROID_STL_TYPE MATCHES "c\\+\\+_shared")
|
||||
# message("Android: Using ${CMAKE_ANDROID_STL_TYPE} as STL. Set CMAKE_ANDROID_STL_TYPE to c++_shared, if there are any issues.")
|
||||
# endif()
|
||||
else()
|
||||
# message(WARNING "Android: You're using a static STL (${CMAKE_ANDROID_STL_TYPE}). Set CMAKE_ANDROID_STL_TYPE to c++_shared, if there are any issues.")
|
||||
endif()
|
||||
|
||||
# let the user switch ABIs
|
||||
set(ANDROID_ABI "armeabi-v7a" CACHE STRING "Look at the NDK docs for currently supported ABIs")
|
||||
|
||||
# this is a workaround to compile sfml-activity without the stl library as a dependency
|
||||
# we save the original compilation command line to restore it later in Macro.cmake
|
||||
set(CMAKE_CXX_CREATE_SHARED_LIBRARY_WITH_STL ${CMAKE_CXX_CREATE_SHARED_LIBRARY})
|
||||
set(CMAKE_CXX_CREATE_SHARED_LIBRARY_WITHOUT_STL "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
else()
|
||||
unset(ANDROID_ABI CACHE)
|
||||
unset(ANDROID_API_MIN CACHE)
|
||||
unset(ANDROID_STL CACHE)
|
||||
unset(ANDROID_NATIVE_API_LEVEL CACHE)
|
||||
unset(ANDROID_NDK CACHE)
|
||||
endif()
|
||||
|
||||
# define SFML_STATIC if the build type is not set to 'shared'
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
add_definitions(-DSFML_STATIC)
|
||||
# Install directories
|
||||
# For miscellaneous files
|
||||
if(SFML_OS_WINDOWS OR SFML_OS_IOS)
|
||||
set(DEFAULT_INSTALL_MISC_DIR .)
|
||||
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD)
|
||||
set(DEFAULT_INSTALL_MISC_DIR share/SFML)
|
||||
elseif(SFML_OS_MACOSX)
|
||||
set(DEFAULT_INSTALL_MISC_DIR /usr/local/share/SFML)
|
||||
elseif(SFML_OS_ANDROID)
|
||||
set(DEFAULT_INSTALL_MISC_DIR ${CMAKE_ANDROID_NDK}/sources/third_party/sfml)
|
||||
endif()
|
||||
|
||||
# force building sfml-window, if sfml-graphics module is built
|
||||
|
@ -268,39 +263,10 @@ if(SFML_OS_MACOSX)
|
|||
message(FATAL_ERROR "Only 64-bit architecture is supported")
|
||||
endif()
|
||||
|
||||
# Ensure macOS 10.7+ is used
|
||||
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.7")
|
||||
message(FATAL_ERROR "macOS 10.7 or greater is required for the deployment target.")
|
||||
endif()
|
||||
|
||||
# configure Xcode templates
|
||||
set(XCODE_TEMPLATES_ARCH "\$(NATIVE_ARCH_ACTUAL)")
|
||||
endif()
|
||||
|
||||
if(SFML_OS_LINUX OR SFML_OS_FREEBSD)
|
||||
set(PKGCONFIG_DIR lib${LIB_SUFFIX}/pkgconfig)
|
||||
if(SFML_OS_FREEBSD)
|
||||
set(PKGCONFIG_DIR libdata/pkgconfig)
|
||||
endif()
|
||||
if(BUILD_SHARED_LIBS)
|
||||
sfml_set_option(SFML_INSTALL_PKGCONFIG_FILES FALSE BOOL "TRUE to automatically install pkg-config files so other projects can find SFML")
|
||||
if(SFML_INSTALL_PKGCONFIG_FILES)
|
||||
foreach(sfml_module IN ITEMS all system window graphics audio network)
|
||||
CONFIGURE_FILE(
|
||||
"tools/pkg-config/sfml-${sfml_module}.pc.in"
|
||||
"tools/pkg-config/sfml-${sfml_module}.pc"
|
||||
@ONLY)
|
||||
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/tools/pkg-config/sfml-${sfml_module}.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/${PKGCONFIG_DIR}")
|
||||
endforeach()
|
||||
endif()
|
||||
else()
|
||||
if(SFML_INSTALL_PKGCONFIG_FILES)
|
||||
message(WARNING "No pkg-config files are provided for the static SFML libraries (SFML_INSTALL_PKGCONFIG_FILES will be ignored).")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# enable project folders
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
|
||||
|
@ -313,17 +279,34 @@ endif()
|
|||
if(SFML_BUILD_DOC)
|
||||
add_subdirectory(doc)
|
||||
endif()
|
||||
if(SFML_BUILD_TEST_SUITE)
|
||||
if (SFML_OS_IOS)
|
||||
message( WARNING "Unit testing not supported on iOS")
|
||||
else()
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
sfml_set_option(SFML_INSTALL_PKGCONFIG_FILES FALSE BOOL "TRUE to automatically install pkg-config files so other projects can find SFML")
|
||||
# on Linux and BSD-like OS, install pkg-config files by default
|
||||
set(SFML_INSTALL_PKGCONFIG_DEFAULT FALSE)
|
||||
|
||||
if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD)
|
||||
set(SFML_INSTALL_PKGCONFIG_DEFAULT TRUE)
|
||||
endif()
|
||||
|
||||
sfml_set_option(SFML_INSTALL_PKGCONFIG_FILES ${SFML_INSTALL_PKGCONFIG_DEFAULT} BOOL "TRUE to automatically install pkg-config files so other projects can find SFML")
|
||||
|
||||
if(SFML_INSTALL_PKGCONFIG_FILES)
|
||||
sfml_set_option(SFML_PKGCONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/${SFML_PKGCONFIG_DIR}" PATH "Install directory for SFML's pkg-config .pc files")
|
||||
|
||||
if(SFML_OS_SUPPORTS_PKGCONFIG OR SFML_INSTALL_PKGCONFIG_FILES)
|
||||
foreach(sfml_module IN ITEMS all system window graphics audio network)
|
||||
CONFIGURE_FILE(
|
||||
"tools/pkg-config/sfml-${sfml_module}.pc.in"
|
||||
"tools/pkg-config/sfml-${sfml_module}.pc"
|
||||
@ONLY)
|
||||
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/tools/pkg-config/sfml-${sfml_module}.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/${SFML_OS_PKGCONFIG_DIR}")
|
||||
DESTINATION "${SFML_PKGCONFIG_INSTALL_PREFIX}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
|
@ -358,6 +341,9 @@ else()
|
|||
# create SFML.framework
|
||||
add_library(SFML ${SFML_SOURCES})
|
||||
|
||||
# set the target flags to use the appropriate C++ standard library
|
||||
sfml_set_stdlib(SFML)
|
||||
|
||||
# edit target properties
|
||||
set_target_properties(SFML PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
|
@ -371,6 +357,7 @@ else()
|
|||
add_custom_command(TARGET SFML POST_BUILD COMMAND cp -r
|
||||
${PROJECT_SOURCE_DIR}/include/SFML/Config.hpp
|
||||
${PROJECT_SOURCE_DIR}/include/SFML/OpenGL.hpp
|
||||
${PROJECT_SOURCE_DIR}/include/SFML/GpuPreference.hpp
|
||||
${PROJECT_SOURCE_DIR}/include/SFML/System.hpp
|
||||
${PROJECT_SOURCE_DIR}/include/SFML/Main.hpp
|
||||
${PROJECT_SOURCE_DIR}/include/SFML/System
|
||||
|
@ -410,21 +397,23 @@ else()
|
|||
|
||||
# adapt install directory to allow distributing dylibs/frameworks in user's frameworks/application bundle
|
||||
# NOTE: it's not required to link against SFML.framework
|
||||
set_target_properties(SFML PROPERTIES
|
||||
BUILD_WITH_INSTALL_RPATH 1
|
||||
INSTALL_NAME_DIR "@rpath")
|
||||
set_target_properties(SFML PROPERTIES INSTALL_NAME_DIR "@rpath")
|
||||
if(NOT CMAKE_SKIP_BUILD_RPATH)
|
||||
if (CMAKE_VERSION VERSION_LESS 3.9)
|
||||
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
else()
|
||||
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_NAME_DIR TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# install rule
|
||||
install(TARGETS SFML
|
||||
FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX}
|
||||
FRAMEWORK DESTINATION "."
|
||||
COMPONENT devel)
|
||||
endif()
|
||||
|
||||
install(FILES license.md DESTINATION ${INSTALL_MISC_DIR})
|
||||
install(FILES readme.md DESTINATION ${INSTALL_MISC_DIR})
|
||||
if(NOT SFML_OS_ANDROID)
|
||||
install(FILES cmake/Modules/FindSFML.cmake DESTINATION ${INSTALL_MISC_DIR}/cmake/Modules)
|
||||
endif()
|
||||
install(FILES license.md DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||
install(FILES readme.md DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||
|
||||
# install 3rd-party libraries and tools
|
||||
if(SFML_OS_WINDOWS)
|
||||
|
@ -432,58 +421,57 @@ if(SFML_OS_WINDOWS)
|
|||
if(NOT SFML_USE_SYSTEM_DEPS)
|
||||
# install the binaries of SFML dependencies
|
||||
if(ARCH_32BITS)
|
||||
install(DIRECTORY extlibs/bin/x86/ DESTINATION bin)
|
||||
install(DIRECTORY extlibs/bin/x86/ DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
if(SFML_COMPILER_MSVC AND SFML_MSVC_VERSION LESS 14)
|
||||
install(DIRECTORY extlibs/libs-msvc/x86/ DESTINATION lib)
|
||||
install(DIRECTORY extlibs/libs-msvc/x86/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
elseif(SFML_COMPILER_MSVC)
|
||||
install(DIRECTORY extlibs/libs-msvc-universal/x86/ DESTINATION lib)
|
||||
install(DIRECTORY extlibs/libs-msvc-universal/x86/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
else()
|
||||
install(DIRECTORY extlibs/libs-mingw/x86/ DESTINATION lib)
|
||||
install(DIRECTORY extlibs/libs-mingw/x86/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
elseif(ARCH_64BITS)
|
||||
install(DIRECTORY extlibs/bin/x64/ DESTINATION bin)
|
||||
install(DIRECTORY extlibs/bin/x64/ DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
if(SFML_COMPILER_MSVC AND SFML_MSVC_VERSION LESS 14)
|
||||
install(DIRECTORY extlibs/libs-msvc/x64/ DESTINATION lib)
|
||||
install(DIRECTORY extlibs/libs-msvc/x64/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
elseif(SFML_COMPILER_MSVC)
|
||||
install(DIRECTORY extlibs/libs-msvc-universal/x64/ DESTINATION lib)
|
||||
install(DIRECTORY extlibs/libs-msvc-universal/x64/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
else()
|
||||
install(DIRECTORY extlibs/libs-mingw/x64/ DESTINATION lib)
|
||||
install(DIRECTORY extlibs/libs-mingw/x64/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
elseif(SFML_OS_MACOSX)
|
||||
|
||||
# install extlibs dependencies only when used
|
||||
if(SFML_BUILD_GRAPHICS)
|
||||
if(FREETYPE_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/freetype.framework")
|
||||
install(DIRECTORY extlibs/libs-osx/Frameworks/freetype.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
|
||||
install(DIRECTORY extlibs/libs-osx/Frameworks/freetype.framework DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(SFML_BUILD_AUDIO)
|
||||
if(FLAC_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/FLAC.framework")
|
||||
install(DIRECTORY extlibs/libs-osx/Frameworks/FLAC.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
|
||||
install(DIRECTORY extlibs/libs-osx/Frameworks/FLAC.framework DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
if(OGG_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/ogg.framework")
|
||||
install(DIRECTORY extlibs/libs-osx/Frameworks/ogg.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
|
||||
install(DIRECTORY extlibs/libs-osx/Frameworks/ogg.framework DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
if(VORBIS_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/vorbis.framework")
|
||||
install(DIRECTORY extlibs/libs-osx/Frameworks/vorbis.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
|
||||
install(DIRECTORY extlibs/libs-osx/Frameworks/vorbis.framework DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
if(VORBISENC_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/vorbisenc.framework")
|
||||
install(DIRECTORY extlibs/libs-osx/Frameworks/vorbisenc.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
|
||||
install(DIRECTORY extlibs/libs-osx/Frameworks/vorbisenc.framework DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
if(VORBISFILE_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/vorbisfile.framework")
|
||||
install(DIRECTORY extlibs/libs-osx/Frameworks/vorbisfile.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
|
||||
install(DIRECTORY extlibs/libs-osx/Frameworks/vorbisfile.framework DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
if(OPENAL_LIBRARY STREQUAL "${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/OpenAL.framework")
|
||||
install(DIRECTORY "${OPENAL_LIBRARY}" DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
|
||||
install(DIRECTORY "${OPENAL_LIBRARY}" DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -505,9 +493,7 @@ elseif(SFML_OS_MACOSX)
|
|||
elseif(SFML_OS_IOS)
|
||||
|
||||
# fix CMake install rules broken for iOS (see http://public.kitware.com/Bug/view.php?id=12506)
|
||||
if(SFML_OS_IOS)
|
||||
install(DIRECTORY "${CMAKE_BINARY_DIR}/lib/\$ENV{CONFIGURATION}/" DESTINATION lib${LIB_SUFFIX})
|
||||
endif()
|
||||
install(DIRECTORY "${CMAKE_BINARY_DIR}/lib/\$ENV{CONFIGURATION}/" DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
if(NOT SFML_USE_SYSTEM_DEPS)
|
||||
# since the iOS libraries are built as static, we must install the SFML dependencies
|
||||
|
@ -515,13 +501,20 @@ elseif(SFML_OS_IOS)
|
|||
if(SFML_BUILD_GRAPHICS)
|
||||
install(FILES extlibs/libs-ios/libfreetype.a DESTINATION lib)
|
||||
endif()
|
||||
|
||||
if(SFML_BUILD_AUDIO)
|
||||
install(FILES extlibs/libs-ios/libflac.a
|
||||
extlibs/libs-ios/libvorbis.a
|
||||
extlibs/libs-ios/libogg.a
|
||||
DESTINATION lib)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
elseif(SFML_OS_ANDROID)
|
||||
|
||||
if(NOT SFML_USE_SYSTEM_DEPS)
|
||||
# install extlibs
|
||||
install(DIRECTORY extlibs/libs-android/${ANDROID_ABI} DESTINATION extlibs/lib)
|
||||
install(DIRECTORY extlibs/libs-android/${CMAKE_ANDROID_ARCH_ABI} DESTINATION extlibs/lib)
|
||||
install(FILES extlibs/Android.mk DESTINATION extlibs)
|
||||
endif()
|
||||
|
||||
|
@ -529,3 +522,5 @@ elseif(SFML_OS_ANDROID)
|
|||
install(FILES src/SFML/Android.mk DESTINATION .)
|
||||
|
||||
endif()
|
||||
|
||||
sfml_export_targets()
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
You would like to see a feature implemented or a bug fixed in SFML? Great! Contributions to SFML are highly appreciated, be it in the form of general ideas, concrete suggestions or code patches.
|
||||
|
||||
[A few guiding rules have been set up on the SFML website](http://www.sfml-dev.org/contribute.php) that you should be aware of before opening an Issue or Pull Request. They will help you focus on the important stuff and prevent you from losing (y)our time with requests that are out of SFML's scope, known issues, and so on.
|
||||
[A few guiding rules have been set up on the SFML website](https://www.sfml-dev.org/contribute.php) that you should be aware of before opening an Issue or Pull Request. They will help you focus on the important stuff and prevent you from losing (y)our time with requests that are out of SFML's scope, known issues, and so on.
|
||||
|
||||
Those rules cover the general scope defined for this project, a coding style, and a precise procedure to report bugs or suggest new features.
|
||||
|
|
268
changelog.md
|
@ -1,8 +1,174 @@
|
|||
# Changelog
|
||||
|
||||
## SFML 2.5.1
|
||||
|
||||
Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.5.1
|
||||
|
||||
### General
|
||||
|
||||
* Various CMake fixes (#1414, #1416, #1436, #1439, #1467, #1470)
|
||||
* Fixed the installation of pkg-config files (#1466)
|
||||
* Fixed two conversion warnings (#1454)
|
||||
* [Android] Fixes all symbols in sfml-main are hidden (#1457, #1460)
|
||||
* [Android] Fixed some `#define` flag problem (#1458)
|
||||
* [Android] Fix deadlock in main cleanup (#1265)
|
||||
* [iOS] Modernized toolchain file (#1411)
|
||||
* [iOS] Check that `<SFML/Main.hpp>` is used (#1412)
|
||||
* [macOS] Add `-ObjC` flag to fix static linking on macOS (#1485)
|
||||
|
||||
### Window
|
||||
|
||||
**Bugfixes**
|
||||
|
||||
* [iOS] Use default supported rotations when none are specified (#1417)
|
||||
* [iOS] Fixed autocomplete window overlaps keyboard (#1473, #1482)
|
||||
* [Linux] Fixed dual monitor issue (#1226, #1238)
|
||||
* [Linux] Fixed issue where fullscreen window didn't go over task bars on top and left on in Ubuntu (#1224)
|
||||
* [Linux] Fixed the Unix clipboard implementation causing an abort due to internal data races in Xlib (#1437)
|
||||
* [macOS] Added additional system cursors (#1401, #1413, #1425)
|
||||
* [Windows] Fixed swapped colors for custom cursors (#1464, #1465, #1491)
|
||||
|
||||
### Graphics
|
||||
|
||||
**Bugfixes**
|
||||
|
||||
* Fixed a bug in which a `sf::RenderTexture` would not be re-activated after being re-created (#1438)
|
||||
* Fixed `sf::RenderTextureImplFBO`'s destructor incorrectly triggering deletion of other `sf::RenderTextureImplFBO`'s active FBOs (#1440)
|
||||
* Fix `sf::RenderWindow::setActive` incorrectly trying to unbind an FBO during deactivation (#1442)
|
||||
* Fixed `sf::RenderTexture::display()` dereferencing a NULL pointer when being called before `sf::RenderTexture::create()` (#1446)
|
||||
* Fixed bug in `sf::Text` when applying an outline color/thickness (#1176)
|
||||
* Squash duplicated `sf::Font` glyphs to single chars (#1461)
|
||||
* Fixed two issues with glyph sub-pixel positioning (#1452)
|
||||
* Reduced context locking & unlocking while creating textures (#1459)
|
||||
* Fixed the error message when the wrong bitmap font size is selected (#1456, #1474, #1492)
|
||||
|
||||
### Audio
|
||||
|
||||
**Bugfixes**
|
||||
|
||||
* Fixed performance issue with reading WAV files (#1450)
|
||||
|
||||
## SFML 2.5.0
|
||||
|
||||
Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.5.0
|
||||
|
||||
### General
|
||||
|
||||
* Replaced FindSFML.cmake with SFMLConfig.cmake (#1335)
|
||||
* Markdown'd and updated readme, changelog, contributing and license files (#1196, #1368, #1317)
|
||||
* Improve packaging support (#1173)
|
||||
* Added Tagfile generation and search (#1327)
|
||||
* Added CMake variables to select the modules to be built (#798, #800)
|
||||
* Do not install extlibs if `SFML_USE_SYSTEM_DEPS` is true (#1236, #1237)
|
||||
* Fixed various type conversion/comparison warnings (#1325)
|
||||
* [Android] Increased minimum API version to 14 (#1362)
|
||||
* [Android] Removed custom toolchain and added support for the newest NDK version and Gradle (#1350, #1393)
|
||||
* [iOS] Updated the binary libs from exlibs/libs-ios (#1207, #1209)
|
||||
* [iOS] Use a CMake toolchain file for iOS build (#1268, #1269)
|
||||
* [iOS] Install extlibs if needed (#1348)
|
||||
* [iOS] Drop 32 bit support (#1374)
|
||||
* [iOS] Force correct iOS architecture for cmake (#1373, #1377)
|
||||
* [iOS] Added iOS example (#1378)
|
||||
* [macOS] Fixed launch of cocoa examples (#1334)
|
||||
* [macOS] Improved application signing process (#1020, #1036, #1194)
|
||||
* [macOS] Improved CMake script (#1215, #1371)
|
||||
* [macOS] Use `-stdlib=libc++` (#1361)
|
||||
* [OpenBSD] Added support for OpenBSD (#1330)
|
||||
|
||||
### System
|
||||
|
||||
**Bugfixes**
|
||||
|
||||
* Added protected destructor to `sf::NonCopyable` to prevent possible resource leaks (#1125, #1161)
|
||||
* Fixed crash when `sf::Clock` is constructed in a global scope (#1258)
|
||||
|
||||
### Window
|
||||
|
||||
**Features**
|
||||
|
||||
* Implemented Cursor API (#269, #784, #827)
|
||||
* Implemented Clipboard API (#715, #1204, #1221)
|
||||
* Renamed a few key codes (#1395)
|
||||
* Added joystick example (#1363)
|
||||
* [Windows] Added support for interfacing with joysticks via DirectInput when it is available (#1251, #1326)
|
||||
* [Windows] Fix discrete GPU preference symbols being exported from the wrong place (#1192, #1406)
|
||||
|
||||
**Bugfixes**
|
||||
|
||||
* [Android] Return correct key code for delete/backspace (#1309, #1362)
|
||||
* [iOS] Don't need to find vorbisfile or vorbisenc (#1347)
|
||||
* [Linux] Fixed `sf::Window::getPosition()` returning incorrect position because of differences in window managers (#1228, #1266)
|
||||
* [Linux] Fix X11 key repeat handling not filtering out events from other windows (#1223, #1230, #1291)
|
||||
* [Linux] Restore fullscreen of a non-visible window (#1339)
|
||||
* [macOS] Fixed window menu not working (#1091, #1180, #1193)
|
||||
* [macOS] Fixed crash with application messing hardware detection e.g. TeamViewer (#1323)
|
||||
* [macOS] Added support for (some) Hat/POV axis (#1248)
|
||||
* [Windows] Prevent uninitialized read by zeroing memory (#1264)
|
||||
* [Windows] Fixed modifier keys handling (#1357)
|
||||
|
||||
### Graphics
|
||||
|
||||
**Features**
|
||||
|
||||
* Implemented additional line spacing and letter spacing in `sf::Text` (#928, #1366)
|
||||
* Added `sf::VertexBuffer` class (#1308)
|
||||
* Added GPU local texture copying support, allowing performance optimizations and texture swapping (#1119, #1319, #1320)
|
||||
* Optimize performance by skipping `glTexCoordPointer()` call if not needed (#1015)
|
||||
* Generate shape outline vertices only if necessary (#925, #1356)
|
||||
* Removed dependency to libjpeg, stb_image_write now supports writing JPEG files (#1278, #1279)
|
||||
* Enable comparing `sf::Transform` and optimize resetting OpenGL back to the identity matrix (#1298)
|
||||
* Added missing `setActive()` virtual method to `sf::RenderTarget` (#1157)
|
||||
* Updated stb_image to v2.16 and stb_image_write to v1.07 (#1270)
|
||||
* Added `sf::RenderTexture` stencil and multisampling support (#1274, #1285)
|
||||
* Added example demonstrating `sf::VertexBuffer`, `sf::Shader` and `sf::Thread` usage (#1352)
|
||||
* Optimized `sf::RenderTexture` performance (#1379)
|
||||
|
||||
**Bugfixes**
|
||||
|
||||
* Properly free memory in `sf::Font::cleanup()` (#1119)
|
||||
* Fixed memory leak in `sf::Font` (#1216)
|
||||
* Fix OpenGL texture coordinate pointer not being updated correctly under certain conditions (#1297)
|
||||
* Fix for broken text when the font is reloaded (#1345)
|
||||
* Fix memory leak in `sf::Text` (#1233, #1360)
|
||||
* Fixed strict aliasing punning warning when generating the key of a glyph in Font.cpp (#1187, #1396)
|
||||
* Fixed OpenGL version string being parsed incorrectly on some platforms (#1249, #1390)
|
||||
* [macOS] Worked around render target bug (#1132, #1342)
|
||||
* [Windows] Replaced time-based joystick poll with a hardware event handler (#1179, #1195, #1198, #1199, #1421)
|
||||
|
||||
### Audio
|
||||
|
||||
**Features**
|
||||
|
||||
* Added loop point support to `sf::Music` (#177, #629)
|
||||
* Added support for the extensible PCM wave file format (#1296)
|
||||
* [iOS] Enable audio module (#1338)
|
||||
|
||||
**Bugfixes**
|
||||
|
||||
* Fixed inconsistent seek behavior in `sf::SoundStream` (#1118)
|
||||
* Fixed stack overflow in `sf::SoundStream::fillAndPushBuffer()` (#1154)
|
||||
* Fixed seeking quirks in the FLAC reader (#966, #1162)
|
||||
* Allow polymorphism with `sf::SoundSource` (#1185)
|
||||
* Fixed WAV file writer writing wrong header values (#1280, #1281)
|
||||
* Small bugfix to argument of `alcCaptureOpenDevice()` (#1304, #1305)
|
||||
* [iOS] Find OpenAL correctly (#1263, #1376)
|
||||
* [Windows] Updated OpenAL Soft to 1.18.1 fixing crashes (#1247, #1260)
|
||||
|
||||
### Network
|
||||
|
||||
**Features**
|
||||
|
||||
* Add append/overwrite parameter to Ftp::upload (#1072, #1399)
|
||||
|
||||
**Bugfixes**
|
||||
|
||||
* Fixed wrong condition for building network support (#1253)
|
||||
* Changed TCP listen backlog from 0 to SOMAXCONN (#1369, #1407)
|
||||
* Fixed socket reuse not conforming to documentation (#1346, #1408)
|
||||
|
||||
## SFML 2.4.2
|
||||
|
||||
Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.4.2
|
||||
Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.4.2
|
||||
|
||||
### System
|
||||
|
||||
|
@ -16,7 +182,7 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.4.2
|
|||
|
||||
* Fixed bug where TransientContextLock would hang (#1165, #1172)
|
||||
* [Linux] Fixed GLX extensions being loaded too late (#1183)
|
||||
* [Linux] Fix wrong types passed to XChangeProperty (#1168 #1171)
|
||||
* [Linux] Fix wrong types passed to XChangeProperty (#1168, #1171)
|
||||
* [Windows] Make context disabling via wglMakeCurrent more tolerant of broken drivers (#1186)
|
||||
|
||||
### Graphics
|
||||
|
@ -27,7 +193,7 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.4.2
|
|||
|
||||
## SFML 2.4.1
|
||||
|
||||
Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.4.1
|
||||
Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.4.1
|
||||
|
||||
### General
|
||||
|
||||
|
@ -47,7 +213,7 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.4.1
|
|||
* [Linux] Fixed an issue where GNOME flags window unresponsive (#1089, #1138)
|
||||
* [Linux] Fixed leak of XVisualInfo objects during GlxContext creation (#1135)
|
||||
* [Linux] Fixed possible hang when setting visibility if external window sources (#1136)
|
||||
* [OS X] Fixed inconsistency between doc and impl on OS X for the grab feature (#1133, #1148, #1150)
|
||||
* [macOS] Fixed inconsistency between doc and impl on macOS for the grab feature (#1133, #1148, #1150)
|
||||
* [Windows] Fixed context memory leaks (#1143, #1002)
|
||||
|
||||
### Graphics
|
||||
|
@ -65,7 +231,7 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.4.1
|
|||
|
||||
## SFML 2.4.0
|
||||
|
||||
Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.4.0
|
||||
Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.4.0
|
||||
|
||||
### General
|
||||
|
||||
|
@ -77,7 +243,7 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.4.0
|
|||
* Updated/fixed string comparisons in Config.cmake (#1102)
|
||||
* Added the missing -s postfix for the RelWithDebInfo config (#1014)
|
||||
* [Android] Fixed current Android compilation issues (#1116, #1111, #1079)
|
||||
* [OS X] Update Xcode template material (#976, #968)
|
||||
* [macOS] Update Xcode template material (#976, #968)
|
||||
* [Windows] Added support for VS 2015 (#972)
|
||||
* [Windows] Create and install PDB debug symbols alongside binaries (#1037)
|
||||
|
||||
|
@ -119,10 +285,10 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.4.0
|
|||
* [Android] Accept touch events from "multiple" devices (#954, #953)
|
||||
* [Android] Copy the selected EGL context's settings to SFML (#1039)
|
||||
* [Linux] Fixed modifiers causing sf::Keyboard::Unknown being returned (#1022, #1012)
|
||||
* [OS X] Improved memory management on OS X (#962, #790)
|
||||
* [OS X] Fixed crash when resizing a window to a zero-height/width size (#986, #984)
|
||||
* [OS X] Use the mouse button constant instead of 0 to avoid a compiler error on OSX (#1035)
|
||||
* [OS X] OS X improvement: warnings + bugfix + refactoring, the lot! (#1042)
|
||||
* [macOS] Improved memory management on macOS (#962, #790)
|
||||
* [macOS] Fixed crash when resizing a window to a zero-height/width size (#986, #984)
|
||||
* [macOS] Use the mouse button constant instead of 0 to avoid a compiler error on macOS (#1035)
|
||||
* [macOS] macOS improvement: warnings + bugfix + refactoring, the lot! (#1042)
|
||||
|
||||
### Graphics
|
||||
|
||||
|
@ -150,7 +316,7 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.4.0
|
|||
**Bugfixes**
|
||||
|
||||
* Added an assignment operator to SoundSource (#864)
|
||||
* [OS X] Updates OpenAL-soft for OS X to version 1.17.2 (#1057, #900, #1000)
|
||||
* [macOS] Updates OpenAL-soft for macOS to version 1.17.2 (#1057, #900, #1000)
|
||||
* Fixed a bug where vorbis can't handle large buffers (#1067)
|
||||
* Added support for 24-bit .wav files (#958, #955)
|
||||
* Fixed threading issue in sf::SoundRecorder (#1011)
|
||||
|
@ -169,7 +335,7 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.4.0
|
|||
|
||||
## SFML 2.3.2
|
||||
|
||||
Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.3.2
|
||||
Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.3.2
|
||||
|
||||
### General
|
||||
|
||||
|
@ -197,7 +363,7 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.3.2
|
|||
|
||||
## SFML 2.3.1
|
||||
|
||||
Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.3.1
|
||||
Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.3.1
|
||||
|
||||
### Window
|
||||
|
||||
|
@ -225,7 +391,7 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.3.1
|
|||
|
||||
## SFML 2.3
|
||||
|
||||
Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.3
|
||||
Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.3
|
||||
|
||||
### General
|
||||
|
||||
|
@ -241,7 +407,7 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.3
|
|||
* Added missing includes in the general headers (#851)
|
||||
* [Android] Updated toolchain file and dependencies (#791)
|
||||
* [Linux] Fixed missing pthread dependency (#794)
|
||||
* [OS X] Relaxed CMake installation rules regarding framework dependencies (#767)
|
||||
* [macOS] Relaxed CMake installation rules regarding framework dependencies (#767)
|
||||
|
||||
### Deprecated API
|
||||
|
||||
|
@ -264,8 +430,8 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.3
|
|||
* [iOS] Fixed inconsistency between sf::Touch::getPosition and touch events (#875)
|
||||
* [Linux] Fixed Alt+F4 not getting triggered in window mode (#274)
|
||||
* [Linux] Fixed Unix joystick stuff (#838)
|
||||
* [OS X] Fixed typo in JoystickImpl.cpp to prevent a crash (#762, #765)
|
||||
* [OS X] Fixed an issue in InputImpl::getSFOpenGLViewFromSFMLWindow (#782, #792)
|
||||
* [macOS] Fixed typo in JoystickImpl.cpp to prevent a crash (#762, #765)
|
||||
* [macOS] Fixed an issue in InputImpl::getSFOpenGLViewFromSFMLWindow (#782, #792)
|
||||
|
||||
### Graphics
|
||||
|
||||
|
@ -293,7 +459,7 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.3
|
|||
**Bugfixes**
|
||||
|
||||
* Fixed access violation error in the destructor of sf::AudioDevice (#30, #602)
|
||||
* [OS X] Fixed threading issue with sf::SoundStream and OpenAL (#541, #831)
|
||||
* [macOS] Fixed threading issue with sf::SoundStream and OpenAL (#541, #831)
|
||||
|
||||
### Network
|
||||
|
||||
|
@ -303,7 +469,7 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.3
|
|||
|
||||
## SFML 2.2
|
||||
|
||||
Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.2
|
||||
Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.2
|
||||
|
||||
### General
|
||||
|
||||
|
@ -319,15 +485,15 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.2
|
|||
* Slight adjustments to the examples (#737)
|
||||
* [FreeBSD] Various configuration fixes (#577, #578)
|
||||
* [Linux] Updated FindSFML.cmake to add UDev to SFML's dependencies (#728, #729, #734, #736)
|
||||
* [OS X] Fixed incorrect symlink in freetype.framework (#519)
|
||||
* [OS X] CMake module for correct dependencies (#548)
|
||||
* [OS X] Fixed SFML target for Xcode (#595, #596)
|
||||
* [OS X] Updated implementation, mainly reverting to non-ARC (#601)
|
||||
* [OS X] Fixed memory leaks and dead store (#615)
|
||||
* [OS X] Improved event handling and performance (#617)
|
||||
* [OS X] Reduced memory usage (#672, #698)
|
||||
* [OS X] OS X 10.10 support (#691, #699)
|
||||
* [OS X] Improve flexibility of dependencies' locations (#713)
|
||||
* [macOS] Fixed incorrect symlink in freetype.framework (#519)
|
||||
* [macOS] CMake module for correct dependencies (#548)
|
||||
* [macOS] Fixed SFML target for Xcode (#595, #596)
|
||||
* [macOS] Updated implementation, mainly reverting to non-ARC (#601)
|
||||
* [macOS] Fixed memory leaks and dead store (#615)
|
||||
* [macOS] Improved event handling and performance (#617)
|
||||
* [macOS] Reduced memory usage (#672, #698)
|
||||
* [macOS] macOS 10.10 support (#691, #699)
|
||||
* [macOS] Improve flexibility of dependencies' locations (#713)
|
||||
* [Windows] Removed the hack that copied external libraries into SFML static libraries (dbf01a7)
|
||||
|
||||
### System
|
||||
|
@ -352,10 +518,10 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.2
|
|||
* Added window methods to request and to check focus (#518, #525, #613, #723, #735)
|
||||
* Provide name, manufacturer ID and product ID via sf::Joystick (#152, #528)
|
||||
* [FreeBSD] Joystick support (#477)
|
||||
* [OS X] Improved integration with menus and dock actions (#11)
|
||||
* [OS X] Support for OpenGL 3.2 (#84)
|
||||
* [OS X] Improved fullscreen support (#343)
|
||||
* [OS X] Added support for retina displays (#353, #388)
|
||||
* [macOS] Improved integration with menus and dock actions (#11)
|
||||
* [macOS] Support for OpenGL 3.2 (#84)
|
||||
* [macOS] Improved fullscreen support (#343)
|
||||
* [macOS] Added support for retina displays (#353, #388)
|
||||
* [Windows] Removed support for Windows 9x (#469)
|
||||
* [Windows] Fixed typo in Windows keyboard implementation (#516)
|
||||
|
||||
|
@ -368,14 +534,14 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.2
|
|||
* [Linux] Output error message when XOpenDisplay() fails (#508, #616)
|
||||
* [Linux] Resize window with setSize when sf::Style::Resize is set (#466)
|
||||
* [Linux] Fixed broken key repeat on window recreation (#564, #567)
|
||||
* [OS X] Fixed KeyReleased not being fired in fullscreen mode (#465)
|
||||
* [OS X] Fixed an issue where disconnecting the keyboard would cause a crash (#467)
|
||||
* [OS X] Fixed unexpected resizing behavior (#468)
|
||||
* [OS X] Improved resizing windows (#474)
|
||||
* [OS X] Fixed memory leak with sf::Window::create() (#484)
|
||||
* [OS X] Fixed menu shortcuts in fullscreen on OS X (#527)
|
||||
* [OS X] Improved cursor hiding (#703)
|
||||
* [OS X] Fixed right click not detected with trackpads (#716, #730)
|
||||
* [macOS] Fixed KeyReleased not being fired in fullscreen mode (#465)
|
||||
* [macOS] Fixed an issue where disconnecting the keyboard would cause a crash (#467)
|
||||
* [macOS] Fixed unexpected resizing behavior (#468)
|
||||
* [macOS] Improved resizing windows (#474)
|
||||
* [macOS] Fixed memory leak with sf::Window::create() (#484)
|
||||
* [macOS] Fixed menu shortcuts in fullscreen on macOS (#527)
|
||||
* [macOS] Improved cursor hiding (#703)
|
||||
* [macOS] Fixed right click not detected with trackpads (#716, #730)
|
||||
* [Windows] Fixed joystick POV values (ef1d29b)
|
||||
* [Windows] Fixed Unicode inconsistency (#635)
|
||||
* [Windows] Fixed Alt+F4 and mouse clicks issues (#437, #457)
|
||||
|
@ -451,7 +617,7 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.2
|
|||
|
||||
## SFML 2.1
|
||||
|
||||
Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.1
|
||||
Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.1
|
||||
|
||||
### General
|
||||
|
||||
|
@ -462,12 +628,12 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.1
|
|||
**Features**
|
||||
|
||||
* Now using inotify on Linux to avoid constantly polling joystick connections (#96)
|
||||
* Add keypad return, equal and period keys support for OS X
|
||||
* Improved mouse events on OS X regarding fullscreen mode
|
||||
* Improved mouse events on OS X (#213, #277)
|
||||
* Improved reactivity of setMousePosition on OS X (#290)
|
||||
* Added support for right control key on OS X
|
||||
* Improved TextEntered for OS X (#377)
|
||||
* Add keypad return, equal and period keys support for macOS
|
||||
* Improved mouse events on macOS regarding fullscreen mode
|
||||
* Improved mouse events on macOS (#213, #277)
|
||||
* Improved reactivity of setMousePosition on macOS (#290)
|
||||
* Added support for right control key on macOS
|
||||
* Improved TextEntered for macOS (#377)
|
||||
* Improved the performances of Window::getSize() (the size is now cached)
|
||||
* Added the WM_CLASS property to SFML windows on Linux
|
||||
* Fake resize events are no longer sent when the window is moved, on Linux
|
||||
|
@ -480,7 +646,7 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.1
|
|||
* Fixed ContextSettings ignored on Linux when creating a window (#35)
|
||||
* Fixed windows bigger than the desktop not appearing on Windows (#215)
|
||||
* Fixed KeyRelease events sometimes not reported on Linux (#404)
|
||||
* Fixed mouse moved event on OS X when dragging the cursor (#277)
|
||||
* Fixed mouse moved event on macOS when dragging the cursor (#277)
|
||||
* Fixed KeyRelease event with CMD key pressed (#381)
|
||||
* Fixed taskbar bugs on Windows (#328, #69)
|
||||
* Fixed Window::getPosition() on Linux (#346)
|
||||
|
@ -509,7 +675,7 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.1
|
|||
|
||||
**Bugfixes**
|
||||
|
||||
* Added a workaround for a bug in the OS X implementation of OpenAL (unsupported channel count no properly detected) (#201)
|
||||
* Added a workaround for a bug in the macOS implementation of OpenAL (unsupported channel count no properly detected) (#201)
|
||||
* Fixed SoundBuffer::loadFromStream reading past the end of the stream (#214)
|
||||
|
||||
### Network
|
||||
|
@ -527,10 +693,10 @@ Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.1
|
|||
|
||||
## SFML 2.0
|
||||
|
||||
Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.0
|
||||
Also available on the website: https://www.sfml-dev.org/changelog.php#sfml-2.0
|
||||
|
||||
No changelog available. *Everything changed.*
|
||||
|
||||
## Older Releases
|
||||
|
||||
See the website for changelogs of older releases: http://www.sfml-dev.org/changelog.php
|
||||
See the website for changelogs of older releases: https://www.sfml-dev.org/changelog.php
|
||||
|
|
|
@ -31,18 +31,14 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "^k?FreeBSD$")
|
|||
set(SFML_OS_FREEBSD 1)
|
||||
# don't use the OpenGL ES implementation on FreeBSD
|
||||
set(OPENGL_ES 0)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "^OpenBSD$")
|
||||
set(SFML_OS_OPENBSD 1)
|
||||
# don't use the OpenGL ES implementation on OpenBSD
|
||||
set(OPENGL_ES 0)
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
if(IOS)
|
||||
set(SFML_OS_IOS 1)
|
||||
|
||||
# set the target framework and platforms
|
||||
set(CMAKE_OSX_SYSROOT "iphoneos")
|
||||
set(CMAKE_OSX_ARCHITECTURES "armv6;armv7;i386")
|
||||
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator")
|
||||
|
||||
# help the compiler detection script below
|
||||
set(CMAKE_COMPILER_IS_GNUCXX 1)
|
||||
|
||||
# use the OpenGL ES implementation on iOS
|
||||
set(OPENGL_ES 1)
|
||||
else()
|
||||
|
@ -73,23 +69,18 @@ else()
|
|||
return()
|
||||
endif()
|
||||
|
||||
# check if OS or package system supports pkg-config
|
||||
# set pkgconfig install directory
|
||||
# this could be e.g. macports on mac or msys2 on windows etc.
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_EXECUTABLE)
|
||||
if(EXISTS "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig")
|
||||
set(SFML_OS_SUPPORTS_PKGCONFIG ON)
|
||||
set(SFML_OS_PKGCONFIG_DIR "/lib${LIB_SUFFIX}/pkgconfig")
|
||||
elseif(EXISTS "${CMAKE_INSTALL_PREFIX}/libdata/pkgconfig")
|
||||
set(SFML_OS_SUPPORTS_PKGCONFIG ON)
|
||||
set(SFML_OS_PKGCONFIG_DIR "/libdata/pkgconfig")
|
||||
endif()
|
||||
set(SFML_PKGCONFIG_DIR "/${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
|
||||
if(SFML_OS_FREEBSD OR SFML_OS_OPENBSD)
|
||||
set(SFML_PKGCONFIG_DIR "/libdata/pkgconfig")
|
||||
endif()
|
||||
|
||||
# detect the compiler and its version
|
||||
# Note: on some platforms (OS X), CMAKE_COMPILER_IS_GNUCXX is true
|
||||
# even when CLANG is used, therefore the Clang test is done first
|
||||
if(CMAKE_CXX_COMPILER MATCHES ".*clang[+][+]" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
if(CMAKE_CXX_COMPILER MATCHES "clang[+][+]" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# CMAKE_CXX_COMPILER_ID is an internal CMake variable subject to change,
|
||||
# but there is no other way to detect CLang at the moment
|
||||
set(SFML_COMPILER_CLANG 1)
|
||||
|
@ -125,12 +116,3 @@ else()
|
|||
message(FATAL_ERROR "Unsupported compiler")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# define the install directory for miscellaneous files
|
||||
if(SFML_OS_WINDOWS OR SFML_OS_IOS)
|
||||
set(INSTALL_MISC_DIR .)
|
||||
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX)
|
||||
set(INSTALL_MISC_DIR share/SFML)
|
||||
elseif(SFML_OS_ANDROID)
|
||||
set(INSTALL_MISC_DIR ${ANDROID_NDK}/sources/sfml)
|
||||
endif()
|
||||
|
|
|
@ -1,17 +1,67 @@
|
|||
include(CMakeParseArguments)
|
||||
|
||||
# This little macro lets you set any Xcode specific property
|
||||
macro (sfml_set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE)
|
||||
set_property (TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE})
|
||||
endmacro ()
|
||||
|
||||
# set the appropriate standard library on each platform for the given target
|
||||
# example: sfml_set_stdlib(sfml-system)
|
||||
function(sfml_set_stdlib target)
|
||||
# for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
|
||||
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4")
|
||||
if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
|
||||
target_link_libraries(${target} PRIVATE "-static-libgcc" "-static-libstdc++")
|
||||
elseif(NOT SFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM)
|
||||
target_link_libraries(${target} PRIVATE "-shared-libgcc" "-shared-libstdc++")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (SFML_OS_MACOSX)
|
||||
if (${CMAKE_GENERATOR} MATCHES "Xcode")
|
||||
sfml_set_xcode_property(${target} CLANG_CXX_LIBRARY "libc++")
|
||||
else()
|
||||
target_compile_options(${target} PRIVATE "-stdlib=libc++")
|
||||
target_link_libraries(${target} PRIVATE "-stdlib=libc++")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(sfml_set_common_ios_properties target)
|
||||
# enable automatic reference counting on iOS
|
||||
sfml_set_xcode_property(${target} CLANG_ENABLE_OBJC_ARC YES)
|
||||
sfml_set_xcode_property(${target} IPHONEOS_DEPLOYMENT_TARGET "${SFML_IOS_DEPLOYMENT_TARGET}")
|
||||
sfml_set_xcode_property(${target} CODE_SIGN_IDENTITY "${SFML_CODE_SIGN_IDENTITY}")
|
||||
|
||||
get_target_property(target_type ${target} TYPE)
|
||||
if (target_type STREQUAL "EXECUTABLE")
|
||||
set_target_properties(${target} PROPERTIES
|
||||
MACOSX_BUNDLE TRUE # Bare executables are not usable on iOS, only bundle applications
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER "org.sfml-dev.${target}" # If missing, trying to launch an example in simulator will make Xcode < 9.3 crash
|
||||
MACOSX_BUNDLE_BUNDLE_NAME "${target}"
|
||||
MACOSX_BUNDLE_LONG_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# add a new target which is a SFML library
|
||||
# ex: sfml_add_library(sfml-graphics
|
||||
# SOURCES sprite.cpp image.cpp ...
|
||||
# DEPENDS sfml-window sfml-system
|
||||
# EXTERNAL_LIBS opengl freetype ...)
|
||||
# example: sfml_add_library(sfml-graphics
|
||||
# SOURCES sprite.cpp image.cpp ...
|
||||
# [STATIC]) # Always create a static library and ignore BUILD_SHARED_LIBS
|
||||
macro(sfml_add_library target)
|
||||
|
||||
# parse the arguments
|
||||
cmake_parse_arguments(THIS "" "" "SOURCES;DEPENDS;EXTERNAL_LIBS" ${ARGN})
|
||||
cmake_parse_arguments(THIS "STATIC" "" "SOURCES" ${ARGN})
|
||||
if (NOT "${THIS_UNPARSED_ARGUMENTS}" STREQUAL "")
|
||||
message(FATAL_ERROR "Extra unparsed arguments when calling sfml_add_library: ${THIS_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
|
||||
# create the target
|
||||
add_library(${target} ${THIS_SOURCES})
|
||||
if (THIS_STATIC)
|
||||
add_library(${target} STATIC ${THIS_SOURCES})
|
||||
else()
|
||||
add_library(${target} ${THIS_SOURCES})
|
||||
endif()
|
||||
|
||||
# define the export symbol of the module
|
||||
string(REPLACE "-" "_" NAME_UPPER "${target}")
|
||||
|
@ -19,7 +69,7 @@ macro(sfml_add_library target)
|
|||
set_target_properties(${target} PROPERTIES DEFINE_SYMBOL ${NAME_UPPER}_EXPORTS)
|
||||
|
||||
# adjust the output file prefix/suffix to match our conventions
|
||||
if(BUILD_SHARED_LIBS)
|
||||
if(BUILD_SHARED_LIBS AND NOT THIS_STATIC)
|
||||
if(SFML_OS_WINDOWS)
|
||||
# include the major version number in Windows shared library names (but not import library names)
|
||||
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
|
||||
|
@ -50,14 +100,8 @@ macro(sfml_add_library target)
|
|||
# set the target's folder (for IDEs that support it, e.g. Visual Studio)
|
||||
set_target_properties(${target} PROPERTIES FOLDER "SFML")
|
||||
|
||||
# for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
|
||||
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4")
|
||||
if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
|
||||
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()
|
||||
# set the target flags to use the appropriate C++ standard library
|
||||
sfml_set_stdlib(${target})
|
||||
|
||||
# For Visual Studio on Windows, export debug symbols (PDB files) to lib directory
|
||||
if(SFML_GENERATE_PDB)
|
||||
|
@ -68,7 +112,7 @@ macro(sfml_add_library target)
|
|||
set(SFML_PDB_POSTFIX "")
|
||||
endif()
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
if(BUILD_SHARED_LIBS AND NOT THIS_STATIC)
|
||||
# DLLs export debug symbols in the linker PDB (the compiler PDB is an intermediate file)
|
||||
set_target_properties(${target} PROPERTIES
|
||||
PDB_NAME "${target}${SFML_PDB_POSTFIX}"
|
||||
|
@ -87,13 +131,8 @@ macro(sfml_add_library target)
|
|||
set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fvisibility=hidden)
|
||||
endif()
|
||||
|
||||
# link the target to its SFML dependencies
|
||||
if(THIS_DEPENDS)
|
||||
target_link_libraries(${target} ${THIS_DEPENDS})
|
||||
endif()
|
||||
|
||||
# build frameworks or dylibs
|
||||
if(SFML_OS_MACOSX AND BUILD_SHARED_LIBS)
|
||||
if(SFML_OS_MACOSX AND BUILD_SHARED_LIBS AND NOT THIS_STATIC)
|
||||
if(SFML_BUILD_FRAMEWORKS)
|
||||
# adapt target to build frameworks instead of dylibs
|
||||
set_target_properties(${target} PROPERTIES
|
||||
|
@ -107,20 +146,19 @@ macro(sfml_add_library target)
|
|||
# adapt install directory to allow distributing dylibs/frameworks in user's frameworks/application bundle
|
||||
# but only if cmake rpath options aren't set
|
||||
if(NOT CMAKE_SKIP_RPATH AND NOT CMAKE_SKIP_INSTALL_RPATH AND NOT CMAKE_INSTALL_RPATH AND NOT CMAKE_INSTALL_RPATH_USE_LINK_PATH AND NOT CMAKE_INSTALL_NAME_DIR)
|
||||
if(CMAKE_SKIP_BUILD_RPATH)
|
||||
set_target_properties(${target} PROPERTIES
|
||||
INSTALL_NAME_DIR "@rpath")
|
||||
else()
|
||||
set_target_properties(${target} PROPERTIES
|
||||
BUILD_WITH_INSTALL_RPATH 1
|
||||
INSTALL_NAME_DIR "@rpath")
|
||||
set_target_properties(${target} PROPERTIES INSTALL_NAME_DIR "@rpath")
|
||||
if(NOT CMAKE_SKIP_BUILD_RPATH)
|
||||
if (CMAKE_VERSION VERSION_LESS 3.9)
|
||||
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
else()
|
||||
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_NAME_DIR TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# enable automatic reference counting on iOS
|
||||
if (SFML_OS_IOS)
|
||||
set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES)
|
||||
sfml_set_common_ios_properties(${target})
|
||||
endif()
|
||||
|
||||
# sfml-activity library is our bootstrap activity and must not depend on stlport_shared
|
||||
|
@ -135,37 +173,71 @@ macro(sfml_add_library target)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
# link the target to its external dependencies
|
||||
if(THIS_EXTERNAL_LIBS)
|
||||
target_link_libraries(${target} ${THIS_EXTERNAL_LIBS})
|
||||
# add the install rule
|
||||
install(TARGETS ${target} EXPORT SFMLConfigExport
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT bin
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel
|
||||
FRAMEWORK DESTINATION "." COMPONENT bin)
|
||||
|
||||
# add <project>/include as public include directory
|
||||
target_include_directories(${target}
|
||||
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||
PRIVATE ${PROJECT_SOURCE_DIR}/src)
|
||||
|
||||
if (SFML_BUILD_FRAMEWORKS)
|
||||
target_include_directories(${target} INTERFACE $<INSTALL_INTERFACE:SFML.framework>)
|
||||
else()
|
||||
target_include_directories(${target} INTERFACE $<INSTALL_INTERFACE:include>)
|
||||
endif()
|
||||
|
||||
# define SFML_STATIC if the build type is not set to 'shared'
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(${target} PUBLIC "SFML_STATIC")
|
||||
endif()
|
||||
|
||||
# add the install rule
|
||||
install(TARGETS ${target}
|
||||
RUNTIME DESTINATION bin COMPONENT bin
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel
|
||||
FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} COMPONENT bin)
|
||||
endmacro()
|
||||
|
||||
# add a new target which is a SFML example
|
||||
# ex: sfml_add_example(ftp
|
||||
# SOURCES ftp.cpp ...
|
||||
# DEPENDS sfml-network sfml-system)
|
||||
# example: sfml_add_example(ftp
|
||||
# SOURCES ftp.cpp ...
|
||||
# BUNDLE_RESOURCES MainMenu.nib ... # Files to be added in target but not installed next to the executable
|
||||
# DEPENDS sfml-network
|
||||
# RESOURCES_DIR resources) # A directory to install next to the executable and sources
|
||||
macro(sfml_add_example target)
|
||||
|
||||
# parse the arguments
|
||||
cmake_parse_arguments(THIS "GUI_APP" "" "SOURCES;DEPENDS" ${ARGN})
|
||||
cmake_parse_arguments(THIS "GUI_APP" "RESOURCES_DIR" "SOURCES;BUNDLE_RESOURCES;DEPENDS" ${ARGN})
|
||||
|
||||
# set a source group for the source files
|
||||
source_group("" FILES ${THIS_SOURCES})
|
||||
|
||||
# check whether resources must be added in target
|
||||
set(target_input ${THIS_SOURCES})
|
||||
if(THIS_BUNDLE_RESOURCES)
|
||||
set(target_input ${target_input} ${THIS_BUNDLE_RESOURCES})
|
||||
endif()
|
||||
|
||||
# create the target
|
||||
if(THIS_GUI_APP AND SFML_OS_WINDOWS AND NOT DEFINED CMAKE_CONFIGURATION_TYPES AND ${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
||||
add_executable(${target} WIN32 ${THIS_SOURCES})
|
||||
target_link_libraries(${target} sfml-main)
|
||||
add_executable(${target} WIN32 ${target_input})
|
||||
target_link_libraries(${target} PRIVATE sfml-main)
|
||||
elseif(THIS_GUI_APP AND SFML_OS_IOS)
|
||||
|
||||
# For iOS apps we need the launch screen storyboard,
|
||||
# and a custom info.plist to use it
|
||||
SET(LAUNCH_SCREEN "${CMAKE_SOURCE_DIR}/examples/assets/LaunchScreen.storyboard")
|
||||
SET(LOGO "${CMAKE_SOURCE_DIR}/examples/assets/logo.png")
|
||||
SET(INFO_PLIST "${CMAKE_SOURCE_DIR}/examples/assets/info.plist")
|
||||
SET(ICONS "${CMAKE_SOURCE_DIR}/examples/assets/icon.icns")
|
||||
add_executable(${target} MACOSX_BUNDLE ${target_input} ${LAUNCH_SCREEN} ${LOGO} ${ICONS})
|
||||
set(RESOURCES ${LAUNCH_SCREEN} ${LOGO} ${ICONS})
|
||||
set_target_properties(${target} PROPERTIES RESOURCE "${RESOURCES}"
|
||||
MACOSX_BUNDLE_INFO_PLIST ${INFO_PLIST}
|
||||
MACOSX_BUNDLE_ICON_FILE icon.icns)
|
||||
target_link_libraries(${target} PRIVATE sfml-main)
|
||||
else()
|
||||
add_executable(${target} ${THIS_SOURCES})
|
||||
add_executable(${target} ${target_input})
|
||||
endif()
|
||||
|
||||
# set the debug suffix
|
||||
|
@ -174,61 +246,182 @@ macro(sfml_add_example target)
|
|||
# set the target's folder (for IDEs that support it, e.g. Visual Studio)
|
||||
set_target_properties(${target} PROPERTIES FOLDER "Examples")
|
||||
|
||||
# for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
|
||||
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4")
|
||||
if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
|
||||
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()
|
||||
# set the target flags to use the appropriate C++ standard library
|
||||
sfml_set_stdlib(${target})
|
||||
|
||||
# set the Visual Studio startup path for debugging
|
||||
set_target_properties(${target} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# link the target to its SFML dependencies
|
||||
if(THIS_DEPENDS)
|
||||
target_link_libraries(${target} ${THIS_DEPENDS})
|
||||
target_link_libraries(${target} PRIVATE ${THIS_DEPENDS})
|
||||
endif()
|
||||
|
||||
# add the install rule
|
||||
install(TARGETS ${target}
|
||||
RUNTIME DESTINATION ${INSTALL_MISC_DIR}/examples/${target} COMPONENT examples
|
||||
BUNDLE DESTINATION ${INSTALL_MISC_DIR}/examples/${target} COMPONENT examples)
|
||||
|
||||
# install the example's source code
|
||||
install(FILES ${THIS_SOURCES}
|
||||
DESTINATION ${INSTALL_MISC_DIR}/examples/${target}
|
||||
COMPONENT examples)
|
||||
|
||||
# install the example's resources as well
|
||||
set(EXAMPLE_RESOURCES "${CMAKE_SOURCE_DIR}/examples/${target}/resources")
|
||||
if(EXISTS ${EXAMPLE_RESOURCES})
|
||||
install(DIRECTORY ${EXAMPLE_RESOURCES}
|
||||
DESTINATION ${INSTALL_MISC_DIR}/examples/${target}
|
||||
COMPONENT examples)
|
||||
if (SFML_OS_IOS)
|
||||
sfml_set_common_ios_properties(${target})
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
|
||||
# macro to find packages on the host OS
|
||||
# this is the same as in the toolchain file, which is here for Nsight Tegra VS
|
||||
# since it won't use the Android toolchain file
|
||||
if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
|
||||
macro(find_host_package)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
|
||||
if(CMAKE_HOST_WIN32)
|
||||
set(WIN32 1)
|
||||
set(UNIX)
|
||||
elseif(CMAKE_HOST_APPLE)
|
||||
set(APPLE 1)
|
||||
set(UNIX)
|
||||
endif()
|
||||
find_package(${ARGN})
|
||||
set(WIN32)
|
||||
set(APPLE)
|
||||
set(UNIX 1)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
endmacro()
|
||||
endif()
|
||||
# add a new target which is a SFML test
|
||||
# example: sfml_add_test(sfml-test
|
||||
# ftp.cpp ...
|
||||
# sfml-network)
|
||||
function(sfml_add_test target SOURCES DEPENDS)
|
||||
|
||||
# set a source group for the source files
|
||||
source_group("" FILES ${SOURCES})
|
||||
|
||||
# create the target
|
||||
add_executable(${target} ${SOURCES})
|
||||
|
||||
# set the target's folder (for IDEs that support it, e.g. Visual Studio)
|
||||
set_target_properties(${target} PROPERTIES FOLDER "Tests")
|
||||
|
||||
# link the target to its SFML dependencies
|
||||
if(DEPENDS)
|
||||
target_link_libraries(${target} PRIVATE ${DEPENDS})
|
||||
endif()
|
||||
|
||||
# Add the test
|
||||
add_test(${target} ${target})
|
||||
|
||||
# If building shared libs on windows we must copy the dependencies into the folder
|
||||
if (WIN32 AND BUILD_SHARED_LIBS)
|
||||
foreach (DEPENDENCY ${DEPENDS})
|
||||
add_custom_command(TARGET ${target} PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
$<TARGET_FILE:${DEPENDENCY}>
|
||||
$<TARGET_FILE_DIR:${target}>)
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Create an interface library for an external dependency. This virtual target can provide
|
||||
# link specifications and include directories to be used by dependees.
|
||||
# The created INTERFACE library is tagged for export to be part of the generated SFMLConfig
|
||||
# Usage: sfml_add_external(target_name
|
||||
# [INCLUDE "extlibs/include"]
|
||||
# [LINK "extlibs/libfoo/libfoo.a"])
|
||||
function(sfml_add_external)
|
||||
list(GET ARGN 0 target)
|
||||
list(REMOVE_AT ARGN 0)
|
||||
|
||||
if (TARGET ${target})
|
||||
message(FATAL_ERROR "Target '${target}' is already defined")
|
||||
endif()
|
||||
|
||||
cmake_parse_arguments(THIS "" "" "INCLUDE;LINK" ${ARGN})
|
||||
if (THIS_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "Unknown arguments when calling sfml_import_library: ${THIS_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
|
||||
add_library(${target} INTERFACE)
|
||||
|
||||
if (THIS_INCLUDE)
|
||||
foreach(include_dir IN LISTS THIS_INCLUDE)
|
||||
if (NOT include_dir)
|
||||
message(FATAL_ERROR "No path given for include dir ${THIS_INCLUDE}")
|
||||
endif()
|
||||
target_include_directories(${target} INTERFACE "$<BUILD_INTERFACE:${include_dir}>")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if (THIS_LINK)
|
||||
foreach(link_item IN LISTS THIS_LINK)
|
||||
if (NOT link_item)
|
||||
message(FATAL_ERROR "Missing item in ${THIS_LINK}")
|
||||
endif()
|
||||
target_link_libraries(${target} INTERFACE "$<BUILD_INTERFACE:${link_item}>")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
install(TARGETS ${target} EXPORT SFMLConfigExport)
|
||||
endfunction()
|
||||
|
||||
# Find the requested package and make an INTERFACE library from it
|
||||
# The created INTERFACE library is tagged for export to be part of the generated SFMLConfig
|
||||
# Usage: sfml_find_package(wanted_target_name
|
||||
# [INCLUDE "OPENGL_INCLUDE_DIR"]
|
||||
# [LINK "OPENGL_gl_LIBRARY"])
|
||||
function(sfml_find_package)
|
||||
list(GET ARGN 0 target)
|
||||
list(REMOVE_AT ARGN 0)
|
||||
|
||||
if (TARGET ${target})
|
||||
message(FATAL_ERROR "Target '${target}' is already defined")
|
||||
endif()
|
||||
|
||||
cmake_parse_arguments(THIS "" "" "INCLUDE;LINK" ${ARGN})
|
||||
if (THIS_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "Unknown arguments when calling sfml_import_library: ${THIS_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
|
||||
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules/")
|
||||
if (SFML_OS_IOS)
|
||||
find_host_package(${target} REQUIRED)
|
||||
else()
|
||||
find_package(${target} REQUIRED)
|
||||
endif()
|
||||
|
||||
# Make sure to interpret the items in INCLUDE and LINK parameters. sfml_add_external()
|
||||
# does not interpret given items in order to also accept parameters that must not be interpreted
|
||||
set(LINK_LIST "")
|
||||
if (THIS_LINK)
|
||||
foreach(link_item IN LISTS THIS_LINK)
|
||||
list(APPEND LINK_LIST "${${link_item}}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(INCLUDE_LIST "")
|
||||
if (THIS_INCLUDE)
|
||||
foreach(include_dir IN LISTS THIS_INCLUDE)
|
||||
list(APPEND INCLUDE_LIST "${${include_dir}}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
sfml_add_external(${target} INCLUDE ${INCLUDE_LIST} LINK ${LINK_LIST})
|
||||
endfunction()
|
||||
|
||||
# Generate a SFMLConfig.cmake file (and associated files) from the targets registered against
|
||||
# the EXPORT name "SFMLConfigExport" (EXPORT parameter of install(TARGETS))
|
||||
function(sfml_export_targets)
|
||||
# CMAKE_CURRENT_LIST_DIR or CMAKE_CURRENT_SOURCE_DIR not usable for files that are to be included like this one
|
||||
set(CURRENT_DIR "${PROJECT_SOURCE_DIR}/cmake")
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/SFMLConfigVersion.cmake"
|
||||
VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
set(config_name "Shared")
|
||||
else()
|
||||
set(config_name "Static")
|
||||
endif()
|
||||
set(targets_config_filename "SFML${config_name}Targets.cmake")
|
||||
|
||||
export(EXPORT SFMLConfigExport
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/${targets_config_filename}")
|
||||
|
||||
if (SFML_BUILD_FRAMEWORKS)
|
||||
set(config_package_location "SFML.framework/Resources/CMake")
|
||||
else()
|
||||
set(config_package_location ${CMAKE_INSTALL_LIBDIR}/cmake/SFML)
|
||||
endif()
|
||||
configure_package_config_file("${CURRENT_DIR}/SFMLConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/SFMLConfig.cmake"
|
||||
INSTALL_DESTINATION "${config_package_location}")
|
||||
configure_package_config_file("${CURRENT_DIR}/SFMLConfigDependencies.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/SFMLConfigDependencies.cmake"
|
||||
INSTALL_DESTINATION "${config_package_location}")
|
||||
|
||||
|
||||
install(EXPORT SFMLConfigExport
|
||||
FILE ${targets_config_filename}
|
||||
DESTINATION ${config_package_location})
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/SFMLConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/SFMLConfigDependencies.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/SFMLConfigVersion.cmake"
|
||||
DESTINATION ${config_package_location}
|
||||
COMPONENT devel)
|
||||
endfunction()
|
||||
|
|
|
@ -1,364 +0,0 @@
|
|||
# This script locates the SFML library
|
||||
# ------------------------------------
|
||||
#
|
||||
# Usage
|
||||
# -----
|
||||
#
|
||||
# When you try to locate the SFML libraries, you must specify which modules you want to use (system, window, graphics, network, audio, main).
|
||||
# If none is given, the SFML_LIBRARIES variable will be empty and you'll end up linking to nothing.
|
||||
# example:
|
||||
# find_package(SFML COMPONENTS graphics window system) # find the graphics, window and system modules
|
||||
#
|
||||
# You can enforce a specific version, either MAJOR.MINOR or only MAJOR.
|
||||
# If nothing is specified, the version won't be checked (i.e. any version will be accepted).
|
||||
# example:
|
||||
# find_package(SFML COMPONENTS ...) # no specific version required
|
||||
# find_package(SFML 2 COMPONENTS ...) # any 2.x version
|
||||
# find_package(SFML 2.4 COMPONENTS ...) # version 2.4 or greater
|
||||
#
|
||||
# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
|
||||
# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
|
||||
# Since you have to link yourself all the SFML dependencies when you link it statically, the following
|
||||
# additional variables are defined: SFML_XXX_DEPENDENCIES and SFML_DEPENDENCIES (see their detailed
|
||||
# description below).
|
||||
# In case of static linking, the SFML_STATIC macro will also be defined by this script.
|
||||
# example:
|
||||
# set(SFML_STATIC_LIBRARIES TRUE)
|
||||
# find_package(SFML 2 COMPONENTS network system)
|
||||
#
|
||||
# On Mac OS X if SFML_STATIC_LIBRARIES is not set to TRUE then by default CMake will search for frameworks unless
|
||||
# CMAKE_FIND_FRAMEWORK is set to "NEVER" for example. Please refer to CMake documentation for more details.
|
||||
# Moreover, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which
|
||||
# are available for both release and debug modes.
|
||||
#
|
||||
# If SFML is not installed in a standard path, you can use the SFML_ROOT CMake (or environment) variable
|
||||
# to tell CMake where SFML is.
|
||||
#
|
||||
# Output
|
||||
# ------
|
||||
#
|
||||
# This script defines the following variables:
|
||||
# - For each specified module XXX (system, window, graphics, network, audio, main):
|
||||
# - SFML_XXX_LIBRARY_DEBUG: the name of the debug library of the xxx module (set to SFML_XXX_LIBRARY_RELEASE is no debug version is found)
|
||||
# - SFML_XXX_LIBRARY_RELEASE: the name of the release library of the xxx module (set to SFML_XXX_LIBRARY_DEBUG is no release version is found)
|
||||
# - SFML_XXX_LIBRARY: the name of the library to link to for the xxx module (includes both debug and optimized names if necessary)
|
||||
# - SFML_XXX_FOUND: true if either the debug or release library of the xxx module is found
|
||||
# - SFML_XXX_DEPENDENCIES: the list of libraries the module depends on, in case of static linking
|
||||
# - SFML_LIBRARIES: the list of all libraries corresponding to the required modules
|
||||
# - SFML_FOUND: true if all the required modules are found
|
||||
# - SFML_INCLUDE_DIR: the path where SFML headers are located (the directory containing the SFML/Config.hpp file)
|
||||
# - SFML_DEPENDENCIES: the list of libraries SFML depends on, in case of static linking
|
||||
#
|
||||
# example:
|
||||
# find_package(SFML 2 COMPONENTS system window graphics audio REQUIRED)
|
||||
# include_directories(${SFML_INCLUDE_DIR})
|
||||
# add_executable(myapp ...)
|
||||
# target_link_libraries(myapp ${SFML_LIBRARIES})
|
||||
|
||||
# define the SFML_STATIC macro if static build was chosen
|
||||
if(SFML_STATIC_LIBRARIES)
|
||||
add_definitions(-DSFML_STATIC)
|
||||
endif()
|
||||
|
||||
# define the list of search paths for headers and libraries
|
||||
set(FIND_SFML_PATHS
|
||||
${SFML_ROOT}
|
||||
$ENV{SFML_ROOT}
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local
|
||||
/usr
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt)
|
||||
|
||||
# find the SFML include directory
|
||||
find_path(SFML_INCLUDE_DIR SFML/Config.hpp
|
||||
PATH_SUFFIXES include
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# check the version number
|
||||
set(SFML_VERSION_OK TRUE)
|
||||
if(SFML_FIND_VERSION AND SFML_INCLUDE_DIR)
|
||||
# extract the major and minor version numbers from SFML/Config.hpp
|
||||
# we have to handle framework a little bit differently:
|
||||
if("${SFML_INCLUDE_DIR}" MATCHES "SFML.framework")
|
||||
set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/Headers/Config.hpp")
|
||||
else()
|
||||
set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/SFML/Config.hpp")
|
||||
endif()
|
||||
FILE(READ "${SFML_CONFIG_HPP_INPUT}" SFML_CONFIG_HPP_CONTENTS)
|
||||
STRING(REGEX REPLACE ".*#define SFML_VERSION_MAJOR ([0-9]+).*" "\\1" SFML_VERSION_MAJOR "${SFML_CONFIG_HPP_CONTENTS}")
|
||||
STRING(REGEX REPLACE ".*#define SFML_VERSION_MINOR ([0-9]+).*" "\\1" SFML_VERSION_MINOR "${SFML_CONFIG_HPP_CONTENTS}")
|
||||
STRING(REGEX REPLACE ".*#define SFML_VERSION_PATCH ([0-9]+).*" "\\1" SFML_VERSION_PATCH "${SFML_CONFIG_HPP_CONTENTS}")
|
||||
if (NOT "${SFML_VERSION_PATCH}" MATCHES "^[0-9]+$")
|
||||
set(SFML_VERSION_PATCH 0)
|
||||
endif()
|
||||
math(EXPR SFML_REQUESTED_VERSION "${SFML_FIND_VERSION_MAJOR} * 10000 + ${SFML_FIND_VERSION_MINOR} * 100 + ${SFML_FIND_VERSION_PATCH}")
|
||||
|
||||
# if we could extract them, compare with the requested version number
|
||||
if (SFML_VERSION_MAJOR)
|
||||
# transform version numbers to an integer
|
||||
math(EXPR SFML_VERSION "${SFML_VERSION_MAJOR} * 10000 + ${SFML_VERSION_MINOR} * 100 + ${SFML_VERSION_PATCH}")
|
||||
|
||||
# compare them
|
||||
if(SFML_VERSION LESS SFML_REQUESTED_VERSION)
|
||||
set(SFML_VERSION_OK FALSE)
|
||||
endif()
|
||||
else()
|
||||
# SFML version is < 2.0
|
||||
if (SFML_REQUESTED_VERSION GREATER 10900)
|
||||
set(SFML_VERSION_OK FALSE)
|
||||
set(SFML_VERSION_MAJOR 1)
|
||||
set(SFML_VERSION_MINOR x)
|
||||
set(SFML_VERSION_PATCH x)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# find the requested modules
|
||||
set(SFML_FOUND TRUE) # will be set to false if one of the required modules is not found
|
||||
foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS})
|
||||
string(TOLOWER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_LOWER)
|
||||
string(TOUPPER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_UPPER)
|
||||
set(FIND_SFML_COMPONENT_NAME sfml-${FIND_SFML_COMPONENT_LOWER})
|
||||
|
||||
# no suffix for sfml-main, it is always a static library
|
||||
if(FIND_SFML_COMPONENT_LOWER STREQUAL "main")
|
||||
# release library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# debug library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}-d
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
else()
|
||||
# static release library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}-s
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# static debug library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}-s-d
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# dynamic release library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# dynamic debug library
|
||||
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG
|
||||
NAMES ${FIND_SFML_COMPONENT_NAME}-d
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
# choose the entries that fit the requested link type
|
||||
if(SFML_STATIC_LIBRARIES)
|
||||
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE})
|
||||
endif()
|
||||
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG})
|
||||
endif()
|
||||
else()
|
||||
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE})
|
||||
endif()
|
||||
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG OR SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
|
||||
# library found
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND TRUE)
|
||||
|
||||
# if both are found, set SFML_XXX_LIBRARY to contain both
|
||||
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY debug ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG}
|
||||
optimized ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
|
||||
endif()
|
||||
|
||||
# if only one debug/release variant is found, set the other to be equal to the found one
|
||||
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
|
||||
# debug and not release
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
|
||||
endif()
|
||||
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG)
|
||||
# release and not debug
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
|
||||
endif()
|
||||
else()
|
||||
# library not found
|
||||
set(SFML_FOUND FALSE)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND FALSE)
|
||||
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY "")
|
||||
set(FIND_SFML_MISSING "${FIND_SFML_MISSING} SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY")
|
||||
endif()
|
||||
|
||||
# mark as advanced
|
||||
MARK_AS_ADVANCED(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE
|
||||
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG)
|
||||
|
||||
# add to the global list of libraries
|
||||
set(SFML_LIBRARIES ${SFML_LIBRARIES} "${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY}")
|
||||
endforeach()
|
||||
|
||||
# in case of static linking, we must also define the list of all the dependencies of SFML libraries
|
||||
if(SFML_STATIC_LIBRARIES)
|
||||
|
||||
# detect the OS
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
set(FIND_SFML_OS_WINDOWS 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(FIND_SFML_OS_LINUX 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
set(FIND_SFML_OS_FREEBSD 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(FIND_SFML_OS_MACOSX 1)
|
||||
endif()
|
||||
|
||||
# start with an empty list
|
||||
set(SFML_DEPENDENCIES)
|
||||
set(FIND_SFML_DEPENDENCIES_NOTFOUND)
|
||||
|
||||
# macro that searches for a 3rd-party library
|
||||
macro(find_sfml_dependency output friendlyname)
|
||||
# No lookup in environment variables (PATH on Windows), as they may contain wrong library versions
|
||||
find_library(${output} NAMES ${ARGN} PATHS ${FIND_SFML_PATHS} PATH_SUFFIXES lib NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
if(${${output}} STREQUAL "${output}-NOTFOUND")
|
||||
unset(output)
|
||||
set(FIND_SFML_DEPENDENCIES_NOTFOUND "${FIND_SFML_DEPENDENCIES_NOTFOUND} ${friendlyname}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# sfml-system
|
||||
list(FIND SFML_FIND_COMPONENTS "system" FIND_SFML_SYSTEM_COMPONENT)
|
||||
if(NOT ${FIND_SFML_SYSTEM_COMPONENT} EQUAL -1)
|
||||
|
||||
# update the list -- these are only system libraries, no need to find them
|
||||
if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD OR FIND_SFML_OS_MACOSX)
|
||||
set(SFML_SYSTEM_DEPENDENCIES "pthread")
|
||||
endif()
|
||||
if(FIND_SFML_OS_LINUX)
|
||||
set(SFML_SYSTEM_DEPENDENCIES ${SFML_SYSTEM_DEPENDENCIES} "rt")
|
||||
endif()
|
||||
if(FIND_SFML_OS_WINDOWS)
|
||||
set(SFML_SYSTEM_DEPENDENCIES "winmm")
|
||||
endif()
|
||||
set(SFML_DEPENDENCIES ${SFML_SYSTEM_DEPENDENCIES} ${SFML_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
# sfml-network
|
||||
list(FIND SFML_FIND_COMPONENTS "network" FIND_SFML_NETWORK_COMPONENT)
|
||||
if(NOT ${FIND_SFML_NETWORK_COMPONENT} EQUAL -1)
|
||||
|
||||
# update the list -- these are only system libraries, no need to find them
|
||||
if(FIND_SFML_OS_WINDOWS)
|
||||
set(SFML_NETWORK_DEPENDENCIES "ws2_32")
|
||||
endif()
|
||||
set(SFML_DEPENDENCIES ${SFML_NETWORK_DEPENDENCIES} ${SFML_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
# sfml-window
|
||||
list(FIND SFML_FIND_COMPONENTS "window" FIND_SFML_WINDOW_COMPONENT)
|
||||
if(NOT ${FIND_SFML_WINDOW_COMPONENT} EQUAL -1)
|
||||
|
||||
# find libraries
|
||||
if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD)
|
||||
find_sfml_dependency(X11_LIBRARY "X11" X11)
|
||||
find_sfml_dependency(XRANDR_LIBRARY "Xrandr" Xrandr)
|
||||
endif()
|
||||
|
||||
if(FIND_SFML_OS_LINUX)
|
||||
find_sfml_dependency(UDEV_LIBRARIES "UDev" udev libudev)
|
||||
endif()
|
||||
|
||||
# update the list
|
||||
if(FIND_SFML_OS_WINDOWS)
|
||||
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "opengl32" "winmm" "gdi32")
|
||||
elseif(FIND_SFML_OS_LINUX)
|
||||
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "GL" ${X11_LIBRARY} ${XRANDR_LIBRARY} ${UDEV_LIBRARIES})
|
||||
elseif(FIND_SFML_OS_FREEBSD)
|
||||
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "GL" ${X11_LIBRARY} ${XRANDR_LIBRARY} "usbhid")
|
||||
elseif(FIND_SFML_OS_MACOSX)
|
||||
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "-framework OpenGL -framework Foundation -framework AppKit -framework IOKit -framework Carbon")
|
||||
endif()
|
||||
set(SFML_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} ${SFML_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
# sfml-graphics
|
||||
list(FIND SFML_FIND_COMPONENTS "graphics" FIND_SFML_GRAPHICS_COMPONENT)
|
||||
if(NOT ${FIND_SFML_GRAPHICS_COMPONENT} EQUAL -1)
|
||||
|
||||
# find libraries
|
||||
find_sfml_dependency(FREETYPE_LIBRARY "FreeType" freetype)
|
||||
|
||||
# update the list
|
||||
set(SFML_GRAPHICS_DEPENDENCIES ${FREETYPE_LIBRARY})
|
||||
set(SFML_DEPENDENCIES ${SFML_GRAPHICS_DEPENDENCIES} ${SFML_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
# sfml-audio
|
||||
list(FIND SFML_FIND_COMPONENTS "audio" FIND_SFML_AUDIO_COMPONENT)
|
||||
if(NOT ${FIND_SFML_AUDIO_COMPONENT} EQUAL -1)
|
||||
|
||||
# find libraries
|
||||
find_sfml_dependency(OPENAL_LIBRARY "OpenAL" openal openal32)
|
||||
find_sfml_dependency(OGG_LIBRARY "Ogg" ogg)
|
||||
find_sfml_dependency(VORBIS_LIBRARY "Vorbis" vorbis)
|
||||
find_sfml_dependency(VORBISFILE_LIBRARY "VorbisFile" vorbisfile)
|
||||
find_sfml_dependency(VORBISENC_LIBRARY "VorbisEnc" vorbisenc)
|
||||
find_sfml_dependency(FLAC_LIBRARY "FLAC" FLAC)
|
||||
|
||||
# update the list
|
||||
set(SFML_AUDIO_DEPENDENCIES ${OPENAL_LIBRARY} ${FLAC_LIBRARY} ${VORBISENC_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY})
|
||||
set(SFML_DEPENDENCIES ${SFML_DEPENDENCIES} ${SFML_AUDIO_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# handle errors
|
||||
if(NOT SFML_VERSION_OK)
|
||||
# SFML version not ok
|
||||
set(FIND_SFML_ERROR "SFML found but version too low (requested: ${SFML_FIND_VERSION}, found: ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH})")
|
||||
set(SFML_FOUND FALSE)
|
||||
elseif(SFML_STATIC_LIBRARIES AND FIND_SFML_DEPENDENCIES_NOTFOUND)
|
||||
set(FIND_SFML_ERROR "SFML found but some of its dependencies are missing (${FIND_SFML_DEPENDENCIES_NOTFOUND})")
|
||||
set(SFML_FOUND FALSE)
|
||||
elseif(NOT SFML_FOUND)
|
||||
# include directory or library not found
|
||||
set(FIND_SFML_ERROR "Could NOT find SFML (missing: ${FIND_SFML_MISSING})")
|
||||
endif()
|
||||
if (NOT SFML_FOUND)
|
||||
if(SFML_FIND_REQUIRED)
|
||||
# fatal error
|
||||
message(FATAL_ERROR ${FIND_SFML_ERROR})
|
||||
elseif(NOT SFML_FIND_QUIETLY)
|
||||
# error but continue
|
||||
message("${FIND_SFML_ERROR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# handle success
|
||||
if(SFML_FOUND AND NOT SFML_FIND_QUIETLY)
|
||||
message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH} in ${SFML_INCLUDE_DIR}")
|
||||
endif()
|
|
@ -50,3 +50,4 @@ ELSE (UDEV_FOUND)
|
|||
ENDIF (UDev_FIND_REQUIRED)
|
||||
ENDIF (UDEV_FOUND)
|
||||
|
||||
mark_as_advanced(UDEV_INCLUDE_DIR UDEV_LIBRARIES)
|
||||
|
|
|
@ -12,13 +12,18 @@ find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
|
|||
|
||||
find_library(OGG_LIBRARY NAMES ogg)
|
||||
find_library(VORBIS_LIBRARY NAMES vorbis)
|
||||
find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
|
||||
find_library(VORBISENC_LIBRARY NAMES vorbisenc)
|
||||
if (NOT SFML_OS_IOS)
|
||||
find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
|
||||
find_library(VORBISENC_LIBRARY NAMES vorbisenc)
|
||||
set(VORBIS_LIBRARIES ${VORBISENC_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY})
|
||||
else()
|
||||
set(VORBIS_LIBRARIES ${VORBIS_LIBRARY} ${OGG_LIBRARY})
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(VORBIS DEFAULT_MSG VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY OGG_LIBRARY VORBIS_INCLUDE_DIR OGG_INCLUDE_DIR)
|
||||
|
||||
find_package_handle_standard_args(VORBIS DEFAULT_MSG VORBIS_LIBRARIES VORBIS_INCLUDE_DIR OGG_INCLUDE_DIR)
|
||||
|
||||
set(VORBIS_INCLUDE_DIRS ${OGG_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR})
|
||||
set(VORBIS_LIBRARIES ${VORBISENC_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY})
|
||||
|
||||
mark_as_advanced(OGG_INCLUDE_DIR VORBIS_INCLUDE_DIR OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY)
|
148
cmake/SFMLConfig.cmake.in
Normal file
|
@ -0,0 +1,148 @@
|
|||
# This script provides the SFML libraries as imported targets
|
||||
# ------------------------------------
|
||||
#
|
||||
# Usage
|
||||
# -----
|
||||
#
|
||||
# When you try to locate the SFML libraries, you must specify which modules you want to use (system, window, graphics, network, audio, main).
|
||||
# If none is given, no imported target will be created and you won't be able to link to SFML libraries.
|
||||
# example:
|
||||
# find_package(SFML COMPONENTS graphics window system) # find the graphics, window and system modules
|
||||
#
|
||||
# You can enforce a specific version, either MAJOR.MINOR or only MAJOR.
|
||||
# If nothing is specified, the version won't be checked (i.e. any version will be accepted).
|
||||
# example:
|
||||
# find_package(SFML COMPONENTS ...) # no specific version required
|
||||
# find_package(SFML 2 COMPONENTS ...) # any 2.x version
|
||||
# find_package(SFML 2.4 COMPONENTS ...) # version 2.4 or greater
|
||||
#
|
||||
# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
|
||||
# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
|
||||
# You don't need to deal with SFML's dependencies when linking your targets against SFML libraries,
|
||||
# they will all be configured automatically, even if you use SFML static libraries.
|
||||
# example:
|
||||
# set(SFML_STATIC_LIBRARIES TRUE)
|
||||
# find_package(SFML 2 COMPONENTS network system)
|
||||
#
|
||||
# On macOS by default CMake will search for frameworks. If you want to use static libraries and have installed
|
||||
# both SFML frameworks and SFML static libraries, your must set CMAKE_FIND_FRAMEWORK to "NEVER" or "LAST"
|
||||
# in addition to setting SFML_STATIC_LIBRARIES to TRUE. Otherwise CMake will check the frameworks bundle config and
|
||||
# fail after finding out that it does not provide static libraries. Please refer to CMake documentation for more details.
|
||||
#
|
||||
# Additionally, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which
|
||||
# are available for both release and debug modes.
|
||||
#
|
||||
# If SFML is not installed in a standard path, you can use the SFML_DIR CMake variable
|
||||
# to tell CMake where SFML's config file is located (PREFIX/lib/cmake/SFML for a library-based installation,
|
||||
# and PREFIX/SFML.framework/Resources/CMake on macOS for a framework-based installation).
|
||||
#
|
||||
# Output
|
||||
# ------
|
||||
#
|
||||
# This script defines the following variables:
|
||||
# - For each specified module XXX (system, window, graphics, network, audio, main):
|
||||
# - SFML_XXX_FOUND: true if either the debug or release library of the xxx module is found
|
||||
# - SFML_FOUND: true if all the required modules are found
|
||||
#
|
||||
# And the following targets:
|
||||
# - For each specified module XXX (system, window, graphics, network, audio, main):
|
||||
# - sfml-XXX
|
||||
# The SFML targets are the same for both Debug and Release build configurations and will automatically provide
|
||||
# correct settings based on your currently active build configuration. The SFML targets name also do not change
|
||||
# when using dynamic or static SFML libraries.
|
||||
#
|
||||
# When linking against a SFML target, you do not need to specify indirect dependencies. For example, linking
|
||||
# against sfml-graphics will also automatically link against sfml-window and sfml-system.
|
||||
#
|
||||
# example:
|
||||
# find_package(SFML 2 COMPONENTS graphics audio REQUIRED)
|
||||
# add_executable(myapp ...)
|
||||
# target_link_libraries(myapp sfml-graphics sfml-audio)
|
||||
|
||||
if (NOT SFML_FIND_COMPONENTS)
|
||||
message(FATAL_ERROR "find_package(SFML) called with no component")
|
||||
endif()
|
||||
|
||||
set(FIND_SFML_PATHS
|
||||
"${CMAKE_CURRENT_LIST_DIR}/../.."
|
||||
${SFML_ROOT}
|
||||
$ENV{SFML_ROOT}
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local
|
||||
/usr
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt)
|
||||
|
||||
find_path(SFML_DOC_DIR SFML.tag
|
||||
PATH_SUFFIXES SFML/doc share/doc/SFML
|
||||
PATHS ${FIND_SFML_PATHS})
|
||||
|
||||
|
||||
# Update requested components (eg. request window component if graphics component was requested)
|
||||
set(FIND_SFML_SYSTEM_DEPENDENCIES "")
|
||||
set(FIND_SFML_MAIN_DEPENDENCIES "")
|
||||
set(FIND_SFML_AUDIO_DEPENDENCIES system)
|
||||
set(FIND_SFML_NETWORK_DEPENDENCIES system)
|
||||
set(FIND_SFML_WINDOW_DEPENDENCIES system)
|
||||
set(FIND_SFML_GRAPHICS_DEPENDENCIES window system)
|
||||
set(FIND_SFML_ADDITIONAL_COMPONENTS "")
|
||||
foreach(component ${SFML_FIND_COMPONENTS})
|
||||
string(TOUPPER "${component}" UPPER_COMPONENT)
|
||||
list(APPEND FIND_SFML_ADDITIONAL_COMPONENTS ${FIND_SFML_${UPPER_COMPONENT}_DEPENDENCIES})
|
||||
endforeach()
|
||||
list(APPEND SFML_FIND_COMPONENTS ${FIND_SFML_ADDITIONAL_COMPONENTS})
|
||||
list(REMOVE_DUPLICATES SFML_FIND_COMPONENTS)
|
||||
|
||||
# Choose which target definitions must be imported
|
||||
if (SFML_STATIC_LIBRARIES)
|
||||
set(SFML_IS_FRAMEWORK_INSTALL "@SFML_BUILD_FRAMEWORKS@")
|
||||
if (SFML_IS_FRAMEWORK_INSTALL)
|
||||
message(WARNING "Static frameworks are not supported by SFML. Clear SFML_DIR cache entry, \
|
||||
and either change SFML_STATIC_LIBRARIES or CMAKE_FIND_FRAMEWORK before calling find_package(SFML)")
|
||||
endif()
|
||||
set(config_name "Static")
|
||||
else()
|
||||
set(config_name "Shared")
|
||||
endif()
|
||||
set(targets_config_file "${CMAKE_CURRENT_LIST_DIR}/SFML${config_name}Targets.cmake")
|
||||
|
||||
# Generate imported targets for SFML and its dependencies
|
||||
if (EXISTS "${targets_config_file}")
|
||||
# Set SFML_FOUND to TRUE by default, may be overwritten by one of the includes below
|
||||
set(SFML_FOUND TRUE)
|
||||
include("${targets_config_file}")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/SFMLConfigDependencies.cmake")
|
||||
|
||||
if (SFML_FOUND)
|
||||
foreach (component ${SFML_FIND_COMPONENTS})
|
||||
string(TOUPPER "${component}" UPPER_COMPONENT)
|
||||
if (TARGET sfml-${component})
|
||||
set(SFML_${UPPER_COMPONENT}_FOUND TRUE)
|
||||
else()
|
||||
set(FIND_SFML_ERROR "Found SFML but requested component '${component}' is missing in the config defined in ${SFML_DIR}.")
|
||||
set(SFML_${UPPER_COMPONENT}_FOUND FALSE)
|
||||
set(SFML_FOUND FALSE)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
else()
|
||||
set(FIND_SFML_ERROR "Requested SFML configuration (${config_name}) was not found")
|
||||
set(SFML_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
if (NOT SFML_FOUND)
|
||||
if(SFML_FIND_REQUIRED)
|
||||
# fatal error
|
||||
message(FATAL_ERROR "${FIND_SFML_ERROR}")
|
||||
elseif(NOT SFML_FIND_QUIETLY)
|
||||
# error but continue
|
||||
message(STATUS "${FIND_SFML_ERROR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (SFML_FOUND AND NOT SFML_FIND_QUIETLY)
|
||||
message(STATUS "Found SFML @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@ in ${CMAKE_CURRENT_LIST_DIR}")
|
||||
endif()
|
87
cmake/SFMLConfigDependencies.cmake.in
Normal file
|
@ -0,0 +1,87 @@
|
|||
|
||||
if (CMAKE_VERSION VERSION_LESS 3.5.2)
|
||||
include(CMakeParseArguments)
|
||||
endif()
|
||||
|
||||
# in case of static linking, we must also define the list of all the dependencies of SFML libraries
|
||||
if(SFML_STATIC_LIBRARIES)
|
||||
# detect the OS
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
set(FIND_SFML_OS_WINDOWS 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(FIND_SFML_OS_LINUX 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
set(FIND_SFML_OS_FREEBSD 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
if (DEFINED IOS)
|
||||
set(FIND_SFML_OS_IOS 1)
|
||||
else()
|
||||
set(FIND_SFML_OS_MACOSX 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# start with an empty list
|
||||
set(FIND_SFML_DEPENDENCIES_NOTFOUND)
|
||||
|
||||
# macro that searches for a 3rd-party library
|
||||
function(sfml_bind_dependency)
|
||||
cmake_parse_arguments(THIS "" "TARGET;FRIENDLY_NAME" "SEARCH_NAMES" ${ARGN})
|
||||
if (THIS_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "Unknown arguments when calling sfml_bind_dependency: ${THIS_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
|
||||
# No lookup in environment variables (PATH on Windows), as they may contain wrong library versions
|
||||
find_library(${THIS_FRIENDLY_NAME}_LIB NAMES ${THIS_SEARCH_NAMES}
|
||||
PATHS ${FIND_SFML_PATHS} PATH_SUFFIXES lib NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
mark_as_advanced(${THIS_FRIENDLY_NAME}_LIB)
|
||||
if(${THIS_FRIENDLY_NAME}_LIB)
|
||||
set_property(TARGET ${THIS_TARGET} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${${THIS_FRIENDLY_NAME}_LIB}")
|
||||
else()
|
||||
set(FIND_SFML_DEPENDENCIES_NOTFOUND "${FIND_SFML_DEPENDENCIES_NOTFOUND} ${THIS_FRIENDLY_NAME}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# sfml-window
|
||||
list(FIND SFML_FIND_COMPONENTS "window" FIND_SFML_WINDOW_COMPONENT_INDEX)
|
||||
if(FIND_SFML_WINDOW_COMPONENT_INDEX GREATER -1)
|
||||
if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD)
|
||||
sfml_bind_dependency(TARGET X11 FRIENDLY_NAME "X11" SEARCH_NAMES "X11")
|
||||
sfml_bind_dependency(TARGET X11 FRIENDLY_NAME "Xrandr" SEARCH_NAMES "Xrandr")
|
||||
sfml_bind_dependency(TARGET X11 FRIENDLY_NAME "Xcursor" SEARCH_NAMES "Xcursor")
|
||||
endif()
|
||||
|
||||
if(FIND_SFML_OS_LINUX)
|
||||
sfml_bind_dependency(TARGET UDev FRIENDLY_NAME "UDev" SEARCH_NAMES "udev" "libudev")
|
||||
endif()
|
||||
|
||||
if (FIND_SFML_OS_WINDOWS)
|
||||
set_property(TARGET OpenGL APPEND PROPERTY INTERFACE_LINK_LIBRARIES "OpenGL32")
|
||||
elseif(NOT FIND_SFML_OS_IOS)
|
||||
sfml_bind_dependency(TARGET OpenGL FRIENDLY_NAME "OpenGL" SEARCH_NAMES "OpenGL" "GL")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# sfml-graphics
|
||||
list(FIND SFML_FIND_COMPONENTS "graphics" FIND_SFML_GRAPHICS_COMPONENT_INDEX)
|
||||
if(FIND_SFML_GRAPHICS_COMPONENT_INDEX GREATER -1)
|
||||
sfml_bind_dependency(TARGET Freetype FRIENDLY_NAME "FreeType" SEARCH_NAMES "freetype")
|
||||
endif()
|
||||
|
||||
# sfml-audio
|
||||
list(FIND SFML_FIND_COMPONENTS "audio" FIND_SFML_AUDIO_COMPONENT_INDEX)
|
||||
if(FIND_SFML_AUDIO_COMPONENT_INDEX GREATER -1)
|
||||
sfml_bind_dependency(TARGET OpenAL FRIENDLY_NAME "OpenAL" SEARCH_NAMES "OpenAL" "openal" "openal32")
|
||||
if (NOT FIND_SFML_OS_IOS)
|
||||
sfml_bind_dependency(TARGET VORBIS FRIENDLY_NAME "VorbisFile" SEARCH_NAMES "vorbisfile")
|
||||
sfml_bind_dependency(TARGET VORBIS FRIENDLY_NAME "VorbisEnc" SEARCH_NAMES "vorbisenc")
|
||||
endif()
|
||||
sfml_bind_dependency(TARGET VORBIS FRIENDLY_NAME "Vorbis" SEARCH_NAMES "vorbis")
|
||||
sfml_bind_dependency(TARGET VORBIS FRIENDLY_NAME "Ogg" SEARCH_NAMES "ogg")
|
||||
sfml_bind_dependency(TARGET FLAC FRIENDLY_NAME "FLAC" SEARCH_NAMES "FLAC")
|
||||
endif()
|
||||
|
||||
if (FIND_SFML_DEPENDENCIES_NOTFOUND)
|
||||
set(FIND_SFML_ERROR "SFML found but some of its dependencies are missing (${FIND_SFML_DEPENDENCIES_NOTFOUND})")
|
||||
set(SFML_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
188
cmake/toolchains/iOS.toolchain.cmake
Normal file
|
@ -0,0 +1,188 @@
|
|||
# Copyright (c) 2016, Bogdan Cristea <cristeab@gmail.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# This file is based off of the Platform/Darwin.cmake and Platform/UnixPaths.cmake
|
||||
# files which are included with CMake 2.8.4
|
||||
# It has been altered for iOS development
|
||||
|
||||
# Options:
|
||||
#
|
||||
# IOS_PLATFORM = OS (default) or SIMULATOR
|
||||
# This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders
|
||||
# OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch.
|
||||
# SIMULATOR - used to build for the Simulator platforms, which have an x86_64 arch.
|
||||
#
|
||||
# IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder
|
||||
# By default this location is automatcially chosen based on the IOS_PLATFORM value above.
|
||||
# If set manually, it will override the default location and force the user of a particular Developer Platform
|
||||
#
|
||||
# IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder
|
||||
# By default this location is automatcially chosen based on the IOS_DEVELOPER_ROOT value.
|
||||
# In this case it will always be the most up-to-date SDK found in the IOS_DEVELOPER_ROOT path.
|
||||
# If set manually, this will force the use of a specific SDK version
|
||||
|
||||
# Macros:
|
||||
#
|
||||
# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE)
|
||||
# A convenience macro for setting xcode specific properties on targets
|
||||
# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1")
|
||||
#
|
||||
# find_host_package (PROGRAM ARGS)
|
||||
# A macro used to find executable programs on the host system, not within the iOS environment.
|
||||
# Thanks to the android-cmake project for providing the command
|
||||
|
||||
# Standard settings
|
||||
set (CMAKE_SYSTEM_NAME Darwin)
|
||||
set (CMAKE_SYSTEM_VERSION 1)
|
||||
set (UNIX True)
|
||||
set (APPLE True)
|
||||
set (IOS True)
|
||||
|
||||
# Required as of cmake 2.8.10
|
||||
set (CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)
|
||||
|
||||
# Determine the cmake host system version so we know where to find the iOS SDKs
|
||||
find_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin)
|
||||
if (CMAKE_UNAME)
|
||||
exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION)
|
||||
string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
|
||||
endif (CMAKE_UNAME)
|
||||
|
||||
set(CMAKE_C_COMPILER /usr/bin/clang CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_CXX_COMPILER /usr/bin/clang++ CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_AR ar CACHE FILEPATH "" FORCE)
|
||||
|
||||
# Skip the platform compiler checks for cross compiling
|
||||
set (CMAKE_CXX_COMPILER_WORKS TRUE)
|
||||
set (CMAKE_C_COMPILER_WORKS TRUE)
|
||||
|
||||
# All iOS/Darwin specific settings - some may be redundant
|
||||
set (CMAKE_SHARED_LIBRARY_PREFIX "lib")
|
||||
set (CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
|
||||
set (CMAKE_SHARED_MODULE_PREFIX "lib")
|
||||
set (CMAKE_SHARED_MODULE_SUFFIX ".so")
|
||||
set (CMAKE_MODULE_EXISTS 1)
|
||||
set (CMAKE_DL_LIBS "")
|
||||
|
||||
set (CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
|
||||
set (CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
|
||||
set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
|
||||
set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
|
||||
|
||||
# Hidden visibilty is required for cxx on iOS
|
||||
set (CMAKE_C_FLAGS_INIT "")
|
||||
set (CMAKE_CXX_FLAGS_INIT "-fvisibility=hidden -fvisibility-inlines-hidden")
|
||||
|
||||
set (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
|
||||
set (CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
|
||||
|
||||
set (CMAKE_PLATFORM_HAS_INSTALLNAME 1)
|
||||
set (CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names")
|
||||
set (CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names")
|
||||
set (CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
|
||||
set (CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
|
||||
set (CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
|
||||
|
||||
# hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree
|
||||
# (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache
|
||||
# and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun)
|
||||
# hardcode CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did before, Alex
|
||||
if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
||||
find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
|
||||
endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
||||
|
||||
# Setup iOS platform unless specified manually with IOS_PLATFORM
|
||||
if (NOT DEFINED IOS_PLATFORM)
|
||||
set (IOS_PLATFORM "OS")
|
||||
endif (NOT DEFINED IOS_PLATFORM)
|
||||
set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform: OS or SIMULATOR")
|
||||
|
||||
# Check the platform selection and setup for developer root
|
||||
if (IOS_PLATFORM STREQUAL OS)
|
||||
set (IOS_PLATFORM_LOCATION "iPhoneOS.platform")
|
||||
|
||||
# This causes the installers to properly locate the output libraries
|
||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos")
|
||||
elseif (IOS_PLATFORM STREQUAL SIMULATOR)
|
||||
set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
|
||||
|
||||
# This causes the installers to properly locate the output libraries
|
||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
|
||||
else ()
|
||||
message (FATAL_ERROR "Unsupported IOS_PLATFORM value '${IOS_PLATFORM}' selected. Please choose OS or SIMULATOR")
|
||||
endif ()
|
||||
|
||||
# Setup iOS developer location unless specified manually with IOS_DEVELOPER_ROOT
|
||||
exec_program(/usr/bin/xcode-select ARGS -print-path OUTPUT_VARIABLE XCODE_DEVELOPER_DIR)
|
||||
set (IOS_DEVELOPER_ROOT "${XCODE_DEVELOPER_DIR}/Platforms/${IOS_PLATFORM_LOCATION}/Developer" CACHE PATH "Location of iOS Platform")
|
||||
|
||||
# Find and use the most recent iOS sdk unless specified manually with IOS_SDK_ROOT
|
||||
if (NOT DEFINED IOS_SDK_ROOT)
|
||||
file (GLOB _IOS_SDKS "${IOS_DEVELOPER_ROOT}/SDKs/*")
|
||||
if (_IOS_SDKS)
|
||||
list (SORT _IOS_SDKS)
|
||||
list (REVERSE _IOS_SDKS)
|
||||
list (GET _IOS_SDKS 0 IOS_SDK_ROOT)
|
||||
else (_IOS_SDKS)
|
||||
message (FATAL_ERROR "No iOS SDK's found in default search path ${IOS_DEVELOPER_ROOT}. Manually set IOS_SDK_ROOT or install the iOS SDK.")
|
||||
endif (_IOS_SDKS)
|
||||
message (STATUS "Toolchain using default iOS SDK: ${IOS_SDK_ROOT}")
|
||||
endif (NOT DEFINED IOS_SDK_ROOT)
|
||||
set (IOS_SDK_ROOT ${IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK")
|
||||
|
||||
# Set the sysroot default to the most recent SDK
|
||||
set (CMAKE_OSX_SYSROOT ${IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
|
||||
|
||||
# set the architecture for iOS
|
||||
if (${IOS_PLATFORM} STREQUAL OS)
|
||||
set (OSX_UNIVERSAL true)
|
||||
set (IOS_ARCH arm64)
|
||||
elseif (${IOS_PLATFORM} STREQUAL SIMULATOR)
|
||||
set (IOS_ARCH x86_64)
|
||||
endif (${IOS_PLATFORM} STREQUAL OS)
|
||||
|
||||
set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS" FORCE)
|
||||
|
||||
# Set the find root to the iOS developer roots and to user defined paths
|
||||
set (CMAKE_FIND_ROOT_PATH ${IOS_DEVELOPER_ROOT} ${IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE STRING "iOS find search path root")
|
||||
|
||||
# default to searching for frameworks first
|
||||
set (CMAKE_FIND_FRAMEWORK FIRST)
|
||||
|
||||
# set up the default search directories for frameworks
|
||||
set (CMAKE_SYSTEM_FRAMEWORK_PATH
|
||||
${IOS_SDK_ROOT}/System/Library/Frameworks
|
||||
${IOS_SDK_ROOT}/System/Library/PrivateFrameworks
|
||||
${IOS_SDK_ROOT}/Developer/Library/Frameworks
|
||||
)
|
||||
|
||||
# only search the iOS sdks, not the remainder of the host filesystem
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
|
||||
# This macro lets you find executable programs on the host system
|
||||
macro (find_host_package)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
|
||||
set (IOS FALSE)
|
||||
|
||||
find_package(${ARGN})
|
||||
|
||||
set (IOS TRUE)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
endmacro (find_host_package)
|
|
@ -52,11 +52,14 @@ add_custom_target(doc ALL
|
|||
WORKING_DIRECTORY ${DOXYGEN_INPUT_DIR})
|
||||
|
||||
# setup install rules
|
||||
install(FILES ${DOXYGEN_OUTPUT_DIR}/SFML.tag
|
||||
DESTINATION ${CMAKE_INSTALL_DOCDIR}
|
||||
COMPONENT doc)
|
||||
install(DIRECTORY ${DOXYGEN_OUTPUT_DIR}/html
|
||||
DESTINATION ${INSTALL_MISC_DIR}/doc
|
||||
DESTINATION ${CMAKE_INSTALL_DOCDIR}
|
||||
COMPONENT doc)
|
||||
if(DOXYGEN_HHC_PROGRAM)
|
||||
install(FILES ${DOXYGEN_OUTPUT_DIR}/sfml.chm
|
||||
DESTINATION ${INSTALL_MISC_DIR}/doc
|
||||
DESTINATION ${CMAKE_INSTALL_DOCDIR}
|
||||
COMPONENT doc)
|
||||
endif()
|
||||
|
|
455
doc/doxyfile.in
|
@ -415,6 +415,10 @@ table.memberdecls {
|
|||
margin-left: 9px;
|
||||
}
|
||||
|
||||
.memtitle {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.memnav {
|
||||
background-color: #EBEFF6;
|
||||
border: 1px solid #A3B4D7;
|
||||
|
@ -1440,4 +1444,7 @@ div.contents ul li {
|
|||
border-width: 11px;
|
||||
top: 50%;
|
||||
margin-top: -11px;
|
||||
}
|
||||
}
|
||||
.arrow {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
</div>
|
||||
<div id="footer-container">
|
||||
<div id="footer">
|
||||
SFML is licensed under the terms and conditions of the <a href="http://www.sfml-dev.org/license.php">zlib/png license</a>.<br>
|
||||
SFML is licensed under the terms and conditions of the <a href="https://www.sfml-dev.org/license.php">zlib/png license</a>.<br>
|
||||
Copyright © Laurent Gomila ::
|
||||
Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen</a> ::
|
||||
</div>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<title>SFML - Simple and Fast Multimedia Library</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;"/>
|
||||
<meta charset="utf-8"/>
|
||||
<!--<link rel='stylesheet' type='text/css' href="http://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic"/>-->
|
||||
<!--<link rel='stylesheet' type='text/css' href="https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic"/>-->
|
||||
<link rel="stylesheet" type="text/css" href="doxygen.css" title="default" media="screen,print" />
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
///
|
||||
/// \section welcome Welcome
|
||||
/// Welcome to the official SFML documentation. Here you will find a detailed
|
||||
/// view of all the SFML <a href="./annotated.php">classes</a> and functions. <br/>
|
||||
/// view of all the SFML classes and functions. <br/>
|
||||
/// If you are looking for tutorials, you can visit the official website
|
||||
/// at <a href="http://www.sfml-dev.org/">www.sfml-dev.org</a>.
|
||||
/// at <a href="https://www.sfml-dev.org/">www.sfml-dev.org</a>.
|
||||
///
|
||||
/// \section example Short example
|
||||
/// Here is a short example, to show you how simple it is to use SFML:
|
||||
|
|
|
@ -1,22 +1,33 @@
|
|||
# CLI based examples
|
||||
if (NOT SFML_OS_IOS)
|
||||
if(SFML_BUILD_NETWORK)
|
||||
add_subdirectory(ftp)
|
||||
add_subdirectory(sockets)
|
||||
endif()
|
||||
if(SFML_BUILD_NETWORK AND SFML_BUILD_AUDIO)
|
||||
add_subdirectory(voip)
|
||||
endif()
|
||||
if(SFML_BUILD_AUDIO)
|
||||
add_subdirectory(sound)
|
||||
add_subdirectory(sound_capture)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# add the examples subdirectories
|
||||
if(SFML_BUILD_NETWORK)
|
||||
add_subdirectory(ftp)
|
||||
add_subdirectory(sockets)
|
||||
endif()
|
||||
if(SFML_BUILD_NETWORK AND SFML_BUILD_AUDIO)
|
||||
add_subdirectory(voip)
|
||||
endif()
|
||||
if(SFML_BUILD_AUDIO)
|
||||
add_subdirectory(sound)
|
||||
add_subdirectory(sound_capture)
|
||||
endif()
|
||||
# GUI based examples
|
||||
if(SFML_BUILD_WINDOW)
|
||||
add_subdirectory(window)
|
||||
endif()
|
||||
|
||||
if(SFML_BUILD_GRAPHICS)
|
||||
add_subdirectory(opengl)
|
||||
add_subdirectory(shader)
|
||||
|
||||
if (NOT SFML_OS_IOS)
|
||||
add_subdirectory(joystick)
|
||||
add_subdirectory(shader)
|
||||
add_subdirectory(island)
|
||||
add_subdirectory(vulkan)
|
||||
endif()
|
||||
|
||||
if(SFML_OS_WINDOWS)
|
||||
add_subdirectory(win32)
|
||||
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD)
|
||||
|
|
|
@ -4,13 +4,7 @@ set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/X11)
|
|||
# all source files
|
||||
set(SRC ${SRCROOT}/X11.cpp)
|
||||
|
||||
# find OpenGL and X11
|
||||
find_package(OpenGL REQUIRED)
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
find_package(X11 REQUIRED)
|
||||
include_directories(${X11_INCLUDE_DIR})
|
||||
|
||||
# define the X11 target
|
||||
sfml_add_example(X11 GUI_APP
|
||||
sfml_add_example(X11Example GUI_APP
|
||||
SOURCES ${SRC}
|
||||
DEPENDS sfml-window sfml-system ${OPENGL_LIBRARIES} ${X11_LIBRARIES})
|
||||
DEPENDS sfml-window X11)
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
#include <SFML/OpenGL.hpp>
|
||||
|
||||
#define GLAD_GL_IMPLEMENTATION
|
||||
#include "gl.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
@ -23,7 +26,13 @@ void initialize(sf::Window& window)
|
|||
|
||||
// Setup OpenGL states
|
||||
// Set color and depth clear value
|
||||
|
||||
#ifdef SFML_OPENGL_ES
|
||||
glClearDepthf(1.f);
|
||||
#else
|
||||
glClearDepth(1.f);
|
||||
#endif
|
||||
|
||||
glClearColor(0.f, 0.5f, 0.5f, 0.f);
|
||||
|
||||
// Enable Z-buffer read and write
|
||||
|
@ -33,9 +42,14 @@ void initialize(sf::Window& window)
|
|||
// Setup a perspective projection
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
static const double pi = 3.141592654;
|
||||
GLdouble extent = std::tan(90.0 * pi / 360.0);
|
||||
glFrustum(-extent, extent, -extent, extent, 1.0, 500.0);
|
||||
static const float pi = 3.141592654f;
|
||||
float extent = std::tan(90.0f * pi / 360.0f);
|
||||
|
||||
#ifdef SFML_OPENGL_ES
|
||||
glFrustumf(-extent, extent, -extent, extent, 1.0f, 500.0f);
|
||||
#else
|
||||
glFrustum(-extent, extent, -extent, extent, 1.0f, 500.0f);
|
||||
#endif
|
||||
|
||||
// Enable position and texture coordinates vertex components
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
@ -177,6 +191,15 @@ int main()
|
|||
// Create a clock for measuring elapsed time
|
||||
sf::Clock clock;
|
||||
|
||||
// Load OpenGL or OpenGL ES entry points using glad
|
||||
sfmlView1.setActive();
|
||||
|
||||
#ifdef SFML_OPENGL_ES
|
||||
gladLoadGLES1(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||
#else
|
||||
gladLoadGL(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||
#endif
|
||||
|
||||
// Initialize our views
|
||||
initialize(sfmlView1);
|
||||
initialize(sfmlView2);
|
||||
|
@ -210,6 +233,13 @@ int main()
|
|||
sfmlView2.display();
|
||||
}
|
||||
|
||||
// Close our SFML views before destroying the underlying window
|
||||
sfmlView1.close();
|
||||
sfmlView2.close();
|
||||
|
||||
// Destroy the window
|
||||
XDestroyWindow(display, window);
|
||||
|
||||
// Close the display
|
||||
XCloseDisplay(display);
|
||||
|
||||
|
|
7837
examples/X11/gl.h
Normal file
8
examples/android/.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
local.properties
|
||||
.idea
|
||||
.gradle
|
||||
build
|
||||
android.iml
|
||||
app/build
|
||||
app/.externalNativeBuild
|
||||
app/src/main/obj
|
123
examples/android/app/app.iml
Normal file
|
@ -0,0 +1,123 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="android-gradle" name="Android-Gradle">
|
||||
<configuration>
|
||||
<option name="GRADLE_PROJECT_PATH" value=":app" />
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="native-android-gradle" name="Native-Android-Gradle">
|
||||
<configuration>
|
||||
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="android" name="Android">
|
||||
<configuration>
|
||||
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
||||
<afterSyncTasks>
|
||||
<task>generateDebugSources</task>
|
||||
</afterSyncTasks>
|
||||
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
||||
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
|
||||
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
|
||||
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
|
||||
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
|
||||
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes-jar" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndkBuild" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
39
examples/android/app/build.gradle
Normal file
|
@ -0,0 +1,39 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 27
|
||||
defaultConfig {
|
||||
applicationId "org.sfmldev.android"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 19
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
// cppFlags "-std=c++14 -frtti -fexceptions"
|
||||
}
|
||||
|
||||
}
|
||||
ndk {
|
||||
abiFilters 'armeabi-v7a'
|
||||
}
|
||||
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
path "src/main/jni/Android.mk"
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
21
examples/android/app/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
|
@ -1,17 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.sfml"
|
||||
package="org.sfmldev.android"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-feature android:glEsVersion="0x00010001" />
|
||||
|
||||
<uses-sdk android:minSdkVersion="9"
|
||||
<uses-sdk android:minSdkVersion="14"
|
||||
android:targetSdkVersion="19" />
|
||||
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
|
||||
<application android:label="@string/app_name"
|
||||
android:icon="@drawable/sfml_logo"
|
||||
android:hasCode="false"
|
||||
|
@ -22,7 +22,7 @@
|
|||
android:icon="@drawable/sfml_logo"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize">
|
||||
|
||||
<meta-data android:name="android.app.lib_name" android:value="sfml-activity" />
|
||||
<meta-data android:name="android.app.lib_name" android:value="sfml-activity-d" />
|
||||
<meta-data android:name="sfml.app.lib_name" android:value="sfml-example" />
|
||||
|
||||
<intent-filter>
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 8.6 KiB |
20
examples/android/app/src/main/jni/Android.mk
Normal file
|
@ -0,0 +1,20 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := sfml-example
|
||||
|
||||
LOCAL_SRC_FILES := main.cpp
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := sfml-system-d
|
||||
LOCAL_SHARED_LIBRARIES += sfml-window-d
|
||||
LOCAL_SHARED_LIBRARIES += sfml-graphics-d
|
||||
LOCAL_SHARED_LIBRARIES += sfml-audio-d
|
||||
LOCAL_SHARED_LIBRARIES += sfml-network-d
|
||||
LOCAL_SHARED_LIBRARIES += sfml-activity-d
|
||||
LOCAL_SHARED_LIBRARIES += openal
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := sfml-main-d
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
$(call import-module,third_party/sfml)
|
8
examples/android/app/src/main/jni/Application.mk
Normal file
|
@ -0,0 +1,8 @@
|
|||
NDK_TOOLCHAIN_VERSION := 4.9
|
||||
APP_PLATFORM := android-14
|
||||
# APP_STL has to match CMAKE_ANDROID_STL_TYPE
|
||||
APP_STL := c++_static
|
||||
APP_ABI := armeabi-v7a
|
||||
APP_MODULES := sfml-activity-d sfml-example
|
||||
APP_OPTIM := debug
|
||||
APP_CFLAG := -g -ggdb -O0
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
// Do we want to showcase direct JNI/NDK interaction?
|
||||
// Undefine this to get real cross-platform code.
|
||||
#define USE_JNI
|
||||
// Uncomment this to try JNI access; this seems to be broken in latest NDKs
|
||||
//#define USE_JNI
|
||||
|
||||
#if defined(USE_JNI)
|
||||
// These headers are only needed for direct NDK/JDK interaction
|
||||
|
@ -76,40 +77,79 @@ int vibrate(sf::Time duration)
|
|||
// ('vibrate()' in this example; undefine 'USE_JNI' above to disable it)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "");
|
||||
sf::VideoMode screen(sf::VideoMode::getDesktopMode());
|
||||
|
||||
sf::RenderWindow window(screen, "");
|
||||
window.setFramerateLimit(30);
|
||||
|
||||
sf::Texture texture;
|
||||
if(!texture.loadFromFile("image.png"))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
sf::Sprite image(texture);
|
||||
image.setPosition(0, 0);
|
||||
image.setPosition(screen.width / 2, screen.height / 2);
|
||||
image.setOrigin(texture.getSize().x/2, texture.getSize().y/2);
|
||||
|
||||
sf::Music music;
|
||||
sf::Font font;
|
||||
if (!font.loadFromFile("sansation.ttf"))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
sf::Text text("Tap anywhere to move the logo.", font, 64);
|
||||
text.setFillColor(sf::Color::Black);
|
||||
text.setPosition(10, 10);
|
||||
|
||||
// Loading canary.wav fails for me for now; haven't had time to test why
|
||||
|
||||
/*sf::Music music;
|
||||
if(!music.openFromFile("canary.wav"))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
music.play();
|
||||
music.play();*/
|
||||
|
||||
sf::View view = window.getDefaultView();
|
||||
|
||||
sf::Color background = sf::Color::White;
|
||||
|
||||
// We shouldn't try drawing to the screen while in background
|
||||
// so we'll have to track that. You can do minor background
|
||||
// work, but keep battery life in mind.
|
||||
bool active = true;
|
||||
|
||||
while (window.isOpen())
|
||||
{
|
||||
sf::Event event;
|
||||
|
||||
while (window.pollEvent(event))
|
||||
while (active ? window.pollEvent(event) : window.waitEvent(event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case sf::Event::Closed:
|
||||
window.close();
|
||||
break;
|
||||
case sf::Event::KeyPressed:
|
||||
if (event.key.code == sf::Keyboard::Escape)
|
||||
window.close();
|
||||
break;
|
||||
case sf::Event::Resized:
|
||||
view.setSize(event.size.width, event.size.height);
|
||||
view.setCenter(event.size.width/2, event.size.height/2);
|
||||
window.setView(view);
|
||||
break;
|
||||
case sf::Event::LostFocus:
|
||||
background = sf::Color::Black;
|
||||
break;
|
||||
case sf::Event::GainedFocus:
|
||||
background = sf::Color::White;
|
||||
break;
|
||||
|
||||
// On Android MouseLeft/MouseEntered are (for now) triggered,
|
||||
// whenever the app loses or gains focus.
|
||||
case sf::Event::MouseLeft:
|
||||
active = false;
|
||||
break;
|
||||
case sf::Event::MouseEntered:
|
||||
active = true;
|
||||
break;
|
||||
case sf::Event::TouchBegan:
|
||||
if (event.touch.finger == 0)
|
||||
{
|
||||
|
@ -122,8 +162,15 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
window.clear(sf::Color::White);
|
||||
window.draw(image);
|
||||
window.display();
|
||||
if (active)
|
||||
{
|
||||
window.clear(background);
|
||||
window.draw(image);
|
||||
window.draw(text);
|
||||
window.display();
|
||||
}
|
||||
else {
|
||||
sf::sleep(sf::milliseconds(100));
|
||||
}
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
23
examples/android/build.gradle
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.0.0'
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
17
examples/android/gradle.properties
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
|
@ -1,18 +0,0 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := sfml-example
|
||||
|
||||
LOCAL_SRC_FILES := main.cpp
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := sfml-system
|
||||
LOCAL_SHARED_LIBRARIES += sfml-window
|
||||
LOCAL_SHARED_LIBRARIES += sfml-graphics
|
||||
LOCAL_SHARED_LIBRARIES += sfml-audio
|
||||
LOCAL_SHARED_LIBRARIES += sfml-network
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := sfml-main
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
$(call import-module,sfml)
|
|
@ -1,5 +0,0 @@
|
|||
NDK_TOOLCHAIN_VERSION := 4.9
|
||||
APP_PLATFORM := android-9
|
||||
APP_STL := c++_shared
|
||||
APP_ABI := armeabi-v7a
|
||||
APP_MODULES := sfml-activity sfml-example
|
1
examples/android/settings.gradle
Normal file
|
@ -0,0 +1 @@
|
|||
include ':app'
|
38
examples/assets/LaunchScreen.storyboard
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<device id="ipad9_7" orientation="landscape">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="1024" height="768"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="logo.png" translatesAutoresizingMaskIntoConstraints="NO" id="HXY-06-8aG">
|
||||
<rect key="frame" x="0.0" y="0.0" width="1024" height="768"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</imageView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="52" y="374.66266866566718"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="logo.png" width="512" height="512"/>
|
||||
</resources>
|
||||
</document>
|
BIN
examples/assets/icon.icns
Normal file
36
examples/assets/info.plist
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>icon.icns</string>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.sfml-dev.$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleLongVersionString</key>
|
||||
<string>2.5.1</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string></string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string></string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
BIN
examples/assets/logo.png
Normal file
After Width: | Height: | Size: 30 KiB |
|
@ -1,6 +1,34 @@
|
|||
|
||||
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/cocoa)
|
||||
|
||||
# Usage: compile_xib(INPUT path/to/file.xib OUTPUT path/to/file.nib)
|
||||
function(compile_xib)
|
||||
cmake_parse_arguments(THIS "" "INPUT;OUTPUT" "" ${ARGN})
|
||||
if (NOT THIS_INPUT)
|
||||
message(FATAL_ERROR "Missing required argument INPUT in call to compile_xib()")
|
||||
endif()
|
||||
|
||||
if (NOT THIS_OUTPUT)
|
||||
message(FATAL_ERROR "Missing required argument OUTPUT in call to compile_xib()")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED IBTOOL)
|
||||
find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
|
||||
endif()
|
||||
if(NOT IBTOOL)
|
||||
message(FATAL_ERROR "ibtool is required to compile .xib files but wasn't found.")
|
||||
endif()
|
||||
|
||||
# Default args taken from Xcode 9 when it generates a nib from a xib
|
||||
set(DEFAULT_ARGS --errors --warnings --notices --module cocoa --auto-activate-custom-fonts --target-device mac --output-format human-readable-text)
|
||||
|
||||
add_custom_command(OUTPUT "${THIS_OUTPUT}"
|
||||
COMMAND "${IBTOOL}" ${DEFAULT_ARGS} "${THIS_INPUT}" --compile "${THIS_OUTPUT}"
|
||||
DEPENDS "${THIS_INPUT}"
|
||||
COMMENT "Generating ${THIS_OUTPUT}"
|
||||
VERBATIM)
|
||||
endfunction()
|
||||
|
||||
# all source files
|
||||
set(SRC ${SRCROOT}/CocoaAppDelegate.h
|
||||
${SRCROOT}/CocoaAppDelegate.mm
|
||||
|
@ -8,8 +36,7 @@ set(SRC ${SRCROOT}/CocoaAppDelegate.h
|
|||
${SRCROOT}/NSString+stdstring.mm
|
||||
${SRCROOT}/main.m)
|
||||
|
||||
# all XIB files
|
||||
set(XIBS MainMenu)
|
||||
compile_xib(INPUT "${SRCROOT}/MainMenu.xib" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/MainMenu.nib")
|
||||
|
||||
# all resource files
|
||||
set(RESOURCES ${SRCROOT}/resources/logo.png
|
||||
|
@ -18,50 +45,17 @@ set(RESOURCES ${SRCROOT}/resources/logo.png
|
|||
${SRCROOT}/resources/blue.png
|
||||
${SRCROOT}/resources/green.png
|
||||
${SRCROOT}/resources/red.png
|
||||
${SRCROOT}/resources/Credits.rtf)
|
||||
|
||||
# define the cocoa target and customize it
|
||||
add_executable(cocoa MACOSX_BUNDLE ${SRC} ${RESOURCES})
|
||||
${SRCROOT}/resources/Credits.rtf
|
||||
${CMAKE_CURRENT_BINARY_DIR}/MainMenu.nib)
|
||||
set_source_files_properties(${RESOURCES} PROPERTIES
|
||||
MACOSX_PACKAGE_LOCATION Resources)
|
||||
|
||||
# define the cocoa target and customize it
|
||||
sfml_add_example(cocoa
|
||||
SOURCES ${SRC}
|
||||
BUNDLE_RESOURCES ${RESOURCES}
|
||||
DEPENDS sfml-system sfml-window sfml-graphics)
|
||||
set_target_properties(cocoa PROPERTIES
|
||||
MACOSX_BUNDLE TRUE
|
||||
MACOSX_BUNDLE_INFO_PLIST ${SRCROOT}/resources/Cocoa-Info.plist)
|
||||
target_link_libraries(cocoa "-framework Cocoa -framework Foundation"
|
||||
sfml-system sfml-window sfml-graphics)
|
||||
|
||||
# set the target's folder (for IDEs that support it, e.g. Visual Studio)
|
||||
set_target_properties(cocoa PROPERTIES FOLDER "Examples")
|
||||
|
||||
# compile XIB files
|
||||
find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
|
||||
if(${IBTOOL} STREQUAL "IBTOOL-NOTFOUND")
|
||||
message(FATAL_ERROR "ibtool is required to compile .xib files but wasn't found.")
|
||||
endif()
|
||||
set(RESOURCE_PATH "cocoa.app/Contents/Resources")
|
||||
set(XIB_OUTPUT_PATH "${RESOURCE_PATH}/")
|
||||
set(XIB_INPUT_PATH "${SRCROOT}/")
|
||||
foreach(XIB ${XIBS})
|
||||
add_custom_command(TARGET cocoa
|
||||
POST_BUILD
|
||||
COMMAND ${IBTOOL} --errors
|
||||
--output-format human-readable-text
|
||||
--compile ${XIB_OUTPUT_PATH}/${XIB}.nib
|
||||
${XIB_INPUT_PATH}/${XIB}.xib
|
||||
COMMENT "Compiling ${XIB}.xib")
|
||||
# deactivated options: --warnings --notices
|
||||
endforeach()
|
||||
|
||||
# add install rule
|
||||
install(TARGETS cocoa
|
||||
BUNDLE DESTINATION ${INSTALL_MISC_DIR}/examples/cocoa
|
||||
COMPONENT examples)
|
||||
|
||||
#
|
||||
# define the cocoa target
|
||||
# sfml_add_example is not compatible with application bundles !
|
||||
#
|
||||
#sfml_add_example(cocoa
|
||||
# SOURCES ${SRC}
|
||||
# DEPENDS sfml-system sfml-window sfml-graphics)
|
||||
#
|
||||
|
||||
target_link_libraries(cocoa PRIVATE "-framework Cocoa" "-framework Foundation" sfml-graphics)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2017 Marco Antognini (antognini.marco@gmail.com),
|
||||
// Copyright (C) 2007-2020 Marco Antognini (antognini.marco@gmail.com),
|
||||
// Laurent Gomila (laurent@sfml-dev.org)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2017 Marco Antognini (antognini.marco@gmail.com),
|
||||
// Copyright (C) 2007-2020 Marco Antognini (antognini.marco@gmail.com),
|
||||
// Laurent Gomila (laurent@sfml-dev.org)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2017 Marco Antognini (antognini.marco@gmail.com),
|
||||
// Copyright (C) 2007-2020 Marco Antognini (antognini.marco@gmail.com),
|
||||
// Laurent Gomila (laurent@sfml-dev.org)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2017 Marco Antognini (antognini.marco@gmail.com),
|
||||
// Copyright (C) 2007-2020 Marco Antognini (antognini.marco@gmail.com),
|
||||
// Laurent Gomila (laurent@sfml-dev.org)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
|
@ -65,7 +65,7 @@
|
|||
-(std::wstring)tostdwstring
|
||||
{
|
||||
// According to Wikipedia, Mac OS X is Little Endian on x86 and x86-64
|
||||
// http://en.wikipedia.org/wiki/Endianness
|
||||
// https://en.wikipedia.org/wiki/Endianness
|
||||
NSData* asData = [self dataUsingEncoding:NSUTF32LittleEndianStringEncoding];
|
||||
return std::wstring((wchar_t*)[asData bytes], [asData length] / sizeof(wchar_t));
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2017 Marco Antognini (antognini.marco@gmail.com),
|
||||
// Copyright (C) 2007-2020 Marco Antognini (antognini.marco@gmail.com),
|
||||
// Laurent Gomila (laurent@sfml-dev.org)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.6</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2007-2017 Marco Antognini and Laurent Gomila. Shared under zlib/libpng License.</string>
|
||||
<string>Copyright © 2007-2020 Marco Antognini and Laurent Gomila. Shared under zlib/libpng License.</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
\paperw11900\paperh16840\vieww9600\viewh8400\viewkind0
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qj
|
||||
|
||||
\f0\fs24 \cf0 See {\field{\*\fldinst{HYPERLINK "http://sfml-dev.org"}}{\fldrslt http://sfml-dev.org}} for more information}
|
||||
\f0\fs24 \cf0 See {\field{\*\fldinst{HYPERLINK "https://sfml-dev.org"}}{\fldrslt https://sfml-dev.org}} for more information}
|
||||
|
|
|
@ -7,4 +7,4 @@ set(SRC ${SRCROOT}/Ftp.cpp)
|
|||
# define the ftp target
|
||||
sfml_add_example(ftp
|
||||
SOURCES ${SRC}
|
||||
DEPENDS sfml-network sfml-system)
|
||||
DEPENDS sfml-network)
|
||||
|
|
11
examples/island/CMakeLists.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/island)
|
||||
|
||||
# all source files
|
||||
set(SRC ${SRCROOT}/Island.cpp)
|
||||
|
||||
# define the island target
|
||||
sfml_add_example(island GUI_APP
|
||||
SOURCES ${SRC}
|
||||
DEPENDS sfml-graphics
|
||||
RESOURCES_DIR resources)
|
590
examples/island/Island.cpp
Normal file
|
@ -0,0 +1,590 @@
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#define STB_PERLIN_IMPLEMENTATION
|
||||
#include "stb_perlin.h"
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
// Width and height of the application window
|
||||
const unsigned int windowWidth = 800;
|
||||
const unsigned int windowHeight = 600;
|
||||
|
||||
// Resolution of the generated terrain
|
||||
const unsigned int resolutionX = 800;
|
||||
const unsigned int resolutionY = 600;
|
||||
|
||||
// Thread pool parameters
|
||||
const unsigned int threadCount = 4;
|
||||
const unsigned int blockCount = 32;
|
||||
|
||||
struct WorkItem
|
||||
{
|
||||
sf::Vertex* targetBuffer;
|
||||
unsigned int index;
|
||||
};
|
||||
|
||||
std::deque<WorkItem> workQueue;
|
||||
std::vector<sf::Thread*> threads;
|
||||
int pendingWorkCount = 0;
|
||||
bool workPending = true;
|
||||
bool bufferUploadPending = false;
|
||||
sf::Mutex workQueueMutex;
|
||||
|
||||
struct Setting
|
||||
{
|
||||
const char* name;
|
||||
float* value;
|
||||
};
|
||||
|
||||
// Terrain noise parameters
|
||||
const int perlinOctaves = 3;
|
||||
|
||||
float perlinFrequency = 7.0f;
|
||||
float perlinFrequencyBase = 4.0f;
|
||||
|
||||
// Terrain generation parameters
|
||||
float heightBase = 0.0f;
|
||||
float edgeFactor = 0.9f;
|
||||
float edgeDropoffExponent = 1.5f;
|
||||
|
||||
float snowcapHeight = 0.6f;
|
||||
|
||||
// Terrain lighting parameters
|
||||
float heightFactor = windowHeight / 2.0f;
|
||||
float heightFlatten = 3.0f;
|
||||
float lightFactor = 0.7f;
|
||||
}
|
||||
|
||||
|
||||
// Forward declarations of the functions we define further down
|
||||
void threadFunction();
|
||||
void generateTerrain(sf::Vertex* vertexBuffer);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Entry point of application
|
||||
///
|
||||
/// \return Application exit code
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
int main()
|
||||
{
|
||||
// Create the window of the application
|
||||
sf::RenderWindow window(sf::VideoMode(windowWidth, windowHeight), "SFML Island",
|
||||
sf::Style::Titlebar | sf::Style::Close);
|
||||
window.setVerticalSyncEnabled(true);
|
||||
|
||||
sf::Font font;
|
||||
if (!font.loadFromFile("resources/sansation.ttf"))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
// Create all of our graphics resources
|
||||
sf::Text hudText;
|
||||
sf::Text statusText;
|
||||
sf::Shader terrainShader;
|
||||
sf::RenderStates terrainStates(&terrainShader);
|
||||
sf::VertexBuffer terrain(sf::Triangles, sf::VertexBuffer::Static);
|
||||
|
||||
// Set up our text drawables
|
||||
statusText.setFont(font);
|
||||
statusText.setCharacterSize(28);
|
||||
statusText.setFillColor(sf::Color::White);
|
||||
statusText.setOutlineColor(sf::Color::Black);
|
||||
statusText.setOutlineThickness(2.0f);
|
||||
|
||||
hudText.setFont(font);
|
||||
hudText.setCharacterSize(14);
|
||||
hudText.setFillColor(sf::Color::White);
|
||||
hudText.setOutlineColor(sf::Color::Black);
|
||||
hudText.setOutlineThickness(2.0f);
|
||||
hudText.setPosition(5.0f, 5.0f);
|
||||
|
||||
// Staging buffer for our terrain data that we will upload to our VertexBuffer
|
||||
std::vector<sf::Vertex> terrainStagingBuffer;
|
||||
|
||||
// Check whether the prerequisites are suppprted
|
||||
bool prerequisitesSupported = sf::VertexBuffer::isAvailable() && sf::Shader::isAvailable();
|
||||
|
||||
// Set up our graphics resources and set the status text accordingly
|
||||
if (!prerequisitesSupported)
|
||||
{
|
||||
statusText.setString("Shaders and/or Vertex Buffers Unsupported");
|
||||
}
|
||||
else if (!terrainShader.loadFromFile("resources/terrain.vert", "resources/terrain.frag"))
|
||||
{
|
||||
prerequisitesSupported = false;
|
||||
|
||||
statusText.setString("Failed to load shader program");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Start up our thread pool
|
||||
for (unsigned int i = 0; i < threadCount; i++)
|
||||
{
|
||||
threads.push_back(new sf::Thread(threadFunction));
|
||||
threads.back()->launch();
|
||||
}
|
||||
|
||||
// Create our VertexBuffer with enough space to hold all the terrain geometry
|
||||
terrain.create(resolutionX * resolutionY * 6);
|
||||
|
||||
// Resize the staging buffer to be able to hold all the terrain geometry
|
||||
terrainStagingBuffer.resize(resolutionX * resolutionY * 6);
|
||||
|
||||
// Generate the initial terrain
|
||||
generateTerrain(&terrainStagingBuffer[0]);
|
||||
|
||||
statusText.setString("Generating Terrain...");
|
||||
}
|
||||
|
||||
// Center the status text
|
||||
statusText.setPosition((windowWidth - statusText.getLocalBounds().width) / 2.f, (windowHeight - statusText.getLocalBounds().height) / 2.f);
|
||||
|
||||
// Set up an array of pointers to our settings for arrow navigation
|
||||
Setting settings[] =
|
||||
{
|
||||
{"perlinFrequency", &perlinFrequency},
|
||||
{"perlinFrequencyBase", &perlinFrequencyBase},
|
||||
{"heightBase", &heightBase},
|
||||
{"edgeFactor", &edgeFactor},
|
||||
{"edgeDropoffExponent", &edgeDropoffExponent},
|
||||
{"snowcapHeight", &snowcapHeight},
|
||||
{"heightFactor", &heightFactor},
|
||||
{"heightFlatten", &heightFlatten},
|
||||
{"lightFactor", &lightFactor}
|
||||
};
|
||||
|
||||
const int settingCount = 9;
|
||||
int currentSetting = 0;
|
||||
|
||||
std::ostringstream osstr;
|
||||
sf::Clock clock;
|
||||
|
||||
while (window.isOpen())
|
||||
{
|
||||
// Handle events
|
||||
sf::Event event;
|
||||
while (window.pollEvent(event))
|
||||
{
|
||||
// Window closed or escape key pressed: exit
|
||||
if ((event.type == sf::Event::Closed) ||
|
||||
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
|
||||
{
|
||||
window.close();
|
||||
break;
|
||||
}
|
||||
|
||||
// Arrow key pressed:
|
||||
if (prerequisitesSupported && (event.type == sf::Event::KeyPressed))
|
||||
{
|
||||
switch (event.key.code)
|
||||
{
|
||||
case sf::Keyboard::Return: generateTerrain(&terrainStagingBuffer[0]); break;
|
||||
case sf::Keyboard::Down: currentSetting = (currentSetting + 1) % settingCount; break;
|
||||
case sf::Keyboard::Up: currentSetting = (currentSetting + settingCount - 1) % settingCount; break;
|
||||
case sf::Keyboard::Left: *(settings[currentSetting].value) -= 0.1f; break;
|
||||
case sf::Keyboard::Right: *(settings[currentSetting].value) += 0.1f; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clear, draw graphics objects and display
|
||||
window.clear();
|
||||
|
||||
window.draw(statusText);
|
||||
|
||||
if (prerequisitesSupported)
|
||||
{
|
||||
{
|
||||
sf::Lock lock(workQueueMutex);
|
||||
|
||||
// Don't bother updating/drawing the VertexBuffer while terrain is being regenerated
|
||||
if (!pendingWorkCount)
|
||||
{
|
||||
// If there is new data pending to be uploaded to the VertexBuffer, do it now
|
||||
if (bufferUploadPending)
|
||||
{
|
||||
terrain.update(&terrainStagingBuffer[0]);
|
||||
bufferUploadPending = false;
|
||||
}
|
||||
|
||||
terrainShader.setUniform("lightFactor", lightFactor);
|
||||
window.draw(terrain, terrainStates);
|
||||
}
|
||||
}
|
||||
|
||||
// Update and draw the HUD text
|
||||
osstr.str("");
|
||||
osstr << "Frame: " << clock.restart().asMilliseconds() << "ms\n"
|
||||
<< "perlinOctaves: " << perlinOctaves << "\n\n"
|
||||
<< "Use the arrow keys to change the values.\nUse the return key to regenerate the terrain.\n\n";
|
||||
|
||||
for (int i = 0; i < settingCount; ++i)
|
||||
osstr << ((i == currentSetting) ? ">> " : " ") << settings[i].name << ": " << *(settings[i].value) << "\n";
|
||||
|
||||
hudText.setString(osstr.str());
|
||||
|
||||
window.draw(hudText);
|
||||
}
|
||||
|
||||
// Display things on screen
|
||||
window.display();
|
||||
}
|
||||
|
||||
// Shut down our thread pool
|
||||
{
|
||||
sf::Lock lock(workQueueMutex);
|
||||
workPending = false;
|
||||
}
|
||||
|
||||
while (!threads.empty())
|
||||
{
|
||||
threads.back()->wait();
|
||||
delete threads.back();
|
||||
threads.pop_back();
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the terrain elevation at the given coordinates.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float getElevation(float x, float y)
|
||||
{
|
||||
x = x / resolutionX - 0.5f;
|
||||
y = y / resolutionY - 0.5f;
|
||||
|
||||
float elevation = 0.0f;
|
||||
|
||||
for (int i = 0; i < perlinOctaves; i++)
|
||||
{
|
||||
elevation += stb_perlin_noise3(
|
||||
x * perlinFrequency * std::pow(perlinFrequencyBase, i),
|
||||
y * perlinFrequency * std::pow(perlinFrequencyBase, i),
|
||||
0, 0, 0, 0
|
||||
) * std::pow(perlinFrequencyBase, -i);
|
||||
}
|
||||
|
||||
elevation = (elevation + 1.f) / 2.f;
|
||||
|
||||
float distance = 2.0f * std::sqrt(x * x + y * y);
|
||||
elevation = (elevation + heightBase) * (1.0f - edgeFactor * std::pow(distance, edgeDropoffExponent));
|
||||
elevation = std::min(std::max(elevation, 0.0f), 1.0f);
|
||||
|
||||
return elevation;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the terrain moisture at the given coordinates.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float getMoisture(float x, float y)
|
||||
{
|
||||
x = x / resolutionX - 0.5f;
|
||||
y = y / resolutionY - 0.5f;
|
||||
|
||||
float moisture = stb_perlin_noise3(
|
||||
x * 4.f + 0.5f,
|
||||
y * 4.f + 0.5f,
|
||||
0, 0, 0, 0
|
||||
);
|
||||
|
||||
return (moisture + 1.f) / 2.f;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the lowlands terrain color for the given moisture.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
sf::Color getLowlandsTerrainColor(float moisture)
|
||||
{
|
||||
sf::Color color =
|
||||
moisture < 0.27f ? sf::Color(240, 240, 180) :
|
||||
moisture < 0.3f ? sf::Color(240 - 240 * (moisture - 0.27f) / 0.03f, 240 - 40 * (moisture - 0.27f) / 0.03f, 180 - 180 * (moisture - 0.27f) / 0.03f) :
|
||||
moisture < 0.4f ? sf::Color(0, 200, 0) :
|
||||
moisture < 0.48f ? sf::Color(0, 200 - 40 * (moisture - 0.4f) / 0.08f, 0) :
|
||||
moisture < 0.6f ? sf::Color(0, 160, 0) :
|
||||
moisture < 0.7f ? sf::Color(34 * (moisture - 0.6f) / 0.1f, 160 - 60 * (moisture - 0.6f) / 0.1f, 34 * (moisture - 0.6f) / 0.1f) :
|
||||
sf::Color(34, 100, 34);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the highlands terrain color for the given elevation
|
||||
/// and moisture.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
sf::Color getHighlandsTerrainColor(float elevation, float moisture)
|
||||
{
|
||||
sf::Color lowlandsColor = getLowlandsTerrainColor(moisture);
|
||||
|
||||
sf::Color color =
|
||||
moisture < 0.6f ? sf::Color(112, 128, 144) :
|
||||
sf::Color(112 + 110 * (moisture - 0.6f) / 0.4f, 128 + 56 * (moisture - 0.6f) / 0.4f, 144 - 9 * (moisture - 0.6f) / 0.4f);
|
||||
|
||||
float factor = std::min((elevation - 0.4f) / 0.1f, 1.f);
|
||||
|
||||
color.r = lowlandsColor.r * (1.f - factor) + color.r * factor;
|
||||
color.g = lowlandsColor.g * (1.f - factor) + color.g * factor;
|
||||
color.b = lowlandsColor.b * (1.f - factor) + color.b * factor;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the snowcap terrain color for the given elevation
|
||||
/// and moisture.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
sf::Color getSnowcapTerrainColor(float elevation, float moisture)
|
||||
{
|
||||
sf::Color highlandsColor = getHighlandsTerrainColor(elevation, moisture);
|
||||
|
||||
sf::Color color = sf::Color::White;
|
||||
|
||||
float factor = std::min((elevation - snowcapHeight) / 0.05f, 1.f);
|
||||
|
||||
color.r = highlandsColor.r * (1.f - factor) + color.r * factor;
|
||||
color.g = highlandsColor.g * (1.f - factor) + color.g * factor;
|
||||
color.b = highlandsColor.b * (1.f - factor) + color.b * factor;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the terrain color for the given elevation and
|
||||
/// moisture.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
sf::Color getTerrainColor(float elevation, float moisture)
|
||||
{
|
||||
sf::Color color =
|
||||
elevation < 0.11f ? sf::Color(0, 0, elevation / 0.11f * 74.f + 181.0f) :
|
||||
elevation < 0.14f ? sf::Color(std::pow((elevation - 0.11f) / 0.03f, 0.3f) * 48.f, std::pow((elevation - 0.11f) / 0.03f, 0.3f) * 48.f, 255) :
|
||||
elevation < 0.16f ? sf::Color((elevation - 0.14f) * 128.f / 0.02f + 48.f, (elevation - 0.14f) * 128.f / 0.02f + 48.f, 127.0f + (0.16f - elevation) * 128.f / 0.02f) :
|
||||
elevation < 0.17f ? sf::Color(240, 230, 140) :
|
||||
elevation < 0.4f ? getLowlandsTerrainColor(moisture) :
|
||||
elevation < snowcapHeight ? getHighlandsTerrainColor(elevation, moisture) :
|
||||
getSnowcapTerrainColor(elevation, moisture);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Compute a compressed representation of the surface
|
||||
/// normal based on the given coordinates, and the elevation
|
||||
/// of the 4 adjacent neighbours.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
sf::Vector2f computeNormal(int x, int y, float left, float right, float bottom, float top)
|
||||
{
|
||||
sf::Vector3f deltaX(1, 0, (std::pow(right, heightFlatten) - std::pow(left, heightFlatten)) * heightFactor);
|
||||
sf::Vector3f deltaY(0, 1, (std::pow(top, heightFlatten) - std::pow(bottom, heightFlatten)) * heightFactor);
|
||||
|
||||
sf::Vector3f crossProduct(
|
||||
deltaX.y * deltaY.z - deltaX.z * deltaY.y,
|
||||
deltaX.z * deltaY.x - deltaX.x * deltaY.z,
|
||||
deltaX.x * deltaY.y - deltaX.y * deltaY.x
|
||||
);
|
||||
|
||||
// Scale cross product to make z component 1.0f so we can drop it
|
||||
crossProduct /= crossProduct.z;
|
||||
|
||||
// Return "compressed" normal
|
||||
return sf::Vector2f(crossProduct.x, crossProduct.y);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Process a terrain generation work item. Use the vector
|
||||
/// of vertices as scratch memory and upload the data to
|
||||
/// the vertex buffer when done.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void processWorkItem(std::vector<sf::Vertex>& vertices, const WorkItem& workItem)
|
||||
{
|
||||
unsigned int rowBlockSize = (resolutionY / blockCount) + 1;
|
||||
unsigned int rowStart = rowBlockSize * workItem.index;
|
||||
|
||||
if (rowStart >= resolutionY)
|
||||
return;
|
||||
|
||||
unsigned int rowEnd = std::min(rowStart + rowBlockSize, resolutionY);
|
||||
unsigned int rowCount = rowEnd - rowStart;
|
||||
|
||||
const float scalingFactorX = static_cast<float>(windowWidth) / static_cast<float>(resolutionX);
|
||||
const float scalingFactorY = static_cast<float>(windowHeight) / static_cast<float>(resolutionY);
|
||||
|
||||
for (unsigned int y = rowStart; y < rowEnd; y++)
|
||||
{
|
||||
for (int x = 0; x < resolutionX; x++)
|
||||
{
|
||||
int arrayIndexBase = ((y - rowStart) * resolutionX + x) * 6;
|
||||
|
||||
// Top left corner (first triangle)
|
||||
if (x > 0)
|
||||
{
|
||||
vertices[arrayIndexBase + 0] = vertices[arrayIndexBase - 6 + 5];
|
||||
}
|
||||
else if (y > rowStart)
|
||||
{
|
||||
vertices[arrayIndexBase + 0] = vertices[arrayIndexBase - resolutionX * 6 + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
vertices[arrayIndexBase + 0].position = sf::Vector2f(x * scalingFactorX, y * scalingFactorY);
|
||||
vertices[arrayIndexBase + 0].color = getTerrainColor(getElevation(x, y), getMoisture(x, y));
|
||||
vertices[arrayIndexBase + 0].texCoords = computeNormal(x, y, getElevation(x - 1, y), getElevation(x + 1, y), getElevation(x, y + 1), getElevation(x, y - 1));
|
||||
}
|
||||
|
||||
// Bottom left corner (first triangle)
|
||||
if (x > 0)
|
||||
{
|
||||
vertices[arrayIndexBase + 1] = vertices[arrayIndexBase - 6 + 2];
|
||||
}
|
||||
else
|
||||
{
|
||||
vertices[arrayIndexBase + 1].position = sf::Vector2f(x * scalingFactorX, (y + 1) * scalingFactorY);
|
||||
vertices[arrayIndexBase + 1].color = getTerrainColor(getElevation(x, y + 1), getMoisture(x, y + 1));
|
||||
vertices[arrayIndexBase + 1].texCoords = computeNormal(x, y + 1, getElevation(x - 1, y + 1), getElevation(x + 1, y + 1), getElevation(x, y + 2), getElevation(x, y));
|
||||
}
|
||||
|
||||
// Bottom right corner (first triangle)
|
||||
vertices[arrayIndexBase + 2].position = sf::Vector2f((x + 1) * scalingFactorX, (y + 1) * scalingFactorY);
|
||||
vertices[arrayIndexBase + 2].color = getTerrainColor(getElevation(x + 1, y + 1), getMoisture(x + 1, y + 1));
|
||||
vertices[arrayIndexBase + 2].texCoords = computeNormal(x + 1, y + 1, getElevation(x, y + 1), getElevation(x + 2, y + 1), getElevation(x + 1, y + 2), getElevation(x + 1, y));
|
||||
|
||||
// Top left corner (second triangle)
|
||||
vertices[arrayIndexBase + 3] = vertices[arrayIndexBase + 0];
|
||||
|
||||
// Bottom right corner (second triangle)
|
||||
vertices[arrayIndexBase + 4] = vertices[arrayIndexBase + 2];
|
||||
|
||||
// Top right corner (second triangle)
|
||||
if (y > rowStart)
|
||||
{
|
||||
vertices[arrayIndexBase + 5] = vertices[arrayIndexBase - resolutionX * 6 + 2];
|
||||
}
|
||||
else
|
||||
{
|
||||
vertices[arrayIndexBase + 5].position = sf::Vector2f((x + 1) * scalingFactorX, y * scalingFactorY);
|
||||
vertices[arrayIndexBase + 5].color = getTerrainColor(getElevation(x + 1, y), getMoisture(x + 1, y));
|
||||
vertices[arrayIndexBase + 5].texCoords = computeNormal(x + 1, y, getElevation(x, y), getElevation(x + 2, y), getElevation(x + 1, y + 1), getElevation(x + 1, y - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copy the resulting geometry from our thread-local buffer into the target buffer
|
||||
std::memcpy(workItem.targetBuffer + (resolutionX * rowStart * 6), &vertices[0], sizeof(sf::Vertex) * resolutionX * rowCount * 6);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Worker thread entry point. We use a thread pool to avoid
|
||||
/// the heavy cost of constantly recreating and starting
|
||||
/// new threads whenever we need to regenerate the terrain.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void threadFunction()
|
||||
{
|
||||
unsigned int rowBlockSize = (resolutionY / blockCount) + 1;
|
||||
|
||||
std::vector<sf::Vertex> vertices(resolutionX * rowBlockSize * 6);
|
||||
|
||||
WorkItem workItem = {0, 0};
|
||||
|
||||
// Loop until the application exits
|
||||
for (;;)
|
||||
{
|
||||
workItem.targetBuffer = 0;
|
||||
|
||||
// Check if there are new work items in the queue
|
||||
{
|
||||
sf::Lock lock(workQueueMutex);
|
||||
|
||||
if (!workPending)
|
||||
return;
|
||||
|
||||
if (!workQueue.empty())
|
||||
{
|
||||
workItem = workQueue.front();
|
||||
workQueue.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
// If we didn't receive a new work item, keep looping
|
||||
if (!workItem.targetBuffer)
|
||||
{
|
||||
sf::sleep(sf::milliseconds(10));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
processWorkItem(vertices, workItem);
|
||||
|
||||
{
|
||||
sf::Lock lock(workQueueMutex);
|
||||
|
||||
--pendingWorkCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Terrain generation entry point. This queues up the
|
||||
/// generation work items which the worker threads dequeue
|
||||
/// and process.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void generateTerrain(sf::Vertex* buffer)
|
||||
{
|
||||
bufferUploadPending = true;
|
||||
|
||||
// Make sure the work queue is empty before queuing new work
|
||||
for (;;)
|
||||
{
|
||||
{
|
||||
sf::Lock lock(workQueueMutex);
|
||||
|
||||
if (workQueue.empty())
|
||||
break;
|
||||
}
|
||||
|
||||
sf::sleep(sf::milliseconds(10));
|
||||
}
|
||||
|
||||
// Queue all the new work items
|
||||
{
|
||||
sf::Lock lock(workQueueMutex);
|
||||
|
||||
for (unsigned int i = 0; i < blockCount; i++)
|
||||
{
|
||||
WorkItem workItem = {buffer, i};
|
||||
workQueue.push_back(workItem);
|
||||
}
|
||||
|
||||
pendingWorkCount = blockCount;
|
||||
}
|
||||
}
|
BIN
examples/island/resources/sansation.ttf
Normal file
11
examples/island/resources/terrain.frag
Normal file
|
@ -0,0 +1,11 @@
|
|||
varying vec3 normal;
|
||||
uniform float lightFactor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 lightPosition = vec3(-1.0, 1.0, 1.0);
|
||||
vec3 eyePosition = vec3(0.0, 0.0, 1.0);
|
||||
vec3 halfVector = normalize(lightPosition + eyePosition);
|
||||
float intensity = lightFactor + (1.0 - lightFactor) * dot(normalize(normal), normalize(halfVector));
|
||||
gl_FragColor = gl_Color * vec4(intensity, intensity, intensity, 1.0);
|
||||
}
|
8
examples/island/resources/terrain.vert
Normal file
|
@ -0,0 +1,8 @@
|
|||
varying vec3 normal;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
gl_FrontColor = gl_Color;
|
||||
normal = vec3(gl_MultiTexCoord0.xy, 1.0);
|
||||
}
|
316
examples/island/stb_perlin.h
Normal file
|
@ -0,0 +1,316 @@
|
|||
// stb_perlin.h - v0.3 - perlin noise
|
||||
// public domain single-file C implementation by Sean Barrett
|
||||
//
|
||||
// LICENSE
|
||||
//
|
||||
// See end of file.
|
||||
//
|
||||
//
|
||||
// to create the implementation,
|
||||
// #define STB_PERLIN_IMPLEMENTATION
|
||||
// in *one* C/CPP file that includes this file.
|
||||
//
|
||||
//
|
||||
// Documentation:
|
||||
//
|
||||
// float stb_perlin_noise3( float x,
|
||||
// float y,
|
||||
// float z,
|
||||
// int x_wrap=0,
|
||||
// int y_wrap=0,
|
||||
// int z_wrap=0)
|
||||
//
|
||||
// This function computes a random value at the coordinate (x,y,z).
|
||||
// Adjacent random values are continuous but the noise fluctuates
|
||||
// its randomness with period 1, i.e. takes on wholly unrelated values
|
||||
// at integer points. Specifically, this implements Ken Perlin's
|
||||
// revised noise function from 2002.
|
||||
//
|
||||
// The "wrap" parameters can be used to create wraparound noise that
|
||||
// wraps at powers of two. The numbers MUST be powers of two. Specify
|
||||
// 0 to mean "don't care". (The noise always wraps every 256 due
|
||||
// details of the implementation, even if you ask for larger or no
|
||||
// wrapping.)
|
||||
//
|
||||
// Fractal Noise:
|
||||
//
|
||||
// Three common fractal noise functions are included, which produce
|
||||
// a wide variety of nice effects depending on the parameters
|
||||
// provided. Note that each function will call stb_perlin_noise3
|
||||
// 'octaves' times, so this parameter will affect runtime.
|
||||
//
|
||||
// float stb_perlin_ridge_noise3(float x, float y, float z,
|
||||
// float lacunarity, float gain, float offset, int octaves,
|
||||
// int x_wrap, int y_wrap, int z_wrap);
|
||||
//
|
||||
// float stb_perlin_fbm_noise3(float x, float y, float z,
|
||||
// float lacunarity, float gain, int octaves,
|
||||
// int x_wrap, int y_wrap, int z_wrap);
|
||||
//
|
||||
// float stb_perlin_turbulence_noise3(float x, float y, float z,
|
||||
// float lacunarity, float gain,int octaves,
|
||||
// int x_wrap, int y_wrap, int z_wrap);
|
||||
//
|
||||
// Typical values to start playing with:
|
||||
// octaves = 6 -- number of "octaves" of noise3() to sum
|
||||
// lacunarity = ~ 2.0 -- spacing between successive octaves (use exactly 2.0 for wrapping output)
|
||||
// gain = 0.5 -- relative weighting applied to each successive octave
|
||||
// offset = 1.0? -- used to invert the ridges, may need to be larger, not sure
|
||||
//
|
||||
//
|
||||
// Contributors:
|
||||
// Jack Mott - additional noise functions
|
||||
//
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern float stb_perlin_noise3(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap);
|
||||
extern float stb_perlin_ridge_noise3(float x, float y, float z,float lacunarity, float gain, float offset, int octaves,int x_wrap, int y_wrap, int z_wrap);
|
||||
extern float stb_perlin_fbm_noise3(float x, float y, float z,float lacunarity, float gain, int octaves,int x_wrap, int y_wrap, int z_wrap);
|
||||
extern float stb_perlin_turbulence_noise3(float x, float y, float z, float lacunarity, float gain, int octaves,int x_wrap, int y_wrap, int z_wrap);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef STB_PERLIN_IMPLEMENTATION
|
||||
|
||||
// not same permutation table as Perlin's reference to avoid copyright issues;
|
||||
// Perlin's table can be found at http://mrl.nyu.edu/~perlin/noise/
|
||||
// @OPTIMIZE: should this be unsigned char instead of int for cache?
|
||||
static unsigned char stb__perlin_randtab[512] =
|
||||
{
|
||||
23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123,
|
||||
152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72,
|
||||
175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240,
|
||||
8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57,
|
||||
225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233,
|
||||
94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172,
|
||||
165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243,
|
||||
65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122,
|
||||
26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76,
|
||||
250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246,
|
||||
132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3,
|
||||
91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231,
|
||||
38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221,
|
||||
131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62,
|
||||
27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135,
|
||||
61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5,
|
||||
|
||||
// and a second copy so we don't need an extra mask or static initializer
|
||||
23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123,
|
||||
152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72,
|
||||
175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240,
|
||||
8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57,
|
||||
225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233,
|
||||
94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172,
|
||||
165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243,
|
||||
65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122,
|
||||
26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76,
|
||||
250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246,
|
||||
132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3,
|
||||
91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231,
|
||||
38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221,
|
||||
131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62,
|
||||
27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135,
|
||||
61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5,
|
||||
};
|
||||
|
||||
static float stb__perlin_lerp(float a, float b, float t)
|
||||
{
|
||||
return a + (b-a) * t;
|
||||
}
|
||||
|
||||
static int stb__perlin_fastfloor(float a)
|
||||
{
|
||||
int ai = (int) a;
|
||||
return (a < ai) ? ai-1 : ai;
|
||||
}
|
||||
|
||||
// different grad function from Perlin's, but easy to modify to match reference
|
||||
static float stb__perlin_grad(int hash, float x, float y, float z)
|
||||
{
|
||||
static float basis[12][4] =
|
||||
{
|
||||
{ 1, 1, 0 },
|
||||
{ -1, 1, 0 },
|
||||
{ 1,-1, 0 },
|
||||
{ -1,-1, 0 },
|
||||
{ 1, 0, 1 },
|
||||
{ -1, 0, 1 },
|
||||
{ 1, 0,-1 },
|
||||
{ -1, 0,-1 },
|
||||
{ 0, 1, 1 },
|
||||
{ 0,-1, 1 },
|
||||
{ 0, 1,-1 },
|
||||
{ 0,-1,-1 },
|
||||
};
|
||||
|
||||
// perlin's gradient has 12 cases so some get used 1/16th of the time
|
||||
// and some 2/16ths. We reduce bias by changing those fractions
|
||||
// to 5/64ths and 6/64ths, and the same 4 cases get the extra weight.
|
||||
static unsigned char indices[64] =
|
||||
{
|
||||
0,1,2,3,4,5,6,7,8,9,10,11,
|
||||
0,9,1,11,
|
||||
0,1,2,3,4,5,6,7,8,9,10,11,
|
||||
0,1,2,3,4,5,6,7,8,9,10,11,
|
||||
0,1,2,3,4,5,6,7,8,9,10,11,
|
||||
0,1,2,3,4,5,6,7,8,9,10,11,
|
||||
};
|
||||
|
||||
// if you use reference permutation table, change 63 below to 15 to match reference
|
||||
// (this is why the ordering of the table above is funky)
|
||||
float *grad = basis[indices[hash & 63]];
|
||||
return grad[0]*x + grad[1]*y + grad[2]*z;
|
||||
}
|
||||
|
||||
float stb_perlin_noise3(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap)
|
||||
{
|
||||
float u,v,w;
|
||||
float n000,n001,n010,n011,n100,n101,n110,n111;
|
||||
float n00,n01,n10,n11;
|
||||
float n0,n1;
|
||||
|
||||
unsigned int x_mask = (x_wrap-1) & 255;
|
||||
unsigned int y_mask = (y_wrap-1) & 255;
|
||||
unsigned int z_mask = (z_wrap-1) & 255;
|
||||
int px = stb__perlin_fastfloor(x);
|
||||
int py = stb__perlin_fastfloor(y);
|
||||
int pz = stb__perlin_fastfloor(z);
|
||||
int x0 = px & x_mask, x1 = (px+1) & x_mask;
|
||||
int y0 = py & y_mask, y1 = (py+1) & y_mask;
|
||||
int z0 = pz & z_mask, z1 = (pz+1) & z_mask;
|
||||
int r0,r1, r00,r01,r10,r11;
|
||||
|
||||
#define stb__perlin_ease(a) (((a*6-15)*a + 10) * a * a * a)
|
||||
|
||||
x -= px; u = stb__perlin_ease(x);
|
||||
y -= py; v = stb__perlin_ease(y);
|
||||
z -= pz; w = stb__perlin_ease(z);
|
||||
|
||||
r0 = stb__perlin_randtab[x0];
|
||||
r1 = stb__perlin_randtab[x1];
|
||||
|
||||
r00 = stb__perlin_randtab[r0+y0];
|
||||
r01 = stb__perlin_randtab[r0+y1];
|
||||
r10 = stb__perlin_randtab[r1+y0];
|
||||
r11 = stb__perlin_randtab[r1+y1];
|
||||
|
||||
n000 = stb__perlin_grad(stb__perlin_randtab[r00+z0], x , y , z );
|
||||
n001 = stb__perlin_grad(stb__perlin_randtab[r00+z1], x , y , z-1 );
|
||||
n010 = stb__perlin_grad(stb__perlin_randtab[r01+z0], x , y-1, z );
|
||||
n011 = stb__perlin_grad(stb__perlin_randtab[r01+z1], x , y-1, z-1 );
|
||||
n100 = stb__perlin_grad(stb__perlin_randtab[r10+z0], x-1, y , z );
|
||||
n101 = stb__perlin_grad(stb__perlin_randtab[r10+z1], x-1, y , z-1 );
|
||||
n110 = stb__perlin_grad(stb__perlin_randtab[r11+z0], x-1, y-1, z );
|
||||
n111 = stb__perlin_grad(stb__perlin_randtab[r11+z1], x-1, y-1, z-1 );
|
||||
|
||||
n00 = stb__perlin_lerp(n000,n001,w);
|
||||
n01 = stb__perlin_lerp(n010,n011,w);
|
||||
n10 = stb__perlin_lerp(n100,n101,w);
|
||||
n11 = stb__perlin_lerp(n110,n111,w);
|
||||
|
||||
n0 = stb__perlin_lerp(n00,n01,v);
|
||||
n1 = stb__perlin_lerp(n10,n11,v);
|
||||
|
||||
return stb__perlin_lerp(n0,n1,u);
|
||||
}
|
||||
|
||||
float stb_perlin_ridge_noise3(float x, float y, float z,float lacunarity, float gain, float offset, int octaves,int x_wrap, int y_wrap, int z_wrap)
|
||||
{
|
||||
int i;
|
||||
float frequency = 1.0f;
|
||||
float prev = 1.0f;
|
||||
float amplitude = 0.5f;
|
||||
float sum = 0.0f;
|
||||
|
||||
for (i = 0; i < octaves; i++) {
|
||||
float r = (float)(stb_perlin_noise3(x*frequency,y*frequency,z*frequency,x_wrap,y_wrap,z_wrap));
|
||||
r = r<0 ? -r : r; // fabs()
|
||||
r = offset - r;
|
||||
r = r*r;
|
||||
sum += r*amplitude*prev;
|
||||
prev = r;
|
||||
frequency *= lacunarity;
|
||||
amplitude *= gain;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
float stb_perlin_fbm_noise3(float x, float y, float z,float lacunarity, float gain, int octaves,int x_wrap, int y_wrap, int z_wrap)
|
||||
{
|
||||
int i;
|
||||
float frequency = 1.0f;
|
||||
float amplitude = 1.0f;
|
||||
float sum = 0.0f;
|
||||
|
||||
for (i = 0; i < octaves; i++) {
|
||||
sum += stb_perlin_noise3(x*frequency,y*frequency,z*frequency,x_wrap,y_wrap,z_wrap)*amplitude;
|
||||
frequency *= lacunarity;
|
||||
amplitude *= gain;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
float stb_perlin_turbulence_noise3(float x, float y, float z, float lacunarity, float gain, int octaves,int x_wrap, int y_wrap, int z_wrap)
|
||||
{
|
||||
int i;
|
||||
float frequency = 1.0f;
|
||||
float amplitude = 1.0f;
|
||||
float sum = 0.0f;
|
||||
|
||||
for (i = 0; i < octaves; i++) {
|
||||
float r = stb_perlin_noise3(x*frequency,y*frequency,z*frequency,x_wrap,y_wrap,z_wrap)*amplitude;
|
||||
r = r<0 ? -r : r; // fabs()
|
||||
sum += r;
|
||||
frequency *= lacunarity;
|
||||
amplitude *= gain;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
#endif // STB_PERLIN_IMPLEMENTATION
|
||||
|
||||
/*
|
||||
------------------------------------------------------------------------------
|
||||
This software is available under 2 licenses -- choose whichever you prefer.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE A - MIT License
|
||||
Copyright (c) 2017 Sean Barrett
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||
This is free and unencumbered software released into the public domain.
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||
software, either in source code form or as a compiled binary, for any purpose,
|
||||
commercial or non-commercial, and by any means.
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||
software dedicate any and all copyright interest in the software to the public
|
||||
domain. We make this dedication for the benefit of the public at large and to
|
||||
the detriment of our heirs and successors. We intend this dedication to be an
|
||||
overt act of relinquishment in perpetuity of all present and future rights to
|
||||
this software under copyright law.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
*/
|
11
examples/joystick/CMakeLists.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/joystick)
|
||||
|
||||
# all source files
|
||||
set(SRC ${SRCROOT}/Joystick.cpp)
|
||||
|
||||
# define the joystick target
|
||||
sfml_add_example(joystick GUI_APP
|
||||
SOURCES ${SRC}
|
||||
DEPENDS sfml-graphics
|
||||
RESOURCES_DIR resources)
|
238
examples/joystick/Joystick.cpp
Normal file
|
@ -0,0 +1,238 @@
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
struct JoystickObject
|
||||
{
|
||||
sf::Text label;
|
||||
sf::Text value;
|
||||
};
|
||||
|
||||
typedef std::map<std::string, JoystickObject> Texts;
|
||||
Texts texts;
|
||||
std::ostringstream sstr;
|
||||
float threshold = 0.1f;
|
||||
|
||||
// Axes labels in as C strings
|
||||
const char* axislabels[] = {"X", "Y", "Z", "R", "U", "V", "PovX", "PovY"};
|
||||
|
||||
// Helper to set text entries to a specified value
|
||||
template<typename T>
|
||||
void set(const char* label, const T& value)
|
||||
{
|
||||
sstr.str("");
|
||||
sstr << value;
|
||||
texts[label].value.setString(sstr.str());
|
||||
}
|
||||
|
||||
// Update joystick identification
|
||||
void updateIdentification(unsigned int index)
|
||||
{
|
||||
sstr.str("");
|
||||
sstr << "Joystick " << index << ":";
|
||||
texts["ID"].label.setString(sstr.str());
|
||||
texts["ID"].value.setString(sf::Joystick::getIdentification(index).name);
|
||||
}
|
||||
|
||||
// Update joystick axes
|
||||
void updateAxes(unsigned int index)
|
||||
{
|
||||
for (unsigned int j = 0; j < sf::Joystick::AxisCount; ++j)
|
||||
{
|
||||
if (sf::Joystick::hasAxis(index, static_cast<sf::Joystick::Axis>(j)))
|
||||
set(axislabels[j], sf::Joystick::getAxisPosition(index, static_cast<sf::Joystick::Axis>(j)));
|
||||
}
|
||||
}
|
||||
|
||||
// Update joystick buttons
|
||||
void updateButtons(unsigned int index)
|
||||
{
|
||||
for (unsigned int j = 0; j < sf::Joystick::getButtonCount(index); ++j)
|
||||
{
|
||||
sstr.str("");
|
||||
sstr << "Button " << j;
|
||||
|
||||
set(sstr.str().c_str(), sf::Joystick::isButtonPressed(index, j));
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to update displayed joystick values
|
||||
void updateValues(unsigned int index)
|
||||
{
|
||||
if (sf::Joystick::isConnected(index)) {
|
||||
// Update the label-value sf::Text objects based on the current joystick state
|
||||
updateIdentification(index);
|
||||
updateAxes(index);
|
||||
updateButtons(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Entry point of application
|
||||
///
|
||||
/// \return Application exit code
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
int main()
|
||||
{
|
||||
// Create the window of the application
|
||||
sf::RenderWindow window(sf::VideoMode(400, 680), "Joystick", sf::Style::Close);
|
||||
window.setVerticalSyncEnabled(true);
|
||||
|
||||
// Load the text font
|
||||
sf::Font font;
|
||||
if (!font.loadFromFile("resources/sansation.ttf"))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
// Set up our string conversion parameters
|
||||
sstr.precision(2);
|
||||
sstr.setf(std::ios::fixed | std::ios::boolalpha);
|
||||
|
||||
// Set up our joystick identification sf::Text objects
|
||||
texts["ID"].label.setPosition(5.f, 5.f);
|
||||
texts["ID"].value.setPosition(80.f, 5.f);
|
||||
|
||||
texts["ID"].label.setString("<Not Connected>");
|
||||
texts["ID"].value.setString("");
|
||||
|
||||
// Set up our threshold sf::Text objects
|
||||
sstr.str("");
|
||||
sstr << threshold << " (Change with up/down arrow keys)";
|
||||
|
||||
texts["Threshold"].label.setPosition(5.f, 5.f + 2 * font.getLineSpacing(14));
|
||||
texts["Threshold"].value.setPosition(80.f, 5.f + 2 * font.getLineSpacing(14));
|
||||
|
||||
texts["Threshold"].label.setString("Threshold:");
|
||||
texts["Threshold"].value.setString(sstr.str());
|
||||
|
||||
// Set up our label-value sf::Text objects
|
||||
for (unsigned int i = 0; i < sf::Joystick::AxisCount; ++i)
|
||||
{
|
||||
JoystickObject& object = texts[axislabels[i]];
|
||||
|
||||
object.label.setPosition(5.f, 5.f + ((i + 4) * font.getLineSpacing(14)));
|
||||
object.label.setString(std::string(axislabels[i]) + ":");
|
||||
|
||||
object.value.setPosition(80.f, 5.f + ((i + 4) * font.getLineSpacing(14)));
|
||||
object.value.setString("N/A");
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < sf::Joystick::ButtonCount; ++i)
|
||||
{
|
||||
sstr.str("");
|
||||
sstr << "Button " << i;
|
||||
JoystickObject& object = texts[sstr.str()];
|
||||
|
||||
object.label.setPosition(5.f, 5.f + ((sf::Joystick::AxisCount + i + 4) * font.getLineSpacing(14)));
|
||||
object.label.setString(sstr.str() + ":");
|
||||
|
||||
object.value.setPosition(80.f, 5.f + ((sf::Joystick::AxisCount + i + 4) * font.getLineSpacing(14)));
|
||||
object.value.setString("N/A");
|
||||
}
|
||||
|
||||
for (Texts::iterator it = texts.begin(); it != texts.end(); ++it)
|
||||
{
|
||||
it->second.label.setFont(font);
|
||||
it->second.label.setCharacterSize(14);
|
||||
it->second.label.setFillColor(sf::Color::White);
|
||||
|
||||
it->second.value.setFont(font);
|
||||
it->second.value.setCharacterSize(14);
|
||||
it->second.value.setFillColor(sf::Color::White);
|
||||
}
|
||||
|
||||
// Update initially displayed joystick values if a joystick is already connected on startup
|
||||
for (unsigned int i = 0; i < sf::Joystick::Count; ++i)
|
||||
{
|
||||
if (sf::Joystick::isConnected(i))
|
||||
{
|
||||
updateValues(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (window.isOpen())
|
||||
{
|
||||
// Handle events
|
||||
sf::Event event;
|
||||
while (window.pollEvent(event))
|
||||
{
|
||||
// Window closed or escape key pressed: exit
|
||||
if ((event.type == sf::Event::Closed) ||
|
||||
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
|
||||
{
|
||||
window.close();
|
||||
break;
|
||||
}
|
||||
else if ((event.type == sf::Event::JoystickButtonPressed) ||
|
||||
(event.type == sf::Event::JoystickButtonReleased) ||
|
||||
(event.type == sf::Event::JoystickMoved) ||
|
||||
(event.type == sf::Event::JoystickConnected))
|
||||
{
|
||||
// Update displayed joystick values
|
||||
updateValues(event.joystickConnect.joystickId);
|
||||
}
|
||||
else if (event.type == sf::Event::JoystickDisconnected)
|
||||
{
|
||||
// Reset displayed joystick values to empty
|
||||
for (Texts::iterator it = texts.begin(); it != texts.end(); ++it)
|
||||
it->second.value.setString("N/A");
|
||||
|
||||
texts["ID"].label.setString("<Not Connected>");
|
||||
texts["ID"].value.setString("");
|
||||
|
||||
sstr.str("");
|
||||
sstr << threshold << " (Change with up/down arrow keys)";
|
||||
|
||||
texts["Threshold"].value.setString(sstr.str());
|
||||
}
|
||||
}
|
||||
|
||||
// Update threshold if the user wants to change it
|
||||
float newThreshold = threshold;
|
||||
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
|
||||
newThreshold += 0.1f;
|
||||
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
|
||||
newThreshold -= 0.1f;
|
||||
|
||||
newThreshold = std::min(std::max(newThreshold, 0.1f), 100.0f);
|
||||
|
||||
if (newThreshold != threshold)
|
||||
{
|
||||
threshold = newThreshold;
|
||||
window.setJoystickThreshold(threshold);
|
||||
|
||||
sstr.str("");
|
||||
sstr << threshold << " (Change with up/down arrow keys)";
|
||||
|
||||
texts["Threshold"].value.setString(sstr.str());
|
||||
}
|
||||
|
||||
// Clear the window
|
||||
window.clear();
|
||||
|
||||
// Draw the label-value sf::Text objects
|
||||
for (Texts::const_iterator it = texts.begin(); it != texts.end(); ++it)
|
||||
{
|
||||
window.draw(it->second.label);
|
||||
window.draw(it->second.value);
|
||||
}
|
||||
|
||||
// Display things on screen
|
||||
window.display();
|
||||
}
|
||||
}
|
BIN
examples/joystick/resources/sansation.ttf
Normal file
|
@ -4,12 +4,17 @@ set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/opengl)
|
|||
# all source files
|
||||
set(SRC ${SRCROOT}/OpenGL.cpp)
|
||||
|
||||
# find OpenGL
|
||||
find_package(OpenGL REQUIRED)
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
set(ADDITIONAL_LIBRARIES ${OPENGL_LIBRARIES})
|
||||
if (SFML_OS_IOS)
|
||||
set(RESOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/resources/background.jpg
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/resources/texture.jpg
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/resources/sansation.ttf)
|
||||
set_source_files_properties(${RESOURCES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
endif()
|
||||
|
||||
# define the opengl target
|
||||
sfml_add_example(opengl GUI_APP
|
||||
SOURCES ${SRC}
|
||||
DEPENDS sfml-graphics sfml-window sfml-system ${ADDITIONAL_LIBRARIES})
|
||||
BUNDLE_RESOURCES ${RESOURCES}
|
||||
DEPENDS sfml-graphics
|
||||
RESOURCES_DIR resources)
|
||||
|
|
|
@ -3,12 +3,26 @@
|
|||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <SFML/OpenGL.hpp>
|
||||
|
||||
#define GLAD_GL_IMPLEMENTATION
|
||||
#include "gl.h"
|
||||
|
||||
#ifdef SFML_SYSTEM_IOS
|
||||
#include <SFML/Main.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef GL_SRGB8_ALPHA8
|
||||
#define GL_SRGB8_ALPHA8 0x8C43
|
||||
#endif
|
||||
|
||||
std::string resourcesDir()
|
||||
{
|
||||
#ifdef SFML_SYSTEM_IOS
|
||||
return "";
|
||||
#else
|
||||
return "resources/";
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Entry point of application
|
||||
|
@ -35,13 +49,13 @@ int main()
|
|||
// Create a sprite for the background
|
||||
sf::Texture backgroundTexture;
|
||||
backgroundTexture.setSrgb(sRgb);
|
||||
if (!backgroundTexture.loadFromFile("resources/background.jpg"))
|
||||
if (!backgroundTexture.loadFromFile(resourcesDir() + "background.jpg"))
|
||||
return EXIT_FAILURE;
|
||||
sf::Sprite background(backgroundTexture);
|
||||
|
||||
// Create some text to draw on top of our OpenGL object
|
||||
sf::Font font;
|
||||
if (!font.loadFromFile("resources/sansation.ttf"))
|
||||
if (!font.loadFromFile(resourcesDir() + "sansation.ttf"))
|
||||
return EXIT_FAILURE;
|
||||
sf::Text text("SFML / OpenGL demo", font);
|
||||
sf::Text sRgbInstructions("Press space to toggle sRGB conversion", font);
|
||||
|
@ -55,7 +69,7 @@ int main()
|
|||
|
||||
// Load a texture to apply to our 3D cube
|
||||
sf::Texture texture;
|
||||
if (!texture.loadFromFile("resources/texture.jpg"))
|
||||
if (!texture.loadFromFile(resourcesDir() + "texture.jpg"))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
// Attempt to generate a mipmap for our cube texture
|
||||
|
@ -66,10 +80,21 @@ int main()
|
|||
// Make the window the active window for OpenGL calls
|
||||
window.setActive(true);
|
||||
|
||||
// Load OpenGL or OpenGL ES entry points using glad
|
||||
#ifdef SFML_OPENGL_ES
|
||||
gladLoadGLES1(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||
#else
|
||||
gladLoadGL(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||
#endif
|
||||
|
||||
// Enable Z-buffer read and write
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
#ifdef SFML_OPENGL_ES
|
||||
glClearDepthf(1.f);
|
||||
#else
|
||||
glClearDepth(1.f);
|
||||
#endif
|
||||
|
||||
// Disable lighting
|
||||
glDisable(GL_LIGHTING);
|
||||
|
@ -81,7 +106,11 @@ int main()
|
|||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
GLfloat ratio = static_cast<float>(window.getSize().x) / window.getSize().y;
|
||||
#ifdef SFML_OPENGL_ES
|
||||
glFrustumf(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||
#else
|
||||
glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||
#endif
|
||||
|
||||
// Bind the texture
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
@ -175,12 +204,12 @@ int main()
|
|||
}
|
||||
|
||||
// Return key: toggle mipmapping
|
||||
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Return))
|
||||
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Enter))
|
||||
{
|
||||
if (mipmapEnabled)
|
||||
{
|
||||
// We simply reload the texture to disable mipmapping
|
||||
if (!texture.loadFromFile("resources/texture.jpg"))
|
||||
if (!texture.loadFromFile(resourcesDir() + "texture.jpg"))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
mipmapEnabled = false;
|
||||
|
@ -203,13 +232,28 @@ int main()
|
|||
// Adjust the viewport when the window is resized
|
||||
if (event.type == sf::Event::Resized)
|
||||
{
|
||||
sf::Vector2u textureSize = backgroundTexture.getSize();
|
||||
|
||||
// Make the window the active window for OpenGL calls
|
||||
window.setActive(true);
|
||||
|
||||
glViewport(0, 0, event.size.width, event.size.height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
GLfloat ratio = static_cast<float>(event.size.width) / event.size.height;
|
||||
#ifdef SFML_OPENGL_ES
|
||||
glFrustumf(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||
#else
|
||||
glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||
#endif
|
||||
|
||||
// Make the window no longer the active window for OpenGL calls
|
||||
window.setActive(false);
|
||||
|
||||
sf::View view;
|
||||
view.setSize(textureSize.x, textureSize.y);
|
||||
view.setCenter(textureSize.x/2.f, textureSize.y/2.f);
|
||||
window.setView(view);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,9 +268,17 @@ int main()
|
|||
// Clear the depth buffer
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// We get the position of the mouse cursor, so that we can move the box accordingly
|
||||
float x = sf::Mouse::getPosition(window).x * 200.f / window.getSize().x - 100.f;
|
||||
float y = -sf::Mouse::getPosition(window).y * 200.f / window.getSize().y + 100.f;
|
||||
// We get the position of the mouse cursor (or touch), so that we can move the box accordingly
|
||||
sf::Vector2i pos;
|
||||
|
||||
#ifdef SFML_SYSTEM_IOS
|
||||
pos = sf::Touch::getPosition(0);
|
||||
#else
|
||||
pos = sf::Mouse::getPosition();
|
||||
#endif
|
||||
|
||||
float x = pos.x * 200.f / window.getSize().x - 100.f;
|
||||
float y = -pos.y * 200.f / window.getSize().y + 100.f;
|
||||
|
||||
// Apply some transformations
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
|
7837
examples/opengl/gl.h
Normal file
|
@ -3,8 +3,16 @@ set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/pong)
|
|||
|
||||
# all source files
|
||||
set(SRC ${SRCROOT}/Pong.cpp)
|
||||
if (SFML_OS_IOS)
|
||||
set(RESOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/resources/ball.wav
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/resources/sansation.ttf)
|
||||
set_source_files_properties(${RESOURCES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
endif()
|
||||
|
||||
# define the pong target
|
||||
sfml_add_example(pong GUI_APP
|
||||
SOURCES ${SRC}
|
||||
DEPENDS sfml-audio sfml-graphics sfml-window sfml-system)
|
||||
BUNDLE_RESOURCES ${RESOURCES}
|
||||
DEPENDS sfml-audio sfml-graphics
|
||||
RESOURCES_DIR resources)
|
||||
|
|
|
@ -8,6 +8,18 @@
|
|||
#include <ctime>
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef SFML_SYSTEM_IOS
|
||||
#include <SFML/Main.hpp>
|
||||
#endif
|
||||
|
||||
std::string resourcesDir()
|
||||
{
|
||||
#ifdef SFML_SYSTEM_IOS
|
||||
return "";
|
||||
#else
|
||||
return "resources/";
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Entry point of application
|
||||
|
@ -33,7 +45,7 @@ int main()
|
|||
|
||||
// Load the sounds used in the game
|
||||
sf::SoundBuffer ballSoundBuffer;
|
||||
if (!ballSoundBuffer.loadFromFile("resources/ball.wav"))
|
||||
if (!ballSoundBuffer.loadFromFile(resourcesDir() + "ball.wav"))
|
||||
return EXIT_FAILURE;
|
||||
sf::Sound ballSound(ballSoundBuffer);
|
||||
|
||||
|
@ -63,7 +75,7 @@ int main()
|
|||
|
||||
// Load the text font
|
||||
sf::Font font;
|
||||
if (!font.loadFromFile("resources/sansation.ttf"))
|
||||
if (!font.loadFromFile(resourcesDir() + "sansation.ttf"))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
// Initialize the pause message
|
||||
|
@ -72,7 +84,12 @@ int main()
|
|||
pauseMessage.setCharacterSize(40);
|
||||
pauseMessage.setPosition(170.f, 150.f);
|
||||
pauseMessage.setFillColor(sf::Color::White);
|
||||
|
||||
#ifdef SFML_SYSTEM_IOS
|
||||
pauseMessage.setString("Welcome to SFML pong!\nTouch the screen to start the game");
|
||||
#else
|
||||
pauseMessage.setString("Welcome to SFML pong!\nPress space to start the game");
|
||||
#endif
|
||||
|
||||
// Define the paddles properties
|
||||
sf::Clock AITimer;
|
||||
|
@ -99,7 +116,8 @@ int main()
|
|||
}
|
||||
|
||||
// Space key pressed: play
|
||||
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space))
|
||||
if (((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space)) ||
|
||||
(event.type == sf::Event::TouchBegan))
|
||||
{
|
||||
if (!isPlaying)
|
||||
{
|
||||
|
@ -121,6 +139,15 @@ int main()
|
|||
while (std::abs(std::cos(ballAngle)) < 0.7f);
|
||||
}
|
||||
}
|
||||
|
||||
// Window size changed, adjust view appropriately
|
||||
if (event.type == sf::Event::Resized)
|
||||
{
|
||||
sf::View view;
|
||||
view.setSize(gameWidth, gameHeight);
|
||||
view.setCenter(gameWidth/2.f, gameHeight/2.f);
|
||||
window.setView(view);
|
||||
}
|
||||
}
|
||||
|
||||
if (isPlaying)
|
||||
|
@ -138,6 +165,13 @@ int main()
|
|||
{
|
||||
leftPaddle.move(0.f, paddleSpeed * deltaTime);
|
||||
}
|
||||
|
||||
if (sf::Touch::isDown(0))
|
||||
{
|
||||
sf::Vector2i pos = sf::Touch::getPosition(0);
|
||||
sf::Vector2f mappedPos = window.mapPixelToCoords(pos);
|
||||
leftPaddle.setPosition(leftPaddle.getPosition().x, mappedPos.y);
|
||||
}
|
||||
|
||||
// Move the computer's paddle
|
||||
if (((rightPaddleSpeed < 0.f) && (rightPaddle.getPosition().y - paddleSize.y / 2 > 5.f)) ||
|
||||
|
@ -162,16 +196,22 @@ int main()
|
|||
float factor = ballSpeed * deltaTime;
|
||||
ball.move(std::cos(ballAngle) * factor, std::sin(ballAngle) * factor);
|
||||
|
||||
#ifdef SFML_SYSTEM_IOS
|
||||
const std::string inputString = "Touch the screen to restart";
|
||||
#else
|
||||
const std::string inputString = "Press space to restart or\nescape to exit";
|
||||
#endif
|
||||
|
||||
// Check collisions between the ball and the screen
|
||||
if (ball.getPosition().x - ballRadius < 0.f)
|
||||
{
|
||||
isPlaying = false;
|
||||
pauseMessage.setString("You lost!\nPress space to restart or\nescape to exit");
|
||||
pauseMessage.setString("You Lost!\n" + inputString);
|
||||
}
|
||||
if (ball.getPosition().x + ballRadius > gameWidth)
|
||||
{
|
||||
isPlaying = false;
|
||||
pauseMessage.setString("You won!\nPress space to restart or\nescape to exit");
|
||||
pauseMessage.setString("You Won!\n" + inputString);
|
||||
}
|
||||
if (ball.getPosition().y - ballRadius < 0.f)
|
||||
{
|
||||
|
|
|
@ -9,4 +9,5 @@ set(SRC
|
|||
# define the shader target
|
||||
sfml_add_example(shader GUI_APP
|
||||
SOURCES ${SRC}
|
||||
DEPENDS sfml-graphics sfml-window sfml-system)
|
||||
DEPENDS sfml-graphics
|
||||
RESOURCES_DIR resources)
|
||||
|
|
|
@ -9,4 +9,4 @@ set(SRC ${SRCROOT}/Sockets.cpp
|
|||
# define the sockets target
|
||||
sfml_add_example(sockets
|
||||
SOURCES ${SRC}
|
||||
DEPENDS sfml-network sfml-system)
|
||||
DEPENDS sfml-network)
|
||||
|
|
|
@ -7,4 +7,5 @@ set(SRC ${SRCROOT}/Sound.cpp)
|
|||
# define the sound target
|
||||
sfml_add_example(sound
|
||||
SOURCES ${SRC}
|
||||
DEPENDS sfml-audio sfml-system)
|
||||
DEPENDS sfml-audio
|
||||
RESOURCES_DIR resources)
|
||||
|
|
|
@ -7,4 +7,4 @@ set(SRC ${SRCROOT}/SoundCapture.cpp)
|
|||
# define the sound-capture target
|
||||
sfml_add_example(sound-capture
|
||||
SOURCES ${SRC}
|
||||
DEPENDS sfml-audio sfml-system)
|
||||
DEPENDS sfml-audio)
|
||||
|
|
|
@ -9,4 +9,4 @@ set(SRC ${SRCROOT}/VoIP.cpp
|
|||
# define the voip target
|
||||
sfml_add_example(voip
|
||||
SOURCES ${SRC}
|
||||
DEPENDS sfml-audio sfml-network sfml-system)
|
||||
DEPENDS sfml-audio sfml-network)
|
||||
|
|
11
examples/vulkan/CMakeLists.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/vulkan)
|
||||
|
||||
# all source files
|
||||
set(SRC ${SRCROOT}/Vulkan.cpp)
|
||||
|
||||
# define the window target
|
||||
sfml_add_example(vulkan GUI_APP
|
||||
SOURCES ${SRC}
|
||||
DEPENDS sfml-graphics
|
||||
RESOURCES_DIR resources)
|
2557
examples/vulkan/Vulkan.cpp
Normal file
BIN
examples/vulkan/resources/logo.png
Normal file
After Width: | Height: | Size: 21 KiB |
16
examples/vulkan/resources/shader.frag
Normal file
|
@ -0,0 +1,16 @@
|
|||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(binding = 1) uniform sampler2D texSampler;
|
||||
|
||||
layout(location = 0) in vec4 fragColor;
|
||||
layout(location = 1) in vec2 fragTexCoord;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
outColor = fragColor * texture(texSampler, fragTexCoord);
|
||||
|
||||
if (outColor.a < 0.5)
|
||||
discard;
|
||||
}
|
BIN
examples/vulkan/resources/shader.frag.spv
Normal file
25
examples/vulkan/resources/shader.vert
Normal file
|
@ -0,0 +1,25 @@
|
|||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
|
||||
layout(binding = 0) uniform UniformBufferObject {
|
||||
mat4 model;
|
||||
mat4 view;
|
||||
mat4 proj;
|
||||
} ubo;
|
||||
|
||||
layout(location = 0) in vec3 inPosition;
|
||||
layout(location = 1) in vec4 inColor;
|
||||
layout(location = 2) in vec2 inTexCoord;
|
||||
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
layout(location = 1) out vec2 fragTexCoord;
|
||||
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
void main() {
|
||||
gl_Position = ubo.proj * ubo.view * ubo.model * vec4(inPosition, 1.0);
|
||||
fragColor = inColor;
|
||||
fragTexCoord = inTexCoord;
|
||||
}
|
BIN
examples/vulkan/resources/shader.vert.spv
Normal file
3341
examples/vulkan/vulkan.h
Normal file
|
@ -7,4 +7,5 @@ set(SRC ${SRCROOT}/Win32.cpp)
|
|||
# define the win32 target
|
||||
sfml_add_example(win32 GUI_APP
|
||||
SOURCES ${SRC}
|
||||
DEPENDS sfml-graphics sfml-window sfml-system)
|
||||
DEPENDS sfml-graphics
|
||||
RESOURCES_DIR resources)
|
||||
|
|
|
@ -122,6 +122,10 @@ int main()
|
|||
}
|
||||
}
|
||||
|
||||
// Close our SFML views before destroying the underlying window
|
||||
SFMLView1.close();
|
||||
SFMLView2.close();
|
||||
|
||||
// Destroy the main window (all its child controls will be destroyed)
|
||||
DestroyWindow(window);
|
||||
|
||||
|
|
|
@ -4,12 +4,7 @@ set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/window)
|
|||
# all source files
|
||||
set(SRC ${SRCROOT}/Window.cpp)
|
||||
|
||||
# find OpenGL
|
||||
find_package(OpenGL REQUIRED)
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
set(ADDITIONAL_LIBRARIES ${OPENGL_LIBRARIES})
|
||||
|
||||
# define the window target
|
||||
sfml_add_example(window GUI_APP
|
||||
SOURCES ${SRC}
|
||||
DEPENDS sfml-window sfml-system ${ADDITIONAL_LIBRARIES})
|
||||
DEPENDS sfml-window)
|
||||
|
|
|
@ -2,8 +2,13 @@
|
|||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window.hpp>
|
||||
#include <SFML/OpenGL.hpp>
|
||||
|
||||
#define GLAD_GL_IMPLEMENTATION
|
||||
#include "gl.h"
|
||||
|
||||
#ifdef SFML_SYSTEM_IOS
|
||||
#include <SFML/Main.hpp>
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Entry point of application
|
||||
|
@ -23,8 +28,19 @@ int main()
|
|||
// Make it the active window for OpenGL calls
|
||||
window.setActive();
|
||||
|
||||
// Load OpenGL or OpenGL ES entry points using glad
|
||||
#ifdef SFML_OPENGL_ES
|
||||
gladLoadGLES1(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||
#else
|
||||
gladLoadGL(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||
#endif
|
||||
|
||||
// Set the color and depth clear values
|
||||
#ifdef SFML_OPENGL_ES
|
||||
glClearDepthf(1.f);
|
||||
#else
|
||||
glClearDepth(1.f);
|
||||
#endif
|
||||
glClearColor(0.f, 0.f, 0.f, 1.f);
|
||||
|
||||
// Enable Z-buffer read and write
|
||||
|
@ -42,7 +58,11 @@ int main()
|
|||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
GLfloat ratio = static_cast<float>(window.getSize().x) / window.getSize().y;
|
||||
#ifdef SFML_OPENGL_ES
|
||||
glFrustumf(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||
#else
|
||||
glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||
#endif
|
||||
|
||||
// Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
|
||||
GLfloat cube[] =
|
||||
|
@ -121,7 +141,17 @@ int main()
|
|||
|
||||
// Resize event: adjust the viewport
|
||||
if (event.type == sf::Event::Resized)
|
||||
{
|
||||
glViewport(0, 0, event.size.width, event.size.height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
GLfloat ratio = static_cast<float>(event.size.width) / event.size.height;
|
||||
#ifdef SFML_OPENGL_ES
|
||||
glFrustumf(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||
#else
|
||||
glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the color and depth buffers
|
||||
|
|
7837
examples/window/gl.h
Normal file
11689
extlibs/headers/catch.hpp
vendored
Normal file
1497
extlibs/headers/glad/include/glad/egl.h
vendored
Normal file
7839
extlibs/headers/glad/include/glad/gl.h
vendored
Normal file
1043
extlibs/headers/glad/include/glad/glx.h
vendored
Normal file
586
extlibs/headers/glad/include/glad/wgl.h
vendored
Normal file
|
@ -0,0 +1,586 @@
|
|||
/**
|
||||
* Loader generated by glad 2.0.0-beta on Wed Jul 17 02:23:29 2019
|
||||
*
|
||||
* Generator: C/C++
|
||||
* Specification: wgl
|
||||
* Extensions: 10
|
||||
*
|
||||
* APIs:
|
||||
* - wgl=1.0
|
||||
*
|
||||
* Options:
|
||||
* - MX_GLOBAL = False
|
||||
* - ON_DEMAND = False
|
||||
* - LOADER = True
|
||||
* - ALIAS = True
|
||||
* - HEADER_ONLY = True
|
||||
* - DEBUG = False
|
||||
* - MX = False
|
||||
*
|
||||
* Commandline:
|
||||
* --api='wgl=1.0' --extensions='WGL_ARB_create_context,WGL_ARB_create_context_profile,WGL_ARB_extensions_string,WGL_ARB_framebuffer_sRGB,WGL_ARB_multisample,WGL_ARB_pbuffer,WGL_ARB_pixel_format,WGL_EXT_extensions_string,WGL_EXT_framebuffer_sRGB,WGL_EXT_swap_control' c --loader --alias --header-only
|
||||
*
|
||||
* Online:
|
||||
* http://glad.sh/#api=wgl%3D1.0&extensions=WGL_ARB_create_context%2CWGL_ARB_create_context_profile%2CWGL_ARB_extensions_string%2CWGL_ARB_framebuffer_sRGB%2CWGL_ARB_multisample%2CWGL_ARB_pbuffer%2CWGL_ARB_pixel_format%2CWGL_EXT_extensions_string%2CWGL_EXT_framebuffer_sRGB%2CWGL_EXT_swap_control&generator=c&options=LOADER%2CALIAS%2CHEADER_ONLY
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SF_GLAD_WGL_H_
|
||||
#define SF_GLAD_WGL_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <glad/gl.h>
|
||||
|
||||
#define SF_GLAD_WGL
|
||||
#define GLAD_OPTION_WGL_LOADER
|
||||
#define GLAD_OPTION_WGL_ALIAS
|
||||
#define GLAD_OPTION_WGL_HEADER_ONLY
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef GLAD_PLATFORM_H_
|
||||
#define GLAD_PLATFORM_H_
|
||||
|
||||
#ifndef GLAD_PLATFORM_WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
|
||||
#define GLAD_PLATFORM_WIN32 1
|
||||
#else
|
||||
#define GLAD_PLATFORM_WIN32 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GLAD_PLATFORM_APPLE
|
||||
#ifdef __APPLE__
|
||||
#define GLAD_PLATFORM_APPLE 1
|
||||
#else
|
||||
#define GLAD_PLATFORM_APPLE 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GLAD_PLATFORM_EMSCRIPTEN
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#define GLAD_PLATFORM_EMSCRIPTEN 1
|
||||
#else
|
||||
#define GLAD_PLATFORM_EMSCRIPTEN 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GLAD_PLATFORM_UWP
|
||||
#if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
|
||||
#ifdef __has_include
|
||||
#if __has_include(<winapifamily.h>)
|
||||
#define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
|
||||
#endif
|
||||
#elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
|
||||
#define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
|
||||
#include <winapifamily.h>
|
||||
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
|
||||
#define GLAD_PLATFORM_UWP 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GLAD_PLATFORM_UWP
|
||||
#define GLAD_PLATFORM_UWP 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define GLAD_GNUC_EXTENSION __extension__
|
||||
#else
|
||||
#define GLAD_GNUC_EXTENSION
|
||||
#endif
|
||||
|
||||
#ifndef GLAD_API_CALL
|
||||
#if defined(GLAD_API_CALL_EXPORT)
|
||||
#if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
|
||||
#if defined(GLAD_API_CALL_EXPORT_BUILD)
|
||||
#if defined(__GNUC__)
|
||||
#define GLAD_API_CALL __attribute__ ((dllexport)) extern
|
||||
#else
|
||||
#define GLAD_API_CALL __declspec(dllexport) extern
|
||||
#endif
|
||||
#else
|
||||
#if defined(__GNUC__)
|
||||
#define GLAD_API_CALL __attribute__ ((dllimport)) extern
|
||||
#else
|
||||
#define GLAD_API_CALL __declspec(dllimport) extern
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
|
||||
#define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
|
||||
#else
|
||||
#define GLAD_API_CALL extern
|
||||
#endif
|
||||
#else
|
||||
#define GLAD_API_CALL extern
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef APIENTRY
|
||||
#define GLAD_API_PTR APIENTRY
|
||||
#elif GLAD_PLATFORM_WIN32
|
||||
#define GLAD_API_PTR __stdcall
|
||||
#else
|
||||
#define GLAD_API_PTR
|
||||
#endif
|
||||
|
||||
#ifndef GLAPI
|
||||
#define GLAPI GLAD_API_CALL
|
||||
#endif
|
||||
|
||||
#ifndef GLAPIENTRY
|
||||
#define GLAPIENTRY GLAD_API_PTR
|
||||
#endif
|
||||
|
||||
#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
|
||||
#define GLAD_VERSION_MAJOR(version) (version / 10000)
|
||||
#define GLAD_VERSION_MINOR(version) (version % 10000)
|
||||
|
||||
#define GLAD_GENERATOR_VERSION "2.0.0-beta"
|
||||
|
||||
typedef void (*GLADapiproc)(void);
|
||||
|
||||
typedef GLADapiproc (*GLADloadfunc)(const char *name);
|
||||
typedef GLADapiproc (*GLADuserptrloadfunc)(void *userptr, const char *name);
|
||||
|
||||
typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
|
||||
typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
|
||||
|
||||
#endif /* GLAD_PLATFORM_H_ */
|
||||
|
||||
#define ERROR_INVALID_PROFILE_ARB 0x2096
|
||||
#define ERROR_INVALID_VERSION_ARB 0x2095
|
||||
#define WGL_ACCELERATION_ARB 0x2003
|
||||
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
|
||||
#define WGL_ACCUM_BITS_ARB 0x201D
|
||||
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
|
||||
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
|
||||
#define WGL_ACCUM_RED_BITS_ARB 0x201E
|
||||
#define WGL_ALPHA_BITS_ARB 0x201B
|
||||
#define WGL_ALPHA_SHIFT_ARB 0x201C
|
||||
#define WGL_AUX_BUFFERS_ARB 0x2024
|
||||
#define WGL_BLUE_BITS_ARB 0x2019
|
||||
#define WGL_BLUE_SHIFT_ARB 0x201A
|
||||
#define WGL_COLOR_BITS_ARB 0x2014
|
||||
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
||||
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||
#define WGL_CONTEXT_FLAGS_ARB 0x2094
|
||||
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
|
||||
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
|
||||
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||
#define WGL_DEPTH_BITS_ARB 0x2022
|
||||
#define WGL_DOUBLE_BUFFER_ARB 0x2011
|
||||
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
|
||||
#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
|
||||
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
|
||||
#define WGL_FONT_LINES 0
|
||||
#define WGL_FONT_POLYGONS 1
|
||||
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
|
||||
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9
|
||||
#define WGL_FULL_ACCELERATION_ARB 0x2027
|
||||
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
|
||||
#define WGL_GREEN_BITS_ARB 0x2017
|
||||
#define WGL_GREEN_SHIFT_ARB 0x2018
|
||||
#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
|
||||
#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
|
||||
#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
|
||||
#define WGL_NEED_PALETTE_ARB 0x2004
|
||||
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
|
||||
#define WGL_NO_ACCELERATION_ARB 0x2025
|
||||
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
|
||||
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
|
||||
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
|
||||
#define WGL_PBUFFER_HEIGHT_ARB 0x2035
|
||||
#define WGL_PBUFFER_LARGEST_ARB 0x2033
|
||||
#define WGL_PBUFFER_LOST_ARB 0x2036
|
||||
#define WGL_PBUFFER_WIDTH_ARB 0x2034
|
||||
#define WGL_PIXEL_TYPE_ARB 0x2013
|
||||
#define WGL_RED_BITS_ARB 0x2015
|
||||
#define WGL_RED_SHIFT_ARB 0x2016
|
||||
#define WGL_SAMPLES_ARB 0x2042
|
||||
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
|
||||
#define WGL_SHARE_ACCUM_ARB 0x200E
|
||||
#define WGL_SHARE_DEPTH_ARB 0x200C
|
||||
#define WGL_SHARE_STENCIL_ARB 0x200D
|
||||
#define WGL_STENCIL_BITS_ARB 0x2023
|
||||
#define WGL_STEREO_ARB 0x2012
|
||||
#define WGL_SUPPORT_GDI_ARB 0x200F
|
||||
#define WGL_SUPPORT_OPENGL_ARB 0x2010
|
||||
#define WGL_SWAP_COPY_ARB 0x2029
|
||||
#define WGL_SWAP_EXCHANGE_ARB 0x2028
|
||||
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
|
||||
#define WGL_SWAP_MAIN_PLANE 0x00000001
|
||||
#define WGL_SWAP_METHOD_ARB 0x2007
|
||||
#define WGL_SWAP_OVERLAY1 0x00000002
|
||||
#define WGL_SWAP_OVERLAY10 0x00000400
|
||||
#define WGL_SWAP_OVERLAY11 0x00000800
|
||||
#define WGL_SWAP_OVERLAY12 0x00001000
|
||||
#define WGL_SWAP_OVERLAY13 0x00002000
|
||||
#define WGL_SWAP_OVERLAY14 0x00004000
|
||||
#define WGL_SWAP_OVERLAY15 0x00008000
|
||||
#define WGL_SWAP_OVERLAY2 0x00000004
|
||||
#define WGL_SWAP_OVERLAY3 0x00000008
|
||||
#define WGL_SWAP_OVERLAY4 0x00000010
|
||||
#define WGL_SWAP_OVERLAY5 0x00000020
|
||||
#define WGL_SWAP_OVERLAY6 0x00000040
|
||||
#define WGL_SWAP_OVERLAY7 0x00000080
|
||||
#define WGL_SWAP_OVERLAY8 0x00000100
|
||||
#define WGL_SWAP_OVERLAY9 0x00000200
|
||||
#define WGL_SWAP_UNDEFINED_ARB 0x202A
|
||||
#define WGL_SWAP_UNDERLAY1 0x00010000
|
||||
#define WGL_SWAP_UNDERLAY10 0x02000000
|
||||
#define WGL_SWAP_UNDERLAY11 0x04000000
|
||||
#define WGL_SWAP_UNDERLAY12 0x08000000
|
||||
#define WGL_SWAP_UNDERLAY13 0x10000000
|
||||
#define WGL_SWAP_UNDERLAY14 0x20000000
|
||||
#define WGL_SWAP_UNDERLAY15 0x40000000
|
||||
#define WGL_SWAP_UNDERLAY2 0x00020000
|
||||
#define WGL_SWAP_UNDERLAY3 0x00040000
|
||||
#define WGL_SWAP_UNDERLAY4 0x00080000
|
||||
#define WGL_SWAP_UNDERLAY5 0x00100000
|
||||
#define WGL_SWAP_UNDERLAY6 0x00200000
|
||||
#define WGL_SWAP_UNDERLAY7 0x00400000
|
||||
#define WGL_SWAP_UNDERLAY8 0x00800000
|
||||
#define WGL_SWAP_UNDERLAY9 0x01000000
|
||||
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
|
||||
#define WGL_TRANSPARENT_ARB 0x200A
|
||||
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
|
||||
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
|
||||
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
|
||||
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
|
||||
#define WGL_TYPE_COLORINDEX_ARB 0x202C
|
||||
#define WGL_TYPE_RGBA_ARB 0x202B
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct _GPU_DEVICE {
|
||||
DWORD cb;
|
||||
CHAR DeviceName[32];
|
||||
CHAR DeviceString[128];
|
||||
DWORD Flags;
|
||||
RECT rcVirtualScreen;
|
||||
};
|
||||
DECLARE_HANDLE(HPBUFFERARB);
|
||||
DECLARE_HANDLE(HPBUFFEREXT);
|
||||
DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
|
||||
DECLARE_HANDLE(HPVIDEODEV);
|
||||
DECLARE_HANDLE(HPGPUNV);
|
||||
DECLARE_HANDLE(HGPUNV);
|
||||
DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
|
||||
typedef struct _GPU_DEVICE GPU_DEVICE;
|
||||
typedef struct _GPU_DEVICE *PGPU_DEVICE;
|
||||
|
||||
|
||||
#define WGL_VERSION_1_0 1
|
||||
GLAD_API_CALL int SF_GLAD_WGL_VERSION_1_0;
|
||||
#define WGL_ARB_create_context 1
|
||||
GLAD_API_CALL int SF_GLAD_WGL_ARB_create_context;
|
||||
#define WGL_ARB_create_context_profile 1
|
||||
GLAD_API_CALL int SF_GLAD_WGL_ARB_create_context_profile;
|
||||
#define WGL_ARB_extensions_string 1
|
||||
GLAD_API_CALL int SF_GLAD_WGL_ARB_extensions_string;
|
||||
#define WGL_ARB_framebuffer_sRGB 1
|
||||
GLAD_API_CALL int SF_GLAD_WGL_ARB_framebuffer_sRGB;
|
||||
#define WGL_ARB_multisample 1
|
||||
GLAD_API_CALL int SF_GLAD_WGL_ARB_multisample;
|
||||
#define WGL_ARB_pbuffer 1
|
||||
GLAD_API_CALL int SF_GLAD_WGL_ARB_pbuffer;
|
||||
#define WGL_ARB_pixel_format 1
|
||||
GLAD_API_CALL int SF_GLAD_WGL_ARB_pixel_format;
|
||||
#define WGL_EXT_extensions_string 1
|
||||
GLAD_API_CALL int SF_GLAD_WGL_EXT_extensions_string;
|
||||
#define WGL_EXT_framebuffer_sRGB 1
|
||||
GLAD_API_CALL int SF_GLAD_WGL_EXT_framebuffer_sRGB;
|
||||
#define WGL_EXT_swap_control 1
|
||||
GLAD_API_CALL int SF_GLAD_WGL_EXT_swap_control;
|
||||
|
||||
|
||||
typedef int (GLAD_API_PTR *PFNCHOOSEPIXELFORMATPROC)(HDC hDc, const PIXELFORMATDESCRIPTOR * pPfd);
|
||||
typedef int (GLAD_API_PTR *PFNDESCRIBEPIXELFORMATPROC)(HDC hdc, int ipfd, UINT cjpfd, const PIXELFORMATDESCRIPTOR * ppfd);
|
||||
typedef UINT (GLAD_API_PTR *PFNGETENHMETAFILEPIXELFORMATPROC)(HENHMETAFILE hemf, const PIXELFORMATDESCRIPTOR * ppfd);
|
||||
typedef int (GLAD_API_PTR *PFNGETPIXELFORMATPROC)(HDC hdc);
|
||||
typedef BOOL (GLAD_API_PTR *PFNSETPIXELFORMATPROC)(HDC hdc, int ipfd, const PIXELFORMATDESCRIPTOR * ppfd);
|
||||
typedef BOOL (GLAD_API_PTR *PFNSWAPBUFFERSPROC)(HDC hdc);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLCHOOSEPIXELFORMATARBPROC)(HDC hdc, const int * piAttribIList, const FLOAT * pfAttribFList, UINT nMaxFormats, int * piFormats, UINT * nNumFormats);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLCOPYCONTEXTPROC)(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask);
|
||||
typedef HGLRC (GLAD_API_PTR *PFNWGLCREATECONTEXTPROC)(HDC hDc);
|
||||
typedef HGLRC (GLAD_API_PTR *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hDC, HGLRC hShareContext, const int * attribList);
|
||||
typedef HGLRC (GLAD_API_PTR *PFNWGLCREATELAYERCONTEXTPROC)(HDC hDc, int level);
|
||||
typedef HPBUFFERARB (GLAD_API_PTR *PFNWGLCREATEPBUFFERARBPROC)(HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int * piAttribList);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLDELETECONTEXTPROC)(HGLRC oldContext);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLDESCRIBELAYERPLANEPROC)(HDC hDc, int pixelFormat, int layerPlane, UINT nBytes, const LAYERPLANEDESCRIPTOR * plpd);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLDESTROYPBUFFERARBPROC)(HPBUFFERARB hPbuffer);
|
||||
typedef HGLRC (GLAD_API_PTR *PFNWGLGETCURRENTCONTEXTPROC)(void);
|
||||
typedef HDC (GLAD_API_PTR *PFNWGLGETCURRENTDCPROC)(void);
|
||||
typedef const char * (GLAD_API_PTR *PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC hdc);
|
||||
typedef const char * (GLAD_API_PTR *PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);
|
||||
typedef int (GLAD_API_PTR *PFNWGLGETLAYERPALETTEENTRIESPROC)(HDC hdc, int iLayerPlane, int iStart, int cEntries, const COLORREF * pcr);
|
||||
typedef HDC (GLAD_API_PTR *PFNWGLGETPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLGETPIXELFORMATATTRIBFVARBPROC)(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int * piAttributes, FLOAT * pfValues);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int * piAttributes, int * piValues);
|
||||
typedef PROC (GLAD_API_PTR *PFNWGLGETPROCADDRESSPROC)(LPCSTR lpszProc);
|
||||
typedef int (GLAD_API_PTR *PFNWGLGETSWAPINTERVALEXTPROC)(void);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLMAKECURRENTPROC)(HDC hDc, HGLRC newContext);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLQUERYPBUFFERARBPROC)(HPBUFFERARB hPbuffer, int iAttribute, int * piValue);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLREALIZELAYERPALETTEPROC)(HDC hdc, int iLayerPlane, BOOL bRealize);
|
||||
typedef int (GLAD_API_PTR *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer, HDC hDC);
|
||||
typedef int (GLAD_API_PTR *PFNWGLSETLAYERPALETTEENTRIESPROC)(HDC hdc, int iLayerPlane, int iStart, int cEntries, const COLORREF * pcr);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLSHARELISTSPROC)(HGLRC hrcSrvShare, HGLRC hrcSrvSource);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLSWAPINTERVALEXTPROC)(int interval);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLSWAPLAYERBUFFERSPROC)(HDC hdc, UINT fuFlags);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLUSEFONTBITMAPSPROC)(HDC hDC, DWORD first, DWORD count, DWORD listBase);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLUSEFONTBITMAPSAPROC)(HDC hDC, DWORD first, DWORD count, DWORD listBase);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLUSEFONTBITMAPSWPROC)(HDC hDC, DWORD first, DWORD count, DWORD listBase);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLUSEFONTOUTLINESPROC)(HDC hDC, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLUSEFONTOUTLINESAPROC)(HDC hDC, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf);
|
||||
typedef BOOL (GLAD_API_PTR *PFNWGLUSEFONTOUTLINESWPROC)(HDC hDC, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf);
|
||||
|
||||
GLAD_API_CALL PFNWGLCHOOSEPIXELFORMATARBPROC sf_glad_wglChoosePixelFormatARB;
|
||||
#define wglChoosePixelFormatARB sf_glad_wglChoosePixelFormatARB
|
||||
GLAD_API_CALL PFNWGLCREATECONTEXTATTRIBSARBPROC sf_glad_wglCreateContextAttribsARB;
|
||||
#define wglCreateContextAttribsARB sf_glad_wglCreateContextAttribsARB
|
||||
GLAD_API_CALL PFNWGLCREATEPBUFFERARBPROC sf_glad_wglCreatePbufferARB;
|
||||
#define wglCreatePbufferARB sf_glad_wglCreatePbufferARB
|
||||
GLAD_API_CALL PFNWGLDESTROYPBUFFERARBPROC sf_glad_wglDestroyPbufferARB;
|
||||
#define wglDestroyPbufferARB sf_glad_wglDestroyPbufferARB
|
||||
GLAD_API_CALL PFNWGLGETEXTENSIONSSTRINGARBPROC sf_glad_wglGetExtensionsStringARB;
|
||||
#define wglGetExtensionsStringARB sf_glad_wglGetExtensionsStringARB
|
||||
GLAD_API_CALL PFNWGLGETEXTENSIONSSTRINGEXTPROC sf_glad_wglGetExtensionsStringEXT;
|
||||
#define wglGetExtensionsStringEXT sf_glad_wglGetExtensionsStringEXT
|
||||
GLAD_API_CALL PFNWGLGETPBUFFERDCARBPROC sf_glad_wglGetPbufferDCARB;
|
||||
#define wglGetPbufferDCARB sf_glad_wglGetPbufferDCARB
|
||||
GLAD_API_CALL PFNWGLGETPIXELFORMATATTRIBFVARBPROC sf_glad_wglGetPixelFormatAttribfvARB;
|
||||
#define wglGetPixelFormatAttribfvARB sf_glad_wglGetPixelFormatAttribfvARB
|
||||
GLAD_API_CALL PFNWGLGETPIXELFORMATATTRIBIVARBPROC sf_glad_wglGetPixelFormatAttribivARB;
|
||||
#define wglGetPixelFormatAttribivARB sf_glad_wglGetPixelFormatAttribivARB
|
||||
GLAD_API_CALL PFNWGLGETSWAPINTERVALEXTPROC sf_glad_wglGetSwapIntervalEXT;
|
||||
#define wglGetSwapIntervalEXT sf_glad_wglGetSwapIntervalEXT
|
||||
GLAD_API_CALL PFNWGLQUERYPBUFFERARBPROC sf_glad_wglQueryPbufferARB;
|
||||
#define wglQueryPbufferARB sf_glad_wglQueryPbufferARB
|
||||
GLAD_API_CALL PFNWGLRELEASEPBUFFERDCARBPROC sf_glad_wglReleasePbufferDCARB;
|
||||
#define wglReleasePbufferDCARB sf_glad_wglReleasePbufferDCARB
|
||||
GLAD_API_CALL PFNWGLSWAPINTERVALEXTPROC sf_glad_wglSwapIntervalEXT;
|
||||
#define wglSwapIntervalEXT sf_glad_wglSwapIntervalEXT
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Source */
|
||||
#ifdef SF_GLAD_WGL_IMPLEMENTATION
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef GLAD_IMPL_UTIL_C_
|
||||
#define GLAD_IMPL_UTIL_C_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define GLAD_IMPL_UTIL_SSCANF sscanf_s
|
||||
#else
|
||||
#define GLAD_IMPL_UTIL_SSCANF sscanf
|
||||
#endif
|
||||
|
||||
#endif /* GLAD_IMPL_UTIL_C_ */
|
||||
|
||||
|
||||
int SF_GLAD_WGL_VERSION_1_0 = 0;
|
||||
int SF_GLAD_WGL_ARB_create_context = 0;
|
||||
int SF_GLAD_WGL_ARB_create_context_profile = 0;
|
||||
int SF_GLAD_WGL_ARB_extensions_string = 0;
|
||||
int SF_GLAD_WGL_ARB_framebuffer_sRGB = 0;
|
||||
int SF_GLAD_WGL_ARB_multisample = 0;
|
||||
int SF_GLAD_WGL_ARB_pbuffer = 0;
|
||||
int SF_GLAD_WGL_ARB_pixel_format = 0;
|
||||
int SF_GLAD_WGL_EXT_extensions_string = 0;
|
||||
int SF_GLAD_WGL_EXT_framebuffer_sRGB = 0;
|
||||
int SF_GLAD_WGL_EXT_swap_control = 0;
|
||||
|
||||
|
||||
|
||||
PFNWGLCHOOSEPIXELFORMATARBPROC sf_glad_wglChoosePixelFormatARB = NULL;
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC sf_glad_wglCreateContextAttribsARB = NULL;
|
||||
PFNWGLCREATEPBUFFERARBPROC sf_glad_wglCreatePbufferARB = NULL;
|
||||
PFNWGLDESTROYPBUFFERARBPROC sf_glad_wglDestroyPbufferARB = NULL;
|
||||
PFNWGLGETEXTENSIONSSTRINGARBPROC sf_glad_wglGetExtensionsStringARB = NULL;
|
||||
PFNWGLGETEXTENSIONSSTRINGEXTPROC sf_glad_wglGetExtensionsStringEXT = NULL;
|
||||
PFNWGLGETPBUFFERDCARBPROC sf_glad_wglGetPbufferDCARB = NULL;
|
||||
PFNWGLGETPIXELFORMATATTRIBFVARBPROC sf_glad_wglGetPixelFormatAttribfvARB = NULL;
|
||||
PFNWGLGETPIXELFORMATATTRIBIVARBPROC sf_glad_wglGetPixelFormatAttribivARB = NULL;
|
||||
PFNWGLGETSWAPINTERVALEXTPROC sf_glad_wglGetSwapIntervalEXT = NULL;
|
||||
PFNWGLQUERYPBUFFERARBPROC sf_glad_wglQueryPbufferARB = NULL;
|
||||
PFNWGLRELEASEPBUFFERDCARBPROC sf_glad_wglReleasePbufferDCARB = NULL;
|
||||
PFNWGLSWAPINTERVALEXTPROC sf_glad_wglSwapIntervalEXT = NULL;
|
||||
|
||||
|
||||
static void sf_glad_wgl_load_WGL_ARB_create_context(GLADuserptrloadfunc load, void *userptr) {
|
||||
if(!SF_GLAD_WGL_ARB_create_context) return;
|
||||
sf_glad_wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) load(userptr, "wglCreateContextAttribsARB");
|
||||
}
|
||||
static void sf_glad_wgl_load_WGL_ARB_extensions_string(GLADuserptrloadfunc load, void *userptr) {
|
||||
if(!SF_GLAD_WGL_ARB_extensions_string) return;
|
||||
sf_glad_wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) load(userptr, "wglGetExtensionsStringARB");
|
||||
}
|
||||
static void sf_glad_wgl_load_WGL_ARB_pbuffer(GLADuserptrloadfunc load, void *userptr) {
|
||||
if(!SF_GLAD_WGL_ARB_pbuffer) return;
|
||||
sf_glad_wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC) load(userptr, "wglCreatePbufferARB");
|
||||
sf_glad_wglDestroyPbufferARB = (PFNWGLDESTROYPBUFFERARBPROC) load(userptr, "wglDestroyPbufferARB");
|
||||
sf_glad_wglGetPbufferDCARB = (PFNWGLGETPBUFFERDCARBPROC) load(userptr, "wglGetPbufferDCARB");
|
||||
sf_glad_wglQueryPbufferARB = (PFNWGLQUERYPBUFFERARBPROC) load(userptr, "wglQueryPbufferARB");
|
||||
sf_glad_wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC) load(userptr, "wglReleasePbufferDCARB");
|
||||
}
|
||||
static void sf_glad_wgl_load_WGL_ARB_pixel_format(GLADuserptrloadfunc load, void *userptr) {
|
||||
if(!SF_GLAD_WGL_ARB_pixel_format) return;
|
||||
sf_glad_wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC) load(userptr, "wglChoosePixelFormatARB");
|
||||
sf_glad_wglGetPixelFormatAttribfvARB = (PFNWGLGETPIXELFORMATATTRIBFVARBPROC) load(userptr, "wglGetPixelFormatAttribfvARB");
|
||||
sf_glad_wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC) load(userptr, "wglGetPixelFormatAttribivARB");
|
||||
}
|
||||
static void sf_glad_wgl_load_WGL_EXT_extensions_string(GLADuserptrloadfunc load, void *userptr) {
|
||||
if(!SF_GLAD_WGL_EXT_extensions_string) return;
|
||||
sf_glad_wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC) load(userptr, "wglGetExtensionsStringEXT");
|
||||
}
|
||||
static void sf_glad_wgl_load_WGL_EXT_swap_control(GLADuserptrloadfunc load, void *userptr) {
|
||||
if(!SF_GLAD_WGL_EXT_swap_control) return;
|
||||
sf_glad_wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC) load(userptr, "wglGetSwapIntervalEXT");
|
||||
sf_glad_wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) load(userptr, "wglSwapIntervalEXT");
|
||||
}
|
||||
|
||||
|
||||
static void sf_glad_wgl_resolve_aliases(void) {
|
||||
}
|
||||
|
||||
static int sf_glad_wgl_has_extension(HDC hdc, const char *ext) {
|
||||
const char *terminator;
|
||||
const char *loc;
|
||||
const char *extensions;
|
||||
|
||||
if(wglGetExtensionsStringEXT == NULL && wglGetExtensionsStringARB == NULL)
|
||||
return 0;
|
||||
|
||||
if(wglGetExtensionsStringARB == NULL || hdc == INVALID_HANDLE_VALUE)
|
||||
extensions = wglGetExtensionsStringEXT();
|
||||
else
|
||||
extensions = wglGetExtensionsStringARB(hdc);
|
||||
|
||||
if(extensions == NULL || ext == NULL)
|
||||
return 0;
|
||||
|
||||
while(1) {
|
||||
loc = strstr(extensions, ext);
|
||||
if(loc == NULL)
|
||||
break;
|
||||
|
||||
terminator = loc + strlen(ext);
|
||||
if((loc == extensions || *(loc - 1) == ' ') &&
|
||||
(*terminator == ' ' || *terminator == '\0'))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
extensions = terminator;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GLADapiproc sf_glad_wgl_get_proc_from_userptr(void *userptr, const char* name) {
|
||||
return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
|
||||
}
|
||||
|
||||
static int sf_glad_wgl_find_extensions_wgl(HDC hdc) {
|
||||
SF_GLAD_WGL_ARB_create_context = sf_glad_wgl_has_extension(hdc, "WGL_ARB_create_context");
|
||||
SF_GLAD_WGL_ARB_create_context_profile = sf_glad_wgl_has_extension(hdc, "WGL_ARB_create_context_profile");
|
||||
SF_GLAD_WGL_ARB_extensions_string = sf_glad_wgl_has_extension(hdc, "WGL_ARB_extensions_string");
|
||||
SF_GLAD_WGL_ARB_framebuffer_sRGB = sf_glad_wgl_has_extension(hdc, "WGL_ARB_framebuffer_sRGB");
|
||||
SF_GLAD_WGL_ARB_multisample = sf_glad_wgl_has_extension(hdc, "WGL_ARB_multisample");
|
||||
SF_GLAD_WGL_ARB_pbuffer = sf_glad_wgl_has_extension(hdc, "WGL_ARB_pbuffer");
|
||||
SF_GLAD_WGL_ARB_pixel_format = sf_glad_wgl_has_extension(hdc, "WGL_ARB_pixel_format");
|
||||
SF_GLAD_WGL_EXT_extensions_string = sf_glad_wgl_has_extension(hdc, "WGL_EXT_extensions_string");
|
||||
SF_GLAD_WGL_EXT_framebuffer_sRGB = sf_glad_wgl_has_extension(hdc, "WGL_EXT_framebuffer_sRGB");
|
||||
SF_GLAD_WGL_EXT_swap_control = sf_glad_wgl_has_extension(hdc, "WGL_EXT_swap_control");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int sf_glad_wgl_find_core_wgl(void) {
|
||||
int major = 1, minor = 0;
|
||||
SF_GLAD_WGL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
|
||||
return GLAD_MAKE_VERSION(major, minor);
|
||||
}
|
||||
|
||||
static int gladLoadWGLUserPtr(HDC hdc, GLADuserptrloadfunc load, void *userptr) {
|
||||
int version;
|
||||
wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) load(userptr, "wglGetExtensionsStringARB");
|
||||
wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC) load(userptr, "wglGetExtensionsStringEXT");
|
||||
if(wglGetExtensionsStringARB == NULL && wglGetExtensionsStringEXT == NULL) return 0;
|
||||
version = sf_glad_wgl_find_core_wgl();
|
||||
|
||||
|
||||
if (!sf_glad_wgl_find_extensions_wgl(hdc)) return 0;
|
||||
sf_glad_wgl_load_WGL_ARB_create_context(load, userptr);
|
||||
sf_glad_wgl_load_WGL_ARB_extensions_string(load, userptr);
|
||||
sf_glad_wgl_load_WGL_ARB_pbuffer(load, userptr);
|
||||
sf_glad_wgl_load_WGL_ARB_pixel_format(load, userptr);
|
||||
sf_glad_wgl_load_WGL_EXT_extensions_string(load, userptr);
|
||||
sf_glad_wgl_load_WGL_EXT_swap_control(load, userptr);
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
static int gladLoadWGL(HDC hdc, GLADloadfunc load) {
|
||||
return gladLoadWGLUserPtr(hdc, sf_glad_wgl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
|
||||
}
|
||||
|
||||
|
||||
#ifdef SF_GLAD_WGL
|
||||
|
||||
static int gladLoaderLoadWGL(HDC hdc) {
|
||||
return gladLoadWGLUserPtr(hdc, sf_glad_wgl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) wglGetProcAddress);
|
||||
}
|
||||
|
||||
|
||||
#endif /* SF_GLAD_WGL */
|
||||
|
||||
#endif /* SF_GLAD_WGL_IMPLEMENTATION */
|
||||
|
117
extlibs/headers/mingw/_mingw_dxhelper.h
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER within this package.
|
||||
*/
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS)
|
||||
#define NONAMELESSUNION 1
|
||||
#endif
|
||||
#if defined(NONAMELESSSTRUCT) && \
|
||||
!defined(NONAMELESSUNION)
|
||||
#define NONAMELESSUNION 1
|
||||
#endif
|
||||
#if defined(NONAMELESSUNION) && \
|
||||
!defined(NONAMELESSSTRUCT)
|
||||
#define NONAMELESSSTRUCT 1
|
||||
#endif
|
||||
#if !defined(__GNU_EXTENSION)
|
||||
#if defined(__GNUC__) || defined(__GNUG__)
|
||||
#define __GNU_EXTENSION __extension__
|
||||
#else
|
||||
#define __GNU_EXTENSION
|
||||
#endif
|
||||
#endif /* __extension__ */
|
||||
|
||||
#ifndef __ANONYMOUS_DEFINED
|
||||
#define __ANONYMOUS_DEFINED
|
||||
#if defined(__GNUC__) || defined(__GNUG__)
|
||||
#define _ANONYMOUS_UNION __extension__
|
||||
#define _ANONYMOUS_STRUCT __extension__
|
||||
#else
|
||||
#define _ANONYMOUS_UNION
|
||||
#define _ANONYMOUS_STRUCT
|
||||
#endif
|
||||
#ifndef NONAMELESSUNION
|
||||
#define _UNION_NAME(x)
|
||||
#define _STRUCT_NAME(x)
|
||||
#else /* NONAMELESSUNION */
|
||||
#define _UNION_NAME(x) x
|
||||
#define _STRUCT_NAME(x) x
|
||||
#endif
|
||||
#endif /* __ANONYMOUS_DEFINED */
|
||||
|
||||
#ifndef DUMMYUNIONNAME
|
||||
# ifdef NONAMELESSUNION
|
||||
# define DUMMYUNIONNAME u
|
||||
# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */
|
||||
# define DUMMYUNIONNAME2 u2
|
||||
# define DUMMYUNIONNAME3 u3
|
||||
# define DUMMYUNIONNAME4 u4
|
||||
# define DUMMYUNIONNAME5 u5
|
||||
# define DUMMYUNIONNAME6 u6
|
||||
# define DUMMYUNIONNAME7 u7
|
||||
# define DUMMYUNIONNAME8 u8
|
||||
# define DUMMYUNIONNAME9 u9
|
||||
# else /* NONAMELESSUNION */
|
||||
# define DUMMYUNIONNAME
|
||||
# define DUMMYUNIONNAME1 /* Wine uses this variant */
|
||||
# define DUMMYUNIONNAME2
|
||||
# define DUMMYUNIONNAME3
|
||||
# define DUMMYUNIONNAME4
|
||||
# define DUMMYUNIONNAME5
|
||||
# define DUMMYUNIONNAME6
|
||||
# define DUMMYUNIONNAME7
|
||||
# define DUMMYUNIONNAME8
|
||||
# define DUMMYUNIONNAME9
|
||||
# endif
|
||||
#endif /* DUMMYUNIONNAME */
|
||||
|
||||
#if !defined(DUMMYUNIONNAME1) /* MinGW does not define this one */
|
||||
# ifdef NONAMELESSUNION
|
||||
# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */
|
||||
# else
|
||||
# define DUMMYUNIONNAME1 /* Wine uses this variant */
|
||||
# endif
|
||||
#endif /* DUMMYUNIONNAME1 */
|
||||
|
||||
#ifndef DUMMYSTRUCTNAME
|
||||
# ifdef NONAMELESSUNION
|
||||
# define DUMMYSTRUCTNAME s
|
||||
# define DUMMYSTRUCTNAME1 s1 /* Wine uses this variant */
|
||||
# define DUMMYSTRUCTNAME2 s2
|
||||
# define DUMMYSTRUCTNAME3 s3
|
||||
# define DUMMYSTRUCTNAME4 s4
|
||||
# define DUMMYSTRUCTNAME5 s5
|
||||
# else
|
||||
# define DUMMYSTRUCTNAME
|
||||
# define DUMMYSTRUCTNAME1 /* Wine uses this variant */
|
||||
# define DUMMYSTRUCTNAME2
|
||||
# define DUMMYSTRUCTNAME3
|
||||
# define DUMMYSTRUCTNAME4
|
||||
# define DUMMYSTRUCTNAME5
|
||||
# endif
|
||||
#endif /* DUMMYSTRUCTNAME */
|
||||
|
||||
/* These are for compatibility with the Wine source tree */
|
||||
|
||||
#ifndef WINELIB_NAME_AW
|
||||
# ifdef __MINGW_NAME_AW
|
||||
# define WINELIB_NAME_AW __MINGW_NAME_AW
|
||||
# else
|
||||
# ifdef UNICODE
|
||||
# define WINELIB_NAME_AW(func) func##W
|
||||
# else
|
||||
# define WINELIB_NAME_AW(func) func##A
|
||||
# endif
|
||||
# endif
|
||||
#endif /* WINELIB_NAME_AW */
|
||||
|
||||
#ifndef DECL_WINELIB_TYPE_AW
|
||||
# ifdef __MINGW_TYPEDEF_AW
|
||||
# define DECL_WINELIB_TYPE_AW __MINGW_TYPEDEF_AW
|
||||
# else
|
||||
# define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
|
||||
# endif
|
||||
#endif /* DECL_WINELIB_TYPE_AW */
|
||||
|