Compare commits
671 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7ef114d1da | ||
![]() |
adb20569be | ||
![]() |
07f3a65a96 | ||
![]() |
6a8b1079c1 | ||
![]() |
703850b341 | ||
![]() |
8da6307456 | ||
![]() |
e469f4ebf7 | ||
![]() |
8941cf3e66 | ||
![]() |
68cad30646 | ||
![]() |
fc7ec5e907 | ||
![]() |
1a948849f3 | ||
![]() |
bba10504e2 | ||
![]() |
ff11a6fbe8 | ||
![]() |
27ebe78313 | ||
![]() |
44961d1975 | ||
![]() |
e8a8d544c5 | ||
![]() |
62cdb2299b | ||
![]() |
9b66883e0b | ||
![]() |
d1b0d6a6dc | ||
![]() |
c47ba58494 | ||
![]() |
41582f0448 | ||
![]() |
3e76d3a3d3 | ||
![]() |
733ed972f7 | ||
![]() |
5d7050bdf9 | ||
![]() |
a025636fa1 | ||
![]() |
3c3dfde3f9 | ||
![]() |
5829fdb73e | ||
![]() |
9b74c40fc2 | ||
![]() |
66e0d774bd | ||
![]() |
a5e1aff99b | ||
![]() |
e333eb415b | ||
![]() |
02df366a7a | ||
![]() |
976a10c891 | ||
![]() |
d28e73849b | ||
![]() |
d7b15ac1cf | ||
![]() |
c0c775e45d | ||
![]() |
b5842434c2 | ||
![]() |
c7e9951795 | ||
![]() |
70ed975b99 | ||
![]() |
7e2b1b4ff0 | ||
![]() |
915b5f370b | ||
![]() |
0c6c421508 | ||
![]() |
bc2c6251f8 | ||
![]() |
b9dd459d5a | ||
![]() |
28da2522fe | ||
![]() |
2528854664 | ||
![]() |
7ae7a87f8a | ||
![]() |
3d41c1b6cd | ||
![]() |
96005f2566 | ||
![]() |
e37d021cd3 | ||
![]() |
133a882556 | ||
![]() |
74339b9fdc | ||
![]() |
2dbcef218c | ||
![]() |
e07281f8bd | ||
![]() |
5e670be239 | ||
![]() |
05abaee0e0 | ||
![]() |
d657537821 | ||
![]() |
5fe0db347c | ||
![]() |
649665eac9 | ||
![]() |
efe359d613 | ||
![]() |
c45fe62abc | ||
![]() |
584e2d664c | ||
![]() |
51a8e1d692 | ||
![]() |
da836a732c | ||
![]() |
6bab884d1d | ||
![]() |
4e6db307e4 | ||
![]() |
0229f9b1a4 | ||
![]() |
6bbaca118f | ||
![]() |
ba3b4b2d08 | ||
![]() |
fcdb120935 | ||
![]() |
8f45370073 | ||
![]() |
502bc61931 | ||
![]() |
5a39b22521 | ||
![]() |
6c44c9d730 | ||
![]() |
a523c64718 | ||
![]() |
5aebd2a16c | ||
![]() |
574c689ff7 | ||
![]() |
b178c992a1 | ||
![]() |
a4d31e1dad | ||
![]() |
e151487fde | ||
![]() |
061848cd0c | ||
![]() |
ab1c12c449 | ||
![]() |
8db8401bc1 | ||
![]() |
58a81dd760 | ||
![]() |
a5838e40d9 | ||
![]() |
78e8fd1c31 | ||
![]() |
2d07d29a1c | ||
![]() |
19bbcbb486 | ||
![]() |
b6ba3dacb9 | ||
![]() |
65d9d0aac1 | ||
![]() |
b9c966f902 | ||
![]() |
d62368f133 | ||
![]() |
3d66a6c93f | ||
![]() |
01e035e28b | ||
![]() |
4af4483f5f | ||
![]() |
2344941974 | ||
![]() |
6f41b9594a | ||
![]() |
3e049c09d5 | ||
![]() |
92e1205f40 | ||
![]() |
71b06caed4 | ||
![]() |
4611406c68 | ||
![]() |
427be604b9 | ||
![]() |
d57b5ac89a | ||
![]() |
82937e1564 | ||
![]() |
7fa12844ed | ||
![]() |
af011bc952 | ||
![]() |
4c728f0b54 | ||
![]() |
5895fb6adc | ||
![]() |
eb6f8bd0ba | ||
![]() |
b7c0d5b6dd | ||
![]() |
680f9d5772 | ||
![]() |
20d8889a03 | ||
![]() |
c67bc02dd1 | ||
![]() |
1b56f7917e | ||
![]() |
7639726193 | ||
![]() |
fb2ed693e4 | ||
![]() |
966e8adcf9 | ||
![]() |
c3386300d3 | ||
![]() |
cb4c676f5d | ||
![]() |
74c486201d | ||
![]() |
6b8f30964d | ||
![]() |
dc2e5c1751 | ||
![]() |
645a5b2507 | ||
![]() |
3a073db029 | ||
![]() |
a6297a2be1 | ||
![]() |
8724cf2ea5 | ||
![]() |
485787059a | ||
![]() |
08615d3247 | ||
![]() |
a1b2d96d9c | ||
![]() |
3c2ee1cc75 | ||
![]() |
117696a893 | ||
![]() |
2f5a7ddcc6 | ||
![]() |
18a9982126 | ||
![]() |
41d3c47ffe | ||
![]() |
7428747ef0 | ||
![]() |
1ee6290fcf | ||
![]() |
572969d8b7 | ||
![]() |
f2247c6f0a | ||
![]() |
05992a6fce | ||
![]() |
c8464bc731 | ||
![]() |
b2098a2d60 | ||
![]() |
ac73e3b5e2 | ||
![]() |
1be68d8cfe | ||
![]() |
eb86d69a38 | ||
![]() |
acfa967e89 | ||
![]() |
5ff0776235 | ||
![]() |
2a408d789c | ||
![]() |
5100cb3e7f | ||
![]() |
b029fb6d31 | ||
![]() |
245ba2a152 | ||
![]() |
89ecad1e29 | ||
![]() |
23bde477e5 | ||
![]() |
2294947660 | ||
![]() |
5aed36e76d | ||
![]() |
e5b5aea998 | ||
![]() |
fadd74358b | ||
![]() |
7912fac815 | ||
![]() |
fa4e0c1a26 | ||
![]() |
1046449339 | ||
![]() |
c5d5d19443 | ||
![]() |
0f783aab34 | ||
![]() |
7849db65e0 | ||
![]() |
9b5a796213 | ||
![]() |
32e374d941 | ||
![]() |
113a580021 | ||
![]() |
a77273d8d8 | ||
![]() |
310fd9b147 | ||
![]() |
01d8642520 | ||
![]() |
30f3e49f3d | ||
![]() |
0b8aded399 | ||
![]() |
d2aeafcf1e | ||
![]() |
81881a120c | ||
![]() |
e7fdf8a13d | ||
![]() |
a750bcceec | ||
![]() |
67d0bf75a7 | ||
![]() |
a8a21312e1 | ||
![]() |
42dad5df95 | ||
![]() |
e176a476c0 | ||
![]() |
19390eaf09 | ||
![]() |
faff512140 | ||
![]() |
946a6cb280 | ||
![]() |
7d789763d6 | ||
![]() |
d62a2f793f | ||
![]() |
9eefcb7939 | ||
![]() |
36bf8a60d8 | ||
![]() |
6d1cdf25a7 | ||
![]() |
51db3b589d | ||
![]() |
b18940d3c6 | ||
![]() |
3f25c52a29 | ||
![]() |
39e73ccc4d | ||
![]() |
df4b55d657 | ||
![]() |
80dbbef0f5 | ||
![]() |
23b75281ad | ||
![]() |
91b2dc2aa9 | ||
![]() |
7459a5c6ef | ||
![]() |
8820baf5cc | ||
![]() |
3b3e163c48 | ||
![]() |
83fb4613c1 | ||
![]() |
1b20182d33 | ||
![]() |
7dfe42d6d0 | ||
![]() |
55f0647213 | ||
![]() |
484c6b360f | ||
![]() |
dec85f741a | ||
![]() |
87d5b51256 | ||
![]() |
aa3b413390 | ||
![]() |
ee43a14f19 | ||
![]() |
64c23f8477 | ||
![]() |
49145e90a2 | ||
![]() |
28e12a6c6a | ||
![]() |
131132f17d | ||
![]() |
884e868e92 | ||
![]() |
eb2483338f | ||
![]() |
becd3c3831 | ||
![]() |
34fafb733f | ||
![]() |
90c129fd61 | ||
![]() |
9922160ab4 | ||
![]() |
1d324d5496 | ||
![]() |
03c38396f3 | ||
![]() |
85cecb2aae | ||
![]() |
d15b93839b | ||
![]() |
b06497cad6 | ||
![]() |
f632e32100 | ||
![]() |
52a6d756f4 | ||
![]() |
f4ca5b378a | ||
![]() |
97054e4e0f | ||
![]() |
86bdf60887 | ||
![]() |
4b4f052fea | ||
![]() |
2de92e3c07 | ||
![]() |
85e7856989 | ||
![]() |
b4293edd70 | ||
![]() |
6c7685da3f | ||
![]() |
ea40bda88c | ||
![]() |
1184db83f7 | ||
![]() |
ca600b44a0 | ||
![]() |
b5fe41f41a | ||
![]() |
3cd9e3896a | ||
![]() |
7024628c65 | ||
![]() |
d2bb6185f1 | ||
![]() |
c3f06b7470 | ||
![]() |
a7afd8de99 | ||
![]() |
cde26c743c | ||
![]() |
40b73a8a91 | ||
![]() |
6f3c99a295 | ||
![]() |
9ce2331cc1 | ||
![]() |
cacd4a9d90 | ||
![]() |
be7f717a24 | ||
![]() |
4992edab24 | ||
![]() |
af3df8bdd6 | ||
![]() |
02a533768c | ||
![]() |
46046bf018 | ||
![]() |
bc29720024 | ||
![]() |
6a2e51ec78 | ||
![]() |
e6d304cdc2 | ||
![]() |
4663cc03f3 | ||
![]() |
77484cb19c | ||
![]() |
15345ded25 | ||
![]() |
c715cae18d | ||
![]() |
98a7d35bab | ||
![]() |
4f7d090fb2 | ||
![]() |
954f029118 | ||
![]() |
4fa2c32906 | ||
![]() |
7e9bed5c89 | ||
![]() |
5ec87c4c6f | ||
![]() |
05443cd0c8 | ||
![]() |
b02c6127a0 | ||
![]() |
46774a8167 | ||
![]() |
f28c1ef675 | ||
![]() |
eee995ec3d | ||
![]() |
a3ca859db2 | ||
![]() |
40d6c15798 | ||
![]() |
d41386d661 | ||
![]() |
7ae426c377 | ||
![]() |
fa0d5bbf9e | ||
![]() |
d10ff78822 | ||
![]() |
e932d23cf4 | ||
![]() |
49b723e76d | ||
![]() |
71017993ce | ||
![]() |
42d56d2f37 | ||
![]() |
cff38308b7 | ||
![]() |
9c52a4932d | ||
![]() |
edc1d2511d | ||
![]() |
1c4dadcf68 | ||
![]() |
d797bb3e1c | ||
![]() |
bec467705e | ||
![]() |
fe0d04c879 | ||
![]() |
406373caa9 | ||
![]() |
6a46dcb374 | ||
![]() |
7e77dc7a21 | ||
![]() |
56e7a75a77 | ||
![]() |
0b4af7d341 | ||
![]() |
8deac79028 | ||
![]() |
2031c06880 | ||
![]() |
20e446cc7d | ||
![]() |
1eae4b483b | ||
![]() |
1f82b0d847 | ||
![]() |
b0ce16b460 | ||
![]() |
237972652d | ||
![]() |
9f699af138 | ||
![]() |
4525c897e2 | ||
![]() |
019434a37e | ||
![]() |
22b7713287 | ||
![]() |
a748c3bf25 | ||
![]() |
cc827041a9 | ||
![]() |
95d31b0986 | ||
![]() |
e30995c65c | ||
![]() |
2829cec720 | ||
![]() |
a63a422972 | ||
![]() |
e043dad2a6 | ||
![]() |
aca9f20c2e | ||
![]() |
da51abf07f | ||
![]() |
31af42ee8e | ||
![]() |
c77f97c84a | ||
![]() |
d8f1aad494 | ||
![]() |
6b2aa173fc | ||
![]() |
2cf8352b95 | ||
![]() |
55e7428924 | ||
![]() |
c7fe2c772e | ||
![]() |
a4a10a6edd | ||
![]() |
c2e79a212c | ||
![]() |
680cbdf1f0 | ||
![]() |
9961e3b0d7 | ||
![]() |
5997fa8fe1 | ||
![]() |
59a44bf5b9 | ||
![]() |
30f21438bc | ||
![]() |
ebcbe292c1 | ||
![]() |
b978dec51c | ||
![]() |
8cef1d12f2 | ||
![]() |
a77505c554 | ||
![]() |
e0d4cc3143 | ||
![]() |
fcf15fe8c0 | ||
![]() |
1694887f9b | ||
![]() |
0237231a8d | ||
![]() |
e88099bfd3 | ||
![]() |
887881486b | ||
![]() |
f21bd8836a | ||
![]() |
18c309fb38 | ||
![]() |
bc07636d6b | ||
![]() |
7104911236 | ||
![]() |
ca329bba0d | ||
![]() |
d1a4c1f789 | ||
![]() |
451969de1b | ||
![]() |
7fe8d25253 | ||
![]() |
b17937dda8 | ||
![]() |
6f0a4a7663 | ||
![]() |
98f4e06a37 | ||
![]() |
1db9a85b5d | ||
![]() |
e5c9e5e328 | ||
![]() |
eb8512b43c | ||
![]() |
6321dd4614 | ||
![]() |
689f3c086b | ||
![]() |
9f79ed2972 | ||
![]() |
421bbde1e0 | ||
![]() |
10982fa184 | ||
![]() |
a1809fad4c | ||
![]() |
8f05322263 | ||
![]() |
358ca7595d | ||
![]() |
89fedf0bb9 | ||
![]() |
4211056354 | ||
![]() |
6d56c99a37 | ||
![]() |
f46fcb8307 | ||
![]() |
b708965ab7 | ||
![]() |
3c8b7a41b2 | ||
![]() |
a08508f6a4 | ||
![]() |
7e0929e3b4 | ||
![]() |
793977db4a | ||
![]() |
b5b3bbb30b | ||
![]() |
615cb35d96 | ||
![]() |
21c30f43d4 | ||
![]() |
c20ccfe274 | ||
![]() |
c0d1425aac | ||
![]() |
350cb0a8a8 | ||
![]() |
cedd5efe4c | ||
![]() |
f8bd56b07f | ||
![]() |
9fbf5c8ca2 | ||
![]() |
caa1f45643 | ||
![]() |
5e8b6b0157 | ||
![]() |
8473e94879 | ||
![]() |
8dece6a179 | ||
![]() |
ccf085ac70 | ||
![]() |
dde1d68a02 | ||
![]() |
14884a2a6c | ||
![]() |
9c62d8a400 | ||
![]() |
6e1326143e | ||
![]() |
03e6006ac8 | ||
![]() |
e614942a2d | ||
![]() |
1397242d88 | ||
![]() |
b8246d8592 | ||
![]() |
7eacac24d5 | ||
![]() |
2a64aa2abd | ||
![]() |
f976b03a4f | ||
![]() |
8db130289e | ||
![]() |
3aad221b1e | ||
![]() |
ff499fe57d | ||
![]() |
3c75bb5e6d | ||
![]() |
8a08a9b225 | ||
![]() |
1b7d136daa | ||
![]() |
f346c672fb | ||
![]() |
08adb4b8c3 | ||
![]() |
3d936061c8 | ||
![]() |
95f3b6e18e | ||
![]() |
8eecbbe4aa | ||
![]() |
ea5cd42e6c | ||
![]() |
3ffe34f9bb | ||
![]() |
416a52b5bc | ||
![]() |
91faf72dda | ||
![]() |
60e8511543 | ||
![]() |
97abaff4c5 | ||
![]() |
5ad65d9291 | ||
![]() |
776304e8e8 | ||
![]() |
d5aab98ac9 | ||
![]() |
1f66f0d9a2 | ||
![]() |
c1a02e9fca | ||
![]() |
f987ac9dca | ||
![]() |
1d3f230c92 | ||
![]() |
ae301a1d23 | ||
![]() |
b132ae099b | ||
![]() |
2783d0d63e | ||
![]() |
5d27c1e6c9 | ||
![]() |
d2882a68fe | ||
![]() |
2ae5849826 | ||
![]() |
25ae374f62 | ||
![]() |
8b7db29ba0 | ||
![]() |
74642ba1c6 | ||
![]() |
96b0563249 | ||
![]() |
00c611a5fb | ||
![]() |
bba8454034 | ||
![]() |
29b9b054dd | ||
![]() |
e8b89b5ecf | ||
![]() |
5d9df629d7 | ||
![]() |
dc6136e820 | ||
![]() |
75b0264f35 | ||
![]() |
64c588e9d8 | ||
![]() |
862ef0524e | ||
![]() |
d73abe73e5 | ||
![]() |
6bf746d531 | ||
![]() |
f6df47dfe5 | ||
![]() |
3f12fa54f7 | ||
![]() |
90b3dceb54 | ||
![]() |
a6db31c01e | ||
![]() |
39e22046c1 | ||
![]() |
3d8b1165a8 | ||
![]() |
163a9e1f41 | ||
![]() |
9b6227688f | ||
![]() |
3c2ce77b7b | ||
![]() |
1878a9ea01 | ||
![]() |
06910eedfd | ||
![]() |
ca92f43c27 | ||
![]() |
ea70c47a1a | ||
![]() |
3f7fa6d6e7 | ||
![]() |
ab52f98480 | ||
![]() |
c1d282d9e8 | ||
![]() |
e25f4dca1f | ||
![]() |
68dcb55349 | ||
![]() |
b75511248d | ||
![]() |
e40c26dea5 | ||
![]() |
7baa2975ec | ||
![]() |
e0cb892d2d | ||
![]() |
12d3e21f1b | ||
![]() |
161c8b7d08 | ||
![]() |
82306af111 | ||
![]() |
596338b26a | ||
![]() |
eb772bc1e0 | ||
![]() |
047f093503 | ||
![]() |
df84f93938 | ||
![]() |
a8e63b9724 | ||
![]() |
99e86d180b | ||
![]() |
8adcec185e | ||
![]() |
3fcf2ee19a | ||
![]() |
bdcb16e7bb | ||
![]() |
a679b0ccc0 | ||
![]() |
acedf4a0d5 | ||
![]() |
1f730b3b35 | ||
![]() |
b331edd7a6 | ||
![]() |
9d53e07883 | ||
![]() |
bce2dd1231 | ||
![]() |
d089e1cd34 | ||
![]() |
741afde3bc | ||
![]() |
314c4061df | ||
![]() |
08165fed18 | ||
![]() |
112874fe07 | ||
![]() |
c10348cc85 | ||
![]() |
904a7ee032 | ||
![]() |
4ccf1e61be | ||
![]() |
6916ff58b1 | ||
![]() |
e5d5f6e367 | ||
![]() |
7caedff9ca | ||
![]() |
d9d9c6111b | ||
![]() |
8d6f179062 | ||
![]() |
7e08b312d5 | ||
![]() |
c6d2502bdb | ||
![]() |
a2fd427224 | ||
![]() |
74ed3d07f9 | ||
![]() |
ce58b168f6 | ||
![]() |
c247c371c3 | ||
![]() |
0a2177b4bc | ||
![]() |
ae2452d280 | ||
![]() |
2d6bc1ff42 | ||
![]() |
dec5f332ad | ||
![]() |
d93f8eadf8 | ||
![]() |
53b32f1c20 | ||
![]() |
402ce4e53b | ||
![]() |
861a619053 | ||
![]() |
fc95ceadf0 | ||
![]() |
dde1e0671f | ||
![]() |
4e43192561 | ||
![]() |
97101d1003 | ||
![]() |
37bb8e9554 | ||
![]() |
41732bebe8 | ||
![]() |
e2183f0b99 | ||
![]() |
f565ff018e | ||
![]() |
8241dcf80b | ||
![]() |
c661cad692 | ||
![]() |
37a6f12037 | ||
![]() |
addbd88833 | ||
![]() |
8e86f3586d | ||
![]() |
e67c842faa | ||
![]() |
061294e4d1 | ||
![]() |
20fa362700 | ||
![]() |
20257f3e49 | ||
![]() |
3db13edd89 | ||
![]() |
a727f5768f | ||
![]() |
bf0db83134 | ||
![]() |
ef3b01dffc | ||
![]() |
64575e711b | ||
![]() |
3414910809 | ||
![]() |
2f42b0ce85 | ||
![]() |
12bcdb977a | ||
![]() |
973d32f9a7 | ||
![]() |
049a1c8f6d | ||
![]() |
4b79f63d07 | ||
![]() |
7ebcd06652 | ||
![]() |
ce8d7042c6 | ||
![]() |
d8b8c0f3fc | ||
![]() |
c387bc586d | ||
![]() |
c629b16ebc | ||
![]() |
cef1e6e2e2 | ||
![]() |
740834bb83 | ||
![]() |
2c2ccadd32 | ||
![]() |
6f2f09947f | ||
![]() |
e6e48675cc | ||
![]() |
108f7f6fee | ||
![]() |
2234158049 | ||
![]() |
3ebc55fdfe | ||
![]() |
084fb31186 | ||
![]() |
2d5cc5ddbf | ||
![]() |
f3555a1016 | ||
![]() |
5f1990e044 | ||
![]() |
3d46297cc1 | ||
![]() |
439e73a8ec | ||
![]() |
3d5fa81bf2 | ||
![]() |
2a913b6587 | ||
![]() |
042499188c | ||
![]() |
b354c10072 | ||
![]() |
6267fd1865 | ||
![]() |
f518c4e939 | ||
![]() |
e53e42f43d | ||
![]() |
94abe0db88 | ||
![]() |
89c16baf18 | ||
![]() |
68ffbc06c7 | ||
![]() |
f81cb1a252 | ||
![]() |
1da7e1da8c | ||
![]() |
5775f9d224 | ||
![]() |
38ee6156f8 | ||
![]() |
b83d165764 | ||
![]() |
895f9613d2 | ||
![]() |
602d2a65dd | ||
![]() |
879c874330 | ||
![]() |
153f078bd1 | ||
![]() |
9a478bef1a | ||
![]() |
a1c551c6c4 | ||
![]() |
e44eae3cd5 | ||
![]() |
814952c01d | ||
![]() |
6baf8bccb1 | ||
![]() |
f46ffb98a6 | ||
![]() |
65d003507b | ||
![]() |
251f90cd31 | ||
![]() |
8e870f0eda | ||
![]() |
7c05e498fc | ||
![]() |
eed53a5b44 | ||
![]() |
9909c83012 | ||
![]() |
73a3d4a183 | ||
![]() |
ae95111006 | ||
![]() |
8730f22371 | ||
![]() |
a5329efb23 | ||
![]() |
b4d67499a7 | ||
![]() |
543c0ba30d | ||
![]() |
47137b1489 | ||
![]() |
7b448f59e2 | ||
![]() |
2cb3b91913 | ||
![]() |
2433f30b4b | ||
![]() |
b44b7dd310 | ||
![]() |
632d064b21 | ||
![]() |
bc3983a3dd | ||
![]() |
f501d42e47 | ||
![]() |
4b2f6b2b5f | ||
![]() |
3fd48a14a2 | ||
![]() |
55e76dab47 | ||
![]() |
8d576aaf2b | ||
![]() |
e5271dbdc3 | ||
![]() |
e8829538c9 | ||
![]() |
c563b53afb | ||
![]() |
e19616592d | ||
![]() |
24566c0cf3 | ||
![]() |
a386cedae6 | ||
![]() |
83f6ae148a | ||
![]() |
f9a2d89ed2 | ||
![]() |
b4da7b6777 | ||
![]() |
4ad1fa85a4 | ||
![]() |
892813de76 | ||
![]() |
83a4eb0852 | ||
![]() |
a4e307ed96 | ||
![]() |
65a21ab416 | ||
![]() |
1b249ac1e1 | ||
![]() |
e0854696b4 | ||
![]() |
f951f0c536 | ||
![]() |
e36a80f730 | ||
![]() |
d21422687a | ||
![]() |
9a7d4ccb79 | ||
![]() |
5baab54f93 | ||
![]() |
721d18589f | ||
![]() |
dccd61bef9 | ||
![]() |
9c991bd079 | ||
![]() |
81d8302d53 | ||
![]() |
a43d49ed72 | ||
![]() |
0c60af8981 | ||
![]() |
9609ebf49a | ||
![]() |
55380f8489 | ||
![]() |
266df463cc | ||
![]() |
5fec3ef895 | ||
![]() |
396b830db5 | ||
![]() |
034e9ba1b8 | ||
![]() |
d7f4be0715 | ||
![]() |
baf7d7d19a | ||
![]() |
632d16e27d | ||
![]() |
f6db1ef9c5 | ||
![]() |
9b3b28c81f | ||
![]() |
391555a063 | ||
![]() |
63e320d405 | ||
![]() |
59b7412772 | ||
![]() |
718f7a0161 | ||
![]() |
dee602464b | ||
![]() |
baf225dc01 | ||
![]() |
6945511e82 | ||
![]() |
e1f3f84e84 | ||
![]() |
eb1b2535f6 | ||
![]() |
566a8d17c8 | ||
![]() |
af38e18389 | ||
![]() |
37ce51b274 | ||
![]() |
498c172d8e | ||
![]() |
272d9d58e3 | ||
![]() |
7b4831f1b7 | ||
![]() |
bdbc05c0dc | ||
![]() |
e3ef738264 | ||
![]() |
03720b30a1 | ||
![]() |
ddaa4a304d | ||
![]() |
24c7549698 | ||
![]() |
c5f605e888 | ||
![]() |
5c8191f8a7 | ||
![]() |
923f4b9bbd | ||
![]() |
e103320ad8 | ||
![]() |
7367140fb4 | ||
![]() |
df7a058216 | ||
![]() |
1ba5f1515d | ||
![]() |
0b7373446d | ||
![]() |
767ac9bc3e | ||
![]() |
6f9c176d93 | ||
![]() |
538dfa010d | ||
![]() |
2eb7e96f4b | ||
![]() |
093042b760 | ||
![]() |
434e460c18 | ||
![]() |
65474c621c |
6
.github/FUNDING.yml
vendored
@@ -1,8 +1,8 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: raylib
|
||||
github: raysan5
|
||||
patreon: # raylib
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: raysan
|
||||
ko_fi: # raysan
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
custom: # Replace with a single custom sponsorship URL
|
||||
|
30
.github/workflows/cd_src_release.yml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
name: CD - Source Build & Release - Linux
|
||||
|
||||
# Trigger the workflow on release publish
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@master
|
||||
|
||||
# TODO: Build project and zip generated files
|
||||
- name: Build project
|
||||
id: build_project
|
||||
run: |
|
||||
zip raylib.zip README.md
|
||||
|
||||
- name: Upload Release Asset
|
||||
id: upload-release-asset
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
||||
asset_path: ./raylib.zip
|
||||
asset_name: raylib.zip
|
||||
asset_content_type: application/zip
|
18
.github/workflows/ci_src_examples_linux.yml
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
name: CI - Source & Examples - Linux
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@master
|
||||
- name: apt-update
|
||||
run: sudo apt-get update -qq
|
||||
- name: apt get glfw
|
||||
run: sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev
|
||||
- name: make src
|
||||
run: cd src && make PLATFORM=PLATFORM_DESKTOP
|
||||
- name: make examples
|
||||
run: cd examples && make PLATFORM=PLATFORM_DESKTOP
|
13
.github/workflows/ci_src_examples_macos.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
name: CI - Source & Examples - macOS
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: make src
|
||||
run: cd src && make PLATFORM=PLATFORM_DESKTOP
|
||||
- name: make examples
|
||||
run: cd examples && make PLATFORM=PLATFORM_DESKTOP
|
64
.github/workflows/ci_src_examples_win.yml
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
name: CI - Source & Examples - Windows
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 1
|
||||
matrix:
|
||||
compiler: [mingw, msvc16]
|
||||
bits: [32, 64]
|
||||
include:
|
||||
- compiler: mingw
|
||||
bits: 32
|
||||
CFLAGS: -m32
|
||||
GENERATOR: "MinGW Makefiles"
|
||||
- compiler: mingw
|
||||
bits: 64
|
||||
CFLAGS: -m64
|
||||
GENERATOR: "MinGW Makefiles"
|
||||
- compiler: msvc16
|
||||
bits: 32
|
||||
GENERATOR: "Visual Studio 16 2019"
|
||||
ARCH: "-A Win32"
|
||||
- compiler: msvc16
|
||||
bits: 64
|
||||
GENERATOR: "Visual Studio 16 2019"
|
||||
ARCH: "-A x64"
|
||||
|
||||
env:
|
||||
CFLAGS: ${{ matrix.CFLAGS }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: Setup Environment
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
# Trying to solve an issue with CMake and Chocolatey for MinGW
|
||||
- run: cmake -E remove c:\ProgramData\chocolatey\bin\cpack.exe
|
||||
if: matrix.compiler == 'mingw'
|
||||
|
||||
# Setup MSBuild.exe path if required
|
||||
- uses: warrenbuckley/Setup-MSBuild@v1
|
||||
if: matrix.compiler == 'msvc16'
|
||||
|
||||
- name: Build MinGW Project
|
||||
run: |
|
||||
cd ../raylib/src
|
||||
make PLATFORM=PLATFORM_DESKTOP CC=gcc
|
||||
if: matrix.compiler == 'mingw'
|
||||
|
||||
- name: Setup CMake Project
|
||||
run: cmake -G "${{ matrix.GENERATOR }}" ${{ matrix.ARCH }} -DCMAKE_SH="CMAKE_SH-NOTFOUND" -DSTATIC=ON -DSHARED=ON -DBUILD_EXAMPLES=ON -DBUILD_GAMES=OFF -DINCLUDE_EVERYTHING=ON ../raylib
|
||||
if: matrix.compiler == 'msvc16'
|
||||
|
||||
- name: Build raylib Source & Examples
|
||||
run: cmake --build . --target install
|
||||
if: matrix.compiler == 'msvc16'
|
29
.gitignore
vendored
@@ -30,6 +30,8 @@ Thumbs.db
|
||||
*.cache
|
||||
*.ilk
|
||||
*.log
|
||||
.vs
|
||||
|
||||
[Bb]in
|
||||
[Dd]ebug/
|
||||
[Dd]ebug.win32/
|
||||
@@ -52,7 +54,7 @@ packages/
|
||||
*.exe
|
||||
*.a
|
||||
*.bc
|
||||
!raylib.rc.o
|
||||
*.so
|
||||
|
||||
# Ignore all examples files
|
||||
examples/*
|
||||
@@ -74,7 +76,6 @@ games/*
|
||||
!games/*/
|
||||
# Unignore all games files with extension
|
||||
!games/*.c
|
||||
!games/*.lua
|
||||
!games/*.png
|
||||
# Unignore games makefile
|
||||
!games/Makefile
|
||||
@@ -94,22 +95,9 @@ xcschememanagement.plist
|
||||
xcuserdata/
|
||||
DerivedData/
|
||||
|
||||
# Visual Studio project
|
||||
project/VS2015.UWP/packages
|
||||
project/VS2017/packages
|
||||
|
||||
# Web examples
|
||||
docs/examples/web/*.html
|
||||
docs/examples/web/*/*.html
|
||||
!docs/examples/web/loader.html
|
||||
!docs/examples/web/core/loader.html
|
||||
!docs/examples/web/shapes/loader.html
|
||||
!docs/examples/web/text/loader.html
|
||||
!docs/examples/web/textures/loader.html
|
||||
!docs/examples/web/audio/loader.html
|
||||
!docs/examples/web/physac/loader.html
|
||||
!docs/examples/web/shaders/loader.html
|
||||
!docs/examples/web/models/loader.html
|
||||
# Jetbrains project
|
||||
.idea/
|
||||
cmake-build-debug/
|
||||
|
||||
# CMake stuff
|
||||
CMakeCache.txt
|
||||
@@ -122,17 +110,12 @@ install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
build
|
||||
!templates/android_project/Makefile
|
||||
|
||||
# Unignore These makefiles...
|
||||
!examples/CMakeLists.txt
|
||||
!games/CMakeLists.txt
|
||||
|
||||
# Ignore Android generated files and folders
|
||||
templates/android_project/output
|
||||
|
||||
# Ignore GNU global tags
|
||||
GPATH
|
||||
GRTAGS
|
||||
GTAGS
|
||||
.vs
|
||||
|
88
BINDINGS.md
@@ -1,29 +1,71 @@
|
||||
### raylib bindings
|
||||
## raylib bindings
|
||||
|
||||
Some people ported raylib to other languages in form of bindings or wrappers to the library, here is a list with the ones I'm aware of:
|
||||
|
||||
- [raylib](https://github.com/raysan5/raylib) : raylib **C/C++** version (default)
|
||||
- [raylib-lua](https://github.com/raysan5/raylib-lua) : raylib **Lua** binding
|
||||
- [raylib-lua-ffi](https://github.com/raysan5/raylib/issues/693) : raylib **Lua** ffi binding
|
||||
- [raylib-go](https://github.com/gen2brain/raylib-go) : raylib **Go** binding
|
||||
- [raylib-Nim](https://gitlab.com/define-private-public/raylib-Nim) : raylib **Nim** binding
|
||||
- [raylib-cr](https://github.com/AregevDev/raylib-cr) : raylib **Crystal** binding
|
||||
- [cray](https://gitlab.com/Zatherz/cray) - raylib **Crystal** binding
|
||||
- [Graphics::Raylib](https://metacpan.org/pod/Graphics::Raylib) : raylib **Perl** wrapper
|
||||
- [raylib-pascal](https://github.com/drezgames/raylib-pascal) - raylib **Pascal** binding
|
||||
- [Raylib-cs](https://github.com/ChrisDill/Raylib-cs) : raylib **C#** binding
|
||||
- [RaylibSharp](https://github.com/TheLumaio/RaylibSharp) : raylib **C#** binding
|
||||
- [raylib-ruby-ffi](https://github.com/D3nX/raylib-ruby-ffi) : raylib **Ruby** binding
|
||||
- [raylib-rs](https://github.com/deltaphc/raylib-rs) : raylib **Rust** binding
|
||||
- [raylib-py](https://github.com/overdev/raylib-py) : raylib **Python** binding
|
||||
- [raylib-haskell](https://github.com/DevJac/raylib-haskell) : raylib **Haskell** binding
|
||||
- [raylib-java](https://github.com/XoanaIO/raylib-java) : raylib **Java** binding
|
||||
- [raylib-chaiscript](https://github.com/RobLoach/raylib-chaiscript) : raylib **ChaiScript** binding
|
||||
- [node-raylib](https://github.com/RobLoach/node-raylib) : **Node.js** raylib binding
|
||||
- [raylib-odin](https://github.com/kevinw/raylib-odin): **Odin** raylib binding
|
||||
- [raylib-factor](https://github.com/Silverbeard00/raylib-factor): **Factor** raylib binding
|
||||
- *[raylib COBOL Usage example](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib)*
|
||||
- *raylib flat-assembler Usage example*: not uploaded yet...
|
||||
| name | language | repo |
|
||||
|:------------------:|:--------------:|----------------------------------------------------------------------|
|
||||
| raylib | C | https://github.com/raysan5/raylib |
|
||||
| raylib-cpp | C++ | https://github.com/robloach/raylib-cpp |
|
||||
| Raylib-cs | C# | https://github.com/ChrisDill/Raylib-cs |
|
||||
| RaylibSharp | C# | https://github.com/TheLumaio/RaylibSharp |
|
||||
| RaylibFS | F# | https://github.com/dallinbeutler/RaylibFS |
|
||||
| raylib_d | D | https://github.com/0xFireball/raylib_d |
|
||||
| raylib-d | D | https://github.com/onroundit/raylib-d |
|
||||
| raylib-go | Go | https://github.com/gen2brain/raylib-go |
|
||||
| raylib-goplus | Go | https://github.com/Lachee/raylib-goplus |
|
||||
| raylib-rs | Rust | https://github.com/deltaphc/raylib-rs |
|
||||
| raylib-lua | Lua | https://github.com/raysan5/raylib-lua |
|
||||
| raylib-lua-ffi | Lua | https://github.com/raysan5/raylib/issues/693 |
|
||||
| raylib-lua-sol | Lua | https://github.com/RobLoach/raylib-lua-sol |
|
||||
| raylib-lua (raylua)| Lua | https://github.com/TSnake41/raylib-lua |
|
||||
| raylib-luamore | Lua | https://github.com/HDPLocust/raylib-luamore |
|
||||
| raylib-nelua | Nelua | https://github.com/Andre-LA/raylib-nelua-mirror |
|
||||
| raylib-Nim | Nim | https://gitlab.com/define-private-public/raylib-Nim |
|
||||
| raylib-nim | Nim | https://github.com/Skrylar/raylib-nim |
|
||||
| raylib-haskell | Haskell | https://github.com/DevJac/raylib-haskell |
|
||||
| raylib-cr | Crystal | https://github.com/AregevDev/raylib-cr |
|
||||
| cray | Crystal | https://gitlab.com/Zatherz/cray |
|
||||
| cray | Crystal | https://github.com/tapgg/cray |
|
||||
| raylib-pascal | Pascal | https://github.com/drezgames/raylib-pascal |
|
||||
| raylib-pas | Pascal | https://github.com/tazdij/raylib-pas |
|
||||
| Graphics-Raylib | Perl | https://github.com/athreef/Graphics-Raylib |
|
||||
| raylib-ruby-ffi | Ruby | https://github.com/D3nX/raylib-ruby-ffi |
|
||||
| raylib-ruby | Ruby | https://github.com/a0/raylib-ruby |
|
||||
| raylib-mruby | mruby | https://github.com/lihaochen910/raylib-mruby |
|
||||
| raylib-py | Python | https://github.com/overdev/raylib-py |
|
||||
| raylib-python-cffi | Python | https://github.com/electronstudio/raylib-python-cffi |
|
||||
| raylib-java | Java | https://github.com/XoanaIO/raylib-java |
|
||||
| node-raylib | Node.js | https://github.com/RobLoach/node-raylib |
|
||||
| QuickJS-raylib | QuickJS | https://github.com/sntg-p/QuickJS-raylib |
|
||||
| raylib-js | JavaScript | https://github.com/RobLoach/raylib-js |
|
||||
| raylib-chaiscript | ChaiScript | https://github.com/RobLoach/raylib-chaiscript |
|
||||
| raylib-squirrel | Squirrel | https://github.com/RobLoach/raylib-squirrel |
|
||||
| racket-raylib-2d | Racket | https://github.com/arvyy/racket-raylib-2d |
|
||||
| raylib-php | PHP | https://github.com/joseph-montanez/raylib-php |
|
||||
| raylib-php-ffi | PHP | https://github.com/oraoto/raylib-php-ffi |
|
||||
| raylib-phpcpp | PHP | https://github.com/oraoto/raylib-phpcpp |
|
||||
| raylib-factor | Factor | https://github.com/Silverbeard00/raylib-factor |
|
||||
| raylib-haxe | Haxe | https://github.com/ibilon/raylib-haxe |
|
||||
| ringraylib | Ring | https://github.com/ringpackages/ringraylib |
|
||||
| cl-raylib | Common Lisp | https://github.com/longlene/cl-raylib |
|
||||
| raylib-scm | Chicken Scheme | https://github.com/yashrk/raylib-scm |
|
||||
| raylib-chibi | Chibi-Scheme | https://github.com/VincentToups/raylib-chibi |
|
||||
| Euraylib | Euphoria | https://github.com/gAndy50/Euraylib |
|
||||
| raylib-wren | Wren | https://github.com/TSnake41/raylib-wren |
|
||||
| raylib-odin | Odin | https://github.com/kevinw/raylib-odin |
|
||||
| raylib-zig | Zig | https://github.com/G3bE/raylib-zig |
|
||||
| ray.zig | Zig | https://github.com/BitPuffin/zig-raylib-experiments |
|
||||
| raylib-Ada | Ada | https://github.com/mimo/raylib-Ada |
|
||||
| jaylib | Janet | https://github.com/janet-lang/jaylib |
|
||||
| raykit | Kit | https://github.com/Gamerfiend/raykit |
|
||||
| vraylib | V | https://github.com/MajorHard/vraylib |
|
||||
| ray.mod | BlitzMax | https://github.com/bmx-ng/ray.mod |
|
||||
| raylib-mosaic | Mosaic | https://github.com/pluckyporcupine/raylib-mosaic |
|
||||
| raylib-xdpw | XD Pascal | https://github.com/vtereshkov/raylib-xdpw |
|
||||
| raylib-carp | Carp | https://github.com/pluckyporcupine/raylib-carp |
|
||||
| raylib-fb | FreeBasic | https://github.com/IchMagBier/raylib-fb |
|
||||
| raylib-ats2 | ATS2 | https://github.com/mephistopheles-8/raylib-ats2 |
|
||||
| raylib.cbl | COBOL | *[code examples](https://github.com/Martinfx/Cobol/tree/master/OpenCobol/Games/raylib)* |
|
||||
|
||||
Missing some language? Check the [bindings not yet in this list](https://gist.github.com/raysan5/5764cc5b885183f523fce47f098f3d9b#bindings-not-yet-in-the-official-list) or create a new binding! :)
|
||||
|
||||
|
169
CHANGELOG
@@ -1,7 +1,174 @@
|
||||
changelog
|
||||
---------
|
||||
|
||||
Current Release: raylib 2.5.0 (31 May 2019)
|
||||
Current Release: raylib 3.0.0 (01 April 2020)
|
||||
|
||||
-----------------------------------------------
|
||||
Release: raylib 3.0 (01 April 2020)
|
||||
-----------------------------------------------
|
||||
KEY CHANGES:
|
||||
- Global context states used on all modules.
|
||||
- Custom memory allocators for all modules and dependencies.
|
||||
- Centralized file access system and memory data loading.
|
||||
- Structures reviewed to reduce size and always be used as pass-by-value.
|
||||
- Tracelog messages completely reviewed and categorized.
|
||||
- raudio module reviewed to accomodate new Music struct and new miniaudio.
|
||||
- text module reviewed to improve fonts generation and text management functions.
|
||||
- Multiple new examples added and categorized examples table.
|
||||
- GitHub Actions CI implemented for Windows, Linux and macOS.
|
||||
|
||||
Detailed changes:
|
||||
[build] ADDED: VS2017.ANGLE project, by @msmshazan
|
||||
[build] ADDED: VS2017 project support for x64 platform configuration
|
||||
[build] ADDED: Makefile for Android building on macOS, by @Yunoinsky
|
||||
[build] ADDED: Makefile for Android building on Linux, by @pamarcos
|
||||
[build] REMOVED: VS2015 project
|
||||
[build] REVIEWED: VSCode project
|
||||
[build] REVIEWED: Makefile build system
|
||||
[build] REVIEWED: Android building, by @NimbusFox
|
||||
[build] REVIEWED: Compilation with CLion IDE, by @Rover656
|
||||
[build] REVIEWED: Generation of web examples, by @pamarcos
|
||||
[build] REVIEWED: Makefiles path to 'shell.html', by @niorad
|
||||
[build] REVIEWED: VS2017 64bit compilation issues, by @spec-chum
|
||||
[build] REVIEWED: Multiple fixes on projects building, by @ChrisDill, @JuDelCo, @electronstudio
|
||||
[core] ADDED: Support touch/mouse indistinctly
|
||||
[core] ADDED: FLAG_WINDOW_ALWAYS_RUN to avoid pause on minimize
|
||||
[core] ADDED: Config flag SUPPORT_HALFBUSY_WAIT_LOOP
|
||||
[core] ADDED: RPI mouse cursor point support on native mode
|
||||
[core] ADDED: GetWorldToScreen2D()- Get screen space position for a 2d camera world space position, by @arvyy
|
||||
[core] ADDED: GetScreenToWorld2D() - Get world space position for a 2d camera screen space position, by @arvyy
|
||||
[core] ADDED: GetWorldToScreenEx() - Get size position for a 3d world space position
|
||||
[core] ADDED: DirectoryExists() - Check if a directory path exists
|
||||
[core] ADDED: GetPrevDirectoryPath() - Get previous directory path for a given path
|
||||
[core] ADDED: CompressData() - Compress data (DEFLATE algorythm)
|
||||
[core] ADDED: DecompressData() - Decompress data (DEFLATE algorythm)
|
||||
[core] ADDED: GetWindowPosition() - Get window position XY on monitor
|
||||
[core] ADDED: LoadFileData() - Load file data as byte array (read)
|
||||
[core] ADDED: SaveFileData() - Save data to file from byte array (write)
|
||||
[core] ADDED: LoadFileText() - Load text data from file (read), returns a '\0' terminated string
|
||||
[core] ADDED: SaveFileText() - Save text data to file (write), string must be '\0' terminated
|
||||
[core] REMOVED: Show raylib logo at initialization
|
||||
[core] REVIEWED: GetFileName(), security checks
|
||||
[core] REVIEWED: LoadStorageValue(), by @danimartin82
|
||||
[core] REVIEWED: SaveStorageValue(), by @danimartin82
|
||||
[core] REVIEWED: IsMouseButtonReleased(), when press/release events come too fast, by @oswjk
|
||||
[core] REVIEWED: SetWindowMonitor(), by @DropsOfSerenity
|
||||
[core] REVIEWED: IsFileExtension() to be case-insensitive
|
||||
[core] REVIEWED: IsFileExtension() when checking no-extension files
|
||||
[core] REVIEWED: Default font scale filter for HighDPI mode
|
||||
[core] REVIEWED: Touch input scaling for PLATFORM_WEB
|
||||
[core] REVIEWED: RPI input system, by @DarkElvenAngel
|
||||
[core] REVIEWED: RPI input threads issues
|
||||
[core] REVIEWED: OpenGL extensions loading and freeing
|
||||
[core] REVIEWED: GetDirectoryPath()
|
||||
[core] REVIEWED: Camera2D behavior, by @arvyy
|
||||
[core] REVIEWED: OpenGL ES 2.0 extensions check
|
||||
[rlgl] ADDED: Flags to allow frustrum culling near/far distance configuration at compile time
|
||||
[rlgl] ADDED: Flags to sllow MAX_BATCH_BUFFERING config at compile time
|
||||
[rlgl] ADDED: GetMatrixProjection(), by @chriscamacho
|
||||
[rlgl] ADDED: rlUpdateMeshAt() - Update vertex or index data on GPU, at index, by @brankoku
|
||||
[rlgl] REVIEWED: Vertex padding not zeroed for quads, by @kawa-yoiko
|
||||
[rlgl] REVIEWED: Read texture data as RGBA from FBO on GLES 2.0
|
||||
[rlgl] REVIEWED: LoadShaderCode() for const correctness, by @heretique
|
||||
[rlgl] REVIEWED: rlLoadTexture()
|
||||
[rlgl] REVIEWED: rlReadTexturePixels()
|
||||
[rlgl] REVIEWED: rlUpdateMesh() to supports updating indices, by @brankoku
|
||||
[rlgl] REVIEWED: GenTextureCubemap(), renamed parameters for consistency
|
||||
[rlgl] REVIEWED: HDR pixels loading
|
||||
[raymath] ADDED: MatrixRotateXYZ(), by @chriscamacho
|
||||
[raymath] RENAMED: Vector3Multiply() to Vector3Scale()
|
||||
[camera] REVIEWED: Free camera pitch, by @chriscamacho
|
||||
[camera] REVIEWED: Camera not working properly at z-align, by @Ushio
|
||||
[shapes] ADDED: DrawTriangleStrip() - Draw a triangle strip defined by points
|
||||
[shapes] ADDED: DrawEllipse() - Draw ellipse
|
||||
[shapes] ADDED: DrawEllipseLines() - Draw ellipse outline
|
||||
[shapes] ADDED: DrawPolyLines() - Draw a polygon outline of n sides
|
||||
[shapes] REVIEWED: DrawPoly() shape rendering, by @AlexHCC
|
||||
[textures] ADDED: LoadAnimatedGIF() - Load animated GIF file
|
||||
[textures] ADDED: GetImageAlphaBorder() - Get image alpha border rectangle
|
||||
[textures] ADDED: ImageFromImage() - Create an image from another image piece
|
||||
[textures] ADDED: ImageClearBackground(), by @iamsouravgupta
|
||||
[textures] ADDED: ImageDrawPixel(), by @iamsouravgupta
|
||||
[textures] ADDED: ImageDrawCircle(), by @iamsouravgupta
|
||||
[textures] ADDED: ImageDrawLineEx(), by @iamsouravgupta
|
||||
[textures] ADDED: ImageDrawPixelV(), by @RobLoach
|
||||
[textures] ADDED: ImageDrawCircleV(), by @RobLoach
|
||||
[textures] ADDED: ImageDrawLineV(), by @RobLoach
|
||||
[textures] ADDED: ImageDrawRectangleV(), by @RobLoach
|
||||
[textures] ADDED: ImageDrawRectangleRec(), by @RobLoach
|
||||
[textures] REVIEWED: ImageDrawPixel(), by @RobLoach
|
||||
[textures] REVIEWED: ImageDrawLine(), by @RobLoach
|
||||
[textures] REVIEWED: ImageDrawCircle(), by @RobLoach
|
||||
[textures] REVIEWED: ImageDrawRectangle(), by @RobLoach
|
||||
[textures] REVIEWED: ImageDraw(), now it supports color tint parameter
|
||||
[textures] REVIEWED: ImageResizeCanvas()
|
||||
[textures] REVIEWED: ImageCrop() with security checks
|
||||
[textures] REVIEWED: ImageAlphaMask()
|
||||
[textures] REVIEWED: ImageDrawRectangleLines()
|
||||
[textures] REVIEWED: GetImageData()
|
||||
[text] ADDED: TextCopy() - Copy one string to another, returns bytes copied
|
||||
[text] ADDED: GetCodepoints() - Get all codepoints in a string
|
||||
[text] ADDED: CodepointToUtf8() - Encode codepoint into utf8 text
|
||||
[text] ADDED: DrawTextCodepoint() - Draw one character (codepoint)
|
||||
[text] RENAMED: LoadDefaultFont() -> LoadFontDefault()
|
||||
[text] RENAMED: TextCountCodepoints() -> GetCodepointsCount()
|
||||
[text] REVIEWED: TextFormat(), to support caching, by @brankoku
|
||||
[text] REVIEWED: LoadFontData(), generate empty image for space character
|
||||
[text] REVIEWED: TextSplit()
|
||||
[text] REVIEWED: TextToInteger()
|
||||
[text] REVIEWED: GetNextCodepoint(), renamed parameters for clarity
|
||||
[text] REVIEWED: GenImageFontAtlas(), improved atlas size computing
|
||||
[text] REDESIGNED: struct Font, character rectangles have been moved out from CharInfo to Font
|
||||
[text] REDESIGNED: struct CharInfo, now includes directly an Image of the glyph
|
||||
[text] REDESIGNED: GenImageFontAtlas(), additional recs parameter added
|
||||
[text] REDESIGNED: ImageTextEx(), to avoid font retrieval from GPU
|
||||
[models] ADDED: Support rlPushMatrix() and rlPopMatrix() on mesh drawing
|
||||
[models] ADDED: DrawPoint3D() - Draw a point in 3D space, actually a small line, by @ProfJski
|
||||
[models] ADDED: Multi texture support for materials in GLTF format, by @Gamerfiend, @chriscamacho
|
||||
[models] REVIEWED: LoadGLTF(), fixed memory leak, by @jubalh
|
||||
[models] REVIEWED: LoadIQM(), support multiple animations loading, by @culacant
|
||||
[models] REVIEWED: GetCollisionRayModel(), to avoid pointers
|
||||
[models] REVIEWED: CheckCollisionRay*(), parameters renamed
|
||||
[models] REVIEWED: UnloadMesh(), to avoid pointers
|
||||
[models] REVIEWED: LoadModel(), memory initialization
|
||||
[models] REVIEWED: UpdateModelAnimation(), added security checks
|
||||
[models] REVIEWED: Multiple fixes on models loading, by @jubalh
|
||||
[models] REVIEWED: Normals updated when using animated meshes, by @@las3rlars
|
||||
[models] REVIEWED: Compilation when the SUPPORT_MESH_GENERATION not set, by @@Elkantor
|
||||
[raudio] ADDED: Multi-channel audio playing, by @chriscamacho
|
||||
[raudio] REMOVED: LoadWaveEx()
|
||||
[raudio] RENAMED: IsAudioBufferProcessed() to IsAudioStreamProcessed()
|
||||
[raudio] REVIEWED: Ensure .xm playback starts in the right place, by @illegalinstruction
|
||||
[raudio] REVIEWED: Fix short non-looping sounds, by @jbosh
|
||||
[raudio] REVIEWED: Modules playing time to full length
|
||||
[raudio] REDESIGNED: Replaced Music pointer by struct
|
||||
[raudio] REDESIGNED: Removed sampleLeft from Music struct
|
||||
[examples] ADDED: core_scissor_test, by @ChrisDill
|
||||
[examples] ADDED: core_2d_camera_platformer, by @arvyy
|
||||
[examples] ADDED: textures_mouse_painting, by @ChrisDill
|
||||
[examples] ADDED: models_waving_cubes, by @codecat
|
||||
[examples] ADDED: models_solar_system, by @aldrinmartoq
|
||||
[examples] ADDED: shaders_fog, by @chriscamacho
|
||||
[examples] ADDED: shaders_texture_waves, by @Anata
|
||||
[examples] ADDED: shaders_basic_lighting, by @chriscamacho
|
||||
[examples] ADDED: shaders_simple_mask, by @chriscamacho
|
||||
[examples] ADDED: audio_multichannel_sound, by @chriscamacho
|
||||
[examples] ADDED: shaders_spotlight, by @chriscamacho
|
||||
[examples] RENAMED: text_sprite_font > text_font_spritefont
|
||||
[examples] RENAMED: text_ttf_loading > text_font_filters
|
||||
[examples] RENAMED: text_bmfont_ttf > text_font_loading
|
||||
[examples] REMOVED: models_obj_viewer
|
||||
[examples] REMOVED: models_solar_system
|
||||
[examples] REVIEWED: models_obj_loading > models_loading
|
||||
[examples] REVIEWED: models_materials_pbr, shader issues
|
||||
[examples] REVIEWED: core_window_letterbox, detailed explanation, by @jotac0
|
||||
[examples] REVIEWED: core_window_letterbox, virtual mouse, by @anatagawa
|
||||
[games] ADDED: GGJ2020 game - RE-PAIR
|
||||
[*] Misc fixes and tweaks, by @yaram, @oraoto, @zatherz, @piecedigital, @Shylie
|
||||
[*] Update ALL supported projects (Notepad++, VS2017)
|
||||
[*] Update ALL external libraries to latest versions (29.Jan.2020)
|
||||
[*] Update ALL examples and games
|
||||
[*] Update BINDINGS list
|
||||
|
||||
-----------------------------------------------
|
||||
Release: raylib 2.5 (May 2019)
|
||||
|
@@ -1,46 +0,0 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at ray@raylib.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
@@ -6,26 +6,26 @@ Do you enjoy raylib and want to contribute? Nice! You can help with the followin
|
||||
|
||||
- C programming - Can you write/review/test/improve the code?
|
||||
- Documentation/Tutorials/Example - Can you write some tutorial/example?
|
||||
- Web Development - Can you help [with the web](https://github.com/raysan5/raylib.com)?
|
||||
- Porting to other platforms - Can you port and compile raylib on another systems?
|
||||
- Testing - Can you find some bugs on raylib?
|
||||
- Porting to other platforms - Can you port and compile raylib on other systems?
|
||||
- Web Development - Can you help [with the website](https://github.com/raysan5/raylib.com)?
|
||||
- Testing - Can you find some bugs in raylib?
|
||||
|
||||
This document contains a set of guidelines to contribute to the project. These are mostly guidelines, not rules.
|
||||
Use your best judgement, and feel free to propose changes to this document in a pull-request.
|
||||
Use your best judgement, and feel free to propose changes to this document in a pull request.
|
||||
|
||||
### raylib philosophy
|
||||
|
||||
- raylib is a tool to enjoy videogames programming, every single function in raylib should be a tutorial on itself.
|
||||
- raylib is SIMPLE and EASY-TO-USE, I tried to keep it compact with a small set of functions, if a function is too complex or is not clearly useful, better not to include it.
|
||||
- raylib is open source and free; educators and institutions can use this tool to TEACH videogames programming completely by free.
|
||||
- raylib is collaborative; contribution of tutorials / code-examples / bugs-solving / code-comments are highly appreciated.
|
||||
- raylib's license (and its external libs respective licenses) allow using it for commercial products.
|
||||
- raylib is **SIMPLE** and **EASY-TO-USE**, I tried to keep it compact with a small set of functions, if a function is too complex or is not clearly useful, better not including it.
|
||||
- raylib is open source and free; educators and institutions can use this tool to **TEACH** videogames programming completely for free.
|
||||
- raylib is collaborative; contribution of tutorials / code examples / bug fixes / code comments are highly appreciated.
|
||||
- raylib's license (and its external libs respective licenses) allow using it on commercial projects.
|
||||
|
||||
### Some interesting reads to start with
|
||||
|
||||
- [raylib history](HISTORY.md)
|
||||
- [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture)
|
||||
- [raylib license](LICENSE.md)
|
||||
- [raylib license](LICENSE)
|
||||
- [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.
|
||||
@@ -36,13 +36,13 @@ Feel free to review it if required, just take care not to break something.
|
||||
Despite being written in C, raylib does not follow the standard Hungarian notation for C,
|
||||
it [follows Pascal-case/camel-case notation](https://github.com/raysan5/raylib/wiki/raylib-coding-conventions),
|
||||
more common on C# language. All code formatting decisions have been carefully taken
|
||||
to make it easier for students to read, write and understand code.
|
||||
to make it easier for students/users to read, write and understand code.
|
||||
|
||||
Source code is extensively commented for that purpose, raylib primary learning method is:
|
||||
|
||||
> learn by reading code and examples
|
||||
|
||||
For detailed information on building raylib and examples, please check [raylib Wiki](https://github.com/raysan5/raylib/wiki).
|
||||
For detailed information on building raylib and examples, please see [raylib Wiki](https://github.com/raysan5/raylib/wiki).
|
||||
|
||||
### Opening new Issues
|
||||
|
||||
@@ -53,13 +53,13 @@ To open new issue for raylib (bug, enhancement, discussion...), just try to foll
|
||||
title and clear description, as much relevant information as possible, and a code sample demonstrating the unexpected behavior.
|
||||
- If applies, attach some screenshot of the issue and a .zip file with the code sample and required resources.
|
||||
- On issue description, add a brackets tag about the raylib module that relates to this issue.
|
||||
If don't know the module, just report the issue, I will review it.
|
||||
If don't know which module, just report the issue, I will review it.
|
||||
- You can check other issues to see how is being done!
|
||||
|
||||
### Sending a Pull-Request
|
||||
|
||||
- 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.
|
||||
- Don't send big pull requests (lots of changelists), they are difficult to review. It's better to send small pull requests, 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
|
||||
if you cannot test all the platforms.
|
||||
|
||||
@@ -107,15 +107,13 @@ contributing (in some way or another) to make the raylib project better. Huge th
|
||||
- [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 his work on Suse Linux package... and multiple fixes!
|
||||
- [Wilhem Barbier](https://github.com/nounoursheureux) for adding Image generation functions and some fixes.
|
||||
- [Wilhem Barbier](https://github.com/nounoursheureux) for adding Image generation functions, shaders work 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 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 CI support for raylib (Travis and AppVeyor) and great improvements on build system.
|
||||
- [SamNChiet](https://github.com/SamNChiet) for a greatly improved UWP input implementation.
|
||||
- [David Reid](https://github.com/mackron) for a complete review of audio module to support his amazing miniaudio library.
|
||||
- [Kai](https://github.com/questor) for multiple code reviews and improvements.
|
||||
- [RDR8](https://github.com/RDR8) for improvements 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 an amazing work on IQM animated models support.
|
||||
@@ -132,5 +130,7 @@ contributing (in some way or another) to make the raylib project better. Huge th
|
||||
- [Anata](https://github.com/anatagawa) for creating amazing examples and contributing with them
|
||||
- [Narice](https://github.com/narice) made easings.h includable as standalone header
|
||||
- [Eric J.](https://github.com/ProfJski) for shaders_eratosthenes example contribution
|
||||
- [PompPenguin](https://github.com/PompPenguin) for reviewing 3rd person camera
|
||||
- [Mohamed Shazan](https://github.com/msmshazan) for adding support for ANGLE graphics backend
|
||||
|
||||
Please, if I forget someone in this list, excuse me and send a PR!
|
||||
Please, if I forget someone in this list, excuse me and send me a PR!
|
||||
|
149
HISTORY.md
@@ -1,19 +1,19 @@
|
||||

|
||||
|
||||
history
|
||||
-------
|
||||
introduction
|
||||
------------
|
||||
|
||||
I've developed videogames since 2006 and in 2012 I started teaching videogames development to young people with artistic profile, most of them had never written a single line of code.
|
||||
I started developing videogames in 2006 and some years later I started teaching videogames development to young people with artistic profile, most of students had never written a single line of code.
|
||||
|
||||
I started with C language basis and, after searching for the most simple and easy-to-use library to teach videogames programming, I found WinBGI; it was great and it worked very well with students, in just a couple of weeks that people that had never written a single line of code were able to program (and understand) a simple PONG and some of them even a BREAKOUT!
|
||||
I decided to start with C language basis and, after searching for the most simple and easy-to-use library to teach videogames programming, I found [WinBGI](http://www.codecutter.net/tools/winbgim/); it was great and it worked very well with students, in just a couple of weeks, those students that had never written a single line of code were able to program (and understand) a simple PONG game, some of them even a BREAKOUT!
|
||||
|
||||
But WinBGI was not the clearer and most organized lib. There were a lot of things I found confusing and some function names were not clear enough for most of the students; not to mention points like no transparencies support or no hardware acceleration.
|
||||
But WinBGI was not the clearer and most organized library for my taste. There were lots of things I found confusing and some function names were not clear enough for most of the students; not to mention the lack of transparencies support and no hardware acceleration.
|
||||
|
||||
So, I decided to create my own library, hardware accelerated, clear function names, quite organized, well structured, plain C coding and, the most important, primarily intended to learn videogames programming.
|
||||
|
||||
Most of my videogames coding experience was in C# and XNA and I really love it (in fact, my students learn C# after C), so, I decided to use C# language notation and XNA naming conventions. That way, students can jump from raylib to XNA, MonoGame or similar libs extremely easily.
|
||||
My previous videogames development experience was mostly in C# and [XNA](https://en.wikipedia.org/wiki/Microsoft_XNA) and I really loved it, so, I decided to use C# language style notation and XNA naming conventions. That way, students were able to move from raylib to XNA, MonoGame or similar libs extremely easily.
|
||||
|
||||
raylib started as a weekend project and after three months of hard work, raylib 1.0 was published on November 2013.
|
||||
raylib started as a weekend project and after three months of hard work, **raylib 1.0 was published on November 2013**.
|
||||
|
||||
Enjoy it.
|
||||
|
||||
@@ -22,9 +22,9 @@ notes on raylib 1.1
|
||||
|
||||
On April 2014, after 6 month of first raylib release, raylib 1.1 has been released. This new version presents a complete internal redesign of the library to support OpenGL 1.1, OpenGL 3.3+ and OpenGL ES 2.0.
|
||||
|
||||
A new module named [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) has been added to the library. This new module translates raylib-OpenGL-style immediate mode functions (i.e. rlVertex3f(), rlBegin(), ...) to different versions of OpenGL (1.1, 3.3+, ES2), selectable by one define.
|
||||
- A new module named [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) has been added to the library. This new module translates raylib-OpenGL-style immediate mode functions (i.e. rlVertex3f(), rlBegin(), ...) to different versions of OpenGL (1.1, 3.3+, ES2), selectable by one define.
|
||||
|
||||
[rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) also comes with a second new module named [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h), which includes a bunch of useful functions for 3d-math with vectors, matrices and quaternions.
|
||||
- [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) also comes with a second new module named [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h), which includes a bunch of useful functions for 3d-math with vectors, matrices and quaternions.
|
||||
|
||||
Some other big changes of this new version have been the support for OGG files loading and stream playing, and the support of DDS texture files (compressed and uncompressed) along with mipmaps support.
|
||||
|
||||
@@ -37,9 +37,9 @@ On September 2014, after 5 month of raylib 1.1 release, it comes raylib 1.2. Aga
|
||||
|
||||
It's been some month of really hard work to accomodate raylib to those new platforms while keeping it easy for the users. On Android, raylib manages internally the activity cicle, as well as the inputs; on Raspberry Pi, a complete raw input system has been written from scratch.
|
||||
|
||||
A new display initialization system has been created to support multiple resolutions, adding black bars if required; user only defines desired screen size and it gets properly displayed.
|
||||
- A new display initialization system has been created to support multiple resolutions, adding black bars if required; user only defines desired screen size and it gets properly displayed.
|
||||
|
||||
Now raylib can easily deploy games to Android devices and Raspberry Pi (console mode).
|
||||
- Now raylib can easily deploy games to Android devices and Raspberry Pi (console mode).
|
||||
|
||||
Lots of code changes and lot of testing have concluded in this amazing new raylib 1.2.
|
||||
|
||||
@@ -50,15 +50,15 @@ notes on raylib 1.3
|
||||
|
||||
On September 2015, after 1 year of raylib 1.2 release, arrives raylib 1.3. This version adds shaders functionality, improves tremendously textures module and also provides some new modules (camera system, gestures system, immediate-mode gui).
|
||||
|
||||
Shaders support is the biggest addition to raylib 1.3, with support for easy shaders loading and use. Loaded shaders can be attached to 3d models or used as fullscreen postrocessing effects. A bunch of postprocessing shaders are also included in this release, check raylib/shaders folder.
|
||||
- Shaders support is the biggest addition to raylib 1.3, with support for easy shaders loading and use. Loaded shaders can be attached to 3d models or used as fullscreen postrocessing effects. A bunch of postprocessing shaders are also included 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.
|
||||
- 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/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).
|
||||
- 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/master/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/master/src/raygui.h), the new 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.
|
||||
- [raygui](https://github.com/raysan5/raylib/blob/master/src/raygui.h), the new 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.
|
||||
|
||||
@@ -69,17 +69,17 @@ 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/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.
|
||||
- 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.
|
||||
- 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/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.
|
||||
- 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/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.
|
||||
- [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/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.
|
||||
- [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`). Gamepad support has also been added (experimental).
|
||||
- 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`). 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/master/src/easings.h) module has also been added for values animation.
|
||||
@@ -94,17 +94,17 @@ 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/master/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.
|
||||
- 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.
|
||||
|
||||
New lighting system: added support for up to 8 configurable lights and 3 light types: **point**, **directional** and **spot** lights. Just create a light, configure its parameters and raylib manages render internally for every 3d object using standard material.
|
||||
- New lighting system: added support for up to 8 configurable lights and 3 light types: **point**, **directional** and **spot** lights. Just create a light, configure its parameters and raylib manages render internally for every 3d object using standard material.
|
||||
|
||||
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.
|
||||
- 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/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.
|
||||
- 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.
|
||||
- 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/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.
|
||||
|
||||
@@ -119,17 +119,17 @@ notes on raylib 1.6
|
||||
|
||||
On November 2016, only 4 months after raylib 1.5, arrives raylib 1.6. This new version represents another big review of the library and includes some interesting additions. This version conmmemorates raylib 3rd anniversary (raylib 1.0 was published on November 2013) and it is a stepping stone for raylib future. raylib roadmap has been reviewed and redefined to focus on its primary objective: create a simple and easy-to-use library to learn videogames programming. Some of the new features:
|
||||
|
||||
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.
|
||||
- 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/master/src/raudio.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!
|
||||
- Completely redesigned [audio module](https://github.com/raysan5/raylib/blob/master/src/raudio.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!
|
||||
- [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!
|
||||
|
||||
Camera and gestures modules have been reviewed, highly simplified and ported to single-file header-only libraries for easier portability and usage flexibility. Consequently, camera system usage has been simplified in all examples.
|
||||
- Camera and gestures modules have been reviewed, highly simplified and ported to single-file header-only libraries for easier portability and usage flexibility. Consequently, camera system usage has been simplified in all examples.
|
||||
|
||||
Improved Gamepad support on Windows and Raspberry Pi with the addition of new functions for custom gamepad configurations but supporting by default PS3 and Xbox-based gamepads.
|
||||
- Improved Gamepad support on Windows and Raspberry Pi with the addition of new functions for custom gamepad configurations but supporting by default PS3 and Xbox-based gamepads.
|
||||
|
||||
Improved textures and text functionality, adding new functions for texture filtering control and better TTF/AngelCode fonts loading and generation support.
|
||||
- Improved textures and text functionality, adding new functions for texture filtering control and better TTF/AngelCode fonts loading and generation support.
|
||||
|
||||
Build system improvement. Added support for raylib dynamic library generation (raylib.dll) for users that prefer dynamic library linking. Also thinking on advance users, it has been added pre-configured [Visual Studio C++ 2015 solution](https://github.com/raysan5/raylib/tree/master/project/vs2015) with raylib project and C/C++ examples for users that prefer that professional IDE and compiler.
|
||||
|
||||
@@ -140,15 +140,15 @@ notes on raylib 1.7
|
||||
|
||||
On May 2017, around 6 month after raylib 1.6, comes another raylib instalment, raylib 1.7. This time library has been improved a lot in terms of consistency and cleanness. As stated in [this patreon article](https://www.patreon.com/posts/raylib-future-7501034), this new raylib version has focused efforts in becoming more simple and easy-to-use to learn videogames programming. Some highlights of this new version are:
|
||||
|
||||
More than 30 new functions added to the library, functions to control Window, utils to work with filenames and extensions, functions to draw lines with custom thick, mesh loading, functions for 3d ray collisions detailed detection, funtions for VR simulation and much more... Just check [CHANGELOG](CHANGELOG) for a detailed list of additions!
|
||||
- More than 30 new functions added to the library, functions to control Window, utils to work with filenames and extensions, functions to draw lines with custom thick, mesh loading, functions for 3d ray collisions detailed detection, funtions for VR simulation and much more... Just check [CHANGELOG](CHANGELOG) for a detailed list of additions!
|
||||
|
||||
Support of [configuration flags](https://github.com/raysan5/raylib/issues/200) on every raylib module. Advance users can customize raylib just choosing desired features, defining some configuration flags on modules compilation. That way users can control library size and available functionality.
|
||||
- Support of [configuration flags](https://github.com/raysan5/raylib/issues/200) on every raylib module. Advance users can customize raylib just choosing desired features, defining some configuration flags on modules compilation. That way users can control library size and available functionality.
|
||||
|
||||
Improved [build system](https://github.com/raysan5/raylib/blob/master/src/Makefile) for all supported platforms (Windows, Linux, OSX, RPI, Android, HTML5) with a unique Makefile to compile sources. Added support for Android compilation with a custom standalone toolchain and also multiple build compliation flags.
|
||||
- Improved [build system](https://github.com/raysan5/raylib/blob/master/src/Makefile) for all supported platforms (Windows, Linux, OSX, RPI, Android, HTML5) with a unique Makefile to compile sources. Added support for Android compilation with a custom standalone toolchain and also multiple build compliation flags.
|
||||
|
||||
New [examples](http://www.raylib.com/examples.html) and [sample games](http://www.raylib.com/games.html) added. All samples material has been reviewed, removing useless examples and adding more comprehensive ones; all material has been ported to latest raylib version and tested in multiple platforms. Examples folder structure has been improved and also build systems.
|
||||
- New [examples](http://www.raylib.com/examples.html) and [sample games](http://www.raylib.com/games.html) added. All samples material has been reviewed, removing useless examples and adding more comprehensive ones; all material has been ported to latest raylib version and tested in multiple platforms. Examples folder structure has been improved and also build systems.
|
||||
|
||||
Improved library consistency and organization in general. Functions and parameters have been renamed, some parts of the library have been cleaned and simplyfied, some functions has been moved to examples (lighting, Oculus Rift CV1 support) towards a more generic library implementation. Lots of hours have been invested in this process...
|
||||
- Improved library consistency and organization in general. Functions and parameters have been renamed, some parts of the library have been cleaned and simplyfied, some functions has been moved to examples (lighting, Oculus Rift CV1 support) towards a more generic library implementation. Lots of hours have been invested in this process...
|
||||
|
||||
Some other features: Gamepad support on HTML5, RPI touch screen support, 32bit audio support, frames timing improvements, public log system, rres file format support, automatic GIF recording...
|
||||
|
||||
@@ -159,17 +159,17 @@ 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/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.
|
||||
- [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/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.
|
||||
- [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/master/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/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.
|
||||
- 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/master/src/rlgl.h) 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.
|
||||
- [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) 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/master/src/raymath.h) 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/raymath.h) 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).
|
||||
|
||||
@@ -182,17 +182,17 @@ It's been 9 month since last raylib version was published, a lots of things have
|
||||
|
||||
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 required but only the strictly platform-dependant ones, the ones that come installed with the OS. So, raylib becomes a self-contained platform-independent games development library.
|
||||
- **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 required but only the strictly platform-dependant ones, the ones that come installed with the OS. So, raylib becomes a self-contained platform-independent games development library.
|
||||
|
||||
**Full redesign of audio module to use the amazing miniaudio library**, along with external dependencies removal, OpenAL library has been replaced by [miniaudio](https://github.com/dr-soft/miniaudio), this brand new library offers automatic dynamic linking with default OS audio systems. Undoubtly, the perfect low-level companion for raylib audio module!
|
||||
- **Full redesign of audio module to use the amazing miniaudio library**, along with external dependencies removal, OpenAL library has been replaced by [miniaudio](https://github.com/dr-soft/miniaudio), 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. Consequently, raylib GitHub develop branch has been 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!
|
||||
- **Support for continuous integration building*** through AppVeyor and Travis CI. Consequently, raylib GitHub develop branch has been 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!
|
||||
- **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!
|
||||
- **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!
|
||||
- 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).
|
||||
|
||||
@@ -203,25 +203,54 @@ notes on raylib 2.5
|
||||
|
||||
After almost one years since latest raylib installment, here it is **raylib 2.5**. A lot of work has been put on this new version and consequently I decided to bump versioning several digits. The complete list of changes and additions is humungous, details can be found in the [CHANGELOG](CHANGELOG), and here it is a short recap with the highlight improvements.
|
||||
|
||||
New **window management and filesystem functions** to query monitor information, deal with clipboard, check directory files info and even launch a URL with default system web browser. Experimental **High-DPI monitor support** has also been added through a compile flag.
|
||||
- New **window management and file system functions** to query monitor information, deal with clipboard, check directory files info and even launch a URL with default system web browser. Experimental **High-DPI monitor support** has also been added through a compile flag.
|
||||
|
||||
**Redesigned Gamepad mechanism**, now generic for all platforms and gamepads, no more specific gamepad configurations.
|
||||
- **Redesigned Gamepad mechanism**, now generic for all platforms and gamepads, no more specific gamepad configurations.
|
||||
**Redesigned UWP input system**, now raylib supports UWP seamlessly, previous implementation required a custom input system implemented in user code.
|
||||
|
||||
`rlgl` module has been redesigned to **support a unique buffer for shapes drawing batching**, including LINES, TRIANGLES, QUADS in the same indexed buffer, also added support for multi-buffering if required. Additionally, `rlPushMatrix()`/`rlPopMatrix()` functionality has been reviewed to behave exactly like OpenGL 1.1, `models_rlgl_solar_system` example has been added to illustrate this behaviour.
|
||||
- `rlgl` module has been redesigned to **support a unique buffer for shapes drawing batching**, including LINES, TRIANGLES, QUADS in the same indexed buffer, also added support for multi-buffering if required. Additionally, `rlPushMatrix()`/`rlPopMatrix()` functionality has been reviewed to behave exactly like OpenGL 1.1, `models_rlgl_solar_system` example has been added to illustrate this behaviour.
|
||||
|
||||
**VR simulator** has been reviewed to **allow custom configuration of Head-Mounted-Device parameters and distortion shader**, `core_vr_simulator` has been properly adapted to showcase this new functionality, now the VR simulator is a generic configurable stereo rendering system that allows any VR device simulation with just a few lines of code or even dynamic tweaking of HMD parameters.
|
||||
- **VR simulator** has been reviewed to **allow custom configuration of Head-Mounted-Device parameters and distortion shader**, `core_vr_simulator` has been properly adapted to showcase this new functionality, now the VR simulator is a generic configurable stereo rendering system that allows any VR device simulation with just a few lines of code or even dynamic tweaking of HMD parameters.
|
||||
|
||||
Support for **Unicode text drawing**; now raylib processes UTF8 strings on drawing, supporting Unicode codepoints, allowing rendering mostly any existent language (as long as the font with the glyphs is provided). An amazing example showing this feature has also been added: `text_unicode`.
|
||||
- Support for **Unicode text drawing**; now raylib processes UTF8 strings on drawing, supporting Unicode codepoints, allowing rendering mostly any existent language (as long as the font with the glyphs is provided). An amazing example showing this feature has also been added: `text_unicode`.
|
||||
|
||||
Brand **new text management API**, with the addition of multiple functions to deal with string data, including functionality like replace, insert, join, split, append, to uppercase, to lower... Note that most of those functions are intended for text management on rendering, using pre-loaded internal buffers, avoiding new memory allocation that user should free manually.
|
||||
- Brand **new text management API**, with the addition of multiple functions to deal with string data, including functionality like replace, insert, join, split, append, to uppercase, to lower... Note that most of those functions are intended for text management on rendering, using pre-loaded internal buffers, avoiding new memory allocation that user should free manually.
|
||||
|
||||
Multiple **new shapes and textures drawing functions** to support rings (`DrawRing()`, `DrawRingLines()`), circle sectors (`DrawCircleSector()`, `DrawCircleSectorLines()`), rounded rectangles (`DrawRectangleRounded()`, `DrawRectangleRoundedLines()`) and also n-patch textures (`DrawTextureNPatch()`), detailed examples have been added to illustrate all this new functionality.
|
||||
- Multiple **new shapes and textures drawing functions** to support rings (`DrawRing()`, `DrawRingLines()`), circle sectors (`DrawCircleSector()`, `DrawCircleSectorLines()`), rounded rectangles (`DrawRectangleRounded()`, `DrawRectangleRoundedLines()`) and also n-patch textures (`DrawTextureNPatch()`), detailed examples have been added to illustrate all this new functionality.
|
||||
|
||||
Experimental **cubemap support**, to automatically load multiple cubemap layouts (`LoadTextureCubemap()`). It required some internal `rlgl` redesign to allow cubemap textures.
|
||||
- Experimental **cubemap support**, to automatically load multiple cubemap layouts (`LoadTextureCubemap()`). It required some internal `rlgl` redesign to allow cubemap textures.
|
||||
|
||||
**Skeletal animation support for 3d models**, this addition implied a redesign of `Model` data structure to accomodate multiple mesh/multiple materials support and bones information. Multiple models functions have been reviewed and added on this process, also **glTF models loading support** has been added.
|
||||
- **Skeletal animation support for 3d models**, this addition implied a redesign of `Model` data structure to accomodate multiple mesh/multiple materials support and bones information. Multiple models functions have been reviewed and added on this process, also **glTF models loading support** has been added.
|
||||
|
||||
This is a just a brief list with some of the changes of the new **raylib 2.5** but there is way more, about **70 new functions** have been added and several subsystems have been redesigned. More than **30 new examples** have been created to show the new functionalities and better illustrate already available ones.
|
||||
|
||||
It has been a long year of hard work to make raylib a solid technology to develop new products over it.
|
||||
|
||||
notes on raylib 3.0
|
||||
-------------------
|
||||
|
||||
After **10 months of intense development**, new raylib version is ready. Despite primary intended as a minor release, the [CHANGELIST](CHANGELOG) has grown so big and the library has changed so much internally that it finally became a major release. Library **internal ABI** has reveived a big redesign and review, targeting portability, integration with other platforms and making it a perfect option for other progamming [language bindings](BINDINGS.md).
|
||||
|
||||
- All **global variables** from the multiple raylib modules have been moved to a **global context state**, it has several benefits, first, better code readability with more comprehensive variables naming and categorization (organized by types, i.e. `CORE.Window.display.width`, `CORE.Input.Keyboard.currentKeyState` or `RLGL.State.modelview`). Second, it allows better memory management to load global context state dynamically when required (not at the moment), making it easy to implement a **hot-reloading mechanism** if desired.
|
||||
|
||||
- All **memory allocations** on raylib and its dependencies now use `RL_MALLOC`, `RL_FREE` and similar macros. Now users can easely hook their own memory allocations mechanism if desired, having more control over memory allocated internally by the library. Additionally, it makes it easier to port the library to embedded devices where memory control is critical. For more info check raylib issue #1074.
|
||||
|
||||
- All **I/O file accesses** from raylib are being moved to **memory data access**, now all I/O file access is centralized into just four functions: `LoadFileData()`, `SaveFileData()`, `LoadFileText()`, `SaveFileText()`. Users can just update those functions to any I/O file system. This change makes it easier to integrate raylib with **Virtual File Systems** or custom I/O file implementations.
|
||||
|
||||
- All **raylib data structures** have been reviewed and optimized for pass-by-value usage. One of raylib distinctive design decisions is that most of its functions receive and return data by value. This design makes raylib really simple for newcomers, avoiding pointers and allowing complete access to all structures data in a simple way. The downside is that data is copied on stack every function call and that copy could be costly so, all raylib data structures have been optimized to **stay under 64 bytes** for fast copy and retrieve.
|
||||
|
||||
- All **raylib tracelog messages** have been reviewd and categorized for a more comprehensive output information when developing raylib applications, now all display, input, timer, platform, auxiliar libraries, file-accesses, data loading/unloading issues are properly reported with more detailed and visual messages.
|
||||
|
||||
- `raudio` module has been internally reviewed to accomodate the new `Music` structure (converted from previous pointer format) and the module has been adapted to the **highly improved** [`miniaudio v0.10`](https://github.com/dr-soft/miniaudio).
|
||||
|
||||
- `text` module reviewed to **improve fonts generation** and text management functions, `Font` structure has been redesigned to better accomodate characters data, decoupling individual characters as `Image` glyphs from the font atlas parameters. Several improvements have been made to better support Unicode strings with UTF-8 encoding.
|
||||
|
||||
- **Multiple new examples added** (most of them contributed by raylib users) and all examples reviewed for correct execution on most of the supported platforms, specially Web and Raspberry Pi. A detailed categorized table has been created on github for easy examples navigation and code access.
|
||||
|
||||
- New **GitHub Actions CI** system has been implemented for Windows, Linux and macOS code and examples compilation on every new commit or PR to make sure library keeps stable and usable with no breaking bugs.
|
||||
|
||||
Note that only key changes are listed here but there is way more! About **30 new functions**, multiple functions reviewed, bindings to [+40 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md) and great samples/demos/tutorials [created by the community](https://discord.gg/VkzNHUE), including raylib integration with [Spine](https://github.com/WEREMSOFT/spine-raylib-runtimes), [Unity](https://unitycoder.com/blog/2019/12/09/using-raylib-dll-in-unity/), [Tiled](https://github.com/OnACoffeeBreak/raylib_tiled_import_with_tmx), [Nuklear](http://bedroomcoders.co.uk/implementing-a-3d-gui-with-raylib/), [enet](https://github.com/nxrighthere/NetDynamics) and [more](https://github.com/raysan5/raylib/issues/1079)!
|
||||
|
||||
It has been **10 months of improvements** to create the best raylib ever.
|
||||
|
||||
Welcome to **raylib 3.0**.
|
||||
|
16
LICENSE
Normal file
@@ -0,0 +1,16 @@
|
||||
Copyright (c) 2013-2020 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.
|
51
LICENSE.md
@@ -1,51 +0,0 @@
|
||||
license
|
||||
=======
|
||||
|
||||
source code
|
||||
-----------
|
||||
|
||||
raylib 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) 2013-2019 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.
|
||||
|
||||
fonts
|
||||
------
|
||||
|
||||
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)
|
||||
* Jupiter Crash - Brian Kent (AEnigma)
|
||||
* Alagard - Hewett Tsoi
|
||||
* Romulus - Hewett Tsoi
|
||||
* Mecha - Captain Falcon
|
||||
* PixelPlay - Aleksander Shevchuk
|
||||
* PixAntiqua - Gerhard Großmann
|
||||
|
||||
2d art
|
||||
------
|
||||
|
||||
[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 are licensed as [Creative Commons Attribution-NonCommercial 3.0](https://creativecommons.org/licenses/by-nc/3.0/legalcode)
|
||||
|
||||
[cyberpunk street environments](https://github.com/raysan5/raylib/blob/master/examples/textures/resources) have been created by Luis Zuno ([@ansimuz](https://twitter.com/ansimuz)) and are licensed as [CC-BY-3.0](http://creativecommons.org/licenses/by/3.0/)
|
||||
|
||||
3d models
|
||||
---------
|
||||
|
||||
[medieval city 3d models and textures](https://github.com/raysan5/raylib/tree/master/examples/models/resources/medieval) have been created by Alberto Cano and are licensed as [Creative Commons Attribution-NonCommercial 4.0](https://creativecommons.org/licenses/by-nc/4.0/legalcode)
|
81
README.md
@@ -8,56 +8,99 @@ raylib is highly inspired by Borland BGI graphics lib and by XNA framework and i
|
||||
|
||||
Ready to learn? Jump to [code examples!](http://www.raylib.com/examples.html)
|
||||
|
||||
<br>
|
||||
|
||||
[](https://github.com/raysan5/raylib/graphs/contributors)
|
||||
[](https://github.com/raysan5/raylib/releases)
|
||||
[](https://github.com/raysan5/raylib/commits/master)
|
||||
[](LICENSE)
|
||||
|
||||
[](https://travis-ci.org/raysan5/raylib)
|
||||
[](https://ci.appveyor.com/project/raysan5/raylib)
|
||||
[](https://discord.gg/VkzNHUE)
|
||||
[](LICENSE.md)
|
||||
[](https://twitter.com/raysan5)
|
||||
[](https://github.com/raysan5/raylib/stargazers)
|
||||
[](https://twitter.com/raysan5)
|
||||
[](https://www.reddit.com/r/raylib/)
|
||||
|
||||
[](https://travis-ci.org/raysan5/raylib)
|
||||
[)](https://ci.appveyor.com/project/raysan5/raylib)
|
||||
|
||||
[](https://github.com/raysan5/raylib/actions)
|
||||
[](https://github.com/raysan5/raylib/actions)
|
||||
[](https://github.com/raysan5/raylib/actions)
|
||||
|
||||
features
|
||||
--------
|
||||
- **NO external dependencies**, all required libraries are bundled into raylib
|
||||
- Multiple platforms supported: **Windows, Linux, MacOS, Android... and many more!**
|
||||
- Multiple platforms supported: **Windows, Linux, MacOS, Android, HTML5... and 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.h)
|
||||
- Multiple **Fonts** formats supported (XNA fonts, AngelCode fonts, TTF)
|
||||
- Multiple **Fonts** formats supported (TTF, XNA fonts, AngelCode fonts)
|
||||
- Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
|
||||
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
|
||||
- Flexible Materials system, supporting classic maps and **PBR maps**
|
||||
- **Animated 3D models** supported (skeletal bones animation)
|
||||
- Shaders support, including model and postprocessing shaders.
|
||||
- Shaders support, including model 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
|
||||
- Huge examples collection with [+95 code examples](https://www.raylib.com/examples.html)!
|
||||
- Bindings to [+25 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
||||
|
||||
- Huge examples collection with [+115 code examples](https://github.com/raysan5/raylib/tree/master/examples)!
|
||||
- Bindings to [+40 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
||||
- Free and open source.
|
||||
|
||||
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 in the form of [rglfw](https://github.com/raysan5/raylib/blob/master/src/rglfw.c) module, to avoid external dependencies.
|
||||
|
||||
raylib uses on its [raudio](https://github.com/raysan5/raylib/blob/master/src/raudio.c) module, the amazing [miniaudio](https://github.com/dr-soft/miniaudio) library to support multiple platforms and multiple audio backends.
|
||||
|
||||
raylib uses internally multiple single-file header-only libraries to support different 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. Check [raylib Wiki](https://github.com/raysan5/raylib/wiki/raylib-dependencies) for a detailed list.
|
||||
raylib uses internally several single-file header-only libraries to support different 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. Check [raylib Wiki](https://github.com/raysan5/raylib/wiki/raylib-dependencies) for a detailed list.
|
||||
|
||||
*On Android platform, `native_app_glue module` module (provided by Android NDK) and native Android libraries are used to manage window/context, inputs and activity life cycle.*
|
||||
*On Android platform, `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 platform (native mode), `Videocore API` and `EGL` libraries are used for window/context management. Inputs are processed using `evdev` Linux libraries*
|
||||
|
||||
*On Web platform, raylib uses `emscripten` provided libraries for several input events management, specially noticeable the touch events support.*
|
||||
|
||||
build and installation
|
||||
----------------------
|
||||
|
||||
Binary releases for Windows, Linux and macOS are available at the [Github Releases page](https://github.com/raysan5/raylib/releases). raylib is also available via multiple package managers on multiple OS distributions. Check [raylib Wiki](https://github.com/raysan5/raylib/wiki) for more info.
|
||||
raylib binary releases for Windows, Linux and macOS are available at the [Github Releases page](https://github.com/raysan5/raylib/releases).
|
||||
|
||||
If you wish to build raylib yourself, [the raylib Wiki](https://github.com/raysan5/raylib/wiki) also contains detailed instructions on how to approach that.
|
||||
raylib is also available via multiple [package managers](https://github.com/raysan5/raylib/issues/613) on multiple OS distributions.
|
||||
|
||||
raylib has been developed using two tools:
|
||||
#### Installing and building raylib via vcpkg
|
||||
|
||||
* Notepad++ (text editor) - [http://notepad-plus-plus.org](http://notepad-plus-plus.org/)
|
||||
* MinGW (GCC compiler) - [http://www.mingw.org](http://www.mingw.org/)
|
||||
You can download and install raylib using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
|
||||
|
||||
Those are the tools recommended to enjoy raylib development.
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
./bootstrap-vcpkg.sh
|
||||
./vcpkg integrate install
|
||||
vcpkg install raylib
|
||||
|
||||
*The raylib port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.*
|
||||
|
||||
#### Building raylib on multiple platforms
|
||||
|
||||
[raylib Wiki](https://github.com/raysan5/raylib/wiki#development-platforms) contains detailed instructions on building and usage on multiple platforms.
|
||||
|
||||
- [Working on Windows](https://github.com/raysan5/raylib/wiki/Working-on-Windows)
|
||||
- [Working on macOS](https://github.com/raysan5/raylib/wiki/Working-on-macOS)
|
||||
- [Working on GNU Linux](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux)
|
||||
- [Working on FreeBSD](https://github.com/raysan5/raylib/wiki/Working-on-FreeBSD)
|
||||
- [Working on Raspberry Pi](https://github.com/raysan5/raylib/wiki/Working-on-Raspberry-Pi)
|
||||
- [Working for Android](https://github.com/raysan5/raylib/wiki/Working-for-Android)
|
||||
- [Working for Web (HTML5)](https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5))
|
||||
- [Working for UWP (Universal Window Platform)](https://github.com/raysan5/raylib/wiki/Working-for-UWP)
|
||||
- [Working anywhere with CMake](https://github.com/raysan5/raylib/wiki/Working-with-CMake)
|
||||
|
||||
*Note that Wiki is open for edit, if you find some issue while building raylib for your target platform, feel free to edit the Wiki or open and issue related to it.*
|
||||
|
||||
#### Using raylib with multiple IDEs
|
||||
|
||||
raylib has been developed on Windows platform using [Notepad++](https://notepad-plus-plus.org/) and [MinGW GCC](http://mingw-w64.org/doku.php) compiler but it can be used with other IDEs on multiple platforms.
|
||||
|
||||
[Projects directory](https://github.com/raysan5/raylib/tree/master/projects) contains several ready-to-use **project templates** to build raylib and code examples with multiple IDEs.
|
||||
|
||||
*Note that there are lots of IDEs supported, some of the provided templates could require some review, please, if you find some issue with some template or you think they could be improved, feel free to send a PR or open a related issue.*
|
||||
|
||||
contact
|
||||
-------
|
||||
@@ -70,7 +113,7 @@ contact
|
||||
* Patreon: [https://www.patreon.com/raylib](https://www.patreon.com/raylib)
|
||||
* YouTube: [https://www.youtube.com/channel/raylib](https://www.youtube.com/channel/UC8WIBkhYb5sBNqXO1mZ7WSQ)
|
||||
|
||||
If you are using raylib and you enjoy it, please, join our [Discord server](https://discord.gg/VkzNHUE).
|
||||
If you are using raylib and enjoying it, please, join our [Discord server](https://discord.gg/VkzNHUE) and let us know! :)
|
||||
|
||||
license
|
||||
-------
|
||||
|
20
ROADMAP.md
@@ -3,14 +3,20 @@ roadmap
|
||||
|
||||
Here it is a wish-list with features and ideas to improve the library. Note that features listed here are quite high-level and could be long term additions for the library. Current version of raylib is complete and functional but there is a lot of room for improvement.
|
||||
|
||||
[raylib source code](https://github.com/raysan5/raylib/tree/master/src) has some *TODO* marks around code with pending things to review and improve.
|
||||
Also, check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
|
||||
[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 also [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
|
||||
|
||||
**raylib 2.x**
|
||||
- [ ] rnet: raylib network module
|
||||
- [ ] rres: raylib resource packer
|
||||
- [ ] rlvk: raylib Vulkan API support (GRAPHICS_API_VULKAN)
|
||||
- [ ] Basic CPU/GPU stats sytem (memory, draws, time...)
|
||||
**raylib 3.x**
|
||||
- [ ] Network module (UDP): `rnet` ([info](https://github.com/raysan5/raylib/issues/753))
|
||||
- [ ] Custom raylib resource packer: `rres` ([info](https://github.com/raysan5/rres))
|
||||
- [ ] Basic CPU/GPU stats system (memory, draws, time...)
|
||||
- [ ] Continuous Deployment using GitHub Actions
|
||||
|
||||
**raylib 3.0**
|
||||
- [x] Custom memory allocators support
|
||||
- [x] Global variables moved to global context
|
||||
- [x] Optimize data structures for pass-by-value
|
||||
- [x] Trace log messages redesign ([info](https://github.com/raysan5/raylib/issues/1065))
|
||||
- [x] Continuous Integration using GitHub Actions
|
||||
|
||||
**raylib 2.5**
|
||||
- [x] Support Animated models
|
||||
|
13
SPONSORS.md
Normal file
@@ -0,0 +1,13 @@
|
||||
The following people has contributed with a generous donation to the raylib project.
|
||||
|
||||
## 🥇 Gold Contributors
|
||||
|
||||
...
|
||||
|
||||
## 🥈 Silver Contributors
|
||||
|
||||
...
|
||||
|
||||
## 🥉 Bronze Contributors
|
||||
|
||||
...
|
@@ -39,7 +39,7 @@ before_build:
|
||||
- cd build
|
||||
|
||||
build_script:
|
||||
- cmake -G %GENERATOR% -DSTATIC=ON -DSHARED=ON -DBUILD_EXAMPLES=%examples% -DBUILD_GAMES=%examples% -DINCLUDE_EVERYTHING=ON ..
|
||||
- cmake -G %GENERATOR% -DCMAKE_BUILD_TYPE=Release -DSTATIC=ON -DSHARED=ON -DBUILD_EXAMPLES=%examples% -DBUILD_GAMES=%examples% -DINCLUDE_EVERYTHING=ON ..
|
||||
- cmake --build . --target install
|
||||
|
||||
after_build:
|
||||
|
@@ -12,12 +12,14 @@
|
||||
# raylib_DEFINITIONS - Compiler switches required for using raylib
|
||||
|
||||
set(XPREFIX PC_RAYLIB)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(${XPREFIX} QUIET raylib)
|
||||
|
||||
if (raylib_USE_STATIC_LIBS)
|
||||
set(XPREFIX ${XPREFIX}_STATIC)
|
||||
endif()
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(${XPREFIX} QUIET raylib)
|
||||
set(raylib_DEFINITIONS ${${XPREFIX}_CFLAGS})
|
||||
|
||||
find_path(raylib_INCLUDE_DIR
|
||||
@@ -25,18 +27,17 @@ find_path(raylib_INCLUDE_DIR
|
||||
HINTS ${${XPREFIX}_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
set(RAYLIB_NAMES raylib)
|
||||
|
||||
if (raylib_USE_STATIC_LIBS)
|
||||
find_library(raylib_LIBRARY
|
||||
NAMES raylib_static
|
||||
HINTS ${${XPREFIX}_LIBRARY_DIRS}
|
||||
)
|
||||
else ()
|
||||
find_library(raylib_LIBRARY
|
||||
NAMES raylib
|
||||
HINTS ${${XPREFIX}_LIBRARY_DIRS}
|
||||
)
|
||||
set(RAYLIB_NAMES libraylib.a raylib.lib ${RAYLIB_NAMES})
|
||||
endif()
|
||||
|
||||
find_library(raylib_LIBRARY
|
||||
NAMES ${RAYLIB_NAMES}
|
||||
HINTS ${${XPREFIX}_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
set(raylib_LIBRARIES ${raylib_LIBRARY})
|
||||
set(raylib_LIBRARY_DIRS ${${XPREFIX}_LIBRARY_DIRS})
|
||||
set(raylib_LIBRARY_DIR ${raylib_LIBRARY_DIRS})
|
||||
|
@@ -67,6 +67,8 @@ if(${PLATFORM} MATCHES "Android")
|
||||
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}/models/models_rlgl_solar_system.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_rlgl_full_solar_system.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_solar_system.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_obj_viewer.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_animation.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_first_person_maze.c)
|
||||
@@ -76,15 +78,19 @@ if(${PLATFORM} MATCHES "Android")
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_postprocessing.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_raymarching.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_palette_switch.c)
|
||||
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_basic_lighting.c)
|
||||
|
||||
elseif(${PLATFORM} MATCHES "Web")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1")
|
||||
# Since WASM is used, ALLOW_MEMORY_GROWTH has no extra overheads
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1 --no-heap-copy")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/src/shell.html")
|
||||
|
||||
set(OUTPUT_EXT ".html")
|
||||
|
||||
# Remove the -rdynamic flag because otherwise emscripten
|
||||
# does not generate HTML+JS+WASM files, only a non-working
|
||||
# and fat HTML
|
||||
string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_C_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS})
|
||||
endif()
|
||||
|
||||
include_directories(BEFORE SYSTEM others/external/include)
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5
|
||||
#
|
||||
# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5)
|
||||
# Copyright (c) 2013-2020 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.
|
||||
@@ -25,8 +25,8 @@
|
||||
|
||||
# Define required raylib variables
|
||||
PROJECT_NAME ?= raylib_examples
|
||||
RAYLIB_VERSION ?= 2.5.0
|
||||
RAYLIB_API_VERSION ?= 2
|
||||
RAYLIB_VERSION ?= 3.0.0
|
||||
RAYLIB_API_VERSION ?= 3
|
||||
RAYLIB_PATH ?= ..
|
||||
|
||||
# Define default options
|
||||
@@ -116,12 +116,11 @@ endif
|
||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
# Emscripten required variables
|
||||
EMSDK_PATH ?= C:/emsdk
|
||||
EMSCRIPTEN_VERSION ?= 1.38.31
|
||||
CLANG_VERSION = e$(EMSCRIPTEN_VERSION)_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)
|
||||
EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten
|
||||
CLANG_PATH = $(EMSDK_PATH)/upstream/bin
|
||||
PYTHON_PATH = $(EMSDK_PATH)/python/3.7.4_64bit
|
||||
NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin
|
||||
export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH)
|
||||
endif
|
||||
|
||||
# Define raylib release directory for compiled library.
|
||||
@@ -188,20 +187,24 @@ endif
|
||||
# -std=gnu99 defines C language mode (GNU C from 1999 revision)
|
||||
# -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 -Wno-missing-braces
|
||||
CFLAGS += -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces
|
||||
|
||||
ifeq ($(BUILD_MODE),DEBUG)
|
||||
CFLAGS += -g
|
||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
CFLAGS += -s ASSERTIONS=1 --profiling
|
||||
endif
|
||||
else
|
||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
CFLAGS += -O3
|
||||
else
|
||||
CFLAGS += -s -O1
|
||||
endif
|
||||
endif
|
||||
|
||||
# Additional flags for compiler (if desired)
|
||||
#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||
# resource file contains windows executable icon and properties
|
||||
# -Wl,--subsystem,windows hides the console window
|
||||
CFLAGS += $(RAYLIB_PATH)/raylib.rc.data -Wl,--subsystem,windows
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),LINUX)
|
||||
ifeq ($(RAYLIB_LIBTYPE),STATIC)
|
||||
CFLAGS += -D_DEFAULT_SOURCE
|
||||
@@ -230,17 +233,15 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
# --profiling # include information for code profiling
|
||||
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
|
||||
# --preload-file resources # specify a resources folder for data compilation
|
||||
CFLAGS += -Os -s USE_GLFW=3 -s FORCE_FILESYSTEM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 --preload-file $(dir $<)resources@resources
|
||||
ifeq ($(BUILD_MODE), DEBUG)
|
||||
CFLAGS += -s ASSERTIONS=1 --profiling
|
||||
endif
|
||||
CFLAGS += -s USE_GLFW=3 -s FORCE_FILESYSTEM=1 -s ASYNCIFY --preload-file $(dir $<)resources@resources
|
||||
|
||||
# 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)\src\shell.html
|
||||
CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html
|
||||
EXT = .html
|
||||
endif
|
||||
|
||||
@@ -271,6 +272,14 @@ endif
|
||||
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
|
||||
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||
# resource file contains windows executable icon and properties
|
||||
LDFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data
|
||||
# -Wl,--subsystem,windows hides the console window
|
||||
ifeq ($(BUILD_MODE), RELEASE)
|
||||
LDFLAGS += -Wl,--subsystem,windows
|
||||
endif
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),BSD)
|
||||
# Consider -L$(RAYLIB_INSTALL_PATH)
|
||||
LDFLAGS += -L. -Lsrc -L/usr/local/lib
|
||||
@@ -318,7 +327,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
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
|
||||
LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),BSD)
|
||||
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
||||
@@ -343,8 +352,8 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.bc
|
||||
endif
|
||||
|
||||
# Define all source files required
|
||||
EXAMPLES = \
|
||||
# Define all object files required
|
||||
CORE = \
|
||||
core/core_basic_window \
|
||||
core/core_input_keys \
|
||||
core/core_input_mouse \
|
||||
@@ -353,6 +362,7 @@ EXAMPLES = \
|
||||
core/core_input_multitouch \
|
||||
core/core_input_gestures \
|
||||
core/core_2d_camera \
|
||||
core/core_2d_camera_platformer \
|
||||
core/core_3d_camera_mode \
|
||||
core/core_3d_camera_free \
|
||||
core/core_3d_camera_first_person \
|
||||
@@ -362,9 +372,12 @@ EXAMPLES = \
|
||||
core/core_window_letterbox \
|
||||
core/core_drop_files \
|
||||
core/core_random_values \
|
||||
core/core_scissor_test \
|
||||
core/core_storage_values \
|
||||
core/core_vr_simulator \
|
||||
core/core_loading_thread \
|
||||
core/core_loading_thread
|
||||
|
||||
SHAPES = \
|
||||
shapes/shapes_basic_shapes \
|
||||
shapes/shapes_bouncing_ball \
|
||||
shapes/shapes_colors_palette \
|
||||
@@ -379,18 +392,11 @@ EXAMPLES = \
|
||||
shapes/shapes_easings_rectangle_array \
|
||||
shapes/shapes_draw_ring \
|
||||
shapes/shapes_draw_circle_sector \
|
||||
shapes/shapes_draw_rectangle_rounded \
|
||||
text/text_raylib_fonts \
|
||||
text/text_sprite_fonts \
|
||||
text/text_ttf_loading \
|
||||
text/text_bmfont_ttf \
|
||||
text/text_font_sdf \
|
||||
text/text_format_text \
|
||||
text/text_input_box \
|
||||
text/text_writing_anim \
|
||||
text/text_rectangle_bounds \
|
||||
text/text_unicode \
|
||||
shapes/shapes_draw_rectangle_rounded
|
||||
|
||||
TEXTURES = \
|
||||
textures/textures_logo_raylib \
|
||||
textures/textures_mouse_painting \
|
||||
textures/textures_rectangle \
|
||||
textures/textures_srcrec_dstrec \
|
||||
textures/textures_image_drawing \
|
||||
@@ -405,7 +411,21 @@ EXAMPLES = \
|
||||
textures/textures_background_scrolling \
|
||||
textures/textures_sprite_button \
|
||||
textures/textures_sprite_explosion \
|
||||
textures/textures_bunnymark \
|
||||
textures/textures_bunnymark
|
||||
|
||||
TEXT = \
|
||||
text/text_raylib_fonts \
|
||||
text/text_font_spritefont \
|
||||
text/text_font_loading \
|
||||
text/text_font_filters \
|
||||
text/text_font_sdf \
|
||||
text/text_format_text \
|
||||
text/text_input_box \
|
||||
text/text_writing_anim \
|
||||
text/text_rectangle_bounds \
|
||||
text/text_unicode
|
||||
|
||||
MODELS = \
|
||||
models/models_animation \
|
||||
models/models_billboard \
|
||||
models/models_box_collisions \
|
||||
@@ -415,13 +435,15 @@ EXAMPLES = \
|
||||
models/models_material_pbr \
|
||||
models/models_mesh_generation \
|
||||
models/models_mesh_picking \
|
||||
models/models_obj_loading \
|
||||
models/models_obj_viewer \
|
||||
models/models_loading \
|
||||
models/models_orthographic_projection \
|
||||
models/models_rlgl_solar_system \
|
||||
models/models_skybox \
|
||||
models/models_yaw_pitch_roll \
|
||||
models/models_heightmap \
|
||||
models/models_waving_cubes
|
||||
|
||||
SHADERS = \
|
||||
shaders/shaders_model_shader \
|
||||
shaders/shaders_shapes_textures \
|
||||
shaders/shaders_custom_uniform \
|
||||
@@ -432,21 +454,39 @@ EXAMPLES = \
|
||||
shaders/shaders_texture_waves \
|
||||
shaders/shaders_julia_set \
|
||||
shaders/shaders_eratosthenes \
|
||||
shaders/shaders_basic_lighting \
|
||||
shaders/shaders_fog \
|
||||
shaders/shaders_simple_mask \
|
||||
shaders/shaders_spotlight
|
||||
|
||||
AUDIO = \
|
||||
audio/audio_module_playing \
|
||||
audio/audio_music_stream \
|
||||
audio/audio_raw_stream \
|
||||
audio/audio_sound_loading \
|
||||
physac/physics_demo \
|
||||
physac/physics_friction \
|
||||
physac/physics_movement \
|
||||
physac/physics_restitution \
|
||||
physac/physics_shatter
|
||||
audio/audio_multichannel_sound
|
||||
|
||||
PHYSICS = \
|
||||
physics/physics_demo \
|
||||
physics/physics_friction \
|
||||
physics/physics_movement \
|
||||
physics/physics_restitution \
|
||||
physics/physics_shatter
|
||||
|
||||
|
||||
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
||||
|
||||
# Default target entry
|
||||
all: $(EXAMPLES)
|
||||
all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) $(PHYSICS)
|
||||
|
||||
core: $(CORE)
|
||||
shapes: $(SHAPES)
|
||||
text: $(TEXT)
|
||||
textures: $(TEXTURES)
|
||||
models: $(MODELS)
|
||||
shaders: $(SHADERS)
|
||||
audio: $(AUDIO)
|
||||
physics: $(PHYSICS)
|
||||
|
||||
# Generic compilation pattern
|
||||
# NOTE: Examples must be ready for Android compilation!
|
||||
@@ -464,7 +504,8 @@ 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 -fv
|
||||
find . -type f -executable -delete
|
||||
rm -fv *.o
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),OSX)
|
||||
find . -type f -perm +ugo+x -delete
|
||||
|
@@ -26,8 +26,10 @@ PLATFORM ?= PLATFORM_ANDROID
|
||||
RAYLIB_PATH ?= ..\..
|
||||
|
||||
# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version
|
||||
# Starting in 2019 using ARM64 is mandatory for published apps,
|
||||
# and minimum required target API is Android 9 (API level 28)
|
||||
ANDROID_ARCH ?= ARM
|
||||
ANDROID_API_VERSION = 21
|
||||
ANDROID_API_VERSION = 28
|
||||
ifeq ($(ANDROID_ARCH),ARM)
|
||||
ANDROID_ARCH_NAME = armeabi-v7a
|
||||
endif
|
||||
@@ -36,11 +38,11 @@ ifeq ($(ANDROID_ARCH),ARM64)
|
||||
endif
|
||||
|
||||
# Required path variables
|
||||
# NOTE: JAVA_HOME must be set to JDK
|
||||
JAVA_HOME ?= C:/JavaJDK
|
||||
# NOTE: JAVA_HOME must be set to JDK (using OpenJDK 13)
|
||||
JAVA_HOME ?= C:/open-jdk
|
||||
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_TOOLCHAIN = C:/android-ndk-r21/toolchains/llvm/prebuilt/windows-x86_64
|
||||
ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/29.0.3
|
||||
ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools
|
||||
|
||||
# Android project configuration variables
|
||||
@@ -81,13 +83,12 @@ ifeq ($(RAYLIB_LIBTYPE),SHARED)
|
||||
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
|
||||
CC = $(ANDROID_TOOLCHAIN)/bin/armv7a-linux-androideabi$(ANDROID_API_VERSION)-clang
|
||||
AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar
|
||||
endif
|
||||
ifeq ($(ANDROID_ARCH),ARM64)
|
||||
CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-clang
|
||||
CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android$(ANDROID_API_VERSION)-clang
|
||||
AR = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-ar
|
||||
endif
|
||||
|
||||
@@ -274,7 +275,7 @@ zipalign_project_apk_package:
|
||||
# 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
|
||||
$(ANDROID_PLATFORM_TOOLS)/adb install $(PROJECT_NAME).apk
|
||||
|
||||
# Check supported ABI for the device (armeabi-v7a, arm64-v8a, x86, x86_64)
|
||||
check_device_abi:
|
||||
|
191
examples/README.md
Normal file
@@ -0,0 +1,191 @@
|
||||
## EXAMPLES LIST
|
||||
|
||||
### category: core
|
||||
|
||||
Examples using raylib core platform functionality like window creation, inputs, drawing modes and system functionality.
|
||||
|
||||
| ## | example | image | developer | new |
|
||||
|----|----------|--------|:----------:|:---:|
|
||||
| 01 | [core_basic_window](core/core_basic_window.c) | <img src="core/core_basic_window.png" alt="core_basic_window" width="200"> | ray | |
|
||||
| 02 | [core_input_keys](core/core_input_keys.c) | <img src="core/core_input_keys.png" alt="core_input_keys" width="200"> | ray | |
|
||||
| 03 | [core_input_mouse](core/core_input_mouse.c) | <img src="core/core_input_mouse.png" alt="core_input_mouse" width="200"> | ray | |
|
||||
| 04 | [core_input_mouse_wheel](core/core_input_mouse_wheel.c) | <img src="core/core_input_mouse_wheel.png" alt="core_input_mouse_wheel" width="200"> | ray | |
|
||||
| 05 | [core_input_gamepad](core/core_input_gamepad.c) | <img src="core/core_input_gamepad.png" alt="core_input_gamepad" width="200"> | ray | |
|
||||
| 06 | [core_input_multitouch](core/core_input_multitouch.c) | <img src="core/core_input_multitouch.png" alt="core_input_multitouch" width="200"> | [Berni](https://github.com/Berni8k) | |
|
||||
| 07 | [core_input_gestures](core/core_input_gestures.c) | <img src="core/core_input_gestures.png" alt="core_input_gestures" width="200"> | ray | |
|
||||
| 08 | [core_2d_camera](core/core_2d_camera.c) | <img src="core/core_2d_camera.png" alt="core_2d_camera" width="200"> | ray | |
|
||||
| 09 | [core_2d_camera_platformer](core/core_2d_camera_platformer.c) | <img src="core/core_2d_camera_platformer.png" alt="core_2d_camera_platformer" width="200"> | [avyy](https://github.com/avyy) | ⭐️ |
|
||||
| 10 | [core_3d_camera_mode](core/core_3d_camera_mode.c) | <img src="core/core_3d_camera_mode.png" alt="core_3d_camera_mode" width="200"> | ray | |
|
||||
| 11 | [core_3d_camera_free](core/core_3d_camera_free.c) | <img src="core/core_3d_camera_free.png" alt="core_3d_camera_free" width="200"> | ray | |
|
||||
| 12 | [core_3d_camera_first_person](core/core_3d_camera_first_person.c) | <img src="core/core_3d_camera_first_person.png" alt="core_3d_camera_first_person" width="200"> | ray | |
|
||||
| 13 | [core_3d_picking](core/core_3d_picking.c) | <img src="core/core_3d_picking.png" alt="core_3d_picking" width="200"> | ray | |
|
||||
| 14 | [core_world_screen](core/core_world_screen.c) | <img src="core/core_world_screen.png" alt="core_world_screen" width="200"> | ray | |
|
||||
| 15 | [core_custom_logging](core/core_custom_logging.c) | <img src="core/core_custom_logging.png" alt="core_custom_logging" width="200"> | [Pablo Marcos](https://github.com/pamarcos) | |
|
||||
| 16 | [core_window_letterbox](core/core_window_letterbox.c) | <img src="core/core_window_letterbox.png" alt="core_window_letterbox" width="200"> | [Anata](https://github.com/anatagawa) | |
|
||||
| 17 | [core_drop_files](core/core_drop_files.c) | <img src="core/core_drop_files.png" alt="core_drop_files" width="200"> | ray | |
|
||||
| 18 | [core_random_values](core/core_random_values.c) | <img src="core/core_random_values.png" alt="core_random_values" width="200"> | ray | |
|
||||
| 19 | [core_storage_values](core/core_storage_values.c) | <img src="core/core_storage_values.png" alt="core_storage_values" width="200"> | ray | |
|
||||
| 20 | [core_vr_simulator](core/core_vr_simulator.c) | <img src="core/core_vr_simulator.png" alt="core_vr_simulator" width="200"> | ray | |
|
||||
| 21 | [core_loading_thread](core/core_loading_thread.c) | <img src="core/core_loading_thread.png" alt="core_loading_thread" width="200"> | ray | ⭐️ |
|
||||
| 22 | [core_scissor_test](core/core_scissor_test.c) | <img src="core/core_scissor_test.png" alt="core_scissor_test" width="200"> | [Chris Dill](https://github.com/MysteriousSpace) | ⭐️ |
|
||||
|
||||
### category: shapes
|
||||
|
||||
Examples using raylib shapes drawing functionality, provided by raylib [shapes](../src/shapes.c) module.
|
||||
|
||||
| ## | example | image | developer | new |
|
||||
|----|----------|--------|:----------:|:---:|
|
||||
| 23 | [shapes_basic_shapes](shapes/shapes_basic_shapes.c) | <img src="shapes/shapes_basic_shapes.png" alt="shapes_basic_shapes" width="200"> | ray | |
|
||||
| 24 | [shapes_bouncing_ball](shapes/shapes_bouncing_ball.c) | <img src="shapes/shapes_bouncing_ball.png" alt="shapes_bouncing_ball" width="200"> | ray | ⭐️ |
|
||||
| 25 | [shapes_colors_palette](shapes/shapes_colors_palette.c) | <img src="shapes/shapes_colors_palette.png" alt="shapes_colors_palette" width="200"> | ray | |
|
||||
| 26 | [shapes_logo_raylib](shapes/shapes_logo_raylib.c) | <img src="shapes/shapes_logo_raylib.png" alt="shapes_logo_raylib" width="200"> | ray | |
|
||||
| 27 | [shapes_logo_raylib_anim](shapes/shapes_logo_raylib_anim.c) | <img src="shapes/shapes_logo_raylib_anim.png" alt="shapes_logo_raylib_anim" width="200"> | ray | |
|
||||
| 28 | [shapes_rectangle_scaling](shapes/shapes_rectangle_scaling.c) | <img src="shapes/shapes_rectangle_scaling.png" alt="shapes_rectangle_scaling" width="200"> | [Vlad Adrian](https://github.com/demizdor) | |
|
||||
| 29 | [shapes_lines_bezier](shapes/shapes_lines_bezier.c) | <img src="shapes/shapes_lines_bezier.png" alt="shapes_lines_bezier" width="200"> | ray | |
|
||||
| 30 | [shapes_collision_area](shapes/shapes_collision_area.c) | <img src="shapes/shapes_collision_area.png" alt="shapes_collision_area" width="200"> | ray | ⭐️ |
|
||||
| 31 | [shapes_following_eyes](shapes/shapes_following_eyes.c) | <img src="shapes/shapes_following_eyes.png" alt="shapes_following_eyes" width="200"> | ray | ⭐️ |
|
||||
| 32 | [shapes_easings_ball_anim](shapes/shapes_easings_ball_anim.c) | <img src="shapes/shapes_easings_ball_anim.png" alt="shapes_easings_ball_anim" width="200"> | ray | ⭐️ |
|
||||
| 33 | [shapes_easings_box_anim](shapes/shapes_easings_box_anim.c) | <img src="shapes/shapes_easings_box_anim.png" alt="shapes_easings_box_anim" width="200"> | ray | ⭐️ |
|
||||
| 34 | [shapes_easings_rectangle_array](shapes/shapes_easings_rectangle_array.c) | <img src="shapes/shapes_easings_rectangle_array.png" alt="shapes_easings_rectangle_array" width="200"> | ray | ⭐️ |
|
||||
| 35 | [shapes_draw_ring](shapes/shapes_draw_ring.c) | <img src="shapes/shapes_draw_ring.png" alt="shapes_draw_ring" width="200"> | [Vlad Adrian](https://github.com/demizdor) | ⭐️ |
|
||||
| 36 | [shapes_draw_circle_sector](shapes/shapes_draw_circle_sector.c) | <img src="shapes/shapes_draw_circle_sector.png" alt="shapes_draw_circle_sector" width="200"> | [Vlad Adrian](https://github.com/demizdor) | |
|
||||
| 37 | [shapes_draw_rectangle_rounded](shapes/shapes_draw_rectangle_rounded.c) | <img src="shapes/shapes_draw_rectangle_rounded.png" alt="shapes_draw_rectangle_rounded" width="200"> | [Vlad Adrian](https://github.com/demizdor) | |
|
||||
|
||||
### category: text
|
||||
|
||||
Examples using raylib text functionality, including sprite fonts loading/generation and text drawing, provided by raylib [text](../src/text.c) module.
|
||||
|
||||
| ## | example | image | developer | new |
|
||||
|----|----------|--------|:----------:|:---:|
|
||||
| 38 | [text_raylib_fonts](text/text_raylib_fonts.c) | <img src="text/text_raylib_fonts.png" alt="text_raylib_fonts" width="200"> | ray | |
|
||||
| 39 | [text_font_spritefont](text/text_font_spritefont.c) | <img src="text/text_font_spritefont.png" alt="text_font_spritefont" width="200"> | ray | |
|
||||
| 40 | [text_font_filters](text/text_font_filters.c) | <img src="text/text_font_filters.png" alt="text_font_filters" width="200"> | ray | |
|
||||
| 41 | [text_font_loading](text/text_font_loading.c) | <img src="text/text_font_loading.png" alt="text_font_loading" width="200"> | ray | |
|
||||
| 42 | [text_font_sdf](text/text_font_sdf.c) | <img src="text/text_font_sdf.png" alt="text_font_sdf" width="200"> | ray | ⭐️ |
|
||||
| 43 | [text_format_text](text/text_format_text.c) | <img src="text/text_format_text.png" alt="text_format_text" width="200"> | ray | |
|
||||
| 44 | [text_input_box](text/text_input_box.c) | <img src="text/text_input_box.png" alt="text_input_box" width="200"> | ray | |
|
||||
| 45 | [text_writing_anim](text/text_writing_anim.c) | <img src="text/text_writing_anim.png" alt="text_writing_anim" width="200"> | ray | |
|
||||
| 46 | [text_rectangle_bounds](text/text_rectangle_bounds.c) | <img src="text/text_rectangle_bounds.png" alt="text_rectangle_bounds" width="200"> | [Vlad Adrian](https://github.com/demizdor) | |
|
||||
| 47 | [text_unicode](text/text_unicode.c) | <img src="text/text_unicode.png" alt="text_unicode" width="200"> | [Vlad Adrian](https://github.com/demizdor) | |
|
||||
|
||||
### category: textures
|
||||
|
||||
Examples using raylib textures functionality, including image/textures loading/generation and drawing, provided by raylib [textures](../src/textures.c) module.
|
||||
|
||||
| ## | example | image | developer | new |
|
||||
|----|----------|--------|:----------:|:---:|
|
||||
| 48 | [textures_logo_raylib](textures/textures_logo_raylib.c) | <img src="textures/textures_logo_raylib.png" alt="textures_logo_raylib" width="200"> | ray | |
|
||||
| 49 | [textures_rectangle](textures/textures_rectangle.c) | <img src="textures/textures_rectangle.png" alt="textures_rectangle" width="200"> | ray | |
|
||||
| 50 | [textures_srcrec_dstrec](textures/textures_srcrec_dstrec.c) | <img src="textures/textures_srcrec_dstrec.png" alt="textures_srcrec_dstrec" width="200"> | ray | |
|
||||
| 51 | [textures_image_drawing](textures/textures_image_drawing.c) | <img src="textures/textures_image_drawing.png" alt="textures_image_drawing" width="200"> | ray | |
|
||||
| 52 | [textures_image_generation](textures/textures_image_generation.c) | <img src="textures/textures_image_generation.png" alt="textures_image_generation" width="200"> | ray | |
|
||||
| 53 | [textures_image_loading](textures/textures_image_loading.c) | <img src="textures/textures_image_loading.png" alt="textures_image_loading" width="200"> | ray | |
|
||||
| 54 | [textures_image_processing](textures/textures_image_processing.c) | <img src="textures/textures_image_processing.png" alt="textures_image_processing" width="200"> | ray | |
|
||||
| 55 | [textures_image_text](textures/textures_image_text.c) | <img src="textures/textures_image_text.png" alt="textures_image_text" width="200"> | ray | ⭐️ |
|
||||
| 56 | [textures_to_image](textures/textures_to_image.c) | <img src="textures/textures_to_image.png" alt="textures_to_image" width="200"> | ray | |
|
||||
| 57 | [textures_raw_data](textures/textures_raw_data.c) | <img src="textures/textures_raw_data.png" alt="textures_raw_data" width="200"> | ray | |
|
||||
| 58 | [textures_particles_blending](textures/textures_particles_blending.c) | <img src="textures/textures_particles_blending.png" alt="textures_particles_blending" width="200"> | ray | |
|
||||
| 59 | [textures_npatch_drawing](textures/textures_npatch_drawing.c) | <img src="textures/textures_npatch_drawing.png" alt="textures_npatch_drawing" width="200"> | [Jorge A. Gomes](https://github.com/overdev) | |
|
||||
| 60 | [textures_background_scrolling](textures/textures_background_scrolling.c) | <img src="textures/textures_background_scrolling.png" alt="textures_background_scrolling" width="200"> | ray | ⭐️ |
|
||||
| 61 | [textures_sprite_button](textures/textures_sprite_button.c) | <img src="textures/textures_sprite_button.png" alt="textures_sprite_button" width="200"> | ray | ⭐️ |
|
||||
| 62 | [textures_sprite_explosion](textures/textures_sprite_explosion.c) | <img src="textures/textures_sprite_explosion.png" alt="textures_sprite_explosion" width="200"> | ray | ⭐️ |
|
||||
| 63 | [textures_bunnymark](textures/textures_bunnymark.c) | <img src="textures/textures_bunnymark.png" alt="textures_bunnymark" width="200"> | ray | ⭐️ |
|
||||
| 64 | [textures_mouse_painting](textures/textures_mouse_painting.c) | <img src="textures/textures_mouse_painting.png" alt="textures_mouse_painting" width="200"> | [Chris Dill](https://github.com/MysteriousSpace) | ⭐️ |
|
||||
|
||||
### category: models
|
||||
|
||||
Examples using raylib models functionality, including models loading/generation and drawing, provided by raylib [models](../src/models.c) module.
|
||||
|
||||
| ## | example | image | developer | new |
|
||||
|----|----------|--------|:----------:|:---:|
|
||||
| 65 | [models_animation](models/models_animation.c) | <img src="models/models_animation.png" alt="models_animation" width="200"> | [culacant](https://github.com/culacant) | ⭐️ |
|
||||
| 66 | [models_billboard](models/models_billboard.c) | <img src="models/models_billboard.png" alt="models_billboard" width="200"> | ray | |
|
||||
| 67 | [models_box_collisions](models/models_box_collisions.c) | <img src="models/models_box_collisions.png" alt="models_box_collisions" width="200"> | ray | |
|
||||
| 68 | [models_cubicmap](models/models_cubicmap.c) | <img src="models/models_cubicmap.png" alt="models_cubicmap" width="200"> | ray | |
|
||||
| 69 | [models_first_person_maze](models/models_first_person_maze.c) | <img src="models/models_first_person_maze.png" alt="models_first_person_maze" width="200"> | ray | ⭐️ |
|
||||
| 70 | [models_geometric_shapes](models/models_geometric_shapes.c) | <img src="models/models_geometric_shapes.png" alt="models_geometric_shapes" width="200"> | ray | |
|
||||
| 71 | [models_material_pbr](models/models_material_pbr.c) | <img src="models/models_material_pbr.png" alt="models_material_pbr" width="200"> | ray | |
|
||||
| 72 | [models_mesh_generation](models/models_mesh_generation.c) | <img src="models/models_mesh_generation.png" alt="models_mesh_generation" width="200"> | ray | |
|
||||
| 73 | [models_mesh_picking](models/models_mesh_picking.c) | <img src="models/models_mesh_picking.png" alt="models_mesh_picking" width="200"> | [Joel Davis](https://github.com/joeld42) | |
|
||||
| 74 | [models_loading](models/models_loading.c) | <img src="models/models_loading.png" alt="models_loading" width="200"> | ray | |
|
||||
| 75 | [models_orthographic_projection](models/models_orthographic_projection.c) | <img src="models/models_orthographic_projection.png" alt="models_orthographic_projection" width="200"> | [Max Danielsson](https://github.com/autious) | |
|
||||
| 76 | *TODO* | *TODO* | *TODO* | |
|
||||
| 77 | *TODO* | *TODO* | *TODO* | |
|
||||
| 78 | [models_solar_system_rlgl](models/models_rlgl_solar_system.c) | <img src="models/models_rlgl_solar_system.png" alt="models_rlgl_solar_system" width="200"> | ray | ⭐️ |
|
||||
| 79 | [models_yaw_pitch_roll](models/models_yaw_pitch_roll.c) | <img src="models/models_yaw_pitch_roll.png" alt="models_yaw_pitch_roll" width="200"> | [Berni](https://github.com/Berni8k) | |
|
||||
| 80 | [models_waving_cubes](models/models_waving_cubes.c) | <img src="models/models_waving_cubes.png" alt="models_waving_cubes" width="200"> | [codecat](https://github.com/codecat) | ⭐️ |
|
||||
| 81 | [models_heightmap](models/models_heightmap.c) | <img src="models/models_heightmap.png" alt="models_heightmap" width="200"> | ray | |
|
||||
| 82 | [models_skybox](models/models_skybox.c) | <img src="models/models_skybox.png" alt="models_skybox" width="200"> | ray | |
|
||||
|
||||
### category: shaders
|
||||
|
||||
Examples using raylib shaders functionality, including shaders loading, parameters configuration and drawing using them (model shaders and postprocessing shaders). This functionality is directly provided by raylib [rlgl](../src/rlgl.c) module.
|
||||
|
||||
| ## | example | image | developer | new |
|
||||
|----|----------|--------|:----------:|:---:|
|
||||
| 83 | [shaders_basic_lighting](shaders/shaders_basic_lighting.c) | <img src="shaders/shaders_basic_lighting.png" alt="shaders_basic_lighting" width="200"> | [Chris Camacho](https://github.com/codifies) | ⭐️ |
|
||||
| 84 | [shaders_model_shader](shaders/shaders_model_shader.c) | <img src="shaders/shaders_model_shader.png" alt="shaders_model_shader" width="200"> | ray | |
|
||||
| 85 | [shaders_shapes_textures](shaders/shaders_shapes_textures.c) | <img src="shaders/shaders_shapes_textures.png" alt="shaders_shapes_textures" width="200"> | ray | |
|
||||
| 86 | [shaders_custom_uniform](shaders/shaders_custom_uniform.c) | <img src="shaders/shaders_custom_uniform.png" alt="shaders_custom_uniform" width="200"> | ray | |
|
||||
| 87 | [shaders_postprocessing](shaders/shaders_postprocessing.c) | <img src="shaders/shaders_postprocessing.png" alt="shaders_postprocessing" width="200"> | ray | |
|
||||
| 88 | [shaders_palette_switch](shaders/shaders_palette_switch.c) | <img src="shaders/shaders_palette_switch.png" alt="shaders_palette_switch" width="200"> | [Marco Lizza](https://github.com/MarcoLizza) | |
|
||||
| 89 | [shaders_raymarching](shaders/shaders_raymarching.c) | <img src="shaders/shaders_raymarching.png" alt="shaders_raymarching" width="200"> | Shader by Iñigo Quilez | ⭐️ |
|
||||
| 90 | [shaders_texture_drawing](shaders/shaders_texture_drawing.c) | <img src="shaders/shaders_texture_drawing.png" alt="shaders_texture_drawing" width="200"> | Michał Ciesielski | ⭐️ |
|
||||
| 91 | [shaders_texture_waves](shaders/shaders_texture_waves.c) | <img src="shaders/shaders_texture_waves.png" alt="shaders_texture_waves" width="200"> | [Anata](https://github.com/anatagawa) | ⭐️ |
|
||||
| 92 | [shaders_julia_set](shaders/shaders_julia_set.c) | <img src="shaders/shaders_julia_set.png" alt="shaders_julia_set" width="200"> | [eggmund](https://github.com/eggmund) | ⭐️ |
|
||||
| 93 | [shaders_eratosthenes](shaders/shaders_eratosthenes.c) | <img src="shaders/shaders_eratosthenes.png" alt="shaders_eratosthenes" width="200"> | [ProfJski](https://github.com/ProfJski) | ⭐️ |
|
||||
| 94 | [shaders_fog](shaders/shaders_fog.c) | <img src="shaders/shaders_fog.png" alt="shaders_fog" width="200"> | [Chris Camacho](https://github.com/codifies) | ⭐️ |
|
||||
| 95 | [shaders_simple_mask](shaders/shaders_simple_mask.c) | <img src="shaders/shaders_simple_mask.png" alt="shaders_simple_mask" width="200"> | [Chris Camacho](https://github.com/codifies) | ⭐️ |
|
||||
|
||||
### category: audio
|
||||
|
||||
Examples using raylib audio functionality, including sound/music loading and playing. This functionality is provided by raylib [raudio](../src/raudio.c) module. Note this module can be used standalone independently of raylib, check [raudio_standalone](others/raudio_standalone.c) example.
|
||||
|
||||
| ## | example | image | developer | new |
|
||||
|----|----------|--------|:----------:|:---:|
|
||||
| 96 | [audio_module_playing](audio/audio_module_playing.c) | <img src="audio/audio_module_playing.png" alt="audio_module_playing" width="200"> | ray | |
|
||||
| 97 | [audio_music_stream](audio/audio_music_stream.c) | <img src="audio/audio_music_stream.png" alt="audio_music_stream" width="200"> | ray | |
|
||||
| 98 | [audio_raw_stream](audio/audio_raw_stream.c) | <img src="audio/audio_raw_stream.png" alt="audio_raw_stream" width="200"> | ray | |
|
||||
| 99 | [audio_sound_loading](audio/audio_sound_loading.c) | <img src="audio/audio_sound_loading.png" alt="audio_sound_loading" width="200"> | ray | |
|
||||
| 100 | [audio_multichannel_sound](audio/audio_multichannel_sound.c) | <img src="audio/audio_multichannel_sound.png" alt="audio_multichannel_sound" width="200"> | [Chris Camacho](https://github.com/codifies) | ⭐️ |
|
||||
|
||||
### category: physics
|
||||
|
||||
Examples showing physics functionality with raylib. This functionality is provided by [physac](https://github.com/victorfisac/Physac) library, included with raylib [sources](../src/physac.h). Note this library is not linked with raylib by default, it should be manually included in user code.
|
||||
|
||||
| ## | example | image | developer | new |
|
||||
|----|----------|--------|:----------:|:---:|
|
||||
| 101 | [physics_demo](physics/physics_demo.c) | <img src="physics/physics_demo.png" alt="physics_demo" width="200"> | [Victor Fisac](https://github.com/victorfisac) | |
|
||||
| 102 | [physics_friction](physics/physics_friction.c) | <img src="physics/physics_friction.png" alt="physics_friction" width="200"> | [Victor Fisac](https://github.com/victorfisac) | |
|
||||
| 103 | [physics_movement](physics/physics_movement.c) | <img src="physics/physics_movement.png" alt="physics_movement" width="200"> | [Victor Fisac](https://github.com/victorfisac) | |
|
||||
| 104 | [physics_restitution](physics/physics_restitution.c) | <img src="physics/physics_restitution.png" alt="physics_restitution" width="200"> | [Victor Fisac](https://github.com/victorfisac) | |
|
||||
| 105 | [physics_shatter](physics/physics_shatter.c) | <img src="physics/physics_shatter.png" alt="physics_shatter" width="200"> | [Victor Fisac](https://github.com/victorfisac) | |
|
||||
|
||||
### category: network
|
||||
|
||||
Examples showing raylib network functionality. This functionality is provided by [rnet](../src/rnet.h) module.
|
||||
|
||||
**Note that rnet module is under development and not ready yet.**
|
||||
|
||||
| ## | example | image | developer | new |
|
||||
|----|----------|--------|:----------:|:---:|
|
||||
| 106 | [network_ping_pong](network/network_ping_pong.c) | | [Jak Barnes](https://github.com/syphonx) | |
|
||||
| 107 | [network_resolve_host](network/network_resolve_host.c) | | [Jak Barnes](https://github.com/syphonx) | |
|
||||
| 108 | [network_tcp_client](network/network_tcp_client.c) | | [Jak Barnes](https://github.com/syphonx) | |
|
||||
| 109 | [network_tcp_server](network/network_tcp_server.c) | | [Jak Barnes](https://github.com/syphonx) | |
|
||||
| 110 | [network_test](network/network_test.c) | | [Jak Barnes](https://github.com/syphonx) | |
|
||||
| 111 | [network_udp_client](network/network_udp_client.c) | | [Jak Barnes](https://github.com/syphonx) | |
|
||||
| 112 | [network_udp_server](network/network_udp_server.c) | | [Jak Barnes](https://github.com/syphonx) | |
|
||||
|
||||
### category: others
|
||||
|
||||
Examples showing raylib misc functionality that does not fit in other categories, like standalone modules usage or examples integrating external libraries.
|
||||
|
||||
| ## | example | image | developer | new |
|
||||
|----|----------|--------|:----------:|:---:|
|
||||
| 113 | [raudio_standalone](others/raudio_standalone.c) | | ray | |
|
||||
| 114 | [rlgl_standalone](others/rlgl_standalone.c) | | ray | |
|
||||
| 115 | [easings_testbed](others/easings_testbed.c) | | ray | |
|
||||
|
||||
As always contributions are welcome, feel free to send new examples! Here it is an [examples template](examples_template.c) to start with!
|
||||
|
@@ -2,8 +2,6 @@
|
||||
*
|
||||
* raylib [audio] example - Module playing (streaming)
|
||||
*
|
||||
* NOTE: This example requires OpenAL Soft library installed
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
@@ -48,13 +46,13 @@ int main(void)
|
||||
circles[i].radius = GetRandomValue(10, 40);
|
||||
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius);
|
||||
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius);
|
||||
circles[i].speed = (float)GetRandomValue(1, 100)/20000.0f;
|
||||
circles[i].speed = (float)GetRandomValue(1, 100)/2000.0f;
|
||||
circles[i].color = colors[GetRandomValue(0, 13)];
|
||||
}
|
||||
|
||||
Music xm = LoadMusicStream("resources/chiptun1.mod");
|
||||
Music music = LoadMusicStream("resources/mini1111.xm");
|
||||
|
||||
PlayMusicStream(xm);
|
||||
PlayMusicStream(music);
|
||||
|
||||
float timePlayed = 0.0f;
|
||||
bool pause = false;
|
||||
@@ -67,13 +65,13 @@ int main(void)
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateMusicStream(xm); // Update music buffer with new stream data
|
||||
UpdateMusicStream(music); // Update music buffer with new stream data
|
||||
|
||||
// Restart music playing (stop and play)
|
||||
if (IsKeyPressed(KEY_SPACE))
|
||||
{
|
||||
StopMusicStream(xm);
|
||||
PlayMusicStream(xm);
|
||||
StopMusicStream(music);
|
||||
PlayMusicStream(music);
|
||||
}
|
||||
|
||||
// Pause/Resume music playing
|
||||
@@ -81,12 +79,12 @@ int main(void)
|
||||
{
|
||||
pause = !pause;
|
||||
|
||||
if (pause) PauseMusicStream(xm);
|
||||
else ResumeMusicStream(xm);
|
||||
if (pause) PauseMusicStream(music);
|
||||
else ResumeMusicStream(music);
|
||||
}
|
||||
|
||||
// Get timePlayed scaled to bar dimensions
|
||||
timePlayed = GetMusicTimePlayed(xm)/GetMusicTimeLength(xm)*(screenWidth - 40);
|
||||
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*(screenWidth - 40);
|
||||
|
||||
// Color circles animation
|
||||
for (int i = MAX_CIRCLES - 1; (i >= 0) && !pause; i--)
|
||||
@@ -103,7 +101,7 @@ int main(void)
|
||||
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius);
|
||||
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius);
|
||||
circles[i].color = colors[GetRandomValue(0, 13)];
|
||||
circles[i].speed = (float)GetRandomValue(1, 100)/20000.0f;
|
||||
circles[i].speed = (float)GetRandomValue(1, 100)/2000.0f;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
@@ -130,7 +128,7 @@ int main(void)
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadMusicStream(xm); // Unload music stream buffers from RAM
|
||||
UnloadMusicStream(music); // Unload music stream buffers from RAM
|
||||
|
||||
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
||||
|
||||
|
73
examples/audio/audio_multichannel_sound.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [audio] example - Multichannel sound playing
|
||||
*
|
||||
* This example has been created using raylib 2.6 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Example contributed by Chris Camacho (@codifies) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Copyright (c) 2019 Chris Camacho (@codifies) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - Multichannel sound playing");
|
||||
|
||||
InitAudioDevice(); // Initialize audio device
|
||||
|
||||
Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file
|
||||
Sound fxOgg = LoadSound("resources/tanatana.ogg"); // Load OGG audio file
|
||||
|
||||
SetSoundVolume(fxWav, 0.2);
|
||||
|
||||
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_ENTER)) PlaySoundMulti(fxWav); // Play a new wav sound instance
|
||||
if (IsKeyPressed(KEY_SPACE)) PlaySoundMulti(fxOgg); // Play a new ogg sound instance
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText("MULTICHANNEL SOUND PLAYING", 20, 20, 20, GRAY);
|
||||
DrawText("Press SPACE to play new ogg instance!", 200, 120, 20, LIGHTGRAY);
|
||||
DrawText("Press ENTER to play new wav instance!", 200, 180, 20, LIGHTGRAY);
|
||||
|
||||
DrawText(FormatText("CONCURRENT SOUNDS PLAYING: %02i", GetSoundsPlaying()), 220, 280, 20, RED);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
StopSoundMulti(); // We must stop the buffer pool before unloading
|
||||
|
||||
UnloadSound(fxWav); // Unload sound data
|
||||
UnloadSound(fxOgg); // Unload sound data
|
||||
|
||||
CloseAudioDevice(); // Close audio device
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/audio/audio_multichannel_sound.png
Normal file
After Width: | Height: | Size: 16 KiB |
@@ -2,8 +2,6 @@
|
||||
*
|
||||
* raylib [audio] example - Music playing (streaming)
|
||||
*
|
||||
* NOTE: This example requires OpenAL Soft library installed
|
||||
*
|
||||
* This example has been created using raylib 1.3 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
|
@@ -2,11 +2,11 @@
|
||||
*
|
||||
* raylib [audio] example - Raw audio streaming
|
||||
*
|
||||
* NOTE: This example requires OpenAL Soft library installed
|
||||
*
|
||||
* This example has been created using raylib 1.6 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Example created by Ramon Santamaria (@raysan5) and reviewed by James Hofmann (@triplefox)
|
||||
*
|
||||
* Copyright (c) 2015-2019 Ramon Santamaria (@raysan5) and James Hofmann (@triplefox)
|
||||
*
|
||||
********************************************************************************************/
|
||||
@@ -99,7 +99,7 @@ int main(void)
|
||||
}
|
||||
|
||||
// Refill audio stream if required
|
||||
if (IsAudioBufferProcessed(stream))
|
||||
if (IsAudioStreamProcessed(stream))
|
||||
{
|
||||
// Synthesize a buffer that is exactly the requested size
|
||||
int writeCursor = 0;
|
||||
|
@@ -2,8 +2,6 @@
|
||||
*
|
||||
* raylib [audio] example - Sound loading and playing
|
||||
*
|
||||
* NOTE: This example requires OpenAL Soft library installed
|
||||
*
|
||||
* This example has been created using raylib 1.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
|
@@ -42,7 +42,7 @@ int main(void)
|
||||
|
||||
Camera2D camera = { 0 };
|
||||
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
||||
camera.offset = (Vector2){ 0, 0 };
|
||||
camera.offset = (Vector2){ screenWidth/2, screenHeight/2 };
|
||||
camera.rotation = 0.0f;
|
||||
camera.zoom = 1.0f;
|
||||
|
||||
@@ -54,16 +54,10 @@ int main(void)
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyDown(KEY_RIGHT))
|
||||
{
|
||||
player.x += 2; // Player movement
|
||||
camera.offset.x -= 2; // Camera displacement with player movement
|
||||
}
|
||||
else if (IsKeyDown(KEY_LEFT))
|
||||
{
|
||||
player.x -= 2; // Player movement
|
||||
camera.offset.x += 2; // Camera displacement with player movement
|
||||
}
|
||||
|
||||
// Player movement
|
||||
if (IsKeyDown(KEY_RIGHT)) player.x += 2;
|
||||
else if (IsKeyDown(KEY_LEFT)) player.x -= 2;
|
||||
|
||||
// Camera target follows player
|
||||
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
||||
|
293
examples/core/core_2d_camera_platformer.c
Normal file
@@ -0,0 +1,293 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - 2d camera platformer
|
||||
*
|
||||
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Example contributed by arvyy (@arvyy) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Copyright (c) 2019 arvyy (@arvyy)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
#include "raymath.h"
|
||||
|
||||
#define G 400
|
||||
#define PLAYER_JUMP_SPD 350.f
|
||||
#define PLAYER_HOR_SPD 200.f
|
||||
|
||||
typedef struct Player {
|
||||
Vector2 position;
|
||||
float speed;
|
||||
bool canJump;
|
||||
} Player;
|
||||
|
||||
typedef struct EnvItem {
|
||||
Rectangle rect;
|
||||
int blocking;
|
||||
Color color;
|
||||
} EnvItem;
|
||||
|
||||
|
||||
void UpdatePlayer(Player *player, EnvItem *envItems, int envItemsLength, float delta);
|
||||
|
||||
void UpdateCameraCenter(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
|
||||
void UpdateCameraCenterInsideMap(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
|
||||
void UpdateCameraCenterSmoothFollow(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
|
||||
void UpdateCameraEvenOutOnLanding(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
|
||||
void UpdateCameraPlayerBoundsPush(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera");
|
||||
|
||||
Player player = { 0 };
|
||||
player.position = (Vector2){ 400, 280 };
|
||||
player.speed = 0;
|
||||
player.canJump = false;
|
||||
EnvItem envItems[] = {
|
||||
{{ 0, 0, 1000, 400 }, 0, LIGHTGRAY },
|
||||
{{ 0, 400, 1000, 200 }, 1, GRAY },
|
||||
{{ 300, 200, 400, 10 }, 1, GRAY },
|
||||
{{ 250, 300, 100, 10 }, 1, GRAY },
|
||||
{{ 650, 300, 100, 10 }, 1, GRAY }
|
||||
};
|
||||
|
||||
int envItemsLength = sizeof(envItems)/sizeof(envItems[0]);
|
||||
|
||||
Camera2D camera = { 0 };
|
||||
camera.target = player.position;
|
||||
camera.offset = (Vector2){ screenWidth/2, screenHeight/2 };
|
||||
camera.rotation = 0.0f;
|
||||
camera.zoom = 1.0f;
|
||||
|
||||
// Store pointers to the multiple update camera functions
|
||||
void (*cameraUpdaters[])(Camera2D*, Player*, EnvItem*, int, float, int, int) = {
|
||||
UpdateCameraCenter,
|
||||
UpdateCameraCenterInsideMap,
|
||||
UpdateCameraCenterSmoothFollow,
|
||||
UpdateCameraEvenOutOnLanding,
|
||||
UpdateCameraPlayerBoundsPush
|
||||
};
|
||||
|
||||
int cameraOption = 0;
|
||||
int cameraUpdatersLength = sizeof(cameraUpdaters)/sizeof(cameraUpdaters[0]);
|
||||
|
||||
char *cameraDescriptions[] = {
|
||||
"Follow player center",
|
||||
"Follow player center, but clamp to map edges",
|
||||
"Follow player center; smoothed",
|
||||
"Follow player center horizontally; updateplayer center vertically after landing",
|
||||
"Player push camera on getting too close to screen edge"
|
||||
};
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
float deltaTime = GetFrameTime();
|
||||
|
||||
UpdatePlayer(&player, envItems, envItemsLength, deltaTime);
|
||||
|
||||
camera.zoom += ((float)GetMouseWheelMove()*0.05f);
|
||||
|
||||
if (camera.zoom > 3.0f) camera.zoom = 3.0f;
|
||||
else if (camera.zoom < 0.25f) camera.zoom = 0.25f;
|
||||
|
||||
if (IsKeyPressed(KEY_R))
|
||||
{
|
||||
camera.zoom = 1.0f;
|
||||
player.position = (Vector2){ 400, 280 };
|
||||
}
|
||||
|
||||
if (IsKeyPressed(KEY_C)) cameraOption = (cameraOption + 1)%cameraUpdatersLength;
|
||||
|
||||
// Call update camera function by its pointer
|
||||
cameraUpdaters[cameraOption](&camera, &player, envItems, envItemsLength, deltaTime, screenWidth, screenHeight);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(LIGHTGRAY);
|
||||
|
||||
BeginMode2D(camera);
|
||||
|
||||
for (int i = 0; i < envItemsLength; i++) DrawRectangleRec(envItems[i].rect, envItems[i].color);
|
||||
|
||||
Rectangle playerRect = { player.position.x - 20, player.position.y - 40, 40, 40 };
|
||||
DrawRectangleRec(playerRect, RED);
|
||||
|
||||
EndMode2D();
|
||||
|
||||
DrawText("Controls:", 20, 20, 10, BLACK);
|
||||
DrawText("- Right/Left to move", 40, 40, 10, DARKGRAY);
|
||||
DrawText("- Space to jump", 40, 60, 10, DARKGRAY);
|
||||
DrawText("- Mouse Wheel to Zoom in-out, R to reset zoom", 40, 80, 10, DARKGRAY);
|
||||
DrawText("- C to change camera mode", 40, 100, 10, DARKGRAY);
|
||||
DrawText("Current camera mode:", 20, 120, 10, BLACK);
|
||||
DrawText(cameraDescriptions[cameraOption], 40, 140, 10, DARKGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void UpdatePlayer(Player *player, EnvItem *envItems, int envItemsLength, float delta)
|
||||
{
|
||||
if (IsKeyDown(KEY_LEFT)) player->position.x -= PLAYER_HOR_SPD*delta;
|
||||
if (IsKeyDown(KEY_RIGHT)) player->position.x += PLAYER_HOR_SPD*delta;
|
||||
if (IsKeyDown(KEY_SPACE) && player->canJump)
|
||||
{
|
||||
player->speed = -PLAYER_JUMP_SPD;
|
||||
player->canJump = false;
|
||||
}
|
||||
|
||||
int hitObstacle = 0;
|
||||
for (int i = 0; i < envItemsLength; i++)
|
||||
{
|
||||
EnvItem *ei = envItems + i;
|
||||
Vector2 *p = &(player->position);
|
||||
if (ei->blocking &&
|
||||
ei->rect.x <= p->x &&
|
||||
ei->rect.x + ei->rect.width >= p->x &&
|
||||
ei->rect.y >= p->y &&
|
||||
ei->rect.y < p->y + player->speed*delta)
|
||||
{
|
||||
hitObstacle = 1;
|
||||
player->speed = 0.0f;
|
||||
p->y = ei->rect.y;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hitObstacle)
|
||||
{
|
||||
player->position.y += player->speed*delta;
|
||||
player->speed += G*delta;
|
||||
player->canJump = false;
|
||||
}
|
||||
else player->canJump = true;
|
||||
}
|
||||
|
||||
void UpdateCameraCenter(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height)
|
||||
{
|
||||
camera->offset = (Vector2){ width/2, height/2 };
|
||||
camera->target = player->position;
|
||||
}
|
||||
|
||||
void UpdateCameraCenterInsideMap(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height)
|
||||
{
|
||||
camera->target = player->position;
|
||||
camera->offset = (Vector2){ width/2, height/2 };
|
||||
float minX = 1000, minY = 1000, maxX = -1000, maxY = -1000;
|
||||
|
||||
for (int i = 0; i < envItemsLength; i++)
|
||||
{
|
||||
EnvItem *ei = envItems + i;
|
||||
minX = fminf(ei->rect.x, minX);
|
||||
maxX = fmaxf(ei->rect.x + ei->rect.width, maxX);
|
||||
minY = fminf(ei->rect.y, minY);
|
||||
maxY = fmaxf(ei->rect.y + ei->rect.height, maxY);
|
||||
}
|
||||
|
||||
Vector2 max = GetWorldToScreen2D((Vector2){ maxX, maxY }, *camera);
|
||||
Vector2 min = GetWorldToScreen2D((Vector2){ minX, minY }, *camera);
|
||||
|
||||
if (max.x < width) camera->offset.x = width - (max.x - width/2);
|
||||
if (max.y < height) camera->offset.y = height - (max.y - height/2);
|
||||
if (min.x > 0) camera->offset.x = width/2 - min.x;
|
||||
if (min.y > 0) camera->offset.y = height/2 - min.y;
|
||||
}
|
||||
|
||||
void UpdateCameraCenterSmoothFollow(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height)
|
||||
{
|
||||
static float minSpeed = 30;
|
||||
static float minEffectLength = 10;
|
||||
static float fractionSpeed = 0.8f;
|
||||
|
||||
camera->offset = (Vector2){ width/2, height/2 };
|
||||
Vector2 diff = Vector2Subtract(player->position, camera->target);
|
||||
float length = Vector2Length(diff);
|
||||
|
||||
if (length > minEffectLength)
|
||||
{
|
||||
float speed = fmaxf(fractionSpeed*length, minSpeed);
|
||||
camera->target = Vector2Add(camera->target, Vector2Scale(diff, speed*delta/length));
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateCameraEvenOutOnLanding(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height)
|
||||
{
|
||||
static float evenOutSpeed = 700;
|
||||
static int eveningOut = false;
|
||||
static float evenOutTarget;
|
||||
|
||||
camera->offset = (Vector2){ width/2, height/2 };
|
||||
camera->target.x = player->position.x;
|
||||
|
||||
if (eveningOut)
|
||||
{
|
||||
if (evenOutTarget > camera->target.y)
|
||||
{
|
||||
camera->target.y += evenOutSpeed*delta;
|
||||
|
||||
if (camera->target.y > evenOutTarget)
|
||||
{
|
||||
camera->target.y = evenOutTarget;
|
||||
eveningOut = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
camera->target.y -= evenOutSpeed*delta;
|
||||
|
||||
if (camera->target.y < evenOutTarget)
|
||||
{
|
||||
camera->target.y = evenOutTarget;
|
||||
eveningOut = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player->canJump && (player->speed == 0) && (player->position.y != camera->target.y))
|
||||
{
|
||||
eveningOut = 1;
|
||||
evenOutTarget = player->position.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateCameraPlayerBoundsPush(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height)
|
||||
{
|
||||
static Vector2 bbox = { 0.2f, 0.2f };
|
||||
|
||||
Vector2 bboxWorldMin = GetScreenToWorld2D((Vector2){ (1 - bbox.x)*0.5f*width, (1 - bbox.y)*0.5f*height }, *camera);
|
||||
Vector2 bboxWorldMax = GetScreenToWorld2D((Vector2){ (1 + bbox.x)*0.5f*width, (1 + bbox.y)*0.5f*height }, *camera);
|
||||
camera->offset = (Vector2){ (1 - bbox.x)*0.5f * width, (1 - bbox.y)*0.5f*height };
|
||||
|
||||
if (player->position.x < bboxWorldMin.x) camera->target.x = player->position.x;
|
||||
if (player->position.y < bboxWorldMin.y) camera->target.y = player->position.y;
|
||||
if (player->position.x > bboxWorldMax.x) camera->target.x = bboxWorldMin.x + (player->position.x - bboxWorldMax.x);
|
||||
if (player->position.y > bboxWorldMax.y) camera->target.y = bboxWorldMin.y + (player->position.y - bboxWorldMax.y);
|
||||
}
|
BIN
examples/core/core_2d_camera_platformer.png
Normal file
After Width: | Height: | Size: 16 KiB |
@@ -4,18 +4,19 @@
|
||||
*
|
||||
* Welcome to raylib!
|
||||
*
|
||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
||||
* To test examples in Notepad++, provided with default raylib installer package,
|
||||
* just press F6 and run [raylib_compile_execute] script, it will compile and execute.
|
||||
* Note that compiled executable is placed in the same folder as .c file
|
||||
*
|
||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
||||
* raylib official webpage: www.raylib.com
|
||||
* You can find all basic examples on [C:\raylib\raylib\examples] directory and
|
||||
* raylib official webpage: [www.raylib.com]
|
||||
*
|
||||
* Enjoy using raylib. :)
|
||||
*
|
||||
* This example has been created using raylib 1.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2013-2020 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
71
examples/core/core_scissor_test.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - Scissor test
|
||||
*
|
||||
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Example contributed by Chris Dill (@MysteriousSpace) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Copyright (c) 2019 Chris Dill (@MysteriousSpace)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - scissor test");
|
||||
|
||||
Rectangle scissorArea = { 0, 0, 300, 300 };
|
||||
bool scissorMode = true;
|
||||
|
||||
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_S)) scissorMode = !scissorMode;
|
||||
|
||||
// Centre the scissor area around the mouse position
|
||||
scissorArea.x = GetMouseX() - scissorArea.width/2;
|
||||
scissorArea.y = GetMouseY() - scissorArea.height/2;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
if (scissorMode) BeginScissorMode(scissorArea.x, scissorArea.y, scissorArea.width, scissorArea.height);
|
||||
|
||||
// Draw full screen rectangle and some text
|
||||
// NOTE: Only part defined by scissor area will be rendered
|
||||
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), RED);
|
||||
DrawText("Move the mouse around to reveal this text!", 190, 200, 20, LIGHTGRAY);
|
||||
|
||||
if (scissorMode) EndScissorMode();
|
||||
|
||||
DrawRectangleLinesEx(scissorArea, 1, BLACK);
|
||||
DrawText("Press S to toggle scissor test", 10, 10, 20, BLACK);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/core/core_scissor_test.png
Normal file
After Width: | Height: | Size: 15 KiB |
@@ -12,7 +12,10 @@
|
||||
#include "raylib.h"
|
||||
|
||||
// NOTE: Storage positions must start with 0, directly related to file memory layout
|
||||
typedef enum { STORAGE_SCORE = 0, STORAGE_HISCORE } StorageData;
|
||||
typedef enum {
|
||||
STORAGE_POSITION_SCORE = 0,
|
||||
STORAGE_POSITION_HISCORE = 1
|
||||
} StorageData;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
@@ -43,14 +46,14 @@ int main(void)
|
||||
|
||||
if (IsKeyPressed(KEY_ENTER))
|
||||
{
|
||||
StorageSaveValue(STORAGE_SCORE, score);
|
||||
StorageSaveValue(STORAGE_HISCORE, hiscore);
|
||||
SaveStorageValue(STORAGE_POSITION_SCORE, score);
|
||||
SaveStorageValue(STORAGE_POSITION_HISCORE, hiscore);
|
||||
}
|
||||
else if (IsKeyPressed(KEY_SPACE))
|
||||
{
|
||||
// NOTE: If requested position could not be found, value 0 is returned
|
||||
score = StorageLoadValue(STORAGE_SCORE);
|
||||
hiscore = StorageLoadValue(STORAGE_HISCORE);
|
||||
score = LoadStorageValue(STORAGE_POSITION_SCORE);
|
||||
hiscore = LoadStorageValue(STORAGE_POSITION_HISCORE);
|
||||
}
|
||||
|
||||
framesCounter++;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - window scale letterbox
|
||||
* raylib [core] example - window scale letterbox (and virtual mouse)
|
||||
*
|
||||
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
@@ -16,6 +16,18 @@
|
||||
#define max(a, b) ((a)>(b)? (a) : (b))
|
||||
#define min(a, b) ((a)<(b)? (a) : (b))
|
||||
|
||||
// Clamp Vector2 value with min and max and return a new vector2
|
||||
// NOTE: Required for virtual mouse, to clamp inside virtual game size
|
||||
Vector2 ClampValue(Vector2 value, Vector2 min, Vector2 max)
|
||||
{
|
||||
Vector2 result = value;
|
||||
result.x = (result.x > max.x)? max.x : result.x;
|
||||
result.x = (result.x < min.x)? min.x : result.x;
|
||||
result.y = (result.y > max.y)? max.y : result.y;
|
||||
result.y = (result.y < min.y)? min.y : result.y;
|
||||
return result;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const int windowWidth = 800;
|
||||
@@ -29,7 +41,7 @@ int main(void)
|
||||
int gameScreenWidth = 640;
|
||||
int gameScreenHeight = 480;
|
||||
|
||||
// Render texture initialization
|
||||
// Render texture initialization, used to hold the rendering result so we can easily resize it
|
||||
RenderTexture2D target = LoadRenderTexture(gameScreenWidth, gameScreenHeight);
|
||||
SetTextureFilter(target.texture, FILTER_BILINEAR); // Texture scale filter to use
|
||||
|
||||
@@ -52,6 +64,13 @@ int main(void)
|
||||
// Recalculate random colors for the bars
|
||||
for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 };
|
||||
}
|
||||
|
||||
// Update virtual mouse (clamped mouse value behind game screen)
|
||||
Vector2 mouse = GetMousePosition();
|
||||
Vector2 virtualMouse = { 0 };
|
||||
virtualMouse.x = (mouse.x - (GetScreenWidth() - (gameScreenWidth*scale))*0.5f)/scale;
|
||||
virtualMouse.y = (mouse.y - (GetScreenHeight() - (gameScreenHeight*scale))*0.5f)/scale;
|
||||
virtualMouse = ClampValue(virtualMouse, (Vector2){ 0, 0 }, (Vector2){ gameScreenWidth, gameScreenHeight });
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
@@ -59,14 +78,17 @@ int main(void)
|
||||
BeginDrawing();
|
||||
ClearBackground(BLACK);
|
||||
|
||||
// Draw everything in the render texture
|
||||
// Draw everything in the render texture, note this will not be rendered on screen, yet
|
||||
BeginTextureMode(target);
|
||||
|
||||
ClearBackground(RAYWHITE); // Clear render texture background color
|
||||
|
||||
for (int i = 0; i < 10; i++) DrawRectangle(0, (gameScreenHeight/10)*i, gameScreenWidth, gameScreenHeight/10, colors[i]);
|
||||
|
||||
DrawText("You can resize the window,\nand see the screen scaling!", 10, 25, 20, WHITE);
|
||||
DrawText("If executed inside a window,\nyou can resize the window,\nand see the screen scaling!", 10, 25, 20, WHITE);
|
||||
|
||||
DrawText(TextFormat("Default Mouse: [%i , %i]", (int)mouse.x, (int)mouse.y), 350, 25, 20, GREEN);
|
||||
DrawText(TextFormat("Virtual Mouse: [%i , %i]", (int)virtualMouse.x, (int)virtualMouse.y), 350, 55, 20, YELLOW);
|
||||
|
||||
EndTextureMode();
|
||||
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 23 KiB |
@@ -11,14 +11,14 @@ uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
uniform vec2 leftLensCenter = vec2(0.288, 0.5);
|
||||
uniform vec2 rightLensCenter = vec2(0.712, 0.5);
|
||||
uniform vec2 leftScreenCenter = vec2(0.25, 0.5);
|
||||
uniform vec2 rightScreenCenter = vec2(0.75, 0.5);
|
||||
uniform vec2 scale = vec2(0.25, 0.45);
|
||||
uniform vec2 scaleIn = vec2(4, 2.2222);
|
||||
uniform vec4 hmdWarpParam = vec4(1, 0.22, 0.24, 0);
|
||||
uniform vec4 chromaAbParam = vec4(0.996, -0.004, 1.014, 0.0);
|
||||
uniform vec2 leftLensCenter;
|
||||
uniform vec2 rightLensCenter;
|
||||
uniform vec2 leftScreenCenter;
|
||||
uniform vec2 rightScreenCenter;
|
||||
uniform vec2 scale;
|
||||
uniform vec2 scaleIn;
|
||||
uniform vec4 hmdWarpParam;
|
||||
uniform vec4 chromaAbParam;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
@@ -5,10 +5,19 @@
|
||||
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2019 Ramon Santamaria (@raysan5) and @culacant
|
||||
* Example contributed by Culacant (@culacant) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Copyright (c) 2019 Culacant (@culacant) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************
|
||||
*
|
||||
* To export a model from blender, make sure it is not posed, the vertices need to be in the
|
||||
* same position as they would be in edit mode.
|
||||
* and that the scale of your models is set to 0. Scaling can be done from the export menu.
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "raylib.h"
|
||||
|
||||
int main(void)
|
||||
@@ -28,7 +37,6 @@ int main(void)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.type = CAMERA_PERSPECTIVE; // Camera mode type
|
||||
|
||||
|
||||
Model model = LoadModel("resources/guy/guy.iqm"); // Load the animated model mesh and basic data
|
||||
Texture2D texture = LoadTexture("resources/guy/guytex.png"); // Load model texture and set material
|
||||
SetMaterialTexture(&model.materials[0], MAP_DIFFUSE, texture); // Set model material map texture
|
||||
@@ -89,8 +97,11 @@ int main(void)
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Unload texture
|
||||
|
||||
// Unload model animations data
|
||||
for (int i = 0; i < animsCount; i++) UnloadModelAnimation(anims[i]);
|
||||
RL_FREE(anims);
|
||||
|
||||
UnloadModel(model); // Unload model
|
||||
|
||||
|
@@ -21,7 +21,7 @@ int main(void)
|
||||
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, 0 };
|
||||
Camera camera = { { 18.0f, 18.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)
|
||||
|
142
examples/models/models_loading.c
Normal file
@@ -0,0 +1,142 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [models] example - Models loading
|
||||
*
|
||||
* raylib supports multiple models file formats:
|
||||
*
|
||||
* - OBJ > Text file, must include vertex position-texcoords-normals information,
|
||||
* if files references some .mtl materials file, it will be loaded (or try to)
|
||||
* - GLTF > Modern text/binary file format, includes lot of information and it could
|
||||
* also reference external files, raylib will try loading mesh and materials data
|
||||
* - IQM > Binary file format including mesh vertex data but also animation data,
|
||||
* raylib can load .iqm animations.
|
||||
*
|
||||
* This example has been created using raylib 2.6 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - models loading");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 50.0f, 50.0f, 50.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 10.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
|
||||
|
||||
Model model = LoadModel("resources/models/castle.obj"); // Load model
|
||||
Texture2D texture = LoadTexture("resources/models/castle_diffuse.png"); // Load model texture
|
||||
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
|
||||
BoundingBox bounds = MeshBoundingBox(model.meshes[0]); // Set model bounds
|
||||
|
||||
// NOTE: bounds are calculated from the original size of the model,
|
||||
// if model is scaled on drawing, bounds must be also scaled
|
||||
|
||||
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
||||
|
||||
bool selected = false; // Selected object flag
|
||||
|
||||
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);
|
||||
|
||||
// Load new models/textures on drag&drop
|
||||
if (IsFileDropped())
|
||||
{
|
||||
int count = 0;
|
||||
char **droppedFiles = GetDroppedFiles(&count);
|
||||
|
||||
if (count == 1) // Only support one file dropped
|
||||
{
|
||||
if (IsFileExtension(droppedFiles[0], ".obj") ||
|
||||
IsFileExtension(droppedFiles[0], ".gltf") ||
|
||||
IsFileExtension(droppedFiles[0], ".iqm")) // Model file formats supported
|
||||
{
|
||||
UnloadModel(model); // Unload previous model
|
||||
model = LoadModel(droppedFiles[0]); // Load new model
|
||||
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set current map diffuse texture
|
||||
|
||||
bounds = MeshBoundingBox(model.meshes[0]);
|
||||
|
||||
// TODO: Move camera position from target enough distance to visualize model properly
|
||||
}
|
||||
else if (IsFileExtension(droppedFiles[0], ".png")) // Texture file formats supported
|
||||
{
|
||||
// Unload current model texture and load new one
|
||||
UnloadTexture(texture);
|
||||
texture = LoadTexture(droppedFiles[0]);
|
||||
model.materials[0].maps[MAP_DIFFUSE].texture = texture;
|
||||
}
|
||||
}
|
||||
|
||||
ClearDroppedFiles(); // Clear internal buffers
|
||||
}
|
||||
|
||||
// Select model on mouse click
|
||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||
{
|
||||
// Check collision between ray and box
|
||||
if (CheckCollisionRayBox(GetMouseRay(GetMousePosition(), camera), bounds)) selected = !selected;
|
||||
else selected = false;
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModel(model, position, 1.0f, WHITE); // Draw 3d model with texture
|
||||
|
||||
DrawGrid(20, 10.0f); // Draw a grid
|
||||
|
||||
if (selected) DrawBoundingBox(bounds, GREEN); // Draw selection box
|
||||
|
||||
EndMode3D();
|
||||
|
||||
DrawText("Drag & drop model to load mesh/texture.", 10, GetScreenHeight() - 20, 10, DARKGRAY);
|
||||
if (selected) DrawText("MODEL SELECTED", GetScreenWidth() - 110, 10, 10, GREEN);
|
||||
|
||||
DrawText("(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Unload texture
|
||||
UnloadModel(model); // Unload model
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/models/models_loading.png
Normal file
After Width: | Height: | Size: 217 KiB |
@@ -2,6 +2,9 @@
|
||||
*
|
||||
* raylib [models] example - PBR material
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 for shaders support and only #version 330
|
||||
* is currently supported. OpenGL ES 2.0 platforms are not supported at the moment.
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
@@ -50,16 +53,15 @@ int main(void)
|
||||
// NOTE: New VBO for tangents is generated at default location and also binded to mesh VAO
|
||||
MeshTangents(&model.meshes[0]);
|
||||
|
||||
UnloadMaterial(model.materials[0]); // get rid of default material
|
||||
model.materials[0] = LoadMaterialPBR((Color){ 255, 255, 255, 255 }, 1.0f, 1.0f);
|
||||
|
||||
// Define lights attributes
|
||||
// NOTE: Shader is passed to every light on creation to define shader bindings internally
|
||||
Light lights[MAX_LIGHTS] = {
|
||||
CreateLight(LIGHT_POINT, (Vector3){ LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 0, 255 }, model.materials[0].shader),
|
||||
CreateLight(LIGHT_POINT, (Vector3){ 0.0f, LIGHT_HEIGHT, LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 255, 0, 255 }, model.materials[0].shader),
|
||||
CreateLight(LIGHT_POINT, (Vector3){ -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 0, 255, 255 }, model.materials[0].shader),
|
||||
CreateLight(LIGHT_DIRECTIONAL, (Vector3){ 0.0f, LIGHT_HEIGHT*2.0f, -LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 255, 255 }, model.materials[0].shader)
|
||||
};
|
||||
// Create lights
|
||||
// NOTE: Lights are added to an internal lights pool automatically
|
||||
CreateLight(LIGHT_POINT, (Vector3){ LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 0, 255 }, model.materials[0].shader);
|
||||
CreateLight(LIGHT_POINT, (Vector3){ 0.0f, LIGHT_HEIGHT, LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 255, 0, 255 }, model.materials[0].shader);
|
||||
CreateLight(LIGHT_POINT, (Vector3){ -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 0, 255, 255 }, model.materials[0].shader);
|
||||
CreateLight(LIGHT_DIRECTIONAL, (Vector3){ 0.0f, LIGHT_HEIGHT*2.0f, -LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 255, 255 }, model.materials[0].shader);
|
||||
|
||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
||||
|
||||
@@ -100,7 +102,20 @@ int main(void)
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadModel(model); // Unload skybox model
|
||||
|
||||
// Shaders and textures must be unloaded by user,
|
||||
// they could be in use by other models
|
||||
UnloadTexture(model.materials[0].maps[MAP_ALBEDO].texture);
|
||||
UnloadTexture(model.materials[0].maps[MAP_NORMAL].texture);
|
||||
UnloadTexture(model.materials[0].maps[MAP_METALNESS].texture);
|
||||
UnloadTexture(model.materials[0].maps[MAP_ROUGHNESS].texture);
|
||||
UnloadTexture(model.materials[0].maps[MAP_OCCLUSION].texture);
|
||||
UnloadTexture(model.materials[0].maps[MAP_IRRADIANCE].texture);
|
||||
UnloadTexture(model.materials[0].maps[MAP_PREFILTER].texture);
|
||||
UnloadTexture(model.materials[0].maps[MAP_BRDF].texture);
|
||||
UnloadShader(model.materials[0].shader);
|
||||
|
||||
UnloadModel(model); // Unload model
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -112,7 +127,7 @@ int main(void)
|
||||
// NOTE: PBR shader is loaded inside this function
|
||||
static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
|
||||
{
|
||||
Material mat = { 0 }; // NOTE: All maps textures are set to { 0 }
|
||||
Material mat = LoadMaterialDefault(); // Initialize material to default
|
||||
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
mat.shader = LoadShader("resources/shaders/glsl330/pbr.vs", "resources/shaders/glsl330/pbr.fs");
|
||||
@@ -135,7 +150,7 @@ static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
|
||||
|
||||
// Set view matrix location
|
||||
mat.shader.locs[LOC_MATRIX_MODEL] = GetShaderLocation(mat.shader, "matModel");
|
||||
mat.shader.locs[LOC_MATRIX_VIEW] = GetShaderLocation(mat.shader, "view");
|
||||
//mat.shader.locs[LOC_MATRIX_VIEW] = GetShaderLocation(mat.shader, "view");
|
||||
mat.shader.locs[LOC_VECTOR_VIEW] = GetShaderLocation(mat.shader, "viewPos");
|
||||
|
||||
// Set PBR standard maps
|
||||
|
@@ -115,6 +115,7 @@ int main(void)
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Unload texture
|
||||
|
||||
// Unload models data (GPU VRAM)
|
||||
for (int i = 0; i < NUM_MODELS; i++) UnloadModel(models[i]);
|
||||
|
@@ -105,7 +105,7 @@ int main(void)
|
||||
|
||||
// Check ray collision against model
|
||||
// NOTE: It considers model.transform matrix!
|
||||
meshHitInfo = GetCollisionRayModel(ray, &tower);
|
||||
meshHitInfo = GetCollisionRayModel(ray, tower);
|
||||
|
||||
if ((meshHitInfo.hit) && (meshHitInfo.distance < nearestHit.distance))
|
||||
{
|
||||
|
@@ -1,80 +0,0 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [models] example - Load and draw a 3d model (OBJ)
|
||||
*
|
||||
* This example has been created using raylib 1.3 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
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 model = LoadModel("resources/models/castle.obj"); // Load OBJ model
|
||||
Texture2D texture = LoadTexture("resources/models/castle_diffuse.png"); // Load model texture
|
||||
model.materials[0].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
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
//...
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModel(model, position, 0.2f, WHITE); // Draw 3d model with texture
|
||||
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
DrawGizmo(position); // Draw gizmo
|
||||
|
||||
EndMode3D();
|
||||
|
||||
DrawText("(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Unload texture
|
||||
UnloadModel(model); // Unload model
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
Before Width: | Height: | Size: 260 KiB |
@@ -1,127 +0,0 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [models] example - OBJ models viewer
|
||||
*
|
||||
* 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) 2014-2019 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include <string.h> // Required for: strcpy()
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example - obj viewer");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = { { 30.0f, 30.0f, 30.0f }, { 0.0f, 10.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||
|
||||
Model model = LoadModel("resources/models/turret.obj"); // Load default model obj
|
||||
Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load default model texture
|
||||
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Bind texture to model
|
||||
|
||||
Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position
|
||||
BoundingBox bounds = MeshBoundingBox(model.meshes[0]); // Set model bounds
|
||||
bool selected = false; // Selected object flag
|
||||
|
||||
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
||||
|
||||
char objFilename[64] = "turret.obj";
|
||||
|
||||
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 (IsFileDropped())
|
||||
{
|
||||
int count = 0;
|
||||
char **droppedFiles = GetDroppedFiles(&count);
|
||||
|
||||
if (count == 1)
|
||||
{
|
||||
if (IsFileExtension(droppedFiles[0], ".obj"))
|
||||
{
|
||||
for (int i = 0; i < model.meshCount; i++) UnloadMesh(&model.meshes[i]);
|
||||
model.meshes = LoadMeshes(droppedFiles[0], &model.meshCount);
|
||||
bounds = MeshBoundingBox(model.meshes[0]);
|
||||
}
|
||||
else if (IsFileExtension(droppedFiles[0], ".png"))
|
||||
{
|
||||
UnloadTexture(texture);
|
||||
texture = LoadTexture(droppedFiles[0]);
|
||||
model.materials[0].maps[MAP_DIFFUSE].texture = texture;
|
||||
}
|
||||
|
||||
strcpy(objFilename, GetFileName(droppedFiles[0]));
|
||||
}
|
||||
|
||||
ClearDroppedFiles(); // Clear internal buffers
|
||||
}
|
||||
|
||||
UpdateCamera(&camera);
|
||||
|
||||
// Select model on mouse click
|
||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||
{
|
||||
// Check collision between ray and box
|
||||
if (CheckCollisionRayBox(GetMouseRay(GetMousePosition(), camera), bounds)) selected = !selected;
|
||||
else selected = false;
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModel(model, position, 1.0f, WHITE); // Draw 3d model with texture
|
||||
|
||||
DrawGrid(20.0, 10.0); // Draw a grid
|
||||
|
||||
if (selected) DrawBoundingBox(bounds, GREEN);
|
||||
|
||||
EndMode3D();
|
||||
|
||||
DrawText("Free camera default controls:", 10, 20, 10, DARKGRAY);
|
||||
DrawText("- Mouse Wheel to Zoom in-out", 20, 40, 10, GRAY);
|
||||
DrawText("- Mouse Wheel Pressed to Pan", 20, 60, 10, GRAY);
|
||||
DrawText("- Alt + Mouse Wheel Pressed to Rotate", 20, 80, 10, GRAY);
|
||||
DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 20, 100, 10, GRAY);
|
||||
|
||||
DrawText("Drag & drop .obj/.png to load mesh/texture.", 10, GetScreenHeight() - 20, 10, DARKGRAY);
|
||||
DrawText(FormatText("Current file: %s", objFilename), 250, GetScreenHeight() - 20, 10, GRAY);
|
||||
if (selected) DrawText("MODEL SELECTED", GetScreenWidth() - 110, 10, 10, GREEN);
|
||||
|
||||
DrawText("(c) Turret 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadModel(model); // Unload model
|
||||
|
||||
ClearDroppedFiles(); // Clear internal buffers
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
Before Width: | Height: | Size: 95 KiB |
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* This example uses [rlgl] module funtionality (pseudo-OpenGL 1.1 style coding)
|
||||
*
|
||||
* This example has been created using raylib 2.2 (www.raylib.com)
|
||||
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2018 Ramon Santamaria (@raysan5)
|
||||
|
@@ -89,7 +89,10 @@ int main(void)
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadModel(skybox); // Unload skybox model (and textures)
|
||||
UnloadShader(skybox.materials[0].shader);
|
||||
UnloadTexture(skybox.materials[0].maps[MAP_CUBEMAP].texture);
|
||||
|
||||
UnloadModel(skybox); // Unload skybox model
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
112
examples/models/models_waving_cubes.c
Normal file
@@ -0,0 +1,112 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [models] example - Waving cubes
|
||||
*
|
||||
* This example has been created using raylib 2.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Example contributed by Codecat (@codecat) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Copyright (c) 2019 Codecat (@codecat) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - waving cubes");
|
||||
|
||||
// Initialize the camera
|
||||
Camera3D camera = { 0 };
|
||||
camera.position = (Vector3){ 30.0f, 20.0f, 30.0f };
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||
camera.fovy = 70.0f;
|
||||
camera.type = CAMERA_PERSPECTIVE;
|
||||
|
||||
// Specify the amount of blocks in each direction
|
||||
const int numBlocks = 15;
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
double time = GetTime();
|
||||
|
||||
// Calculate time scale for cube position and size
|
||||
float scale = (2.0f + (float)sin(time))*0.7f;
|
||||
|
||||
// Move camera around the scene
|
||||
double cameraTime = time*0.3;
|
||||
camera.position.x = (float)cos(cameraTime)*40.0f;
|
||||
camera.position.z = (float)sin(cameraTime)*40.0f;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawGrid(10, 5.0f);
|
||||
|
||||
for (int x = 0; x < numBlocks; x++)
|
||||
{
|
||||
for (int y = 0; y < numBlocks; y++)
|
||||
{
|
||||
for (int z = 0; z < numBlocks; z++)
|
||||
{
|
||||
// Scale of the blocks depends on x/y/z positions
|
||||
float blockScale = (x + y + z)/30.0f;
|
||||
|
||||
// Scatter makes the waving effect by adding blockScale over time
|
||||
float scatter = sinf(blockScale*20.0f + (float)(time*4.0f));
|
||||
|
||||
// Calculate the cube position
|
||||
Vector3 cubePos = {
|
||||
(float)(x - numBlocks/2)*(scale*3.0f) + scatter,
|
||||
(float)(y - numBlocks/2)*(scale*2.0f) + scatter,
|
||||
(float)(z - numBlocks/2)*(scale*3.0f) + scatter
|
||||
};
|
||||
|
||||
// Pick a color with a hue depending on cube position for the rainbow color effect
|
||||
Color cubeColor = ColorFromHSV((Vector3){ (float)(((x + y + z)*18)%360), 0.75f, 0.9f });
|
||||
|
||||
// Calculate cube size
|
||||
float cubeSize = (2.4f - scale)*blockScale;
|
||||
|
||||
// And finally, draw the cube!
|
||||
DrawCube(cubePos, cubeSize, cubeSize, cubeSize, cubeColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EndMode3D();
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/models/models_waving_cubes.png
Normal file
After Width: | Height: | Size: 37 KiB |
@@ -92,6 +92,7 @@ int main(void)
|
||||
while (pitchOffset < -180) pitchOffset += 360;
|
||||
pitchOffset *= 10;
|
||||
|
||||
/* matrix transform done with multiplication to combine rotations
|
||||
Matrix transform = MatrixIdentity();
|
||||
|
||||
transform = MatrixMultiply(transform, MatrixRotateZ(DEG2RAD*roll));
|
||||
@@ -99,8 +100,11 @@ int main(void)
|
||||
transform = MatrixMultiply(transform, MatrixRotateY(DEG2RAD*yaw));
|
||||
|
||||
model.transform = transform;
|
||||
//----------------------------------------------------------------------------------
|
||||
*/
|
||||
// matrix created from multiple axes at once
|
||||
model.transform = MatrixRotateXYZ((Vector3){DEG2RAD*pitch,DEG2RAD*yaw,DEG2RAD*roll});
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
@@ -165,6 +169,7 @@ int main(void)
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Unload all loaded data
|
||||
UnloadTexture(model.materials[0].maps[MAP_DIFFUSE].texture);
|
||||
UnloadModel(model);
|
||||
|
||||
UnloadRenderTexture(framebuffer);
|
||||
|
BIN
examples/models/resources/models/Duck/Duck.glb
Normal file
219
examples/models/resources/models/Duck/Duck.gltf
Normal file
@@ -0,0 +1,219 @@
|
||||
{
|
||||
"asset": {
|
||||
"generator": "COLLADA2GLTF",
|
||||
"version": "2.0"
|
||||
},
|
||||
"scene": 0,
|
||||
"scenes": [
|
||||
{
|
||||
"nodes": [
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"children": [
|
||||
2,
|
||||
1
|
||||
],
|
||||
"matrix": [
|
||||
0.009999999776482582,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.009999999776482582,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.009999999776482582,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
{
|
||||
"matrix": [
|
||||
-0.7289686799049377,
|
||||
0.0,
|
||||
-0.6845470666885376,
|
||||
0.0,
|
||||
-0.4252049028873444,
|
||||
0.7836934328079224,
|
||||
0.4527972936630249,
|
||||
0.0,
|
||||
0.5364750623703003,
|
||||
0.6211478114128113,
|
||||
-0.571287989616394,
|
||||
0.0,
|
||||
400.1130065917969,
|
||||
463.2640075683594,
|
||||
-431.0780334472656,
|
||||
1.0
|
||||
],
|
||||
"camera": 0
|
||||
},
|
||||
{
|
||||
"mesh": 0
|
||||
}
|
||||
],
|
||||
"cameras": [
|
||||
{
|
||||
"perspective": {
|
||||
"aspectRatio": 1.5,
|
||||
"yfov": 0.6605925559997559,
|
||||
"zfar": 10000.0,
|
||||
"znear": 1.0
|
||||
},
|
||||
"type": "perspective"
|
||||
}
|
||||
],
|
||||
"meshes": [
|
||||
{
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"NORMAL": 1,
|
||||
"POSITION": 2,
|
||||
"TEXCOORD_0": 3
|
||||
},
|
||||
"indices": 0,
|
||||
"mode": 4,
|
||||
"material": 0
|
||||
}
|
||||
],
|
||||
"name": "LOD3spShape"
|
||||
}
|
||||
],
|
||||
"accessors": [
|
||||
{
|
||||
"bufferView": 0,
|
||||
"byteOffset": 0,
|
||||
"componentType": 5123,
|
||||
"count": 12636,
|
||||
"max": [
|
||||
2398
|
||||
],
|
||||
"min": [
|
||||
0
|
||||
],
|
||||
"type": "SCALAR"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"byteOffset": 0,
|
||||
"componentType": 5126,
|
||||
"count": 2399,
|
||||
"max": [
|
||||
0.9995989799499512,
|
||||
0.999580979347229,
|
||||
0.9984359741210938
|
||||
],
|
||||
"min": [
|
||||
-0.9990839958190918,
|
||||
-1.0,
|
||||
-0.9998319745063782
|
||||
],
|
||||
"type": "VEC3"
|
||||
},
|
||||
{
|
||||
"bufferView": 1,
|
||||
"byteOffset": 28788,
|
||||
"componentType": 5126,
|
||||
"count": 2399,
|
||||
"max": [
|
||||
96.17990112304688,
|
||||
163.97000122070313,
|
||||
53.92519760131836
|
||||
],
|
||||
"min": [
|
||||
-69.29850006103516,
|
||||
9.929369926452637,
|
||||
-61.32819747924805
|
||||
],
|
||||
"type": "VEC3"
|
||||
},
|
||||
{
|
||||
"bufferView": 2,
|
||||
"byteOffset": 0,
|
||||
"componentType": 5126,
|
||||
"count": 2399,
|
||||
"max": [
|
||||
0.9833459854125976,
|
||||
0.9800369739532472
|
||||
],
|
||||
"min": [
|
||||
0.026409000158309938,
|
||||
0.01996302604675293
|
||||
],
|
||||
"type": "VEC2"
|
||||
}
|
||||
],
|
||||
"materials": [
|
||||
{
|
||||
"pbrMetallicRoughness": {
|
||||
"baseColorTexture": {
|
||||
"index": 0
|
||||
},
|
||||
"metallicFactor": 0.0
|
||||
},
|
||||
"emissiveFactor": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
],
|
||||
"name": "blinn3-fx"
|
||||
}
|
||||
],
|
||||
"textures": [
|
||||
{
|
||||
"sampler": 0,
|
||||
"source": 0
|
||||
}
|
||||
],
|
||||
"images": [
|
||||
{
|
||||
"uri": "DuckCM.png"
|
||||
}
|
||||
],
|
||||
"samplers": [
|
||||
{
|
||||
"magFilter": 9729,
|
||||
"minFilter": 9986,
|
||||
"wrapS": 10497,
|
||||
"wrapT": 10497
|
||||
}
|
||||
],
|
||||
"bufferViews": [
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 76768,
|
||||
"byteLength": 25272,
|
||||
"target": 34963
|
||||
},
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 0,
|
||||
"byteLength": 57576,
|
||||
"byteStride": 12,
|
||||
"target": 34962
|
||||
},
|
||||
{
|
||||
"buffer": 0,
|
||||
"byteOffset": 57576,
|
||||
"byteLength": 19192,
|
||||
"byteStride": 8,
|
||||
"target": 34962
|
||||
}
|
||||
],
|
||||
"buffers": [
|
||||
{
|
||||
"byteLength": 102040,
|
||||
"uri": "Duck0.bin"
|
||||
}
|
||||
]
|
||||
}
|
BIN
examples/models/resources/models/Duck/Duck0.bin
Normal file
BIN
examples/models/resources/models/Duck/DuckCM.png
Normal file
After Width: | Height: | Size: 16 KiB |
14
examples/models/resources/models/Duck/Duck_license.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
# Duck
|
||||
## Screenshot
|
||||
|
||||

|
||||
|
||||
## License Information
|
||||
|
||||
Copyright 2006 Sony Computer Entertainment Inc.
|
||||
|
||||
Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:
|
||||
|
||||
http://research.scea.com/scea_shared_source_license.html
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
4
examples/models/resources/models/LICENSE
Normal file
@@ -0,0 +1,4 @@
|
||||
Medieval City models and textures have been created by Alberto Cano,
|
||||
and licensed as Creative Commons Attribution-NonCommercial 4.0.
|
||||
|
||||
Check for details: https://creativecommons.org/licenses/by-nc/4.0/legalcode
|
Before Width: | Height: | Size: 364 KiB After Width: | Height: | Size: 295 KiB |
@@ -1,133 +0,0 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* BRDF LUT Generation - Bidirectional reflectance distribution function fragment shader
|
||||
*
|
||||
* REF: https://github.com/HectorMF/BRDFGenerator
|
||||
*
|
||||
* Copyright (c) 2017 Victor Fisac
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#version 330
|
||||
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
// Constant values
|
||||
const float PI = 3.14159265359;
|
||||
const uint MAX_SAMPLES = 1024u;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
||||
vec2 Hammersley(uint i, uint N);
|
||||
float RadicalInverseVdC(uint bits);
|
||||
float GeometrySchlickGGX(float NdotV, float roughness);
|
||||
float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness);
|
||||
vec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness);
|
||||
vec2 IntegrateBRDF(float NdotV, float roughness);
|
||||
|
||||
float RadicalInverseVdC(uint bits)
|
||||
{
|
||||
bits = (bits << 16u) | (bits >> 16u);
|
||||
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
|
||||
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
|
||||
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
|
||||
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
|
||||
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
|
||||
}
|
||||
|
||||
// Compute Hammersley coordinates
|
||||
vec2 Hammersley(uint i, uint N)
|
||||
{
|
||||
return vec2(float(i)/float(N), RadicalInverseVdC(i));
|
||||
}
|
||||
|
||||
// Integrate number of importance samples for (roughness and NoV)
|
||||
vec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness)
|
||||
{
|
||||
float a = roughness*roughness;
|
||||
float phi = 2.0 * PI * Xi.x;
|
||||
float cosTheta = sqrt((1.0 - Xi.y)/(1.0 + (a*a - 1.0)*Xi.y));
|
||||
float sinTheta = sqrt(1.0 - cosTheta*cosTheta);
|
||||
|
||||
// Transform from spherical coordinates to cartesian coordinates (halfway vector)
|
||||
vec3 H = vec3(cos(phi)*sinTheta, sin(phi)*sinTheta, cosTheta);
|
||||
|
||||
// Transform from tangent space H vector to world space sample vector
|
||||
vec3 up = ((abs(N.z) < 0.999) ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0));
|
||||
vec3 tangent = normalize(cross(up, N));
|
||||
vec3 bitangent = cross(N, tangent);
|
||||
vec3 sampleVec = tangent*H.x + bitangent*H.y + N*H.z;
|
||||
|
||||
return normalize(sampleVec);
|
||||
}
|
||||
|
||||
float GeometrySchlickGGX(float NdotV, float roughness)
|
||||
{
|
||||
// For IBL k is calculated different
|
||||
float k = (roughness*roughness)/2.0;
|
||||
|
||||
float nom = NdotV;
|
||||
float denom = NdotV*(1.0 - k) + k;
|
||||
|
||||
return nom/denom;
|
||||
}
|
||||
|
||||
// Compute the geometry term for the BRDF given roughness squared, NoV, NoL
|
||||
float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness)
|
||||
{
|
||||
float NdotV = max(dot(N, V), 0.0);
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
float ggx2 = GeometrySchlickGGX(NdotV, roughness);
|
||||
float ggx1 = GeometrySchlickGGX(NdotL, roughness);
|
||||
|
||||
return ggx1*ggx2;
|
||||
}
|
||||
|
||||
vec2 IntegrateBRDF(float NdotV, float roughness)
|
||||
{
|
||||
float A = 0.0;
|
||||
float B = 0.0;
|
||||
vec3 V = vec3(sqrt(1.0 - NdotV*NdotV), 0.0, NdotV);
|
||||
vec3 N = vec3(0.0, 0.0, 1.0);
|
||||
|
||||
for (uint i = 0u; i < MAX_SAMPLES; i++)
|
||||
{
|
||||
// Generate a sample vector that's biased towards the preferred alignment direction (importance sampling)
|
||||
|
||||
vec2 Xi = Hammersley(i, MAX_SAMPLES); // Compute a Hammersely coordinate
|
||||
vec3 H = ImportanceSampleGGX(Xi, N, roughness); // Integrate number of importance samples for (roughness and NoV)
|
||||
vec3 L = normalize(2.0*dot(V, H)*H - V); // Compute reflection vector L
|
||||
|
||||
float NdotL = max(L.z, 0.0); // Compute normal dot light
|
||||
float NdotH = max(H.z, 0.0); // Compute normal dot half
|
||||
float VdotH = max(dot(V, H), 0.0); // Compute view dot half
|
||||
|
||||
if (NdotL > 0.0)
|
||||
{
|
||||
float G = GeometrySmith(N, V, L, roughness); // Compute the geometry term for the BRDF given roughness squared, NoV, NoL
|
||||
float GVis = (G*VdotH)/(NdotH*NdotV); // Compute the visibility term given G, VoH, NoH, NoV, NoL
|
||||
float Fc = pow(1.0 - VdotH, 5.0); // Compute the fresnel term given VoH
|
||||
|
||||
A += (1.0 - Fc)*GVis; // Sum the result given fresnel, geometry, visibility
|
||||
B += Fc*GVis;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate brdf average sample
|
||||
A /= float(MAX_SAMPLES);
|
||||
B /= float(MAX_SAMPLES);
|
||||
|
||||
return vec2(A, B);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// Calculate brdf based on texture coordinates
|
||||
vec2 brdf = IntegrateBRDF(fragTexCoord.x, fragTexCoord.y);
|
||||
|
||||
// Calculate final fragment color
|
||||
finalColor = vec4(brdf.r, brdf.g, 0.0, 1.0);
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* rPBR [shader] - Bidirectional reflectance distribution function vertex shader
|
||||
*
|
||||
* Copyright (c) 2017 Victor Fisac
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes
|
||||
in vec3 vertexPosition;
|
||||
in vec2 vertexTexCoord;
|
||||
|
||||
// Output vertex attributes (to fragment shader)
|
||||
out vec2 fragTexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Calculate fragment position based on model transformations
|
||||
fragTexCoord = vertexTexCoord;
|
||||
|
||||
// Calculate final vertex position
|
||||
gl_Position = vec4(vertexPosition, 1.0);
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* rPBR [shader] - Irradiance cubemap fragment shader
|
||||
*
|
||||
* Copyright (c) 2017 Victor Fisac
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec3 fragPosition;
|
||||
|
||||
// Input uniform values
|
||||
uniform samplerCube environmentMap;
|
||||
|
||||
// Constant values
|
||||
const float PI = 3.14159265359f;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
// The sample direction equals the hemisphere's orientation
|
||||
vec3 normal = normalize(fragPosition);
|
||||
|
||||
vec3 irradiance = vec3(0.0);
|
||||
|
||||
vec3 up = vec3(0.0, 1.0, 0.0);
|
||||
vec3 right = cross(up, normal);
|
||||
up = cross(normal, right);
|
||||
|
||||
float sampleDelta = 0.025f;
|
||||
float nrSamples = 0.0f;
|
||||
|
||||
for (float phi = 0.0; phi < 2.0*PI; phi += sampleDelta)
|
||||
{
|
||||
for (float theta = 0.0; theta < 0.5*PI; theta += sampleDelta)
|
||||
{
|
||||
// Spherical to cartesian (in tangent space)
|
||||
vec3 tangentSample = vec3(sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta));
|
||||
|
||||
// tangent space to world
|
||||
vec3 sampleVec = tangentSample.x*right + tangentSample.y*up + tangentSample.z*normal;
|
||||
|
||||
// Fetch color from environment cubemap
|
||||
irradiance += texture(environmentMap, sampleVec).rgb*cos(theta)*sin(theta);
|
||||
nrSamples++;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate irradiance average value from samples
|
||||
irradiance = PI*irradiance*(1.0/float(nrSamples));
|
||||
|
||||
// Calculate final fragment color
|
||||
finalColor = vec4(irradiance, 1.0);
|
||||
}
|
@@ -1,298 +0,0 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* rPBR [shader] - Physically based rendering fragment shader
|
||||
*
|
||||
* Copyright (c) 2017 Victor Fisac
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#version 330
|
||||
|
||||
#define MAX_REFLECTION_LOD 4.0
|
||||
#define MAX_DEPTH_LAYER 20
|
||||
#define MIN_DEPTH_LAYER 10
|
||||
|
||||
#define MAX_LIGHTS 4
|
||||
#define LIGHT_DIRECTIONAL 0
|
||||
#define LIGHT_POINT 1
|
||||
|
||||
struct MaterialProperty {
|
||||
vec3 color;
|
||||
int useSampler;
|
||||
sampler2D sampler;
|
||||
};
|
||||
|
||||
struct Light {
|
||||
int enabled;
|
||||
int type;
|
||||
vec3 position;
|
||||
vec3 target;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec3 fragPosition;
|
||||
in vec2 fragTexCoord;
|
||||
in vec3 fragNormal;
|
||||
in vec3 fragTangent;
|
||||
in vec3 fragBinormal;
|
||||
|
||||
// Input material values
|
||||
uniform MaterialProperty albedo;
|
||||
uniform MaterialProperty normals;
|
||||
uniform MaterialProperty metalness;
|
||||
uniform MaterialProperty roughness;
|
||||
uniform MaterialProperty occlusion;
|
||||
uniform MaterialProperty emission;
|
||||
uniform MaterialProperty height;
|
||||
|
||||
// Input uniform values
|
||||
uniform samplerCube irradianceMap;
|
||||
uniform samplerCube prefilterMap;
|
||||
uniform sampler2D brdfLUT;
|
||||
|
||||
// Input lighting values
|
||||
uniform Light lights[MAX_LIGHTS];
|
||||
|
||||
// Other uniform values
|
||||
uniform int renderMode;
|
||||
uniform vec3 viewPos;
|
||||
vec2 texCoord;
|
||||
|
||||
// Constant values
|
||||
const float PI = 3.14159265359;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
||||
vec3 ComputeMaterialProperty(MaterialProperty property);
|
||||
float DistributionGGX(vec3 N, vec3 H, float roughness);
|
||||
float GeometrySchlickGGX(float NdotV, float roughness);
|
||||
float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness);
|
||||
vec3 fresnelSchlick(float cosTheta, vec3 F0);
|
||||
vec3 fresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness);
|
||||
vec2 ParallaxMapping(vec2 texCoords, vec3 viewDir);
|
||||
|
||||
vec3 ComputeMaterialProperty(MaterialProperty property)
|
||||
{
|
||||
vec3 result = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
if (property.useSampler == 1) result = texture(property.sampler, texCoord).rgb;
|
||||
else result = property.color;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
float DistributionGGX(vec3 N, vec3 H, float roughness)
|
||||
{
|
||||
float a = roughness*roughness;
|
||||
float a2 = a*a;
|
||||
float NdotH = max(dot(N, H), 0.0);
|
||||
float NdotH2 = NdotH*NdotH;
|
||||
|
||||
float nom = a2;
|
||||
float denom = (NdotH2*(a2 - 1.0) + 1.0);
|
||||
denom = PI*denom*denom;
|
||||
|
||||
return nom/denom;
|
||||
}
|
||||
|
||||
float GeometrySchlickGGX(float NdotV, float roughness)
|
||||
{
|
||||
float r = (roughness + 1.0);
|
||||
float k = r*r/8.0;
|
||||
|
||||
float nom = NdotV;
|
||||
float denom = NdotV*(1.0 - k) + k;
|
||||
|
||||
return nom/denom;
|
||||
}
|
||||
float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness)
|
||||
{
|
||||
float NdotV = max(dot(N, V), 0.0);
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
float ggx2 = GeometrySchlickGGX(NdotV, roughness);
|
||||
float ggx1 = GeometrySchlickGGX(NdotL, roughness);
|
||||
|
||||
return ggx1*ggx2;
|
||||
}
|
||||
|
||||
vec3 fresnelSchlick(float cosTheta, vec3 F0)
|
||||
{
|
||||
return F0 + (1.0 - F0)*pow(1.0 - cosTheta, 5.0);
|
||||
}
|
||||
|
||||
vec3 fresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness)
|
||||
{
|
||||
return F0 + (max(vec3(1.0 - roughness), F0) - F0)*pow(1.0 - cosTheta, 5.0);
|
||||
}
|
||||
|
||||
vec2 ParallaxMapping(vec2 texCoords, vec3 viewDir)
|
||||
{
|
||||
// Calculate the number of depth layers and calculate the size of each layer
|
||||
float numLayers = mix(MAX_DEPTH_LAYER, MIN_DEPTH_LAYER, abs(dot(vec3(0.0, 0.0, 1.0), viewDir)));
|
||||
float layerDepth = 1.0/numLayers;
|
||||
|
||||
// Calculate depth of current layer
|
||||
float currentLayerDepth = 0.0;
|
||||
|
||||
// Calculate the amount to shift the texture coordinates per layer (from vector P)
|
||||
// Note: height amount is stored in height material attribute color R channel (sampler use is independent)
|
||||
vec2 P = viewDir.xy*height.color.r;
|
||||
vec2 deltaTexCoords = P/numLayers;
|
||||
|
||||
// Store initial texture coordinates and depth values
|
||||
vec2 currentTexCoords = texCoords;
|
||||
float currentDepthMapValue = texture(height.sampler, currentTexCoords).r;
|
||||
|
||||
while (currentLayerDepth < currentDepthMapValue)
|
||||
{
|
||||
// Shift texture coordinates along direction of P
|
||||
currentTexCoords -= deltaTexCoords;
|
||||
|
||||
// Get depth map value at current texture coordinates
|
||||
currentDepthMapValue = texture(height.sampler, currentTexCoords).r;
|
||||
|
||||
// Get depth of next layer
|
||||
currentLayerDepth += layerDepth;
|
||||
}
|
||||
|
||||
// Get texture coordinates before collision (reverse operations)
|
||||
vec2 prevTexCoords = currentTexCoords + deltaTexCoords;
|
||||
|
||||
// Get depth after and before collision for linear interpolation
|
||||
float afterDepth = currentDepthMapValue - currentLayerDepth;
|
||||
float beforeDepth = texture(height.sampler, prevTexCoords).r - currentLayerDepth + layerDepth;
|
||||
|
||||
// Interpolation of texture coordinates
|
||||
float weight = afterDepth/(afterDepth - beforeDepth);
|
||||
vec2 finalTexCoords = prevTexCoords*weight + currentTexCoords*(1.0 - weight);
|
||||
|
||||
return finalTexCoords;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// Calculate TBN and RM matrices
|
||||
mat3 TBN = transpose(mat3(fragTangent, fragBinormal, fragNormal));
|
||||
|
||||
// Calculate lighting required attributes
|
||||
vec3 normal = normalize(fragNormal);
|
||||
vec3 view = normalize(viewPos - fragPosition);
|
||||
vec3 refl = reflect(-view, normal);
|
||||
|
||||
// Check if parallax mapping is enabled and calculate texture coordinates to use based on height map
|
||||
// NOTE: remember that 'texCoord' variable must be assigned before calling any ComputeMaterialProperty() function
|
||||
if (height.useSampler == 1) texCoord = ParallaxMapping(fragTexCoord, view);
|
||||
else texCoord = fragTexCoord; // Use default texture coordinates
|
||||
|
||||
// Fetch material values from texture sampler or color attributes
|
||||
vec3 color = ComputeMaterialProperty(albedo);
|
||||
vec3 metal = ComputeMaterialProperty(metalness);
|
||||
vec3 rough = ComputeMaterialProperty(roughness);
|
||||
vec3 emiss = ComputeMaterialProperty(emission);
|
||||
vec3 ao = ComputeMaterialProperty(occlusion);
|
||||
|
||||
// Check if normal mapping is enabled
|
||||
if (normals.useSampler == 1)
|
||||
{
|
||||
// Fetch normal map color and transform lighting values to tangent space
|
||||
normal = ComputeMaterialProperty(normals);
|
||||
normal = normalize(normal*2.0 - 1.0);
|
||||
normal = normalize(normal*TBN);
|
||||
|
||||
// Convert tangent space normal to world space due to cubemap reflection calculations
|
||||
refl = normalize(reflect(-view, normal));
|
||||
}
|
||||
|
||||
// Calculate reflectance at normal incidence
|
||||
vec3 F0 = vec3(0.04);
|
||||
F0 = mix(F0, color, metal.r);
|
||||
|
||||
// Calculate lighting for all lights
|
||||
vec3 Lo = vec3(0.0);
|
||||
vec3 lightDot = vec3(0.0);
|
||||
|
||||
for (int i = 0; i < MAX_LIGHTS; i++)
|
||||
{
|
||||
if (lights[i].enabled == 1)
|
||||
{
|
||||
// Calculate per-light radiance
|
||||
vec3 light = vec3(0.0);
|
||||
vec3 radiance = lights[i].color.rgb;
|
||||
if (lights[i].type == LIGHT_DIRECTIONAL) light = -normalize(lights[i].target - lights[i].position);
|
||||
else if (lights[i].type == LIGHT_POINT)
|
||||
{
|
||||
light = normalize(lights[i].position - fragPosition);
|
||||
float distance = length(lights[i].position - fragPosition);
|
||||
float attenuation = 1.0/(distance*distance);
|
||||
radiance *= attenuation;
|
||||
}
|
||||
|
||||
// Cook-torrance BRDF
|
||||
vec3 high = normalize(view + light);
|
||||
float NDF = DistributionGGX(normal, high, rough.r);
|
||||
float G = GeometrySmith(normal, view, light, rough.r);
|
||||
vec3 F = fresnelSchlick(max(dot(high, view), 0.0), F0);
|
||||
vec3 nominator = NDF*G*F;
|
||||
float denominator = 4*max(dot(normal, view), 0.0)*max(dot(normal, light), 0.0) + 0.001;
|
||||
vec3 brdf = nominator/denominator;
|
||||
|
||||
// Store to kS the fresnel value and calculate energy conservation
|
||||
vec3 kS = F;
|
||||
vec3 kD = vec3(1.0) - kS;
|
||||
|
||||
// Multiply kD by the inverse metalness such that only non-metals have diffuse lighting
|
||||
kD *= 1.0 - metal.r;
|
||||
|
||||
// Scale light by dot product between normal and light direction
|
||||
float NdotL = max(dot(normal, light), 0.0);
|
||||
|
||||
// Add to outgoing radiance Lo
|
||||
// Note: BRDF is already multiplied by the Fresnel so it doesn't need to be multiplied again
|
||||
Lo += (kD*color/PI + brdf)*radiance*NdotL*lights[i].color.a;
|
||||
lightDot += radiance*NdotL + brdf*lights[i].color.a;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate ambient lighting using IBL
|
||||
vec3 F = fresnelSchlickRoughness(max(dot(normal, view), 0.0), F0, rough.r);
|
||||
vec3 kS = F;
|
||||
vec3 kD = 1.0 - kS;
|
||||
kD *= 1.0 - metal.r;
|
||||
|
||||
// Calculate indirect diffuse
|
||||
vec3 irradiance = texture(irradianceMap, fragNormal).rgb;
|
||||
vec3 diffuse = color*irradiance;
|
||||
|
||||
// Sample both the prefilter map and the BRDF lut and combine them together as per the Split-Sum approximation
|
||||
vec3 prefilterColor = textureLod(prefilterMap, refl, rough.r*MAX_REFLECTION_LOD).rgb;
|
||||
vec2 brdf = texture(brdfLUT, vec2(max(dot(normal, view), 0.0), rough.r)).rg;
|
||||
vec3 reflection = prefilterColor*(F*brdf.x + brdf.y);
|
||||
|
||||
// Calculate final lighting
|
||||
vec3 ambient = (kD*diffuse + reflection)*ao;
|
||||
|
||||
// Calculate fragment color based on render mode
|
||||
vec3 fragmentColor = ambient + Lo + emiss; // Physically Based Rendering
|
||||
|
||||
if (renderMode == 1) fragmentColor = color; // Albedo
|
||||
else if (renderMode == 2) fragmentColor = normal; // Normals
|
||||
else if (renderMode == 3) fragmentColor = metal; // Metalness
|
||||
else if (renderMode == 4) fragmentColor = rough; // Roughness
|
||||
else if (renderMode == 5) fragmentColor = ao; // Ambient Occlusion
|
||||
else if (renderMode == 6) fragmentColor = emiss; // Emission
|
||||
else if (renderMode == 7) fragmentColor = lightDot; // Lighting
|
||||
else if (renderMode == 8) fragmentColor = kS; // Fresnel
|
||||
else if (renderMode == 9) fragmentColor = irradiance; // Irradiance
|
||||
else if (renderMode == 10) fragmentColor = reflection; // Reflection
|
||||
|
||||
// Apply HDR tonemapping
|
||||
fragmentColor = fragmentColor/(fragmentColor + vec3(1.0));
|
||||
|
||||
// Apply gamma correction
|
||||
fragmentColor = pow(fragmentColor, vec3(1.0/2.2));
|
||||
|
||||
// Calculate final fragment color
|
||||
finalColor = vec4(fragmentColor, 1.0);
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* rPBR [shader] - Physically based rendering vertex shader
|
||||
*
|
||||
* Copyright (c) 2017 Victor Fisac
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes
|
||||
in vec3 vertexPosition;
|
||||
in vec2 vertexTexCoord;
|
||||
in vec3 vertexNormal;
|
||||
in vec4 vertexTangent;
|
||||
|
||||
// Input uniform values
|
||||
uniform mat4 mvp;
|
||||
uniform mat4 matModel;
|
||||
|
||||
// Output vertex attributes (to fragment shader)
|
||||
out vec3 fragPosition;
|
||||
out vec2 fragTexCoord;
|
||||
out vec3 fragNormal;
|
||||
out vec3 fragTangent;
|
||||
out vec3 fragBinormal;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Calculate binormal from vertex normal and tangent
|
||||
vec3 vertexBinormal = cross(vertexNormal, vec3(vertexTangent));
|
||||
|
||||
// Calculate fragment normal based on normal transformations
|
||||
mat3 normalMatrix = transpose(inverse(mat3(matModel)));
|
||||
|
||||
// Calculate fragment position based on model transformations
|
||||
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0f));
|
||||
|
||||
// Send vertex attributes to fragment shader
|
||||
fragTexCoord = vertexTexCoord;
|
||||
fragNormal = normalize(normalMatrix*vertexNormal);
|
||||
fragTangent = normalize(normalMatrix*vec3(vertexTangent));
|
||||
fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal)*fragNormal);
|
||||
fragBinormal = normalize(normalMatrix*vertexBinormal);
|
||||
fragBinormal = cross(fragNormal, fragTangent);
|
||||
|
||||
// Calculate final vertex position
|
||||
gl_Position = mvp*vec4(vertexPosition, 1.0);
|
||||
}
|
@@ -1,120 +0,0 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* rPBR [shader] - Prefiltered environment for reflections fragment shader
|
||||
*
|
||||
* Copyright (c) 2017 Victor Fisac
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#version 330
|
||||
#define MAX_SAMPLES 1024u
|
||||
#define CUBEMAP_RESOLUTION 1024.0
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec3 fragPosition;
|
||||
|
||||
// Input uniform values
|
||||
uniform samplerCube environmentMap;
|
||||
uniform float roughness;
|
||||
|
||||
// Constant values
|
||||
const float PI = 3.14159265359f;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
||||
float DistributionGGX(vec3 N, vec3 H, float roughness);
|
||||
float RadicalInverse_VdC(uint bits);
|
||||
vec2 Hammersley(uint i, uint N);
|
||||
vec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness);
|
||||
|
||||
float DistributionGGX(vec3 N, vec3 H, float roughness)
|
||||
{
|
||||
float a = roughness*roughness;
|
||||
float a2 = a*a;
|
||||
float NdotH = max(dot(N, H), 0.0);
|
||||
float NdotH2 = NdotH*NdotH;
|
||||
|
||||
float nom = a2;
|
||||
float denom = (NdotH2*(a2 - 1.0) + 1.0);
|
||||
denom = PI*denom*denom;
|
||||
|
||||
return nom/denom;
|
||||
}
|
||||
|
||||
float RadicalInverse_VdC(uint bits)
|
||||
{
|
||||
bits = (bits << 16u) | (bits >> 16u);
|
||||
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
|
||||
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
|
||||
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
|
||||
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
|
||||
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
|
||||
}
|
||||
|
||||
vec2 Hammersley(uint i, uint N)
|
||||
{
|
||||
return vec2(float(i)/float(N), RadicalInverse_VdC(i));
|
||||
}
|
||||
|
||||
vec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness)
|
||||
{
|
||||
float a = roughness*roughness;
|
||||
float phi = 2.0 * PI * Xi.x;
|
||||
float cosTheta = sqrt((1.0 - Xi.y)/(1.0 + (a*a - 1.0)*Xi.y));
|
||||
float sinTheta = sqrt(1.0 - cosTheta*cosTheta);
|
||||
|
||||
// Transform from spherical coordinates to cartesian coordinates (halfway vector)
|
||||
vec3 H = vec3(cos(phi)*sinTheta, sin(phi)*sinTheta, cosTheta);
|
||||
|
||||
// Transform from tangent space H vector to world space sample vector
|
||||
vec3 up = ((abs(N.z) < 0.999) ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0));
|
||||
vec3 tangent = normalize(cross(up, N));
|
||||
vec3 bitangent = cross(N, tangent);
|
||||
vec3 sampleVec = tangent*H.x + bitangent*H.y + N*H.z;
|
||||
|
||||
return normalize(sampleVec);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// Make the simplyfying assumption that V equals R equals the normal
|
||||
vec3 N = normalize(fragPosition);
|
||||
vec3 R = N;
|
||||
vec3 V = R;
|
||||
|
||||
vec3 prefilteredColor = vec3(0.0);
|
||||
float totalWeight = 0.0;
|
||||
|
||||
for (uint i = 0u; i < MAX_SAMPLES; i++)
|
||||
{
|
||||
// Generate a sample vector that's biased towards the preferred alignment direction (importance sampling)
|
||||
vec2 Xi = Hammersley(i, MAX_SAMPLES);
|
||||
vec3 H = ImportanceSampleGGX(Xi, N, roughness);
|
||||
vec3 L = normalize(2.0*dot(V, H)*H - V);
|
||||
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
if(NdotL > 0.0)
|
||||
{
|
||||
// Sample from the environment's mip level based on roughness/pdf
|
||||
float D = DistributionGGX(N, H, roughness);
|
||||
float NdotH = max(dot(N, H), 0.0);
|
||||
float HdotV = max(dot(H, V), 0.0);
|
||||
float pdf = D*NdotH/(4.0*HdotV) + 0.0001;
|
||||
|
||||
float resolution = CUBEMAP_RESOLUTION;
|
||||
float saTexel = 4.0*PI/(6.0*resolution*resolution);
|
||||
float saSample = 1.0/(float(MAX_SAMPLES)*pdf + 0.0001);
|
||||
float mipLevel = ((roughness == 0.0) ? 0.0 : 0.5*log2(saSample/saTexel));
|
||||
|
||||
prefilteredColor += textureLod(environmentMap, L, mipLevel).rgb*NdotL;
|
||||
totalWeight += NdotL;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate prefilter average color
|
||||
prefilteredColor = prefilteredColor/totalWeight;
|
||||
|
||||
// Calculate final fragment color
|
||||
finalColor = vec4(prefilteredColor, 1.0);
|
||||
}
|
@@ -15,7 +15,7 @@ in vec3 fragPosition;
|
||||
uniform samplerCube environmentMap;
|
||||
|
||||
// Constant values
|
||||
const float PI = 3.14159265359f;
|
||||
const float PI = 3.14159265359;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
@@ -31,8 +31,8 @@ void main()
|
||||
vec3 right = cross(up, normal);
|
||||
up = cross(normal, right);
|
||||
|
||||
float sampleDelta = 0.025f;
|
||||
float nrSamples = 0.0f;
|
||||
float sampleDelta = 0.025;
|
||||
float nrSamples = 0.0;
|
||||
|
||||
for (float phi = 0.0; phi < 2.0*PI; phi += sampleDelta)
|
||||
{
|
||||
|
@@ -73,6 +73,8 @@ vec3 fresnelSchlick(float cosTheta, vec3 F0);
|
||||
vec3 fresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness);
|
||||
vec2 ParallaxMapping(vec2 texCoords, vec3 viewDir);
|
||||
|
||||
// WARNING: There is some weird behaviour with this function, always returns black!
|
||||
// Yes, I even tried: return texture(property.sampler, texCoord).rgb;
|
||||
vec3 ComputeMaterialProperty(MaterialProperty property)
|
||||
{
|
||||
vec3 result = vec3(0.0, 0.0, 0.0);
|
||||
@@ -187,17 +189,17 @@ void main()
|
||||
else texCoord = fragTexCoord; // Use default texture coordinates
|
||||
|
||||
// Fetch material values from texture sampler or color attributes
|
||||
vec3 color = ComputeMaterialProperty(albedo);
|
||||
vec3 metal = ComputeMaterialProperty(metalness);
|
||||
vec3 rough = ComputeMaterialProperty(roughness);
|
||||
vec3 emiss = ComputeMaterialProperty(emission);
|
||||
vec3 ao = ComputeMaterialProperty(occlusion);
|
||||
vec3 color = texture(albedo.sampler, texCoord).rgb; //ComputeMaterialProperty(albedo);
|
||||
vec3 metal = texture(metalness.sampler, texCoord).rgb; //ComputeMaterialProperty(metalness);
|
||||
vec3 rough = texture(roughness.sampler, texCoord).rgb; //ComputeMaterialProperty(roughness);
|
||||
vec3 emiss = texture(emission.sampler, texCoord).rgb; //ComputeMaterialProperty(emission);
|
||||
vec3 ao = texture(occlusion.sampler, texCoord).rgb; //ComputeMaterialProperty(occlusion);
|
||||
|
||||
// Check if normal mapping is enabled
|
||||
if (normals.useSampler == 1)
|
||||
{
|
||||
// Fetch normal map color and transform lighting values to tangent space
|
||||
normal = ComputeMaterialProperty(normals);
|
||||
normal = texture(normals.sampler, texCoord).rgb; //ComputeMaterialProperty(normals);
|
||||
normal = normalize(normal*2.0 - 1.0);
|
||||
normal = normalize(normal*TBN);
|
||||
|
||||
|
@@ -34,7 +34,7 @@ void main()
|
||||
mat3 normalMatrix = transpose(inverse(mat3(matModel)));
|
||||
|
||||
// Calculate fragment position based on model transformations
|
||||
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0f));
|
||||
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
|
||||
|
||||
// Send vertex attributes to fragment shader
|
||||
fragTexCoord = vertexTexCoord;
|
||||
|
@@ -18,7 +18,7 @@ uniform samplerCube environmentMap;
|
||||
uniform float roughness;
|
||||
|
||||
// Constant values
|
||||
const float PI = 3.14159265359f;
|
||||
const float PI = 3.14159265359;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
@@ -33,6 +33,8 @@
|
||||
#ifndef RLIGHTS_H
|
||||
#define RLIGHTS_H
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Defines and Macros
|
||||
//----------------------------------------------------------------------------------
|
||||
@@ -65,15 +67,10 @@ typedef struct {
|
||||
extern "C" { // Prevents name mangling of functions
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
int lightsCount = 0; // Current amount of created lights
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
Light CreateLight(int type, Vector3 pos, Vector3 targ, Color color, Shader shader); // Defines a light and get locations from PBR shader
|
||||
void CreateLight(int type, Vector3 pos, Vector3 targ, Color color, Shader shader); // Defines a light and get locations from PBR shader
|
||||
void UpdateLightValues(Shader shader, Light light); // Send to PBR shader light values
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -106,7 +103,8 @@ void UpdateLightValues(Shader shader, Light light);
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
// ...
|
||||
static Light lights[MAX_LIGHTS] = { 0 };
|
||||
static int lightsCount = 0; // Current amount of created lights
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module specific Functions Declaration
|
||||
@@ -118,7 +116,7 @@ void UpdateLightValues(Shader shader, Light light);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Defines a light and get locations from PBR shader
|
||||
Light CreateLight(int type, Vector3 pos, Vector3 targ, Color color, Shader shader)
|
||||
void CreateLight(int type, Vector3 pos, Vector3 targ, Color color, Shader shader)
|
||||
{
|
||||
Light light = { 0 };
|
||||
|
||||
@@ -148,10 +146,10 @@ Light CreateLight(int type, Vector3 pos, Vector3 targ, Color color, Shader shade
|
||||
light.colorLoc = GetShaderLocation(shader, colorName);
|
||||
|
||||
UpdateLightValues(shader, light);
|
||||
|
||||
lights[lightsCount] = light;
|
||||
lightsCount++;
|
||||
}
|
||||
|
||||
return light;
|
||||
}
|
||||
|
||||
// Send to PBR shader light values
|
||||
|
@@ -2,78 +2,71 @@
|
||||
*
|
||||
* raylib [network] example - Client/Server ping-pong
|
||||
*
|
||||
* Welcome to raylib!
|
||||
* This example has been created using raylib 3.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
||||
* Note that compiled executable is placed in the same folder as .c file
|
||||
*
|
||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
||||
* raylib official webpage: www.raylib.com
|
||||
*
|
||||
* Enjoy using raylib. :)
|
||||
*
|
||||
* 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) 2013-2016 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2019-2020 Jak Barnes (@syphonx) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
#include "rnet.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#define RNET_IMPLEMENTATION
|
||||
#include "rnet.h"
|
||||
|
||||
float elapsed = 0.0f;
|
||||
float delay = 1.0f;
|
||||
bool ping = false;
|
||||
bool pong = false;
|
||||
bool connected = false;
|
||||
bool client_connected = false;
|
||||
bool clientConnected = false;
|
||||
const char *pingmsg = "Ping!";
|
||||
const char *pongmsg = "Pong!";
|
||||
int msglen = 0;
|
||||
SocketConfig server_cfg = {.host = "127.0.0.1", .port = "4950", .type = SOCKET_TCP, .server = true, .nonblocking = true};
|
||||
SocketConfig client_cfg = {.host = "127.0.0.1", .port = "4950", .type = SOCKET_TCP, .nonblocking = true};
|
||||
SocketConfig connection_cfg = {.nonblocking = true};
|
||||
SocketResult *server_res = NULL;
|
||||
SocketResult *client_res = NULL;
|
||||
SocketSet * socket_set = NULL;
|
||||
SocketConfig serverConfig = { .host = "127.0.0.1", .port = "4950", .type = SOCKET_TCP, .server = true, .nonblocking = true };
|
||||
SocketConfig clientConfig = { .host = "127.0.0.1", .port = "4950", .type = SOCKET_TCP, .nonblocking = true };
|
||||
SocketConfig connectionConfig = { .nonblocking = true };
|
||||
SocketResult *serverResult = NULL;
|
||||
SocketResult *clientResult = NULL;
|
||||
SocketSet *socketSet = NULL;
|
||||
Socket *connection = NULL;
|
||||
char recvBuffer[512];
|
||||
char receiveBuffer[512] = { 0 };
|
||||
|
||||
// Attempt to connect to the network (Either TCP, or UDP)
|
||||
void NetworkConnect()
|
||||
static void NetworkConnect(void)
|
||||
{
|
||||
// If the server is configured as UDP, ignore connection requests
|
||||
if (server_cfg.type == SOCKET_UDP && client_cfg.type == SOCKET_UDP) {
|
||||
if ((serverConfig.type == SOCKET_UDP) && (clientConfig.type == SOCKET_UDP))
|
||||
{
|
||||
ping = true;
|
||||
connected = true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the client is connected, run the server code to check for a connection
|
||||
if (client_connected) {
|
||||
int active = CheckSockets(socket_set, 0);
|
||||
if (active != 0) {
|
||||
TraceLog(LOG_DEBUG,
|
||||
"There are currently %d socket(s) with data to be processed.", active);
|
||||
}
|
||||
if (active > 0) {
|
||||
if ((connection = SocketAccept(server_res->socket, &connection_cfg)) != NULL) {
|
||||
AddSocket(socket_set, connection);
|
||||
ping = true;
|
||||
if (clientConnected)
|
||||
{
|
||||
int active = CheckSockets(socketSet, 0);
|
||||
if (active != 0) TraceLog(LOG_INFO, "There are currently %d socket(s) with data to be processed.", active);
|
||||
|
||||
if (active > 0)
|
||||
{
|
||||
if ((connection = SocketAccept(serverResult->socket, &connectionConfig)) != NULL)
|
||||
{
|
||||
AddSocket(socketSet, connection);
|
||||
connected = true;
|
||||
ping = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check if we're connected every _delay_ seconds
|
||||
elapsed += GetFrameTime();
|
||||
if (elapsed > delay) {
|
||||
if (IsSocketConnected(client_res->socket)) {
|
||||
client_connected = true;
|
||||
}
|
||||
if (elapsed > delay)
|
||||
{
|
||||
if (IsSocketConnected(clientResult->socket)) clientConnected = true;
|
||||
|
||||
elapsed = 0.0f;
|
||||
}
|
||||
}
|
||||
@@ -82,144 +75,138 @@ void NetworkConnect()
|
||||
|
||||
// Once connected to the network, check the sockets for pending information
|
||||
// and when information is ready, send either a Ping or a Pong.
|
||||
void NetworkUpdate()
|
||||
static void UpdateNetwork(void)
|
||||
{
|
||||
// CheckSockets
|
||||
//
|
||||
// If any of the sockets in the socket_set are pending (received data, or requests)
|
||||
// then mark the socket as being ready. You can check this with IsSocketReady(client_res->socket)
|
||||
int active = CheckSockets(socket_set, 0);
|
||||
if (active != 0) {
|
||||
TraceLog(LOG_DEBUG,
|
||||
"There are currently %d socket(s) with data to be processed.", active);
|
||||
}
|
||||
// CheckSockets, if any of the sockets in the socketSet are pending (received data, or requests)
|
||||
// then mark the socket as being ready. You can check this with IsSocketReady(clientResult->socket)
|
||||
int active = CheckSockets(socketSet, 0);
|
||||
if (active != 0) TraceLog(LOG_DEBUG, "There are currently %d socket(s) with data to be processed.", active);
|
||||
|
||||
// IsSocketReady
|
||||
//
|
||||
// If the socket is ready, attempt to receive data from the socket
|
||||
// IsSocketReady, if the socket is ready, attempt to receive data from the socket
|
||||
int bytesRecv = 0;
|
||||
if (server_cfg.type == SOCKET_UDP && client_cfg.type == SOCKET_UDP) {
|
||||
if (IsSocketReady(client_res->socket)) {
|
||||
bytesRecv = SocketReceive(client_res->socket, recvBuffer, msglen);
|
||||
}
|
||||
if (IsSocketReady(server_res->socket)) {
|
||||
bytesRecv = SocketReceive(server_res->socket, recvBuffer, msglen);
|
||||
}
|
||||
} else {
|
||||
if (IsSocketReady(connection)) {
|
||||
bytesRecv = SocketReceive(connection, recvBuffer, msglen);
|
||||
}
|
||||
if ((serverConfig.type == SOCKET_UDP) && (clientConfig.type == SOCKET_UDP))
|
||||
{
|
||||
if (IsSocketReady(clientResult->socket)) bytesRecv = SocketReceive(clientResult->socket, receiveBuffer, msglen);
|
||||
if (IsSocketReady(serverResult->socket)) bytesRecv = SocketReceive(serverResult->socket, receiveBuffer, msglen);
|
||||
}
|
||||
else if (IsSocketReady(connection)) bytesRecv = SocketReceive(connection, receiveBuffer, msglen);
|
||||
|
||||
// If we received data, was that data a "Ping!" or a "Pong!"
|
||||
if (bytesRecv > 0) {
|
||||
if (strcmp(recvBuffer, pingmsg) == 0) { pong = true; }
|
||||
if (strcmp(recvBuffer, pongmsg) == 0) { ping = true; }
|
||||
if (bytesRecv > 0)
|
||||
{
|
||||
if (strcmp(receiveBuffer, pingmsg) == 0) { pong = true; }
|
||||
if (strcmp(receiveBuffer, pongmsg) == 0) { ping = true; }
|
||||
}
|
||||
|
||||
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice versa
|
||||
elapsed += GetFrameTime();
|
||||
if (elapsed > delay) {
|
||||
if (ping) {
|
||||
if (elapsed > delay)
|
||||
{
|
||||
if (ping)
|
||||
{
|
||||
ping = false;
|
||||
if (server_cfg.type == SOCKET_UDP && client_cfg.type == SOCKET_UDP) {
|
||||
SocketSend(client_res->socket, pingmsg, msglen);
|
||||
} else {
|
||||
SocketSend(client_res->socket, pingmsg, msglen);
|
||||
if (serverConfig.type == SOCKET_UDP && clientConfig.type == SOCKET_UDP) SocketSend(clientResult->socket, pingmsg, msglen);
|
||||
else SocketSend(clientResult->socket, pingmsg, msglen);
|
||||
}
|
||||
} else if (pong) {
|
||||
else if (pong)
|
||||
{
|
||||
pong = false;
|
||||
if (server_cfg.type == SOCKET_UDP && client_cfg.type == SOCKET_UDP) {
|
||||
SocketSend(client_res->socket, pongmsg, msglen);
|
||||
} else {
|
||||
SocketSend(client_res->socket, pongmsg, msglen);
|
||||
}
|
||||
if (serverConfig.type == SOCKET_UDP && clientConfig.type == SOCKET_UDP) SocketSend(clientResult->socket, pongmsg, msglen);
|
||||
else SocketSend(clientResult->socket, pongmsg, msglen);
|
||||
}
|
||||
|
||||
elapsed = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
int main(void)
|
||||
{
|
||||
// Setup
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
InitWindow(
|
||||
screenWidth, screenHeight, "raylib [network] example - ping pong");
|
||||
SetTargetFPS(60);
|
||||
SetTraceLogLevel(LOG_DEBUG);
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
// Networking
|
||||
InitNetwork();
|
||||
InitWindow(screenWidth, screenHeight, "raylib [network] example - ping pong");
|
||||
|
||||
// Create the server
|
||||
//
|
||||
// Performs
|
||||
// getaddrinfo
|
||||
// socket
|
||||
// setsockopt
|
||||
// bind
|
||||
// listen
|
||||
server_res = AllocSocketResult();
|
||||
if (!SocketCreate(&server_cfg, server_res)) {
|
||||
TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d",
|
||||
server_res->status, server_res->socket->status);
|
||||
} else {
|
||||
if (!SocketBind(&server_cfg, server_res)) {
|
||||
TraceLog(LOG_WARNING, "Failed to bind server: status %d, errno %d",
|
||||
server_res->status, server_res->socket->status);
|
||||
} else {
|
||||
if (!(server_cfg.type == SOCKET_UDP)) {
|
||||
if (!SocketListen(&server_cfg, server_res)) {
|
||||
TraceLog(LOG_WARNING,
|
||||
"Failed to start listen server: status %d, errno %d",
|
||||
server_res->status, server_res->socket->status);
|
||||
InitNetworkDevice(); // Init network communications
|
||||
|
||||
// Create the server: getaddrinfo + socket + setsockopt + bind + listen
|
||||
serverResult = LoadSocketResult();
|
||||
if (!SocketCreate(&serverConfig, serverResult))
|
||||
{
|
||||
TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!SocketBind(&serverConfig, serverResult))
|
||||
{
|
||||
TraceLog(LOG_WARNING, "Failed to bind server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(serverConfig.type == SOCKET_UDP))
|
||||
{
|
||||
if (!SocketListen(&serverConfig, serverResult))
|
||||
{
|
||||
TraceLog(LOG_WARNING, "Failed to start listen server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create the client
|
||||
//
|
||||
// Performs
|
||||
// getaddrinfo
|
||||
// socket
|
||||
// setsockopt
|
||||
// connect (TCP only)
|
||||
client_res = AllocSocketResult();
|
||||
if (!SocketCreate(&client_cfg, client_res)) {
|
||||
TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d",
|
||||
client_res->status, client_res->socket->status);
|
||||
} else {
|
||||
if (!(client_cfg.type == SOCKET_UDP)) {
|
||||
if (!SocketConnect(&client_cfg, client_res)) {
|
||||
TraceLog(LOG_WARNING,
|
||||
"Failed to connect to server: status %d, errno %d",
|
||||
client_res->status, client_res->socket->status);
|
||||
// Create the client: getaddrinfo + socket + setsockopt + connect (TCP only)
|
||||
clientResult = LoadSocketResult();
|
||||
if (!SocketCreate(&clientConfig, clientResult))
|
||||
{
|
||||
TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(clientConfig.type == SOCKET_UDP))
|
||||
{
|
||||
if (!SocketConnect(&clientConfig, clientResult))
|
||||
{
|
||||
TraceLog(LOG_WARNING, "Failed to connect to server: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create & Add sockets to the socket set
|
||||
socket_set = AllocSocketSet(3);
|
||||
msglen = strlen(pingmsg) + 1;
|
||||
memset(recvBuffer, '\0', sizeof(recvBuffer));
|
||||
AddSocket(socket_set, server_res->socket);
|
||||
AddSocket(socket_set, client_res->socket);
|
||||
// Create and add sockets to the socket set
|
||||
socketSet = LoadSocketSet(3);
|
||||
|
||||
AddSocket(socketSet, serverResult->socket);
|
||||
AddSocket(socketSet, clientResult->socket);
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) {
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (connected) UpdateNetwork();
|
||||
//else NetworkConnect();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
if (connected) {
|
||||
NetworkUpdate();
|
||||
} else {
|
||||
NetworkConnect();
|
||||
}
|
||||
|
||||
// TODO: Draw relevant connection info
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
CloseWindow();
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseNetworkDevice(); // Close network communication
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
@@ -2,79 +2,77 @@
|
||||
*
|
||||
* raylib [network] example - Resolve Host
|
||||
*
|
||||
* Welcome to raylib!
|
||||
* This example has been created using raylib 3.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
||||
* Note that compiled executable is placed in the same folder as .c file
|
||||
*
|
||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
||||
* raylib official webpage: www.raylib.com
|
||||
*
|
||||
* Enjoy using raylib. :)
|
||||
*
|
||||
* 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) 2013-2016 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2019-2020 Jak Barnes (@syphonx) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define RNET_IMPLEMENTATION
|
||||
#include "rnet.h"
|
||||
|
||||
char buffer[ADDRESS_IPV6_ADDRSTRLEN];
|
||||
uint16_t port = 0;
|
||||
|
||||
int main()
|
||||
int main(void)
|
||||
{
|
||||
// Setup
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
InitWindow(
|
||||
screenWidth, screenHeight, "raylib [network] example - ping pong");
|
||||
SetTargetFPS(60);
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
SetTraceLogLevel(LOG_DEBUG);
|
||||
InitWindow(screenWidth, screenHeight, "raylib [network] example - resolve host");
|
||||
|
||||
// Networking
|
||||
InitNetwork();
|
||||
InitNetworkDevice(); // Init network communications
|
||||
|
||||
AddressInformation* addr = AllocAddressList(1);
|
||||
int count = ResolveHost(
|
||||
NULL,
|
||||
"5210",
|
||||
ADDRESS_TYPE_IPV4,
|
||||
0 // Uncomment any of these flags
|
||||
char buffer[ADDRESS_IPV6_ADDRSTRLEN];
|
||||
unsigned short port = 0;
|
||||
|
||||
AddressInformation *address = LoadAddressList(1);
|
||||
|
||||
// Address info flags
|
||||
// ADDRESS_INFO_NUMERICHOST // or try them in conjunction to
|
||||
// ADDRESS_INFO_NUMERICSERV // specify custom behaviour from
|
||||
// ADDRESS_INFO_DNS_ONLY // the function getaddrinfo()
|
||||
// ADDRESS_INFO_ALL //
|
||||
// ADDRESS_INFO_FQDN // e.g. ADDRESS_INFO_CANONNAME | ADDRESS_INFO_NUMERICSERV
|
||||
,
|
||||
addr
|
||||
);
|
||||
int count = ResolveHost(NULL, "5210", ADDRESS_TYPE_IPV4, 0, address);
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
GetAddressHostAndPort(addr[0], buffer, &port);
|
||||
TraceLog(LOG_INFO, "Resolved to ip %s::%d\n", buffer, port);
|
||||
GetAddressHostAndPort(address[0], buffer, &port);
|
||||
TraceLog(LOG_INFO, "Resolved to ip %s::%d", buffer, port);
|
||||
}
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose())
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
// Clear
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
// End draw
|
||||
// TODO: Draw relevant connection info
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
CloseWindow();
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseNetworkDevice(); // Close network communication
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
@@ -2,150 +2,141 @@
|
||||
*
|
||||
* raylib [network] example - TCP Client
|
||||
*
|
||||
* Welcome to raylib!
|
||||
* This example has been created using raylib 3.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
||||
* Note that compiled executable is placed in the same folder as .c file
|
||||
*
|
||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
||||
* raylib official webpage: www.raylib.com
|
||||
*
|
||||
* Enjoy using raylib. :)
|
||||
*
|
||||
* 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) 2013-2016 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2019-2020 Jak Barnes (@syphonx) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define RNET_IMPLEMENTATION
|
||||
#include "rnet.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [network] example - tcp client");
|
||||
|
||||
InitNetworkDevice(); // Init network communications
|
||||
|
||||
float elapsed = 0.0f;
|
||||
float delay = 1.0f;
|
||||
bool ping = false;
|
||||
bool pong = false;
|
||||
bool connected = false;
|
||||
const char *pingmsg = "Ping!";
|
||||
const char *pongmsg = "Pong!";
|
||||
int msglen = 0;
|
||||
SocketConfig client_cfg = {.host = "127.0.0.1", .port = "4950", .type = SOCKET_TCP, .nonblocking = true};
|
||||
SocketResult *client_res = NULL;
|
||||
SocketSet * socket_set = NULL;
|
||||
char recvBuffer[512];
|
||||
|
||||
// Attempt to connect to the network (Either TCP, or UDP)
|
||||
void NetworkConnect()
|
||||
bool ping = false;
|
||||
bool pong = false;
|
||||
float elapsed = 0.0f;
|
||||
float delay = 1.0f;
|
||||
bool connected = false;
|
||||
|
||||
SocketConfig clientConfig = {
|
||||
.host = "127.0.0.1",
|
||||
.port = "4950",
|
||||
.type = SOCKET_TCP,
|
||||
.nonblocking = true
|
||||
};
|
||||
|
||||
SocketSet *socketSet = NULL;
|
||||
SocketResult *clientResult = NULL;
|
||||
char receiveBuffer[512] = { 0 };
|
||||
|
||||
// Create the client: getaddrinfo + socket + setsockopt + connect (TCP only)
|
||||
clientResult = LoadSocketResult();
|
||||
if (!SocketCreate(&clientConfig, clientResult)) TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
||||
else
|
||||
{
|
||||
// Check if we're connected every _delay_ seconds
|
||||
elapsed += GetFrameTime();
|
||||
if (elapsed > delay) {
|
||||
if (IsSocketConnected(client_res->socket)) { connected = true; }
|
||||
elapsed = 0.0f;
|
||||
if (!(clientConfig.type == SOCKET_UDP))
|
||||
{
|
||||
if (!SocketConnect(&clientConfig, clientResult)) TraceLog(LOG_WARNING, "Failed to connect to server: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
||||
}
|
||||
}
|
||||
|
||||
// Create and add sockets to the socket set
|
||||
socketSet = LoadSocketSet(1);
|
||||
AddSocket(socketSet, clientResult->socket);
|
||||
|
||||
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 (connected)
|
||||
{
|
||||
// Once connected to the network, check the sockets for pending information
|
||||
// and when information is ready, send either a Ping or a Pong.
|
||||
void NetworkUpdate()
|
||||
{
|
||||
// CheckSockets
|
||||
//
|
||||
// If any of the sockets in the socket_set are pending (received data, or requests)
|
||||
// then mark the socket as being ready. You can check this with IsSocketReady(client_res->socket)
|
||||
int active = CheckSockets(socket_set, 0);
|
||||
if (active != 0) {
|
||||
TraceLog(LOG_DEBUG,
|
||||
"There are currently %d socket(s) with data to be processed.", active);
|
||||
}
|
||||
|
||||
// IsSocketReady
|
||||
//
|
||||
// If the socket is ready, attempt to receive data from the socket
|
||||
// CheckSockets, if any of the sockets in the socketSet are pending (received data, or requests)
|
||||
// then mark the socket as being ready. You can check this with IsSocketReady(clientResult->socket)
|
||||
int active = CheckSockets(socketSet, 0);
|
||||
if (active != 0) TraceLog(LOG_DEBUG, "There are currently %d socket(s) with data to be processed.", active);
|
||||
|
||||
// IsSocketReady, if the socket is ready, attempt to receive data from the socket
|
||||
int bytesRecv = 0;
|
||||
if (IsSocketReady(client_res->socket)) {
|
||||
bytesRecv = SocketReceive(client_res->socket, recvBuffer, msglen);
|
||||
}
|
||||
if (IsSocketReady(clientResult->socket)) bytesRecv = SocketReceive(clientResult->socket, receiveBuffer, strlen(pingmsg) + 1);
|
||||
|
||||
// If we received data, was that data a "Ping!" or a "Pong!"
|
||||
if (bytesRecv > 0) {
|
||||
if (strcmp(recvBuffer, pingmsg) == 0) { pong = true; }
|
||||
if (strcmp(recvBuffer, pongmsg) == 0) { ping = true; }
|
||||
if (bytesRecv > 0)
|
||||
{
|
||||
if (strcmp(receiveBuffer, pingmsg) == 0) { pong = true; }
|
||||
if (strcmp(receiveBuffer, pongmsg) == 0) { ping = true; }
|
||||
}
|
||||
|
||||
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice versa
|
||||
elapsed += GetFrameTime();
|
||||
if (elapsed > delay) {
|
||||
if (ping) {
|
||||
if (elapsed > delay)
|
||||
{
|
||||
if (ping)
|
||||
{
|
||||
ping = false;
|
||||
SocketSend(client_res->socket, pingmsg, msglen);
|
||||
} else if (pong) {
|
||||
pong = false;
|
||||
SocketSend(client_res->socket, pongmsg, msglen);
|
||||
SocketSend(clientResult->socket, pingmsg, strlen(pingmsg) + 1);
|
||||
}
|
||||
else if (pong)
|
||||
{
|
||||
pong = false;
|
||||
SocketSend(clientResult->socket, pongmsg, strlen(pingmsg) + 1);
|
||||
}
|
||||
|
||||
elapsed = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
else
|
||||
{
|
||||
// Setup
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
InitWindow(
|
||||
screenWidth, screenHeight, "raylib [network] example - tcp client");
|
||||
SetTargetFPS(60);
|
||||
SetTraceLogLevel(LOG_DEBUG);
|
||||
|
||||
// Networking
|
||||
InitNetwork();
|
||||
|
||||
// Create the client
|
||||
//
|
||||
// Performs
|
||||
// getaddrinfo
|
||||
// socket
|
||||
// setsockopt
|
||||
// connect (TCP only)
|
||||
client_res = AllocSocketResult();
|
||||
if (!SocketCreate(&client_cfg, client_res)) {
|
||||
TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d",
|
||||
client_res->status, client_res->socket->status);
|
||||
} else {
|
||||
if (!(client_cfg.type == SOCKET_UDP)) {
|
||||
if (!SocketConnect(&client_cfg, client_res)) {
|
||||
TraceLog(LOG_WARNING,
|
||||
"Failed to connect to server: status %d, errno %d",
|
||||
client_res->status, client_res->socket->status);
|
||||
}
|
||||
// Check if we're connected every delay seconds
|
||||
elapsed += GetFrameTime();
|
||||
if (elapsed > delay)
|
||||
{
|
||||
if (IsSocketConnected(clientResult->socket)) { connected = true; }
|
||||
elapsed = 0.0f;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Create & Add sockets to the socket set
|
||||
socket_set = AllocSocketSet(1);
|
||||
msglen = strlen(pingmsg) + 1;
|
||||
memset(recvBuffer, '\0', sizeof(recvBuffer));
|
||||
AddSocket(socket_set, client_res->socket);
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) {
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
if (connected) {
|
||||
NetworkUpdate();
|
||||
} else {
|
||||
NetworkConnect();
|
||||
}
|
||||
|
||||
// TODO: Draw relevant connection info
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
CloseWindow();
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseNetworkDevice(); // Close network communication
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
@@ -2,164 +2,161 @@
|
||||
*
|
||||
* raylib [network] example - TCP Server
|
||||
*
|
||||
* Welcome to raylib!
|
||||
* This example has been created using raylib 3.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
||||
* Note that compiled executable is placed in the same folder as .c file
|
||||
*
|
||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
||||
* raylib official webpage: www.raylib.com
|
||||
*
|
||||
* Enjoy using raylib. :)
|
||||
*
|
||||
* 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) 2013-2016 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2019-2020 Jak Barnes (@syphonx) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define RNET_IMPLEMENTATION
|
||||
#include "rnet.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [network] example - tcp server");
|
||||
|
||||
InitNetworkDevice(); // Init network communications
|
||||
|
||||
float elapsed = 0.0f;
|
||||
float delay = 1.0f;
|
||||
bool ping = false;
|
||||
bool pong = false;
|
||||
bool connected = false;
|
||||
const char *pingmsg = "Ping!";
|
||||
const char *pongmsg = "Pong!";
|
||||
int msglen = 0;
|
||||
SocketConfig server_cfg = {.host = "127.0.0.1", .port = "4950", .type = SOCKET_TCP, .server = true, .nonblocking = true};
|
||||
SocketConfig connection_cfg = {.nonblocking = true};
|
||||
SocketResult *server_res = NULL;
|
||||
SocketSet * socket_set = NULL;
|
||||
|
||||
bool ping = false;
|
||||
bool pong = false;
|
||||
float elapsed = 0.0f;
|
||||
float delay = 1.0f;
|
||||
bool connected = false;
|
||||
|
||||
SocketConfig serverConfig = {
|
||||
.host = "127.0.0.1",
|
||||
.port = "4950",
|
||||
.type = SOCKET_TCP,
|
||||
.server = true,
|
||||
.nonblocking = true
|
||||
};
|
||||
|
||||
SocketConfig connectionConfig = { .nonblocking = true };
|
||||
|
||||
Socket *connection = NULL;
|
||||
char recvBuffer[512];
|
||||
SocketSet *socketSet = NULL;
|
||||
SocketResult *serverResult = NULL;
|
||||
char receiveBuffer[512] = { 0 };
|
||||
|
||||
// Attempt to connect to the network (Either TCP, or UDP)
|
||||
void NetworkConnect()
|
||||
// Create the server: getaddrinfo + socket + setsockopt + bind + listen
|
||||
serverResult = LoadSocketResult();
|
||||
if (!SocketCreate(&serverConfig, serverResult))
|
||||
{
|
||||
int active = CheckSockets(socket_set, 0);
|
||||
if (active != 0) {
|
||||
TraceLog(LOG_DEBUG,
|
||||
"There are currently %d socket(s) with data to be processed.", active);
|
||||
TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||
}
|
||||
if (active > 0) {
|
||||
if ((connection = SocketAccept(server_res->socket, &connection_cfg)) != NULL) {
|
||||
AddSocket(socket_set, connection);
|
||||
ping = true;
|
||||
connected = true;
|
||||
else
|
||||
{
|
||||
if (!SocketBind(&serverConfig, serverResult))
|
||||
{
|
||||
TraceLog(LOG_WARNING, "Failed to bind server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(serverConfig.type == SOCKET_UDP))
|
||||
{
|
||||
if (!SocketListen(&serverConfig, serverResult)) TraceLog(LOG_WARNING, "Failed to start listen server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create and add sockets to the socket set
|
||||
socketSet = LoadSocketSet(2);
|
||||
AddSocket(socketSet, serverResult->socket);
|
||||
|
||||
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 (connected)
|
||||
{
|
||||
// Once connected to the network, check the sockets for pending information
|
||||
// and when information is ready, send either a Ping or a Pong.
|
||||
void NetworkUpdate()
|
||||
{
|
||||
// CheckSockets
|
||||
//
|
||||
// If any of the sockets in the socket_set are pending (received data, or requests)
|
||||
// then mark the socket as being ready. You can check this with IsSocketReady(client_res->socket)
|
||||
int active = CheckSockets(socket_set, 0);
|
||||
if (active != 0) {
|
||||
TraceLog(LOG_DEBUG,
|
||||
"There are currently %d socket(s) with data to be processed.", active);
|
||||
}
|
||||
|
||||
// IsSocketReady
|
||||
//
|
||||
// If the socket is ready, attempt to receive data from the socket
|
||||
// CheckSockets, if any of the sockets in the socketSet are pending (received data, or requests)
|
||||
// then mark the socket as being ready. You can check this with IsSocketReady(client_res->socket)
|
||||
int active = CheckSockets(socketSet, 0);
|
||||
if (active != 0) TraceLog(LOG_DEBUG, "There are currently %d socket(s) with data to be processed.", active);
|
||||
|
||||
// IsSocketReady, if the socket is ready, attempt to receive data from the socket
|
||||
int bytesRecv = 0;
|
||||
if (IsSocketReady(connection)) {
|
||||
bytesRecv = SocketReceive(connection, recvBuffer, msglen);
|
||||
}
|
||||
if (IsSocketReady(connection)) bytesRecv = SocketReceive(connection, receiveBuffer, strlen(pingmsg) + 1);
|
||||
|
||||
// If we received data, was that data a "Ping!" or a "Pong!"
|
||||
if (bytesRecv > 0) {
|
||||
if (strcmp(recvBuffer, pingmsg) == 0) { pong = true; }
|
||||
if (strcmp(recvBuffer, pongmsg) == 0) { ping = true; }
|
||||
if (bytesRecv > 0)
|
||||
{
|
||||
if (strcmp(receiveBuffer, pingmsg) == 0) { pong = true; }
|
||||
if (strcmp(receiveBuffer, pongmsg) == 0) { ping = true; }
|
||||
}
|
||||
|
||||
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice versa
|
||||
elapsed += GetFrameTime();
|
||||
if (elapsed > delay) {
|
||||
if (ping) {
|
||||
if (elapsed > delay)
|
||||
{
|
||||
if (ping)
|
||||
{
|
||||
ping = false;
|
||||
SocketSend(connection, pingmsg, msglen);
|
||||
} else if (pong) {
|
||||
pong = false;
|
||||
SocketSend(connection, pongmsg, msglen);
|
||||
SocketSend(connection, pingmsg, strlen(pingmsg) + 1);
|
||||
}
|
||||
else if (pong)
|
||||
{
|
||||
pong = false;
|
||||
SocketSend(connection, pongmsg, strlen(pingmsg) + 1);
|
||||
}
|
||||
|
||||
elapsed = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
else
|
||||
{
|
||||
// Setup
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
InitWindow(
|
||||
screenWidth, screenHeight, "raylib [network] example - tcp server");
|
||||
SetTargetFPS(60);
|
||||
SetTraceLogLevel(LOG_DEBUG);
|
||||
// Attempt to connect to the network (Either TCP, or UDP)
|
||||
int active = CheckSockets(socketSet, 0);
|
||||
if (active != 0) TraceLog(LOG_DEBUG, "There are currently %d socket(s) with data to be processed.", active);
|
||||
|
||||
// Networking
|
||||
InitNetwork();
|
||||
|
||||
// Create the server
|
||||
//
|
||||
// Performs
|
||||
// getaddrinfo
|
||||
// socket
|
||||
// setsockopt
|
||||
// bind
|
||||
// listen
|
||||
server_res = AllocSocketResult();
|
||||
if (!SocketCreate(&server_cfg, server_res)) {
|
||||
TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d",
|
||||
server_res->status, server_res->socket->status);
|
||||
} else {
|
||||
if (!SocketBind(&server_cfg, server_res)) {
|
||||
TraceLog(LOG_WARNING, "Failed to bind server: status %d, errno %d",
|
||||
server_res->status, server_res->socket->status);
|
||||
} else {
|
||||
if (!(server_cfg.type == SOCKET_UDP)) {
|
||||
if (!SocketListen(&server_cfg, server_res)) {
|
||||
TraceLog(LOG_WARNING,
|
||||
"Failed to start listen server: status %d, errno %d",
|
||||
server_res->status, server_res->socket->status);
|
||||
}
|
||||
if (active > 0)
|
||||
{
|
||||
if ((connection = SocketAccept(serverResult->socket, &connectionConfig)) != NULL)
|
||||
{
|
||||
AddSocket(socketSet, connection);
|
||||
connected = true;
|
||||
ping = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Create & Add sockets to the socket set
|
||||
socket_set = AllocSocketSet(2);
|
||||
msglen = strlen(pingmsg) + 1;
|
||||
memset(recvBuffer, '\0', sizeof(recvBuffer));
|
||||
AddSocket(socket_set, server_res->socket);
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) {
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
if (connected) {
|
||||
NetworkUpdate();
|
||||
} else {
|
||||
NetworkConnect();
|
||||
}
|
||||
|
||||
// TODO: Draw relevant connection info
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
CloseWindow();
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseNetworkDevice(); // Close network communication
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
@@ -2,47 +2,38 @@
|
||||
*
|
||||
* raylib [network] example - Network Test
|
||||
*
|
||||
* Welcome to raylib!
|
||||
* This example has been created using raylib 3.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
||||
* Note that compiled executable is placed in the same folder as .c file
|
||||
*
|
||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
||||
* raylib official webpage: www.raylib.com
|
||||
*
|
||||
* Enjoy using raylib. :)
|
||||
*
|
||||
* 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) 2013-2016 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2019-2020 Jak Barnes (@syphonx) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define RNET_IMPLEMENTATION
|
||||
#include "rnet.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
void test_network_initialise()
|
||||
{
|
||||
assert(InitNetwork() == true);
|
||||
assert(InitNetworkDevice() == true);
|
||||
}
|
||||
|
||||
void test_socket_result()
|
||||
{
|
||||
SocketResult *result = AllocSocketResult();
|
||||
SocketResult *result = LoadSocketResult();
|
||||
assert(result != NULL);
|
||||
FreeSocketResult(&result);
|
||||
UnloadSocketResult(&result);
|
||||
assert(result == NULL);
|
||||
}
|
||||
|
||||
void test_socket()
|
||||
{
|
||||
Socket *socket = AllocSocket();
|
||||
Socket *socket = LoadSocket();
|
||||
assert(socket != NULL);
|
||||
FreeSocket(&socket);
|
||||
UnloadSocket(&socket);
|
||||
assert(socket == NULL);
|
||||
}
|
||||
|
||||
@@ -93,7 +84,7 @@ void test_resolve_host()
|
||||
{
|
||||
const char *address = "localhost";
|
||||
const char *port = "80";
|
||||
AddressInformation *addr = AllocAddressList(3);
|
||||
AddressInformation *addr = LoadAddressList(3);
|
||||
int count = ResolveHost(address, port, ADDRESS_TYPE_ANY, 0, addr);
|
||||
|
||||
assert(GetAddressFamily(addr[0]) == ADDRESS_TYPE_IPV6);
|
||||
@@ -114,35 +105,60 @@ void test_address_list()
|
||||
void test_socket_create()
|
||||
{
|
||||
SocketConfig server_cfg = { .host = "127.0.0.1", .port = "8080", .server = true, .nonblocking = true };
|
||||
Socket * socket = AllocSocket();
|
||||
SocketResult *server_res = AllocSocketResult();
|
||||
SocketSet * socket_set = AllocSocketSet(1);
|
||||
Socket *socket = LoadSocket();
|
||||
SocketResult *server_res = LoadSocketResult();
|
||||
SocketSet *socket_set = LoadSocketSet(1);
|
||||
|
||||
assert(SocketCreate(&server_cfg, server_res));
|
||||
assert(AddSocket(socket_set, server_res->socket));
|
||||
assert(SocketListen(&server_cfg, server_res));
|
||||
}
|
||||
|
||||
int main()
|
||||
int main(void)
|
||||
{
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
InitWindow(
|
||||
screenWidth, screenHeight, "raylib [network] example - network test");
|
||||
SetTargetFPS(60);
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
// Run the tests
|
||||
test_network_initialise();
|
||||
InitWindow(screenWidth, screenHeight, "raylib [network] example - network test");
|
||||
|
||||
InitNetworkDevice(); // Init network communications
|
||||
|
||||
// Run some tests
|
||||
test_resolve_host();
|
||||
//test_socket_create();
|
||||
//test_resolve_ip();
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) {
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
|
||||
|
||||
// TODO: Draw relevant connection info
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
CloseWindow();
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseNetworkDevice(); // Close network communication
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
@@ -2,127 +2,123 @@
|
||||
*
|
||||
* raylib [network] example - UDP Client
|
||||
*
|
||||
* Welcome to raylib!
|
||||
* This example has been created using raylib 3.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
||||
* Note that compiled executable is placed in the same folder as .c file
|
||||
*
|
||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
||||
* raylib official webpage: www.raylib.com
|
||||
*
|
||||
* Enjoy using raylib. :)
|
||||
*
|
||||
* 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) 2013-2016 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2019-2020 Jak Barnes (@syphonx) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define RNET_IMPLEMENTATION
|
||||
#include "rnet.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [network] example - udp client");
|
||||
|
||||
InitNetworkDevice(); // Init network communications
|
||||
|
||||
float elapsed = 0.0f;
|
||||
float delay = 1.0f;
|
||||
bool ping = false;
|
||||
bool pong = false;
|
||||
const char *pingmsg = "Ping!";
|
||||
const char *pongmsg = "Pong!";
|
||||
int msglen = 0;
|
||||
SocketConfig client_cfg = {.host = "127.0.0.1", .port = "4950", .type = SOCKET_UDP, .nonblocking = true};
|
||||
SocketResult *client_res = NULL;
|
||||
SocketSet * socket_set = NULL;
|
||||
char recvBuffer[512];
|
||||
|
||||
// Once connected to the network, check the sockets for pending information
|
||||
// and when information is ready, send either a Ping or a Pong.
|
||||
void NetworkUpdate()
|
||||
bool ping = true;
|
||||
bool pong = false;
|
||||
float elapsed = 0.0f;
|
||||
float delay = 1.0f;
|
||||
|
||||
SocketConfig clientConfig = {
|
||||
.host = "127.0.0.1",
|
||||
.port = "4950",
|
||||
.type = SOCKET_UDP,
|
||||
.nonblocking = true
|
||||
};
|
||||
|
||||
SocketResult *clientResult = NULL;
|
||||
SocketSet *socketSet = NULL;
|
||||
char receiveBuffer[512] = { 0 };
|
||||
|
||||
// Create the client: getaddrinfo + socket + setsockopt + connect (TCP only)
|
||||
clientResult = LoadSocketResult();
|
||||
if (!SocketCreate(&clientConfig, clientResult))
|
||||
{
|
||||
// CheckSockets
|
||||
//
|
||||
// If any of the sockets in the socket_set are pending (received data, or requests)
|
||||
// then mark the socket as being ready. You can check this with IsSocketReady(client_res->socket)
|
||||
int active = CheckSockets(socket_set, 0);
|
||||
if (active != 0) {
|
||||
TraceLog(LOG_DEBUG,
|
||||
"There are currently %d socket(s) with data to be processed.", active);
|
||||
TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
||||
}
|
||||
|
||||
// IsSocketReady
|
||||
//
|
||||
// If the socket is ready, attempt to receive data from the socket
|
||||
int bytesRecv = 0;
|
||||
if (IsSocketReady(client_res->socket)) {
|
||||
bytesRecv = SocketReceive(client_res->socket, recvBuffer, msglen);
|
||||
}
|
||||
// Create and add sockets to the socket set
|
||||
socketSet = LoadSocketSet(1);
|
||||
AddSocket(socketSet, clientResult->socket);
|
||||
|
||||
// If we received data, was that data a "Ping!" or a "Pong!"
|
||||
if (bytesRecv > 0) {
|
||||
if (strcmp(recvBuffer, pingmsg) == 0) { pong = true; }
|
||||
if (strcmp(recvBuffer, pongmsg) == 0) { ping = true; }
|
||||
}
|
||||
|
||||
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice versa
|
||||
elapsed += GetFrameTime();
|
||||
if (elapsed > delay) {
|
||||
if (ping) {
|
||||
ping = false;
|
||||
SocketSend(client_res->socket, pingmsg, msglen);
|
||||
} else if (pong) {
|
||||
pong = false;
|
||||
SocketSend(client_res->socket, pongmsg, msglen);
|
||||
}
|
||||
elapsed = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// Setup
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
InitWindow(
|
||||
screenWidth, screenHeight, "raylib [network] example - udp client");
|
||||
SetTargetFPS(60);
|
||||
SetTraceLogLevel(LOG_DEBUG);
|
||||
|
||||
// Networking
|
||||
InitNetwork();
|
||||
|
||||
// Create the client
|
||||
//
|
||||
// Performs
|
||||
// getaddrinfo
|
||||
// socket
|
||||
// setsockopt
|
||||
// connect (TCP only)
|
||||
client_res = AllocSocketResult();
|
||||
if (!SocketCreate(&client_cfg, client_res)) {
|
||||
TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d",
|
||||
client_res->status, client_res->socket->status);
|
||||
}
|
||||
|
||||
// Create & Add sockets to the socket set
|
||||
socket_set = AllocSocketSet(1);
|
||||
msglen = strlen(pingmsg) + 1;
|
||||
ping = true;
|
||||
memset(recvBuffer, '\0', sizeof(recvBuffer));
|
||||
AddSocket(socket_set, client_res->socket);
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) {
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
NetworkUpdate();
|
||||
EndDrawing();
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Once connected to the network, check the sockets for pending information
|
||||
// and when information is ready, send either a Ping or a Pong.
|
||||
|
||||
// CheckSockets, if any of the sockets in the socketSet are pending (received data, or requests)
|
||||
// then mark the socket as being ready. You can check this with IsSocketReady(clientResult->socket)
|
||||
int active = CheckSockets(socketSet, 0);
|
||||
if (active != 0) TraceLog(LOG_INFO, "There are currently %d socket(s) with data to be processed.", active);
|
||||
|
||||
// IsSocketReady, if the socket is ready, attempt to receive data from the socket
|
||||
int bytesRecv = 0;
|
||||
if (IsSocketReady(clientResult->socket)) bytesRecv = SocketReceive(clientResult->socket, receiveBuffer, strlen(pingmsg) + 1);
|
||||
|
||||
// If we received data, was that data a "Ping!" or a "Pong!"
|
||||
if (bytesRecv > 0)
|
||||
{
|
||||
if (strcmp(receiveBuffer, pingmsg) == 0) { pong = true; }
|
||||
if (strcmp(receiveBuffer, pongmsg) == 0) { ping = true; }
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
CloseWindow();
|
||||
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice-versa
|
||||
elapsed += GetFrameTime();
|
||||
if (elapsed > delay)
|
||||
{
|
||||
if (ping)
|
||||
{
|
||||
ping = false;
|
||||
SocketSend(clientResult->socket, pingmsg, strlen(pingmsg) + 1);
|
||||
}
|
||||
else if (pong)
|
||||
{
|
||||
pong = false;
|
||||
SocketSend(clientResult->socket, pongmsg, strlen(pongmsg) + 1);
|
||||
}
|
||||
|
||||
elapsed = 0.0f;
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
// TODO: Draw relevant connection info
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseNetworkDevice(); // Close network communication
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
@@ -2,133 +2,127 @@
|
||||
*
|
||||
* raylib [network] example - UDP Server
|
||||
*
|
||||
* Welcome to raylib!
|
||||
* This example has been created using raylib 3.0 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
||||
* Note that compiled executable is placed in the same folder as .c file
|
||||
*
|
||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
||||
* raylib official webpage: www.raylib.com
|
||||
*
|
||||
* Enjoy using raylib. :)
|
||||
*
|
||||
* 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) 2013-2016 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2019-2020 Jak Barnes (@syphonx) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define RNET_IMPLEMENTATION
|
||||
#include "rnet.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [network] example - udp server");
|
||||
|
||||
InitNetworkDevice(); // Init network communications
|
||||
|
||||
float elapsed = 0.0f;
|
||||
float delay = 1.0f;
|
||||
bool ping = false;
|
||||
bool pong = false;
|
||||
const char *pingmsg = "Ping!";
|
||||
const char *pongmsg = "Pong!";
|
||||
int msglen = 0;
|
||||
SocketConfig server_cfg = {.host = "127.0.0.1", .port = "4950", .server = true, .type = SOCKET_UDP, .nonblocking = true};
|
||||
SocketResult *server_res = NULL;
|
||||
SocketSet * socket_set = NULL;
|
||||
char recvBuffer[512];
|
||||
|
||||
// Once connected to the network, check the sockets for pending information
|
||||
// and when information is ready, send either a Ping or a Pong.
|
||||
void NetworkUpdate()
|
||||
{
|
||||
// CheckSockets
|
||||
//
|
||||
// If any of the sockets in the socket_set are pending (received data, or requests)
|
||||
// then mark the socket as being ready. You can check this with IsSocketReady(client_res->socket)
|
||||
int active = CheckSockets(socket_set, 0);
|
||||
if (active != 0) {
|
||||
TraceLog(LOG_DEBUG,
|
||||
"There are currently %d socket(s) with data to be processed.", active);
|
||||
}
|
||||
bool ping = false;
|
||||
bool pong = false;
|
||||
float elapsed = 0.0f;
|
||||
float delay = 1.0f;
|
||||
|
||||
// IsSocketReady
|
||||
//
|
||||
// If the socket is ready, attempt to receive data from the socket
|
||||
// int bytesRecv = 0;
|
||||
// if (IsSocketReady(server_res->socket)) {
|
||||
// bytesRecv = SocketReceive(server_res->socket, recvBuffer, msglen);
|
||||
// }
|
||||
int bytesRecv = SocketReceive(server_res->socket, recvBuffer, msglen);
|
||||
SocketConfig serverConfig = {
|
||||
.host = "127.0.0.1",
|
||||
.port = "4950",
|
||||
.server = true,
|
||||
.type = SOCKET_UDP,
|
||||
.nonblocking = true
|
||||
};
|
||||
|
||||
// If we received data, was that data a "Ping!" or a "Pong!"
|
||||
if (bytesRecv > 0) {
|
||||
if (strcmp(recvBuffer, pingmsg) == 0) { pong = true; }
|
||||
if (strcmp(recvBuffer, pongmsg) == 0) { ping = true; }
|
||||
}
|
||||
SocketResult *serverResult = NULL;
|
||||
SocketSet *socketSet = NULL;
|
||||
char receiveBuffer[512] = { 0 };
|
||||
|
||||
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice versa
|
||||
elapsed += GetFrameTime();
|
||||
if (elapsed > delay) {
|
||||
if (ping) {
|
||||
ping = false;
|
||||
SocketSend(server_res->socket, pingmsg, msglen);
|
||||
} else if (pong) {
|
||||
pong = false;
|
||||
SocketSend(server_res->socket, pongmsg, msglen);
|
||||
}
|
||||
elapsed = 0.0f;
|
||||
}
|
||||
}
|
||||
// Create the server: getaddrinfo + socket + setsockopt + bind + listen
|
||||
serverResult = LoadSocketResult();
|
||||
|
||||
int main()
|
||||
{
|
||||
// Setup
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
InitWindow(
|
||||
screenWidth, screenHeight, "raylib [network] example - udp server");
|
||||
SetTargetFPS(60);
|
||||
SetTraceLogLevel(LOG_DEBUG);
|
||||
if (!SocketCreate(&serverConfig, serverResult)) TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||
else if (!SocketBind(&serverConfig, serverResult)) TraceLog(LOG_WARNING, "Failed to bind server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||
|
||||
// Networking
|
||||
InitNetwork();
|
||||
// Create and add sockets to the socket set
|
||||
socketSet = LoadSocketSet(1);
|
||||
AddSocket(socketSet, serverResult->socket);
|
||||
|
||||
// Create the server
|
||||
//
|
||||
// Performs
|
||||
// getaddrinfo
|
||||
// socket
|
||||
// setsockopt
|
||||
// bind
|
||||
// listen
|
||||
server_res = AllocSocketResult();
|
||||
if (!SocketCreate(&server_cfg, server_res)) {
|
||||
TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d",
|
||||
server_res->status, server_res->socket->status);
|
||||
} else {
|
||||
if (!SocketBind(&server_cfg, server_res)) {
|
||||
TraceLog(LOG_WARNING, "Failed to bind server: status %d, errno %d",
|
||||
server_res->status, server_res->socket->status);
|
||||
}
|
||||
}
|
||||
|
||||
// Create & Add sockets to the socket set
|
||||
socket_set = AllocSocketSet(1);
|
||||
msglen = strlen(pingmsg) + 1;
|
||||
memset(recvBuffer, '\0', sizeof(recvBuffer));
|
||||
AddSocket(socket_set, server_res->socket);
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) {
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
NetworkUpdate();
|
||||
EndDrawing();
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Once connected to the network, check the sockets for pending information
|
||||
// and when information is ready, send either a Ping or a Pong.
|
||||
|
||||
// CheckSockets, if any of the sockets in the set are pending (received data, or requests)
|
||||
// then mark the socket as being ready. You can check this with IsSocketReady(client_res->socket)
|
||||
int active = CheckSockets(socketSet, 0);
|
||||
if (active != 0) TraceLog(LOG_INFO, "There are currently %d socket(s) with data to be processed.", active);
|
||||
|
||||
// IsSocketReady, if the socket is ready, attempt to receive data from the socket
|
||||
// int bytesRecv = 0;
|
||||
// if (IsSocketReady(serverResult->socket)) {
|
||||
// bytesRecv = SocketReceive(serverResult->socket, receiveBuffer, msglen);
|
||||
// }
|
||||
int bytesRecv = SocketReceive(serverResult->socket, receiveBuffer, strlen(pingmsg) + 1);
|
||||
|
||||
// If we received data, is that data a "Ping!" or a "Pong!"?
|
||||
if (bytesRecv > 0)
|
||||
{
|
||||
if (strcmp(receiveBuffer, pingmsg) == 0) { pong = true; }
|
||||
if (strcmp(receiveBuffer, pongmsg) == 0) { ping = true; }
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
CloseWindow();
|
||||
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice-versa
|
||||
elapsed += GetFrameTime();
|
||||
|
||||
if (elapsed > delay)
|
||||
{
|
||||
if (ping)
|
||||
{
|
||||
ping = false;
|
||||
SocketSend(serverResult->socket, pingmsg, strlen(pingmsg) + 1);
|
||||
}
|
||||
else if (pong)
|
||||
{
|
||||
pong = false;
|
||||
SocketSend(serverResult->socket, pongmsg, strlen(pongmsg) + 1);
|
||||
}
|
||||
|
||||
elapsed = 0.0f;
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
// TODO: Draw relevant connection info
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseNetworkDevice(); // Close network communication
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
@@ -45,14 +45,17 @@
|
||||
|
||||
#define RLGL_IMPLEMENTATION
|
||||
#define RLGL_STANDALONE
|
||||
#define RLGL_SUPPORT_TRACELOG
|
||||
#include "rlgl.h" // OpenGL 1.1 immediate-mode style coding
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
#define GLFW_INCLUDE_ES2
|
||||
#endif
|
||||
|
||||
#include <GLFW/glfw3.h> // Windows/Context and inputs management
|
||||
|
||||
#include <stdio.h> // Required for: printf()
|
||||
|
||||
#define RED (Color){ 230, 41, 55, 255 } // Red
|
||||
#define RAYWHITE (Color){ 245, 245, 245, 255 } // My own White (raylib logo)
|
||||
#define DARKGRAY (Color){ 80, 80, 80, 255 } // Dark Gray
|
||||
@@ -85,10 +88,10 @@ int main(void)
|
||||
|
||||
if (!glfwInit())
|
||||
{
|
||||
TraceLog(LOG_WARNING, "GLFW3: Can not initialize GLFW");
|
||||
printf("GLFW3: Can not initialize GLFW\n");
|
||||
return 1;
|
||||
}
|
||||
else TraceLog(LOG_INFO, "GLFW3: GLFW initialized successfully");
|
||||
else printf("GLFW3: GLFW initialized successfully\n");
|
||||
|
||||
glfwWindowHint(GLFW_SAMPLES, 4);
|
||||
glfwWindowHint(GLFW_DEPTH_BITS, 16);
|
||||
@@ -104,7 +107,7 @@ int main(void)
|
||||
glfwTerminate();
|
||||
return 2;
|
||||
}
|
||||
else TraceLog(LOG_INFO, "GLFW3: Window created successfully");
|
||||
else printf("GLFW3: Window created successfully\n");
|
||||
|
||||
glfwSetWindowPos(window, 200, 200);
|
||||
|
||||
@@ -216,7 +219,7 @@ int main(void)
|
||||
// GLFW3: Error callback
|
||||
static void ErrorCallback(int error, const char *description)
|
||||
{
|
||||
TraceLog(LOG_ERROR, description);
|
||||
fprintf(stderr, description);
|
||||
}
|
||||
|
||||
// GLFW3: Keyboard callback
|
||||
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@@ -120,6 +120,10 @@ int main(void)
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
DestroyPhysicsBody(circleA);
|
||||
DestroyPhysicsBody(circleB);
|
||||
DestroyPhysicsBody(circleC);
|
||||
DestroyPhysicsBody(floor);
|
||||
ClosePhysics(); // Unitialize physics
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
BIN
examples/shaders/resources/mask.png
Normal file
After Width: | Height: | Size: 73 KiB |
BIN
examples/shaders/resources/plasma.png
Normal file
After Width: | Height: | Size: 568 KiB |
BIN
examples/shaders/resources/raysan.png
Normal file
After Width: | Height: | Size: 15 KiB |
@@ -11,7 +11,6 @@ uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
uniform vec2 resolution = vec2(800, 450);
|
||||
|
||||
void main()
|
||||
{
|
||||
|
59
examples/shaders/resources/shaders/glsl100/base_lighting.vs
Normal file
@@ -0,0 +1,59 @@
|
||||
#version 100
|
||||
|
||||
// Input vertex attributes
|
||||
attribute vec3 vertexPosition;
|
||||
attribute vec2 vertexTexCoord;
|
||||
attribute vec3 vertexNormal;
|
||||
attribute vec4 vertexColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform mat4 mvp;
|
||||
uniform mat4 matModel;
|
||||
|
||||
// Output vertex attributes (to fragment shader)
|
||||
varying vec3 fragPosition;
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
varying vec3 fragNormal;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
// https://github.com/glslify/glsl-inverse
|
||||
mat3 inverse(mat3 m)
|
||||
{
|
||||
float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];
|
||||
float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
|
||||
float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];
|
||||
|
||||
float b01 = a22*a11 - a12*a21;
|
||||
float b11 = -a22*a10 + a12*a20;
|
||||
float b21 = a21*a10 - a11*a20;
|
||||
|
||||
float det = a00*b01 + a01*b11 + a02*b21;
|
||||
|
||||
return mat3(b01, (-a22*a01 + a02*a21), (a12*a01 - a02*a11),
|
||||
b11, (a22*a00 - a02*a20), (-a12*a00 + a02*a10),
|
||||
b21, (-a21*a00 + a01*a20), (a11*a00 - a01*a10))/det;
|
||||
}
|
||||
|
||||
// https://github.com/glslify/glsl-transpose
|
||||
mat3 transpose(mat3 m)
|
||||
{
|
||||
return mat3(m[0][0], m[1][0], m[2][0],
|
||||
m[0][1], m[1][1], m[2][1],
|
||||
m[0][2], m[1][2], m[2][2]);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// Send vertex attributes to fragment shader
|
||||
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
|
||||
fragTexCoord = vertexTexCoord;
|
||||
fragColor = vertexColor;
|
||||
|
||||
mat3 normalMatrix = transpose(inverse(mat3(matModel)));
|
||||
fragNormal = normalize(normalMatrix*vertexNormal);
|
||||
|
||||
// Calculate final vertex position
|
||||
gl_Position = mvp*vec4(vertexPosition, 1.0);
|
||||
}
|
@@ -7,8 +7,8 @@ varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
// Custom variables
|
||||
#define PI 3.14159265358979323846
|
||||
uniform float uTime = 0.0;
|
||||
const float PI = 3.14159265358979323846;
|
||||
uniform float uTime;
|
||||
|
||||
float divisions = 5.0;
|
||||
float angle = 0.0;
|
||||
@@ -19,9 +19,9 @@ vec2 VectorRotateTime(vec2 v, float speed)
|
||||
float localTime = fract(time); // The time domain this works on is 1 sec.
|
||||
|
||||
if ((localTime >= 0.0) && (localTime < 0.25)) angle = 0.0;
|
||||
else if ((localTime >= 0.25) && (localTime < 0.50)) angle = PI/4*sin(2*PI*localTime - PI/2);
|
||||
else if ((localTime >= 0.25) && (localTime < 0.50)) angle = PI/4.0*sin(2.0*PI*localTime - PI/2.0);
|
||||
else if ((localTime >= 0.50) && (localTime < 0.75)) angle = PI*0.25;
|
||||
else if ((localTime >= 0.75) && (localTime < 1.00)) angle = PI/4*sin(2*PI*localTime);
|
||||
else if ((localTime >= 0.75) && (localTime < 1.00)) angle = PI/4.0*sin(2.0*PI*localTime);
|
||||
|
||||
// Rotate vector by angle
|
||||
v -= 0.5;
|
||||
|
@@ -39,20 +39,22 @@ void main()
|
||||
{
|
||||
vec4 color = vec4(1.0);
|
||||
float scale = 1000.0; // Makes 100x100 square grid. Change this variable to make a smaller or larger grid.
|
||||
int value = int(scale*floor(fragTexCoord.y*scale) + floor(fragTexCoord.x*scale)); // Group pixels into boxes representing integer values
|
||||
float value = scale*floor(fragTexCoord.y*scale) + floor(fragTexCoord.x*scale); // Group pixels into boxes representing integer values
|
||||
int valuei = int(value);
|
||||
|
||||
if ((value == 0) || (value == 1) || (value == 2)) gl_FragColor = vec4(1.0);
|
||||
else
|
||||
//if ((valuei == 0) || (valuei == 1) || (valuei == 2)) gl_FragColor = vec4(1.0);
|
||||
//else
|
||||
{
|
||||
for (int i = 2; (i < max(2, sqrt(value) + 1)); i++)
|
||||
//for (int i = 2; (i < int(max(2.0, sqrt(value) + 1.0))); i++)
|
||||
// NOTE: On GLSL 100 for loops are restricted and loop condition must be a constant
|
||||
// Tested on RPI, it seems loops are limited around 60 iteractions
|
||||
for (int i = 2; i < 48; i++)
|
||||
{
|
||||
if ((value - i*floor(value/i)) == 0)
|
||||
if ((value - float(i)*floor(value/float(i))) <= 0.0)
|
||||
{
|
||||
color = Colorizer(float(i), scale);
|
||||
gl_FragColor = Colorizer(float(i), scale);
|
||||
//break; // Uncomment to color by the largest factor instead
|
||||
}
|
||||
}
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
||||
}
|
||||
|
94
examples/shaders/resources/shaders/glsl100/fog.fs
Normal file
@@ -0,0 +1,94 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec3 fragPosition;
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
varying vec3 fragNormal;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
#define MAX_LIGHTS 4
|
||||
#define LIGHT_DIRECTIONAL 0
|
||||
#define LIGHT_POINT 1
|
||||
|
||||
struct MaterialProperty {
|
||||
vec3 color;
|
||||
int useSampler;
|
||||
sampler2D sampler;
|
||||
};
|
||||
|
||||
struct Light {
|
||||
int enabled;
|
||||
int type;
|
||||
vec3 position;
|
||||
vec3 target;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
// Input lighting values
|
||||
uniform Light lights[MAX_LIGHTS];
|
||||
uniform vec4 ambient;
|
||||
uniform vec3 viewPos;
|
||||
uniform float fogDensity;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Texel color fetching from texture sampler
|
||||
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
||||
vec3 lightDot = vec3(0.0);
|
||||
vec3 normal = normalize(fragNormal);
|
||||
vec3 viewD = normalize(viewPos - fragPosition);
|
||||
vec3 specular = vec3(0.0);
|
||||
|
||||
// NOTE: Implement here your fragment shader code
|
||||
|
||||
for (int i = 0; i < MAX_LIGHTS; i++)
|
||||
{
|
||||
if (lights[i].enabled == 1)
|
||||
{
|
||||
vec3 light = vec3(0.0);
|
||||
|
||||
if (lights[i].type == LIGHT_DIRECTIONAL) light = -normalize(lights[i].target - lights[i].position);
|
||||
if (lights[i].type == LIGHT_POINT) light = normalize(lights[i].position - fragPosition);
|
||||
|
||||
float NdotL = max(dot(normal, light), 0.0);
|
||||
lightDot += lights[i].color.rgb*NdotL;
|
||||
|
||||
float specCo = 0.0;
|
||||
if (NdotL > 0.0) specCo = pow(max(0.0, dot(viewD, reflect(-(light), normal))), 16.0); // Shine: 16.0
|
||||
specular += specCo;
|
||||
}
|
||||
}
|
||||
|
||||
vec4 finalColor = (texelColor*((colDiffuse + vec4(specular,1))*vec4(lightDot, 1.0)));
|
||||
finalColor += texelColor*(ambient/10.0);
|
||||
|
||||
// Gamma correction
|
||||
finalColor = pow(finalColor, vec4(1.0/2.2));
|
||||
|
||||
// Fog calculation
|
||||
float dist = length(viewPos - fragPosition);
|
||||
|
||||
// these could be parameters...
|
||||
const vec4 fogColor = vec4(0.5, 0.5, 0.5, 1.0);
|
||||
//const float fogDensity = 0.16;
|
||||
|
||||
// Exponential fog
|
||||
float fogFactor = 1.0/exp((dist*fogDensity)*(dist*fogDensity));
|
||||
|
||||
// Linear fog (less nice)
|
||||
//const float fogStart = 2.0;
|
||||
//const float fogEnd = 10.0;
|
||||
//float fogFactor = (fogEnd - dist)/(fogEnd - fogStart);
|
||||
|
||||
fogFactor = clamp(fogFactor, 0.0, 1.0);
|
||||
|
||||
gl_FragColor = mix(fogColor, finalColor, fogFactor);
|
||||
}
|
@@ -11,7 +11,9 @@ uniform vec2 c; // c.x = real, c.y = imaginary component. Equati
|
||||
uniform vec2 offset; // Offset of the scale.
|
||||
uniform float zoom; // Zoom of the scale.
|
||||
|
||||
const int MAX_ITERATIONS = 255; // Max iterations to do.
|
||||
// NOTE: Maximum number of shader for-loop iterations depend on GPU,
|
||||
// for example, on RasperryPi for this examply only supports up to 60
|
||||
const int MAX_ITERATIONS = 48; // Max iterations to do
|
||||
|
||||
// Square a complex number
|
||||
vec2 ComplexSquare(vec2 z)
|
||||
@@ -30,7 +32,6 @@ vec3 Hsv2rgb(vec3 c)
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
/**********************************************************************************************
|
||||
@@ -56,12 +57,13 @@ void main()
|
||||
// NOTE: fragTexCoord already comes as normalized screen coordinates but offset must be normalized before scaling and zoom
|
||||
vec2 z = vec2((fragTexCoord.x + offset.x/screenDims.x)*2.5/zoom, (fragTexCoord.y + offset.y/screenDims.y)*1.5/zoom);
|
||||
|
||||
int iterations = 0;
|
||||
for (iterations = 0; iterations < MAX_ITERATIONS; iterations++)
|
||||
int iter = 0;
|
||||
for (int iterations = 0; iterations < 60; iterations++)
|
||||
{
|
||||
z = ComplexSquare(z) + c; // Iterate function
|
||||
|
||||
if (dot(z, z) > 4.0) break;
|
||||
|
||||
iter = iterations;
|
||||
}
|
||||
|
||||
// Another few iterations decreases errors in the smoothing calculation.
|
||||
@@ -70,7 +72,7 @@ void main()
|
||||
z = ComplexSquare(z) + c;
|
||||
|
||||
// This last part smooths the color (again see link above).
|
||||
float smoothVal = float(iterations) + 1.0 - (log(log(length(z)))/log(2.0));
|
||||
float smoothVal = float(iter) + 1.0 - (log(log(length(z)))/log(2.0));
|
||||
|
||||
// Normalize the value so it is between 0 and 1.
|
||||
float norm = smoothVal/float(MAX_ITERATIONS);
|
||||
|
81
examples/shaders/resources/shaders/glsl100/lighting.fs
Normal file
@@ -0,0 +1,81 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec3 fragPosition;
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
varying vec3 fragNormal;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
#define MAX_LIGHTS 4
|
||||
#define LIGHT_DIRECTIONAL 0
|
||||
#define LIGHT_POINT 1
|
||||
|
||||
struct MaterialProperty {
|
||||
vec3 color;
|
||||
int useSampler;
|
||||
sampler2D sampler;
|
||||
};
|
||||
|
||||
struct Light {
|
||||
int enabled;
|
||||
int type;
|
||||
vec3 position;
|
||||
vec3 target;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
// Input lighting values
|
||||
uniform Light lights[MAX_LIGHTS];
|
||||
uniform vec4 ambient;
|
||||
uniform vec3 viewPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Texel color fetching from texture sampler
|
||||
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
||||
vec3 lightDot = vec3(0.0);
|
||||
vec3 normal = normalize(fragNormal);
|
||||
vec3 viewD = normalize(viewPos - fragPosition);
|
||||
vec3 specular = vec3(0.0);
|
||||
|
||||
// NOTE: Implement here your fragment shader code
|
||||
|
||||
for (int i = 0; i < MAX_LIGHTS; i++)
|
||||
{
|
||||
if (lights[i].enabled == 1)
|
||||
{
|
||||
vec3 light = vec3(0.0);
|
||||
|
||||
if (lights[i].type == LIGHT_DIRECTIONAL)
|
||||
{
|
||||
light = -normalize(lights[i].target - lights[i].position);
|
||||
}
|
||||
|
||||
if (lights[i].type == LIGHT_POINT)
|
||||
{
|
||||
light = normalize(lights[i].position - fragPosition);
|
||||
}
|
||||
|
||||
float NdotL = max(dot(normal, light), 0.0);
|
||||
lightDot += lights[i].color.rgb*NdotL;
|
||||
|
||||
float specCo = 0.0;
|
||||
if (NdotL > 0.0) specCo = pow(max(0.0, dot(viewD, reflect(-(light), normal))), 16.0); // 16 refers to shine
|
||||
specular += specCo;
|
||||
}
|
||||
}
|
||||
|
||||
vec4 finalColor = (texelColor*((colDiffuse + vec4(specular, 1.0))*vec4(lightDot, 1.0)));
|
||||
finalColor += texelColor*(ambient/10.0);
|
||||
|
||||
// Gamma correction
|
||||
gl_FragColor = pow(finalColor, vec4(1.0/2.2));
|
||||
}
|