Compare commits
352 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
639ce09c9d | ||
![]() |
3632b160d5 | ||
![]() |
f3d144bf0e | ||
![]() |
82e4a12fd3 | ||
![]() |
74a0814a8f | ||
![]() |
08f2725c8b | ||
![]() |
e5030e28f6 | ||
![]() |
4c15515ba6 | ||
![]() |
7dc66d2d3f | ||
![]() |
864511fe57 | ||
![]() |
2875f4cf11 | ||
![]() |
6e812cf147 | ||
![]() |
103044926b | ||
![]() |
6efb89c51e | ||
![]() |
bff3bb758a | ||
![]() |
b80ec381c8 | ||
![]() |
98273f0152 | ||
![]() |
4d4d9b0170 | ||
![]() |
5b37178af9 | ||
![]() |
096fd6f2c3 | ||
![]() |
40551958dd | ||
![]() |
98de843827 | ||
![]() |
546254b439 | ||
![]() |
475a1a263d | ||
![]() |
c5f65c0b16 | ||
![]() |
d127d8e9f8 | ||
![]() |
0c631e6b5a | ||
![]() |
7d7c6fc42d | ||
![]() |
dfc4baaa35 | ||
![]() |
292499bdeb | ||
![]() |
971a7419ec | ||
![]() |
cadcc05a84 | ||
![]() |
b5b4da1d05 | ||
![]() |
ea72c9e5af | ||
![]() |
f0ac73ef8b | ||
![]() |
4e367d2db8 | ||
![]() |
2f3011c457 | ||
![]() |
90d35b2ac4 | ||
![]() |
1c9537b5e7 | ||
![]() |
c19bd3eb04 | ||
![]() |
5774d31893 | ||
![]() |
d2c0d1bfef | ||
![]() |
9e2c418a92 | ||
![]() |
eb296a5605 | ||
![]() |
43178f3488 | ||
![]() |
414bb6018b | ||
![]() |
758a774173 | ||
![]() |
240ecd6332 | ||
![]() |
d34c1285e0 | ||
![]() |
22bf279672 | ||
![]() |
3c02a9fc66 | ||
![]() |
f939378764 | ||
![]() |
e23fb6e1d5 | ||
![]() |
c6d188a09a | ||
![]() |
50088bf49b | ||
![]() |
7c80a517b4 | ||
![]() |
8651e14955 | ||
![]() |
fa36c5294a | ||
![]() |
f981daf1df | ||
![]() |
7f040009ee | ||
![]() |
0ab3d85aa0 | ||
![]() |
4ec4481eca | ||
![]() |
b129ba09a6 | ||
![]() |
311d8b92f5 | ||
![]() |
103bc7dfc6 | ||
![]() |
d881c73257 | ||
![]() |
1f1d8eeeeb | ||
![]() |
4582d548b1 | ||
![]() |
b7d7704098 | ||
![]() |
6c96fa6301 | ||
![]() |
c598701873 | ||
![]() |
1d354bc704 | ||
![]() |
7c36237048 | ||
![]() |
91586fd7bc | ||
![]() |
c3aeaf4a49 | ||
![]() |
61747508b0 | ||
![]() |
33c830353b | ||
![]() |
74fd0e7ca4 | ||
![]() |
7b971e0623 | ||
![]() |
1727bbabb1 | ||
![]() |
276974de05 | ||
![]() |
fec0a4f2e3 | ||
![]() |
bce7a7b576 | ||
![]() |
7dedb84fd0 | ||
![]() |
d0166c9d45 | ||
![]() |
a1d9c33995 | ||
![]() |
c8b378ae50 | ||
![]() |
afe81d94ce | ||
![]() |
64207b11c0 | ||
![]() |
1f3bbf457c | ||
![]() |
859b1cf574 | ||
![]() |
dbfd8d713f | ||
![]() |
bd957c7442 | ||
![]() |
b1d3810011 | ||
![]() |
59ebe1b7c3 | ||
![]() |
965cc8ab6f | ||
![]() |
e1e036a602 | ||
![]() |
1630597f08 | ||
![]() |
1ff8947864 | ||
![]() |
c3b948b1b2 | ||
![]() |
d573a5ad60 | ||
![]() |
0e135118fd | ||
![]() |
d6f56c0d5c | ||
![]() |
75ba5aca55 | ||
![]() |
179231504a | ||
![]() |
372e4a1139 | ||
![]() |
64804f30e6 | ||
![]() |
0c01c08718 | ||
![]() |
59fd261491 | ||
![]() |
7d0e09ff4c | ||
![]() |
b588af5ce2 | ||
![]() |
b48d225a43 | ||
![]() |
817ae07505 | ||
![]() |
31cd4a1a48 | ||
![]() |
5b21f6cf6f | ||
![]() |
0e6458cfee | ||
![]() |
61a1c59472 | ||
![]() |
9688c677de | ||
![]() |
c7d6a44e33 | ||
![]() |
b1b4a11bdb | ||
![]() |
0c1bc039a2 | ||
![]() |
afc4181752 | ||
![]() |
fcef578c9a | ||
![]() |
2536bea379 | ||
![]() |
129c890a28 | ||
![]() |
8f4b53384c | ||
![]() |
d873314c27 | ||
![]() |
0148432588 | ||
![]() |
dbff40944a | ||
![]() |
1f0cc57ec7 | ||
![]() |
f89afaa335 | ||
![]() |
8f4fa5006b | ||
![]() |
f454af08bb | ||
![]() |
559b9b8cc3 | ||
![]() |
44181baf04 | ||
![]() |
63cf43b729 | ||
![]() |
647c08ef4c | ||
![]() |
f1b624d38b | ||
![]() |
6d8cc250bd | ||
![]() |
e025e62445 | ||
![]() |
cea78e4fc1 | ||
![]() |
bd2300fed3 | ||
![]() |
ad8509732c | ||
![]() |
ff55af14f9 | ||
![]() |
ae26e083b4 | ||
![]() |
20ddc6a2bb | ||
![]() |
a752092055 | ||
![]() |
8e0cd51afb | ||
![]() |
ca69068814 | ||
![]() |
3b70b66a08 | ||
![]() |
24adca4ad0 | ||
![]() |
25d5e907ec | ||
![]() |
a1ec0a5bc3 | ||
![]() |
5cfbb53f6c | ||
![]() |
fb4265f646 | ||
![]() |
0b05169aa7 | ||
![]() |
88c2337225 | ||
![]() |
2aae62cea2 | ||
![]() |
1d3e4ef437 | ||
![]() |
542eb6f250 | ||
![]() |
bb43755a9d | ||
![]() |
eed170f852 | ||
![]() |
0f1aaa474a | ||
![]() |
a09d6fd428 | ||
![]() |
c1b9104d54 | ||
![]() |
2d6fb5c628 | ||
![]() |
245704df72 | ||
![]() |
0790171125 | ||
![]() |
aa76985c0d | ||
![]() |
281dbf5d83 | ||
![]() |
a0f9c2b1eb | ||
![]() |
7243cebad1 | ||
![]() |
0adb4b67de | ||
![]() |
0df501be91 | ||
![]() |
f11fe80180 | ||
![]() |
b8ca51fd01 | ||
![]() |
8ae8d3ac78 | ||
![]() |
f26a38a9e1 | ||
![]() |
9ea2a69bfd | ||
![]() |
ac2dbba5b7 | ||
![]() |
3a803ac95e | ||
![]() |
6884d3bc14 | ||
![]() |
8e9ff75f1c | ||
![]() |
04db494db0 | ||
![]() |
f14492432d | ||
![]() |
ec33e7d705 | ||
![]() |
6045062a05 | ||
![]() |
6324697ffd | ||
![]() |
9d103b7c2f | ||
![]() |
198d739256 | ||
![]() |
400c345f96 | ||
![]() |
23e335d933 | ||
![]() |
c51203ae7e | ||
![]() |
dff1028466 | ||
![]() |
8d81b6e4e4 | ||
![]() |
ada6668b24 | ||
![]() |
ca5f7ebd10 | ||
![]() |
0045402c99 | ||
![]() |
3ca5047c82 | ||
![]() |
af4d23aa82 | ||
![]() |
24cab8f920 | ||
![]() |
0febaa2446 | ||
![]() |
f5ebbfb6bc | ||
![]() |
847bdaf682 | ||
![]() |
76a6bf6c52 | ||
![]() |
afda1d0815 | ||
![]() |
739df34f5e | ||
![]() |
5ef6cc1fb9 | ||
![]() |
3f59bdfc76 | ||
![]() |
8b0fef6c34 | ||
![]() |
4cc12ef2b3 | ||
![]() |
cc3b8645df | ||
![]() |
8e44f7b3c7 | ||
![]() |
54e24d905a | ||
![]() |
cd616258c6 | ||
![]() |
9e7dedf5af | ||
![]() |
1dbce35247 | ||
![]() |
1841afad11 | ||
![]() |
d88523f03a | ||
![]() |
3caa044bf2 | ||
![]() |
7bd0f8b28c | ||
![]() |
d2cc5b88df | ||
![]() |
d003c23ecf | ||
![]() |
b8bd1d2ea6 | ||
![]() |
005f2ffb75 | ||
![]() |
931b672c92 | ||
![]() |
6edf15b9f9 | ||
![]() |
322cebcbaf | ||
![]() |
9393d1d76f | ||
![]() |
fe1c04d1b8 | ||
![]() |
533780aadf | ||
![]() |
0c0ff2802e | ||
![]() |
3e0de31424 | ||
![]() |
befd363966 | ||
![]() |
375adf86a6 | ||
![]() |
6985953e3d | ||
![]() |
e18e8c6276 | ||
![]() |
bbdf9f4880 | ||
![]() |
201007e426 | ||
![]() |
db98dba10f | ||
![]() |
03ca9508bf | ||
![]() |
44eedf235d | ||
![]() |
551cf50685 | ||
![]() |
6a3eca3f92 | ||
![]() |
ca9e652f8b | ||
![]() |
28a9a181cb | ||
![]() |
9459186125 | ||
![]() |
df74607479 | ||
![]() |
e659336c11 | ||
![]() |
e72b96ada1 | ||
![]() |
bd2c81d481 | ||
![]() |
564baa22d6 | ||
![]() |
b4e2f5b45c | ||
![]() |
42e64e931b | ||
![]() |
6c049fdd76 | ||
![]() |
e38d28543a | ||
![]() |
d91179f8ab | ||
![]() |
5ecee69088 | ||
![]() |
22c8ea76aa | ||
![]() |
a8e2c7de9c | ||
![]() |
deffad1701 | ||
![]() |
aab6c11ce1 | ||
![]() |
4a69c2d75e | ||
![]() |
2c219fb814 | ||
![]() |
61e0e4b4f3 | ||
![]() |
9318dc98ce | ||
![]() |
487bc613fd | ||
![]() |
9d8f15c19d | ||
![]() |
6c6d6776c0 | ||
![]() |
4cae2b8829 | ||
![]() |
4c0925067a | ||
![]() |
82491fcf6c | ||
![]() |
b9573e583f | ||
![]() |
d6c1159fce | ||
![]() |
8bc2813b0c | ||
![]() |
a0127d8300 | ||
![]() |
fd5e457bb4 | ||
![]() |
5b4197afeb | ||
![]() |
d6fee9da29 | ||
![]() |
3201bad65a | ||
![]() |
8f1d6f3850 | ||
![]() |
df50eada53 | ||
![]() |
276847eca9 | ||
![]() |
8cb324b2da | ||
![]() |
85850a955a | ||
![]() |
3b4a64f2d6 | ||
![]() |
fd2adbe62d | ||
![]() |
a7207dc6d4 | ||
![]() |
3f48ffb1b6 | ||
![]() |
18f61948ce | ||
![]() |
80bf636f81 | ||
![]() |
76aca9b0d1 | ||
![]() |
c5f7863689 | ||
![]() |
1430d01906 | ||
![]() |
6026ed61a5 | ||
![]() |
f52d2de582 | ||
![]() |
ed6962edd3 | ||
![]() |
2b5fc12036 | ||
![]() |
a5881fb9cc | ||
![]() |
c9043b5a87 | ||
![]() |
6ffc8cb799 | ||
![]() |
e4d7bbec1e | ||
![]() |
077bef4286 | ||
![]() |
6d64327a87 | ||
![]() |
cd5e2e0f17 | ||
![]() |
326fe09777 | ||
![]() |
97bf2706c4 | ||
![]() |
788049df09 | ||
![]() |
81546308cd | ||
![]() |
11612fce27 | ||
![]() |
1652943f98 | ||
![]() |
d892243d18 | ||
![]() |
f6231aa8b6 | ||
![]() |
7e32a627e8 | ||
![]() |
0958904eac | ||
![]() |
4492a70a4b | ||
![]() |
50fc4f7164 | ||
![]() |
769cf23e53 | ||
![]() |
883ed20e7c | ||
![]() |
e0a3a51b75 | ||
![]() |
6ebc3fd29a | ||
![]() |
988f5b7832 | ||
![]() |
051040af2d | ||
![]() |
ffde83d85f | ||
![]() |
36750ffb9a | ||
![]() |
7530a60abc | ||
![]() |
dd8f0765b8 | ||
![]() |
8af5f9dfe0 | ||
![]() |
51124bfb74 | ||
![]() |
97f8b85429 | ||
![]() |
f742f1289d | ||
![]() |
0be4d802ee | ||
![]() |
5616314069 | ||
![]() |
4c4b564392 | ||
![]() |
e86b4d4e03 | ||
![]() |
1be72a2e72 | ||
![]() |
09b022305f | ||
![]() |
d90a33b850 | ||
![]() |
231a69417a | ||
![]() |
7bf6becc94 | ||
![]() |
6d922b3e1f | ||
![]() |
468309d06c | ||
![]() |
f72b315cb6 | ||
![]() |
2ace360230 | ||
![]() |
a976e76ae6 | ||
![]() |
4d5d1e0434 | ||
![]() |
950f31e620 | ||
![]() |
dd50348b4d | ||
![]() |
353912b215 | ||
![]() |
eb7b5e59bb | ||
![]() |
f9277f2163 | ||
![]() |
ce56fcb1ed |
31
.gitignore
vendored
@@ -13,9 +13,10 @@ Thumbs.db
|
||||
# *.obj --> Can be confused with 3d model!
|
||||
*.pdb
|
||||
*.aps
|
||||
*.vcproj.*.user
|
||||
*.vcxproj*
|
||||
*.sln
|
||||
*.user
|
||||
# *.vcproj
|
||||
# *.vcxproj*
|
||||
# *.sln
|
||||
*.vspscc
|
||||
*_i.c
|
||||
*.i
|
||||
@@ -41,11 +42,13 @@ _ReSharper*/
|
||||
[Tt]est[Rr]esult*
|
||||
ipch/
|
||||
*.opensdf
|
||||
*.db
|
||||
*.opendb
|
||||
|
||||
# Ignore compiled binaries
|
||||
*.o
|
||||
*.exe
|
||||
!tools/rREM/rrem.exe
|
||||
!raylib.rc.o
|
||||
|
||||
# Ignore all examples files
|
||||
examples/*
|
||||
@@ -57,6 +60,7 @@ examples/*
|
||||
!examples/*.png
|
||||
# Unignore examples Makefile
|
||||
!examples/Makefile
|
||||
!examples/Makefile.Android
|
||||
|
||||
# Ignore all games files
|
||||
games/*
|
||||
@@ -68,6 +72,7 @@ games/*
|
||||
!games/*.png
|
||||
# Unignore games makefile
|
||||
!games/Makefile
|
||||
!games/Makefile.Android
|
||||
|
||||
# Ignore files build by xcode
|
||||
*.mode*v*
|
||||
@@ -84,21 +89,10 @@ xcuserdata/
|
||||
DerivedData/
|
||||
|
||||
# Visual Studio project
|
||||
project/vs2015/*.db
|
||||
project/vs2015/*.opendb
|
||||
project/vs2015.UWP/packages
|
||||
project/vs2015.UWP/*.db
|
||||
!project/vs2015/raylib.sln
|
||||
!project/vs2015/raylib/*.vcxproj
|
||||
!project/vs2015/examples/*.vcxproj
|
||||
!project/vs2017/raylib.sln
|
||||
!project/vs2017/raylib/*.vcxproj
|
||||
!project/vs2017/examples/*.vcxproj
|
||||
!project/vs2015.UWP/raylib/*.vcxproj
|
||||
!project/vs2015.UWP/*.sln
|
||||
!project/vs2015.UWP/raylib.App.UWP/*.vcxproj
|
||||
project/VS2015.UWP/packages
|
||||
project/VS2017/packages
|
||||
|
||||
# Web examples
|
||||
# Web examples
|
||||
docs/examples/web/*.html
|
||||
docs/examples/web/*/*.html
|
||||
!docs/examples/web/loader.html
|
||||
@@ -116,6 +110,7 @@ CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
TestingIfSymlinkWorks
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
|
100
.travis.yml
@@ -5,7 +5,8 @@ git:
|
||||
depth: 3
|
||||
|
||||
# TODO we could use a 32 bit Docker container for running true 32-bit tests
|
||||
# services: - docker
|
||||
services:
|
||||
- docker
|
||||
|
||||
matrix:
|
||||
include:
|
||||
@@ -15,39 +16,100 @@ matrix:
|
||||
- os: linux
|
||||
env: ARCH=amd64
|
||||
sudo: required
|
||||
- os: linux
|
||||
env: ARCH=amd64 GLFW=SYSTEM RELEASE=NO
|
||||
sudo: required
|
||||
- os: linux
|
||||
env: USE_WAYLAND=ON ARCH=amd64 RELEASE=NO
|
||||
sudo: required
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libwayland-dev
|
||||
- libxkbcommon-dev
|
||||
- libegl1-mesa-dev
|
||||
- os: osx
|
||||
env: ARCH=universal
|
||||
- os: linux
|
||||
env: ARCH=arm64-android RELEASE=NO
|
||||
sudo: required
|
||||
- os: linux
|
||||
env: ARCH=arm32-android RELEASE=NO
|
||||
sudo: required
|
||||
- os: linux
|
||||
env: ARCH=html5 RELEASE=NO
|
||||
sudo: required
|
||||
|
||||
before_script:
|
||||
|
||||
before_install:
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
|
||||
sudo apt-get install -y gcc-multilib
|
||||
libasound2-dev:$ARCH
|
||||
libxcursor-dev:$ARCH libxinerama-dev:$ARCH mesa-common-dev:$ARCH
|
||||
libx11-dev:$ARCH libxrandr-dev:$ARCH libxi-dev:$ARCH
|
||||
libgl1-mesa-dev:$ARCH libglu1-mesa-dev:$ARCH;
|
||||
export RAYLIB_PACKAGE_SUFFIX="-Linux-$ARCH";
|
||||
if [ "$ARCH" == "i386" ]; then export CFLAGS="-m32"; fi;
|
||||
if [ "$ARCH" == "amd64" ]; then export CFLAGS="-m64"; fi;
|
||||
if [ "$GLFW" == "SYSTEM" ]; then
|
||||
wget 'http://ftp.de.debian.org/debian/pool/main/g/glfw3/libglfw3_3.2.1-1_amd64.deb';
|
||||
wget 'http://ftp.de.debian.org/debian/pool/main/g/glfw3/libglfw3-dev_3.2.1-1_amd64.deb';
|
||||
sudo dpkg -i libglfw3_3.2.1-1_amd64.deb libglfw3-dev_3.2.1-1_amd64.deb;
|
||||
if [[ "$ARCH" == *-android ]]; then
|
||||
export RAYLIB_PACKAGE_SUFFIX="-Android-arm64";
|
||||
wget https://dl.google.com/android/repository/android-ndk-r17-linux-x86_64.zip;
|
||||
unzip -qq android-ndk*.zip;
|
||||
if [[ "$ARCH" == arm64-* ]]; then
|
||||
export RAYLIB_PACKAGE_SUFFIX="-Android-arm64";
|
||||
export TOOLCHAIN_ARCH=arm64;
|
||||
export PREFIX=aarch64-linux-android-;
|
||||
else
|
||||
export RAYLIB_PACKAGE_SUFFIX="-Android-arm32";
|
||||
export TOOLCHAIN_ARCH=arm;
|
||||
export PREFIX=arm-linux-androideabi-;
|
||||
fi;
|
||||
android-ndk*/build/tools/make_standalone_toolchain.py --arch $TOOLCHAIN_ARCH --api 21 --install-dir /tmp/android-toolchain;
|
||||
export PATH=/tmp/android-toolchain/bin:$PATH;
|
||||
export CC=${PREFIX}clang;
|
||||
export CXX=${PREFIX}clang++;
|
||||
export CMAKE_ARCH_ARGS='-DPLATFORM=Android';
|
||||
elif [ "$ARCH" == "html5" ]; then
|
||||
export RAYLIB_PACKAGE_SUFFIX="-html5";
|
||||
docker run --privileged=true -dit --name emscripten -v $(pwd):/src trzeci/emscripten:sdk-incoming-64bit bash;
|
||||
export CMAKE_ARCH_ARGS='-DPLATFORM=Web -DCMAKE_TOOLCHAIN_FILE=../cmake/emscripten.cmake';
|
||||
export RUNNER='docker exec -it emscripten cmake -E chdir build';
|
||||
else
|
||||
sudo apt-get install -y gcc-multilib
|
||||
libasound2-dev:$ARCH
|
||||
libxcursor-dev:$ARCH libxinerama-dev:$ARCH mesa-common-dev:$ARCH
|
||||
libx11-dev:$ARCH libxrandr-dev:$ARCH libxrandr2:$ARCH libxi-dev:$ARCH
|
||||
libgl1-mesa-dev:$ARCH libglu1-mesa-dev:$ARCH;
|
||||
if [ "$ARCH" == "i386" ]; then
|
||||
export CMAKE_ARCH_ARGS='-DCMAKE_C_FLAGS=-m32 -DCMAKE_SYSTEM_LIBRARY_PATH=/usr/lib/i386-linux-gnu';
|
||||
fi;
|
||||
export RAYLIB_PACKAGE_SUFFIX="-Linux-$ARCH";
|
||||
if [ "$GLFW" == "SYSTEM" ]; then
|
||||
wget 'http://ftp.de.debian.org/debian/pool/main/g/glfw3/libglfw3_3.2.1-1_amd64.deb';
|
||||
wget 'http://ftp.de.debian.org/debian/pool/main/g/glfw3/libglfw3-dev_3.2.1-1_amd64.deb';
|
||||
sudo dpkg -i libglfw3_3.2.1-1_amd64.deb libglfw3-dev_3.2.1-1_amd64.deb;
|
||||
fi;
|
||||
fi;
|
||||
fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||
export RAYLIB_PACKAGE_SUFFIX="-macOS";
|
||||
if [ "$GLFW" == "SYSTEM" ]; then brew update; brew install glfw; fi;
|
||||
fi
|
||||
- "$CC --version"
|
||||
- mkdir build
|
||||
- $RUNNER $CC --version
|
||||
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake -DMACOS_FATLIB=ON -DSTATIC_RAYLIB=ON -DSHARED_RAYLIB=ON -DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON -DUSE_EXTERNAL_GLFW=IF_POSSIBLE ..
|
||||
- make VERBOSE=1
|
||||
- make package
|
||||
- if test -n "${USE_WAYLAND}";
|
||||
then wget https://mirrors.kernel.org/ubuntu/pool/universe/e/extra-cmake-modules/extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb;
|
||||
sudo dpkg -i extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb;
|
||||
git clone git://anongit.freedesktop.org/wayland/wayland-protocols;
|
||||
pushd wayland-protocols;
|
||||
git checkout 1.12 && ./autogen.sh --prefix=/usr && make && sudo make install;
|
||||
popd;
|
||||
fi
|
||||
- $RUNNER cmake $CMAKE_ARCH_ARGS -DMACOS_FATLIB=ON -DSTATIC=ON -DSHARED=ON -DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON -DUSE_EXTERNAL_GLFW=IF_POSSIBLE -DUSE_WAYLAND=${USE_WAYLAND} ..
|
||||
- $RUNNER make VERBOSE=1
|
||||
- if [ "$RELEASE" != "NO" ]; then $RUNNER make package; fi;
|
||||
- sudo $RUNNER make install
|
||||
- if [[ "$ARCH" != *-android && "$ARCH" != html5 ]]; then
|
||||
pkg-config --static --libs raylib;
|
||||
nm -g release/libraylib.a | grep glfwGetProcAddress || (echo "libraylib.a doesn't contain GLFW symbols! Aborting..." && false);
|
||||
ctest --output-on-failure;
|
||||
fi
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
@@ -58,5 +120,5 @@ deploy:
|
||||
skip_cleanup: true
|
||||
on:
|
||||
repo: raysan5/raylib
|
||||
branch: develop
|
||||
branch: master
|
||||
tags: true
|
||||
|
122
CHANGELOG
@@ -1,7 +1,127 @@
|
||||
changelog
|
||||
---------
|
||||
|
||||
Current Release: raylib 1.8.0 (Oct 2017)
|
||||
Current Release: raylib 2.0.0 (July 2018)
|
||||
|
||||
-----------------------------------------------
|
||||
Release: raylib 2.0 (July 2018)
|
||||
-----------------------------------------------
|
||||
KEY CHANGES:
|
||||
- Removed external dependencies (GLFW3 and OpenAL)
|
||||
- Complete redesign of audio module to use mini_al audio library
|
||||
- Support AppVeyor and Travis CI (continuous integration) building
|
||||
- Reviewed raymath.h for better consistency and performance (inlining)
|
||||
- Refactor all #define SUPPORT_* into a single config.h
|
||||
- Support TCC compiler (32bit and 64bit)
|
||||
|
||||
Detailed changes:
|
||||
[build] REMOVED: GitHub develop branch
|
||||
[build] REMOVED: External dependencies GLFW and OpenAL
|
||||
[build] ADDED: Android 64bit ARM support
|
||||
[build] ADDED: FreeBSD, OpenBSD, NetBSD, Dragon Fly OS support
|
||||
[build] ADDED: Universal Windows Platform (UWP) support
|
||||
[build] ADDED: Wayland Linux desktop support
|
||||
[build] ADDED: AppVeyor CI for automatic Windows builds
|
||||
[build] ADDED: Travis CI for automatic Linux/macOS builds
|
||||
[build] ADDED: rglfw (GLFW3 module) to avoid external dependency
|
||||
[build] ADDED: VS2017 UWP project
|
||||
[build] ADDED: Builder project template
|
||||
[build] ADDED: Compiler memory sanitizer for better debug
|
||||
[build] ADDED: CMake package target and CI auto-deploy tags
|
||||
[build] ADDED: DEBUG library building support
|
||||
[build] ADDED: Notepad++ NppExec scripts
|
||||
[build] REVIEWED: VS2015 and VS2017 projects
|
||||
[build] REVIEWED: Android APK build pipeline
|
||||
[core] REVIEWED: Window creation hints to support transparent windows
|
||||
[core] Unified InitWindow() between platforms
|
||||
[core] Export Android main entry point
|
||||
[core] RENAMED: Begin3dMode() to BeginMode3D()
|
||||
[core] RENAMED: End3dMode() to EndMode3D()
|
||||
[core] RENAMED: Begin2dMode() to BeginMode2D()
|
||||
[core] RENAMED: End2dMode() to EndMode2D()
|
||||
[core] RENAMED: struct Camera to Camera3D
|
||||
[core] RENAMED: struct SpriteFont to Font -> plus all required functions!
|
||||
[core] RENAMED: enum TextureFormat to PixelFormat
|
||||
[core] REVIEWED: Rectangle params int to float
|
||||
[core] REVIEWED: timming system for macOS
|
||||
[core] REMOVED: ColorToFloat()
|
||||
[core] ADDED: GetCurrentTime() on macOS
|
||||
[core] ADDED: GetTime()
|
||||
[core] ADDED: struct Vector4
|
||||
[core] ADDED: SetTraceLog() to define trace log messages type
|
||||
[core] ADDED: GetFileName() to get filename from path string
|
||||
[core] ADDED: ColorToHSV()
|
||||
[core] ADDED: ColorNormalize()
|
||||
[core] ADDED: SetWindowSize() to scale Windows in runtime
|
||||
[core] ADDED: SetMouseScale() to scale mouse input
|
||||
[core] ADDED: key definitions - KEY_GRAVE, KEY_SLASH, KEY_BACKSLASH
|
||||
[core] RENAMED: GetHexValue() to ColorToInt()
|
||||
[core] REVIEWED: Fade()
|
||||
[core] REVIEWED: InitWindow() to avoid void pointer (safety)
|
||||
[core] Support camera 3d orthographic projection mode
|
||||
[shapes] ADDED: DrawRectangleLinesEx()
|
||||
[textures] Improved pixel formats support (32bit channels)
|
||||
[textures] Improved textures support for OpenGL 2.1
|
||||
[textures] REMOVED: DrawRectangleT() --> Added support to DrawRectangle()
|
||||
[textures] ADDED: GetPixelDataSize(); pixel data size in bytes (image or texture)
|
||||
[textures] ADDED: ImageAlphaClear() --> Clear alpha channel to desired color
|
||||
[textures] ADDED: ImageAlphaCrop() --> Crop image depending on alpha value
|
||||
[textures] ADDED: ImageAlphaPremultiply() --> Premultiply alpha channel
|
||||
[textures] ADDED: ImageDrawRectangle()
|
||||
[textures] ADDED: ImageMipmaps()
|
||||
[textures] ADDED: GenImageColor()
|
||||
[textures] ADDED: GetPixelDataSize()
|
||||
[textures] ADDED: ImageRotateCW()
|
||||
[textures] ADDED: ImageRotateCCW()
|
||||
[textures] ADDED: ImageResizeCanvas()
|
||||
[textures] ADDED: GetImageDataNormalized()
|
||||
[textures] REVIEWED: ImageFormat() to use normalized data
|
||||
[textures] REVIEWED: Manual mipmap generation
|
||||
[textures] REVIEWED: LoadASTC()
|
||||
[textures] REVIEWED: GenImagePerlinNoise()
|
||||
[textures] REVIEWED: ImageTextEx() to support UTF8 basic characters
|
||||
[textures] REVIEWED: GetTextureData() for RPI - requires some work
|
||||
[textures] Added new example: text drawing on image
|
||||
[text] Corrected issue with ttf font y-offset
|
||||
[text] Support SDF font data generation
|
||||
[text] ADDED: GenImageFontAtlas()
|
||||
[text] ADDED: LoadFontData() to load data from TTF file
|
||||
[text] REMOVED: LoadTTF() internal function
|
||||
[text] REVIEWED: DrawTextEx() - avoid rendering SPACE character!
|
||||
[text] RENAMED: GetDefaultFont() to GetFontDefault()
|
||||
[rlgl] ADDED: rlCheckBufferLimit()
|
||||
[rlgl] ADDED: LoadShaderCode()
|
||||
[rlgl] ADDED: GetMatrixModelview()
|
||||
[rlgl] ADDED: SetVrDistortionShader(Shader shader)
|
||||
[rlgl] REVIEWED: rlLoadTexture() - added mipmaps support, improved compressed textures loading
|
||||
[rlgl] REVIEWED: rlReadTexturePixels()
|
||||
[models] Support 4 components mesh.tangent data
|
||||
[models] Removed tangents generation from LoadOBJ()
|
||||
[models] ADDED: MeshTangents()
|
||||
[models] ADDED: MeshBinormals()
|
||||
[models] ADDED: ExportMesh()
|
||||
[models] ADDED: GetCollisionRayModel()
|
||||
[models] RENAMED: CalculateBoundingBox() to MeshBoundingBox()
|
||||
[models] REMOVED: GetCollisionRayMesh() - does not consider model transform
|
||||
[models] REVIEWED: LoadMesh() - fallback to default cube mesh if loading fails
|
||||
[audio] ADDED: Support for MP3 fileformat
|
||||
[audio] ADDED: IsAudioStreamPlaying()
|
||||
[audio] ADDED: SetAudioStreamVolume()
|
||||
[audio] ADDED: SetAudioStreamPitch()
|
||||
[utils] Corrected issue with SaveImageAs()
|
||||
[utils] RENAMED: SaveImageAs() to ExportImage()
|
||||
[utils] REMOVED: rres support - moved to external library (rres.h)
|
||||
[shaders] REVIEWED: GLSL 120 shaders
|
||||
[raymath] ADDED: Vector3RotateByQuaternion()
|
||||
[raymath] REVIEWED: math usage to reduce temp variables
|
||||
[raymath] REVIEWED: Avoid pointer-based parameters for API consistency
|
||||
[physac] REVIEWED: physac.h timming system
|
||||
[examples] Replaced dwarf model by brand new 3d assets: 3d medieval buildings
|
||||
[examples] Assets cleaning and some replacements
|
||||
[games] ADDED: GGJ18 game - transmission mission
|
||||
[games] REVIEWED: Light my Ritual game - improved gameplay drawing
|
||||
[*] Updated external libraries to latest version
|
||||
[*] Multiple bugs corrected (check github issues)
|
||||
|
||||
-----------------------------------------------
|
||||
Release: raylib 1.8.0 (Oct 2017)
|
||||
|
43
CMakeLists.txt
Executable file → Normal file
@@ -1,8 +1,12 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
# Config options
|
||||
set(BUILD_EXAMPLES ON CACHE BOOL "Build the examples.")
|
||||
set(BUILD_GAMES ON CACHE BOOL "Build the example games.")
|
||||
option(BUILD_EXAMPLES "Build the examples." ON)
|
||||
option(BUILD_GAMES "Build the example games." ON)
|
||||
option(ENABLE_ASAN "Enable AddressSanitizer (ASAN) for debugging (degrades performance)" OFF)
|
||||
option(ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan) for debugging" OFF)
|
||||
option(ENABLE_MSAN "Enable MemorySanitizer (MSan) for debugging (not recommended for run with ASAN)" OFF)
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS "3.1")
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
@@ -11,17 +15,31 @@ if(CMAKE_VERSION VERSION_LESS "3.1")
|
||||
else()
|
||||
set (CMAKE_C_STANDARD 99)
|
||||
endif()
|
||||
include(CheckCCompilerFlag)
|
||||
foreach(option -Werror=pointer-arith;-Werror=implicit-function-declaration)
|
||||
CHECK_C_COMPILER_FLAG("${option}" COMPILER_HAS_THOSE_TOGGLES)
|
||||
set(outcome "Failed")
|
||||
if(COMPILER_HAS_THOSE_TOGGLES)
|
||||
set(CMAKE_C_FLAGS "${option} ${CMAKE_C_FLAGS}")
|
||||
set(outcome "works")
|
||||
endif()
|
||||
message(STATUS "Testing if ${option} can be used -- ${outcome}")
|
||||
endforeach()
|
||||
|
||||
include(AddIfFlagCompiles)
|
||||
add_if_flag_compiles(-Werror=pointer-arith CMAKE_C_FLAGS)
|
||||
add_if_flag_compiles(-Werror=implicit-function-declaration CMAKE_C_FLAGS)
|
||||
# src/external/jar_xm.h does shady stuff
|
||||
add_if_flag_compiles(-fno-strict-aliasing CMAKE_C_FLAGS)
|
||||
|
||||
include(CheckFileSystemSymlinkSupport)
|
||||
|
||||
if (ENABLE_ASAN)
|
||||
add_if_flag_compiles(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
||||
add_if_flag_compiles(-fsanitize=address CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
||||
endif()
|
||||
if (ENABLE_UBSAN)
|
||||
add_if_flag_compiles(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
||||
add_if_flag_compiles(-fsanitize=undefined CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
||||
endif()
|
||||
if (ENABLE_MSAN)
|
||||
add_if_flag_compiles(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
||||
add_if_flag_compiles(-fsanitize=memory CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
|
||||
endif()
|
||||
|
||||
if (ENABLE_MSAN AND ENABLE_ASAN)
|
||||
MESSAGE(WARNING "Compiling with both AddressSanitizer and MemorySanitizer is not recommended")
|
||||
endif()
|
||||
|
||||
add_subdirectory(src release)
|
||||
|
||||
@@ -33,3 +51,4 @@ if (${BUILD_GAMES})
|
||||
add_subdirectory(games)
|
||||
endif()
|
||||
|
||||
enable_testing()
|
||||
|
@@ -21,7 +21,7 @@ Use your best judgement, and feel free to propose changes to this document in a
|
||||
- [raylib roadmap](ROADMAP.md)
|
||||
|
||||
[raylib Wiki](https://github.com/raysan5/raylib/wiki) contains some information about the library and is open to anyone for edit.
|
||||
Feel free to review it if required, just take care not to break anything.
|
||||
Feel free to review it if required, just take care not to break something.
|
||||
|
||||
### raylib C coding conventions
|
||||
|
||||
@@ -34,18 +34,6 @@ Source code is extensively commented for that purpose, raylib primary learning m
|
||||
|
||||
> learn by reading code and examples
|
||||
|
||||
|
||||
### Using raylib develop branch
|
||||
|
||||
raylib [master branch](https://github.com/raysan5/raylib) contains the latest raylib release but all
|
||||
the future work is always done on [develop branch](https://github.com/raysan5/raylib/tree/develop),
|
||||
it's far ahead of master and I try to keep it always stable with latest library changes.
|
||||
|
||||
Please, if issuing a bug or sending a pull-request, verify that you're using develop branch.
|
||||
|
||||
Note that while using develop branch predefined Notepad++ building scripts could not work, in that case,
|
||||
use provided [Makefile](https://github.com/raysan5/raylib/blob/develop/src/Makefile) or [CMake](https://github.com/raysan5/raylib/blob/develop/src/CMakeLists.txt) building systems.
|
||||
|
||||
For detailed information on building raylib and examples, please check [raylib Wiki](https://github.com/raysan5/raylib/wiki).
|
||||
|
||||
### Opening new Issues
|
||||
@@ -62,8 +50,6 @@ To open new issue for raylib (bug, enhancement, discussion...), just try to foll
|
||||
|
||||
### Sending a Pull-Request
|
||||
|
||||
To send a pull-request, first of all, make sure you're sending it to [develop branch](https://github.com/raysan5/raylib/tree/develop). Here are some other rules:
|
||||
|
||||
- Make sure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
|
||||
- Don't send big pull-requests (lots of changelists), they are difficult to review. It's better to send small pull-request, one at a time.
|
||||
- Verify that changes don't break the build (at least on Windows platform). As many platforms where you can test it, the better, but don't worry
|
||||
@@ -80,6 +66,8 @@ Some people ported raylib to other languages in form of bindings or wrappers to
|
||||
- [raylib Crystal binding](https://gitlab.com/Zatherz/cray)
|
||||
- [raylib Perl wrapper](https://metacpan.org/pod/Graphics::Raylib)
|
||||
- raylib Pascal binding with custom IDE (closed-source)
|
||||
- [raylib flat-assembler Usage example](http://forum.raylib.com/index.php?p=/discussion/comment/425/#Comment_425)
|
||||
- [raylib COBOL Usage example](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib)
|
||||
|
||||
Usually, raylib bindings follow the convention: `raylib-{language}`
|
||||
|
||||
@@ -92,7 +80,7 @@ If you have any doubt, don't hesitate to [contact me](mailto:ray@raylib.com)!.
|
||||
You can write me a direct mail but you can also contact me on the following networks:
|
||||
|
||||
- [raylib forum](http://forum.raylib.com/) - A good place for discussions or to ask for help.
|
||||
- [raylib gitter](https://gitter.im/raylib) - A direct communication channel for project discussions.
|
||||
- [raylib Discord](https://discord.gg/VkzNHUE) - A direct communication channel for project discussions.
|
||||
- [raylib twitter](https://twitter.com/raysan5) - My personal twitter account, I usually post about raylib, you can send me PMs.
|
||||
- [raylib web](http://www.raylib.com/) - On top-right corner there is a bunch of networks where you can find me.
|
||||
|
||||
@@ -129,14 +117,20 @@ contributing (in some way or another) to make the raylib project better. Huge th
|
||||
- [Joel Davis](https://github.com/joeld42) for adding raycast picking utilities and a [great example](https://github.com/raysan5/raylib/blob/master/examples/models/models_mesh_picking.c)
|
||||
- [Richard Goodwin](https://github.com/AudioMorphology) for adding RPI touchscreen support
|
||||
- [Milan Nikolic](https://github.com/gen2brain) for adding Android build support with custom standalone toolchain
|
||||
- [Michael Vetter](https://github.com/jubalh) for improvements on build system and adding meson support for Linux
|
||||
- [Michael Vetter](https://github.com/jubalh) for improvements on build system and his work on Suse Linux package... and multiple fixes!
|
||||
- [Wilhem Barbier](https://github.com/nounoursheureux) for adding Image generation functions and some fixes
|
||||
- [Benjamin Summerton](https://github.com/define-private-public) for improving OSX building and his amazing work on CMake build sytem
|
||||
- [MartinFX](https://github.com/Martinfx) for adding compilation support for FreeBSD OS
|
||||
- [MartinFX](https://github.com/Martinfx) for adding compilation support for FreeBSD OS and derivatives
|
||||
- [Wilhem Barbier](https://github.com/nounoursheureux) for supporting default shaders on shader loading, if shader not provided
|
||||
- [Ahmad Fatoum](https://github.com/a3f) for implementing continuus integration support for raylib (Travis and AppVeyor) and greatly improving build system.
|
||||
- [SamNChiet](https://github.com/SamNChiet) for his work on UWP inputs implementation.
|
||||
- [David Reid](https://github.com/mackron) for a complete review of audio module to support his amazing mini_al audio library.
|
||||
- [Kai](https://github.com/questor) for multiple code reviews and improvements.
|
||||
- [RDR8](https://github.com/RDR8) for his work on Makefiles for Linux
|
||||
- [Max Danielsson](https://github.com/autious) for adding support for orthographic 3d camera projection
|
||||
- [Lumaio](https://github.com/TheLumaio) for his great work on GBuffers and GetCollisionRayModel()
|
||||
- [Jonas Daeyaert](https://github.com/culacant) for his amazing work on IQM animated models support
|
||||
- [Seth Archambault](https://github.com/SethArchambault) for his work on Android Gamepad support (SNES model)
|
||||
- [D3nX](https://github.com/D3nX) for adding Code::Blocks project template.
|
||||
|
||||
Please, if I forget someone in this list, excuse me and write me an email to remind me to add you!
|
||||
Please, if I forget someone in this list, excuse me and send a PR!
|
||||
|
@@ -13,7 +13,7 @@ The following help is highly appreciated:
|
||||
- Testers of current features and multiple systems - Can you find some bug on raylib?
|
||||
|
||||
If you can not help on any of the above points but you still want to contribute in some way... please, consider helping
|
||||
with a small [donation](http://www.raylib.com/helpme.html) or contributing with [raylib patreon](https://www.patreon.com/raysan5). It will really motivate to continue improving this project...
|
||||
with a small [donation](http://www.raylib.com/helpme.html) or contributing with [raylib patreon](https://www.patreon.com/raylib). It will really motivate to continue improving this project...
|
||||
|
||||
raylib philosophy
|
||||
------------------
|
||||
@@ -32,6 +32,8 @@ contact
|
||||
* Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames)
|
||||
* Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
||||
* Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5)
|
||||
* Patreon: [https://www.patreon.com/raysan5](https://www.patreon.com/raysan5)
|
||||
* Patreon: [https://www.patreon.com/raylib](https://www.patreon.com/raylib)
|
||||
* Discord: [https://discord.gg/raylib](https://discord.gg/VkzNHUE)
|
||||
* YouTube: [https://www.youtube.com/channel/raylib](https://www.youtube.com/channel/UC8WIBkhYb5sBNqXO1mZ7WSQ)
|
||||
|
||||
[raysan5]: mailto:ray@raylib.com "Ramon Santamaria - Ray San"
|
||||
|
69
HISTORY.md
@@ -1,4 +1,4 @@
|
||||
<img src="https://github.com/raysan5/raylib/blob/master/logo/logo256x256.png" width=256>
|
||||

|
||||
|
||||
history
|
||||
-------
|
||||
@@ -73,12 +73,12 @@ attached to 3d models or used as fullscreen postrocessing effects. A bunch of po
|
||||
in this release, check raylib/shaders folder.
|
||||
|
||||
Textures module has grown to support most of the internal texture formats available in OpenGL (RGB565, RGB888, RGBA5551, RGBA4444, etc.), including compressed texture formats (DXT, ETC1, ETC2, ASTC, PVRT); raylib 1.3 can load .dds, .pkm, .ktx, .astc and .pvr files.
|
||||
A brand new [camera](https://github.com/raysan5/raylib/blob/develop/src/camera.c) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person).
|
||||
Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/develop/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/develop/examples/core_3d_camera_first_person.c).
|
||||
A brand new [camera](https://github.com/raysan5/raylib/blob/master/src/camera.c) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person).
|
||||
Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/master/examples/core_3d_camera_first_person.c).
|
||||
|
||||
New [gestures](https://github.com/raysan5/raylib/blob/develop/src/gestures.h) module simplifies gestures detection on Android and HTML5 programs.
|
||||
New [gestures](https://github.com/raysan5/raylib/blob/master/src/gestures.h) module simplifies gestures detection on Android and HTML5 programs.
|
||||
|
||||
[raygui](https://github.com/raysan5/raylib/blob/develop/src/raygui.h), the new IMGUI (Immediate Mode GUI) module offers a set of functions to create simple user interfaces,
|
||||
[raygui](https://github.com/raysan5/raylib/blob/master/src/raygui.h), the new IMGUI (Immediate Mode GUI) module offers a set of functions to create simple user interfaces,
|
||||
primary intended for tools development. It's still in experimental state but already fully functional.
|
||||
|
||||
Most of the examples have been completely rewritten and +10 new examples have been added to show the new raylib features.
|
||||
@@ -91,18 +91,18 @@ notes on raylib 1.4
|
||||
On February 2016, after 4 months of raylib 1.3 release, it comes raylib 1.4. For this new version,
|
||||
lots of parts of the library have been reviewed, lots of bugs have been solved and some interesting features have been added.
|
||||
|
||||
First big addition is a set of [Image manipulation functions](https://github.com/raysan5/raylib/blob/develop/src/raylib.h#L673) have been added to crop, resize, colorize, flip, dither and even draw image-to-image or text-to-image.
|
||||
First big addition is a set of [Image manipulation functions](https://github.com/raysan5/raylib/blob/master/src/raylib.h#L673) have been added to crop, resize, colorize, flip, dither and even draw image-to-image or text-to-image.
|
||||
Now a basic image processing can be done before converting the image to texture for usage.
|
||||
|
||||
SpriteFonts system has been improved, adding support for AngelCode fonts (.fnt) and TrueType Fonts (using [stb_truetype](https://github.com/nothings/stb/blob/master/stb_truetype.h) helper library).
|
||||
Now raylib can read standard .fnt font data and also generate at loading a SpriteFont from a TTF file.
|
||||
|
||||
New [physac](https://github.com/raysan5/raylib/blob/develop/src/physac.h) physics module for basic 2D physics support. Still in development but already functional.
|
||||
New [physac](https://github.com/raysan5/raylib/blob/master/src/physac.h) physics module for basic 2D physics support. Still in development but already functional.
|
||||
Module comes with some usage examples for basic jump and level interaction and also force-based physic movements.
|
||||
|
||||
[raymath](https://github.com/raysan5/raylib/blob/develop/src/raymath.h) module has been reviewed; some bugs have been solved and the module has been converted to a header-only file for easier portability, optionally, functions can also be used as inline.
|
||||
[raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h) module has been reviewed; some bugs have been solved and the module has been converted to a header-only file for easier portability, optionally, functions can also be used as inline.
|
||||
|
||||
[gestures](https://github.com/raysan5/raylib/blob/develop/src/gestures.c) module has redesigned and simplified, now it can process touch events from any source, including mouse.
|
||||
[gestures](https://github.com/raysan5/raylib/blob/master/src/gestures.c) module has redesigned and simplified, now it can process touch events from any source, including mouse.
|
||||
This way, gestures system can be used on any platform providing an unified way to work with inputs and allowing the user to create multiplatform games with only one source code.
|
||||
|
||||
Raspberry Pi input system has been redesigned to better read raw inputs using generic Linux event handlers (keyboard:`stdin`, mouse:`/dev/input/mouse0`, gamepad:`/dev/input/js0`).
|
||||
@@ -110,7 +110,7 @@ Gamepad support has also been added (experimental).
|
||||
|
||||
Other important improvements are the functional raycast system for 3D picking, including some ray collision-detection functions,
|
||||
and the addition of two simple functions for persistent data storage. Now raylib user can save and load game data in a file (only some platforms supported).
|
||||
A simple [easings](https://github.com/raysan5/raylib/blob/develop/src/easings.h) module has also been added for values animation.
|
||||
A simple [easings](https://github.com/raysan5/raylib/blob/master/src/easings.h) module has also been added for values animation.
|
||||
|
||||
Up to 8 new code examples have been added to show the new raylib features and +10 complete game samples have been provided to learn
|
||||
how to create some classic games like Arkanoid, Asteroids, Missile Commander, Snake or Tetris.
|
||||
@@ -122,7 +122,7 @@ notes on raylib 1.5
|
||||
|
||||
On July 2016, after 5 months of raylib 1.4 release, arrives raylib 1.5. This new version is the biggest boost of the library until now, lots of parts of the library have been redesigned, lots of bugs have been solved and some **AMAZING** new features have been added.
|
||||
|
||||
VR support: raylib supports **Oculus Rift CV1**, one of the most anticipated VR devices in the market. Additionally, raylib supports simulated VR stereo rendering, independent of the VR device; it means, raylib can generate stereo renders with custom head-mounted-display device parameteres, that way, any VR device in the market can be **simulated in any platform** just configuring device parameters (and consequently, lens distortion). To enable VR is [extremely easy](https://github.com/raysan5/raylib/blob/develop/examples/core_oculus_rift.c).
|
||||
VR support: raylib supports **Oculus Rift CV1**, one of the most anticipated VR devices in the market. Additionally, raylib supports simulated VR stereo rendering, independent of the VR device; it means, raylib can generate stereo renders with custom head-mounted-display device parameteres, that way, any VR device in the market can be **simulated in any platform** just configuring device parameters (and consequently, lens distortion). To enable VR is [extremely easy](https://github.com/raysan5/raylib/blob/master/examples/core_oculus_rift.c).
|
||||
|
||||
New materials system: now raylib supports standard material properties for 3D models, including diffuse-ambient-specular colors and diffuse-normal-specular textures. Just assign values to standard material and everything is processed internally.
|
||||
|
||||
@@ -130,15 +130,15 @@ New lighting system: added support for up to 8 configurable lights and 3 light t
|
||||
|
||||
Complete gamepad support on Raspberry Pi: Gamepad system has been completely redesigned. Now multiple gamepads can be easily configured and used; gamepad data is read and processed in raw mode in a second thread.
|
||||
|
||||
Redesigned physics module: [physac](https://github.com/raysan5/raylib/blob/develop/src/physac.h) module has been converted to header only and usage [has been simplified](https://github.com/raysan5/raylib/blob/develop/examples/physics_basic_rigidbody.c). Performance has also been singnificantly improved, now physic objects are managed internally in a second thread.
|
||||
Redesigned physics module: [physac](https://github.com/raysan5/raylib/blob/master/src/physac.h) module has been converted to header only and usage [has been simplified](https://github.com/raysan5/raylib/blob/master/examples/physics_basic_rigidbody.c). Performance has also been singnificantly improved, now physic objects are managed internally in a second thread.
|
||||
|
||||
Audio chiptunese support and mixing channels: Added support for module audio music (.xm, .mod) loading and playing. Multiple mixing channels are now also supported. All this features thanks to the amazing work of @kd7tck.
|
||||
|
||||
Other additions include a [2D camera system](https://github.com/raysan5/raylib/blob/develop/examples/core_2d_camera.c), render textures for offline render (and most comprehensive [postprocessing](https://github.com/raysan5/raylib/blob/develop/examples/shaders_postprocessing.c)) or support for legacy OpenGL 2.1 on desktop platforms.
|
||||
Other additions include a [2D camera system](https://github.com/raysan5/raylib/blob/master/examples/core_2d_camera.c), render textures for offline render (and most comprehensive [postprocessing](https://github.com/raysan5/raylib/blob/master/examples/shaders_postprocessing.c)) or support for legacy OpenGL 2.1 on desktop platforms.
|
||||
|
||||
This new version is so massive that is difficult to list all the improvements, most of raylib modules have been reviewed and [rlgl](https://github.com/raysan5/raylib/blob/develop/src/rlgl.c) module has been completely redesigned to accomodate to new material-lighting systems and stereo rendering. You can check [CHANGELOG](https://github.com/raysan5/raylib/blob/develop/CHANGELOG) file for a more detailed list of changes.
|
||||
This new version is so massive that is difficult to list all the improvements, most of raylib modules have been reviewed and [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) module has been completely redesigned to accomodate to new material-lighting systems and stereo rendering. You can check [CHANGELOG](https://github.com/raysan5/raylib/blob/master/CHANGELOG) file for a more detailed list of changes.
|
||||
|
||||
Up to 8 new code examples have been added to show the new raylib features and also some samples to show the usage of [rlgl](https://github.com/raysan5/raylib/blob/develop/examples/rlgl_standalone.c) and [audio](https://github.com/raysan5/raylib/blob/develop/examples/audio_standalone.c) raylib modules as standalone libraries.
|
||||
Up to 8 new code examples have been added to show the new raylib features and also some samples to show the usage of [rlgl](https://github.com/raysan5/raylib/blob/master/examples/rlgl_standalone.c) and [audio](https://github.com/raysan5/raylib/blob/master/examples/audio_standalone.c) raylib modules as standalone libraries.
|
||||
|
||||
Lots of code changes (+400 commits) and lots of hours of hard work have concluded in this amazing new raylib 1.5.
|
||||
|
||||
@@ -149,7 +149,7 @@ On November 2016, only 4 months after raylib 1.5, arrives raylib 1.6. This new v
|
||||
|
||||
Complete [raylib Lua binding](https://github.com/raysan5/raylib-lua). All raylib functions plus the +60 code examples have been ported to Lua, now Lua users can enjoy coding videogames in Lua while using all the internal power of raylib. This addition also open the doors to Lua scripting support for a future raylib-based engine, being able to move game logic (Init, Update, Draw, De-Init) to Lua scripts while keep using raylib functionality.
|
||||
|
||||
Completely redesigned [audio module](https://github.com/raysan5/raylib/blob/develop/src/audio.c). Based on the new direction taken in raylib 1.5, it has been further improved and more functionality added (+20 new functions) to allow raw audio processing and streaming. [FLAC file format support](https://github.com/raysan5/raylib/blob/develop/src/external/dr_flac.h) has also been added. In the same line, [OpenAL Soft](https://github.com/kcat/openal-soft) backend is now provided as a static library in Windows to allow static linking and get ride of OpenAL32.dll. Now raylib Windows games are completey self-contained, no external libraries required any more!
|
||||
Completely redesigned [audio module](https://github.com/raysan5/raylib/blob/master/src/audio.c). Based on the new direction taken in raylib 1.5, it has been further improved and more functionality added (+20 new functions) to allow raw audio processing and streaming. [FLAC file format support](https://github.com/raysan5/raylib/blob/master/src/external/dr_flac.h) has also been added. In the same line, [OpenAL Soft](https://github.com/kcat/openal-soft) backend is now provided as a static library in Windows to allow static linking and get ride of OpenAL32.dll. Now raylib Windows games are completey self-contained, no external libraries required any more!
|
||||
|
||||
[Physac](https://github.com/victorfisac/Physac) module has been moved to its own repository and it has been improved A LOT, actually, library has been completely rewritten from scratch by [@victorfisac](https://github.com/victorfisac), multiple samples have been added together with countless new features to match current standard 2D physic libraries. Results are amazing!
|
||||
|
||||
@@ -187,18 +187,41 @@ notes on raylib 1.8
|
||||
|
||||
October 2017, around 5 months after latest raylib version, another release is published: raylib 1.8. Again, several modules of the library have been reviewed and some new functionality added. Main changes of this new release are:
|
||||
|
||||
[Procedural image generation](https://github.com/raysan5/raylib/blob/develop/examples/textures/textures_image_generation.c) function, a set of new functions have been added to generate gradients, checked, noise and cellular images from scratch. Image generation could be useful for certain textures or learning pourpouses.
|
||||
[Procedural image generation](https://github.com/raysan5/raylib/blob/master/examples/textures/textures_image_generation.c) function, a set of new functions have been added to generate gradients, checked, noise and cellular images from scratch. Image generation could be useful for certain textures or learning pourpouses.
|
||||
|
||||
[Parametric mesh generation](https://github.com/raysan5/raylib/blob/develop/examples/models/models_mesh_generation.c) functions, create 3d meshes from scratch just defining a set of parameters, meshes like cube, sphere, cylinder, torus, knot and more can be very useful for prototyping or for lighting and texture testing.
|
||||
[Parametric mesh generation](https://github.com/raysan5/raylib/blob/master/examples/models/models_mesh_generation.c) functions, create 3d meshes from scratch just defining a set of parameters, meshes like cube, sphere, cylinder, torus, knot and more can be very useful for prototyping or for lighting and texture testing.
|
||||
|
||||
PBR Materials support, a completely redesigned shaders and material system allows advance materials definition and usage, with fully customizable shaders. Some new functions have been added to generate the environment textures required for PBR shading and a a new complete [PBR material example](https://github.com/raysan5/raylib/blob/develop/examples/models/models_material_pbr.c) is also provided for reference.
|
||||
PBR Materials support, a completely redesigned shaders and material system allows advance materials definition and usage, with fully customizable shaders. Some new functions have been added to generate the environment textures required for PBR shading and a a new complete [PBR material example](https://github.com/raysan5/raylib/blob/master/examples/models/models_material_pbr.c) is also provided for reference.
|
||||
|
||||
Custom Android APK build pipeline with [simple Makefile](https://github.com/raysan5/raylib/blob/develop/templates/simple_game/Makefile). Actually, full code building mechanism based on plain Makefile has been completely reviewed and Android building has been added for sources and also for examples and templates building into final APK package. This way, raylib Android building has been greatly simplified and integrated seamlessly into standard build scripts.
|
||||
Custom Android APK build pipeline with [simple Makefile](https://github.com/raysan5/raylib/blob/master/templates/simple_game/Makefile). Actually, full code building mechanism based on plain Makefile has been completely reviewed and Android building has been added for sources and also for examples and templates building into final APK package. This way, raylib Android building has been greatly simplified and integrated seamlessly into standard build scripts.
|
||||
|
||||
[rlgl](https://github.com/raysan5/raylib/blob/develop/src/rlgl.c) module has been completely reviewed and most of the functions renamed for consistency. This way, standalone usage of rlgl is promoted, with a [complete example provided](https://github.com/raysan5/raylib/blob/develop/examples/others/rlgl_standalone.c). rlgl offers a pseudo-OpenGL 1.1 immediate-mode programming-style layer, with backends to multiple OpenGL versions.
|
||||
[rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) module has been completely reviewed and most of the functions renamed for consistency. This way, standalone usage of rlgl is promoted, with a [complete example provided](https://github.com/raysan5/raylib/blob/master/examples/others/rlgl_standalone.c). rlgl offers a pseudo-OpenGL 1.1 immediate-mode programming-style layer, with backends to multiple OpenGL versions.
|
||||
|
||||
[raymath](https://github.com/raysan5/raylib/blob/develop/src/rlgl.c) library has been also reviewed to align with other advance math libraries like [GLM](https://github.com/g-truc/glm). Matrix math has been improved and simplified, some new Quaternion functions have been added and Vector3 functions have been renamed all around the library for consistency with new Vector2 functionality.
|
||||
[raymath](https://github.com/raysan5/raylib/blob/master/src/rlgl.c) library has been also reviewed to align with other advance math libraries like [GLM](https://github.com/g-truc/glm). Matrix math has been improved and simplified, some new Quaternion functions have been added and Vector3 functions have been renamed all around the library for consistency with new Vector2 functionality.
|
||||
|
||||
Additionally, as always, examples and templates have been reviewed to work with new version (some new examples have been added), all external libraries have been updated to latest stable version and latest Notepad++ and MinGW have been configured to work with new raylib. For a full list of changes, just check [CHANGELOG](CHANGELOG).
|
||||
|
||||
New installer provided, web updated, examples re-builded, documentation reviewed... **new raylib 1.8 published**. Enjoy coding games.
|
||||
New installer provided, web updated, examples re-builded, documentation reviewed... **new raylib 1.8 published**. Enjoy coding games.
|
||||
|
||||
notes on raylib 2.0
|
||||
-------------------
|
||||
|
||||
It's been 9 month since last raylib version was published, a lots of things have changed since then... This new raylib version represents an inflexion point in the development of the library and so, we jump to a new major version... Here it is the result of almost **5 years and thousands of hours of hard work**... here it is... **raylib 2.0**
|
||||
|
||||
In **raylib 2.0** the full API has been carefully reviewed for better consistency, some new functionality has been added and the overall raylib experience has been greatly improved... The key features of new version are:
|
||||
|
||||
**Complete removal of external dependencies.** Finally, raylib does not require external libraries to be installed and linked along with raylib, all required libraries are contained and compiled within raylib. Obviously some external libraries are related but only the strictly platform-dependant required ones, that comes installed with the OS. So, raylib becomes a self-contained platform-independent games development library.
|
||||
|
||||
**Full redesign of audio module to use the amazing mini_al audio library**, along with external dependencies removal, OpenAL library has been replaced by mini_al, this brand new library offers automatic dynamic linking with default OS audio systems. Undoubtly, the perfect low-level companion for raylib audio module!
|
||||
|
||||
**Support for continuous integration building*** through AppVeyor and Travis CI. As a consequence, raylib GitHub develop branch has been completely removed simplyfing the code-base to a single master branch, always stable. Every time a new commit is deployed, library is compiled for **up-to 12 different configurations**, including multiple platforms, 32bit/64bit and multiple compiler options! All those binaries are automatically attached to any new release!
|
||||
|
||||
**More platforms supported and tested**, including BSD family (FreeBSD, openBSD, NetBSD, DragonFly) and Linux-based family platforms (openSUSE, Debian, Ubuntu, Arch, NixOS...). raylib has already been added to some package managers! Oh, and last but not less important, **Android 64bit** is already supported by raylib!
|
||||
|
||||
**Support for TCC compiler!** Thanks to the lack of external dependencies, raylib can now be easily compiled with a **minimal toolchain**, like the one provide by Tiny C Compiler. It opens the door to an amazing future, allowing, for example, static linkage of libtcc for **runtime compilation of raylib-based code**... and the library itself if required! Moreover, TCC is blazing fast, it can compile all raylib in a couple of seconds!
|
||||
|
||||
Refactored all raylib configuration #defines into a **centralized `config.h` header**, with more than **40 possible configuration options** to compile a totally customizable raylib version including only desired options like supported file-formats or specific functionality support. It allows generating a trully ligth-weight version of the library if desired!
|
||||
|
||||
A part of that, lots of new features, like a brand **new font rendering and packaging system** for TTF fonts with **SDF support** (thanks to the amazing STB headers), new functions for **CPU image data manipulation**, new orthographic 3d camera mode, a complete review of `raymath.h` single-file header-only library for better consistency and performance, new examples and way, [way more](https://github.com/raysan5/raylib/blob/master/CHANGELOG).
|
||||
|
||||
Probably by now, **raylib 2.0 is the simplest and easiest-to-use library to learn (and understand) videogames programming**... but, undoubtly its development has exceeded any initial objective; raylib has become a simple and easy-to-use trully multiplatform portable standalone media library with thousands of possibilities... and that's just the beginning!
|
||||
|
@@ -27,7 +27,7 @@ applications, and to alter it and redistribute it freely, subject to the followi
|
||||
fonts
|
||||
------
|
||||
|
||||
The following fonts [provided with raylib](https://github.com/raysan5/raylib/tree/develop/examples/text/resources/fonts) are free to use (freeware) and have been designed by the following people:
|
||||
The following fonts [provided with raylib](https://github.com/raysan5/raylib/tree/master/examples/text/resources/fonts) are free to use (freeware) and have been designed by the following people:
|
||||
|
||||
* Alpha Beta - Brian Kent (AEnigma)
|
||||
* Setback - Brian Kent (AEnigma)
|
||||
@@ -41,9 +41,9 @@ The following fonts [provided with raylib](https://github.com/raysan5/raylib/tre
|
||||
2d art
|
||||
------
|
||||
|
||||
[scarfy spritesheet](https://github.com/raysan5/raylib/blob/develop/examples/textures/resources/scarfy.png) and [fudesumi image](https://github.com/raysan5/raylib/blob/develop/examples/textures/resources/fudesumi.png) have been created by [Eiden Marsal](https://www.artstation.com/artist/marshall_z) and licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
|
||||
[scarfy spritesheet](https://github.com/raysan5/raylib/blob/master/examples/textures/resources/scarfy.png) and [fudesumi image](https://github.com/raysan5/raylib/blob/master/examples/textures/resources/fudesumi.png) have been created by [Eiden Marsal](https://www.artstation.com/artist/marshall_z) and licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
|
||||
|
||||
3d models
|
||||
---------
|
||||
|
||||
[dwarf 3d model and textures](https://github.com/raysan5/raylib/tree/develop/examples/models/resources/model) have been created by David Moreno and licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
|
||||
[medieval city 3d models and textures](https://github.com/raysan5/raylib/tree/master/examples/models/resources/medieval) have been created by Alberto Cano and licensed as [Creative Commons Attribution-NonCommercial 4.0](https://creativecommons.org/licenses/by-nc/4.0/legalcode)
|
||||
|
50
README.md
@@ -1,4 +1,4 @@
|
||||
<img align="left" src="https://github.com/raysan5/raylib/blob/master/logo/logo256x256.png" width=256>
|
||||
<img align="left" src="https://github.com/raysan5/raylib/blob/master/logo/raylib_256x256.png" width=256>
|
||||
|
||||
**raylib is a simple and easy-to-use library to learn videogames programming.**
|
||||
|
||||
@@ -12,46 +12,43 @@ pure spartan-programmers way. Are you ready to learn? Jump to [code examples!](h
|
||||
|
||||
[](https://travis-ci.org/raysan5/raylib)
|
||||
[](https://ci.appveyor.com/project/raysan5/raylib)
|
||||
[](https://gitter.im/raylib/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
[](https://discord.gg/VkzNHUE)
|
||||
[](LICENSE.md)
|
||||
[](https://twitter.com/raysan5)
|
||||
|
||||
features
|
||||
--------
|
||||
- **NO external dependencies**, all required libraries included with raylib
|
||||
- Multiple platforms supported: **Windows, Linux, MacOS, Android... and many more!**
|
||||
- Written in plain C code (C99) in PascalCase/camelCase notation
|
||||
- Hardware accelerated with OpenGL (**1.1, 2.1, 3.3 or ES 2.0**)
|
||||
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c)
|
||||
- Multiple Fonts formats supported (XNA fonts, AngelCode fonts, TTF)
|
||||
- Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
|
||||
- **Full 3d support** for 3d Shapes, Models, Billboards, Heightmaps and more!
|
||||
- Flexible Materials system, supporting classic maps and **PBR maps**
|
||||
- Shaders support, including Model shaders and Postprocessing shaders
|
||||
- **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
|
||||
- Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD)
|
||||
- **VR stereo rendering** support with configurable HMD device parameters
|
||||
- Bindings to **Lua** ([raylib-lua](https://github.com/raysan5/raylib-lua)), **Go** ([raylib-go](https://github.com/gen2brain/raylib-go)) and more!.
|
||||
|
||||
* Written in plain C code (C99) in PascalCase/camelCase notation
|
||||
* Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES2 - choose at compile)
|
||||
* Unique OpenGL abstraction layer (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c)
|
||||
* Powerful fonts module with SpriteFonts support (XNA fonts, AngelCode fonts, TTF)
|
||||
* Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
|
||||
* Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more!
|
||||
* Flexible Materials system, supporting classic maps and PBR maps
|
||||
* Shaders support, including Model shaders and Postprocessing shaders
|
||||
* Powerful math module for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
|
||||
* Audio loading and playing with streaming support (WAV, OGG, FLAC, XM, MOD)
|
||||
* Multiple platforms support: Windows, Linux, FreeBSD, MacOS, UWP, Android, Raspberry Pi, HTML5.
|
||||
* VR stereo rendering with configurable HMD device parameters
|
||||
* NO external dependencies, all required libraries included with raylib
|
||||
* Complete bindings to LUA ([raylib-lua](https://github.com/raysan5/raylib-lua)) and Go ([raylib-go](https://github.com/gen2brain/raylib-go))
|
||||
raylib uses on its [core](https://github.com/raysan5/raylib/blob/master/src/core.c) module the outstanding [GLFW3](http://www.glfw.org/) library, embedded inside raylib in the form of [rglfw](https://github.com/raysan5/raylib/blob/master/src/rglfw.c) module, avoiding that way external dependencies.
|
||||
|
||||
raylib uses on its core module the outstanding [GLFW3](http://www.glfw.org/) library. The best option I found for
|
||||
multiplatform (Windows, Linux, Mac) window/context and input management (clean, focused, great license, well documented, modern, maintained, ...).
|
||||
raylib uses on its [audio](https://github.com/raysan5/raylib/blob/master/src/audio.c) module, the amazing [mini_al](https://github.com/dr-soft/mini_al) audio library, single-file header-only and supporting multiple platforms and multiple audio backends.
|
||||
|
||||
raylib uses on its [audio](https://github.com/raysan5/raylib/blob/master/src/audio.c) module, [OpenAL Soft](http://kcat.strangesoft.net/openal.html) audio library, in multiple flavours,
|
||||
to accomodate to Android, Raspberry Pi and HTML5.
|
||||
raylib uses internally multiple single-file header-only libraries to support multiple fileformats loading and saving, all those libraries are embedded with raylib and available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory.
|
||||
|
||||
*On Android, `native_app_glue module` (provided by Android NDK) and native Android libraries are used to manage window/context, inputs and activity life cycle.*
|
||||
|
||||
*On Raspberry Pi, Videocore API and EGL libraries are used for window/context management and raw inputs reading.*
|
||||
*On Raspberry Pi, `Videocore API` and `EGL` libraries are used for window/context management and raw inputs reading.*
|
||||
|
||||
build and installation
|
||||
----------------------
|
||||
|
||||
Binary releases for Windows, Linux and macOS are available at the [Github Releases](https://github.com/raysan5/raylib/releases) page. Raylib is also available via following package managers:
|
||||
Binary releases for Windows, Linux and macOS are available at the [Github Releases](https://github.com/raysan5/raylib/releases) page. raylib is also available via multiple package managers on multiple OS distributions. For more info check [raylib Wiki](https://github.com/raysan5/raylib/wiki).
|
||||
|
||||
* Homebrew: `brew install raylib`
|
||||
|
||||
To build raylib yourself, check out the [raylib Wiki](https://github.com/raysan5/raylib/wiki) for detailed instructions.
|
||||
To build raylib yourself, check out also the [raylib Wiki](https://github.com/raysan5/raylib/wiki) for detailed instructions.
|
||||
|
||||
raylib has been developed using exclusively two tools:
|
||||
|
||||
@@ -68,7 +65,8 @@ contact
|
||||
* Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames)
|
||||
* Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
||||
* Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5)
|
||||
* Patreon: [https://www.patreon.com/raysan5](https://www.patreon.com/raysan5)
|
||||
* Patreon: [https://www.patreon.com/raylib](https://www.patreon.com/raylib)
|
||||
* Discord: [https://discord.gg/raylib](https://discord.gg/VkzNHUE)
|
||||
* YouTube: [https://www.youtube.com/channel/raylib](https://www.youtube.com/channel/UC8WIBkhYb5sBNqXO1mZ7WSQ)
|
||||
|
||||
If you are using raylib and you enjoy it, please, [let me know][raysan5].
|
||||
|
12
ROADMAP.md
@@ -4,13 +4,13 @@ roadmap
|
||||
Current version of raylib is complete and functional but there is still a lot of room for improvement.
|
||||
Here it is a wish-list with features and ideas to improve the library.
|
||||
|
||||
Note that [raylib source code](https://github.com/raysan5/raylib/tree/develop/src) has some *TODO* marks around code with pending things to review and improve. Check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
|
||||
Note that [raylib source code](https://github.com/raysan5/raylib/tree/master/src) has some *TODO* marks around code with pending things to review and improve. Check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
|
||||
|
||||
**raylib 1.x**
|
||||
- [ ] Basic GPU stats sytem (memory, draws, time...)
|
||||
- [ ] Improved custom file-format (.rres) and packaging tool
|
||||
- [ ] Touch-based camera controls for Android
|
||||
- [ ] Quaternions-based camera system
|
||||
**raylib 2.x**
|
||||
- [ ] raynet: Network module
|
||||
- [ ] Support Vulkan API (GRAPHICS_API_VULKAN)
|
||||
- [ ] Basic CPU/GPU stats sytem (memory, draws, time...)
|
||||
- [ ] Support Animated models
|
||||
|
||||
**raylib 1.8**
|
||||
- [x] Improved Materials system with PBR support
|
||||
|
@@ -39,7 +39,7 @@ before_build:
|
||||
- cd build
|
||||
|
||||
build_script:
|
||||
- cmake -G %GENERATOR% -DSTATIC_RAYLIB=ON -DSHARED_RAYLIB=ON -DBUILD_EXAMPLES=%examples% -DBUILD_GAMES=%examples% ..
|
||||
- cmake -G %GENERATOR% -DSTATIC=ON -DSHARED=ON -DBUILD_EXAMPLES=%examples% -DBUILD_GAMES=%examples% ..
|
||||
- cmake --build . --target install
|
||||
|
||||
after_build:
|
||||
@@ -61,5 +61,5 @@ deploy:
|
||||
prerelease: false
|
||||
force_update: true
|
||||
on:
|
||||
branch: develop
|
||||
branch: master
|
||||
appveyor_repo_tag: true # deploy on tag push only
|
||||
|
12
cmake/AddIfFlagCompiles.cmake
Normal file
@@ -0,0 +1,12 @@
|
||||
include(CheckCCompilerFlag)
|
||||
function(add_if_flag_compiles flag)
|
||||
CHECK_C_COMPILER_FLAG("${flag}" COMPILER_HAS_THOSE_TOGGLES)
|
||||
set(outcome "Failed")
|
||||
if(COMPILER_HAS_THOSE_TOGGLES)
|
||||
foreach(var ${ARGN})
|
||||
set(${var} "${flag} ${${var}}" PARENT_SCOPE)
|
||||
endforeach()
|
||||
set(outcome "compiles")
|
||||
endif()
|
||||
message(STATUS "Testing if ${flag} can be used -- ${outcome}")
|
||||
endfunction()
|
43
cmake/BuildType.cmake
Normal file
@@ -0,0 +1,43 @@
|
||||
# Set a default build type if none was specified
|
||||
set(default_build_type "Release")
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
set(default_build_type "Debug")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
|
||||
STRING "Choose the type of build." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
|
||||
"MinSizeRel" "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
# Taken from the https://github.com/OpenChemistry/tomviz project
|
||||
# Copyright (c) 2014-2017, Kitware, Inc.
|
||||
# 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.
|
13
cmake/CheckFileSystemSymlinkSupport.cmake
Normal file
@@ -0,0 +1,13 @@
|
||||
# Populates a ${FILESYSTEM_LACKS_SYMLINKS} variable
|
||||
message(STATUS "Testing if file system supports symlinks")
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink CMakeLists.txt "${CMAKE_CURRENT_BINARY_DIR}/TestingIfSymlinkWorks"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
RESULT_VARIABLE FILESYSTEM_LACKS_SYMLINKS
|
||||
)
|
||||
If (FILESYSTEM_LACKS_SYMLINKS)
|
||||
message(STATUS "Testing if file system supports symlinks -- unsupported")
|
||||
else()
|
||||
message(STATUS "Testing if file system supports symlinks -- supported")
|
||||
endif()
|
||||
|
15
cmake/emscripten.cmake
Normal file
@@ -0,0 +1,15 @@
|
||||
SET(CMAKE_SYSTEM_NAME Linux)
|
||||
|
||||
SET(CMAKE_C_COMPILER emcc)
|
||||
SET(CMAKE_CXX_COMPILER em++)
|
||||
if(NOT DEFINED CMAKE_AR)
|
||||
find_program(CMAKE_AR NAMES emar)
|
||||
endif()
|
||||
if(NOT DEFINED CMAKE_RANLIB)
|
||||
find_program(CMAKE_RANLIB NAMES emranlib)
|
||||
endif()
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
21
cmake/test-pkgconfig.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
# Test if including/linking/running an installed raylib works
|
||||
|
||||
set -x
|
||||
export LD_RUN_PATH=/usr/local/lib
|
||||
|
||||
CFLAGS="-Wall -Wextra -Werror $CFLAGS"
|
||||
if [ "$ARCH" = "i386" ]; then
|
||||
CFLAGS="-m32 $CLFAGS"
|
||||
fi
|
||||
|
||||
cat << EOF | ${CC:-cc} -otest -xc - $(pkg-config --libs --cflags $@ raylib.pc) $CFLAGS && exec ./test
|
||||
#include <stdlib.h>
|
||||
#include <raylib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int num = GetRandomValue(42, 1337);
|
||||
return 42 <= num && num <= 1337 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
EOF
|
85
cmake/utils.cmake
Normal file
@@ -0,0 +1,85 @@
|
||||
# All sorts of things that we need cross project
|
||||
cmake_minimum_required(VERSION 2.8.0)
|
||||
|
||||
add_definitions("-DRAYLIB_CMAKE=1")
|
||||
|
||||
# Linking for OS X -framework options
|
||||
# Will do nothing on other OSes
|
||||
if(${PLATFORM} MATCHES "Android")
|
||||
find_library(OPENGL_LIBRARY OpenGL)
|
||||
set(LIBS_PRIVATE m log android EGL GLESv2 OpenSLES atomic c)
|
||||
elseif(${PLATFORM} MATCHES "Web")
|
||||
elseif(APPLE)
|
||||
find_library(OPENGL_LIBRARY OpenGL)
|
||||
|
||||
set(LIBS_PRIVATE ${OPENGL_LIBRARY})
|
||||
elseif(WIN32)
|
||||
# no pkg-config --static on Windows yet...
|
||||
else()
|
||||
find_library(pthread NAMES pthread)
|
||||
find_package(OpenGL QUIET)
|
||||
if ("${OPENGL_LIBRARIES}" STREQUAL "")
|
||||
set(OPENGL_LIBRARIES "GL")
|
||||
endif()
|
||||
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
|
||||
if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD")
|
||||
find_library(OSS_LIBRARY ossaudio)
|
||||
endif()
|
||||
|
||||
set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(${PLATFORM} MATCHES "Desktop")
|
||||
if(USE_EXTERNAL_GLFW STREQUAL "ON")
|
||||
find_package(glfw3 3.2.1 REQUIRED)
|
||||
elseif(USE_EXTERNAL_GLFW STREQUAL "IF_POSSIBLE")
|
||||
find_package(glfw3 3.2.1 QUIET)
|
||||
endif()
|
||||
if (glfw3_FOUND)
|
||||
set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||
set(LINUX TRUE)
|
||||
endif()
|
||||
|
||||
foreach(L ${LIBS_PRIVATE})
|
||||
get_filename_component(DIR ${L} PATH)
|
||||
get_filename_component(LIBFILE ${L} NAME_WE)
|
||||
STRING(REGEX REPLACE "^lib" "" FILE ${LIBFILE})
|
||||
|
||||
if (${L} MATCHES "[.]framework$")
|
||||
set(FILE_OPT "-framework ${FILE}")
|
||||
set(DIR_OPT "-F${DIR}")
|
||||
else()
|
||||
set(FILE_OPT "-l${FILE}")
|
||||
set(DIR_OPT "-L${DIR}")
|
||||
endif()
|
||||
|
||||
if ("${DIR}" STREQUAL "" OR "${DIR}" STREQUAL "${LASTDIR}")
|
||||
set (DIR_OPT "")
|
||||
endif()
|
||||
|
||||
set(LASTDIR ${DIR})
|
||||
|
||||
set(__PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE} ${DIR_OPT} ${FILE_OPT})
|
||||
string (REPLACE ";" " " __PKG_CONFIG_LIBS_PRIVATE "${__PKG_CONFIG_LIBS_PRIVATE}")
|
||||
endforeach(L)
|
||||
|
||||
|
||||
|
||||
# Do the linking for executables that are meant to link raylib
|
||||
function(link_libraries_to_executable executable)
|
||||
# Link raylib
|
||||
if (TARGET raylib_shared)
|
||||
target_link_libraries(${executable} raylib_shared)
|
||||
elseif(${PLATFORM} MATCHES "Web")
|
||||
target_link_libraries(${executable} ${__PKG_CONFIG_LIBS_PRIVATE})
|
||||
target_link_libraries(${executable} raylib)
|
||||
else()
|
||||
target_link_libraries(${executable} raylib ${__PKG_CONFIG_LIBS_PRIVATE})
|
||||
endif()
|
||||
endfunction()
|
@@ -1,7 +1,7 @@
|
||||
# Setup the project and settings
|
||||
project(examples)
|
||||
|
||||
include("../utils.cmake")
|
||||
include("../cmake/utils.cmake")
|
||||
|
||||
# Make sure raylib has been built
|
||||
# TODO `build` directory should maybe be something else...
|
||||
@@ -34,12 +34,31 @@ foreach(example_dir ${example_dirs})
|
||||
endforeach()
|
||||
|
||||
include(CheckIncludeFiles)
|
||||
check_include_files(OVR_CAPI_GL.h HAVE_OCULUS_CAPI)
|
||||
if(NOT HAVE_OCULUS_CAPI)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/oculus_rift.c)
|
||||
endif()
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/standard_lighting.c)
|
||||
|
||||
if(${PLATFORM} MATCHES "Android")
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_picking.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_vr_simulator.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_free.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_first_person.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_world_screen.c)
|
||||
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_material_pbr.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_cubicmap.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_skybox.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_generation.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_heightmap.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_billboard.c)
|
||||
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_custom_uniform.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_model_shader.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_postprocessing.c)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
# Do each example
|
||||
foreach(example_source ${example_sources})
|
||||
|
@@ -24,29 +24,46 @@
|
||||
.PHONY: all clean
|
||||
|
||||
# Define required raylib variables
|
||||
# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
|
||||
PLATFORM ?= PLATFORM_DESKTOP
|
||||
RAYLIB_PATH ?= ..
|
||||
PROJECT_NAME ?= raylib_example
|
||||
PROJECT_NAME ?= raylib_examples
|
||||
RAYLIB_VERSION ?= 2.0.0
|
||||
RAYLIB_API_VERSION ?= 1
|
||||
RAYLIB_PATH ?= ..
|
||||
|
||||
# Default path for raylib on Raspberry Pi, if installed in different path, update it!
|
||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||
RAYLIB_PATH ?= /home/pi/raylib
|
||||
endif
|
||||
# Define default options
|
||||
|
||||
# One of PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
|
||||
PLATFORM ?= PLATFORM_DESKTOP
|
||||
|
||||
# Locations of your newly installed library and associated headers. See ../src/Makefile
|
||||
# On Linux, if you have installed raylib but cannot compile the examples, check that
|
||||
# the *_INSTALL_PATH values here are the same as those in src/Makefile or point to known locations.
|
||||
# To enable system-wide compile-time and runtime linking to libraylib.so, run ../src/$ sudo make install RAYLIB_LIBTYPE_SHARED.
|
||||
# To enable compile-time linking to a special version of libraylib.so, change these variables here.
|
||||
# To enable runtime linking to a special version of libraylib.so, see EXAMPLE_RUNTIME_PATH below.
|
||||
# If there is a libraylib in both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH, at runtime,
|
||||
# the library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over the one at RAYLIB_INSTALL_PATH.
|
||||
# RAYLIB_INSTALL_PATH should be the desired full path to libraylib. No relative paths.
|
||||
DESTDIR ?= /usr/local
|
||||
RAYLIB_INSTALL_PATH ?= $(DESTDIR)/lib
|
||||
# RAYLIB_H_INSTALL_PATH locates the installed raylib header and associated source files.
|
||||
RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include
|
||||
|
||||
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
|
||||
RAYLIB_LIBTYPE ?= STATIC
|
||||
RAYLIB_LIBTYPE ?= STATIC
|
||||
|
||||
# Build mode for project: DEBUG or RELEASE
|
||||
RAYLIB_BUILD_MODE ?= RELEASE
|
||||
|
||||
# Use external GLFW library instead of rglfw module
|
||||
USE_EXTERNAL_GLFW ?= FALSE
|
||||
# TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3
|
||||
USE_EXTERNAL_GLFW ?= FALSE
|
||||
|
||||
# Use Wayland display server protocol on Linux desktop
|
||||
# by default it uses X11 windowing system
|
||||
USE_WAYLAND_DISPLAY ?= FALSE
|
||||
USE_WAYLAND_DISPLAY ?= FALSE
|
||||
|
||||
# NOTE: On PLATFORM_WEB OpenAL Soft backend is used by default (check raylib/src/Makefile)
|
||||
|
||||
|
||||
# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
# No uname.exe on MinGW!, but OS=Windows_NT on Windows!
|
||||
@@ -59,7 +76,16 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
PLATFORM_OS=LINUX
|
||||
endif
|
||||
ifeq ($(UNAMEOS),FreeBSD)
|
||||
PLATFORM_OS=FREEBSD
|
||||
PLATFORM_OS=BSD
|
||||
endif
|
||||
ifeq ($(UNAMEOS),OpenBSD)
|
||||
PLATFORM_OS=BSD
|
||||
endif
|
||||
ifeq ($(UNAMEOS),NetBSD)
|
||||
PLATFORM_OS=BSD
|
||||
endif
|
||||
ifeq ($(UNAMEOS),DragonFly)
|
||||
PLATFORM_OS=BSD
|
||||
endif
|
||||
ifeq ($(UNAMEOS),Darwin)
|
||||
PLATFORM_OS=OSX
|
||||
@@ -73,20 +99,35 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
# Emscripten required variables
|
||||
EMSDK_PATH = C:/emsdk
|
||||
EMSCRIPTEN_VERSION = 1.37.28
|
||||
CLANG_VERSION=e1.37.28_64bit
|
||||
PYTHON_VERSION=2.7.5.3_64bit
|
||||
NODE_VERSION=4.1.1_64bit
|
||||
export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
|
||||
EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
|
||||
# RAYLIB_PATH adjustment for different platforms.
|
||||
# If using GNU make, we can get the full path to the top of the tree. Windows? BSD?
|
||||
# Required for ldconfig or other tools that do not perform path expansion.
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(PLATFORM_OS),LINUX)
|
||||
RAYLIB_PREFIX ?= ..
|
||||
RAYLIB_PATH = $(realpath $(RAYLIB_PREFIX))
|
||||
endif
|
||||
endif
|
||||
# Default path for raylib on Raspberry Pi, if installed in different path, update it!
|
||||
# This is not currently used by src/Makefile. Not sure of its origin or usage. Refer to wiki.
|
||||
# TODO: update install: target in src/Makefile for RPI, consider relation to LINUX.
|
||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||
RAYLIB_PATH ?= /home/pi/raylib
|
||||
endif
|
||||
|
||||
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/release/libs
|
||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
# Emscripten required variables
|
||||
EMSDK_PATH = C:/emsdk
|
||||
EMSCRIPTEN_VERSION = 1.38.8
|
||||
CLANG_VERSION = e1.38.8_64bit
|
||||
PYTHON_VERSION = 2.7.13.1_64bit\python-2.7.13.amd64
|
||||
NODE_VERSION = 8.9.1_64bit
|
||||
export PATH = $(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
|
||||
EMSCRIPTEN = $(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
|
||||
endif
|
||||
|
||||
# Define raylib release directory for compiled library
|
||||
# Define raylib release directory for compiled library.
|
||||
# RAYLIB_RELEASE_PATH points to provided binaries or your freshly built version.
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32
|
||||
@@ -97,8 +138,8 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(PLATFORM_OS),OSX)
|
||||
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/osx
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),FREEBSD)
|
||||
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/freebsd
|
||||
ifeq ($(PLATFORM_OS),BSD)
|
||||
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/bsd
|
||||
endif
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||
@@ -108,6 +149,20 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5
|
||||
endif
|
||||
|
||||
# EXAMPLE_RUNTIME_PATH embeds a custom runtime location of libraylib.so or other desired libraries
|
||||
# into each example binary compiled with RAYLIB_LIBTYPE=SHARED. It defaults to RAYLIB_RELEASE_PATH
|
||||
# so that these examples link at runtime with your version of libraylib.so in ../release/libs/linux
|
||||
# without formal installation from ../src/Makefile. It aids portability and is useful if you have
|
||||
# multiple versions of raylib, have raylib installed to a non-standard location, or want to
|
||||
# bundle libraylib.so with your game. Change it to your liking.
|
||||
# Note: If, at runtime, there is a libraylib.so at both EXAMPLE_RUNTIME_PATH and RAYLIB_INSTALL_PATH,
|
||||
# The library at EXAMPLE_RUNTIME_PATH, if present, will take precedence over RAYLIB_INSTALL_PATH,
|
||||
# Implemented for LINUX below with CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH)
|
||||
# To see the result, run readelf -d core/core_basic_window; looking at the RPATH or RUNPATH attribute.
|
||||
# To see which libraries a built example is linking to, ldd core/core_basic_window;
|
||||
# Look for libraylib.so.1 => $(RAYLIB_INSTALL_PATH)/libraylib.so.1 or similar listing.
|
||||
EXAMPLE_RUNTIME_PATH ?= $(RAYLIB_RELEASE_PATH)
|
||||
|
||||
# Define default C compiler: gcc
|
||||
# NOTE: define g++ compiler if using C++
|
||||
CC = gcc
|
||||
@@ -117,8 +172,8 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
# OSX default compiler
|
||||
CC = clang
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),FREEBSD)
|
||||
# FreeBSD default compiler
|
||||
ifeq ($(PLATFORM_OS),BSD)
|
||||
# FreeBSD, OpenBSD, NetBSD, DragonFly default compiler
|
||||
CC = clang
|
||||
endif
|
||||
endif
|
||||
@@ -130,6 +185,7 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
|
||||
# HTML5 emscripten compiler
|
||||
CC = emcc
|
||||
endif
|
||||
@@ -150,61 +206,97 @@ endif
|
||||
# -Wall turns on most, but not all, compiler warnings
|
||||
# -std=c99 defines C language mode (standard C from 1999 revision)
|
||||
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
||||
# -fgnu89-inline declaring inline functions support (GCC optimized)
|
||||
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
|
||||
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
|
||||
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces
|
||||
CFLAGS += -O1 -s -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
|
||||
|
||||
# Additional flags for compiler (if desired)
|
||||
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||
# resources file contains windows exe icon
|
||||
# resource file contains windows executable icon and properties
|
||||
# -Wl,--subsystem,windows hides the console window
|
||||
CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows
|
||||
CFLAGS += $(RAYLIB_PATH)/raylib.rc.o -Wl,--subsystem,windows
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),LINUX)
|
||||
CFLAGS += -no-pie -D_DEFAULT_SOURCE
|
||||
ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
|
||||
CFLAGS += -g
|
||||
#CC = clang
|
||||
endif
|
||||
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
||||
CFLAGS += -D_DEFAULT_SOURCE
|
||||
endif
|
||||
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
||||
# Explicitly enable runtime link to libraylib.so
|
||||
CFLAGS += -Wl,-rpath,$(EXAMPLE_RUNTIME_PATH)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||
CFLAGS += -std=gnu99
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
# -O2 # if used, also set --memory-init-file 0
|
||||
# -Os # size optimization
|
||||
# -O2 # optimization level 2, if used, also set --memory-init-file 0
|
||||
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
||||
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
|
||||
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
|
||||
# -s USE_PTHREADS=1 # multithreading support
|
||||
# -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly)
|
||||
# -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow)
|
||||
# -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter
|
||||
# --profiling # include information for code profiling
|
||||
# --preload-file resources # specify a resources folder for data compilation
|
||||
CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 --profiling --preload-file resources
|
||||
CFLAGS += -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1
|
||||
|
||||
# NOTE: Simple raylib examples are compiled to be interpreter by emterpreter, that way,
|
||||
# we can compile same code for ALL platforms with no change required, but, working on bigger
|
||||
# projects, code needs to be refactored to avoid a blocking while() loop, moving Update and Draw
|
||||
# logic to a self contained function: UpdateDrawFrame(), check core_basic_window_web.c for reference.
|
||||
|
||||
# Define a custom shell .html and output extension
|
||||
CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html
|
||||
EXT = .html
|
||||
endif
|
||||
|
||||
# Define include paths for required headers
|
||||
# Define include paths for required headers.
|
||||
# Precedence: immediately local, raysan5 provided sources
|
||||
# NOTE: Several external required libraries (stb and others)
|
||||
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
|
||||
|
||||
# Define additional directories containing required header files
|
||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||
# RPI requried libraries
|
||||
# RPI required libraries
|
||||
INCLUDE_PATHS += -I/opt/vc/include
|
||||
INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux
|
||||
INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(PLATFORM_OS),BSD)
|
||||
# Consider -L$(RAYLIB_H_INSTALL_PATH)
|
||||
INCLUDE_PATHS += -I/usr/local/include
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),LINUX)
|
||||
# Reset everything.
|
||||
# Precedence: immediately local, installed version, raysan5 provided libs -I$(RAYLIB_H_INSTALL_PATH) -I$(RAYLIB_PATH)/release/include
|
||||
INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -isystem. -isystem$(RAYLIB_PATH)/src -isystem$(RAYLIB_PATH)/release/include -isystem$(RAYLIB_PATH)/src/external
|
||||
endif
|
||||
endif
|
||||
|
||||
# Define library paths containing required libs
|
||||
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
|
||||
# Define library paths containing required libs.
|
||||
# Precedence: immediately local, then raysan5 provided libs
|
||||
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
|
||||
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(PLATFORM_OS),FREEBSD)
|
||||
INCLUDE_PATHS += -I/usr/local/include
|
||||
ifeq ($(PLATFORM_OS),BSD)
|
||||
# Consider -L$(RAYLIB_INSTALL_PATH)
|
||||
LDFLAGS += -L. -Lsrc -L/usr/local/lib
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),LINUX)
|
||||
# Reset everything.
|
||||
# Precedence: immediately local, installed version, raysan5 provided libs
|
||||
LDFLAGS = -L. -L$(RAYLIB_INSTALL_PATH) -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||
@@ -217,7 +309,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||
# Libraries for Windows desktop compilation
|
||||
LDLIBS = -lraylib -lopengl32 -lgdi32
|
||||
|
||||
# Required for physac examples
|
||||
LDLIBS += -static -lpthread
|
||||
endif
|
||||
@@ -225,27 +316,28 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
# Libraries for Debian GNU/Linux desktop compiling
|
||||
# NOTE: Required packages: libegl1-mesa-dev
|
||||
LDLIBS = -lraylib -lGL -lm -lpthread -ldl -lrt
|
||||
|
||||
# On X11 requires also below libraries
|
||||
LDLIBS += -lX11
|
||||
# NOTE: It seems additional libraries are not required any more, latest GLFW just dlopen them
|
||||
#LDLIBS += -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
|
||||
|
||||
# On Wayland windowing system, additional libraries requires
|
||||
ifeq ($(USE_WAYLAND_DISPLAY),TRUE)
|
||||
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
|
||||
endif
|
||||
# Explicit link to libc
|
||||
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
||||
LDLIBS += -lc
|
||||
endif
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),OSX)
|
||||
# Libraries for OSX 10.9 desktop compiling
|
||||
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
||||
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),FREEBSD)
|
||||
# Libraries for FreeBSD desktop compiling
|
||||
ifeq ($(PLATFORM_OS),BSD)
|
||||
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
||||
# NOTE: Required packages: mesa-libs
|
||||
LDLIBS = -lraylib -lGL -lpthread -lm
|
||||
|
||||
# On XWindow requires also below libraries
|
||||
LDLIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
|
||||
endif
|
||||
@@ -307,6 +399,7 @@ EXAMPLES = \
|
||||
text/text_ttf_loading \
|
||||
text/text_bmfont_unordered \
|
||||
text/text_input_box \
|
||||
text/text_font_sdf \
|
||||
models/models_geometric_shapes \
|
||||
models/models_box_collisions \
|
||||
models/models_billboard \
|
||||
@@ -360,7 +453,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
del *.o *.exe /s
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),LINUX)
|
||||
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f
|
||||
find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -fv
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),OSX)
|
||||
find . -type f -perm +ugo+x -delete
|
||||
@@ -369,10 +462,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||
find . -type f -executable -delete
|
||||
rm -f *.o
|
||||
rm -fv *.o
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
del *.o *.html *.js
|
||||
endif
|
||||
@echo Cleaning done
|
||||
|
||||
|
298
examples/Makefile.Android
Normal file
@@ -0,0 +1,298 @@
|
||||
#**************************************************************************************************
|
||||
#
|
||||
# raylib makefile for Android project (APK building)
|
||||
#
|
||||
# Copyright (c) 2017 Ramon Santamaria (@raysan5)
|
||||
#
|
||||
# This software is provided "as-is", without any express or implied warranty. In no event
|
||||
# will the authors be held liable for any damages arising from the use of this software.
|
||||
#
|
||||
# Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
# applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
#
|
||||
# 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
# wrote the original software. If you use this software in a product, an acknowledgment
|
||||
# in the product documentation would be appreciated but is not required.
|
||||
#
|
||||
# 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
# as being the original software.
|
||||
#
|
||||
# 3. This notice may not be removed or altered from any source distribution.
|
||||
#
|
||||
#**************************************************************************************************
|
||||
|
||||
# Define required raylib variables
|
||||
PLATFORM ?= PLATFORM_ANDROID
|
||||
RAYLIB_PATH ?= ..\..
|
||||
|
||||
# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version
|
||||
ANDROID_ARCH ?= ARM
|
||||
ANDROID_API_VERSION = 21
|
||||
ifeq ($(ANDROID_ARCH),ARM)
|
||||
ANDROID_ARCH_NAME = armeabi-v7a
|
||||
endif
|
||||
ifeq ($(ANDROID_ARCH),ARM64)
|
||||
ANDROID_ARCH_NAME = arm64-v8a
|
||||
endif
|
||||
|
||||
# Required path variables
|
||||
# NOTE: JAVA_HOME must be set to JDK
|
||||
JAVA_HOME ?= C:/JavaJDK
|
||||
ANDROID_HOME = C:/android-sdk
|
||||
ANDROID_TOOLCHAIN = C:/android_toolchain_$(ANDROID_ARCH)_API$(ANDROID_API_VERSION)
|
||||
ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/28.0.1
|
||||
ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools
|
||||
|
||||
# Android project configuration variables
|
||||
PROJECT_NAME ?= raylib_game
|
||||
PROJECT_LIBRARY_NAME ?= main
|
||||
PROJECT_BUILD_PATH ?= android.$(PROJECT_NAME)
|
||||
PROJECT_RESOURCES_PATH ?= resources
|
||||
PROJECT_SOURCE_FILES ?= raylib_game.c
|
||||
|
||||
# Some source files are placed in directories, when compiling to some
|
||||
# output directory other than source, that directory must pre-exist.
|
||||
# Here we get a list of required folders that need to be created on
|
||||
# code output folder $(PROJECT_BUILD_PATH)\obj to avoid GCC errors.
|
||||
PROJECT_SOURCE_DIRS = $(sort $(dir $(PROJECT_SOURCE_FILES)))
|
||||
|
||||
# Android app configuration variables
|
||||
APP_LABEL_NAME ?= rGame
|
||||
APP_COMPANY_NAME ?= raylib
|
||||
APP_PRODUCT_NAME ?= rgame
|
||||
APP_VERSION_CODE ?= 1
|
||||
APP_VERSION_NAME ?= 1.0
|
||||
APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png
|
||||
APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png
|
||||
APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png
|
||||
APP_SCREEN_ORIENTATION ?= landscape
|
||||
APP_KEYSTORE_PASS ?= raylib
|
||||
|
||||
# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)
|
||||
RAYLIB_LIBTYPE ?= STATIC
|
||||
RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\$(ANDROID_ARCH_NAME)
|
||||
|
||||
# Shared libs must be added to APK if required
|
||||
# NOTE: Generated NativeLoader.java automatically load those libraries
|
||||
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
||||
PROJECT_SHARED_LIBS = lib/$(ANDROID_ARCH_NAME)/libraylib.so
|
||||
endif
|
||||
|
||||
# Compiler and archiver
|
||||
# NOTE: GCC is being deprecated in Android NDK r16
|
||||
ifeq ($(ANDROID_ARCH),ARM)
|
||||
CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-clang
|
||||
AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar
|
||||
endif
|
||||
ifeq ($(ANDROID_ARCH),ARM64)
|
||||
CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-clang
|
||||
AR = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-ar
|
||||
endif
|
||||
|
||||
# Compiler flags for arquitecture
|
||||
ifeq ($(ANDROID_ARCH),ARM)
|
||||
CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
|
||||
endif
|
||||
ifeq ($(ANDROID_ARCH),ARM64)
|
||||
CFLAGS = -std=c99 -target aarch64 -mfix-cortex-a53-835769
|
||||
endif
|
||||
# Compilation functions attributes options
|
||||
CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC
|
||||
# Compiler options for the linker
|
||||
CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes
|
||||
# Preprocessor macro definitions
|
||||
CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION)
|
||||
|
||||
# Paths containing required header files
|
||||
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/release/include -I$(RAYLIB_PATH)/src/external/android/native_app_glue
|
||||
|
||||
# Linker options
|
||||
LDFLAGS = -Wl,-soname,lib$(PROJECT_LIBRARY_NAME).so -Wl,--exclude-libs,libatomic.a
|
||||
LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings
|
||||
# Force linking of library module to define symbol
|
||||
LDFLAGS += -u ANativeActivity_onCreate
|
||||
# Library paths containing required libs
|
||||
LDFLAGS += -L. -L$(PROJECT_BUILD_PATH)/obj -L$(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME) -L$(ANDROID_TOOLCHAIN)\sysroot\usr\lib
|
||||
|
||||
# Define any libraries to link into executable
|
||||
# if you want to link libraries (libname.so or libname.a), use the -lname
|
||||
LDLIBS = -lm -lc -lraylib -llog -landroid -lEGL -lGLESv2 -lOpenSLES -ldl
|
||||
|
||||
# Generate target objects list from PROJECT_SOURCE_FILES
|
||||
OBJS = $(patsubst %.c, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES))
|
||||
|
||||
# Android APK building process... some steps required...
|
||||
# NOTE: typing 'make' will invoke the default target entry called 'all',
|
||||
all: create_temp_project_dirs \
|
||||
copy_project_required_libs \
|
||||
copy_project_resources \
|
||||
generate_loader_script \
|
||||
generate_android_manifest \
|
||||
generate_apk_keystore \
|
||||
config_project_package \
|
||||
compile_project_code \
|
||||
compile_project_class \
|
||||
compile_project_class_dex \
|
||||
create_project_apk_package \
|
||||
sign_project_apk_package \
|
||||
zipalign_project_apk_package
|
||||
|
||||
# Create required temp directories for APK building
|
||||
create_temp_project_dirs:
|
||||
if not exist $(PROJECT_BUILD_PATH) mkdir $(PROJECT_BUILD_PATH)
|
||||
if not exist $(PROJECT_BUILD_PATH)\obj mkdir $(PROJECT_BUILD_PATH)\obj
|
||||
if not exist $(PROJECT_BUILD_PATH)\src mkdir $(PROJECT_BUILD_PATH)\src
|
||||
if not exist $(PROJECT_BUILD_PATH)\src\com mkdir $(PROJECT_BUILD_PATH)\src\com
|
||||
if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)
|
||||
if not exist $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME) mkdir $(PROJECT_BUILD_PATH)\src\com\$(APP_COMPANY_NAME)\$(APP_PRODUCT_NAME)
|
||||
if not exist $(PROJECT_BUILD_PATH)\lib mkdir $(PROJECT_BUILD_PATH)\lib
|
||||
if not exist $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME) mkdir $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)
|
||||
if not exist $(PROJECT_BUILD_PATH)\bin mkdir $(PROJECT_BUILD_PATH)\bin
|
||||
if not exist $(PROJECT_BUILD_PATH)\res mkdir $(PROJECT_BUILD_PATH)\res
|
||||
if not exist $(PROJECT_BUILD_PATH)\res\drawable-ldpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-ldpi
|
||||
if not exist $(PROJECT_BUILD_PATH)\res\drawable-mdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-mdpi
|
||||
if not exist $(PROJECT_BUILD_PATH)\res\drawable-hdpi mkdir $(PROJECT_BUILD_PATH)\res\drawable-hdpi
|
||||
if not exist $(PROJECT_BUILD_PATH)\res\values mkdir $(PROJECT_BUILD_PATH)\res\values
|
||||
if not exist $(PROJECT_BUILD_PATH)\assets mkdir $(PROJECT_BUILD_PATH)\assets
|
||||
if not exist $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) mkdir $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH)
|
||||
if not exist $(PROJECT_BUILD_PATH)\obj\screens mkdir $(PROJECT_BUILD_PATH)\obj\screens
|
||||
$(foreach dir, $(PROJECT_SOURCE_DIRS), $(call create_dir, $(dir)))
|
||||
|
||||
define create_dir
|
||||
if not exist $(PROJECT_BUILD_PATH)\obj\$(1) mkdir $(PROJECT_BUILD_PATH)\obj\$(1)
|
||||
endef
|
||||
|
||||
# Copy required shared libs for integration into APK
|
||||
# NOTE: If using shared libs they are loaded by generated NativeLoader.java
|
||||
copy_project_required_libs:
|
||||
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
||||
copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.so
|
||||
endif
|
||||
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
||||
copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\$(ANDROID_ARCH_NAME)\libraylib.a
|
||||
endif
|
||||
|
||||
# Copy project required resources: strings.xml, icon.png, assets
|
||||
# NOTE: Required strings.xml is generated and game resources are copied to assets folder
|
||||
# TODO: Review xcopy usage, it can not be found in some systems!
|
||||
copy_project_resources:
|
||||
copy $(APP_ICON_LDPI) $(PROJECT_BUILD_PATH)\res\drawable-ldpi\icon.png /Y
|
||||
copy $(APP_ICON_MDPI) $(PROJECT_BUILD_PATH)\res\drawable-mdpi\icon.png /Y
|
||||
copy $(APP_ICON_HDPI) $(PROJECT_BUILD_PATH)\res\drawable-hdpi\icon.png /Y
|
||||
@echo ^<?xml version="1.0" encoding="utf-8"^?^> > $(PROJECT_BUILD_PATH)/res/values/strings.xml
|
||||
@echo ^<resources^>^<string name="app_name"^>$(APP_LABEL_NAME)^</string^>^</resources^> >> $(PROJECT_BUILD_PATH)/res/values/strings.xml
|
||||
if exist $(PROJECT_RESOURCES_PATH) C:\Windows\System32\xcopy $(PROJECT_RESOURCES_PATH) $(PROJECT_BUILD_PATH)\assets\$(PROJECT_RESOURCES_PATH) /Y /E /F
|
||||
|
||||
# Generate NativeLoader.java to load required shared libraries
|
||||
# NOTE: Probably not the bet way to generate this file... but it works.
|
||||
generate_loader_script:
|
||||
@echo package com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME); > $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
||||
@echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
||||
@echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
||||
@echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
||||
ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
||||
@echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
||||
endif
|
||||
@echo System.loadLibrary("$(PROJECT_LIBRARY_NAME)"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
||||
@echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
||||
@echo } >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
||||
|
||||
# Generate AndroidManifest.xml with all the required options
|
||||
# NOTE: Probably not the bet way to generate this file... but it works.
|
||||
generate_android_manifest:
|
||||
@echo ^<?xml version="1.0" encoding="utf-8"^?^> > $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo ^<manifest xmlns:android="http://schemas.android.com/apk/res/android" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo package="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME)" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo android:versionCode="$(APP_VERSION_CODE)" android:versionName="$(APP_VERSION_NAME)" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo ^<uses-sdk android:minSdkVersion="$(ANDROID_API_VERSION)" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo ^<uses-feature android:glEsVersion="0x00020000" android:required="true" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo ^<application android:allowBackup="false" android:label="@string/app_name" android:icon="@drawable/icon" ^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo ^<activity android:name="com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME).NativeLoader" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo android:configChanges="orientation|keyboardHidden|screenSize" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo android:screenOrientation="$(APP_SCREEN_ORIENTATION)" android:launchMode="singleTask" >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo android:clearTaskOnLaunch="true"^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo ^<meta-data android:name="android.app.lib_name" android:value="$(PROJECT_LIBRARY_NAME)" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo ^<intent-filter^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo ^<action android:name="android.intent.action.MAIN" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo ^<category android:name="android.intent.category.LAUNCHER" /^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo ^</intent-filter^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo ^</activity^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo ^</application^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
@echo ^</manifest^> >> $(PROJECT_BUILD_PATH)/AndroidManifest.xml
|
||||
|
||||
# Generate storekey for APK signing: $(PROJECT_NAME).keystore
|
||||
# NOTE: Configure here your Distinguished Names (-dname) if required!
|
||||
generate_apk_keystore:
|
||||
if not exist $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=$(APP_COMPANY_NAME),O=Android,C=ES" -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -alias $(PROJECT_NAME)Key -keyalg RSA
|
||||
|
||||
# Config project package and resource using AndroidManifest.xml and res/values/strings.xml
|
||||
# NOTE: Generates resources file: src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java
|
||||
config_project_package:
|
||||
$(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(PROJECT_BUILD_PATH)/res -J $(PROJECT_BUILD_PATH)/src -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar
|
||||
|
||||
# Compile native_app_glue code as static library: obj/libnative_app_glue.a
|
||||
compile_native_app_glue:
|
||||
$(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS)
|
||||
$(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o
|
||||
|
||||
# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so
|
||||
compile_project_code: $(OBJS)
|
||||
$(CC) -o $(PROJECT_BUILD_PATH)/lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS)
|
||||
|
||||
# Compile all .c files required into object (.o) files
|
||||
# NOTE: Those files will be linked into a shared library
|
||||
$(PROJECT_BUILD_PATH)/obj/%.o:%.c
|
||||
$(CC) -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot
|
||||
|
||||
# Compile project .java code into .class (Java bytecode)
|
||||
compile_project_class:
|
||||
$(JAVA_HOME)/bin/javac -verbose -source 1.7 -target 1.7 -d $(PROJECT_BUILD_PATH)/obj -bootclasspath $(JAVA_HOME)/jre/lib/rt.jar -classpath $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar;$(PROJECT_BUILD_PATH)/obj -sourcepath $(PROJECT_BUILD_PATH)/src $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/R.java $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java
|
||||
|
||||
# Compile .class files into Dalvik executable bytecode (.dex)
|
||||
# NOTE: Since Android 5.0, Dalvik interpreter (JIT) has been replaced by ART (AOT)
|
||||
compile_project_class_dex:
|
||||
$(ANDROID_BUILD_TOOLS)/dx --verbose --dex --output=$(PROJECT_BUILD_PATH)/bin/classes.dex $(PROJECT_BUILD_PATH)/obj
|
||||
|
||||
# Create Android APK package: bin/$(PROJECT_NAME).unsigned.apk
|
||||
# NOTE: Requires compiled classes.dex and lib$(PROJECT_LIBRARY_NAME).so
|
||||
# NOTE: Use -A resources to define additional directory in which to find raw asset files
|
||||
create_project_apk_package:
|
||||
$(ANDROID_BUILD_TOOLS)/aapt package -f -M $(PROJECT_BUILD_PATH)/AndroidManifest.xml -S $(PROJECT_BUILD_PATH)/res -A $(PROJECT_BUILD_PATH)/assets -I $(ANDROID_HOME)/platforms/android-$(ANDROID_API_VERSION)/android.jar -F $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_BUILD_PATH)/bin
|
||||
cd $(PROJECT_BUILD_PATH) && $(ANDROID_BUILD_TOOLS)/aapt add bin/$(PROJECT_NAME).unsigned.apk lib/$(ANDROID_ARCH_NAME)/lib$(PROJECT_LIBRARY_NAME).so $(PROJECT_SHARED_LIBS)
|
||||
|
||||
# Create signed APK package using generated Key: bin/$(PROJECT_NAME).signed.apk
|
||||
sign_project_apk_package:
|
||||
$(JAVA_HOME)/bin/jarsigner -keystore $(PROJECT_BUILD_PATH)/$(PROJECT_NAME).keystore -storepass $(APP_KEYSTORE_PASS) -keypass $(APP_KEYSTORE_PASS) -signedjar $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).unsigned.apk $(PROJECT_NAME)Key
|
||||
|
||||
# Create zip-aligned APK package: $(PROJECT_NAME).apk
|
||||
zipalign_project_apk_package:
|
||||
$(ANDROID_BUILD_TOOLS)/zipalign -f 4 $(PROJECT_BUILD_PATH)/bin/$(PROJECT_NAME).signed.apk $(PROJECT_NAME).apk
|
||||
|
||||
# Install $(PROJECT_NAME).apk to default emulator/device
|
||||
# NOTE: Use -e (emulator) or -d (device) parameters if required
|
||||
install:
|
||||
$(ANDROID_PLATFORM_TOOLS)/adb install --abi $(ANDROID_ARCH_NAME) -rds $(PROJECT_NAME).apk
|
||||
|
||||
# Check supported ABI for the device (armeabi-v7a, arm64-v8a, x86, x86_64)
|
||||
check_device_abi:
|
||||
$(ANDROID_PLATFORM_TOOLS)/adb shell getprop ro.product.cpu.abi
|
||||
|
||||
# Monitorize output log coming from device, only raylib tag
|
||||
logcat:
|
||||
$(ANDROID_PLATFORM_TOOLS)/adb logcat -c
|
||||
$(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S
|
||||
|
||||
# Install and monitorize $(PROJECT_NAME).apk to default emulator/device
|
||||
deploy:
|
||||
$(ANDROID_PLATFORM_TOOLS)/adb install -r $(PROJECT_NAME).apk
|
||||
$(ANDROID_PLATFORM_TOOLS)/adb logcat -c
|
||||
$(ANDROID_PLATFORM_TOOLS)/adb logcat raylib:V *:S
|
||||
|
||||
#$(ANDROID_PLATFORM_TOOLS)/adb logcat *:W
|
||||
|
||||
# Clean everything
|
||||
clean:
|
||||
del $(PROJECT_BUILD_PATH)\* /f /s /q
|
||||
rmdir $(PROJECT_BUILD_PATH) /s /q
|
||||
@echo Cleaning done
|
BIN
examples/audio/resources/applause.mp3
Normal file
@@ -97,7 +97,7 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin2dMode(camera);
|
||||
BeginMode2D(camera);
|
||||
|
||||
DrawRectangle(-6000, 320, 13000, 8000, DARKGRAY);
|
||||
|
||||
@@ -108,7 +108,7 @@ int main()
|
||||
DrawRectangle(camera.target.x, -500, 1, screenHeight*4, GREEN);
|
||||
DrawRectangle(-500, camera.target.y, screenWidth*4, 1, GREEN);
|
||||
|
||||
End2dMode();
|
||||
EndMode2D();
|
||||
|
||||
DrawText("SCREEN AREA", 640, 10, 20, RED);
|
||||
|
||||
|
@@ -23,7 +23,12 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person");
|
||||
|
||||
// Define the camera to look into our 3d world (position, target, up vector)
|
||||
Camera camera = {{ 4.0f, 2.0f, 4.0f }, { 0.0f, 1.8f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 60.0f };
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 4.0f, 2.0f, 4.0f };
|
||||
camera.target = (Vector3){ 0.0f, 1.8f, 0.0f };
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||
camera.fovy = 60.0f;
|
||||
camera.type = CAMERA_PERSPECTIVE;
|
||||
|
||||
// Generates some random columns
|
||||
float heights[MAX_COLUMNS];
|
||||
@@ -56,7 +61,7 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawPlane((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector2){ 32.0f, 32.0f }, LIGHTGRAY); // Draw ground
|
||||
DrawCube((Vector3){ -16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, BLUE); // Draw a blue wall
|
||||
@@ -70,7 +75,7 @@ int main()
|
||||
DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, MAROON);
|
||||
}
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines( 10, 10, 220, 70, BLUE);
|
||||
|
@@ -21,11 +21,12 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera;
|
||||
Camera3D camera;
|
||||
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.type = CAMERA_PERSPECTIVE; // Camera mode type
|
||||
|
||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
@@ -50,14 +51,14 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
||||
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
DrawRectangle( 10, 10, 320, 133, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines( 10, 10, 320, 133, BLUE);
|
||||
|
@@ -21,11 +21,12 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera;
|
||||
Camera3D camera;
|
||||
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.type = CAMERA_PERSPECTIVE; // Camera mode type
|
||||
|
||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
@@ -46,14 +47,14 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
||||
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY);
|
||||
|
||||
|
@@ -26,14 +26,15 @@ int main()
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.type = CAMERA_PERSPECTIVE; // Camera mode type
|
||||
|
||||
Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
|
||||
Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
|
||||
|
||||
Ray ray; // Picking line ray
|
||||
|
||||
|
||||
Ray ray = {0.0f, 0.0f, 0.0f}; // Picking line ray
|
||||
|
||||
bool collision = false;
|
||||
|
||||
|
||||
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
@@ -45,11 +46,11 @@ int main()
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera); // Update camera
|
||||
|
||||
|
||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||
{
|
||||
ray = GetMouseRay(GetMousePosition(), camera);
|
||||
|
||||
|
||||
// Check collision between ray and box
|
||||
collision = CheckCollisionRayBox(ray,
|
||||
(BoundingBox){(Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 },
|
||||
@@ -63,9 +64,9 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
if (collision)
|
||||
if (collision)
|
||||
{
|
||||
DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, RED);
|
||||
DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, MAROON);
|
||||
@@ -77,15 +78,14 @@ int main()
|
||||
DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY);
|
||||
DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY);
|
||||
}
|
||||
|
||||
|
||||
DrawRay(ray, MAROON);
|
||||
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
End3dMode();
|
||||
|
||||
EndMode3D();
|
||||
|
||||
DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY);
|
||||
|
||||
|
||||
if(collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, screenHeight * 0.1f, 30, GREEN);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
@@ -100,4 +100,4 @@ int main()
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -30,10 +30,10 @@ int main()
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 0.8f;
|
||||
if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 0.8f;
|
||||
if (IsKeyDown(KEY_UP)) ballPosition.y -= 0.8f;
|
||||
if (IsKeyDown(KEY_DOWN)) ballPosition.y += 0.8f;
|
||||
if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 2.0f;
|
||||
if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 2.0f;
|
||||
if (IsKeyDown(KEY_UP)) ballPosition.y -= 2.0f;
|
||||
if (IsKeyDown(KEY_DOWN)) ballPosition.y += 2.0f;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
@@ -31,6 +31,7 @@ int main()
|
||||
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 60.0f; // Camera field-of-view Y
|
||||
camera.type = CAMERA_PERSPECTIVE; // Camera type
|
||||
|
||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
@@ -57,14 +58,14 @@ int main()
|
||||
|
||||
BeginVrDrawing();
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
||||
|
||||
DrawGrid(40, 1.0f);
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
EndVrDrawing();
|
||||
|
||||
|
@@ -21,7 +21,12 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 10.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f };
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||
camera.fovy = 45.0f;
|
||||
camera.type = CAMERA_PERSPECTIVE;
|
||||
|
||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
@@ -49,14 +54,14 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
||||
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
DrawText("Enemy: 100 / 100", cubeScreenPosition.x - MeasureText("Enemy: 100 / 100", 20) / 2, cubeScreenPosition.y, 20, BLACK);
|
||||
DrawText("Text is always on top of the cube", (screenWidth - MeasureText("Text is always on top of the cube", 20)) / 2, 25, 20, GRAY);
|
||||
|
@@ -21,7 +21,13 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 5.0f, 4.0f, 5.0f }, { 0.0f, 2.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 5.0f, 4.0f, 5.0f };
|
||||
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||
camera.fovy = 45.0f;
|
||||
camera.type = CAMERA_PERSPECTIVE;
|
||||
|
||||
|
||||
Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard
|
||||
Vector3 billPosition = { 0.0f, 2.0f, 0.0f }; // Position where draw billboard
|
||||
@@ -45,13 +51,13 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawBillboard(camera, bill, billPosition, 2.0f, WHITE);
|
||||
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
|
@@ -21,7 +21,7 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||
|
||||
Vector3 playerPosition = { 0.0f, 1.0f, 2.0f };
|
||||
Vector3 playerSize = { 1.0f, 2.0f, 1.0f };
|
||||
@@ -87,7 +87,7 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
// Draw enemy-box
|
||||
DrawCube(enemyBoxPos, enemyBoxSize.x, enemyBoxSize.y, enemyBoxSize.z, GRAY);
|
||||
@@ -102,7 +102,7 @@ int main()
|
||||
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
DrawText("Move player with cursors to collide", 220, 40, 20, GRAY);
|
||||
|
||||
|
@@ -21,7 +21,7 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
Camera camera = {{ 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||
|
||||
Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
|
||||
Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM)
|
||||
@@ -56,11 +56,11 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModel(model, mapPosition, 1.0f, WHITE);
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
DrawTextureEx(cubicmap, (Vector2){ screenWidth - cubicmap.width*4 - 20, 20 }, 0.0f, 4.0f, WHITE);
|
||||
DrawRectangleLines(screenWidth - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN);
|
||||
|
@@ -21,7 +21,12 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f };
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||
camera.fovy = 45.0f;
|
||||
camera.type = CAMERA_PERSPECTIVE;
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -40,7 +45,7 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED);
|
||||
DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD);
|
||||
@@ -58,7 +63,7 @@ int main()
|
||||
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
|
@@ -21,7 +21,7 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
|
||||
|
||||
// Define our custom camera to look into our 3d world
|
||||
Camera camera = {{ 18.0f, 16.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
Camera camera = {{ 18.0f, 16.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||
|
||||
Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
|
||||
Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
|
||||
@@ -53,13 +53,13 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModel(model, mapPosition, 1.0f, RED);
|
||||
|
||||
DrawGrid(20, 1.0f);
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
DrawTexture(texture, screenWidth - texture.width - 20, 20, WHITE);
|
||||
DrawRectangleLines(screenWidth - texture.width - 20, 20, texture.width, texture.height, GREEN);
|
||||
|
@@ -34,10 +34,11 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - pbr material");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 4.0f, 4.0f, 4.0f }, { 0.0f, 0.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
Camera camera = {{ 4.0f, 4.0f, 4.0f }, { 0.0f, 0.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||
|
||||
// Load model and PBR material
|
||||
Model model = LoadModel("resources/pbr/trooper.obj");
|
||||
MeshTangents(&model.mesh);
|
||||
model.material = LoadMaterialPBR((Color){ 255, 255, 255, 255 }, 1.0f, 1.0f);
|
||||
|
||||
// Define lights attributes
|
||||
@@ -72,13 +73,13 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModel(model, Vector3Zero(), 1.0f, WHITE);
|
||||
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
@@ -113,7 +114,7 @@ static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
|
||||
mat.shader.locs[LOC_MAP_METALNESS] = GetShaderLocation(mat.shader, "metalness.sampler");
|
||||
mat.shader.locs[LOC_MAP_NORMAL] = GetShaderLocation(mat.shader, "normals.sampler");
|
||||
mat.shader.locs[LOC_MAP_ROUGHNESS] = GetShaderLocation(mat.shader, "roughness.sampler");
|
||||
mat.shader.locs[LOC_MAP_OCCUSION] = GetShaderLocation(mat.shader, "occlusion.sampler");
|
||||
mat.shader.locs[LOC_MAP_OCCLUSION] = GetShaderLocation(mat.shader, "occlusion.sampler");
|
||||
//mat.shader.locs[LOC_MAP_EMISSION] = GetShaderLocation(mat.shader, "emission.sampler");
|
||||
//mat.shader.locs[LOC_MAP_HEIGHT] = GetShaderLocation(mat.shader, "height.sampler");
|
||||
mat.shader.locs[LOC_MAP_IRRADIANCE] = GetShaderLocation(mat.shader, "irradianceMap");
|
||||
@@ -121,7 +122,7 @@ static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
|
||||
mat.shader.locs[LOC_MAP_BRDF] = GetShaderLocation(mat.shader, "brdfLUT");
|
||||
|
||||
// Set view matrix location
|
||||
mat.shader.locs[LOC_MATRIX_MODEL] = GetShaderLocation(mat.shader, "mMatrix");
|
||||
mat.shader.locs[LOC_MATRIX_MODEL] = GetShaderLocation(mat.shader, "matModel");
|
||||
mat.shader.locs[LOC_MATRIX_VIEW] = GetShaderLocation(mat.shader, "view");
|
||||
mat.shader.locs[LOC_VECTOR_VIEW] = GetShaderLocation(mat.shader, "viewPos");
|
||||
|
||||
@@ -151,7 +152,7 @@ static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
|
||||
SetShaderValuei(shdrIrradiance, GetShaderLocation(shdrIrradiance, "environmentMap"), (int[1]){ 0 }, 1);
|
||||
SetShaderValuei(shdrPrefilter, GetShaderLocation(shdrPrefilter, "environmentMap"), (int[1]){ 0 }, 1);
|
||||
|
||||
Texture2D texHDR = LoadTexture("resources/pinetree.hdr");
|
||||
Texture2D texHDR = LoadTexture("resources/dresden_square.hdr");
|
||||
Texture2D cubemap = GenTextureCubemap(shdrCubemap, texHDR, CUBEMAP_SIZE);
|
||||
mat.maps[MAP_IRRADIANCE].texture = GenTextureIrradiance(shdrIrradiance, cubemap, IRRADIANCE_SIZE);
|
||||
mat.maps[MAP_PREFILTER].texture = GenTexturePrefilter(shdrPrefilter, cubemap, PREFILTERED_SIZE);
|
||||
@@ -192,4 +193,4 @@ static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
|
||||
mat.maps[MAP_HEIGHT].value = 0.5f;
|
||||
|
||||
return mat;
|
||||
}
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ int main()
|
||||
for (int i = 0; i < NUM_MODELS; i++) models[i].material.maps[MAP_DIFFUSE].texture = texture;
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 5.0f, 5.0f, 5.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
Camera camera = {{ 5.0f, 5.0f, 5.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||
|
||||
// Model drawing position
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f };
|
||||
@@ -72,13 +72,13 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModel(models[currentModel], position, 1.0f, WHITE);
|
||||
|
||||
DrawGrid(10, 1.0);
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
DrawRectangle(30, 400, 310, 30, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines(30, 400, 310, 30, Fade(DARKBLUE, 0.5f));
|
||||
|
@@ -26,19 +26,20 @@ int main()
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera;
|
||||
camera.position = (Vector3){ 10.0f, 8.0f, 10.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 2.3f, 0.0f }; // Camera looking at point
|
||||
camera.position = (Vector3){ 20.0f, 20.0f, 20.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 8.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.type = CAMERA_PERSPECTIVE; // Camera mode type
|
||||
|
||||
Ray ray; // Picking ray
|
||||
|
||||
Model tower = LoadModel("resources/tower.obj"); // Load OBJ model
|
||||
Texture2D texture = LoadTexture("resources/tower.png"); // Load model texture
|
||||
tower.material.maps[MAP_DIFFUSE].texture = texture; // Set model diffuse texture
|
||||
Model tower = LoadModel("resources/models/turret.obj"); // Load OBJ model
|
||||
Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load model texture
|
||||
tower.material.maps[MAP_DIFFUSE].texture = texture; // Set model diffuse texture
|
||||
|
||||
Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
BoundingBox towerBBox = CalculateBoundingBox(tower.mesh);
|
||||
BoundingBox towerBBox = MeshBoundingBox(tower.mesh); // Get mesh bounding box
|
||||
bool hitMeshBBox = false;
|
||||
bool hitTriangle = false;
|
||||
|
||||
@@ -101,8 +102,9 @@ int main()
|
||||
{
|
||||
hitMeshBBox = true;
|
||||
|
||||
// Check ray collision against mesh
|
||||
meshHitInfo = GetCollisionRayMesh(ray, &tower.mesh);
|
||||
// Check ray collision against model
|
||||
// NOTE: It considers model.transform matrix!
|
||||
meshHitInfo = GetCollisionRayModel(ray, &tower);
|
||||
|
||||
if ((meshHitInfo.hit) && (meshHitInfo.distance < nearestHit.distance))
|
||||
{
|
||||
@@ -120,10 +122,12 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
// Draw the tower
|
||||
DrawModel(tower, towerPos, 1.0, WHITE);
|
||||
// WARNING: If scale is different than 1.0f,
|
||||
// not considered by GetCollisionRayModel()
|
||||
DrawModel(tower, towerPos, 1.0f, WHITE);
|
||||
|
||||
// Draw the test triangle
|
||||
DrawLine3D(ta, tb, PURPLE);
|
||||
@@ -149,9 +153,9 @@ int main()
|
||||
|
||||
DrawRay(ray, MAROON);
|
||||
|
||||
DrawGrid(100, 1.0f);
|
||||
DrawGrid(10, 10.0f);
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
// Draw some debug GUI text
|
||||
DrawText(FormatText("Hit Object: %s", hitObjectName), 10, 50, 10, BLACK);
|
||||
@@ -176,6 +180,8 @@ int main()
|
||||
}
|
||||
|
||||
DrawText("Use Mouse to Move Camera", 10, 430, 10, GRAY);
|
||||
|
||||
DrawText("(c) Turret 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
|
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 136 KiB |
@@ -21,11 +21,16 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 8.0f, 8.0f, 8.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 2.5f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.type = CAMERA_PERSPECTIVE; // Camera mode type
|
||||
|
||||
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
|
||||
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture
|
||||
dwarf.material.maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||
Model model = LoadModel("resources/models/castle.obj"); // Load OBJ model
|
||||
Texture2D texture = LoadTexture("resources/models/castle_diffuse.png"); // Load model texture
|
||||
model.material.maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
@@ -45,17 +50,17 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
|
||||
DrawModel(model, position, 0.2f, WHITE); // Draw 3d model with texture
|
||||
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
DrawGizmo(position); // Draw gizmo
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||
DrawText("(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
@@ -66,7 +71,7 @@ int main()
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Unload texture
|
||||
UnloadModel(dwarf); // Unload model
|
||||
UnloadModel(model); // Unload model
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 260 KiB |
97
examples/models/models_orthographic_projection.c
Normal file
@@ -0,0 +1,97 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [models] example - Show the difference between perspective and orthographic projection
|
||||
*
|
||||
* This program is heavily based on the geometric objects example
|
||||
*
|
||||
* This example has been created using raylib 1.9.7 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2018 Max Danielsson & Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define FOVY_PERSPECTIVE 45.0f
|
||||
#define WIDTH_ORTHOGRAPHIC 10.0f
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, FOVY_PERSPECTIVE, CAMERA_PERSPECTIVE };
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyPressed(KEY_SPACE))
|
||||
{
|
||||
if (camera.type == CAMERA_PERSPECTIVE)
|
||||
{
|
||||
camera.fovy = WIDTH_ORTHOGRAPHIC;
|
||||
camera.type = CAMERA_ORTHOGRAPHIC;
|
||||
}
|
||||
else
|
||||
{
|
||||
camera.fovy = FOVY_PERSPECTIVE;
|
||||
camera.type = CAMERA_PERSPECTIVE;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED);
|
||||
DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD);
|
||||
DrawCubeWires((Vector3){-4.0f, 0.0f, -2.0f}, 3.0f, 6.0f, 2.0f, MAROON);
|
||||
|
||||
DrawSphere((Vector3){-1.0f, 0.0f, -2.0f}, 1.0f, GREEN);
|
||||
DrawSphereWires((Vector3){1.0f, 0.0f, 2.0f}, 2.0f, 16, 16, LIME);
|
||||
|
||||
DrawCylinder((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, SKYBLUE);
|
||||
DrawCylinderWires((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, DARKBLUE);
|
||||
DrawCylinderWires((Vector3){4.5f, -1.0f, 2.0f}, 1.0f, 1.0f, 2.0f, 6, BROWN);
|
||||
|
||||
DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD);
|
||||
DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK);
|
||||
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
EndMode3D();
|
||||
|
||||
DrawText("Press Spacebar to switch camera type", 10, GetScreenHeight() - 30, 20, DARKGRAY);
|
||||
|
||||
if (camera.type == CAMERA_ORTHOGRAPHIC) DrawText("ORTHOGRAPHIC", 10, 40, 20, BLACK);
|
||||
else if (camera.type == CAMERA_PERSPECTIVE) DrawText("PERSPECTIVE", 10, 40, 20, BLACK);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/models/models_orthographic_projection.png
Normal file
After Width: | Height: | Size: 32 KiB |
@@ -21,7 +21,7 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox loading and drawing");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 1.0f, 1.0f, 1.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
Camera camera = {{ 1.0f, 1.0f, 1.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||
|
||||
// Load skybox model
|
||||
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
|
||||
@@ -36,12 +36,17 @@ int main()
|
||||
Shader shdrCubemap = LoadShader("resources/shaders/cubemap.vs", "resources/shaders/cubemap.fs");
|
||||
SetShaderValuei(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), (int[1]){ 0 }, 1);
|
||||
|
||||
Texture2D texHDR = LoadTexture("resources/pinetree.hdr");
|
||||
// Load HDR panorama (sphere) texture
|
||||
Texture2D texHDR = LoadTexture("resources/dresden_square.hdr");
|
||||
|
||||
// Generate cubemap (texture with 6 quads-cube-mapping) from panorama HDR texture
|
||||
// NOTE: New texture is generated rendering to texture, shader computes the sphre->cube coordinates mapping
|
||||
skybox.material.maps[MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, texHDR, 512);
|
||||
|
||||
UnloadShader(shdrCubemap); // Cubemap generation shader not required any more
|
||||
UnloadTexture(texHDR); // Texture not required anymore, cubemap already generated
|
||||
UnloadShader(shdrCubemap); // Unload cubemap generation shader, not required anymore
|
||||
|
||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
||||
SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set a first person camera mode
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -60,13 +65,13 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModel(skybox, Vector3Zero(), 1.0f, WHITE);
|
||||
DrawModel(skybox, (Vector3){0, 0, 0}, 1.0f, WHITE);
|
||||
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
@@ -76,7 +81,7 @@ int main()
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadModel(skybox); // Unload skybox model
|
||||
UnloadModel(skybox); // Unload skybox model (and textures)
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
Before Width: | Height: | Size: 707 KiB After Width: | Height: | Size: 417 KiB |
@@ -5,7 +5,7 @@
|
||||
* This example has been created using raylib 1.8 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Example based on Berni work on Raspberry Pi:
|
||||
* Example based on Berni work on Raspberry Pi:
|
||||
* http://forum.raylib.com/index.php?p=/discussion/124/line-versus-triangle-drawing-order
|
||||
*
|
||||
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
|
||||
@@ -30,25 +30,26 @@ int main()
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - plane rotations (yaw, pitch, roll)");
|
||||
|
||||
Texture2D texAngleGauge = LoadTexture("resources/angle_gauge.png");
|
||||
Texture2D texAngleGauge = LoadTexture("resources/angle_gauge.png");
|
||||
Texture2D texBackground = LoadTexture("resources/background.png");
|
||||
Texture2D texPitch = LoadTexture("resources/pitch.png");
|
||||
Texture2D texPitch = LoadTexture("resources/pitch.png");
|
||||
Texture2D texPlane = LoadTexture("resources/plane.png");
|
||||
|
||||
RenderTexture2D framebuffer = LoadRenderTexture(192, 192);
|
||||
|
||||
|
||||
// Model loading
|
||||
Model model = LoadModel("resources/plane.obj"); // Load OBJ model
|
||||
model.material.maps[MAP_DIFFUSE].texture = LoadTexture("resources/plane_diffuse.png"); // Set map diffuse texture
|
||||
|
||||
|
||||
GenTextureMipmaps(&model.material.maps[MAP_DIFFUSE].texture);
|
||||
|
||||
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 0.0f, 60.0f, -120.0f };// Camera position perspective
|
||||
camera.target = (Vector3){ 0.0f, 12.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 30.0f; // Camera field-of-view Y
|
||||
|
||||
camera.type = CAMERA_PERSPECTIVE; // Camera type
|
||||
|
||||
float pitch = 0.0f;
|
||||
float roll = 0.0f;
|
||||
float yaw = 0.0f;
|
||||
@@ -61,7 +62,7 @@ int main()
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Plane roll (x-axis) controls
|
||||
if (IsKeyDown(KEY_LEFT)) roll += 1.0f;
|
||||
else if (IsKeyDown(KEY_RIGHT)) roll -= 1.0f;
|
||||
@@ -70,7 +71,7 @@ int main()
|
||||
if (roll > 0.0f) roll -= 0.5f;
|
||||
else if (roll < 0.0f) roll += 0.5f;
|
||||
}
|
||||
|
||||
|
||||
// Plane yaw (y-axis) controls
|
||||
if (IsKeyDown(KEY_S)) yaw += 1.0f;
|
||||
else if (IsKeyDown(KEY_A)) yaw -= 1.0f;
|
||||
@@ -79,7 +80,7 @@ int main()
|
||||
if (yaw > 0.0f) yaw -= 0.5f;
|
||||
else if (yaw < 0.0f) yaw += 0.5f;
|
||||
}
|
||||
|
||||
|
||||
// Plane pitch (z-axis) controls
|
||||
if (IsKeyDown(KEY_DOWN)) pitch += 0.6f;
|
||||
else if (IsKeyDown(KEY_UP)) pitch -= 0.6f;
|
||||
@@ -88,7 +89,7 @@ int main()
|
||||
if (pitch > 0.3f) pitch -= 0.3f;
|
||||
else if (pitch < -0.3f) pitch += 0.3f;
|
||||
}
|
||||
|
||||
|
||||
// Wraps the phase of an angle to fit between -180 and +180 degrees
|
||||
int pitchOffset = pitch;
|
||||
while (pitchOffset > 180) pitchOffset -= 360;
|
||||
@@ -96,20 +97,20 @@ int main()
|
||||
pitchOffset *= 10;
|
||||
|
||||
Matrix transform = MatrixIdentity();
|
||||
|
||||
|
||||
transform = MatrixMultiply(transform, MatrixRotateZ(DEG2RAD*roll));
|
||||
transform = MatrixMultiply(transform, MatrixRotateX(DEG2RAD*pitch));
|
||||
transform = MatrixMultiply(transform, MatrixRotateY(DEG2RAD*yaw));
|
||||
|
||||
|
||||
model.transform = transform;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
|
||||
// Draw framebuffer texture (Ahrs Display)
|
||||
int centerX = framebuffer.texture.width/2;
|
||||
int centerY = framebuffer.texture.height/2;
|
||||
@@ -126,28 +127,28 @@ int main()
|
||||
DrawTexturePro(texPitch, (Rectangle){ 0, 0, texPitch.width, texPitch.height },
|
||||
(Rectangle){ centerX, centerY, texPitch.width*scaleFactor, texPitch.height*scaleFactor },
|
||||
(Vector2){ texPitch.width/2*scaleFactor, texPitch.height/2*scaleFactor + pitchOffset*scaleFactor }, roll, WHITE);
|
||||
|
||||
|
||||
DrawTexturePro(texPlane, (Rectangle){ 0, 0, texPlane.width, texPlane.height },
|
||||
(Rectangle){ centerX, centerY, texPlane.width*scaleFactor, texPlane.height*scaleFactor },
|
||||
(Rectangle){ centerX, centerY, texPlane.width*scaleFactor, texPlane.height*scaleFactor },
|
||||
(Vector2){ texPlane.width/2*scaleFactor, texPlane.height/2*scaleFactor }, 0, WHITE);
|
||||
|
||||
|
||||
EndBlendMode();
|
||||
|
||||
EndTextureMode();
|
||||
|
||||
// Draw 3D model (recomended to draw 3D always before 2D)
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModel(model, (Vector3){ 0, 6.0f, 0 }, 1.0f, WHITE); // Draw 3d model with texture
|
||||
DrawGrid(10, 10.0f);
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
// Draw 2D GUI stuff
|
||||
DrawAngleGauge(texAngleGauge, 80, 70, roll, "roll", RED);
|
||||
DrawAngleGauge(texAngleGauge, 190, 70, pitch, "pitch", GREEN);
|
||||
DrawAngleGauge(texAngleGauge, 300, 70, yaw, "yaw", SKYBLUE);
|
||||
|
||||
|
||||
DrawRectangle(30, 360, 260, 70, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines(30, 360, 260, 70, Fade(DARKBLUE, 0.5f));
|
||||
DrawText("Pitch controlled with: KEY_UP / KEY_DOWN", 40, 370, 10, DARKGRAY);
|
||||
@@ -155,31 +156,31 @@ int main()
|
||||
DrawText("Yaw controlled with: KEY_A / KEY_S", 40, 410, 10, DARKGRAY);
|
||||
|
||||
// Draw framebuffer texture
|
||||
DrawTextureRec(framebuffer.texture, (Rectangle){ 0, 0, framebuffer.texture.width, -framebuffer.texture.height },
|
||||
DrawTextureRec(framebuffer.texture, (Rectangle){ 0, 0, framebuffer.texture.width, -framebuffer.texture.height },
|
||||
(Vector2){ screenWidth - framebuffer.texture.width - 20, 20 }, Fade(WHITE, 0.8f));
|
||||
|
||||
|
||||
DrawRectangleLines(screenWidth - framebuffer.texture.width - 20, 20, framebuffer.texture.width, framebuffer.texture.height, DARKGRAY);
|
||||
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Unload all loaded data
|
||||
UnloadModel(model);
|
||||
|
||||
|
||||
UnloadRenderTexture(framebuffer);
|
||||
|
||||
UnloadTexture(texAngleGauge);
|
||||
|
||||
UnloadTexture(texAngleGauge);
|
||||
UnloadTexture(texBackground);
|
||||
UnloadTexture(texPitch);
|
||||
UnloadTexture(texPitch);
|
||||
UnloadTexture(texPlane);
|
||||
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -192,7 +193,7 @@ void DrawAngleGauge(Texture2D angleGauge, int x, int y, float angle, char title[
|
||||
int textSize = 20;
|
||||
|
||||
DrawTexturePro(angleGauge, srcRec, dstRec, origin, angle, color);
|
||||
|
||||
DrawText(FormatText("%5.1f<EFBFBD>", angle), x - MeasureText(FormatText("%5.1f<EFBFBD>", angle), textSize) / 2, y + 10, textSize, DARKGRAY);
|
||||
DrawText(title, x - MeasureText(title, textSize) / 2, y + 60, textSize, DARKGRAY);
|
||||
}
|
||||
|
||||
DrawText(FormatText("%5.1f", angle), x - MeasureText(FormatText("%5.1f", angle), textSize) / 2, y + 10, textSize, DARKGRAY);
|
||||
DrawText(title, x - MeasureText(title, textSize) / 2, y + 60, textSize, DARKGRAY);
|
||||
}
|
||||
|
BIN
examples/models/resources/dresden_square.hdr
Normal file
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 3.9 MiB |
Before Width: | Height: | Size: 2.8 MiB |
1725
examples/models/resources/models/bridge.obj
Normal file
BIN
examples/models/resources/models/bridge_diffuse.png
Normal file
After Width: | Height: | Size: 311 KiB |
12919
examples/models/resources/models/castle.obj
Normal file
BIN
examples/models/resources/models/castle_diffuse.png
Normal file
After Width: | Height: | Size: 1.5 MiB |
4564
examples/models/resources/models/house.obj
Normal file
BIN
examples/models/resources/models/house_diffuse.png
Normal file
After Width: | Height: | Size: 384 KiB |
7301
examples/models/resources/models/market.obj
Normal file
BIN
examples/models/resources/models/market_diffuse.png
Normal file
After Width: | Height: | Size: 381 KiB |
1888
examples/models/resources/models/turret.obj
Normal file
BIN
examples/models/resources/models/turret_diffuse.png
Normal file
After Width: | Height: | Size: 372 KiB |
1030
examples/models/resources/models/well.obj
Normal file
BIN
examples/models/resources/models/well_diffuse.png
Normal file
After Width: | Height: | Size: 335 KiB |
@@ -12,11 +12,11 @@
|
||||
in vec3 vertexPosition;
|
||||
in vec2 vertexTexCoord;
|
||||
in vec3 vertexNormal;
|
||||
in vec3 vertexTangent;
|
||||
in vec4 vertexTangent;
|
||||
|
||||
// Input uniform values
|
||||
uniform mat4 mvp;
|
||||
uniform mat4 mMatrix;
|
||||
uniform mat4 matModel;
|
||||
|
||||
// Output vertex attributes (to fragment shader)
|
||||
out vec3 fragPosition;
|
||||
@@ -28,18 +28,18 @@ out vec3 fragBinormal;
|
||||
void main()
|
||||
{
|
||||
// Calculate binormal from vertex normal and tangent
|
||||
vec3 vertexBinormal = cross(vertexNormal, vertexTangent);
|
||||
vec3 vertexBinormal = cross(vertexNormal, vec3(vertexTangent));
|
||||
|
||||
// Calculate fragment normal based on normal transformations
|
||||
mat3 normalMatrix = transpose(inverse(mat3(mMatrix)));
|
||||
mat3 normalMatrix = transpose(inverse(mat3(matModel)));
|
||||
|
||||
// Calculate fragment position based on model transformations
|
||||
fragPosition = vec3(mMatrix*vec4(vertexPosition, 1.0f));
|
||||
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0f));
|
||||
|
||||
// Send vertex attributes to fragment shader
|
||||
fragTexCoord = vertexTexCoord;
|
||||
fragNormal = normalize(normalMatrix*vertexNormal);
|
||||
fragTangent = normalize(normalMatrix*vertexTangent);
|
||||
fragTangent = normalize(normalMatrix*vec3(vertexTangent));
|
||||
fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal)*fragNormal);
|
||||
fragBinormal = normalize(normalMatrix*vertexBinormal);
|
||||
fragBinormal = cross(fragNormal, fragTangent);
|
||||
|
@@ -1,456 +0,0 @@
|
||||
# Blender v2.78 (sub 0) OBJ File: 'lowpoly-tower.blend'
|
||||
# www.blender.org
|
||||
o Grid
|
||||
v -4.000000 0.000000 4.000000
|
||||
v -2.327363 0.000000 4.654725
|
||||
v 0.000000 0.000000 4.654725
|
||||
v 2.327363 0.000000 4.654725
|
||||
v 4.000000 0.000000 4.000000
|
||||
v -4.654725 0.955085 2.327363
|
||||
v -2.000000 0.815050 2.000000
|
||||
v 0.000000 0.476341 2.423448
|
||||
v 2.000000 0.476341 2.000000
|
||||
v 4.654725 0.000000 2.327363
|
||||
v -4.654725 1.649076 0.000000
|
||||
v -2.423448 1.092402 0.000000
|
||||
v 2.423448 0.198579 0.000000
|
||||
v 4.654725 0.000000 0.000000
|
||||
v -4.654725 1.649076 -2.327363
|
||||
v -2.000000 1.092402 -2.000000
|
||||
v 0.000000 0.476341 -2.423448
|
||||
v 2.000000 -0.012791 -2.000000
|
||||
v 4.654725 0.000000 -2.612731
|
||||
v -4.000000 0.955085 -4.000000
|
||||
v -2.327363 0.955085 -4.654725
|
||||
v 0.000000 0.955085 -4.654725
|
||||
v 2.327363 0.000000 -4.654725
|
||||
v 4.000000 0.000000 -4.000000
|
||||
v 2.423448 0.682825 0.000000
|
||||
v 2.000000 0.565423 -2.000000
|
||||
v -4.654725 -0.020560 2.327363
|
||||
v -4.654725 0.000000 0.000000
|
||||
v -4.654725 0.000000 -2.327363
|
||||
v -4.000000 0.000000 -4.000000
|
||||
v -2.327363 0.000000 -4.654725
|
||||
v 0.000000 -0.020560 -4.654725
|
||||
v 0.000000 0.709880 -1.230535
|
||||
v -0.000000 7.395413 0.000000
|
||||
v 0.962071 0.709880 -0.767226
|
||||
v -0.533909 0.709880 1.108674
|
||||
v -1.199683 0.709880 0.273820
|
||||
v -0.962071 0.709880 -0.767226
|
||||
v 1.506076 0.859071 1.325337
|
||||
v 1.199683 0.709880 0.273820
|
||||
v 0.533909 0.709880 1.108674
|
||||
v 0.000000 1.875340 -1.177842
|
||||
v -0.000000 2.293973 -0.649884
|
||||
v -0.000000 4.365648 -0.627970
|
||||
v 0.000000 6.167194 -0.942957
|
||||
v 0.000000 6.232434 -1.708677
|
||||
v 1.335898 6.232434 -1.065343
|
||||
v 0.737233 6.167195 -0.587924
|
||||
v 0.490966 4.365648 -0.391533
|
||||
v 0.508100 2.293973 -0.405196
|
||||
v 0.920874 1.875340 -0.734372
|
||||
v -0.741367 6.232434 1.539465
|
||||
v -0.409133 6.167195 0.849574
|
||||
v -0.272466 4.365648 0.565781
|
||||
v -0.281974 2.293973 0.585526
|
||||
v -0.511047 1.875340 1.061199
|
||||
v -1.665837 6.232434 0.380217
|
||||
v -0.919314 6.167195 0.209828
|
||||
v -0.612225 4.365648 0.139736
|
||||
v -0.633590 2.293973 0.144613
|
||||
v -1.148311 1.875340 0.262095
|
||||
v -1.335898 6.232434 -1.065343
|
||||
v -0.737233 6.167195 -0.587924
|
||||
v -0.490967 4.365648 -0.391533
|
||||
v -0.508100 2.293973 -0.405196
|
||||
v -0.920874 1.875340 -0.734372
|
||||
v 1.665837 6.232434 0.380216
|
||||
v 0.919315 6.167195 0.209828
|
||||
v 0.612225 4.365648 0.139736
|
||||
v 0.633590 2.293973 0.144613
|
||||
v 1.148311 1.875340 0.262095
|
||||
v 0.741367 6.232434 1.539465
|
||||
v 0.409133 6.167195 0.849575
|
||||
v 0.272466 4.365648 0.565781
|
||||
v 0.281974 2.293973 0.585526
|
||||
v 0.511046 1.875340 1.061199
|
||||
v 0.000000 5.012550 -0.969733
|
||||
v 0.758168 5.012550 -0.604618
|
||||
v -0.420751 5.012550 0.873699
|
||||
v -0.945419 5.012550 0.215786
|
||||
v -0.758168 5.012550 -0.604618
|
||||
v 0.945419 5.012550 0.215786
|
||||
v 0.420751 5.012550 0.873699
|
||||
vt 0.0523 0.5444
|
||||
vt 0.1817 0.4284
|
||||
vt 0.1641 0.5859
|
||||
vt 0.0177 0.4451
|
||||
vt 0.1526 0.3090
|
||||
vt 0.0189 0.1737
|
||||
vt 0.0188 0.3088
|
||||
vt 0.0561 0.0762
|
||||
vt 0.1757 0.1924
|
||||
vt 0.3024 0.4534
|
||||
vt 0.3071 0.5902
|
||||
vt 0.3413 0.2459
|
||||
vt 0.2906 0.1614
|
||||
vt 0.4116 0.1801
|
||||
vt 0.2834 0.3774
|
||||
vt 0.1526 0.0362
|
||||
vt 0.2917 0.1622
|
||||
vt 0.4446 0.5865
|
||||
vt 0.4443 0.2989
|
||||
vt 0.3711 0.3021
|
||||
vt 0.4396 0.0275
|
||||
vt 0.4094 0.1829
|
||||
vt 0.4219 0.4255
|
||||
vt 0.5474 0.5381
|
||||
vt 0.5811 0.4376
|
||||
vt 0.5715 0.1505
|
||||
vt 0.5811 0.2997
|
||||
vt 0.5272 0.0533
|
||||
vt 0.2208 0.2194
|
||||
vt 0.3456 0.3610
|
||||
vt 0.2878 0.0321
|
||||
vt 0.2321 0.3392
|
||||
vt 0.4432 0.0177
|
||||
vt 0.7347 0.7934
|
||||
vt 0.7382 0.7595
|
||||
vt 0.8982 0.7768
|
||||
vt 0.6169 0.7595
|
||||
vt 0.6139 0.7879
|
||||
vt 0.4951 0.7634
|
||||
vt 0.1551 0.6832
|
||||
vt 0.2925 0.6268
|
||||
vt 0.2925 0.6832
|
||||
vt 0.7795 0.6832
|
||||
vt 0.6421 0.6268
|
||||
vt 0.7795 0.6255
|
||||
vt 0.5046 0.7241
|
||||
vt 0.6421 0.7241
|
||||
vt 0.3986 0.6268
|
||||
vt 0.3986 0.6832
|
||||
vt 0.5046 0.6268
|
||||
vt 0.0177 0.6268
|
||||
vt 0.1551 0.6255
|
||||
vt 0.8856 0.6268
|
||||
vt 0.1899 0.9579
|
||||
vt 0.1194 0.8696
|
||||
vt 0.2324 0.8696
|
||||
vt 0.1899 0.7813
|
||||
vt 0.0943 0.7595
|
||||
vt 0.0177 0.8206
|
||||
vt 0.0177 0.9186
|
||||
vt 0.0943 0.9797
|
||||
vt 0.2793 0.2349
|
||||
vt 0.2304 0.2758
|
||||
vt 0.6597 0.0177
|
||||
vt 0.6954 0.0993
|
||||
vt 0.6367 0.0768
|
||||
vt 0.7558 0.0777
|
||||
vt 0.7238 0.0440
|
||||
vt 0.8840 0.1330
|
||||
vt 0.7385 0.1141
|
||||
vt 0.9157 0.0886
|
||||
vt 0.9781 0.1232
|
||||
vt 0.9224 0.1276
|
||||
vt 0.2677 0.8141
|
||||
vt 0.3463 0.8037
|
||||
vt 0.3086 0.8339
|
||||
vt 0.6387 0.3550
|
||||
vt 0.7130 0.3801
|
||||
vt 0.6596 0.4053
|
||||
vt 0.7245 0.3245
|
||||
vt 0.6919 0.3383
|
||||
vt 0.8655 0.3566
|
||||
vt 0.7351 0.3577
|
||||
vt 0.9770 0.3365
|
||||
vt 0.9078 0.3751
|
||||
vt 0.9174 0.3282
|
||||
vt 0.2677 0.9018
|
||||
vt 0.3086 0.8821
|
||||
vt 0.6803 0.2948
|
||||
vt 0.6251 0.3035
|
||||
vt 0.7194 0.2854
|
||||
vt 0.8764 0.2832
|
||||
vt 0.9221 0.2861
|
||||
vt 0.3363 0.9565
|
||||
vt 0.3464 0.9122
|
||||
vt 0.6751 0.2482
|
||||
vt 0.6178 0.2499
|
||||
vt 0.7179 0.2431
|
||||
vt 0.9823 0.2484
|
||||
vt 0.9247 0.2452
|
||||
vt 0.3935 0.9014
|
||||
vt 0.6755 0.1996
|
||||
vt 0.6164 0.1941
|
||||
vt 0.7201 0.1992
|
||||
vt 0.8793 0.2446
|
||||
vt 0.9823 0.2060
|
||||
vt 0.9257 0.2051
|
||||
vt 0.4598 0.8580
|
||||
vt 0.4144 0.8579
|
||||
vt 0.6819 0.1498
|
||||
vt 0.6222 0.1361
|
||||
vt 0.7266 0.1555
|
||||
vt 0.8831 0.1684
|
||||
vt 0.9252 0.1659
|
||||
vt 0.4218 0.7790
|
||||
vt 0.3934 0.8145
|
||||
vt 0.3363 0.7595
|
||||
vt 0.8815 0.2060
|
||||
vt 0.8720 0.3208
|
||||
vt 0.8825 0.1012
|
||||
vt 0.9735 0.0816
|
||||
vt 0.9718 0.3817
|
||||
vt 0.9807 0.2918
|
||||
vt 0.4218 0.9370
|
||||
vt 0.9810 0.1644
|
||||
vn 0.1035 0.8806 0.4623
|
||||
vn 0.0964 0.9481 0.3030
|
||||
vn 0.0000 0.9780 0.2088
|
||||
vn 0.0659 0.9835 0.1683
|
||||
vn 0.2325 0.9320 0.2779
|
||||
vn 0.0553 0.9960 -0.0702
|
||||
vn 0.2827 0.9564 0.0728
|
||||
vn 0.1873 0.9776 -0.0961
|
||||
vn 0.2421 0.9703 0.0000
|
||||
vn 0.0921 0.9772 -0.1913
|
||||
vn -0.0277 0.9947 -0.0993
|
||||
vn 0.2308 0.9274 -0.2944
|
||||
vn 0.2771 0.9572 -0.0837
|
||||
vn 0.3724 0.9074 0.1947
|
||||
vn 0.0777 0.9770 -0.1985
|
||||
vn -0.1094 0.9539 0.2794
|
||||
vn 0.0364 0.9844 0.1721
|
||||
vn 0.1683 0.9835 0.0659
|
||||
vn 0.0674 0.9901 0.1230
|
||||
vn 0.4338 0.8823 0.1829
|
||||
vn 0.2845 0.9565 0.0649
|
||||
vn 0.0886 0.9961 0.0000
|
||||
vn 0.2000 0.9789 0.0424
|
||||
vn 0.1417 0.9830 0.1171
|
||||
vn 0.3021 0.9524 0.0412
|
||||
vn -0.0193 0.9986 -0.0493
|
||||
vn 0.0000 0.9777 0.2098
|
||||
vn 0.0005 0.9781 -0.2083
|
||||
vn 0.1879 0.9782 -0.0887
|
||||
vn 0.2249 0.0000 0.9744
|
||||
vn 0.9783 0.0000 -0.2071
|
||||
vn 0.9783 0.0000 0.2071
|
||||
vn 0.0000 0.0000 -1.0000
|
||||
vn -1.0000 0.0000 0.0000
|
||||
vn -0.3645 0.0000 -0.9312
|
||||
vn -0.9312 0.0000 -0.3645
|
||||
vn -0.9312 0.0000 0.3645
|
||||
vn 0.2615 0.7979 -0.5431
|
||||
vn 0.5877 0.7979 -0.1341
|
||||
vn 0.4713 0.7979 0.3758
|
||||
vn -0.0000 0.7979 0.6028
|
||||
vn -0.4713 0.7979 0.3758
|
||||
vn -0.5877 0.7979 -0.1341
|
||||
vn -0.2615 0.7979 -0.5431
|
||||
vn -0.1285 0.9864 -0.1025
|
||||
vn 0.0929 0.8937 0.4389
|
||||
vn -0.4335 0.0407 -0.9002
|
||||
vn -0.2867 0.7507 -0.5952
|
||||
vn -0.4339 0.0095 -0.9009
|
||||
vn -0.4338 0.0209 -0.9008
|
||||
vn -0.0408 -0.9956 -0.0848
|
||||
vn -0.9741 0.0407 -0.2223
|
||||
vn -0.6441 0.7507 -0.1470
|
||||
vn -0.9749 0.0095 -0.2225
|
||||
vn -0.9747 0.0209 -0.2225
|
||||
vn -0.0918 -0.9956 -0.0209
|
||||
vn -0.7812 0.0407 0.6230
|
||||
vn -0.5165 0.7507 0.4119
|
||||
vn -0.7818 0.0095 0.6235
|
||||
vn -0.7817 0.0209 0.6234
|
||||
vn -0.0736 -0.9956 0.0587
|
||||
vn -0.0000 0.0407 0.9992
|
||||
vn 0.0000 0.7507 0.6607
|
||||
vn 0.0000 0.0095 1.0000
|
||||
vn -0.0000 0.0209 0.9998
|
||||
vn -0.0000 -0.9956 0.0941
|
||||
vn 0.7812 0.0407 0.6230
|
||||
vn 0.5165 0.7507 0.4119
|
||||
vn 0.7818 0.0095 0.6235
|
||||
vn 0.7817 0.0209 0.6234
|
||||
vn 0.0736 -0.9956 0.0587
|
||||
vn 0.9741 0.0407 -0.2223
|
||||
vn 0.6441 0.7507 -0.1470
|
||||
vn 0.9749 0.0095 -0.2225
|
||||
vn 0.9747 0.0209 -0.2225
|
||||
vn 0.0918 -0.9956 -0.0209
|
||||
vn 0.4335 0.0407 -0.9002
|
||||
vn 0.2867 0.7507 -0.5952
|
||||
vn 0.4339 0.0095 -0.9009
|
||||
vn 0.4338 0.0209 -0.9008
|
||||
vn 0.0408 -0.9956 -0.0848
|
||||
vn 0.3918 -0.4298 -0.8135
|
||||
vn 0.8803 -0.4298 -0.2009
|
||||
vn 0.7059 -0.4298 0.5630
|
||||
vn -0.0000 -0.4298 0.9029
|
||||
vn -0.7059 -0.4298 0.5630
|
||||
vn -0.8803 -0.4298 -0.2009
|
||||
vn -0.3918 -0.4298 -0.8135
|
||||
vn 0.0210 0.9998 -0.0048
|
||||
vn 0.0482 0.9981 -0.0385
|
||||
vn -0.0166 0.9914 -0.1301
|
||||
vn -0.0090 0.9904 -0.1379
|
||||
vn 0.2820 0.9576 0.0597
|
||||
vn -0.0000 0.9846 0.1749
|
||||
vn -0.0921 0.9772 -0.1913
|
||||
vn -0.1734 0.9794 0.1036
|
||||
s off
|
||||
f 1/1/1 7/2/1 6/3/1
|
||||
f 2/4/2 8/5/2 7/2/2
|
||||
f 4/6/3 8/5/3 3/7/3
|
||||
f 5/8/4 9/9/4 4/6/4
|
||||
f 6/3/5 12/10/5 11/11/5
|
||||
f 35/12/6 25/13/6 26/14/6
|
||||
f 7/2/7 37/15/7 12/10/7
|
||||
f 10/16/8 13/17/8 9/9/8
|
||||
f 12/10/9 15/18/9 11/11/9
|
||||
f 35/12/10 17/19/10 33/20/10
|
||||
f 13/17/11 19/21/11 18/22/11
|
||||
f 16/23/12 20/24/12 15/18/12
|
||||
f 17/19/13 21/25/13 16/23/13
|
||||
f 17/19/14 23/26/14 22/27/14
|
||||
f 26/14/15 24/28/15 23/26/15
|
||||
f 1/1/16 2/4/16 7/2/16
|
||||
f 2/4/3 3/7/3 8/5/3
|
||||
f 4/6/17 9/9/17 8/5/17
|
||||
f 5/8/18 10/16/18 9/9/18
|
||||
f 6/3/19 7/2/19 12/10/19
|
||||
f 25/13/20 39/29/20 9/9/20
|
||||
f 38/30/21 12/10/21 37/15/21
|
||||
f 10/16/22 14/31/22 13/17/22
|
||||
f 12/10/23 16/23/23 15/18/23
|
||||
f 8/5/24 36/32/24 7/2/24
|
||||
f 38/30/25 17/19/25 16/23/25
|
||||
f 13/17/22 14/31/22 19/21/22
|
||||
f 16/23/26 21/25/26 20/24/26
|
||||
f 17/19/27 22/27/27 21/25/27
|
||||
f 17/19/28 26/14/28 23/26/28
|
||||
f 26/14/29 19/33/29 24/28/29
|
||||
f 26/34/30 18/35/30 19/36/30
|
||||
f 26/34/31 13/37/31 18/35/31
|
||||
f 25/38/32 9/39/32 13/37/32
|
||||
f 22/40/33 31/41/33 21/42/33
|
||||
f 6/43/34 28/44/34 27/45/34
|
||||
f 15/46/34 28/44/34 11/47/34
|
||||
f 21/42/35 30/48/35 20/49/35
|
||||
f 20/49/36 29/50/36 15/46/36
|
||||
f 22/40/33 23/51/33 32/52/33
|
||||
f 6/43/37 27/45/37 1/53/37
|
||||
f 46/54/38 34/55/38 47/56/38
|
||||
f 47/56/39 34/55/39 67/57/39
|
||||
f 67/57/40 34/55/40 72/58/40
|
||||
f 72/58/41 34/55/41 52/59/41
|
||||
f 52/59/42 34/55/42 57/60/42
|
||||
f 57/60/43 34/55/43 62/61/43
|
||||
f 62/61/44 34/55/44 46/54/44
|
||||
f 40/62/45 41/63/45 39/29/45
|
||||
f 39/29/46 8/5/46 9/9/46
|
||||
f 38/64/47 42/65/47 33/66/47
|
||||
f 65/67/48 42/65/48 66/68/48
|
||||
f 65/67/49 44/69/49 43/70/49
|
||||
f 81/71/50 45/72/50 77/73/50
|
||||
f 62/74/51 45/75/51 63/76/51
|
||||
f 37/77/52 66/78/52 38/79/52
|
||||
f 60/80/53 66/78/53 61/81/53
|
||||
f 60/80/54 64/82/54 65/83/54
|
||||
f 58/84/55 81/85/55 80/86/55
|
||||
f 57/87/56 63/76/56 58/88/56
|
||||
f 56/89/57 37/77/57 36/90/57
|
||||
f 55/91/58 61/81/58 56/89/58
|
||||
f 54/92/59 60/80/59 55/91/59
|
||||
f 79/93/60 58/84/60 80/86/60
|
||||
f 52/94/61 58/88/61 53/95/61
|
||||
f 76/96/62 36/90/62 41/97/62
|
||||
f 75/98/63 56/89/63 76/96/63
|
||||
f 75/98/64 54/92/64 55/91/64
|
||||
f 73/99/65 79/93/65 83/100/65
|
||||
f 73/101/66 52/94/66 53/95/66
|
||||
f 71/102/67 41/97/67 40/103/67
|
||||
f 70/104/68 76/96/68 71/102/68
|
||||
f 70/104/69 74/105/69 75/98/69
|
||||
f 68/106/70 83/100/70 82/107/70
|
||||
f 67/108/71 73/101/71 68/109/71
|
||||
f 51/110/72 40/103/72 35/111/72
|
||||
f 50/112/73 71/102/73 51/110/73
|
||||
f 49/113/74 70/104/74 50/112/74
|
||||
f 78/114/75 68/106/75 82/107/75
|
||||
f 47/115/76 68/109/76 48/116/76
|
||||
f 42/65/77 35/111/77 33/66/77
|
||||
f 43/70/78 51/110/78 42/65/78
|
||||
f 44/69/79 50/112/79 43/70/79
|
||||
f 45/72/80 78/114/80 77/73/80
|
||||
f 46/117/81 48/116/81 45/75/81
|
||||
f 44/69/82 78/114/82 49/113/82
|
||||
f 49/113/83 82/107/83 69/118/83
|
||||
f 82/107/84 74/105/84 69/118/84
|
||||
f 83/100/85 54/92/85 74/105/85
|
||||
f 79/93/86 59/119/86 54/92/86
|
||||
f 80/86/87 64/82/87 59/119/87
|
||||
f 64/120/88 77/73/88 44/69/88
|
||||
f 35/12/89 40/62/89 25/13/89
|
||||
f 7/2/90 36/32/90 37/15/90
|
||||
f 35/12/91 26/14/91 17/19/91
|
||||
f 25/13/92 40/62/92 39/29/92
|
||||
f 38/30/93 16/23/93 12/10/93
|
||||
f 8/5/94 41/63/94 36/32/94
|
||||
f 38/30/95 33/20/95 17/19/95
|
||||
f 26/34/31 25/38/31 13/37/31
|
||||
f 22/40/33 32/52/33 31/41/33
|
||||
f 6/43/34 11/47/34 28/44/34
|
||||
f 15/46/34 29/50/34 28/44/34
|
||||
f 21/42/35 31/41/35 30/48/35
|
||||
f 20/49/36 30/48/36 29/50/36
|
||||
f 39/29/96 41/63/96 8/5/96
|
||||
f 38/64/47 66/68/47 42/65/47
|
||||
f 65/67/48 43/70/48 42/65/48
|
||||
f 65/67/49 64/120/49 44/69/49
|
||||
f 81/71/50 63/121/50 45/72/50
|
||||
f 62/74/51 46/117/51 45/75/51
|
||||
f 37/77/52 61/81/52 66/78/52
|
||||
f 60/80/53 65/83/53 66/78/53
|
||||
f 60/80/54 59/119/54 64/82/54
|
||||
f 58/84/55 63/122/55 81/85/55
|
||||
f 57/87/56 62/74/56 63/76/56
|
||||
f 56/89/57 61/81/57 37/77/57
|
||||
f 55/91/58 60/80/58 61/81/58
|
||||
f 54/92/59 59/119/59 60/80/59
|
||||
f 79/93/60 53/123/60 58/84/60
|
||||
f 52/94/61 57/87/61 58/88/61
|
||||
f 76/96/62 56/89/62 36/90/62
|
||||
f 75/98/63 55/91/63 56/89/63
|
||||
f 75/98/64 74/105/64 54/92/64
|
||||
f 73/99/65 53/123/65 79/93/65
|
||||
f 73/101/66 72/124/66 52/94/66
|
||||
f 71/102/67 76/96/67 41/97/67
|
||||
f 70/104/68 75/98/68 76/96/68
|
||||
f 70/104/69 69/118/69 74/105/69
|
||||
f 68/106/70 73/99/70 83/100/70
|
||||
f 67/108/71 72/124/71 73/101/71
|
||||
f 51/110/72 71/102/72 40/103/72
|
||||
f 50/112/73 70/104/73 71/102/73
|
||||
f 49/113/74 69/118/74 70/104/74
|
||||
f 78/114/75 48/125/75 68/106/75
|
||||
f 47/115/76 67/108/76 68/109/76
|
||||
f 42/65/77 51/110/77 35/111/77
|
||||
f 43/70/78 50/112/78 51/110/78
|
||||
f 44/69/79 49/113/79 50/112/79
|
||||
f 45/72/80 48/125/80 78/114/80
|
||||
f 46/117/81 47/115/81 48/116/81
|
||||
f 44/69/82 77/73/82 78/114/82
|
||||
f 49/113/83 78/114/83 82/107/83
|
||||
f 82/107/84 83/100/84 74/105/84
|
||||
f 83/100/85 79/93/85 54/92/85
|
||||
f 79/93/86 80/86/86 59/119/86
|
||||
f 80/86/87 81/85/87 64/82/87
|
||||
f 64/120/88 81/71/88 77/73/88
|
Before Width: | Height: | Size: 24 KiB |
@@ -4,38 +4,58 @@
|
||||
*
|
||||
* NOTE: This example does not require any graphic device, it can run directly on console.
|
||||
*
|
||||
* [audio] module requires some external libs:
|
||||
* OpenAL Soft - Audio device management lib (http://kcat.strangesoft.net/openal.html)
|
||||
* stb_vorbis - Ogg audio files loading (http://www.nothings.org/stb_vorbis/)
|
||||
* jar_xm - XM module file loading
|
||||
* jar_mod - MOD audio file loading
|
||||
* dr_flac - FLAC audio file loading
|
||||
* DEPENDENCIES:
|
||||
* mini_al.h - Audio device management lib (http://kcat.strangesoft.net/openal.html)
|
||||
* stb_vorbis.c - Ogg audio files loading (http://www.nothings.org/stb_vorbis/)
|
||||
* jar_xm.h - XM module file loading
|
||||
* jar_mod.h - MOD audio file loading
|
||||
* dr_flac.h - FLAC audio file loading
|
||||
*
|
||||
* Compile audio module using:
|
||||
* gcc -c audio.c stb_vorbis.c -Wall -std=c99 -DAUDIO_STANDALONE -DAL_LIBTYPE_STATIC
|
||||
* COMPILATION:
|
||||
* gcc -c ..\..\src\external\mini_al.c -Wall -I.
|
||||
* gcc -o audio_standalone.exe audio_standalone.c ..\..\src\audio.c ..\..\src\external\stb_vorbis.c mini_al.o /
|
||||
* -I..\..\src -I..\..\src\external -L. -Wall -std=c99 /
|
||||
* -DAUDIO_STANDALONE -DSUPPORT_FILEFORMAT_WAV -DSUPPORT_FILEFORMAT_OGG
|
||||
*
|
||||
* Compile example using:
|
||||
* gcc -o audio_standalone.exe audio_standalone.c audio.o stb_vorbis.o -lopenal32 -lwinmm /
|
||||
* -s -Wall -std=c99 -Wl,-allow-multiple-definition
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* This example has been created using raylib 1.7 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
* This example is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "audio.h"
|
||||
#if defined(_WIN32)
|
||||
#include <conio.h> // Windows only, no stardard library
|
||||
#include "audio.h" // Audio library
|
||||
|
||||
#include <stdio.h> // Required for: printf()
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <conio.h> // Windows only, no stardard library
|
||||
#else
|
||||
|
||||
// Provide kbhit() function in non-Windows platforms
|
||||
#include <stdio.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
// Check if a key has been pressed
|
||||
static int kbhit(void)
|
||||
{
|
||||
struct termios oldt, newt;
|
||||
@@ -54,7 +74,7 @@ static int kbhit(void)
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
|
||||
fcntl(STDIN_FILENO, F_SETFL, oldf);
|
||||
|
||||
if(ch != EOF)
|
||||
if (ch != EOF)
|
||||
{
|
||||
ungetc(ch, stdin);
|
||||
return 1;
|
||||
@@ -63,10 +83,8 @@ static int kbhit(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char getch()
|
||||
{
|
||||
return getchar();
|
||||
}
|
||||
// Get pressed character
|
||||
static char getch() { return getchar(); }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -76,13 +94,13 @@ int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
unsigned char key;
|
||||
|
||||
static unsigned char key;
|
||||
|
||||
InitAudioDevice();
|
||||
|
||||
|
||||
Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file
|
||||
Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file
|
||||
|
||||
|
||||
Music music = LoadMusicStream("resources/audio/guitar_noodling.ogg");
|
||||
PlayMusicStream(music);
|
||||
|
||||
@@ -99,23 +117,23 @@ int main()
|
||||
PlaySound(fxWav);
|
||||
key = 0;
|
||||
}
|
||||
|
||||
|
||||
if (key == 'd')
|
||||
{
|
||||
PlaySound(fxOgg);
|
||||
key = 0;
|
||||
}
|
||||
|
||||
|
||||
UpdateMusicStream(music);
|
||||
}
|
||||
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadSound(fxWav); // Unload sound data
|
||||
UnloadSound(fxOgg); // Unload sound data
|
||||
|
||||
|
||||
UnloadMusicStream(music); // Unload music stream data
|
||||
|
||||
|
||||
CloseAudioDevice();
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
@@ -10,7 +10,6 @@
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include <stdlib.h> // Required for: malloc(), free()
|
||||
|
||||
#define MAX_BUNNIES 100000 // 100K bunnies
|
||||
@@ -29,15 +28,16 @@ int main()
|
||||
int screenHeight = 960;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example - Bunnymark");
|
||||
|
||||
|
||||
Texture2D texBunny = LoadTexture("resources/wabbit_alpha.png");
|
||||
|
||||
|
||||
Bunny *bunnies = (Bunny *)malloc(MAX_BUNNIES*sizeof(Bunny)); // Bunnies array
|
||||
|
||||
int bunniesCount = 0; // Bunnies counter
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
@@ -54,7 +54,7 @@ int main()
|
||||
bunniesCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update bunnies
|
||||
for (int i = 0; i < bunniesCount; i++)
|
||||
{
|
||||
@@ -65,14 +65,14 @@ int main()
|
||||
if ((bunnies[i].position.y > GetScreenHeight()) || (bunnies[i].position.y < 0)) bunnies[i].speed.y *= -1;
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
for (int i = 0; i <= bunniesCount; i++)
|
||||
|
||||
for (int i = 0; i < bunniesCount; i++)
|
||||
{
|
||||
// NOTE: When internal QUADS batch limit is reached, a draw call is launched and
|
||||
// batching buffer starts being filled again; before launching the draw call,
|
||||
@@ -80,11 +80,10 @@ int main()
|
||||
// a stall and consequently a frame drop, limiting number of bunnies drawn at 60 fps
|
||||
DrawTexture(texBunny, bunnies[i].position.x, bunnies[i].position.y, RAYWHITE);
|
||||
}
|
||||
|
||||
|
||||
DrawRectangle(0, 0, screenWidth, 40, LIGHTGRAY);
|
||||
DrawText("raylib bunnymark", 10, 10, 20, DARKGRAY);
|
||||
DrawText(FormatText("bunnies: %i", bunniesCount), 400, 10, 20, RED);
|
||||
|
||||
DrawFPS(260, 10);
|
||||
|
||||
EndDrawing();
|
||||
@@ -94,9 +93,9 @@ int main()
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
free(bunnies);
|
||||
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
5538
examples/others/external/include/GLFW/glfw3.h
vendored
Normal file
572
examples/others/external/include/GLFW/glfw3native.h
vendored
Normal file
@@ -0,0 +1,572 @@
|
||||
/*************************************************************************
|
||||
* GLFW 3.3 - www.glfw.org
|
||||
* A library for OpenGL, window and input
|
||||
*------------------------------------------------------------------------
|
||||
* Copyright (c) 2002-2006 Marcus Geelnard
|
||||
* Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would
|
||||
* be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not
|
||||
* be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef _glfw3_native_h_
|
||||
#define _glfw3_native_h_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Doxygen documentation
|
||||
*************************************************************************/
|
||||
|
||||
/*! @file glfw3native.h
|
||||
* @brief The header of the native access functions.
|
||||
*
|
||||
* This is the header file of the native access functions. See @ref native for
|
||||
* more information.
|
||||
*/
|
||||
/*! @defgroup native Native access
|
||||
* @brief Functions related to accessing native handles.
|
||||
*
|
||||
* **By using the native access functions you assert that you know what you're
|
||||
* doing and how to fix problems caused by using them. If you don't, you
|
||||
* shouldn't be using them.**
|
||||
*
|
||||
* Before the inclusion of @ref glfw3native.h, you may define zero or more
|
||||
* window system API macro and zero or more context creation API macros.
|
||||
*
|
||||
* The chosen backends must match those the library was compiled for. Failure
|
||||
* to do this will cause a link-time error.
|
||||
*
|
||||
* The available window API macros are:
|
||||
* * `GLFW_EXPOSE_NATIVE_WIN32`
|
||||
* * `GLFW_EXPOSE_NATIVE_COCOA`
|
||||
* * `GLFW_EXPOSE_NATIVE_X11`
|
||||
* * `GLFW_EXPOSE_NATIVE_WAYLAND`
|
||||
* * `GLFW_EXPOSE_NATIVE_MIR`
|
||||
*
|
||||
* The available context API macros are:
|
||||
* * `GLFW_EXPOSE_NATIVE_WGL`
|
||||
* * `GLFW_EXPOSE_NATIVE_NSGL`
|
||||
* * `GLFW_EXPOSE_NATIVE_GLX`
|
||||
* * `GLFW_EXPOSE_NATIVE_EGL`
|
||||
* * `GLFW_EXPOSE_NATIVE_OSMESA`
|
||||
*
|
||||
* These macros select which of the native access functions that are declared
|
||||
* and which platform-specific headers to include. It is then up your (by
|
||||
* definition platform-specific) code to handle which of these should be
|
||||
* defined.
|
||||
*/
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* System headers and types
|
||||
*************************************************************************/
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
|
||||
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
||||
// example to allow applications to correctly declare a GL_ARB_debug_output
|
||||
// callback) but windows.h assumes no one will define APIENTRY before it does
|
||||
#if defined(GLFW_APIENTRY_DEFINED)
|
||||
#undef APIENTRY
|
||||
#undef GLFW_APIENTRY_DEFINED
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#elif defined(GLFW_EXPOSE_NATIVE_COCOA)
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#if defined(__OBJC__)
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#else
|
||||
typedef void* id;
|
||||
#endif
|
||||
#elif defined(GLFW_EXPOSE_NATIVE_X11)
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND)
|
||||
#include <wayland-client.h>
|
||||
#elif defined(GLFW_EXPOSE_NATIVE_MIR)
|
||||
#include <mir_toolkit/mir_client_library.h>
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_WGL)
|
||||
/* WGL is declared by windows.h */
|
||||
#endif
|
||||
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
||||
/* NSGL is declared by Cocoa.h */
|
||||
#endif
|
||||
#if defined(GLFW_EXPOSE_NATIVE_GLX)
|
||||
#include <GL/glx.h>
|
||||
#endif
|
||||
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
||||
#include <EGL/egl.h>
|
||||
#endif
|
||||
#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
|
||||
#include <GL/osmesa.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Functions
|
||||
*************************************************************************/
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
|
||||
/*! @brief Returns the adapter device name of the specified monitor.
|
||||
*
|
||||
* @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
|
||||
* of the specified monitor, or `NULL` if an [error](@ref error_handling)
|
||||
* occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.1.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
|
||||
|
||||
/*! @brief Returns the display device name of the specified monitor.
|
||||
*
|
||||
* @return The UTF-8 encoded display device name (for example
|
||||
* `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.1.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
|
||||
|
||||
/*! @brief Returns the `HWND` of the specified window.
|
||||
*
|
||||
* @return The `HWND` of the specified window, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.0.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_WGL)
|
||||
/*! @brief Returns the `HGLRC` of the specified window.
|
||||
*
|
||||
* @return The `HGLRC` of the specified window, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.0.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_COCOA)
|
||||
/*! @brief Returns the `CGDirectDisplayID` of the specified monitor.
|
||||
*
|
||||
* @return The `CGDirectDisplayID` of the specified monitor, or
|
||||
* `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.1.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
|
||||
|
||||
/*! @brief Returns the `NSWindow` of the specified window.
|
||||
*
|
||||
* @return The `NSWindow` of the specified window, or `nil` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.0.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
||||
/*! @brief Returns the `NSOpenGLContext` of the specified window.
|
||||
*
|
||||
* @return The `NSOpenGLContext` of the specified window, or `nil` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.0.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_X11)
|
||||
/*! @brief Returns the `Display` used by GLFW.
|
||||
*
|
||||
* @return The `Display` used by GLFW, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.0.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI Display* glfwGetX11Display(void);
|
||||
|
||||
/*! @brief Returns the `RRCrtc` of the specified monitor.
|
||||
*
|
||||
* @return The `RRCrtc` of the specified monitor, or `None` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.1.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
|
||||
|
||||
/*! @brief Returns the `RROutput` of the specified monitor.
|
||||
*
|
||||
* @return The `RROutput` of the specified monitor, or `None` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.1.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
|
||||
|
||||
/*! @brief Returns the `Window` of the specified window.
|
||||
*
|
||||
* @return The `Window` of the specified window, or `None` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.0.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
|
||||
|
||||
/*! @brief Sets the current primary selection to the specified string.
|
||||
*
|
||||
* @param[in] string A UTF-8 encoded string.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @pointer_lifetime The specified string is copied before this function
|
||||
* returns.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
* @sa @ref clipboard
|
||||
* @sa glfwGetX11SelectionString
|
||||
* @sa glfwSetClipboardString
|
||||
*
|
||||
* @since Added in version 3.3.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI void glfwSetX11SelectionString(const char* string);
|
||||
|
||||
/*! @brief Returns the contents of the current primary selection as a string.
|
||||
*
|
||||
* If the selection is empty or if its contents cannot be converted, `NULL`
|
||||
* is returned and a @ref GLFW_FORMAT_UNAVAILABLE error is generated.
|
||||
*
|
||||
* @return The contents of the selection as a UTF-8 encoded string, or `NULL`
|
||||
* if an [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
|
||||
* should not free it yourself. It is valid until the next call to @ref
|
||||
* glfwGetX11SelectionString or @ref glfwSetX11SelectionString, or until the
|
||||
* library is terminated.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
* @sa @ref clipboard
|
||||
* @sa glfwSetX11SelectionString
|
||||
* @sa glfwGetClipboardString
|
||||
*
|
||||
* @since Added in version 3.3.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI const char* glfwGetX11SelectionString(void);
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_GLX)
|
||||
/*! @brief Returns the `GLXContext` of the specified window.
|
||||
*
|
||||
* @return The `GLXContext` of the specified window, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.0.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
|
||||
|
||||
/*! @brief Returns the `GLXWindow` of the specified window.
|
||||
*
|
||||
* @return The `GLXWindow` of the specified window, or `None` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.2.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
|
||||
/*! @brief Returns the `struct wl_display*` used by GLFW.
|
||||
*
|
||||
* @return The `struct wl_display*` used by GLFW, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.2.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
|
||||
|
||||
/*! @brief Returns the `struct wl_output*` of the specified monitor.
|
||||
*
|
||||
* @return The `struct wl_output*` of the specified monitor, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.2.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
|
||||
|
||||
/*! @brief Returns the main `struct wl_surface*` of the specified window.
|
||||
*
|
||||
* @return The main `struct wl_surface*` of the specified window, or `NULL` if
|
||||
* an [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.2.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_MIR)
|
||||
/*! @brief Returns the `MirConnection*` used by GLFW.
|
||||
*
|
||||
* @return The `MirConnection*` used by GLFW, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.2.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI MirConnection* glfwGetMirDisplay(void);
|
||||
|
||||
/*! @brief Returns the Mir output ID of the specified monitor.
|
||||
*
|
||||
* @return The Mir output ID of the specified monitor, or zero if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.2.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI int glfwGetMirMonitor(GLFWmonitor* monitor);
|
||||
|
||||
/*! @brief Returns the `MirWindow*` of the specified window.
|
||||
*
|
||||
* @return The `MirWindow*` of the specified window, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.2.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI MirWindow* glfwGetMirWindow(GLFWwindow* window);
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
||||
/*! @brief Returns the `EGLDisplay` used by GLFW.
|
||||
*
|
||||
* @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.0.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
|
||||
|
||||
/*! @brief Returns the `EGLContext` of the specified window.
|
||||
*
|
||||
* @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.0.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
|
||||
|
||||
/*! @brief Returns the `EGLSurface` of the specified window.
|
||||
*
|
||||
* @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.0.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
|
||||
/*! @brief Retrieves the color buffer associated with the specified window.
|
||||
*
|
||||
* @param[in] window The window whose color buffer to retrieve.
|
||||
* @param[out] width Where to store the width of the color buffer, or `NULL`.
|
||||
* @param[out] height Where to store the height of the color buffer, or `NULL`.
|
||||
* @param[out] format Where to store the OSMesa pixel format of the color
|
||||
* buffer, or `NULL`.
|
||||
* @param[out] buffer Where to store the address of the color buffer, or
|
||||
* `NULL`.
|
||||
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.3.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height, int* format, void** buffer);
|
||||
|
||||
/*! @brief Retrieves the depth buffer associated with the specified window.
|
||||
*
|
||||
* @param[in] window The window whose depth buffer to retrieve.
|
||||
* @param[out] width Where to store the width of the depth buffer, or `NULL`.
|
||||
* @param[out] height Where to store the height of the depth buffer, or `NULL`.
|
||||
* @param[out] bytesPerValue Where to store the number of bytes per depth
|
||||
* buffer element, or `NULL`.
|
||||
* @param[out] buffer Where to store the address of the depth buffer, or
|
||||
* `NULL`.
|
||||
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.3.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height, int* bytesPerValue, void** buffer);
|
||||
|
||||
/*! @brief Returns the `OSMesaContext` of the specified window.
|
||||
*
|
||||
* @return The `OSMesaContext` of the specified window, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.3.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* window);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _glfw3_native_h_ */
|
||||
|
5466
examples/others/external/include/glad.h
vendored
Normal file
BIN
examples/others/external/lib/libglfw3.a
vendored
Normal file
5466
examples/others/iqm_loader/glad.h
Normal file
98
examples/others/iqm_loader/models_iqm_animation.c
Normal file
@@ -0,0 +1,98 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [models] example - Load IQM 3d model with animations and play them
|
||||
*
|
||||
* This example has been created using raylib 2.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2018 @culacant and @raysan5
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define RIQM_IMPLEMENTATION
|
||||
#include "riqm.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - iqm animation");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.type = CAMERA_PERSPECTIVE; // Camera mode type
|
||||
|
||||
// Load the animated model mesh and basic data
|
||||
AnimatedModel model = LoadAnimatedModel("resources/guy.iqm");
|
||||
|
||||
// Load model texture and set material
|
||||
// NOTE: There is only 1 mesh and 1 material (both at index 0), thats what the 2 0's are
|
||||
model = AnimatedModelAddTexture(model, "resources/guytex.png"); // REPLACE!
|
||||
model = SetMeshMaterial(model, 0, 0); // REPLACE!
|
||||
|
||||
// Load animation data
|
||||
Animation anim = LoadAnimationFromIQM("resources/guyanim.iqm");
|
||||
|
||||
int animFrameCounter = 0;
|
||||
|
||||
SetCameraMode(camera, CAMERA_FREE); // Set free camera mode
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera);
|
||||
|
||||
// Play animation when spacebar is held down
|
||||
if (IsKeyDown(KEY_SPACE))
|
||||
{
|
||||
animFrameCounter++;
|
||||
AnimateModel(model, anim, animFrameCounter); // Animate the model with animation data and frame
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawAnimatedModel(model, Vector3Zero(), 1.0f, WHITE); // Draw animated model
|
||||
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
EndMode3D();
|
||||
|
||||
DrawText("(c) Guy IQM 3D model by -------", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadAnimation(anim); // Unload animation data
|
||||
UnloadAnimatedModel(model); // Unload animated model
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
1334
examples/others/iqm_loader/raymath.h
Normal file
BIN
examples/others/iqm_loader/resources/guy.blend
Normal file
BIN
examples/others/iqm_loader/resources/guy.iqm
Normal file
BIN
examples/others/iqm_loader/resources/guyanim.iqm
Normal file
BIN
examples/others/iqm_loader/resources/guytex.png
Normal file
After Width: | Height: | Size: 295 KiB |
1260
examples/others/iqm_loader/riqm.h
Normal file
500
examples/others/iqm_loader/rlgl.h
Normal file
@@ -0,0 +1,500 @@
|
||||
/**********************************************************************************************
|
||||
*
|
||||
* rlgl - raylib OpenGL abstraction layer
|
||||
*
|
||||
* rlgl is a wrapper for multiple OpenGL versions (1.1, 2.1, 3.3 Core, ES 2.0) to
|
||||
* pseudo-OpenGL 1.1 style functions (rlVertex, rlTranslate, rlRotate...).
|
||||
*
|
||||
* When chosing an OpenGL version greater than OpenGL 1.1, rlgl stores vertex data on internal
|
||||
* VBO buffers (and VAOs if available). It requires calling 3 functions:
|
||||
* rlglInit() - Initialize internal buffers and auxiliar resources
|
||||
* rlglDraw() - Process internal buffers and send required draw calls
|
||||
* rlglClose() - De-initialize internal buffers data and other auxiliar resources
|
||||
*
|
||||
* CONFIGURATION:
|
||||
*
|
||||
* #define GRAPHICS_API_OPENGL_11
|
||||
* #define GRAPHICS_API_OPENGL_21
|
||||
* #define GRAPHICS_API_OPENGL_33
|
||||
* #define GRAPHICS_API_OPENGL_ES2
|
||||
* Use selected OpenGL graphics backend, should be supported by platform
|
||||
* Those preprocessor defines are only used on rlgl module, if OpenGL version is
|
||||
* required by any other module, use rlGetVersion() tocheck it
|
||||
*
|
||||
* #define RLGL_STANDALONE
|
||||
* Use rlgl as standalone library (no raylib dependency)
|
||||
*
|
||||
* #define SUPPORT_VR_SIMULATOR
|
||||
* Support VR simulation functionality (stereo rendering)
|
||||
*
|
||||
* #define SUPPORT_DISTORTION_SHADER
|
||||
* Include stereo rendering distortion shader (shader_distortion.h)
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
* raymath - 3D math functionality (Vector3, Matrix, Quaternion)
|
||||
* GLAD - OpenGL extensions loading (OpenGL 3.3 Core only)
|
||||
*
|
||||
*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#ifndef RLGL_H
|
||||
#define RLGL_H
|
||||
|
||||
#if defined(RLGL_STANDALONE)
|
||||
#define RAYMATH_STANDALONE
|
||||
#else
|
||||
#include "raylib.h" // Required for: Model, Shader, Texture2D, TraceLog()
|
||||
#endif
|
||||
|
||||
#include "raymath.h" // Required for: Vector3, Matrix
|
||||
|
||||
// Security check in case no GRAPHICS_API_OPENGL_* defined
|
||||
#if !defined(GRAPHICS_API_OPENGL_11) && !defined(GRAPHICS_API_OPENGL_21) && !defined(GRAPHICS_API_OPENGL_33) && !defined(GRAPHICS_API_OPENGL_ES2)
|
||||
#define GRAPHICS_API_OPENGL_33
|
||||
#endif
|
||||
|
||||
// Security check in case multiple GRAPHICS_API_OPENGL_* defined
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
#if defined(GRAPHICS_API_OPENGL_21)
|
||||
#undef GRAPHICS_API_OPENGL_21
|
||||
#endif
|
||||
#if defined(GRAPHICS_API_OPENGL_33)
|
||||
#undef GRAPHICS_API_OPENGL_33
|
||||
#endif
|
||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||
#undef GRAPHICS_API_OPENGL_ES2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_21)
|
||||
#define GRAPHICS_API_OPENGL_33
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Defines and Macros
|
||||
//----------------------------------------------------------------------------------
|
||||
#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
|
||||
// NOTE: This is the maximum amount of lines, triangles and quads per frame, be careful!
|
||||
#define MAX_LINES_BATCH 8192
|
||||
#define MAX_TRIANGLES_BATCH 4096
|
||||
#define MAX_QUADS_BATCH 8192
|
||||
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
||||
// NOTE: Reduce memory sizes for embedded systems (RPI and HTML5)
|
||||
// NOTE: On HTML5 (emscripten) this is allocated on heap, by default it's only 16MB!...just take care...
|
||||
#define MAX_LINES_BATCH 1024 // Critical for wire shapes (sphere)
|
||||
#define MAX_TRIANGLES_BATCH 2048 // Critical for some shapes (sphere)
|
||||
#define MAX_QUADS_BATCH 1024 // Be careful with text, every letter maps a quad
|
||||
#endif
|
||||
|
||||
// Texture parameters (equivalent to OpenGL defines)
|
||||
#define RL_TEXTURE_WRAP_S 0x2802 // GL_TEXTURE_WRAP_S
|
||||
#define RL_TEXTURE_WRAP_T 0x2803 // GL_TEXTURE_WRAP_T
|
||||
#define RL_TEXTURE_MAG_FILTER 0x2800 // GL_TEXTURE_MAG_FILTER
|
||||
#define RL_TEXTURE_MIN_FILTER 0x2801 // GL_TEXTURE_MIN_FILTER
|
||||
#define RL_TEXTURE_ANISOTROPIC_FILTER 0x3000 // Anisotropic filter (custom identifier)
|
||||
|
||||
#define RL_FILTER_NEAREST 0x2600 // GL_NEAREST
|
||||
#define RL_FILTER_LINEAR 0x2601 // GL_LINEAR
|
||||
#define RL_FILTER_MIP_NEAREST 0x2700 // GL_NEAREST_MIPMAP_NEAREST
|
||||
#define RL_FILTER_NEAREST_MIP_LINEAR 0x2702 // GL_NEAREST_MIPMAP_LINEAR
|
||||
#define RL_FILTER_LINEAR_MIP_NEAREST 0x2701 // GL_LINEAR_MIPMAP_NEAREST
|
||||
#define RL_FILTER_MIP_LINEAR 0x2703 // GL_LINEAR_MIPMAP_LINEAR
|
||||
|
||||
#define RL_WRAP_REPEAT 0x2901 // GL_REPEAT
|
||||
#define RL_WRAP_CLAMP 0x812F // GL_CLAMP_TO_EDGE
|
||||
#define RL_WRAP_CLAMP_MIRROR 0x8742 // GL_MIRROR_CLAMP_EXT
|
||||
|
||||
// Matrix modes (equivalent to OpenGL)
|
||||
#define RL_MODELVIEW 0x1700 // GL_MODELVIEW
|
||||
#define RL_PROJECTION 0x1701 // GL_PROJECTION
|
||||
#define RL_TEXTURE 0x1702 // GL_TEXTURE
|
||||
|
||||
// Primitive assembly draw modes
|
||||
#define RL_LINES 0x0001 // GL_LINES
|
||||
#define RL_TRIANGLES 0x0004 // GL_TRIANGLES
|
||||
#define RL_QUADS 0x0007 // GL_QUADS
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
typedef enum { OPENGL_11 = 1, OPENGL_21, OPENGL_33, OPENGL_ES_20 } GlVersion;
|
||||
|
||||
typedef unsigned char byte;
|
||||
|
||||
#if defined(RLGL_STANDALONE)
|
||||
#ifndef __cplusplus
|
||||
// Boolean type
|
||||
typedef enum { false, true } bool;
|
||||
#endif
|
||||
|
||||
// Color type, RGBA (32bit)
|
||||
typedef struct Color {
|
||||
unsigned char r;
|
||||
unsigned char g;
|
||||
unsigned char b;
|
||||
unsigned char a;
|
||||
} Color;
|
||||
|
||||
// Rectangle type
|
||||
typedef struct Rectangle {
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
} Rectangle;
|
||||
|
||||
// Texture2D type
|
||||
// NOTE: Data stored in GPU memory
|
||||
typedef struct Texture2D {
|
||||
unsigned int id; // OpenGL texture id
|
||||
int width; // Texture base width
|
||||
int height; // Texture base height
|
||||
int mipmaps; // Mipmap levels, 1 by default
|
||||
int format; // Data format (PixelFormat)
|
||||
} Texture2D;
|
||||
|
||||
// RenderTexture2D type, for texture rendering
|
||||
typedef struct RenderTexture2D {
|
||||
unsigned int id; // Render texture (fbo) id
|
||||
Texture2D texture; // Color buffer attachment texture
|
||||
Texture2D depth; // Depth buffer attachment texture
|
||||
} RenderTexture2D;
|
||||
|
||||
// Vertex data definning a mesh
|
||||
typedef struct Mesh {
|
||||
int vertexCount; // number of vertices stored in arrays
|
||||
int triangleCount; // number of triangles stored (indexed or not)
|
||||
float *vertices; // vertex position (XYZ - 3 components per vertex) (shader-location = 0)
|
||||
float *texcoords; // vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
|
||||
float *texcoords2; // vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
|
||||
float *normals; // vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
|
||||
float *tangents; // vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)
|
||||
unsigned char *colors; // vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
|
||||
unsigned short *indices;// vertex indices (in case vertex data comes indexed)
|
||||
|
||||
unsigned int vaoId; // OpenGL Vertex Array Object id
|
||||
unsigned int vboId[7]; // OpenGL Vertex Buffer Objects id (7 types of vertex data)
|
||||
} Mesh;
|
||||
|
||||
// Shader and material limits
|
||||
#define MAX_SHADER_LOCATIONS 32
|
||||
#define MAX_MATERIAL_MAPS 12
|
||||
|
||||
// Shader type (generic)
|
||||
typedef struct Shader {
|
||||
unsigned int id; // Shader program id
|
||||
int locs[MAX_SHADER_LOCATIONS]; // Shader locations array
|
||||
} Shader;
|
||||
|
||||
// Material texture map
|
||||
typedef struct MaterialMap {
|
||||
Texture2D texture; // Material map texture
|
||||
Color color; // Material map color
|
||||
float value; // Material map value
|
||||
} MaterialMap;
|
||||
|
||||
// Material type (generic)
|
||||
typedef struct Material {
|
||||
Shader shader; // Material shader
|
||||
MaterialMap maps[MAX_MATERIAL_MAPS]; // Material maps
|
||||
float *params; // Material generic parameters (if required)
|
||||
} Material;
|
||||
|
||||
// Camera type, defines a camera position/orientation in 3d space
|
||||
typedef struct Camera {
|
||||
Vector3 position; // Camera position
|
||||
Vector3 target; // Camera target it looks-at
|
||||
Vector3 up; // Camera up vector (rotation over its axis)
|
||||
float fovy; // Camera field-of-view apperture in Y (degrees)
|
||||
} Camera;
|
||||
|
||||
// Head-Mounted-Display device parameters
|
||||
typedef struct VrDeviceInfo {
|
||||
int hResolution; // HMD horizontal resolution in pixels
|
||||
int vResolution; // HMD vertical resolution in pixels
|
||||
float hScreenSize; // HMD horizontal size in meters
|
||||
float vScreenSize; // HMD vertical size in meters
|
||||
float vScreenCenter; // HMD screen center in meters
|
||||
float eyeToScreenDistance; // HMD distance between eye and display in meters
|
||||
float lensSeparationDistance; // HMD lens separation distance in meters
|
||||
float interpupillaryDistance; // HMD IPD (distance between pupils) in meters
|
||||
float lensDistortionValues[4]; // HMD lens distortion constant parameters
|
||||
float chromaAbCorrection[4]; // HMD chromatic aberration correction parameters
|
||||
} VrDeviceInfo;
|
||||
|
||||
// TraceLog message types
|
||||
typedef enum {
|
||||
LOG_INFO = 0,
|
||||
LOG_ERROR,
|
||||
LOG_WARNING,
|
||||
LOG_DEBUG,
|
||||
LOG_OTHER
|
||||
} TraceLogType;
|
||||
|
||||
// Texture formats (support depends on OpenGL version)
|
||||
typedef enum {
|
||||
UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
|
||||
UNCOMPRESSED_GRAY_ALPHA,
|
||||
UNCOMPRESSED_R5G6B5, // 16 bpp
|
||||
UNCOMPRESSED_R8G8B8, // 24 bpp
|
||||
UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)
|
||||
UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha)
|
||||
UNCOMPRESSED_R8G8B8A8, // 32 bpp
|
||||
UNCOMPRESSED_R32, // 32 bpp (1 channel - float)
|
||||
UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float)
|
||||
UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float)
|
||||
COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)
|
||||
COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)
|
||||
COMPRESSED_DXT3_RGBA, // 8 bpp
|
||||
COMPRESSED_DXT5_RGBA, // 8 bpp
|
||||
COMPRESSED_ETC1_RGB, // 4 bpp
|
||||
COMPRESSED_ETC2_RGB, // 4 bpp
|
||||
COMPRESSED_ETC2_EAC_RGBA, // 8 bpp
|
||||
COMPRESSED_PVRT_RGB, // 4 bpp
|
||||
COMPRESSED_PVRT_RGBA, // 4 bpp
|
||||
COMPRESSED_ASTC_4x4_RGBA, // 8 bpp
|
||||
COMPRESSED_ASTC_8x8_RGBA // 2 bpp
|
||||
} PixelFormat;
|
||||
|
||||
// Texture parameters: filter mode
|
||||
// NOTE 1: Filtering considers mipmaps if available in the texture
|
||||
// NOTE 2: Filter is accordingly set for minification and magnification
|
||||
typedef enum {
|
||||
FILTER_POINT = 0, // No filter, just pixel aproximation
|
||||
FILTER_BILINEAR, // Linear filtering
|
||||
FILTER_TRILINEAR, // Trilinear filtering (linear with mipmaps)
|
||||
FILTER_ANISOTROPIC_4X, // Anisotropic filtering 4x
|
||||
FILTER_ANISOTROPIC_8X, // Anisotropic filtering 8x
|
||||
FILTER_ANISOTROPIC_16X, // Anisotropic filtering 16x
|
||||
} TextureFilterMode;
|
||||
|
||||
// Texture parameters: wrap mode
|
||||
typedef enum {
|
||||
WRAP_REPEAT = 0,
|
||||
WRAP_CLAMP,
|
||||
WRAP_MIRROR
|
||||
} TextureWrapMode;
|
||||
|
||||
// Color blending modes (pre-defined)
|
||||
typedef enum {
|
||||
BLEND_ALPHA = 0,
|
||||
BLEND_ADDITIVE,
|
||||
BLEND_MULTIPLIED
|
||||
} BlendMode;
|
||||
|
||||
// Shader location point type
|
||||
typedef enum {
|
||||
LOC_VERTEX_POSITION = 0,
|
||||
LOC_VERTEX_TEXCOORD01,
|
||||
LOC_VERTEX_TEXCOORD02,
|
||||
LOC_VERTEX_NORMAL,
|
||||
LOC_VERTEX_TANGENT,
|
||||
LOC_VERTEX_COLOR,
|
||||
LOC_MATRIX_MVP,
|
||||
LOC_MATRIX_MODEL,
|
||||
LOC_MATRIX_VIEW,
|
||||
LOC_MATRIX_PROJECTION,
|
||||
LOC_VECTOR_VIEW,
|
||||
LOC_COLOR_DIFFUSE,
|
||||
LOC_COLOR_SPECULAR,
|
||||
LOC_COLOR_AMBIENT,
|
||||
LOC_MAP_ALBEDO, // LOC_MAP_DIFFUSE
|
||||
LOC_MAP_METALNESS, // LOC_MAP_SPECULAR
|
||||
LOC_MAP_NORMAL,
|
||||
LOC_MAP_ROUGHNESS,
|
||||
LOC_MAP_OCCLUSION,
|
||||
LOC_MAP_EMISSION,
|
||||
LOC_MAP_HEIGHT,
|
||||
LOC_MAP_CUBEMAP,
|
||||
LOC_MAP_IRRADIANCE,
|
||||
LOC_MAP_PREFILTER,
|
||||
LOC_MAP_BRDF
|
||||
} ShaderLocationIndex;
|
||||
|
||||
#define LOC_MAP_DIFFUSE LOC_MAP_ALBEDO
|
||||
#define LOC_MAP_SPECULAR LOC_MAP_METALNESS
|
||||
|
||||
// Material map type
|
||||
typedef enum {
|
||||
MAP_ALBEDO = 0, // MAP_DIFFUSE
|
||||
MAP_METALNESS = 1, // MAP_SPECULAR
|
||||
MAP_NORMAL = 2,
|
||||
MAP_ROUGHNESS = 3,
|
||||
MAP_OCCLUSION,
|
||||
MAP_EMISSION,
|
||||
MAP_HEIGHT,
|
||||
MAP_CUBEMAP, // NOTE: Uses GL_TEXTURE_CUBE_MAP
|
||||
MAP_IRRADIANCE, // NOTE: Uses GL_TEXTURE_CUBE_MAP
|
||||
MAP_PREFILTER, // NOTE: Uses GL_TEXTURE_CUBE_MAP
|
||||
MAP_BRDF
|
||||
} TexmapIndex;
|
||||
|
||||
#define MAP_DIFFUSE MAP_ALBEDO
|
||||
#define MAP_SPECULAR MAP_METALNESS
|
||||
|
||||
// VR Head Mounted Display devices
|
||||
typedef enum {
|
||||
HMD_DEFAULT_DEVICE = 0,
|
||||
HMD_OCULUS_RIFT_DK2,
|
||||
HMD_OCULUS_RIFT_CV1,
|
||||
HMD_OCULUS_GO,
|
||||
HMD_VALVE_HTC_VIVE,
|
||||
HMD_SONY_PSVR
|
||||
} VrDevice;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { // Prevents name mangling of functions
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Functions Declaration - Matrix operations
|
||||
//------------------------------------------------------------------------------------
|
||||
void rlMatrixMode(int mode); // Choose the current matrix to be transformed
|
||||
void rlPushMatrix(void); // Push the current matrix to stack
|
||||
void rlPopMatrix(void); // Pop lattest inserted matrix from stack
|
||||
void rlLoadIdentity(void); // Reset current matrix to identity matrix
|
||||
void rlTranslatef(float x, float y, float z); // Multiply the current matrix by a translation matrix
|
||||
void rlRotatef(float angleDeg, float x, float y, float z); // Multiply the current matrix by a rotation matrix
|
||||
void rlScalef(float x, float y, float z); // Multiply the current matrix by a scaling matrix
|
||||
void rlMultMatrixf(float *matf); // Multiply the current matrix by another matrix
|
||||
void rlFrustum(double left, double right, double bottom, double top, double near, double far);
|
||||
void rlOrtho(double left, double right, double bottom, double top, double near, double far);
|
||||
void rlViewport(int x, int y, int width, int height); // Set the viewport area
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Functions Declaration - Vertex level operations
|
||||
//------------------------------------------------------------------------------------
|
||||
void rlBegin(int mode); // Initialize drawing mode (how to organize vertex)
|
||||
void rlEnd(void); // Finish vertex providing
|
||||
void rlVertex2i(int x, int y); // Define one vertex (position) - 2 int
|
||||
void rlVertex2f(float x, float y); // Define one vertex (position) - 2 float
|
||||
void rlVertex3f(float x, float y, float z); // Define one vertex (position) - 3 float
|
||||
void rlTexCoord2f(float x, float y); // Define one vertex (texture coordinate) - 2 float
|
||||
void rlNormal3f(float x, float y, float z); // Define one vertex (normal) - 3 float
|
||||
void rlColor4ub(byte r, byte g, byte b, byte a); // Define one vertex (color) - 4 byte
|
||||
void rlColor3f(float x, float y, float z); // Define one vertex (color) - 3 float
|
||||
void rlColor4f(float x, float y, float z, float w); // Define one vertex (color) - 4 float
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Functions Declaration - OpenGL equivalent functions (common to 1.1, 3.3+, ES2)
|
||||
// NOTE: This functions are used to completely abstract raylib code from OpenGL layer
|
||||
//------------------------------------------------------------------------------------
|
||||
void rlEnableTexture(unsigned int id); // Enable texture usage
|
||||
void rlDisableTexture(void); // Disable texture usage
|
||||
void rlTextureParameters(unsigned int id, int param, int value); // Set texture parameters (filter, wrap)
|
||||
void rlEnableRenderTexture(unsigned int id); // Enable render texture (fbo)
|
||||
void rlDisableRenderTexture(void); // Disable render texture (fbo), return to default framebuffer
|
||||
void rlEnableDepthTest(void); // Enable depth test
|
||||
void rlDisableDepthTest(void); // Disable depth test
|
||||
void rlEnableWireMode(void); // Enable wire mode
|
||||
void rlDisableWireMode(void); // Disable wire mode
|
||||
void rlDeleteTextures(unsigned int id); // Delete OpenGL texture from GPU
|
||||
void rlDeleteRenderTextures(RenderTexture2D target); // Delete render textures (fbo) from GPU
|
||||
void rlDeleteShader(unsigned int id); // Delete OpenGL shader program from GPU
|
||||
void rlDeleteVertexArrays(unsigned int id); // Unload vertex data (VAO) from GPU memory
|
||||
void rlDeleteBuffers(unsigned int id); // Unload vertex data (VBO) from GPU memory
|
||||
void rlClearColor(byte r, byte g, byte b, byte a); // Clear color buffer with color
|
||||
void rlClearScreenBuffers(void); // Clear used screen buffers (color and depth)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Functions Declaration - rlgl functionality
|
||||
//------------------------------------------------------------------------------------
|
||||
void rlglInit(int width, int height); // Initialize rlgl (buffers, shaders, textures, states)
|
||||
void rlglClose(void); // De-inititialize rlgl (buffers, shaders, textures)
|
||||
void rlglDraw(void); // Update and Draw default buffers (lines, triangles, quads)
|
||||
|
||||
int rlGetVersion(void); // Returns current OpenGL version
|
||||
bool rlCheckBufferLimit(int type, int vCount); // Check internal buffer overflow for a given number of vertex
|
||||
void rlSetDebugMarker(const char *text); // Set debug marker for analysis
|
||||
void rlLoadExtensions(void *loader); // Load OpenGL extensions
|
||||
Vector3 rlUnproject(Vector3 source, Matrix proj, Matrix view); // Get world coordinates from screen coordinates
|
||||
|
||||
// Textures data management
|
||||
unsigned int rlLoadTexture(void *data, int width, int height, int format, int mipmapCount); // Load texture in GPU
|
||||
void rlUpdateTexture(unsigned int id, int width, int height, int format, const void *data); // Update GPU texture with new data
|
||||
void rlUnloadTexture(unsigned int id);
|
||||
void rlGenerateMipmaps(Texture2D *texture); // Generate mipmap data for selected texture
|
||||
void *rlReadTexturePixels(Texture2D texture); // Read texture pixel data
|
||||
unsigned char *rlReadScreenPixels(int width, int height); // Read screen pixel data (color buffer)
|
||||
RenderTexture2D rlLoadRenderTexture(int width, int height); // Load a texture to be used for rendering (fbo with color and depth attachments)
|
||||
|
||||
// Vertex data management
|
||||
void rlLoadMesh(Mesh *mesh, bool dynamic); // Upload vertex data into GPU and provided VAO/VBO ids
|
||||
void rlUpdateMesh(Mesh mesh, int buffer, int numVertex); // Update vertex data on GPU (upload new data to one buffer)
|
||||
void rlDrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform
|
||||
void rlUnloadMesh(Mesh *mesh); // Unload mesh data from CPU and GPU
|
||||
|
||||
// NOTE: There is a set of shader related functions that are available to end user,
|
||||
// to avoid creating function wrappers through core module, they have been directly declared in raylib.h
|
||||
|
||||
#if defined(RLGL_STANDALONE)
|
||||
//------------------------------------------------------------------------------------
|
||||
// Shaders System Functions (Module: rlgl)
|
||||
// NOTE: This functions are useless when using OpenGL 1.1
|
||||
//------------------------------------------------------------------------------------
|
||||
Shader LoadShader(char *vsFileName, char *fsFileName); // Load a custom shader and bind default locations
|
||||
void UnloadShader(Shader shader); // Unload a custom shader from memory
|
||||
|
||||
Shader GetShaderDefault(void); // Get default shader
|
||||
Texture2D GetTextureDefault(void); // Get default texture
|
||||
|
||||
// Shader configuration functions
|
||||
int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
||||
void SetShaderValue(Shader shader, int uniformLoc, const float *value, int size); // Set shader uniform value (float)
|
||||
void SetShaderValuei(Shader shader, int uniformLoc, const int *value, int size); // Set shader uniform value (int)
|
||||
void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
||||
void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
|
||||
void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
|
||||
Matrix GetMatrixModelview(); // Get internal modelview matrix
|
||||
|
||||
|
||||
// Texture maps generation (PBR)
|
||||
// NOTE: Required shaders should be provided
|
||||
Texture2D GenTextureCubemap(Shader shader, Texture2D skyHDR, int size); // Generate cubemap texture from HDR texture
|
||||
Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size); // Generate irradiance texture using cubemap data
|
||||
Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size); // Generate prefilter texture using cubemap data
|
||||
Texture2D GenTextureBRDF(Shader shader, Texture2D cubemap, int size); // Generate BRDF texture using cubemap data
|
||||
|
||||
// Shading and blending
|
||||
void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
||||
void EndShaderMode(void); // End custom shader drawing (use default shader)
|
||||
void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
|
||||
void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
|
||||
|
||||
// VR simulator functionality
|
||||
VrDeviceInfo GetVrDeviceInfo(int vrDeviceType); // Get VR device information for some standard devices
|
||||
void InitVrSimulator(VrDeviceInfo info); // Init VR simulator for selected device parameters
|
||||
void CloseVrSimulator(void); // Close VR simulator for current device
|
||||
void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
|
||||
void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator)
|
||||
void BeginVrDrawing(void); // Begin VR stereo rendering
|
||||
void EndVrDrawing(void); // End VR stereo rendering
|
||||
|
||||
void TraceLog(int msgType, const char *text, ...); // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // RLGL_H
|
@@ -1,507 +0,0 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - Oculus Rift CV1
|
||||
*
|
||||
* Compile example using:
|
||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I..\src\external -I..\src\external\OculusSDK\LibOVR\Include /
|
||||
* -L. -L..\src\external\OculusSDK\LibOVR -lLibOVRRT32_1 -lraylib -lglfw3 -lopengl32 -lgdi32 -std=c99 /
|
||||
* -Wl,-allow-multiple-definition
|
||||
*
|
||||
* #define SUPPORT_OCULUS_RIFT_CV1 / RLGL_OCULUS_SUPPORT
|
||||
* Enable Oculus Rift CV1 functionality
|
||||
*
|
||||
* This example has been created using raylib 1.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2016 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include "glad.h" // Required for: OpenGL types and functions declarations
|
||||
#include "raymath.h" // Required for: Vector3, Quaternion and Matrix functionality
|
||||
|
||||
#include <string.h> // Required for: memset()
|
||||
#include <stdlib.h> // Required for: exit()
|
||||
#include <stdio.h> // required for: vfprintf()
|
||||
#include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end()
|
||||
|
||||
#define RLGL_OCULUS_SUPPORT // Enable Oculus Rift code
|
||||
#if defined(RLGL_OCULUS_SUPPORT)
|
||||
#include "OVR_CAPI_GL.h" // Oculus SDK for OpenGL
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Defines and Macros
|
||||
//----------------------------------------------------------------------------------
|
||||
// ...
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
#if defined(RLGL_OCULUS_SUPPORT)
|
||||
// Oculus buffer type
|
||||
typedef struct OculusBuffer {
|
||||
ovrTextureSwapChain textureChain;
|
||||
GLuint depthId;
|
||||
GLuint fboId;
|
||||
int width;
|
||||
int height;
|
||||
} OculusBuffer;
|
||||
|
||||
// Oculus mirror texture type
|
||||
typedef struct OculusMirror {
|
||||
ovrMirrorTexture texture;
|
||||
GLuint fboId;
|
||||
int width;
|
||||
int height;
|
||||
} OculusMirror;
|
||||
|
||||
// Oculus layer type
|
||||
typedef struct OculusLayer {
|
||||
ovrViewScaleDesc viewScaleDesc;
|
||||
ovrLayerEyeFov eyeLayer; // layer 0
|
||||
//ovrLayerQuad quadLayer; // TODO: layer 1: '2D' quad for GUI
|
||||
Matrix eyeProjections[2];
|
||||
int width;
|
||||
int height;
|
||||
} OculusLayer;
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
#if defined(RLGL_OCULUS_SUPPORT)
|
||||
// OVR device variables
|
||||
static ovrSession session; // Oculus session (pointer to ovrHmdStruct)
|
||||
static ovrHmdDesc hmdDesc; // Oculus device descriptor parameters
|
||||
static ovrGraphicsLuid luid; // Oculus locally unique identifier for the program (64 bit)
|
||||
static OculusLayer layer; // Oculus drawing layer (similar to photoshop)
|
||||
static OculusBuffer buffer; // Oculus internal buffers (texture chain and fbo)
|
||||
static OculusMirror mirror; // Oculus mirror texture and fbo
|
||||
static unsigned int frameIndex = 0; // Oculus frames counter, used to discard frames from chain
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module specific Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
#if defined(RLGL_OCULUS_SUPPORT)
|
||||
static bool InitOculusDevice(void); // Initialize Oculus device (returns true if success)
|
||||
static void CloseOculusDevice(void); // Close Oculus device
|
||||
static void UpdateOculusTracking(Camera *camera); // Update Oculus head position-orientation tracking
|
||||
static void BeginOculusDrawing(void); // Setup Oculus buffers for drawing
|
||||
static void EndOculusDrawing(void); // Finish Oculus drawing and blit framebuffer to mirror
|
||||
|
||||
static OculusBuffer LoadOculusBuffer(ovrSession session, int width, int height); // Load Oculus required buffers
|
||||
static void UnloadOculusBuffer(ovrSession session, OculusBuffer buffer); // Unload texture required buffers
|
||||
static OculusMirror LoadOculusMirror(ovrSession session, int width, int height); // Load Oculus mirror buffers
|
||||
static void UnloadOculusMirror(ovrSession session, OculusMirror mirror); // Unload Oculus mirror buffers
|
||||
static void BlitOculusMirror(ovrSession session, OculusMirror mirror); // Copy Oculus screen buffer to mirror texture
|
||||
static OculusLayer InitOculusLayer(ovrSession session); // Init Oculus layer (similar to photoshop)
|
||||
static Matrix FromOvrMatrix(ovrMatrix4f ovrM); // Convert from Oculus ovrMatrix4f struct to raymath Matrix struct
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 1080;
|
||||
int screenHeight = 600;
|
||||
|
||||
// NOTE: screenWidth/screenHeight should match VR device aspect ratio
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - oculus rift");
|
||||
|
||||
bool vrDeviceReady = InitOculusDevice(); // Init VR device Oculus Rift CV1
|
||||
|
||||
if (!vrDeviceReady) InitVrSimulator(HMD_OCULUS_RIFT_CV1); // Init VR simulator if device fails
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera;
|
||||
camera.position = (Vector3){ 5.0f, 2.0f, 5.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 60.0f; // Camera field-of-view Y
|
||||
|
||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set first person camera mode
|
||||
|
||||
SetTargetFPS(90); // Set our game to run at 90 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (!vrDeviceReady) UpdateCamera(&camera); // Update camera (simulator mode)
|
||||
else UpdateOculusTracking(&camera); // Update camera with device tracking data
|
||||
|
||||
if (IsKeyPressed(KEY_SPACE)) ToggleVrMode(); // Toggle VR mode
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
if (vrDeviceReady) BeginOculusDrawing();
|
||||
else BeginVrDrawing();
|
||||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
||||
|
||||
DrawGrid(40, 1.0f);
|
||||
|
||||
End3dMode();
|
||||
|
||||
if (vrDeviceReady) EndOculusDrawing();
|
||||
else EndVrDrawing();
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
if (vrDeviceReady) CloseOculusDevice();
|
||||
else CloseVrSimulator();
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module specific Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
#if defined(RLGL_OCULUS_SUPPORT)
|
||||
// Set internal projection and modelview matrix depending on eyes tracking data
|
||||
static void SetStereoView(int eye, Matrix matProjection, Matrix matModelView)
|
||||
{
|
||||
Matrix eyeProjection = matProjection;
|
||||
Matrix eyeModelView = matModelView;
|
||||
|
||||
glViewport(layer.eyeLayer.Viewport[eye].Pos.x, layer.eyeLayer.Viewport[eye].Pos.y,
|
||||
layer.eyeLayer.Viewport[eye].Size.w, layer.eyeLayer.Viewport[eye].Size.h);
|
||||
|
||||
Quaternion eyeRenderPose = (Quaternion){ layer.eyeLayer.RenderPose[eye].Orientation.x,
|
||||
layer.eyeLayer.RenderPose[eye].Orientation.y,
|
||||
layer.eyeLayer.RenderPose[eye].Orientation.z,
|
||||
layer.eyeLayer.RenderPose[eye].Orientation.w };
|
||||
QuaternionInvert(&eyeRenderPose);
|
||||
Matrix eyeOrientation = QuaternionToMatrix(eyeRenderPose);
|
||||
Matrix eyeTranslation = MatrixTranslate(-layer.eyeLayer.RenderPose[eye].Position.x,
|
||||
-layer.eyeLayer.RenderPose[eye].Position.y,
|
||||
-layer.eyeLayer.RenderPose[eye].Position.z);
|
||||
|
||||
Matrix eyeView = MatrixMultiply(eyeTranslation, eyeOrientation); // Matrix containing eye-head movement
|
||||
eyeModelView = MatrixMultiply(matModelView, eyeView); // Combine internal camera matrix (modelview) wih eye-head movement
|
||||
|
||||
eyeProjection = layer.eyeProjections[eye];
|
||||
}
|
||||
|
||||
// Initialize Oculus device (returns true if success)
|
||||
static bool InitOculusDevice(void)
|
||||
{
|
||||
bool oculusReady = false;
|
||||
|
||||
ovrResult result = ovr_Initialize(NULL);
|
||||
|
||||
if (OVR_FAILURE(result)) TraceLog(WARNING, "OVR: Could not initialize Oculus device");
|
||||
else
|
||||
{
|
||||
result = ovr_Create(&session, &luid);
|
||||
if (OVR_FAILURE(result))
|
||||
{
|
||||
TraceLog(LOG_WARNING, "OVR: Could not create Oculus session");
|
||||
ovr_Shutdown();
|
||||
}
|
||||
else
|
||||
{
|
||||
hmdDesc = ovr_GetHmdDesc(session);
|
||||
|
||||
TraceLog(LOG_INFO, "OVR: Product Name: %s", hmdDesc.ProductName);
|
||||
TraceLog(LOG_INFO, "OVR: Manufacturer: %s", hmdDesc.Manufacturer);
|
||||
TraceLog(LOG_INFO, "OVR: Product ID: %i", hmdDesc.ProductId);
|
||||
TraceLog(LOG_INFO, "OVR: Product Type: %i", hmdDesc.Type);
|
||||
//TraceLog(LOG_INFO, "OVR: Serial Number: %s", hmdDesc.SerialNumber);
|
||||
TraceLog(LOG_INFO, "OVR: Resolution: %ix%i", hmdDesc.Resolution.w, hmdDesc.Resolution.h);
|
||||
|
||||
// NOTE: Oculus mirror is set to defined screenWidth and screenHeight...
|
||||
// ...ideally, it should be (hmdDesc.Resolution.w/2, hmdDesc.Resolution.h/2)
|
||||
|
||||
// Initialize Oculus Buffers
|
||||
layer = InitOculusLayer(session);
|
||||
buffer = LoadOculusBuffer(session, layer.width, layer.height);
|
||||
mirror = LoadOculusMirror(session, hmdDesc.Resolution.w/2, hmdDesc.Resolution.h/2); // NOTE: hardcoded...
|
||||
layer.eyeLayer.ColorTexture[0] = buffer.textureChain; //SetOculusLayerTexture(eyeLayer, buffer.textureChain);
|
||||
|
||||
// Recenter OVR tracking origin
|
||||
ovr_RecenterTrackingOrigin(session);
|
||||
|
||||
oculusReady = true;
|
||||
}
|
||||
}
|
||||
|
||||
return oculusReady;
|
||||
}
|
||||
|
||||
// Close Oculus device (and unload buffers)
|
||||
static void CloseOculusDevice(void)
|
||||
{
|
||||
UnloadOculusMirror(session, mirror); // Unload Oculus mirror buffer
|
||||
UnloadOculusBuffer(session, buffer); // Unload Oculus texture buffers
|
||||
|
||||
ovr_Destroy(session); // Free Oculus session data
|
||||
ovr_Shutdown(); // Close Oculus device connection
|
||||
}
|
||||
|
||||
// Update Oculus head position-orientation tracking
|
||||
static void UpdateOculusTracking(Camera *camera)
|
||||
{
|
||||
frameIndex++;
|
||||
|
||||
ovrPosef eyePoses[2];
|
||||
ovr_GetEyePoses(session, frameIndex, ovrTrue, layer.viewScaleDesc.HmdToEyeOffset, eyePoses, &layer.eyeLayer.SensorSampleTime);
|
||||
|
||||
layer.eyeLayer.RenderPose[0] = eyePoses[0];
|
||||
layer.eyeLayer.RenderPose[1] = eyePoses[1];
|
||||
|
||||
// TODO: Update external camera with eyePoses data (position, orientation)
|
||||
// NOTE: We can simplify to simple camera if we consider IPD and HMD device configuration again later
|
||||
// it will be useful for the user to draw, lets say, billboards oriented to camera
|
||||
|
||||
// Get session status information
|
||||
ovrSessionStatus sessionStatus;
|
||||
ovr_GetSessionStatus(session, &sessionStatus);
|
||||
|
||||
if (sessionStatus.ShouldQuit) TraceLog(LOG_WARNING, "OVR: Session should quit...");
|
||||
if (sessionStatus.ShouldRecenter) ovr_RecenterTrackingOrigin(session);
|
||||
//if (sessionStatus.HmdPresent) // HMD is present.
|
||||
//if (sessionStatus.DisplayLost) // HMD was unplugged or the display driver was manually disabled or encountered a TDR.
|
||||
//if (sessionStatus.HmdMounted) // HMD is on the user's head.
|
||||
//if (sessionStatus.IsVisible) // the game or experience has VR focus and is visible in the HMD.
|
||||
}
|
||||
|
||||
// Setup Oculus buffers for drawing
|
||||
static void BeginOculusDrawing(void)
|
||||
{
|
||||
GLuint currentTexId;
|
||||
int currentIndex;
|
||||
|
||||
ovr_GetTextureSwapChainCurrentIndex(session, buffer.textureChain, ¤tIndex);
|
||||
ovr_GetTextureSwapChainBufferGL(session, buffer.textureChain, currentIndex, ¤tTexId);
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, buffer.fboId);
|
||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, currentTexId, 0);
|
||||
//glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, buffer.depthId, 0); // Already binded
|
||||
}
|
||||
|
||||
// Finish Oculus drawing and blit framebuffer to mirror
|
||||
static void EndOculusDrawing(void)
|
||||
{
|
||||
// Unbind current framebuffer (Oculus buffer)
|
||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
|
||||
ovr_CommitTextureSwapChain(session, buffer.textureChain);
|
||||
|
||||
ovrLayerHeader *layers = &layer.eyeLayer.Header;
|
||||
ovr_SubmitFrame(session, frameIndex, &layer.viewScaleDesc, &layers, 1);
|
||||
|
||||
// Blit mirror texture to back buffer
|
||||
BlitOculusMirror(session, mirror);
|
||||
}
|
||||
|
||||
// Load Oculus required buffers: texture-swap-chain, fbo, texture-depth
|
||||
static OculusBuffer LoadOculusBuffer(ovrSession session, int width, int height)
|
||||
{
|
||||
OculusBuffer buffer;
|
||||
buffer.width = width;
|
||||
buffer.height = height;
|
||||
|
||||
// Create OVR texture chain
|
||||
ovrTextureSwapChainDesc desc = {};
|
||||
desc.Type = ovrTexture_2D;
|
||||
desc.ArraySize = 1;
|
||||
desc.Width = width;
|
||||
desc.Height = height;
|
||||
desc.MipLevels = 1;
|
||||
desc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB; // Requires glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
desc.SampleCount = 1;
|
||||
desc.StaticImage = ovrFalse;
|
||||
|
||||
ovrResult result = ovr_CreateTextureSwapChainGL(session, &desc, &buffer.textureChain);
|
||||
|
||||
if (!OVR_SUCCESS(result)) TraceLog(LOG_WARNING, "OVR: Failed to create swap textures buffer");
|
||||
|
||||
int textureCount = 0;
|
||||
ovr_GetTextureSwapChainLength(session, buffer.textureChain, &textureCount);
|
||||
|
||||
if (!OVR_SUCCESS(result) || !textureCount) TraceLog(LOG_WARNING, "OVR: Unable to count swap chain textures");
|
||||
|
||||
for (int i = 0; i < textureCount; ++i)
|
||||
{
|
||||
GLuint chainTexId;
|
||||
ovr_GetTextureSwapChainBufferGL(session, buffer.textureChain, i, &chainTexId);
|
||||
glBindTexture(GL_TEXTURE_2D, chainTexId);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
/*
|
||||
// Setup framebuffer object (using depth texture)
|
||||
glGenFramebuffers(1, &buffer.fboId);
|
||||
glGenTextures(1, &buffer.depthId);
|
||||
glBindTexture(GL_TEXTURE_2D, buffer.depthId);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, buffer.width, buffer.height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
|
||||
*/
|
||||
|
||||
// Setup framebuffer object (using depth renderbuffer)
|
||||
glGenFramebuffers(1, &buffer.fboId);
|
||||
glGenRenderbuffers(1, &buffer.depthId);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, buffer.fboId);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, buffer.depthId);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, buffer.width, buffer.height);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, buffer.depthId);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// Unload texture required buffers
|
||||
static void UnloadOculusBuffer(ovrSession session, OculusBuffer buffer)
|
||||
{
|
||||
if (buffer.textureChain)
|
||||
{
|
||||
ovr_DestroyTextureSwapChain(session, buffer.textureChain);
|
||||
buffer.textureChain = NULL;
|
||||
}
|
||||
|
||||
if (buffer.depthId != 0) glDeleteTextures(1, &buffer.depthId);
|
||||
if (buffer.fboId != 0) glDeleteFramebuffers(1, &buffer.fboId);
|
||||
}
|
||||
|
||||
// Load Oculus mirror buffers
|
||||
static OculusMirror LoadOculusMirror(ovrSession session, int width, int height)
|
||||
{
|
||||
OculusMirror mirror;
|
||||
mirror.width = width;
|
||||
mirror.height = height;
|
||||
|
||||
ovrMirrorTextureDesc mirrorDesc;
|
||||
memset(&mirrorDesc, 0, sizeof(mirrorDesc));
|
||||
mirrorDesc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
|
||||
mirrorDesc.Width = mirror.width;
|
||||
mirrorDesc.Height = mirror.height;
|
||||
|
||||
if (!OVR_SUCCESS(ovr_CreateMirrorTextureGL(session, &mirrorDesc, &mirror.texture))) TraceLog(LOG_WARNING, "Could not create mirror texture");
|
||||
|
||||
glGenFramebuffers(1, &mirror.fboId);
|
||||
|
||||
return mirror;
|
||||
}
|
||||
|
||||
// Unload Oculus mirror buffers
|
||||
static void UnloadOculusMirror(ovrSession session, OculusMirror mirror)
|
||||
{
|
||||
if (mirror.fboId != 0) glDeleteFramebuffers(1, &mirror.fboId);
|
||||
if (mirror.texture) ovr_DestroyMirrorTexture(session, mirror.texture);
|
||||
}
|
||||
|
||||
// Copy Oculus screen buffer to mirror texture
|
||||
static void BlitOculusMirror(ovrSession session, OculusMirror mirror)
|
||||
{
|
||||
GLuint mirrorTextureId;
|
||||
|
||||
ovr_GetMirrorTextureBufferGL(session, mirror.texture, &mirrorTextureId);
|
||||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, mirror.fboId);
|
||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mirrorTextureId, 0);
|
||||
#if defined(GRAPHICS_API_OPENGL_33)
|
||||
// NOTE: glBlitFramebuffer() requires extension: GL_EXT_framebuffer_blit (not available in OpenGL ES 2.0)
|
||||
glBlitFramebuffer(0, 0, mirror.width, mirror.height, 0, mirror.height, mirror.width, 0, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
#endif
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
// Init Oculus layer (similar to photoshop)
|
||||
static OculusLayer InitOculusLayer(ovrSession session)
|
||||
{
|
||||
OculusLayer layer = { 0 };
|
||||
|
||||
layer.viewScaleDesc.HmdSpaceToWorldScaleInMeters = 1.0f;
|
||||
|
||||
memset(&layer.eyeLayer, 0, sizeof(ovrLayerEyeFov));
|
||||
layer.eyeLayer.Header.Type = ovrLayerType_EyeFov;
|
||||
layer.eyeLayer.Header.Flags = ovrLayerFlag_TextureOriginAtBottomLeft;
|
||||
|
||||
ovrEyeRenderDesc eyeRenderDescs[2];
|
||||
|
||||
for (int eye = 0; eye < 2; eye++)
|
||||
{
|
||||
eyeRenderDescs[eye] = ovr_GetRenderDesc(session, eye, hmdDesc.DefaultEyeFov[eye]);
|
||||
ovrMatrix4f ovrPerspectiveProjection = ovrMatrix4f_Projection(eyeRenderDescs[eye].Fov, 0.01f, 10000.0f, ovrProjection_None); //ovrProjection_ClipRangeOpenGL);
|
||||
layer.eyeProjections[eye] = FromOvrMatrix(ovrPerspectiveProjection); // NOTE: struct ovrMatrix4f { float M[4][4] } --> struct Matrix
|
||||
|
||||
layer.viewScaleDesc.HmdToEyeOffset[eye] = eyeRenderDescs[eye].HmdToEyeOffset;
|
||||
layer.eyeLayer.Fov[eye] = eyeRenderDescs[eye].Fov;
|
||||
|
||||
ovrSizei eyeSize = ovr_GetFovTextureSize(session, eye, layer.eyeLayer.Fov[eye], 1.0f);
|
||||
layer.eyeLayer.Viewport[eye].Size = eyeSize;
|
||||
layer.eyeLayer.Viewport[eye].Pos.x = layer.width;
|
||||
layer.eyeLayer.Viewport[eye].Pos.y = 0;
|
||||
|
||||
layer.height = eyeSize.h; //std::max(renderTargetSize.y, (uint32_t)eyeSize.h);
|
||||
layer.width += eyeSize.w;
|
||||
}
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
// Convert from Oculus ovrMatrix4f struct to raymath Matrix struct
|
||||
static Matrix FromOvrMatrix(ovrMatrix4f ovrmat)
|
||||
{
|
||||
Matrix rmat;
|
||||
|
||||
rmat.m0 = ovrmat.M[0][0];
|
||||
rmat.m1 = ovrmat.M[1][0];
|
||||
rmat.m2 = ovrmat.M[2][0];
|
||||
rmat.m3 = ovrmat.M[3][0];
|
||||
rmat.m4 = ovrmat.M[0][1];
|
||||
rmat.m5 = ovrmat.M[1][1];
|
||||
rmat.m6 = ovrmat.M[2][1];
|
||||
rmat.m7 = ovrmat.M[3][1];
|
||||
rmat.m8 = ovrmat.M[0][2];
|
||||
rmat.m9 = ovrmat.M[1][2];
|
||||
rmat.m10 = ovrmat.M[2][2];
|
||||
rmat.m11 = ovrmat.M[3][2];
|
||||
rmat.m12 = ovrmat.M[0][3];
|
||||
rmat.m13 = ovrmat.M[1][3];
|
||||
rmat.m14 = ovrmat.M[2][3];
|
||||
rmat.m15 = ovrmat.M[3][3];
|
||||
|
||||
MatrixTranspose(&rmat);
|
||||
|
||||
return rmat;
|
||||
}
|
||||
#endif
|
@@ -5,30 +5,54 @@
|
||||
* NOTE: This example requires OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders but it can also be used.
|
||||
*
|
||||
* Compile rlgl module using:
|
||||
* gcc -c $(RAYLIB_DIR)\raylib\src\rlgl.c -DRLGL_STANDALONE -DRAYMATH_IMPLEMENTATION -DGRAPHICS_API_OPENGL_33 /
|
||||
* -I$(RAYLIB_DIR)\raylib\src\external -Wall -std=c99
|
||||
* DEPENDENCIES:
|
||||
* rlgl.h - OpenGL 1.1 immediate-mode style coding translation layer
|
||||
* glad.h - OpenGL extensions initialization library (required by rlgl)
|
||||
* raymath.h - 3D math library (required by rlgl)
|
||||
* glfw3 - Windows and context initialization library
|
||||
*
|
||||
* NOTE: rlgl module requires the following header-only files:
|
||||
* external/glad.h - OpenGL extensions loader (stripped to only required extensions)
|
||||
* shader_distortion.h - Distortion shader for VR
|
||||
* raymath.h - Vector and matrix math functions
|
||||
* rlgl library is provided as a single-file header-only library, this library
|
||||
* allows coding in a pseudo-OpenGL 1.1 style while translating calls to multiple
|
||||
* OpenGL versions backends (1.1, 2.1, 3.3, ES 2.0).
|
||||
*
|
||||
* Compile example using:
|
||||
* gcc -o rlgl_standalone.exe rlgl_standalone.c rlgl.o -s $(RAYLIB_DIR)\raylib\raylib_icon -I$(RAYLIB_DIR)\raylib\src /
|
||||
* -L. -L$(RAYLIB_DIR)\raylib\src -lglfw3 -lopengl32 -lgdi32 -Wall -std=c99
|
||||
* COMPILATION:
|
||||
* gcc -o rlgl_standalone.exe rlgl_standalone.c -s -Iexternal\include -I..\..\src \
|
||||
* -L. -Lexternal\lib -lglfw3 -lopengl32 -lgdi32 -Wall -std=c99 \
|
||||
* -DRAYMATH_IMPLEMENTATION -DGRAPHICS_API_OPENGL_33
|
||||
*
|
||||
* This example has been created using raylib 1.7 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
|
||||
* This example is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include <GLFW/glfw3.h> // Windows/Context and inputs management
|
||||
|
||||
#define RLGL_IMPLEMENTATION
|
||||
#define RLGL_STANDALONE
|
||||
#include "rlgl.h" // rlgl library: OpenGL 1.1 immediate-mode style coding
|
||||
#include "rlgl.h" // OpenGL 1.1 immediate-mode style coding
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#define GLFW_INCLUDE_ES2
|
||||
#endif
|
||||
|
||||
#include <GLFW/glfw3.h> // Windows/Context and inputs management
|
||||
|
||||
#define RED (Color){ 230, 41, 55, 255 } // Red
|
||||
#define RAYWHITE (Color){ 245, 245, 245, 255 } // My own White (raylib logo)
|
||||
|
@@ -107,13 +107,11 @@ int main()
|
||||
// Try to get lights location points (if available)
|
||||
GetShaderLightsLocations(material.shader);
|
||||
|
||||
material.texDiffuse = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model diffuse texture
|
||||
material.texNormal = LoadTexture("resources/model/dwarf_normal.png"); // Load model normal texture
|
||||
material.texSpecular = LoadTexture("resources/model/dwarf_specular.png"); // Load model specular texture
|
||||
material.colDiffuse = WHITE;
|
||||
material.colAmbient = (Color){0, 0, 10, 255};
|
||||
material.colSpecular = WHITE;
|
||||
material.glossiness = 50.0f;
|
||||
material.maps[MAP_DIFFUSE].texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model diffuse texture
|
||||
material.maps[MAP_NORMAL].texture = LoadTexture("resources/model/dwarf_normal.png"); // Load model normal texture
|
||||
material.maps[MAP_SPECULAR].texture = LoadTexture("resources/model/dwarf_specular.png"); // Load model specular texture
|
||||
material.maps[MAP_DIFFUSE].color = WHITE;
|
||||
material.maps[MAP_SPECULAR].color = WHITE;
|
||||
|
||||
dwarf.material = material; // Apply material to model
|
||||
|
||||
@@ -159,7 +157,7 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
|
||||
|
||||
@@ -169,7 +167,7 @@ int main()
|
||||
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
End3dMode();
|
||||
EndMode3D();
|
||||
|
||||
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||
|
||||
|
@@ -7,10 +7,10 @@
|
||||
*
|
||||
* Use the following line to compile:
|
||||
*
|
||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
|
||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib.rc.o -static -lraylib -lpthread
|
||||
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
|
||||
*
|
||||
* Copyright (c) 2017 Victor Fisac
|
||||
* Copyright (c) 2016-2018 Victor Fisac
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
@@ -32,6 +32,7 @@ int main()
|
||||
// Physac logo drawing position
|
||||
int logoX = screenWidth - MeasureText("Physac", 30) - 10;
|
||||
int logoY = 15;
|
||||
bool needsReset = false;
|
||||
|
||||
// Initialize physics and default physics bodies
|
||||
InitPhysics();
|
||||
@@ -52,10 +53,9 @@ int main()
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyPressed('R')) // Reset physics input
|
||||
// Delay initialization of variables due to physics reset async
|
||||
if (needsReset)
|
||||
{
|
||||
ResetPhysics();
|
||||
|
||||
floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10);
|
||||
floor->enabled = false;
|
||||
|
||||
@@ -63,6 +63,13 @@ int main()
|
||||
circle->enabled = false;
|
||||
}
|
||||
|
||||
// Reset physics input
|
||||
if (IsKeyPressed('R'))
|
||||
{
|
||||
ResetPhysics();
|
||||
needsReset = true;
|
||||
}
|
||||
|
||||
// Physics body creation inputs
|
||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10);
|
||||
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10);
|
||||
|
@@ -7,10 +7,10 @@
|
||||
*
|
||||
* Use the following line to compile:
|
||||
*
|
||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
|
||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib.rc.o -static -lraylib -lpthread
|
||||
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
|
||||
*
|
||||
* Copyright (c) 2017 Victor Fisac
|
||||
* Copyright (c) 2016-2018 Victor Fisac
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
@@ -7,10 +7,10 @@
|
||||
*
|
||||
* Use the following line to compile:
|
||||
*
|
||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
|
||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib.rc.o -static -lraylib -lpthread
|
||||
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
|
||||
*
|
||||
* Copyright (c) 2017 Victor Fisac
|
||||
* Copyright (c) 2016-2018 Victor Fisac
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
@@ -7,10 +7,10 @@
|
||||
*
|
||||
* Use the following line to compile:
|
||||
*
|
||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
|
||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib.rc.o -static -lraylib -lpthread
|
||||
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
|
||||
*
|
||||
* Copyright (c) 2017 Victor Fisac
|
||||
* Copyright (c) 2016-2018 Victor Fisac
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
@@ -7,10 +7,10 @@
|
||||
*
|
||||
* Use the following line to compile:
|
||||
*
|
||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
|
||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib.rc.o -static -lraylib -lpthread
|
||||
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
|
||||
*
|
||||
* Copyright (c) 2017 Victor Fisac
|
||||
* Copyright (c) 2016-2018 Victor Fisac
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
@@ -32,14 +32,15 @@ int main()
|
||||
// Physac logo drawing position
|
||||
int logoX = screenWidth - MeasureText("Physac", 30) - 10;
|
||||
int logoY = 15;
|
||||
bool needsReset = false;
|
||||
|
||||
// Initialize physics and default physics bodies
|
||||
InitPhysics();
|
||||
SetPhysicsGravity(0, 0);
|
||||
|
||||
// Create random polygon physics body to shatter
|
||||
PhysicsBody body = CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
|
||||
|
||||
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@@ -48,12 +49,17 @@ int main()
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Delay initialization of variables due to physics reset asynchronous
|
||||
if (needsReset)
|
||||
{
|
||||
// Create random polygon physics body to shatter
|
||||
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
|
||||
}
|
||||
|
||||
if (IsKeyPressed('R')) // Reset physics input
|
||||
{
|
||||
ResetPhysics();
|
||||
|
||||
// Create random polygon physics body to shatter
|
||||
body = CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
|
||||
needsReset = true;
|
||||
}
|
||||
|
||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) // Physics shatter input
|
||||
|
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 3.9 MiB |
Before Width: | Height: | Size: 2.8 MiB |
22251
examples/shaders/resources/models/barracks.obj
Normal file
BIN
examples/shaders/resources/models/barracks_diffuse.png
Normal file
After Width: | Height: | Size: 363 KiB |
5116
examples/shaders/resources/models/church.obj
Normal file
BIN
examples/shaders/resources/models/church_diffuse.png
Normal file
After Width: | Height: | Size: 350 KiB |
5316
examples/shaders/resources/models/watermill.obj
Normal file
BIN
examples/shaders/resources/models/watermill_diffuse.png
Normal file
After Width: | Height: | Size: 437 KiB |
@@ -13,8 +13,8 @@ uniform vec4 colDiffuse;
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
// NOTE: Render size values should be passed from code
|
||||
const float renderWidth = 800;
|
||||
const float renderHeight = 450;
|
||||
const float renderWidth = 800.0;
|
||||
const float renderHeight = 450.0;
|
||||
|
||||
float radius = 250.0;
|
||||
float angle = 0.8;
|
||||
@@ -43,4 +43,4 @@ void main()
|
||||
vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;;
|
||||
|
||||
gl_FragColor = vec4(color.rgb, 1.0);;
|
||||
}
|
||||
}
|
||||
|