Compare commits
665 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ab0d19f356 | ||
![]() |
c482f37dfd | ||
![]() |
c12737ae38 | ||
![]() |
3140496a12 | ||
![]() |
61558ab83f | ||
![]() |
76c9e9883d | ||
![]() |
5139948ef9 | ||
![]() |
13e18c23ed | ||
![]() |
af46222b12 | ||
![]() |
eaec086177 | ||
![]() |
bec58075ff | ||
![]() |
0e6b249260 | ||
![]() |
5ff9811ea8 | ||
![]() |
6c2dc5574f | ||
![]() |
ce1c4055f7 | ||
![]() |
de865a9b55 | ||
![]() |
697e1d4941 | ||
![]() |
f5f3b4e095 | ||
![]() |
40fbe9da81 | ||
![]() |
ebfb1978b8 | ||
![]() |
8328353204 | ||
![]() |
13c56887f1 | ||
![]() |
2272a4722f | ||
![]() |
94a5fc5c2c | ||
![]() |
a36cc7075a | ||
![]() |
f1f51bd9b6 | ||
![]() |
1eafa7020d | ||
![]() |
55b9a2479a | ||
![]() |
52cb0d709a | ||
![]() |
d38fb9bda2 | ||
![]() |
6efaa78058 | ||
![]() |
e62c30c8b1 | ||
![]() |
0ba349bdf2 | ||
![]() |
35bda8980f | ||
![]() |
cac378bd95 | ||
![]() |
be551d7707 | ||
![]() |
bfb5ffedda | ||
![]() |
a05150392a | ||
![]() |
6f335d2c9e | ||
![]() |
f685acd69e | ||
![]() |
dbec22f2df | ||
![]() |
4ef3acfa41 | ||
![]() |
0fbd48a889 | ||
![]() |
b7b51569e2 | ||
![]() |
55491fdb36 | ||
![]() |
a2794379a0 | ||
![]() |
fc19e24eba | ||
![]() |
da71c3d801 | ||
![]() |
e815e205da | ||
![]() |
eb58a0596d | ||
![]() |
7959ccd84d | ||
![]() |
338bb3fd9c | ||
![]() |
11172118d1 | ||
![]() |
9d6d68f00a | ||
![]() |
31b64d4689 | ||
![]() |
3876f19d6a | ||
![]() |
22672bc738 | ||
![]() |
56ec22f5c9 | ||
![]() |
84d1b19f61 | ||
![]() |
24c267d324 | ||
![]() |
d587cc0e36 | ||
![]() |
1733125873 | ||
![]() |
884e13ac2f | ||
![]() |
bcc2b17701 | ||
![]() |
3922bc27cd | ||
![]() |
7cefbd8a94 | ||
![]() |
e2a3a52ad6 | ||
![]() |
8fd4507847 | ||
![]() |
09cc27ca7a | ||
![]() |
bc80174357 | ||
![]() |
2ff2096b36 | ||
![]() |
3fb1c446ea | ||
![]() |
8bdd03eeac | ||
![]() |
2f9abe6e13 | ||
![]() |
ee72654b55 | ||
![]() |
164ead03c9 | ||
![]() |
f88c95ce2d | ||
![]() |
308fcbb96c | ||
![]() |
be61d2f8c1 | ||
![]() |
6fbf6a1c23 | ||
![]() |
5a4eb34c39 | ||
![]() |
c4922c9e88 | ||
![]() |
e977915577 | ||
![]() |
572936ec65 | ||
![]() |
a8bed54586 | ||
![]() |
4b444e7cc3 | ||
![]() |
9127b5a57d | ||
![]() |
8652e644dd | ||
![]() |
4ff85c2ac2 | ||
![]() |
6981e2bffa | ||
![]() |
8fb84d9e63 | ||
![]() |
71ab202295 | ||
![]() |
369b8532c0 | ||
![]() |
f9f33926f7 | ||
![]() |
9ee96bea95 | ||
![]() |
5f7ac64c44 | ||
![]() |
b358402cb3 | ||
![]() |
a522b6e23b | ||
![]() |
03d9583b94 | ||
![]() |
e913de58c7 | ||
![]() |
afe033412b | ||
![]() |
c28a5fbd62 | ||
![]() |
6062201e8f | ||
![]() |
b01f5ff6a7 | ||
![]() |
24c9b1f717 | ||
![]() |
9fdf4420d5 | ||
![]() |
4df7a0f2f8 | ||
![]() |
3468af213f | ||
![]() |
d5d1305bc0 | ||
![]() |
1b0996fb0b | ||
![]() |
1879a8129e | ||
![]() |
4e84ded7ef | ||
![]() |
1a8fbe5cf0 | ||
![]() |
5a1cbb2842 | ||
![]() |
54537e8f0b | ||
![]() |
c9c1263e6f | ||
![]() |
d1a5374ac4 | ||
![]() |
c914010606 | ||
![]() |
56bd9da07c | ||
![]() |
d60dc7c2eb | ||
![]() |
97fc266ad4 | ||
![]() |
3ce0228206 | ||
![]() |
0d0f306fc2 | ||
![]() |
c25b4cdc69 | ||
![]() |
3a5fc0c320 | ||
![]() |
3d6be7fd80 | ||
![]() |
47afda2549 | ||
![]() |
6a2bbae521 | ||
![]() |
5625c11e99 | ||
![]() |
16609d6702 | ||
![]() |
8d2de09f3d | ||
![]() |
4dae3385c3 | ||
![]() |
66ec0b5d82 | ||
![]() |
7999bbafa8 | ||
![]() |
4c43a40788 | ||
![]() |
c10c49e44f | ||
![]() |
1a60f376a4 | ||
![]() |
27ba7de1e4 | ||
![]() |
68a02e567d | ||
![]() |
c46c0fc652 | ||
![]() |
3884716948 | ||
![]() |
8de1427803 | ||
![]() |
bab08f1c89 | ||
![]() |
d63e32a377 | ||
![]() |
52b88e0991 | ||
![]() |
3e8427799c | ||
![]() |
2963782992 | ||
![]() |
77f599885d | ||
![]() |
7b07b68bfd | ||
![]() |
fb90477354 | ||
![]() |
cbda329bfd | ||
![]() |
5d186639c9 | ||
![]() |
e2cfc6b838 | ||
![]() |
3c1be60c66 | ||
![]() |
5f4449f0a1 | ||
![]() |
558ec3891b | ||
![]() |
dcbfb83031 | ||
![]() |
3524fc414b | ||
![]() |
420b85da98 | ||
![]() |
28c2759ae1 | ||
![]() |
374e3e7e11 | ||
![]() |
904ef0d4be | ||
![]() |
99ee26b001 | ||
![]() |
ee049641ba | ||
![]() |
4f47f90336 | ||
![]() |
2d90cc59b6 | ||
![]() |
5576dea00b | ||
![]() |
8323f81ab5 | ||
![]() |
f5f5ce0d33 | ||
![]() |
88f4747437 | ||
![]() |
b79ede4edb | ||
![]() |
70a96fff80 | ||
![]() |
7bf2854e94 | ||
![]() |
f0d8c009ae | ||
![]() |
0ae486f07c | ||
![]() |
79a6235811 | ||
![]() |
c99fc5108e | ||
![]() |
09fa002818 | ||
![]() |
ee795150fa | ||
![]() |
f97f39987c | ||
![]() |
5631f822bd | ||
![]() |
ca13c2ed0c | ||
![]() |
058af472ea | ||
![]() |
3d5a408177 | ||
![]() |
9281e477eb | ||
![]() |
76536fe24b | ||
![]() |
1bcf500eca | ||
![]() |
522af9f477 | ||
![]() |
1c98e6b698 | ||
![]() |
4dada32693 | ||
![]() |
34aea08ba2 | ||
![]() |
6b2823775e | ||
![]() |
d999b3ed53 | ||
![]() |
5f5d191d88 | ||
![]() |
dd468e9ef9 | ||
![]() |
302d84cedc | ||
![]() |
ad8a5a95b2 | ||
![]() |
29d505c98e | ||
![]() |
688045307a | ||
![]() |
72eb2632cc | ||
![]() |
e3b2485453 | ||
![]() |
60232810d8 | ||
![]() |
d1133ca8d3 | ||
![]() |
13bef7aa02 | ||
![]() |
b574e105dd | ||
![]() |
4dfffff19b | ||
![]() |
9417b9969d | ||
![]() |
46a7822eee | ||
![]() |
501ef80bed | ||
![]() |
7ca6397223 | ||
![]() |
e2173922f0 | ||
![]() |
96fa716525 | ||
![]() |
4bc339ea4e | ||
![]() |
0bc71d84f8 | ||
![]() |
2168d8aa1a | ||
![]() |
cafc66a3c1 | ||
![]() |
4c9d0f16a5 | ||
![]() |
80b3c4cd2b | ||
![]() |
5bcddca5e1 | ||
![]() |
c286bea8e1 | ||
![]() |
4fb3103dfa | ||
![]() |
cf6d2e3985 | ||
![]() |
7447b3e1da | ||
![]() |
cf2975d062 | ||
![]() |
af1eb5453a | ||
![]() |
05f8e83ba9 | ||
![]() |
21a01ec870 | ||
![]() |
ae6adb173b | ||
![]() |
90e1ed2b5e | ||
![]() |
17878550b1 | ||
![]() |
7afa0b09ab | ||
![]() |
0a27525a4b | ||
![]() |
3e88156817 | ||
![]() |
897179a06c | ||
![]() |
8f91ed81c5 | ||
![]() |
d17a0cee1a | ||
![]() |
302ec438dd | ||
![]() |
cac2a66deb | ||
![]() |
78b4494e2b | ||
![]() |
caa7bc366b | ||
![]() |
6ad8323860 | ||
![]() |
9f2fc81df2 | ||
![]() |
8a4e28f81d | ||
![]() |
4b93349db5 | ||
![]() |
11cf455fe0 | ||
![]() |
b0a0c5d431 | ||
![]() |
f2d61d4043 | ||
![]() |
0ff26f527f | ||
![]() |
5c32cf2095 | ||
![]() |
64f6c74c9a | ||
![]() |
2e26ce235d | ||
![]() |
ae2d0d4cd8 | ||
![]() |
26833f5aae | ||
![]() |
ea5b00528b | ||
![]() |
e4e315bbfc | ||
![]() |
27df983ee0 | ||
![]() |
5a041a6af5 | ||
![]() |
3d6696f6c9 | ||
![]() |
d53b6f4381 | ||
![]() |
48374c85dd | ||
![]() |
f74791ed7b | ||
![]() |
f232f34981 | ||
![]() |
9811a37690 | ||
![]() |
dcd6942ed1 | ||
![]() |
c320a21f2b | ||
![]() |
80eb4f3f50 | ||
![]() |
30941c0dd1 | ||
![]() |
cf71e1242e | ||
![]() |
0da7c499b6 | ||
![]() |
0b65b44a78 | ||
![]() |
46e7a26770 | ||
![]() |
c9ac176fa7 | ||
![]() |
c0983f3400 | ||
![]() |
30c8058fca | ||
![]() |
c60cc9ee18 | ||
![]() |
6dac1efefe | ||
![]() |
8b3603cd48 | ||
![]() |
3fa6fdacf2 | ||
![]() |
90c62c4cc0 | ||
![]() |
4f1bee3165 | ||
![]() |
dcf5f45f68 | ||
![]() |
af890cf210 | ||
![]() |
c9e30f7754 | ||
![]() |
03cc031d00 | ||
![]() |
7d1d9ff143 | ||
![]() |
bdb450fccb | ||
![]() |
179f2f9e4f | ||
![]() |
41c5f3a017 | ||
![]() |
847944e240 | ||
![]() |
b10425492a | ||
![]() |
8bbbe8cd76 | ||
![]() |
037edbaa13 | ||
![]() |
bc08271da3 | ||
![]() |
cd7f25830b | ||
![]() |
706755d146 | ||
![]() |
0e29aa2951 | ||
![]() |
d84f922372 | ||
![]() |
76ff4d220e | ||
![]() |
86fbf4fd8f | ||
![]() |
d38d7a1bed | ||
![]() |
8c5d403dda | ||
![]() |
f575935ace | ||
![]() |
ea4b5552c2 | ||
![]() |
b46a800597 | ||
![]() |
b62bbb78ed | ||
![]() |
5107a2dc40 | ||
![]() |
ded07690fd | ||
![]() |
83dbc07650 | ||
![]() |
e060944b34 | ||
![]() |
075f51e0a3 | ||
![]() |
f0ada8c40d | ||
![]() |
9737c58054 | ||
![]() |
529d20ee6a | ||
![]() |
ad3d270c42 | ||
![]() |
454b422fd6 | ||
![]() |
4d78d27bd9 | ||
![]() |
6db44500b7 | ||
![]() |
6acfda599e | ||
![]() |
5c112ff542 | ||
![]() |
aee5d9a390 | ||
![]() |
1ddf594d15 | ||
![]() |
9799856ad4 | ||
![]() |
b7f8e97b03 | ||
![]() |
ac44db26a2 | ||
![]() |
c85cd29049 | ||
![]() |
3d0208223a | ||
![]() |
dc4d5dabcd | ||
![]() |
f7d4951165 | ||
![]() |
0bcb873cbb | ||
![]() |
29761c2519 | ||
![]() |
eeb151586f | ||
![]() |
7ab008878a | ||
![]() |
ec72a8868e | ||
![]() |
ba60918eaa | ||
![]() |
e660700924 | ||
![]() |
fd67e31f63 | ||
![]() |
8301980ba8 | ||
![]() |
5f73850fa6 | ||
![]() |
e94acf86f8 | ||
![]() |
d6feeb14ff | ||
![]() |
9d09ada33b | ||
![]() |
c3208c5cd6 | ||
![]() |
4636e3367c | ||
![]() |
f2152aa391 | ||
![]() |
2646ed0393 | ||
![]() |
9ef0240e99 | ||
![]() |
790bc72806 | ||
![]() |
289a53221d | ||
![]() |
a2a3d3aeb6 | ||
![]() |
17732fa9c4 | ||
![]() |
fa98289ddb | ||
![]() |
0e6d1cb272 | ||
![]() |
cc39b4660a | ||
![]() |
fa3112b40e | ||
![]() |
6ca1fd59a9 | ||
![]() |
1fb874cdc5 | ||
![]() |
34e5fcf47e | ||
![]() |
a1038f61b6 | ||
![]() |
5f1e8b8278 | ||
![]() |
91f1f324c0 | ||
![]() |
eb36c351cf | ||
![]() |
f707c1ca46 | ||
![]() |
299ae7a4bd | ||
![]() |
3104d3d6cd | ||
![]() |
04d9deac92 | ||
![]() |
f12754b01f | ||
![]() |
f9bbce0da7 | ||
![]() |
62087d21cc | ||
![]() |
89a84a621b | ||
![]() |
1c370f5a17 | ||
![]() |
cb05c51911 | ||
![]() |
ec2cbaa5eb | ||
![]() |
173529e048 | ||
![]() |
9639b14e1b | ||
![]() |
17eefed08f | ||
![]() |
2e5d898443 | ||
![]() |
6b5e18e6bf | ||
![]() |
0da88ac5c5 | ||
![]() |
c8a30b262d | ||
![]() |
284eaf1576 | ||
![]() |
c1e49d2b13 | ||
![]() |
cde2c1aa6d | ||
![]() |
aa22d97983 | ||
![]() |
4b51248372 | ||
![]() |
1d545449bb | ||
![]() |
78b502b0bf | ||
![]() |
3b67a4cfba | ||
![]() |
1a2a44200a | ||
![]() |
9361615786 | ||
![]() |
0133917bf9 | ||
![]() |
b6cec214bd | ||
![]() |
a66c8531d6 | ||
![]() |
37cc45a0a8 | ||
![]() |
a04a7b6ea5 | ||
![]() |
f2f4079411 | ||
![]() |
565b1089bd | ||
![]() |
06a8d7eb06 | ||
![]() |
108055cd62 | ||
![]() |
66b096d978 | ||
![]() |
1136d4222f | ||
![]() |
136408d8b8 | ||
![]() |
ee9bf76ae9 | ||
![]() |
a3f16c8459 | ||
![]() |
956a6e6f77 | ||
![]() |
8b7ca8b670 | ||
![]() |
35ee4e52c8 | ||
![]() |
ea7afc8ec8 | ||
![]() |
db3dd9d200 | ||
![]() |
60223a358b | ||
![]() |
c453ac8265 | ||
![]() |
269b120104 | ||
![]() |
584e74c676 | ||
![]() |
fa78023aa4 | ||
![]() |
ebc2b9a286 | ||
![]() |
5e45c3c824 | ||
![]() |
e2ba22ec59 | ||
![]() |
49df957058 | ||
![]() |
95c1bf9544 | ||
![]() |
db4585b3e2 | ||
![]() |
d6bc7b8877 | ||
![]() |
ee52b13ae6 | ||
![]() |
d0e26247f4 | ||
![]() |
0caf925d5d | ||
![]() |
dc68205a18 | ||
![]() |
7128ef686d | ||
![]() |
d728494099 | ||
![]() |
5bcda7bf15 | ||
![]() |
9e7a3b7017 | ||
![]() |
530e520727 | ||
![]() |
2e3e62a413 | ||
![]() |
4d8f18e00b | ||
![]() |
ea8363a3b0 | ||
![]() |
c5931c75c6 | ||
![]() |
d07e4f44f1 | ||
![]() |
dcabb49244 | ||
![]() |
18a13679fd | ||
![]() |
6ee5718b2e | ||
![]() |
d0e7195a16 | ||
![]() |
7053724fd6 | ||
![]() |
c9d22c7a14 | ||
![]() |
893facdf6d | ||
![]() |
78e4772f21 | ||
![]() |
305efcf5ad | ||
![]() |
0d911127d7 | ||
![]() |
5ea18b9426 | ||
![]() |
d8bd8634ab | ||
![]() |
dcbf2a0e0c | ||
![]() |
fffbf48dec | ||
![]() |
a167067cbd | ||
![]() |
4476a9e241 | ||
![]() |
4011c13d4b | ||
![]() |
6106ab8a2e | ||
![]() |
1674465bdc | ||
![]() |
8ca6f8c6ec | ||
![]() |
04caf1c262 | ||
![]() |
68088bc5be | ||
![]() |
0dfc7fffff | ||
![]() |
75a73d9417 | ||
![]() |
d042ed52fa | ||
![]() |
2cc05e5e92 | ||
![]() |
2a058338f3 | ||
![]() |
4d2b8471fa | ||
![]() |
26252c4c1d | ||
![]() |
c70d8acb33 | ||
![]() |
16dd57747c | ||
![]() |
24ba22a43a | ||
![]() |
2da3c6d288 | ||
![]() |
c7486a0339 | ||
![]() |
c86b3d0c05 | ||
![]() |
2d1b2efb92 | ||
![]() |
9ec4776812 | ||
![]() |
2f08845d1e | ||
![]() |
9f5efeb309 | ||
![]() |
182054b662 | ||
![]() |
a8bb9b6b19 | ||
![]() |
84252f9b70 | ||
![]() |
89409817b5 | ||
![]() |
7b360d8579 | ||
![]() |
83459159f4 | ||
![]() |
4b6e6d4dd4 | ||
![]() |
954ced21a4 | ||
![]() |
98c60838fe | ||
![]() |
09f28d0f57 | ||
![]() |
8aab52aeda | ||
![]() |
afd2ffb74a | ||
![]() |
825e42dc00 | ||
![]() |
b99b21fa38 | ||
![]() |
0018522031 | ||
![]() |
30fafb77db | ||
![]() |
ed19064405 | ||
![]() |
94c92a58a1 | ||
![]() |
9c9aeaef47 | ||
![]() |
cbbe948529 | ||
![]() |
823abf666e | ||
![]() |
685273675b | ||
![]() |
15cd4dce4e | ||
![]() |
9cbfcbb820 | ||
![]() |
fca83c9ff8 | ||
![]() |
54c7fa491e | ||
![]() |
c69ce1d750 | ||
![]() |
84a6724b33 | ||
![]() |
a847df921f | ||
![]() |
687fe2c3c7 | ||
![]() |
e98ea900cf | ||
![]() |
2ef9552454 | ||
![]() |
6a392f0eb2 | ||
![]() |
c00062655f | ||
![]() |
4ad375a378 | ||
![]() |
4a3509f06d | ||
![]() |
4fae37bb88 | ||
![]() |
646f1c3f71 | ||
![]() |
df5c64d0be | ||
![]() |
65ecde1e75 | ||
![]() |
728e1715cc | ||
![]() |
e484d58d9c | ||
![]() |
708e8c558c | ||
![]() |
4ec0ac89cd | ||
![]() |
196bda0597 | ||
![]() |
bf32081fa9 | ||
![]() |
13925f7bd4 | ||
![]() |
e6ad166ae3 | ||
![]() |
db5493b783 | ||
![]() |
5d6475c93b | ||
![]() |
ac475f46b9 | ||
![]() |
c21ca3ca1a | ||
![]() |
99f99bea47 | ||
![]() |
d0ff78e7f4 | ||
![]() |
3113a20390 | ||
![]() |
41959eeae1 | ||
![]() |
08da91047e | ||
![]() |
6e9d3eb0f9 | ||
![]() |
ed674d865b | ||
![]() |
233f7611da | ||
![]() |
f874fdc1ad | ||
![]() |
4e57bd1f18 | ||
![]() |
455be7f6f6 | ||
![]() |
23d66e9b6f | ||
![]() |
882e2abee1 | ||
![]() |
68ba34c17b | ||
![]() |
a286d9166b | ||
![]() |
fcd30c5649 | ||
![]() |
8ae0da1fa1 | ||
![]() |
25f5995be0 | ||
![]() |
cf6c6fefd7 | ||
![]() |
c5663ca015 | ||
![]() |
51c0b61a43 | ||
![]() |
634f8f0d0f | ||
![]() |
efa1c96d19 | ||
![]() |
423a45ac85 | ||
![]() |
dc385ba4ec | ||
![]() |
c8e8c0a002 | ||
![]() |
c04752c0e4 | ||
![]() |
ae87a35f6e | ||
![]() |
29c618a35e | ||
![]() |
036e77939f | ||
![]() |
de7bddb8df | ||
![]() |
fd05d3e353 | ||
![]() |
a640503119 | ||
![]() |
f24fd14814 | ||
![]() |
f98c4dc82b | ||
![]() |
f1d16386b6 | ||
![]() |
144681fc0f | ||
![]() |
03c82605a0 | ||
![]() |
183795b8aa | ||
![]() |
91e00431d4 | ||
![]() |
3b4d8442e0 | ||
![]() |
4f0165f32d | ||
![]() |
fb6ef2c2f4 | ||
![]() |
bb49102a4b | ||
![]() |
4cc394c376 | ||
![]() |
8eb6fc5612 | ||
![]() |
5e7686695f | ||
![]() |
e5a56fa985 | ||
![]() |
f10835cf09 | ||
![]() |
a5e79b7663 | ||
![]() |
b7461846ab | ||
![]() |
40119949cb | ||
![]() |
21229aa3f6 | ||
![]() |
1793f2c3b8 | ||
![]() |
4a637191f2 | ||
![]() |
8991573984 | ||
![]() |
7f2e67e924 | ||
![]() |
1ce010c7d4 | ||
![]() |
fe0cf8f9a9 | ||
![]() |
32508f6db1 | ||
![]() |
1c23edd1e5 | ||
![]() |
ea50092356 | ||
![]() |
891c4a458a | ||
![]() |
0c539cbf32 | ||
![]() |
70d405b41b | ||
![]() |
95da97fa74 | ||
![]() |
546c727520 | ||
![]() |
1656d17b22 | ||
![]() |
8fa5c9dce2 | ||
![]() |
b8b34a1b26 | ||
![]() |
6608c5a8a7 | ||
![]() |
a299bc289b | ||
![]() |
e0d8cceb65 | ||
![]() |
3a739c38c5 | ||
![]() |
d32feaa668 | ||
![]() |
f269fb46ea | ||
![]() |
63ea3449d3 | ||
![]() |
e97438114f | ||
![]() |
a5492dd5fc | ||
![]() |
fa057f512f | ||
![]() |
55f0abbe99 | ||
![]() |
9f5c5dfff4 | ||
![]() |
802f29fb0e | ||
![]() |
8a29e5eb5e | ||
![]() |
b804f38150 | ||
![]() |
46ea556593 | ||
![]() |
5335f262be | ||
![]() |
b11cda959d | ||
![]() |
8c8e5bb7c8 | ||
![]() |
59cf0f6a42 | ||
![]() |
5659249dfa | ||
![]() |
b894a78385 | ||
![]() |
3b45336929 | ||
![]() |
da28cff0f6 | ||
![]() |
5dbb93dbb4 | ||
![]() |
6cb0603fbe | ||
![]() |
8e30bd1f69 | ||
![]() |
6e5ceaa30d | ||
![]() |
e8c79f53a6 | ||
![]() |
e683fe88b9 | ||
![]() |
1bcb5ddd50 | ||
![]() |
4db2da9185 | ||
![]() |
1b39b2e261 | ||
![]() |
f144b6bae4 | ||
![]() |
2bd7245508 | ||
![]() |
b62f7c3057 | ||
![]() |
f4e455398c | ||
![]() |
85908befea | ||
![]() |
a6f5a0339a | ||
![]() |
c17c1ccaea | ||
![]() |
88e1fd9530 | ||
![]() |
2fa7e00f16 | ||
![]() |
5208d57f1e | ||
![]() |
76024b5036 | ||
![]() |
002dacef40 | ||
![]() |
580c0a7296 | ||
![]() |
67423ff64b | ||
![]() |
b135bcd422 | ||
![]() |
fb4105cf8a | ||
![]() |
d1f099374c | ||
![]() |
932396922d | ||
![]() |
afdf357fbe | ||
![]() |
8c117cfb57 | ||
![]() |
f13b30d606 | ||
![]() |
165b3dd215 | ||
![]() |
d218534fff | ||
![]() |
333fdf6b90 | ||
![]() |
625e4e2fb3 | ||
![]() |
949e93f9fe | ||
![]() |
e9792ef771 | ||
![]() |
9bf411f580 | ||
![]() |
11a8dacb0f | ||
![]() |
3bd7109d8b | ||
![]() |
9af10686b2 | ||
![]() |
c5377f4e05 | ||
![]() |
34db515acb | ||
![]() |
6ffb3c72fb | ||
![]() |
f582ab06ad | ||
![]() |
7c36289768 | ||
![]() |
544df87a8e |
16
.gitignore
vendored
@@ -1,11 +1,15 @@
|
||||
# Ignore generated files
|
||||
# ...
|
||||
|
||||
# Ignore VIM's backup generated files
|
||||
*.swp
|
||||
|
||||
# Ignore Android generated files and folders
|
||||
src_android/obj/
|
||||
templates/android_project/bin/
|
||||
templates/android_project/obj/
|
||||
templates/android_project/libs/
|
||||
local.properties
|
||||
|
||||
# Ignore thumbnails created by windows
|
||||
Thumbs.db
|
||||
@@ -60,3 +64,15 @@ xcschememanagement.plist
|
||||
._.*
|
||||
xcuserdata/
|
||||
DerivedData/
|
||||
*.dll
|
||||
src/libraylib.a
|
||||
src/libraylib.bc
|
||||
|
||||
# oculus example
|
||||
!examples/oculus_glfw_sample/
|
||||
|
||||
# external libraries DLLs
|
||||
!src/external/glfw3/lib/win32/glfw3.dll
|
||||
!src/external/openal_soft/lib/win32/OpenAL32.dll
|
||||
!src/external/OculusSDK/LibOVR/LibOVRRT32_1.dll
|
||||
!src/external/pthread/pthreadGC2.dll
|
||||
|
130
CHANGELOG
@@ -1,11 +1,139 @@
|
||||
changelog
|
||||
---------
|
||||
|
||||
Current Release: raylib 1.3.0 (03 September 2015)
|
||||
Current Release: raylib 1.5.0 (18 July 2016)
|
||||
|
||||
NOTE: Only versions marked as 'Release' are available in installer, updates are only available as source.
|
||||
NOTE: Current Release includes all previous updates.
|
||||
|
||||
-----------------------------------------------
|
||||
Release: raylib 1.5.0 (18 July 2016)
|
||||
-----------------------------------------------
|
||||
NOTE:
|
||||
Probably this new version is the biggest boost of the library ever, lots of parts of the library have been redesigned,
|
||||
lots of bugs have been solved and some **AMAZING** new features have been added.
|
||||
|
||||
HUGE changes:
|
||||
[rlgl] OCULUS RIFT CV1: Added support for VR, not oly Oculus Rift CV1 but also stereo rendering simulator (multiplatform).
|
||||
[rlgl] MATERIALS SYSTEM: Added support for Materials (.mtl) and multiple material properties: diffuse, specular, normal.
|
||||
[rlgl] LIGHTING SYSTEM: Added support for up to 8 lights of 3 different types: Omni, Directional and Spot.
|
||||
[physac] REDESIGNED: Improved performance and simplified usage, physic objects now are managed internally in a second thread!
|
||||
[audio] CHIPTUNES: Added support for module audio music (.xm, .mod) loading and playing. Multiple mixing channels supported.
|
||||
|
||||
other changes:
|
||||
|
||||
[core] Review Android button inputs
|
||||
[core] Support Android internal data storage
|
||||
[core] Renamed WorldToScreen() to GetWorldToScreen()
|
||||
[core] Removed function SetCustomCursor()
|
||||
[core] Removed functions BeginDrawingEx(), BeginDrawingPro()
|
||||
[core] Replaced functions InitDisplay() + InitGraphics() with: InitGraphicsDevice()
|
||||
[core] Added support for field-of-view Y (fovy) on 3d Camera
|
||||
[core] Added 2D camera mode functions: Begin2dMode() - End2dMode()
|
||||
[core] Translate mouse inputs to Android touch/gestures internally
|
||||
[core] Translate mouse inputs as touch inputs in HTML5
|
||||
[core] Improved function GetKeyPressed() to support multiple keys (including function keys)
|
||||
[core] Improved gamepad support, specially for RaspberryPi (including multiple gamepads support)
|
||||
[rlgl] Support stereo rendering simulation (duplicate draw calls by viewport, optimized)
|
||||
[rlgl] Added distortion shader (embeded) to support custom VR simulator: shader_distortion.h
|
||||
[rlgl] Added support for OpenGL 2.1 on desktop
|
||||
[rlgl] Improved 2D vs 3D drawing system (lines, triangles, quads)
|
||||
[rlgl] Improved DXT-ETC1 support on HTML5
|
||||
[rlgl] Review function: rlglUnproject()
|
||||
[rlgl] Removed function: rlglInitGraphics(), integrated into rlglInit()
|
||||
[rlgl] Updated Mesh and Shader structs
|
||||
[rlgl] Simplified internal (default) dynamic buffers
|
||||
[rlgl] Added support for indexed and dynamic mesh data
|
||||
[rlgl] Set fixed vertex attribs location points
|
||||
[rlgl] Improved mesh data loading support
|
||||
[rlgl] Added standard shader (embeded) to support materials and lighting: shader_standard.h
|
||||
[rlgl] Added light functions: CreateLight(), DestroyLight()
|
||||
[rlgl] Added wire mode functions: rlDisableWireMode(), rlEnableWireMode()
|
||||
[rlgl] Review function consistency, added: rlglLoadMesh(), rlglUpdateMesh(), rlglDrawMesh(), rlglUnloadMesh()
|
||||
[rlgl] Replaced SetCustomShader() by: BeginShaderMode() - EndShaderMode()
|
||||
[rlgl] Replaced SetBlendMode() by: BeginBlendMode() - EndBlendMode()
|
||||
[rlgl] Added functions to customize internal matrices: SetMatrixProjection(), SetMatrixModelview()
|
||||
[rlgl] Unified internal shaders to only one default shader
|
||||
[rlgl] Added support for render to texture (RenderTexture2D):
|
||||
LoadRenderTexture() - UnloadRenderTexture()
|
||||
BeginTextureMode() - EndTextureMode()
|
||||
[rlgl] Removed SetShaderMap*() functions
|
||||
[rlgl] Redesigned default buffers usage functions:
|
||||
LoadDefaultBuffers() - UnloadDefaultBuffers()
|
||||
UpdateDefaultBuffers() - DrawDefaultBuffers()
|
||||
[shapes] Corrected bug on GetCollisionRec()
|
||||
[textures] Added support for Nearest-Neighbor image scaling
|
||||
[textures] Added functions to draw text on image: ImageDrawText(), ImageDrawTextEx()
|
||||
[text] Reorganized internal functions: Added LoadImageFont()
|
||||
[text] Security check for unsupported BMFonts
|
||||
[models] Split mesh creation from model loading on heightmap and cubicmap
|
||||
[models] Updated BoundingBox collision detections
|
||||
[models] Added color parameter to DrawBoundigBox()
|
||||
[models] Removed function: DrawQuad()
|
||||
[models] Removed function: SetModelTexture()
|
||||
[models] Redesigned DrawPlane() to use RL_TRIANGLES
|
||||
[models] Redesigned DrawRectangleV() to use RL_TRIANGLES
|
||||
[models] Redesign to accomodate new materials system: LoadMaterial()
|
||||
[models] Added material functions: LoadDefaultMaterial(), LoadStandardMaterial()
|
||||
[models] Added MTL material loading support: LoadMTL()
|
||||
[models] Added function: DrawLight()
|
||||
[audio] Renamed SoundIsPlaying() to IsSoundPlaying()
|
||||
[audio] Renamed MusicIsPlaying() to IsMusicPlaying()
|
||||
[audio] Support multiple Music streams (indexed)
|
||||
[audio] Support multiple mixing channels
|
||||
[gestures] Improved and reviewed gestures system
|
||||
[raymath] Added QuaternionInvert()
|
||||
[raymath] Removed function: PrintMatrix()
|
||||
[raygui] Ported to header-only library (https://github.com/raysan5/raygui)
|
||||
[shaders] Added depth drawing shader (requires a depth texture)
|
||||
[shaders] Reviewed included shaders and added comments
|
||||
[OpenAL Soft] Updated to latest version (1.17.2)
|
||||
[GLFW3] Updated to latest version (3.2)
|
||||
[stb] Updated to latest headers versions
|
||||
[GLAD] Converted to header only library and simplified to only used extensions
|
||||
[*] Reorganize library folders: external libs moved to src/external folder
|
||||
[*] Reorganize src folder for Android library
|
||||
[*] Review external dependencies usage
|
||||
[*] Improved Linux and OSX build systems
|
||||
[*] Lots of tweaks and bugs corrected all around
|
||||
|
||||
-----------------------------------------------
|
||||
Release: raylib 1.4.0 (22 February 2016)
|
||||
-----------------------------------------------
|
||||
NOTE:
|
||||
This version supposed another big improvement for raylib, including new modules and new features.
|
||||
More than 30 new functions have been added to previous raylib version.
|
||||
Around 8 new examples and +10 new game samples have been added.
|
||||
|
||||
BIG changes:
|
||||
[textures] IMAGE MANIPULATION: Functions to crop, resize, colorize, flip, dither and even draw image-to-image or text-to-image.
|
||||
[text] SPRITEFONT SUPPORT: Added support for AngelCode fonts (.fnt) and TrueType fonts (.ttf).
|
||||
[gestures] REDESIGN: Gestures system simplified and prepared to process generic touch events, including mouse events (multiplatform).
|
||||
[physac] NEW MODULE: Basic 2D physics support, use colliders and rigidbodies; apply forces to physic objects.
|
||||
|
||||
other changes:
|
||||
[rlgl] Removed GLEW library dependency, now using GLAD
|
||||
[rlgl] Implemented alternative to glGetTexImage() on OpenGL ES
|
||||
[rlgl] Using depth data on batch drawing
|
||||
[rlgl] Reviewed glReadPixels() function
|
||||
[core][rlgl] Reviewed raycast system, now 3D picking works
|
||||
[core] Android: Reviewed Android App cycle, paused if inactive
|
||||
[shaders] Implemented Blinn-Phong lighting shading model
|
||||
[textures] Implemented Floyd-Steinberg dithering - ImageDither()
|
||||
[text] Added line-break support to DrawText()
|
||||
[text] Added TrueType Fonts support (using stb_truetype)
|
||||
[models] Implement function: CalculateBoundingBox(Mesh mesh)
|
||||
[models] Added functions to check Ray collisions
|
||||
[models] Improve map resolution control on LoadHeightmap()
|
||||
[camera] Corrected small-glitch on zoom-in with mouse-wheel
|
||||
[gestures] Implemented SetGesturesEnabled() to enable only some gestures
|
||||
[gestures] Implemented GetElapsedTime() on Windows system
|
||||
[gestures] Support mouse gestures for desktop platforms
|
||||
[raymath] Complete review of the module and converted to header-only
|
||||
[easings] Added new module for easing animations
|
||||
[stb] Updated to latest headers versions
|
||||
[*] Lots of tweaks around
|
||||
|
||||
-----------------------------------------------
|
||||
Release: raylib 1.3.0 (01 September 2015)
|
||||
-----------------------------------------------
|
||||
|
18
HELPME.md
@@ -7,23 +7,21 @@ please, [let me know][raysan5].
|
||||
The following help is highly appreciated:
|
||||
|
||||
- C programming - Can you write / review / test / improve the code?
|
||||
- Translators / Localizators - Can you translate raylib to another language?
|
||||
- Documentation / Tutorials / Example writters - Can you write some tutorial / example?
|
||||
- Web Development - Can you help with the web? Can you setup a forum?
|
||||
- Porting to Linux, OSX... - Can you compile and test raylib on another OS?
|
||||
- Porting to Linux, OSX, RaspberryPi, consoles... - Can you compile and test raylib on another systems?
|
||||
- Testers of current features and multiple systems - Can you find some bug on raylib?
|
||||
|
||||
If you can not help on any of the above points but you still want to contribute in some way... please, consider helping
|
||||
with a small [donation](http://www.raylib.com/helpme.htm) (just some euros...). It will really motivate to continue improving this project (and pay some bills… or some coffee).
|
||||
with a small [donation](http://www.raylib.com/helpme.htm) or contributing with [raylib patreon](https://www.patreon.com/raysan5). It will really motivate to continue improving this project (and pay some bills… or some coffee).
|
||||
|
||||
raylib philosophy
|
||||
------------------
|
||||
|
||||
* raylib is a tool to LEARN videogames programming, every single function in raylib should be a tutorial on itself (clear code).
|
||||
* 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
|
||||
has not a clear usefulness, better not to include it.
|
||||
* raylib is a tool to LEARN 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 has not a clear usefulness, 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, hopefully, collaborative; contribution of tutorials / code-examples / bugs-solving / code-comments are highly appreciated.
|
||||
* 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.
|
||||
|
||||
contact
|
||||
@@ -32,6 +30,8 @@ contact
|
||||
* Webpage: [http://www.raylib.com](http://www.raylib.com)
|
||||
* Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5)
|
||||
* Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames)
|
||||
* Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
||||
* Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5)
|
||||
* Patreon: [https://www.patreon.com/raysan5](https://www.patreon.com/raysan5)
|
||||
|
||||
|
||||
[raysan5]: mailto:raysan@raysanweb.com "Ramon Santamaria - Ray San"
|
||||
[raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San"
|
||||
|
@@ -7,7 +7,7 @@ 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 Ramon Santamaria (Ray San - raysan@raysanweb.com)
|
||||
Copyright (c) 2013-2016 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.
|
||||
@@ -41,7 +41,7 @@ All rBMF fonts provided with raylib are free to use (freeware) and have been des
|
||||
3d models
|
||||
---------
|
||||
|
||||
dwarf 3d model used in examples is created by Daniel Moreno and licensed as Creative Commons Attribution-NonCommercial 3.0
|
||||
dwarf 3d model used in examples is created by David Moreno and licensed as Creative Commons Attribution-NonCommercial 3.0
|
||||
|
||||
Full license provided below:
|
||||
|
||||
|
229
README.md
@@ -1,4 +1,4 @@
|
||||
<img src="http://www.raylib.com/img/fb_raylib_logo.png" width=256>
|
||||
<img src="https://github.com/raysan5/raylib/blob/master/logo/logo256x256.png" width=256>
|
||||
|
||||
about
|
||||
-----
|
||||
@@ -6,7 +6,6 @@ about
|
||||
raylib is a simple and easy-to-use library to learn videogames programming.
|
||||
|
||||
raylib is highly inspired by Borland BGI graphics lib and by XNA framework.
|
||||
Allegro and SDL have also been analyzed for reference.
|
||||
|
||||
NOTE for ADVENTURERS: raylib is a programming library to learn videogames programming;
|
||||
no fancy interface, no visual helpers, no auto-debugging... just coding in the most
|
||||
@@ -15,7 +14,7 @@ pure spartan-programmers way. Are you ready to learn? Jump to [code examples!](h
|
||||
history
|
||||
-------
|
||||
|
||||
I've developed videogames for some years and last year I had to taught videogames development
|
||||
I've developed videogames for some years and 4 years ago I started teaching videogames development
|
||||
to young people with artistic profile, most of them 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
|
||||
@@ -34,7 +33,7 @@ I've coded quite a lot in C# and XNA and I really love it (in fact, my students
|
||||
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.
|
||||
|
||||
raylib started as a weekend project and after three months of hard work, first version was published.
|
||||
raylib started as a weekend project and after three months of hard work, raylib 1.0 was published on November 2013.
|
||||
|
||||
Enjoy it.
|
||||
|
||||
@@ -44,7 +43,7 @@ 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 translate raylib-OpenGL-style
|
||||
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
|
||||
@@ -84,9 +83,7 @@ Shaders support is the biggest addition to raylib 1.3, with support for easy sha
|
||||
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/develop/src/camera.c) module offers to the user multiple preconfigured ready-to-use camera systems (free camera, 1st person, 3rd person).
|
||||
Camera modes are very easy to use, just check examples: [core_3d_camera_free.c](https://github.com/raysan5/raylib/blob/develop/examples/core_3d_camera_free.c) and [core_3d_camera_first_person.c](https://github.com/raysan5/raylib/blob/develop/examples/core_3d_camera_first_person.c).
|
||||
|
||||
@@ -99,20 +96,81 @@ Most of the examples have been completely rewritten and +10 new examples have be
|
||||
|
||||
Lots of code changes and lot of testing have concluded in this amazing new raylib 1.3.
|
||||
|
||||
notes on raylib 1.4
|
||||
-------------------
|
||||
|
||||
On February 2016, after 4 months of raylib 1.3 release, it comes raylib 1.4. For this new version,
|
||||
lots of parts of the library have been reviewed, lots of bugs have been solved and some interesting features have been added.
|
||||
|
||||
First big addition is a set of [Image manipulation functions](https://github.com/raysan5/raylib/blob/develop/src/raylib.h#L673) have been added to crop, resize, colorize, flip, dither and even draw image-to-image or text-to-image.
|
||||
Now a basic image processing can be done before converting the image to texture for usage.
|
||||
|
||||
SpriteFonts system has been improved, adding support for AngelCode fonts (.fnt) and TrueType Fonts (using [stb_truetype](https://github.com/nothings/stb/blob/master/stb_truetype.h) helper library).
|
||||
Now raylib can read standard .fnt font data and also generate at loading a SpriteFont from a TTF file.
|
||||
|
||||
New [physac](https://github.com/raysan5/raylib/blob/develop/src/physac.h) physics module for basic 2D physics support. Still in development but already functional.
|
||||
Module comes with some usage examples for basic jump and level interaction and also force-based physic movements.
|
||||
|
||||
[raymath](https://github.com/raysan5/raylib/blob/develop/src/raymath.h) module has been reviewed; some bugs have been solved and the module has been converted to a header-only file for easier portability, optionally, functions can also be used as inline.
|
||||
|
||||
[gestures](https://github.com/raysan5/raylib/blob/develop/src/gestures.c) module has redesigned and simplified, now it can process touch events from any source, including mouse.
|
||||
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).
|
||||
|
||||
Other important improvements are the functional raycast system for 3D picking, including some ray collision-detection functions,
|
||||
and the addition of two simple functions for persistent data storage. Now raylib user can save and load game data in a file (only some platforms supported).
|
||||
A simple [easings](https://github.com/raysan5/raylib/blob/develop/src/easings.h) module has also been added for values animation.
|
||||
|
||||
Up to 8 new code examples have been added to show the new raylib features and +10 complete game samples have been provided to learn
|
||||
how to create some classic games like Arkanoid, Asteroids, Missile Commander, Snake or Tetris.
|
||||
|
||||
Lots of code changes and lots of hours of hard work have concluded in this amazing new raylib 1.4.
|
||||
|
||||
notes on raylib 1.5
|
||||
-------------------
|
||||
|
||||
On July 2016, after 5 months of raylib 1.4 release, arrives raylib 1.5. This new version is the biggest boost of the library until now, lots of parts of the library have been redesigned, lots of bugs have been solved and some **AMAZING** new features have been added.
|
||||
|
||||
VR support: raylib supports **Oculus Rift CV1**, one of the most anticipated VR devices in the market. Additionally, raylib supports simulated VR stereo rendering, independent of the VR device; it means, raylib can generate stereo renders with custom head-mounted-display device parameteres, that way, any VR device in the market can be **simulated in any platform** just configuring device parameters (and consequently, lens distortion). To enable VR is [extremely easy](https://github.com/raysan5/raylib/blob/develop/examples/core_oculus_rift.c).
|
||||
|
||||
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.
|
||||
|
||||
Complete gamepad support on Raspberry Pi: Gamepad system has been completely redesigned. Now multiple gamepads can be easily configured and used; gamepad data is read and processed in raw mode in a second thread.
|
||||
|
||||
Redesigned physics module: [physac](https://github.com/raysan5/raylib/blob/develop/src/physac.h) module has been converted to header only and usage [has been simplified](https://github.com/raysan5/raylib/blob/develop/examples/physics_basic_rigidbody.c). Performance has also been singnificantly improved, now physic objects are managed internally in a second thread.
|
||||
|
||||
Audio chiptunese support and mixing channels: Added support for module audio music (.xm, .mod) loading and playing. Multiple mixing channels are now also supported. All this features thanks to the amazing work of @kd7tck.
|
||||
|
||||
Other additions include a [2D camera system](https://github.com/raysan5/raylib/blob/develop/examples/core_2d_camera.c), render textures for offline render (and most comprehensive [postprocessing](https://github.com/raysan5/raylib/blob/develop/examples/shaders_postprocessing.c)) or support for legacy OpenGL 2.1 on desktop platforms.
|
||||
|
||||
This new version is so massive that is difficult to list all the improvements, most of raylib modules have been reviewed and [rlgl](https://github.com/raysan5/raylib/blob/develop/src/rlgl.c) module has been completely redesigned to accomodate to new material-lighting systems and stereo rendering. You can check [CHANGELOG](https://github.com/raysan5/raylib/blob/develop/CHANGELOG) file for a more detailed list of changes.
|
||||
|
||||
Up to 8 new code examples have been added to show the new raylib features and also some samples to show the usage of [rlgl](https://github.com/raysan5/raylib/blob/develop/examples/rlgl_standalone.c) and [audio](https://github.com/raysan5/raylib/blob/develop/examples/audio_standalone.c) raylib modules as standalone libraries.
|
||||
|
||||
Lots of code changes (+400 commits) and lots of hours of hard work have concluded in this amazing new raylib 1.5.
|
||||
|
||||
features
|
||||
--------
|
||||
|
||||
* Written in plain C code (C99)
|
||||
* Uses C# PascalCase/camelCase notation
|
||||
* Hardware accelerated with OpenGL (1.1, 3.3 or ES2)
|
||||
* Unique OpenGL abstraction layer: [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c)
|
||||
* Powerful fonts module with SpriteFonts support
|
||||
* Outstanding texture formats support, including compressed formats
|
||||
* Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES2)
|
||||
* Unique OpenGL abstraction layer (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c)
|
||||
* Powerful fonts module with multiple SpriteFonts formats support (XNA bitmap fonts, AngelCode fonts, TTF)
|
||||
* Outstanding texture formats support, including compressed formats (DXT, ETC, PVRT, ASTC)
|
||||
* Basic 3d support for Shapes, Models, Billboards, Heightmaps and Cubicmaps
|
||||
* Materials (diffuse, normal, specular) and Lighting (point, directional, spot) support
|
||||
* Shaders support, including Model shaders and Postprocessing shaders
|
||||
* Powerful math module for Vector and Matrix operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.c)
|
||||
* Audio loading and playing with streaming support (WAV and OGG)
|
||||
* Audio loading and playing with streaming support and mixing channels (WAV, OGG, XM, MOD)
|
||||
* VR stereo rendering support with configurable HMD device parameters
|
||||
* Multiple platforms support: Windows, Linux, Mac, **Android**, **Raspberry Pi**, **HTML5** and **Oculus Rift CV1**
|
||||
* Custom color palette for fancy visuals on raywhite background
|
||||
* Multiple platforms support: Windows, Linux, Mac, **Android**, **Raspberry Pi** and **HTML5**
|
||||
* Minimal external dependencies (GLFW3, OpenGL, OpenAL)
|
||||
|
||||
raylib uses on its core module the outstanding [GLFW3](http://www.glfw.org/) library. The best option by far I found for
|
||||
multiplatform (Windows, Linux, Mac) window/context and input management (clean, focused, great license, well documented, modern, ...).
|
||||
@@ -120,10 +178,12 @@ multiplatform (Windows, Linux, Mac) window/context and input management (clean,
|
||||
raylib uses on its [audio](https://github.com/raysan5/raylib/blob/master/src/audio.c) module, [OpenAL Soft](http://kcat.strangesoft.net/openal.html) audio library, in multiple flavours,
|
||||
to accomodate to Android, Raspberry Pi and HTML5.
|
||||
|
||||
On Android, raylib uses `native_app_glue module` (provided on Android NDK) and native Android libraries to manage window/context, inputs and activity cycle.
|
||||
On Android, raylib uses `native_app_glue module` (provided by Android NDK) and native Android libraries to manage window/context, inputs and activity cycle.
|
||||
|
||||
On Raspberry Pi, raylib uses Videocore API and EGL for window/context management and raw inputs reading.
|
||||
|
||||
On Oculus Rift CV1, raylib uses Oculus PC SDK libraries but only the core C library ([LibOVR](https://github.com/raysan5/raylib/tree/develop/src/external/OculusSDK/LibOVR)); runtime library (LibOVRRT32_1.dll) must be linked at compilation time.
|
||||
|
||||
raylib is licensed under a zlib/libpng license. View [LICENSE](https://github.com/raysan5/raylib/blob/master/LICENSE.md).
|
||||
|
||||
tools requirements
|
||||
@@ -145,126 +205,12 @@ Since raylib v1.1, you can download a Windows Installer package for easy install
|
||||
building source (generate libraylib.a)
|
||||
--------------------------------------
|
||||
|
||||
**Building raylib sources on desktop platforms:**
|
||||
|
||||
_Step 1:_ Using MinGW make tool, just navigate from command line to `raylib/src/` folder and type:
|
||||
|
||||
mingw32-make PLATFORM=PLATFORM_DESKTOP
|
||||
|
||||
NOTE: By default raylib compiles using OpenGL 1.1 to maximize compatibility; to use OpenGL 3.3 just type:
|
||||
|
||||
mingw32-make PLATFORM=PLATFORM_DESKTOP GRAPHICS=GRAPHICS_API_OPENGL_33
|
||||
|
||||
**Building raylib sources on Raspberry Pi:**
|
||||
|
||||
_Step 1._ Make sure you have installed in your Raspberry Pi OpenAL Soft library for audio:
|
||||
|
||||
sudo apt-get install openal1
|
||||
|
||||
_Step 2._ Navigate from command line to `raylib/src/` folder and type:
|
||||
|
||||
make
|
||||
|
||||
**Building raylib sources for Android:**
|
||||
|
||||
_Step 1._ Make sure you have installed Android SDK, Android NDK and Apache Ant tools:
|
||||
|
||||
> Download and decompress on C: [Android SDK r23](http://dl.google.com/android/android-sdk_r23.0.2-windows.zip)
|
||||
|
||||
> Download and decompress on C: [Android NDK r10b](http://dl.google.com/android/ndk/android-ndk32-r10b-windows-x86.zip)
|
||||
|
||||
> Download and decompress on C: [Apache Ant 1.9.4](http://ftp.cixug.es/apache//ant/binaries/apache-ant-1.9.4-bin.zip)
|
||||
|
||||
_Step 2._ Create the following environment variables with the correct paths:
|
||||
|
||||
ANDROID_SDK_TOOLS = C:\android-sdk\platform-tools
|
||||
ANDROID_NDK_ROOT = C:\android-ndk-r10b
|
||||
ANT_HOME = C:\apache-ant-1.9.4
|
||||
|
||||
_Step 3._ Navigate from command line to folder `raylib/template_android/` and type:
|
||||
|
||||
%ANDROID_NDK_ROOT%\ndk-build
|
||||
|
||||
NOTE: libraylib.a will be generated in folder `raylib/src_android/obj/local/armeabi/`, it must be copied
|
||||
to Android project; if using `raylib/template_android` project, copy it to `raylib/template_android/jni/libs/`.
|
||||
|
||||
**Building raylib sources for Web (HTML5)**
|
||||
|
||||
_Step 1._ Make sure you have installed emscripten SDK:
|
||||
|
||||
> Download latest version from [here](http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html). I recommend downloading the [Portable Emscripten SDK for Windows](https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-1.25.0-portable-64bit.zip) and decompress it in `C:\emsdk-1.25.0` folder. After that, follow the portable version installation instructions.
|
||||
|
||||
_Step 2._ Open `raylib/src/makefile` on Notepad++ and run the script named `raylib_makefile_emscripten`
|
||||
Check raylib wiki page: [Compile for...](https://github.com/raysan5/raylib/wiki)
|
||||
|
||||
building examples
|
||||
-----------------
|
||||
|
||||
**Building raylib examples on desktop platforms:**
|
||||
|
||||
_Step 1:_ Using MinGW make tool, just navigate from command line to `raylib/examples/` folder and type:
|
||||
|
||||
mingw32-make PLATFORM=PLATFORM_DESKTOP
|
||||
|
||||
NOTE: Make sure the following libs (and their headers) are placed on their respectibe MinGW folders:
|
||||
|
||||
libglfw3.a - GLFW3 (static version)
|
||||
libglew32.a - GLEW, OpenGL extension loading, only required if using OpenGL 3.3+ or ES2
|
||||
libopenal32.a - OpenAL Soft, audio device management
|
||||
|
||||
**Building raylib examples on Raspberry Pi:**
|
||||
|
||||
_Step 1._ Make sure you have installed in your Raspberry Pi OpenAL Soft library for audio:
|
||||
|
||||
sudo apt-get install openal1
|
||||
|
||||
_Step 2._ Navigate from command line to `raylib/examples/` folder and type:
|
||||
|
||||
make
|
||||
|
||||
**Building raylib examples for HTML5 (emscripten):**
|
||||
|
||||
_Step 1._ Make sure you have installed emscripten SDK:
|
||||
|
||||
> Download latest version from [here](http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html). I recommend downloading the [Portable Emscripten SDK for Windows](https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-1.25.0-portable-64bit.zip) and decompress it in `C:\emsdk-1.25.0` folder. After that, follow the portable version installation instructions.
|
||||
|
||||
_Step 2._ Open `raylib/examples/makefile` on Notepad++ and run the script named `raylib_makefile_emscripten`
|
||||
|
||||
NOTE: At this moment, raylib examples are not ready to directly compile for HTML5, code needs to be reorganized due to the way web browsers work. To see how code should be refactored to fit compilation for web, check [core_basic_window_web.c](https://github.com/raysan5/raylib/blob/master/examples/core_basic_window_web.c) example.
|
||||
|
||||
**Building raylib project for Android (using template):**
|
||||
|
||||
_Step 1._ Make sure you have installed Android SDK, Android NDK and Apache Ant tools:
|
||||
|
||||
> Download and decompress on C: [Android SDK r23] (http://dl.google.com/android/android-sdk_r23.0.2-windows.zip)
|
||||
|
||||
> Download and decompress on C: [Android NDK r10b] (http://dl.google.com/android/ndk/android-ndk32-r10b-windows-x86.zip)
|
||||
|
||||
> Download and decompress on C: [Apache Ant 1.9.4] (http://ftp.cixug.es/apache//ant/binaries/apache-ant-1.9.4-bin.zip)
|
||||
|
||||
_Step 2._ Create the following environment variables with the correct paths:
|
||||
|
||||
ANDROID_SDK_TOOLS = C:\android-sdk\platform-tools
|
||||
ANDROID_NDK_ROOT = C:\android-ndk-r10b
|
||||
ANT_HOME = C:\apache-ant-1.9.4
|
||||
|
||||
_Step 3._ To compile project, navigate from command line to folder `raylib/template_android/` and type:
|
||||
|
||||
%ANDROID_NDK_ROOT%\ndk-build
|
||||
|
||||
_Step 4._ To generate APK, navigate to folder `raylib/template_android/` and type:
|
||||
|
||||
%ANT_HOME%\bin\ant debug
|
||||
|
||||
_Step 5:_ To install APK into connected device (previously intalled drivers and activated USB debug mode on device):
|
||||
|
||||
%ANT_HOME%\bin\ant installd
|
||||
|
||||
_Step 6:_ To view log output from device:
|
||||
|
||||
%ANDROID_SDK_TOOLS%\adb logcat -c
|
||||
%ANDROID_SDK_TOOLS%\adb -d logcat raylib:V *:S
|
||||
|
||||
**If you have any doubt, [just let me know][raysan5].**
|
||||
Check raylib wiki page: [Compile for...](https://github.com/raysan5/raylib/wiki)
|
||||
|
||||
contact
|
||||
-------
|
||||
@@ -272,6 +218,9 @@ contact
|
||||
* Webpage: [http://www.raylib.com](http://www.raylib.com)
|
||||
* Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5)
|
||||
* Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames)
|
||||
* Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
||||
* Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5)
|
||||
* Patreon: [https://www.patreon.com/raysan5](https://www.patreon.com/raysan5)
|
||||
|
||||
If you are using raylib and you enjoy it, please, [let me know][raysan5].
|
||||
|
||||
@@ -280,18 +229,26 @@ If you feel you can help, then, [helpme!](http://www.raylib.com/helpme.htm)
|
||||
acknowledgements
|
||||
---------------
|
||||
|
||||
The following people have contributed in some way to make raylib project a reality. Big thanks to them!
|
||||
I believe that time is the most valuable resource and the following people have invested part of their time
|
||||
contributing (in some way or another) to make raylib project better. Huge thanks!
|
||||
|
||||
- [Zopokx](https://github.com/Zopokx) for testing the web.
|
||||
- [Elendow](http://www.elendow.com) for testing and helping on web development.
|
||||
- Victor Dual for implementating and testing of 3D shapes functions.
|
||||
- Marc Palau for implementating and testing of 3D shapes functions and helping on development of camera and getures modules.
|
||||
- Victor Dual for implementing and testing 3D shapes functions.
|
||||
- Marc Palau for implementing and testing 3D shapes functions and contribute on camera and gestures modules.
|
||||
- Kevin Gato for improving texture internal formats support and helping on raygui development.
|
||||
- Daniel Nicolas for improving texture internal formats support and helping on raygui development.
|
||||
- Marc Agüera for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
|
||||
- Daniel Moreno for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
|
||||
- Daniel Gomez for testing and using raylib on a real product ([Koala Seasons](http://www.koalaseasons.com))
|
||||
- Sergio Martinez for helping on raygui development and tools development.
|
||||
- Sergio Martinez for helping on raygui development and tools development (raygui_styler).
|
||||
- [Victor Fisac](https://github.com/victorfisac) for developing physics raylib module (physac) and implementing materials and lighting systems... among multiple other improvements and multiple tools and games.
|
||||
- Albert Martos for helping on raygui and porting examples and game-templates to Android and HTML5.
|
||||
- Ian Eito for helping on raygui and porting examples and game-templates to Android and HTML5.
|
||||
- [procedural](https://github.com/procedural) for testing raylib on Linux, correcting some bugs and adding several mouse functions.
|
||||
- [Chris Hemingway](https://github.com/cHemingway) for improving raylib on OSX build system.
|
||||
- [Emanuele Petriglia](https://github.com/LelixSuper) for working on multiple GNU/Linux improvements and developing [TicTacToe](https://github.com/LelixSuper/TicTacToe) raylib game.
|
||||
- [Joshua Reisenauer](https://github.com/kd7tck) for adding audio modules support (XM, MOD) and reviewing audio system.
|
||||
|
||||
|
||||
[raysan5]: mailto:raysan@raysanweb.com "Ramon Santamaria - Ray San"
|
||||
[raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San"
|
||||
|
46
ROADMAP.md
@@ -1,25 +1,43 @@
|
||||
roadmap
|
||||
-------
|
||||
|
||||
Current version of raylib is quite complete and functional but there is still a lot of things I would like to improve.
|
||||
Here it is a list of features I would like to add and functions to improve.
|
||||
Current version of raylib is quite complete and functional but there is still a lot of things to add and improve.
|
||||
Here it is a wish list of features I would like to add and functions to improve.
|
||||
|
||||
Around the source code there are multiple TODO points with pending revisions/bugs and here it is a list of desired features.
|
||||
Note that around the raylib source code there are multiple TODO points with pending revisions/bugs. Check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
|
||||
|
||||
raylib v1.4
|
||||
raylib 1.x
|
||||
|
||||
- TTF fonts support (using stb_truetype)
|
||||
- Raycast system for 3D picking (including collisions detection)
|
||||
- Remove GLEW dependency (use another solution... glad?)
|
||||
- Floyd-Steinberg dithering on 16bit image format conversion
|
||||
- Basic image manipulation functions (crop, resize, draw...)
|
||||
- Basic image procedural generation (spot, gradient, noise...)
|
||||
- Basic GPU stats sytem (memory, draws, time...)
|
||||
- LUA scripting support (wrapper to lua lib)
|
||||
[IN PROGRESS] LUA scripting support (wrapper to lua lib)
|
||||
Basic GPU stats sytem (memory, draws, time...)
|
||||
Procedural image generation functions (spot, gradient, noise...)
|
||||
Procedural mesh generation functions (cube, cone, sphere...)
|
||||
Touch-based camera controls for Android
|
||||
Skybox and Fog support
|
||||
|
||||
Check [GITHUB ISSUES][issues] for further details on implementation status for this features!
|
||||
raylib 1.5
|
||||
|
||||
[DONE] Support Oculus Rift CV1 and VR stereo rendering (simulator)
|
||||
[DONE] Redesign Shaders/Textures system -> New Materials system
|
||||
[DONE] Support lighting: Omni, Directional and Spot lights
|
||||
[DONE] Redesign physics module (physac)
|
||||
[DONE] Chiptunes audio modules support
|
||||
|
||||
raylib 1.4
|
||||
|
||||
[DONE] TTF fonts support (using stb_truetype)
|
||||
[DONE] Raycast system for 3D picking (including collisions detection)
|
||||
[DONE] Floyd-Steinberg dithering on 16bit image format conversion
|
||||
[DONE] Basic image manipulation functions (crop, resize, draw...)
|
||||
[DONE] Storage load/save data functionality
|
||||
[DONE] Add Physics module (physac)
|
||||
[DONE] Remove GLEW dependency -> Replaced by GLAD
|
||||
[DONE] Redesign Raspberry PI inputs system
|
||||
[DONE] Redesign gestures module to be multiplatform
|
||||
[DONE] Module raymath as header-only and functions inline
|
||||
[DONE] Add Easings module (easings.h)
|
||||
|
||||
Any feature missing? Do you have a request? [Let me know!][raysan5]
|
||||
|
||||
[raysan5]: mailto:raysan@raysanweb.com "Ramon Santamaria - Ray San"
|
||||
[raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San"
|
||||
[isssues]: https://github.com/raysan5/raylib/issues
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten)
|
||||
#
|
||||
# Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||
# Copyright (c) 2013-2016 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.
|
||||
@@ -78,32 +78,38 @@ endif
|
||||
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
|
||||
|
||||
# define any directories containing required header files
|
||||
INCLUDES = -I. -I../src -I../src/external
|
||||
|
||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||
INCLUDES = -I. -I../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads
|
||||
else
|
||||
INCLUDES = -I. -I../src
|
||||
INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
# add standard directories for GNU/Linux
|
||||
ifeq ($(PLATFORM_OS),LINUX)
|
||||
INCLUDES += -I/usr/local/include/raylib/
|
||||
else ifeq ($(PLATFORM_OS),WINDOWS)
|
||||
# external libraries headers
|
||||
# GLFW3
|
||||
INCLUDES += -I../external/glfw3/include
|
||||
# GLEW
|
||||
INCLUDES += -I../external/glew/include
|
||||
INCLUDES += -I../src/external/glfw3/include
|
||||
# OpenAL Soft
|
||||
INCLUDES += -I../external/openal_soft/include
|
||||
INCLUDES += -I../src/external/openal_soft/include
|
||||
endif
|
||||
endif
|
||||
|
||||
# define library paths containing required libs
|
||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||
LFLAGS = -L. -L../src -L/opt/vc/lib
|
||||
else
|
||||
LFLAGS = -L. -L../src
|
||||
|
||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||
LFLAGS += -L/opt/vc/lib
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
# add standard directories for GNU/Linux
|
||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||
# external libraries to link with
|
||||
# GLFW3
|
||||
LFLAGS += -L../external/glfw3/lib/$(LIBPATH)
|
||||
ifneq ($(PLATFORM_OS),OSX)
|
||||
LFLAGS += -L../src/external/glfw3/lib/$(LIBPATH)
|
||||
# OpenAL Soft
|
||||
LFLAGS += -L../external/openal_soft/lib/$(LIBPATH)
|
||||
# GLEW
|
||||
LFLAGS += -L../external/glew/lib/$(LIBPATH)
|
||||
LFLAGS += -L../src/external/openal_soft/lib/$(LIBPATH)
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -113,18 +119,20 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(PLATFORM_OS),LINUX)
|
||||
# libraries for Debian GNU/Linux desktop compiling
|
||||
# requires the following packages:
|
||||
# libopenal-dev libglew-dev libegl1-mesa-dev
|
||||
LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lm -pthread
|
||||
# libglfw3-dev libopenal-dev libegl1-mesa-dev
|
||||
LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -pthread -ldl
|
||||
# on XWindow could require also below libraries, just uncomment
|
||||
#LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
|
||||
else
|
||||
ifeq ($(PLATFORM_OS),OSX)
|
||||
# libraries for OS X 10.9 desktop compiling
|
||||
# requires the following packages:
|
||||
# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
|
||||
LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa
|
||||
# libglfw3-dev libopenal-dev libegl1-mesa-dev
|
||||
LIBS = -lraylib -lglfw3 -framework OpenGL -framework OpenAl -framework Cocoa
|
||||
else
|
||||
# libraries for Windows desktop compiling
|
||||
# NOTE: GLFW3 and OpenAL Soft libraries should be installed
|
||||
LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32
|
||||
LIBS = -lraylib -lglfw3 -lopengl32 -lopenal32 -lgdi32
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
@@ -134,7 +142,8 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||
LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
|
||||
endif
|
||||
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||
LIBS = ../src/libraylib.bc
|
||||
# just adjust the correct path to libraylib.bc
|
||||
LIBS = ../release/html5/libraylib.bc
|
||||
endif
|
||||
|
||||
# define additional parameters and flags for windows
|
||||
@@ -158,10 +167,15 @@ EXAMPLES = \
|
||||
core_random_values \
|
||||
core_color_select \
|
||||
core_drop_files \
|
||||
core_storage_values \
|
||||
core_gestures_detection \
|
||||
core_3d_mode \
|
||||
core_3d_picking \
|
||||
core_3d_camera_free \
|
||||
core_3d_camera_first_person \
|
||||
core_2d_camera \
|
||||
core_world_screen \
|
||||
core_oculus_rift \
|
||||
shapes_logo_raylib \
|
||||
shapes_basic_shapes \
|
||||
shapes_colors_palette \
|
||||
@@ -174,10 +188,14 @@ EXAMPLES = \
|
||||
textures_raw_data \
|
||||
textures_formats_loading \
|
||||
textures_particles_trail_blending \
|
||||
textures_image_processing \
|
||||
textures_image_drawing \
|
||||
text_sprite_fonts \
|
||||
text_bmfont_ttf \
|
||||
text_rbmf_fonts \
|
||||
text_format_text \
|
||||
text_font_select \
|
||||
text_writing_anim \
|
||||
models_geometric_shapes \
|
||||
models_box_collisions \
|
||||
models_billboard \
|
||||
@@ -188,16 +206,16 @@ EXAMPLES = \
|
||||
shaders_shapes_textures \
|
||||
shaders_custom_uniform \
|
||||
shaders_postprocessing \
|
||||
shaders_standard_lighting \
|
||||
audio_sound_loading \
|
||||
audio_music_stream \
|
||||
audio_module_playing \
|
||||
fix_dylib \
|
||||
|
||||
#core_input_gamepad \
|
||||
|
||||
|
||||
# typing 'make' will invoke the first target entry in the file,
|
||||
# typing 'make' will invoke the default target entry called 'all',
|
||||
# in this case, the 'default' target entry is raylib
|
||||
default: examples
|
||||
all: examples
|
||||
|
||||
# compile all examples
|
||||
examples: $(EXAMPLES)
|
||||
@@ -214,24 +232,16 @@ core_input_keys: core_input_keys.c
|
||||
core_input_mouse: core_input_mouse.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [core] example - gamepad input
|
||||
core_input_gamepad: core_input_gamepad.c
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
else
|
||||
@echo core_input_gamepad: Only supported on desktop platform
|
||||
endif
|
||||
|
||||
# compile [core] example - mouse wheel
|
||||
core_mouse_wheel: core_mouse_wheel.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [core] example - drop files
|
||||
core_drop_files: core_drop_files.c
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
# compile [core] example - gamepad input
|
||||
core_input_gamepad: core_input_gamepad.c
|
||||
ifeq ($(PLATFORM), $(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_RPI))
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
else
|
||||
@echo core_drop_files: Only supported on desktop platform
|
||||
@echo core_input_gamepad: Example not supported on PLATFORM_ANDROID or PLATFORM_WEB
|
||||
endif
|
||||
|
||||
# compile [core] example - generate random values
|
||||
@@ -242,6 +252,26 @@ core_random_values: core_random_values.c
|
||||
core_color_select: core_color_select.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [core] example - drop files
|
||||
core_drop_files: core_drop_files.c
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
else
|
||||
@echo core_drop_files: Example not supported on PLATFORM_ANDROID or PLATFORM_WEB or PLATFORM_RPI
|
||||
endif
|
||||
|
||||
# compile [core] example - storage values
|
||||
core_storage_values: core_storage_values.c
|
||||
ifeq ($(PLATFORM), $(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_RPI))
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
else
|
||||
@echo core_storage_values: Example not supported on PLATFORM_ANDROID or PLATFORM_WEB
|
||||
endif
|
||||
|
||||
# compile [core] example - gestures detection
|
||||
core_gestures_detection: core_gestures_detection.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [core] example - 3d mode
|
||||
core_3d_mode: core_3d_mode.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
@@ -258,6 +288,18 @@ core_3d_camera_free: core_3d_camera_free.c
|
||||
core_3d_camera_first_person: core_3d_camera_first_person.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [core] example - 2d camera
|
||||
core_2d_camera: core_2d_camera.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [core] example - world screen
|
||||
core_world_screen: core_world_screen.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [core] example - oculus rift
|
||||
core_oculus_rift: core_oculus_rift.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [shapes] example - raylib logo (with basic shapes)
|
||||
shapes_logo_raylib: shapes_logo_raylib.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
@@ -306,10 +348,22 @@ textures_formats_loading: textures_formats_loading.c
|
||||
textures_particles_trail_blending: textures_particles_trail_blending.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [textures] example - texture image processing
|
||||
textures_image_processing: textures_image_processing.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [textures] example - texture image drawing
|
||||
textures_image_drawing: textures_image_drawing.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [text] example - sprite fonts loading
|
||||
text_sprite_fonts: text_sprite_fonts.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [text] example - bmfonts and ttf loading
|
||||
text_bmfont_ttf: text_bmfont_ttf.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [text] example - raylib bitmap fonts (rBMF)
|
||||
text_rbmf_fonts: text_rbmf_fonts.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
@@ -322,6 +376,10 @@ text_format_text: text_format_text.c
|
||||
text_font_select: text_font_select.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [text] example - text writing animation
|
||||
text_writing_anim: text_writing_anim.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [models] example - basic geometric 3d shapes
|
||||
models_geometric_shapes: models_geometric_shapes.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
@@ -366,6 +424,10 @@ shaders_custom_uniform: shaders_custom_uniform.c
|
||||
shaders_postprocessing: shaders_postprocessing.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [shaders] example - standard lighting
|
||||
shaders_standard_lighting: shaders_standard_lighting.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [audio] example - sound loading and playing (WAV and OGG)
|
||||
audio_sound_loading: audio_sound_loading.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
@@ -374,6 +436,10 @@ audio_sound_loading: audio_sound_loading.c
|
||||
audio_music_stream: audio_music_stream.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# compile [audio] example - module playing (OGG)
|
||||
audio_module_playing: audio_module_playing.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||
|
||||
# fix dylib install path name for each executable (MAC)
|
||||
fix_dylib:
|
||||
ifeq ($(PLATFORM_OS),OSX)
|
138
examples/audio_module_playing.c
Normal file
@@ -0,0 +1,138 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* Copyright (c) 2016 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define MAX_CIRCLES 64
|
||||
|
||||
typedef struct {
|
||||
Vector2 position;
|
||||
float radius;
|
||||
float alpha;
|
||||
float speed;
|
||||
Color color;
|
||||
} CircleWave;
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)");
|
||||
|
||||
InitAudioDevice(); // Initialize audio device
|
||||
|
||||
Color colors[14] = { ORANGE, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK,
|
||||
YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE };
|
||||
|
||||
// Creates ome circles for visual effect
|
||||
CircleWave circles[MAX_CIRCLES];
|
||||
|
||||
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
|
||||
{
|
||||
circles[i].alpha = 0.0f;
|
||||
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].color = colors[GetRandomValue(0, 13)];
|
||||
}
|
||||
|
||||
// Load postprocessing bloom shader
|
||||
Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
|
||||
"resources/shaders/glsl330/bloom.fs");
|
||||
|
||||
// Create a RenderTexture2D to be used for render to texture
|
||||
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
|
||||
|
||||
PlayMusicStream(0, "resources/audio/2t2m_spa.xm"); // Play module stream
|
||||
|
||||
float timePlayed = 0.0f;
|
||||
|
||||
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
|
||||
//----------------------------------------------------------------------------------
|
||||
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
|
||||
{
|
||||
circles[i].alpha += circles[i].speed;
|
||||
circles[i].radius += circles[i].speed*10.0f;
|
||||
|
||||
if (circles[i].alpha > 1.0f) circles[i].speed *= -1;
|
||||
|
||||
if (circles[i].alpha <= 0.0f)
|
||||
{
|
||||
circles[i].alpha = 0.0f;
|
||||
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].color = colors[GetRandomValue(0, 13)];
|
||||
circles[i].speed = (float)GetRandomValue(1, 100)/20000.0f;
|
||||
}
|
||||
}
|
||||
|
||||
// Get timePlayed scaled to bar dimensions
|
||||
timePlayed = (GetMusicTimePlayed(0)/GetMusicTimeLength(0)*(screenWidth - 40))*2;
|
||||
|
||||
UpdateMusicStream(0); // Update music buffer with new stream data
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(BLACK);
|
||||
|
||||
BeginTextureMode(target); // Enable drawing to texture
|
||||
|
||||
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
|
||||
{
|
||||
DrawCircleV(circles[i].position, circles[i].radius, Fade(circles[i].color, circles[i].alpha));
|
||||
}
|
||||
|
||||
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
|
||||
|
||||
BeginShaderMode(shader);
|
||||
|
||||
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
||||
DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
||||
|
||||
EndShaderMode();
|
||||
|
||||
// Draw time bar
|
||||
DrawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, LIGHTGRAY);
|
||||
DrawRectangle(20, screenHeight - 20 - 12, (int)timePlayed, 12, MAROON);
|
||||
DrawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, WHITE);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadShader(shader); // Unload shader
|
||||
UnloadRenderTexture(target); // Unload render texture
|
||||
|
||||
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/audio_module_playing.png
Normal file
After Width: | Height: | Size: 210 KiB |
@@ -24,10 +24,10 @@ int main()
|
||||
|
||||
InitAudioDevice(); // Initialize audio device
|
||||
|
||||
PlayMusicStream("resources/audio/guitar_noodling.ogg"); // Play music stream
|
||||
PlayMusicStream(0, "resources/audio/guitar_noodling.ogg"); // Play music stream
|
||||
|
||||
int framesCounter = 0;
|
||||
float timePlayed = 0;
|
||||
float timePlayed = 0.0f;
|
||||
//float volume = 1.0;
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
@@ -52,18 +52,18 @@ int main()
|
||||
{
|
||||
volume = 1.0;
|
||||
framesCounter = 0;
|
||||
PlayMusicStream("resources/audio/another_file.ogg");
|
||||
PlayMusicStream(1, "resources/audio/another_file.ogg");
|
||||
}
|
||||
|
||||
SetMusicVolume(volume);
|
||||
}
|
||||
*/
|
||||
if (IsWindowMinimized()) PauseMusicStream();
|
||||
else ResumeMusicStream();
|
||||
if (IsWindowMinimized()) PauseMusicStream(0);
|
||||
else ResumeMusicStream(0);
|
||||
|
||||
timePlayed = GetMusicTimePlayed()/GetMusicTimeLength()*100*4; // We scale by 4 to fit 400 pixels
|
||||
timePlayed = GetMusicTimePlayed(0)/GetMusicTimeLength(0)*100*4; // We scale by 4 to fit 400 pixels
|
||||
|
||||
UpdateMusicStream(); // Update music buffer with new stream data
|
||||
UpdateMusicStream(0); // Update music buffer with new stream data
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
@@ -26,6 +26,8 @@ int main()
|
||||
|
||||
Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file
|
||||
Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
|
74
examples/audio_standalone.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [audio] example - Using audio module as standalone module
|
||||
*
|
||||
* NOTE: This example does not require any graphic device, it can run directly on console.
|
||||
*
|
||||
* [audio] module requires some external libs:
|
||||
* OpenAL Soft - Audio device management lib (http://kcat.strangesoft.net/openal.html)
|
||||
* stb_vorbis - Ogg audio files loading (http://www.nothings.org/stb_vorbis/)
|
||||
* jar_xm - XM module file loading
|
||||
* jar_mod - MOD audio file loading
|
||||
*
|
||||
* Compile audio module using:
|
||||
* gcc -c audio.c stb_vorbis.c -Wall -std=c99 -DAUDIO_STANDALONE
|
||||
*
|
||||
* Compile example using:
|
||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) audio.o stb_vorbis.o -lopenal32 -std=c99
|
||||
*
|
||||
* This example has been created using raylib 1.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <conio.h> // Windows only, no stardard library
|
||||
|
||||
#include "audio.h"
|
||||
|
||||
#define KEY_ESCAPE 27
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned char key;
|
||||
|
||||
InitAudioDevice();
|
||||
|
||||
Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file
|
||||
Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file
|
||||
|
||||
PlayMusicStream(0, "resources/audio/guitar_noodling.ogg");
|
||||
|
||||
printf("\nPress s or d to play sounds...\n");
|
||||
|
||||
while (key != KEY_ESCAPE)
|
||||
{
|
||||
if (kbhit()) key = getch();
|
||||
|
||||
if (key == 's')
|
||||
{
|
||||
PlaySound(fxWav);
|
||||
key = 0;
|
||||
}
|
||||
|
||||
if (key == 'd')
|
||||
{
|
||||
PlaySound(fxOgg);
|
||||
key = 0;
|
||||
}
|
||||
|
||||
UpdateMusicStream(0);
|
||||
}
|
||||
|
||||
UnloadSound(fxWav); // Unload sound data
|
||||
UnloadSound(fxOgg); // Unload sound data
|
||||
|
||||
CloseAudioDevice();
|
||||
|
||||
printf("\n\nPress ENTER to close...");
|
||||
getchar();
|
||||
|
||||
return 0;
|
||||
}
|
139
examples/core_2d_camera.c
Normal file
@@ -0,0 +1,139 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - 2d camera
|
||||
*
|
||||
* This example has been created using raylib 1.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2016 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define MAX_BUILDINGS 100
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera");
|
||||
|
||||
Rectangle player = { 400, 280, 40, 40 };
|
||||
Rectangle buildings[MAX_BUILDINGS];
|
||||
Color buildColors[MAX_BUILDINGS];
|
||||
|
||||
int spacing = 0;
|
||||
|
||||
for (int i = 0; i < MAX_BUILDINGS; i++)
|
||||
{
|
||||
buildings[i].width = GetRandomValue(50, 200);
|
||||
buildings[i].height = GetRandomValue(100, 800);
|
||||
buildings[i].y = screenHeight - 130 - buildings[i].height;
|
||||
buildings[i].x = -6000 + spacing;
|
||||
|
||||
spacing += buildings[i].width;
|
||||
|
||||
buildColors[i] = (Color){ GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255 };
|
||||
}
|
||||
|
||||
Camera2D camera;
|
||||
|
||||
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
||||
camera.offset = (Vector2){ 0, 0 };
|
||||
camera.rotation = 0.0f;
|
||||
camera.zoom = 1.0f;
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// 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
|
||||
}
|
||||
|
||||
// Camera target follows player
|
||||
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
||||
|
||||
// Camera rotation controls
|
||||
if (IsKeyDown(KEY_A)) camera.rotation--;
|
||||
else if (IsKeyDown(KEY_S)) camera.rotation++;
|
||||
|
||||
// Limit camera rotation to 80 degrees (-40 to 40)
|
||||
if (camera.rotation > 40) camera.rotation = 40;
|
||||
else if (camera.rotation < -40) camera.rotation = -40;
|
||||
|
||||
// Camera zoom controls
|
||||
camera.zoom += ((float)GetMouseWheelMove()*0.05f);
|
||||
|
||||
if (camera.zoom > 3.0f) camera.zoom = 3.0f;
|
||||
else if (camera.zoom < 0.1f) camera.zoom = 0.1f;
|
||||
|
||||
// Camera reset (zoom and rotation)
|
||||
if (IsKeyPressed(KEY_R))
|
||||
{
|
||||
camera.zoom = 1.0f;
|
||||
camera.rotation = 0.0f;
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin2dMode(camera);
|
||||
|
||||
DrawRectangle(-6000, 320, 13000, 8000, DARKGRAY);
|
||||
|
||||
for (int i = 0; i < MAX_BUILDINGS; i++) DrawRectangleRec(buildings[i], buildColors[i]);
|
||||
|
||||
DrawRectangleRec(player, RED);
|
||||
|
||||
DrawRectangle(camera.target.x, -500, 1, screenHeight*4, GREEN);
|
||||
DrawRectangle(-500, camera.target.y, screenWidth*4, 1, GREEN);
|
||||
|
||||
End2dMode();
|
||||
|
||||
DrawText("SCREEN AREA", 640, 10, 20, RED);
|
||||
|
||||
DrawRectangle(0, 0, screenWidth, 5, RED);
|
||||
DrawRectangle(0, 5, 5, screenHeight - 10, RED);
|
||||
DrawRectangle(screenWidth - 5, 5, 5, screenHeight - 10, RED);
|
||||
DrawRectangle(0, screenHeight - 5, screenWidth, 5, RED);
|
||||
|
||||
DrawRectangle( 10, 10, 250, 113, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines( 10, 10, 250, 113, BLUE);
|
||||
|
||||
DrawText("Free 2d camera controls:", 20, 20, 10, BLACK);
|
||||
DrawText("- Right/Left to move Offset", 40, 40, 10, DARKGRAY);
|
||||
DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, DARKGRAY);
|
||||
DrawText("- A / S to Rotate", 40, 80, 10, DARKGRAY);
|
||||
DrawText("- R to reset Zoom and Rotation", 40, 100, 10, DARKGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/core_2d_camera.png
Normal file
After Width: | Height: | Size: 21 KiB |
@@ -22,8 +22,8 @@ int main()
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
// Define the camera to look into our 3d world (position, target, up vector)
|
||||
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 60.0f };
|
||||
|
||||
// Generates some random columns
|
||||
float heights[MAX_COLUMNS];
|
||||
@@ -37,9 +37,10 @@ int main()
|
||||
colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
|
||||
}
|
||||
|
||||
Vector3 playerPosition = { 4, 2, 4 }; // Define player position
|
||||
Vector3 playerPosition = { 4.0f, 2.0f, 4.0f }; // Define player position
|
||||
|
||||
SetCameraMode(CAMERA_FIRST_PERSON); // Set a first person camera mode
|
||||
SetCameraFovy(camera.fovy); // Set internal camera field-of-view Y
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -60,23 +61,26 @@ int main()
|
||||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 32, 32 }, LIGHTGRAY); // Draw ground
|
||||
DrawCube((Vector3){ -16, 2.5, 0 }, 1, 5, 32, BLUE); // Draw a blue wall
|
||||
DrawCube((Vector3){ 16, 2.5, 0 }, 1, 5, 32, LIME); // Draw a green wall
|
||||
DrawCube((Vector3){ 0, 2.5, 16 }, 32, 5, 1, GOLD); // Draw a yellow wall
|
||||
DrawPlane((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector2){ 32.0f, 32.0f }, LIGHTGRAY); // Draw ground
|
||||
DrawCube((Vector3){ -16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, BLUE); // Draw a blue wall
|
||||
DrawCube((Vector3){ 16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, LIME); // Draw a green wall
|
||||
DrawCube((Vector3){ 0.0f, 2.5f, 16.0f }, 32.0f, 5.0f, 1.0f, GOLD); // Draw a yellow wall
|
||||
|
||||
// Draw some cubes around
|
||||
for (int i = 0; i < MAX_COLUMNS; i++)
|
||||
{
|
||||
DrawCube(positions[i], 2, heights[i], 2, colors[i]);
|
||||
DrawCubeWires(positions[i], 2, heights[i], 2, MAROON);
|
||||
DrawCube(positions[i], 2.0f, heights[i], 2.0f, colors[i]);
|
||||
DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, MAROON);
|
||||
}
|
||||
|
||||
End3dMode();
|
||||
|
||||
DrawText("First person camera default controls:", 20, 20, 10, GRAY);
|
||||
DrawText("- Move with keys: W, A, S, D", 40, 50, 10, DARKGRAY);
|
||||
DrawText("- Mouse move to look around", 40, 70, 10, DARKGRAY);
|
||||
DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines( 10, 10, 220, 70, BLUE);
|
||||
|
||||
DrawText("First person camera default controls:", 20, 20, 10, BLACK);
|
||||
DrawText("- Move with keys: W, A, S, D", 40, 40, 10, DARKGRAY);
|
||||
DrawText("- Mouse move to look around", 40, 60, 10, DARKGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 17 KiB |
@@ -21,13 +21,18 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
Camera camera;
|
||||
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
|
||||
Vector3 cubePosition = { 0.0, 0.0, 0.0 };
|
||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
SetCameraMode(CAMERA_FREE); // Set a free camera mode
|
||||
SetCameraPosition(camera.position); // Set internal camera position to match our camera position
|
||||
SetCameraTarget(camera.target); // Set internal camera target to match our camera target
|
||||
SetCameraFovy(camera.fovy); // Set internal camera field-of-view Y
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -44,23 +49,26 @@ int main()
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(WHITE);
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawCube(cubePosition, 2, 2, 2, RED);
|
||||
DrawCubeWires(cubePosition, 2, 2, 2, MAROON);
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
||||
|
||||
DrawGrid(10.0, 1.0);
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
End3dMode();
|
||||
|
||||
DrawText("Free camera default controls:", 20, 20, 10, GRAY);
|
||||
DrawText("- Mouse Wheel to Zoom in-out", 40, 50, 10, DARKGRAY);
|
||||
DrawText("- Mouse Wheel Pressed to Pan", 40, 70, 10, DARKGRAY);
|
||||
DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 90, 10, DARKGRAY);
|
||||
DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 110, 10, DARKGRAY);
|
||||
DrawText("- Z to zoom to (0, 0, 0)", 40, 130, 10, DARKGRAY);
|
||||
DrawRectangle( 10, 10, 320, 133, Fade(SKYBLUE, 0.5f));
|
||||
DrawRectangleLines( 10, 10, 320, 133, BLUE);
|
||||
|
||||
DrawText("Free camera default controls:", 20, 20, 10, BLACK);
|
||||
DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, DARKGRAY);
|
||||
DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, DARKGRAY);
|
||||
DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 80, 10, DARKGRAY);
|
||||
DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 100, 10, DARKGRAY);
|
||||
DrawText("- Z to zoom to (0, 0, 0)", 40, 120, 10, DARKGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 25 KiB |
@@ -21,11 +21,15 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
Camera camera;
|
||||
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
|
||||
Vector3 cubePosition = { 0.0, 0.0, 0.0 };
|
||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
//SetTargetFPS(60); // Set our game to run at 60 frames-per-second, but not now...
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
@@ -40,14 +44,14 @@ int main()
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(WHITE);
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawCube(cubePosition, 2, 2, 2, RED);
|
||||
DrawCubeWires(cubePosition, 2, 2, 2, MAROON);
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
||||
|
||||
DrawGrid(10.0, 1.0);
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
End3dMode();
|
||||
|
||||
|
@@ -21,14 +21,22 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
Camera camera;
|
||||
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
|
||||
Vector3 cubePosition = { 0.0, 1.0, 0.0 };
|
||||
Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
|
||||
Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
|
||||
|
||||
Ray ray; // Picking line ray
|
||||
|
||||
bool collision = false;
|
||||
|
||||
SetCameraMode(CAMERA_FREE); // Set a free camera mode
|
||||
SetCameraPosition(camera.position); // Set internal camera position to match our camera position
|
||||
SetCameraFovy(camera.fovy); // Set internal camera field-of-view Y
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -45,7 +53,10 @@ int main()
|
||||
// NOTE: This function is NOT WORKING properly!
|
||||
ray = GetMouseRay(GetMousePosition(), camera);
|
||||
|
||||
// TODO: Check collision between ray and box
|
||||
// Check collision between ray and box
|
||||
collision = CheckCollisionRayBox(ray,
|
||||
(BoundingBox){(Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 },
|
||||
(Vector3){ cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2, cubePosition.z + cubeSize.z/2 }});
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
@@ -57,16 +68,28 @@ int main()
|
||||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawCube(cubePosition, 2, 2, 2, GRAY);
|
||||
DrawCubeWires(cubePosition, 2, 2, 2, DARKGRAY);
|
||||
if (collision)
|
||||
{
|
||||
DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, RED);
|
||||
DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, MAROON);
|
||||
|
||||
DrawGrid(10.0, 1.0);
|
||||
DrawCubeWires(cubePosition, cubeSize.x + 0.2f, cubeSize.y + 0.2f, cubeSize.z + 0.2f, GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY);
|
||||
DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY);
|
||||
}
|
||||
|
||||
DrawRay(ray, MAROON);
|
||||
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
End3dMode();
|
||||
|
||||
DrawText("Try selecting the box with mouse!", 240, 10, 20, GRAY);
|
||||
DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY);
|
||||
|
||||
if(collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, screenHeight * 0.1f, 30, GREEN);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 24 KiB |
@@ -29,6 +29,8 @@ int main()
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
|
@@ -16,7 +16,7 @@ int main()
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 400;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - color selection (collision detection)");
|
||||
|
||||
@@ -30,7 +30,7 @@ int main()
|
||||
for (int i = 0; i < 21; i++)
|
||||
{
|
||||
colorsRecs[i].x = 20 + 100*(i%7) + 10*(i%7);
|
||||
colorsRecs[i].y = 40 + 100*(i/7) + 10*(i/7);
|
||||
colorsRecs[i].y = 60 + 100*(i/7) + 10*(i/7);
|
||||
colorsRecs[i].width = 100;
|
||||
colorsRecs[i].height = 100;
|
||||
}
|
||||
|
115
examples/core_gestures_detection.c
Normal file
@@ -0,0 +1,115 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - Gestures Detection
|
||||
*
|
||||
* This example has been created using raylib 1.4 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2016 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
#include <string.h>
|
||||
|
||||
#define MAX_GESTURE_STRINGS 20
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - gestures detection");
|
||||
|
||||
Vector2 touchPosition = { 0, 0 };
|
||||
Rectangle touchArea = { 220, 10, screenWidth - 230, screenHeight - 20 };
|
||||
|
||||
int gesturesCount = 0;
|
||||
char gestureStrings[MAX_GESTURE_STRINGS][32];
|
||||
|
||||
int currentGesture = GESTURE_NONE;
|
||||
int lastGesture = GESTURE_NONE;
|
||||
|
||||
//SetGesturesEnabled(0b0000000000001001); // Enable only some gestures to be detected
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
lastGesture = currentGesture;
|
||||
currentGesture = GetGestureDetected();
|
||||
touchPosition = GetTouchPosition(0);
|
||||
|
||||
if (CheckCollisionPointRec(touchPosition, touchArea) && (currentGesture != GESTURE_NONE))
|
||||
{
|
||||
if (currentGesture != lastGesture)
|
||||
{
|
||||
// Store gesture string
|
||||
switch (currentGesture)
|
||||
{
|
||||
case GESTURE_TAP: strcpy(gestureStrings[gesturesCount], "GESTURE TAP"); break;
|
||||
case GESTURE_DOUBLETAP: strcpy(gestureStrings[gesturesCount], "GESTURE DOUBLETAP"); break;
|
||||
case GESTURE_HOLD: strcpy(gestureStrings[gesturesCount], "GESTURE HOLD"); break;
|
||||
case GESTURE_DRAG: strcpy(gestureStrings[gesturesCount], "GESTURE DRAG"); break;
|
||||
case GESTURE_SWIPE_RIGHT: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE RIGHT"); break;
|
||||
case GESTURE_SWIPE_LEFT: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE LEFT"); break;
|
||||
case GESTURE_SWIPE_UP: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE UP"); break;
|
||||
case GESTURE_SWIPE_DOWN: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE DOWN"); break;
|
||||
case GESTURE_PINCH_IN: strcpy(gestureStrings[gesturesCount], "GESTURE PINCH IN"); break;
|
||||
case GESTURE_PINCH_OUT: strcpy(gestureStrings[gesturesCount], "GESTURE PINCH OUT"); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
gesturesCount++;
|
||||
|
||||
// Reset gestures strings
|
||||
if (gesturesCount >= MAX_GESTURE_STRINGS)
|
||||
{
|
||||
for (int i = 0; i < MAX_GESTURE_STRINGS; i++) strcpy(gestureStrings[i], "\0");
|
||||
|
||||
gesturesCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawRectangleRec(touchArea, GRAY);
|
||||
DrawRectangle(225, 15, screenWidth - 240, screenHeight - 30, RAYWHITE);
|
||||
|
||||
DrawText("GESTURES TEST AREA", screenWidth - 270, screenHeight - 40, 20, Fade(GRAY, 0.5f));
|
||||
|
||||
for (int i = 0; i < gesturesCount; i++)
|
||||
{
|
||||
if (i%2 == 0) DrawRectangle(10, 30 + 20*i, 200, 20, Fade(LIGHTGRAY, 0.5f));
|
||||
else DrawRectangle(10, 30 + 20*i, 200, 20, Fade(LIGHTGRAY, 0.3f));
|
||||
|
||||
if (i < gesturesCount - 1) DrawText(gestureStrings[i], 35, 36 + 20*i, 10, DARKGRAY);
|
||||
else DrawText(gestureStrings[i], 35, 36 + 20*i, 10, MAROON);
|
||||
}
|
||||
|
||||
DrawRectangleLines(10, 29, 200, screenHeight - 50, GRAY);
|
||||
DrawText("DETECTED GESTURES", 50, 15, 10, GRAY);
|
||||
|
||||
if (currentGesture != GESTURE_NONE) DrawCircleV(touchPosition, 30, MAROON);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
}
|
BIN
examples/core_gestures_detection.png
Normal file
After Width: | Height: | Size: 19 KiB |
@@ -23,8 +23,8 @@ int main()
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
|
||||
|
||||
Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
|
||||
Vector2 gamepadMovement = { 0, 0 };
|
||||
Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 };
|
||||
Vector2 gamepadMovement = { 0.0f, 0.0f };
|
||||
|
||||
SetTargetFPS(60); // Set target frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -36,15 +36,16 @@ int main()
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsGamepadAvailable(GAMEPAD_PLAYER1))
|
||||
{
|
||||
gamepadMovement = GetGamepadMovement(GAMEPAD_PLAYER1);
|
||||
gamepadMovement.x = GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LEFT_X);
|
||||
gamepadMovement.y = GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LEFT_Y);
|
||||
|
||||
ballPosition.x += gamepadMovement.x;
|
||||
ballPosition.y -= gamepadMovement.y;
|
||||
|
||||
if (IsGamepadButtonPressed(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_A))
|
||||
{
|
||||
ballPosition.x = screenWidth/2;
|
||||
ballPosition.y = screenHeight/2;
|
||||
ballPosition.x = (float)screenWidth/2;
|
||||
ballPosition.y = (float)screenHeight/2;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@@ -20,7 +20,7 @@ int main()
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input");
|
||||
|
||||
Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
|
||||
Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 };
|
||||
|
||||
SetTargetFPS(60); // Set target frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -30,10 +30,10 @@ int main()
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 0.8;
|
||||
if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 0.8;
|
||||
if (IsKeyDown(KEY_UP)) ballPosition.y -= 0.8;
|
||||
if (IsKeyDown(KEY_DOWN)) ballPosition.y += 0.8;
|
||||
if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 0.8f;
|
||||
if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 0.8f;
|
||||
if (IsKeyDown(KEY_UP)) ballPosition.y -= 0.8f;
|
||||
if (IsKeyDown(KEY_DOWN)) ballPosition.y += 0.8f;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
@@ -20,8 +20,10 @@ int main()
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input");
|
||||
|
||||
int mouseX, mouseY;
|
||||
Vector2 ballPosition = { -100.0, -100.0 };
|
||||
Vector2 ballPosition = { -100.0f, -100.0f };
|
||||
Color ballColor = DARKBLUE;
|
||||
|
||||
SetTargetFPS(60);
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
@@ -29,14 +31,11 @@ int main()
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||
{
|
||||
mouseX = GetMouseX();
|
||||
mouseY = GetMouseY();
|
||||
ballPosition = GetMousePosition();
|
||||
|
||||
ballPosition.x = (float)mouseX;
|
||||
ballPosition.y = (float)mouseY;
|
||||
}
|
||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballColor = MAROON;
|
||||
else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) ballColor = LIME;
|
||||
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
@@ -45,9 +44,9 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawCircleV(ballPosition, 40, GOLD);
|
||||
DrawCircleV(ballPosition, 40, ballColor);
|
||||
|
||||
DrawText("mouse click to draw the ball", 10, 10, 20, DARKGRAY);
|
||||
DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 15 KiB |
82
examples/core_oculus_rift.c
Normal file
@@ -0,0 +1,82 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - Oculus Rift CV1
|
||||
*
|
||||
* Compile example using:
|
||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -L. -L..\src\external\OculusSDK\LibOVR -lLibOVRRT32_1 -lraylib -lglfw3 -lopengl32 -lgdi32 -std=c99
|
||||
*
|
||||
* This example has been created using raylib 1.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2016 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 1080;
|
||||
int screenHeight = 600;
|
||||
|
||||
// NOTE: screenWidth/screenHeight should match VR device aspect ratio
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - oculus rift");
|
||||
|
||||
// NOTE: If device is not available, it fallbacks to default device (simulator)
|
||||
InitVrDevice(HMD_OCULUS_RIFT_CV1); // Init VR device (Oculus Rift CV1)
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera;
|
||||
camera.position = (Vector3){ 5.0f, 5.0f, 5.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 60.0f; // Camera field-of-view Y
|
||||
|
||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
SetTargetFPS(90); // Set our game to run at 90 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateVrTracking();
|
||||
|
||||
if (IsKeyPressed(KEY_SPACE)) ToggleVrMode();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
||||
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
End3dMode();
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseVrDevice(); // Close VR device
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/core_oculus_rift.png
Normal file
After Width: | Height: | Size: 173 KiB |
85
examples/core_storage_values.c
Normal file
@@ -0,0 +1,85 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - Storage save/load values
|
||||
*
|
||||
* This example has been created using raylib 1.4 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
// NOTE: Storage positions must start with 0, directly related to file memory layout
|
||||
typedef enum { STORAGE_SCORE = 0, STORAGE_HISCORE } StorageData;
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - storage save/load values");
|
||||
|
||||
int score = 0;
|
||||
int hiscore = 0;
|
||||
|
||||
int framesCounter = 0;
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyPressed(KEY_R))
|
||||
{
|
||||
score = GetRandomValue(1000, 2000);
|
||||
hiscore = GetRandomValue(2000, 4000);
|
||||
}
|
||||
|
||||
if (IsKeyPressed(KEY_ENTER))
|
||||
{
|
||||
StorageSaveValue(STORAGE_SCORE, score);
|
||||
StorageSaveValue(STORAGE_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);
|
||||
}
|
||||
|
||||
framesCounter++;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText(FormatText("SCORE: %i", score), 280, 130, 40, MAROON);
|
||||
DrawText(FormatText("HI-SCORE: %i", hiscore), 210, 200, 50, BLACK);
|
||||
|
||||
DrawText(FormatText("frames: %i", framesCounter), 10, 10, 20, LIME);
|
||||
|
||||
DrawText("Press R to generate random numbers", 220, 40, 20, LIGHTGRAY);
|
||||
DrawText("Press ENTER to SAVE values", 250, 310, 20, LIGHTGRAY);
|
||||
DrawText("Press SPACE to LOAD values", 252, 350, 20, LIGHTGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/core_storage_values.png
Normal file
After Width: | Height: | Size: 16 KiB |
77
examples/core_world_screen.c
Normal file
@@ -0,0 +1,77 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - World to screen
|
||||
*
|
||||
* 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) 2015 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
|
||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
Vector2 cubeScreenPosition;
|
||||
|
||||
SetCameraMode(CAMERA_FREE); // Set a free camera mode
|
||||
SetCameraPosition(camera.position); // Set internal camera position to match our camera position
|
||||
SetCameraTarget(camera.target); // Set internal camera target to match our camera target
|
||||
SetCameraFovy(camera.fovy); // Set internal camera field-of-view Y
|
||||
|
||||
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); // Update internal camera and our camera
|
||||
|
||||
// Calculate cube screen space position (with a little offset to be in top)
|
||||
cubeScreenPosition = GetWorldToScreen((Vector3){cubePosition.x, cubePosition.y + 2.5f, cubePosition.z}, camera);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
||||
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
End3dMode();
|
||||
|
||||
DrawText("Enemy: 100 / 100", cubeScreenPosition.x - MeasureText("Enemy: 100 / 100", 20) / 2, cubeScreenPosition.y, 20, BLACK);
|
||||
DrawText("Text is always on top of the cube", (screenWidth - MeasureText("Text is always on top of the cube", 20)) / 2, 25, 20, GRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/core_world_screen.png
Normal file
After Width: | Height: | Size: 23 KiB |
@@ -21,14 +21,15 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 5.0, 4.0, 5.0 }, { 0.0, 2.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
Camera camera = {{ 5.0f, 4.0f, 5.0f }, { 0.0f, 2.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
|
||||
Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard
|
||||
Vector3 billPosition = { 0.0, 2.0, 0.0 }; // Position where draw billboard
|
||||
Vector3 billPosition = { 0.0f, 2.0f, 0.0f }; // Position where draw billboard
|
||||
|
||||
SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
|
||||
SetCameraPosition(camera.position); // Set internal camera position to match our camera position
|
||||
SetCameraTarget(camera.target); // Set internal camera target to match our camera target
|
||||
SetCameraFovy(camera.fovy); // Set internal camera field-of-view Y
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -51,7 +52,7 @@ int main()
|
||||
|
||||
DrawBillboard(camera, bill, billPosition, 2.0f, WHITE);
|
||||
|
||||
DrawGrid(10.0, 1.0); // Draw a grid
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
End3dMode();
|
||||
|
||||
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 54 KiB |
@@ -21,16 +21,16 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
|
||||
Vector3 playerPosition = { 0, 1, 2 };
|
||||
Vector3 playerSize = { 1, 2, 1 };
|
||||
Vector3 playerPosition = { 0.0f, 1.0f, 2.0f };
|
||||
Vector3 playerSize = { 1.0f, 2.0f, 1.0f };
|
||||
Color playerColor = GREEN;
|
||||
|
||||
Vector3 enemyBoxPos = { -4, 1, 0 };
|
||||
Vector3 enemyBoxSize = { 2, 2, 2 };
|
||||
Vector3 enemyBoxPos = { -4.0f, 1.0f, 0.0f };
|
||||
Vector3 enemyBoxSize = { 2.0f, 2.0f, 2.0f };
|
||||
|
||||
Vector3 enemySpherePos = { 4, 0, 0 };
|
||||
Vector3 enemySpherePos = { 4.0f, 0.0f, 0.0f };
|
||||
float enemySphereSize = 1.5f;
|
||||
|
||||
bool collision = false;
|
||||
@@ -53,26 +53,28 @@ int main()
|
||||
collision = false;
|
||||
|
||||
// Check collisions player vs enemy-box
|
||||
if (CheckCollisionBoxes((Vector3){ playerPosition.x - playerSize.x/2,
|
||||
if (CheckCollisionBoxes(
|
||||
(BoundingBox){(Vector3){ playerPosition.x - playerSize.x/2,
|
||||
playerPosition.y - playerSize.y/2,
|
||||
playerPosition.z - playerSize.z/2 },
|
||||
(Vector3){ playerPosition.x + playerSize.x/2,
|
||||
playerPosition.y + playerSize.y/2,
|
||||
playerPosition.z + playerSize.z/2 },
|
||||
(Vector3){ enemyBoxPos.x - enemyBoxSize.x/2,
|
||||
playerPosition.z + playerSize.z/2 }},
|
||||
(BoundingBox){(Vector3){ enemyBoxPos.x - enemyBoxSize.x/2,
|
||||
enemyBoxPos.y - enemyBoxSize.y/2,
|
||||
enemyBoxPos.z - enemyBoxSize.z/2 },
|
||||
(Vector3){ enemyBoxPos.x + enemyBoxSize.x/2,
|
||||
enemyBoxPos.y + enemyBoxSize.y/2,
|
||||
enemyBoxPos.z + enemyBoxSize.z/2 })) collision = true;
|
||||
enemyBoxPos.z + enemyBoxSize.z/2 }})) collision = true;
|
||||
|
||||
// Check collisions player vs enemy-sphere
|
||||
if (CheckCollisionBoxSphere((Vector3){ playerPosition.x - playerSize.x/2,
|
||||
if (CheckCollisionBoxSphere(
|
||||
(BoundingBox){(Vector3){ playerPosition.x - playerSize.x/2,
|
||||
playerPosition.y - playerSize.y/2,
|
||||
playerPosition.z - playerSize.z/2 },
|
||||
(Vector3){ playerPosition.x + playerSize.x/2,
|
||||
playerPosition.y + playerSize.y/2,
|
||||
playerPosition.z + playerSize.z/2 },
|
||||
playerPosition.z + playerSize.z/2 }},
|
||||
enemySpherePos, enemySphereSize)) collision = true;
|
||||
|
||||
if (collision) playerColor = RED;
|
||||
@@ -98,7 +100,7 @@ int main()
|
||||
// Draw player
|
||||
DrawCubeV(playerPosition, playerSize, playerColor);
|
||||
|
||||
DrawGrid(10.0, 1.0); // Draw a grid
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
End3dMode();
|
||||
|
||||
|
@@ -21,7 +21,7 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 16.0, 14.0, 16.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
Camera camera = {{ 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
|
||||
Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
|
||||
Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM)
|
||||
@@ -29,14 +29,15 @@ int main()
|
||||
|
||||
// NOTE: By default each cube is mapped to one part of texture atlas
|
||||
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture
|
||||
SetModelTexture(&map, texture); // Bind texture to map model
|
||||
map.material.texDiffuse = texture; // Set map diffuse texture
|
||||
|
||||
Vector3 mapPosition = { -16, 0.0, -8 }; // Set model position
|
||||
Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position
|
||||
|
||||
UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM
|
||||
|
||||
SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
|
||||
SetCameraPosition(camera.position); // Set internal camera position to match our custom camera position
|
||||
SetCameraFovy(camera.fovy); // Set internal camera field-of-view Y
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
@@ -21,7 +21,7 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -42,21 +42,21 @@ int main()
|
||||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawCube((Vector3){-4, 0, 2}, 2, 5, 2, RED);
|
||||
DrawCubeWires((Vector3){-4, 0, 2}, 2, 5, 2, GOLD);
|
||||
DrawCubeWires((Vector3){-4, 0, -2}, 3, 6, 2, MAROON);
|
||||
DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED);
|
||||
DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD);
|
||||
DrawCubeWires((Vector3){-4.0f, 0.0f, -2.0f}, 3.0f, 6.0f, 2.0f, MAROON);
|
||||
|
||||
DrawSphere((Vector3){-1, 0, -2}, 1, GREEN);
|
||||
DrawSphereWires((Vector3){1, 0, 2}, 2, 16, 16, LIME);
|
||||
DrawSphere((Vector3){-1.0f, 0.0f, -2.0f}, 1.0f, GREEN);
|
||||
DrawSphereWires((Vector3){1.0f, 0.0f, 2.0f}, 2.0f, 16, 16, LIME);
|
||||
|
||||
DrawCylinder((Vector3){4, 0, -2}, 1, 2, 3, 4, SKYBLUE);
|
||||
DrawCylinderWires((Vector3){4, 0, -2}, 1, 2, 3, 4, DARKBLUE);
|
||||
DrawCylinderWires((Vector3){4.5, -1, 2}, 1, 1, 2, 6, BROWN);
|
||||
DrawCylinder((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, SKYBLUE);
|
||||
DrawCylinderWires((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, DARKBLUE);
|
||||
DrawCylinderWires((Vector3){4.5f, -1.0f, 2.0f}, 1.0f, 1.0f, 2.0f, 6, BROWN);
|
||||
|
||||
DrawCylinder((Vector3){1, 0, -4}, 0, 1.5, 3, 8, GOLD);
|
||||
DrawCylinderWires((Vector3){1, 0, -4}, 0, 1.5, 3, 8, PINK);
|
||||
DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD);
|
||||
DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK);
|
||||
|
||||
DrawGrid(10.0, 1.0); // Draw a grid
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
End3dMode();
|
||||
|
||||
|
@@ -21,13 +21,13 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
|
||||
|
||||
// Define our custom camera to look into our 3d world
|
||||
Camera camera = {{ 24.0, 18.0, 24.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
Camera camera = {{ 18.0f, 16.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
|
||||
Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
|
||||
Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
|
||||
Model map = LoadHeightmap(image, 32); // Load heightmap model
|
||||
SetModelTexture(&map, texture); // Bind texture to model
|
||||
Vector3 mapPosition = { -16, 0.0, -16 }; // Set model position (depends on model scaling!)
|
||||
Model map = LoadHeightmap(image, (Vector3){ 16, 8, 16 }); // Load heightmap model with defined size
|
||||
map.material.texDiffuse = texture; // Set map diffuse texture
|
||||
Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Set model position (depends on model scaling!)
|
||||
|
||||
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
|
||||
|
||||
@@ -54,7 +54,9 @@ int main()
|
||||
Begin3dMode(camera);
|
||||
|
||||
// NOTE: Model is scaled to 1/4 of its original size (128x128 units)
|
||||
DrawModel(map, mapPosition, 1/4.0f, RED);
|
||||
DrawModel(map, mapPosition, 1.0f, RED);
|
||||
|
||||
DrawGrid(20, 1.0f);
|
||||
|
||||
End3dMode();
|
||||
|
||||
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 95 KiB |
@@ -21,12 +21,12 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 3.0, 3.0, 3.0 }, { 0.0, 1.5, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
|
||||
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
|
||||
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture
|
||||
SetModelTexture(&dwarf, texture); // Bind texture to model
|
||||
Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position
|
||||
dwarf.material.texDiffuse = texture; // Set dwarf model 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
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -49,7 +49,7 @@ int main()
|
||||
|
||||
DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
|
||||
|
||||
DrawGrid(10.0, 1.0); // Draw a grid
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
DrawGizmo(position); // Draw gizmo
|
||||
|
||||
|
128
examples/physics_basic_rigidbody.c
Normal file
@@ -0,0 +1,128 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [physac] example - Basic rigidbody
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
*
|
||||
* Compile example using:
|
||||
* cmd /c IF NOT EXIST pthreadGC2.dll copy C:\raylib\raylib\src\external\pthread\pthreadGC2.dll $(CURRENT_DIRECTORY) /Y
|
||||
*
|
||||
* Copyright (c) 2016 Victor Fisac and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define PHYSAC_IMPLEMENTATION
|
||||
#include "physac.h"
|
||||
|
||||
#define MOVE_VELOCITY 5
|
||||
#define JUMP_VELOCITY 30
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [physac] example - basic rigidbody");
|
||||
InitPhysics((Vector2){ 0.0f, -9.81f/2 }); // Initialize physics module
|
||||
|
||||
// Debug variables
|
||||
bool isDebug = false;
|
||||
|
||||
// Create rectangle physic object
|
||||
PhysicBody rectangle = CreatePhysicBody((Vector2){ screenWidth*0.25f, screenHeight/2 }, 0.0f, (Vector2){ 75, 50 });
|
||||
rectangle->rigidbody.enabled = true; // Enable physic object rigidbody behaviour
|
||||
rectangle->rigidbody.applyGravity = true;
|
||||
rectangle->rigidbody.friction = 0.1f;
|
||||
rectangle->rigidbody.bounciness = 6.0f;
|
||||
|
||||
// Create square physic object
|
||||
PhysicBody square = CreatePhysicBody((Vector2){ screenWidth*0.75f, screenHeight/2 }, 0.0f, (Vector2){ 50, 50 });
|
||||
square->rigidbody.enabled = true; // Enable physic object rigidbody behaviour
|
||||
square->rigidbody.applyGravity = true;
|
||||
square->rigidbody.friction = 0.1f;
|
||||
|
||||
// Create walls physic objects
|
||||
PhysicBody floor = CreatePhysicBody((Vector2){ screenWidth/2, screenHeight*0.95f }, 0.0f, (Vector2){ screenWidth*0.9f, 100 });
|
||||
PhysicBody leftWall = CreatePhysicBody((Vector2){ 0.0f, screenHeight/2 }, 0.0f, (Vector2){ screenWidth*0.1f, screenHeight });
|
||||
PhysicBody rightWall = CreatePhysicBody((Vector2){ screenWidth, screenHeight/2 }, 0.0f, (Vector2){ screenWidth*0.1f, screenHeight });
|
||||
PhysicBody roof = CreatePhysicBody((Vector2){ screenWidth/2, screenHeight*0.05f }, 0.0f, (Vector2){ screenWidth*0.9f, 100 });
|
||||
|
||||
// Create pplatform physic object
|
||||
PhysicBody platform = CreatePhysicBody((Vector2){ screenWidth/2, screenHeight*0.7f }, 0.0f, (Vector2){ screenWidth*0.25f, 20 });
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Check rectangle movement inputs
|
||||
if (IsKeyPressed('W')) rectangle->rigidbody.velocity.y = JUMP_VELOCITY;
|
||||
if (IsKeyDown('A')) rectangle->rigidbody.velocity.x = -MOVE_VELOCITY;
|
||||
else if (IsKeyDown('D')) rectangle->rigidbody.velocity.x = MOVE_VELOCITY;
|
||||
|
||||
// Check square movement inputs
|
||||
if (IsKeyDown(KEY_UP) && square->rigidbody.isGrounded) square->rigidbody.velocity.y = JUMP_VELOCITY;
|
||||
if (IsKeyDown(KEY_LEFT)) square->rigidbody.velocity.x = -MOVE_VELOCITY;
|
||||
else if (IsKeyDown(KEY_RIGHT)) square->rigidbody.velocity.x = MOVE_VELOCITY;
|
||||
|
||||
// Check debug switch input
|
||||
if (IsKeyPressed('P')) isDebug = !isDebug;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
// Draw floor, roof and walls rectangles
|
||||
DrawRectangleRec(TransformToRectangle(floor->transform), DARKGRAY); // Convert transform values to rectangle data type variable
|
||||
DrawRectangleRec(TransformToRectangle(leftWall->transform), DARKGRAY);
|
||||
DrawRectangleRec(TransformToRectangle(rightWall->transform), DARKGRAY);
|
||||
DrawRectangleRec(TransformToRectangle(roof->transform), DARKGRAY);
|
||||
|
||||
// Draw middle platform rectangle
|
||||
DrawRectangleRec(TransformToRectangle(platform->transform), DARKGRAY);
|
||||
|
||||
// Draw physic objects
|
||||
DrawRectangleRec(TransformToRectangle(rectangle->transform), RED);
|
||||
DrawRectangleRec(TransformToRectangle(square->transform), BLUE);
|
||||
|
||||
// Draw collider lines if debug is enabled
|
||||
if (isDebug)
|
||||
{
|
||||
DrawRectangleLines(floor->collider.bounds.x, floor->collider.bounds.y, floor->collider.bounds.width, floor->collider.bounds.height, GREEN);
|
||||
DrawRectangleLines(leftWall->collider.bounds.x, leftWall->collider.bounds.y, leftWall->collider.bounds.width, leftWall->collider.bounds.height, GREEN);
|
||||
DrawRectangleLines(rightWall->collider.bounds.x, rightWall->collider.bounds.y, rightWall->collider.bounds.width, rightWall->collider.bounds.height, GREEN);
|
||||
DrawRectangleLines(roof->collider.bounds.x, roof->collider.bounds.y, roof->collider.bounds.width, roof->collider.bounds.height, GREEN);
|
||||
DrawRectangleLines(platform->collider.bounds.x, platform->collider.bounds.y, platform->collider.bounds.width, platform->collider.bounds.height, GREEN);
|
||||
DrawRectangleLines(rectangle->collider.bounds.x, rectangle->collider.bounds.y, rectangle->collider.bounds.width, rectangle->collider.bounds.height, GREEN);
|
||||
DrawRectangleLines(square->collider.bounds.x, square->collider.bounds.y, square->collider.bounds.width, square->collider.bounds.height, GREEN);
|
||||
}
|
||||
|
||||
// Draw help message
|
||||
DrawText("Use WASD to move rectangle and ARROWS to move square", screenWidth/2 - MeasureText("Use WASD to move rectangle and ARROWS to move square", 20)/2, screenHeight*0.075f, 20, LIGHTGRAY);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
ClosePhysics(); // Unitialize physics (including all loaded objects)
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/physics_basic_rigidbody.png
Normal file
After Width: | Height: | Size: 15 KiB |
187
examples/physics_forces.c
Normal file
@@ -0,0 +1,187 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [physac] example - Forces
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* NOTE: This example requires raylib module [rlgl]
|
||||
*
|
||||
* Compile example using:
|
||||
* cmd /c IF NOT EXIST pthreadGC2.dll copy C:\raylib\raylib\src\external\pthread\pthreadGC2.dll $(CURRENT_DIRECTORY) /Y
|
||||
*
|
||||
* Copyright (c) 2016 Victor Fisac and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define PHYSAC_IMPLEMENTATION
|
||||
#include "physac.h"
|
||||
|
||||
#define FORCE_AMOUNT 5.0f
|
||||
#define FORCE_RADIUS 150
|
||||
#define LINE_LENGTH 75
|
||||
#define TRIANGLE_LENGTH 12
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [physac] example - forces");
|
||||
InitPhysics((Vector2){ 0.0f, -9.81f/2 }); // Initialize physics module
|
||||
|
||||
// Global variables
|
||||
Vector2 mousePosition;
|
||||
bool isDebug = false;
|
||||
|
||||
// Create rectangle physic objects
|
||||
PhysicBody rectangles[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
rectangles[i] = CreatePhysicBody((Vector2){ screenWidth/4*(i+1), (((i % 2) == 0) ? (screenHeight/3) : (screenHeight/1.5f)) }, 0.0f, (Vector2){ 50, 50 });
|
||||
rectangles[i]->rigidbody.enabled = true; // Enable physic object rigidbody behaviour
|
||||
rectangles[i]->rigidbody.friction = 0.1f;
|
||||
}
|
||||
|
||||
// Create circles physic objects
|
||||
// NOTE: when creating circle physic objects, transform.scale must be { 0, 0 } and object radius must be defined in collider.radius and use this value to draw the circle.
|
||||
PhysicBody circles[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
circles[i] = CreatePhysicBody((Vector2){ screenWidth/4*(i+1), (((i % 2) == 0) ? (screenHeight/1.5f) : (screenHeight/4)) }, 0.0f, (Vector2){ 0, 0 });
|
||||
circles[i]->rigidbody.enabled = true; // Enable physic object rigidbody behaviour
|
||||
circles[i]->rigidbody.friction = 0.1f;
|
||||
circles[i]->collider.type = COLLIDER_CIRCLE;
|
||||
circles[i]->collider.radius = 25;
|
||||
}
|
||||
|
||||
// Create walls physic objects
|
||||
PhysicBody leftWall = CreatePhysicBody((Vector2){ -25, screenHeight/2 }, 0.0f, (Vector2){ 50, screenHeight });
|
||||
PhysicBody rightWall = CreatePhysicBody((Vector2){ screenWidth + 25, screenHeight/2 }, 0.0f, (Vector2){ 50, screenHeight });
|
||||
PhysicBody topWall = CreatePhysicBody((Vector2){ screenWidth/2, -25 }, 0.0f, (Vector2){ screenWidth, 50 });
|
||||
PhysicBody bottomWall = CreatePhysicBody((Vector2){ screenWidth/2, screenHeight + 25 }, 0.0f, (Vector2){ screenWidth, 50 });
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Update mouse position value
|
||||
mousePosition = GetMousePosition();
|
||||
|
||||
// Check force input
|
||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ApplyForceAtPosition(mousePosition, FORCE_AMOUNT, FORCE_RADIUS);
|
||||
|
||||
// Check reset input
|
||||
if (IsKeyPressed('R'))
|
||||
{
|
||||
// Reset rectangle physic objects positions
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
rectangles[i]->transform.position = (Vector2){ screenWidth/4*(i+1) - rectangles[i]->transform.scale.x/2, (((i % 2) == 0) ? (screenHeight/3) : (screenHeight/1.5f)) - rectangles[i]->transform.scale.y/2 };
|
||||
rectangles[i]->rigidbody.velocity =(Vector2){ 0.0f, 0.0f };
|
||||
}
|
||||
|
||||
// Reset circles physic objects positions
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
circles[i]->transform.position = (Vector2){ screenWidth/4*(i+1), (((i % 2) == 0) ? (screenHeight/1.5f) : (screenHeight/4)) };
|
||||
circles[i]->rigidbody.velocity =(Vector2){ 0.0f, 0.0f };
|
||||
}
|
||||
}
|
||||
|
||||
// Check debug switch input
|
||||
if (IsKeyPressed('P')) isDebug = !isDebug;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
// Draw rectangles
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
// Convert transform values to rectangle data type variable
|
||||
DrawRectangleRec(TransformToRectangle(rectangles[i]->transform), RED);
|
||||
if (isDebug) DrawRectangleLines(rectangles[i]->collider.bounds.x, rectangles[i]->collider.bounds.y, rectangles[i]->collider.bounds.width, rectangles[i]->collider.bounds.height, GREEN);
|
||||
|
||||
// Draw force radius
|
||||
DrawCircleLines(mousePosition.x, mousePosition.y, FORCE_RADIUS, BLACK);
|
||||
|
||||
// Draw direction lines
|
||||
if (CheckCollisionPointCircle((Vector2){ rectangles[i]->transform.position.x + rectangles[i]->transform.scale.x/2, rectangles[i]->transform.position.y + rectangles[i]->transform.scale.y/2 }, mousePosition, FORCE_RADIUS))
|
||||
{
|
||||
Vector2 direction = { rectangles[i]->transform.position.x + rectangles[i]->transform.scale.x/2 - mousePosition.x, rectangles[i]->transform.position.y + rectangles[i]->transform.scale.y/2 - mousePosition.y };
|
||||
float angle = atan2l(direction.y, direction.x);
|
||||
|
||||
// Calculate arrow start and end positions
|
||||
Vector2 startPosition = { rectangles[i]->transform.position.x + rectangles[i]->transform.scale.x/2, rectangles[i]->transform.position.y + rectangles[i]->transform.scale.y/2 };
|
||||
Vector2 endPosition = { rectangles[i]->transform.position.x + rectangles[i]->transform.scale.x/2 + (cos(angle)*LINE_LENGTH), rectangles[i]->transform.position.y + rectangles[i]->transform.scale.y/2 + (sin(angle)*LINE_LENGTH) };
|
||||
|
||||
// Draw arrow line
|
||||
DrawLineV(startPosition, endPosition, BLACK);
|
||||
|
||||
// Draw arrow triangle
|
||||
DrawTriangleLines((Vector2){ endPosition.x - cos(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH, endPosition.y - sin(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH },
|
||||
(Vector2){ endPosition.x + cos(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH, endPosition.y + sin(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH },
|
||||
(Vector2){ endPosition.x + cos(angle)*LINE_LENGTH/TRIANGLE_LENGTH*2, endPosition.y + sin(angle)*LINE_LENGTH/TRIANGLE_LENGTH*2 }, BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw circles
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
DrawCircleV(circles[i]->transform.position, circles[i]->collider.radius, BLUE);
|
||||
if (isDebug) DrawCircleLines(circles[i]->transform.position.x, circles[i]->transform.position.y, circles[i]->collider.radius, GREEN);
|
||||
|
||||
// Draw force radius
|
||||
DrawCircleLines(mousePosition.x, mousePosition.y, FORCE_RADIUS, BLACK);
|
||||
|
||||
// Draw direction lines
|
||||
if (CheckCollisionPointCircle((Vector2){ circles[i]->transform.position.x, circles[i]->transform.position.y }, mousePosition, FORCE_RADIUS))
|
||||
{
|
||||
Vector2 direction = { circles[i]->transform.position.x - mousePosition.x, circles[i]->transform.position.y - mousePosition.y };
|
||||
float angle = atan2l(direction.y, direction.x);
|
||||
|
||||
// Calculate arrow start and end positions
|
||||
Vector2 startPosition = { circles[i]->transform.position.x, circles[i]->transform.position.y };
|
||||
Vector2 endPosition = { circles[i]->transform.position.x + (cos(angle)*LINE_LENGTH), circles[i]->transform.position.y + (sin(angle)*LINE_LENGTH) };
|
||||
|
||||
// Draw arrow line
|
||||
DrawLineV(startPosition, endPosition, BLACK);
|
||||
|
||||
// Draw arrow triangle
|
||||
DrawTriangleLines((Vector2){ endPosition.x - cos(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH, endPosition.y - sin(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH },
|
||||
(Vector2){ endPosition.x + cos(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH, endPosition.y + sin(angle + 90*DEG2RAD)*LINE_LENGTH/TRIANGLE_LENGTH },
|
||||
(Vector2){ endPosition.x + cos(angle)*LINE_LENGTH/TRIANGLE_LENGTH*2, endPosition.y + sin(angle)*LINE_LENGTH/TRIANGLE_LENGTH*2 }, BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw help messages
|
||||
DrawText("Use LEFT MOUSE BUTTON to apply a force", screenWidth/2 - MeasureText("Use LEFT MOUSE BUTTON to apply a force", 20)/2, screenHeight*0.075f, 20, LIGHTGRAY);
|
||||
DrawText("Use R to reset objects position", screenWidth/2 - MeasureText("Use R to reset objects position", 20)/2, screenHeight*0.875f, 20, GRAY);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
ClosePhysics(); // Unitialize physics module
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/physics_forces.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
examples/resources/audio/2t2m_spa.xm
Normal file
BIN
examples/resources/cat.png
Normal file
After Width: | Height: | Size: 379 KiB |
99
examples/resources/fonts/bmfont.fnt
Normal file
@@ -0,0 +1,99 @@
|
||||
info face="Arial Black" size=-32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2 outline=0
|
||||
common lineHeight=45 base=35 scaleW=512 scaleH=256 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4
|
||||
page id=0 file="bmfont.png"
|
||||
chars count=95
|
||||
char id=32 x=423 y=141 width=3 height=45 xoffset=-1 yoffset=0 xadvance=11 page=0 chnl=15
|
||||
char id=33 x=323 y=141 width=9 height=45 xoffset=1 yoffset=0 xadvance=11 page=0 chnl=15
|
||||
char id=34 x=123 y=141 width=16 height=45 xoffset=0 yoffset=0 xadvance=16 page=0 chnl=15
|
||||
char id=35 x=221 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=36 x=244 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=37 x=70 y=0 width=30 height=45 xoffset=1 yoffset=0 xadvance=32 page=0 chnl=15
|
||||
char id=38 x=390 y=0 width=25 height=45 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=15
|
||||
char id=39 x=378 y=141 width=8 height=45 xoffset=1 yoffset=0 xadvance=9 page=0 chnl=15
|
||||
char id=40 x=222 y=141 width=11 height=45 xoffset=1 yoffset=0 xadvance=12 page=0 chnl=15
|
||||
char id=41 x=499 y=94 width=11 height=45 xoffset=1 yoffset=0 xadvance=12 page=0 chnl=15
|
||||
char id=42 x=497 y=47 width=13 height=45 xoffset=2 yoffset=0 xadvance=18 page=0 chnl=15
|
||||
char id=43 x=394 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=44 x=367 y=141 width=9 height=45 xoffset=1 yoffset=0 xadvance=11 page=0 chnl=15
|
||||
char id=45 x=261 y=141 width=11 height=45 xoffset=0 yoffset=0 xadvance=11 page=0 chnl=15
|
||||
char id=46 x=356 y=141 width=9 height=45 xoffset=1 yoffset=0 xadvance=11 page=0 chnl=15
|
||||
char id=47 x=248 y=141 width=11 height=45 xoffset=-1 yoffset=0 xadvance=9 page=0 chnl=15
|
||||
char id=48 x=382 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=49 x=496 y=0 width=14 height=45 xoffset=2 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=50 x=134 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=51 x=359 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=52 x=313 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=53 x=336 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=54 x=178 y=94 width=20 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=55 x=478 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=56 x=290 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=57 x=90 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=58 x=345 y=141 width=9 height=45 xoffset=1 yoffset=0 xadvance=11 page=0 chnl=15
|
||||
char id=59 x=334 y=141 width=9 height=45 xoffset=1 yoffset=0 xadvance=11 page=0 chnl=15
|
||||
char id=60 x=0 y=141 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=61 x=21 y=141 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=62 x=310 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=63 x=352 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=20 page=0 chnl=15
|
||||
char id=64 x=279 y=0 width=26 height=45 xoffset=-1 yoffset=0 xadvance=24 page=0 chnl=15
|
||||
char id=65 x=193 y=0 width=27 height=45 xoffset=-1 yoffset=0 xadvance=25 page=0 chnl=15
|
||||
char id=66 x=150 y=47 width=22 height=45 xoffset=2 yoffset=0 xadvance=25 page=0 chnl=15
|
||||
char id=67 x=444 y=0 width=24 height=45 xoffset=1 yoffset=0 xadvance=25 page=0 chnl=15
|
||||
char id=68 x=174 y=47 width=22 height=45 xoffset=2 yoffset=0 xadvance=25 page=0 chnl=15
|
||||
char id=69 x=156 y=94 width=20 height=45 xoffset=2 yoffset=0 xadvance=23 page=0 chnl=15
|
||||
char id=70 x=63 y=141 width=18 height=45 xoffset=2 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=71 x=417 y=0 width=25 height=45 xoffset=1 yoffset=0 xadvance=27 page=0 chnl=15
|
||||
char id=72 x=125 y=47 width=23 height=45 xoffset=2 yoffset=0 xadvance=27 page=0 chnl=15
|
||||
char id=73 x=388 y=141 width=8 height=45 xoffset=2 yoffset=0 xadvance=12 page=0 chnl=15
|
||||
char id=74 x=200 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=75 x=251 y=0 width=26 height=45 xoffset=2 yoffset=0 xadvance=27 page=0 chnl=15
|
||||
char id=76 x=373 y=94 width=19 height=45 xoffset=2 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=77 x=134 y=0 width=28 height=45 xoffset=1 yoffset=0 xadvance=30 page=0 chnl=15
|
||||
char id=78 x=100 y=47 width=23 height=45 xoffset=2 yoffset=0 xadvance=27 page=0 chnl=15
|
||||
char id=79 x=363 y=0 width=25 height=45 xoffset=1 yoffset=0 xadvance=27 page=0 chnl=15
|
||||
char id=80 x=112 y=94 width=20 height=45 xoffset=2 yoffset=0 xadvance=23 page=0 chnl=15
|
||||
char id=81 x=335 y=0 width=26 height=45 xoffset=1 yoffset=0 xadvance=27 page=0 chnl=15
|
||||
char id=82 x=470 y=0 width=24 height=45 xoffset=2 yoffset=0 xadvance=25 page=0 chnl=15
|
||||
char id=83 x=75 y=47 width=23 height=45 xoffset=0 yoffset=0 xadvance=23 page=0 chnl=15
|
||||
char id=84 x=50 y=47 width=23 height=45 xoffset=0 yoffset=0 xadvance=23 page=0 chnl=15
|
||||
char id=85 x=25 y=47 width=23 height=45 xoffset=2 yoffset=0 xadvance=27 page=0 chnl=15
|
||||
char id=86 x=307 y=0 width=26 height=45 xoffset=0 yoffset=0 xadvance=25 page=0 chnl=15
|
||||
char id=87 x=0 y=0 width=34 height=45 xoffset=-1 yoffset=0 xadvance=32 page=0 chnl=15
|
||||
char id=88 x=222 y=0 width=27 height=45 xoffset=-1 yoffset=0 xadvance=25 page=0 chnl=15
|
||||
char id=89 x=164 y=0 width=27 height=45 xoffset=-1 yoffset=0 xadvance=25 page=0 chnl=15
|
||||
char id=90 x=0 y=47 width=23 height=45 xoffset=0 yoffset=0 xadvance=23 page=0 chnl=15
|
||||
char id=91 x=274 y=141 width=11 height=45 xoffset=1 yoffset=0 xadvance=12 page=0 chnl=15
|
||||
char id=92 x=300 y=141 width=10 height=45 xoffset=-1 yoffset=0 xadvance=9 page=0 chnl=15
|
||||
char id=93 x=287 y=141 width=11 height=45 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
|
||||
char id=94 x=457 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=95 x=103 y=141 width=18 height=45 xoffset=-1 yoffset=0 xadvance=16 page=0 chnl=15
|
||||
char id=96 x=312 y=141 width=9 height=45 xoffset=0 yoffset=0 xadvance=11 page=0 chnl=15
|
||||
char id=97 x=474 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=98 x=68 y=94 width=20 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=99 x=267 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=100 x=46 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=101 x=198 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=102 x=141 y=141 width=15 height=45 xoffset=-1 yoffset=0 xadvance=12 page=0 chnl=15
|
||||
char id=103 x=222 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=104 x=415 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=105 x=398 y=141 width=7 height=45 xoffset=2 yoffset=0 xadvance=11 page=0 chnl=15
|
||||
char id=106 x=235 y=141 width=11 height=45 xoffset=-2 yoffset=0 xadvance=11 page=0 chnl=15
|
||||
char id=107 x=405 y=47 width=21 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=108 x=407 y=141 width=7 height=45 xoffset=2 yoffset=0 xadvance=11 page=0 chnl=15
|
||||
char id=109 x=102 y=0 width=30 height=45 xoffset=1 yoffset=0 xadvance=32 page=0 chnl=15
|
||||
char id=110 x=331 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=111 x=428 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=112 x=266 y=94 width=20 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=113 x=288 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=114 x=158 y=141 width=15 height=45 xoffset=1 yoffset=0 xadvance=14 page=0 chnl=15
|
||||
char id=115 x=244 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=20 page=0 chnl=15
|
||||
char id=116 x=175 y=141 width=14 height=45 xoffset=0 yoffset=0 xadvance=14 page=0 chnl=15
|
||||
char id=117 x=436 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=118 x=451 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=20 page=0 chnl=15
|
||||
char id=119 x=36 y=0 width=32 height=45 xoffset=-1 yoffset=0 xadvance=30 page=0 chnl=15
|
||||
char id=120 x=0 y=94 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15
|
||||
char id=121 x=23 y=94 width=21 height=45 xoffset=0 yoffset=0 xadvance=20 page=0 chnl=15
|
||||
char id=122 x=83 y=141 width=18 height=45 xoffset=0 yoffset=0 xadvance=18 page=0 chnl=15
|
||||
char id=123 x=191 y=141 width=14 height=45 xoffset=-1 yoffset=0 xadvance=12 page=0 chnl=15
|
||||
char id=124 x=416 y=141 width=5 height=45 xoffset=2 yoffset=0 xadvance=9 page=0 chnl=15
|
||||
char id=125 x=207 y=141 width=13 height=45 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
|
||||
char id=126 x=42 y=141 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15
|
BIN
examples/resources/fonts/bmfont.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
examples/resources/fonts/pixantiqua.ttf
Normal file
BIN
examples/resources/model/dwarf_normal.png
Normal file
After Width: | Height: | Size: 3.9 MiB |
BIN
examples/resources/model/dwarf_specular.png
Normal file
After Width: | Height: | Size: 2.8 MiB |
BIN
examples/resources/parrots.png
Normal file
After Width: | Height: | Size: 288 KiB |
@@ -1,19 +0,0 @@
|
||||
#version 330
|
||||
|
||||
in vec3 vertexPosition;
|
||||
in vec2 vertexTexCoord;
|
||||
in vec3 vertexNormal;
|
||||
|
||||
out vec2 fragTexCoord;
|
||||
|
||||
uniform mat4 projectionMatrix;
|
||||
uniform mat4 modelviewMatrix;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
fragTexCoord = vertexTexCoord;
|
||||
|
||||
gl_Position = projectionMatrix*modelviewMatrix*vec4(vertexPosition, 1.0);
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
#version 330
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 sum = vec4(0);
|
||||
vec4 tc = vec4(0);
|
||||
|
||||
for (int i = -4; i < 4; i++)
|
||||
{
|
||||
for (int j = -3; j < 3; j++)
|
||||
{
|
||||
sum += texture2D(texture0, fragTexCoord + vec2(j, i)*0.004) * 0.25;
|
||||
}
|
||||
}
|
||||
|
||||
if (texture2D(texture0, fragTexCoord).r < 0.3)
|
||||
{
|
||||
tc = sum*sum*0.012 + texture2D(texture0, fragTexCoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (texture2D(texture0, fragTexCoord).r < 0.5)
|
||||
{
|
||||
tc = sum*sum*0.009 + texture2D(texture0, fragTexCoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
tc = sum*sum*0.0075 + texture2D(texture0, fragTexCoord);
|
||||
}
|
||||
}
|
||||
|
||||
fragColor = tc;
|
||||
}
|
26
examples/resources/shaders/glsl100/base.vs
Normal file
@@ -0,0 +1,26 @@
|
||||
#version 100
|
||||
|
||||
// Input vertex attributes
|
||||
attribute vec3 vertexPosition;
|
||||
attribute vec2 vertexTexCoord;
|
||||
attribute vec3 vertexNormal;
|
||||
attribute vec4 vertexColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform mat4 mvpMatrix;
|
||||
|
||||
// Output vertex attributes (to fragment shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
// Send vertex attributes to fragment shader
|
||||
fragTexCoord = vertexTexCoord;
|
||||
fragColor = vertexColor;
|
||||
|
||||
// Calculate final vertex position
|
||||
gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
|
||||
}
|
37
examples/resources/shaders/glsl100/bloom.fs
Normal file
@@ -0,0 +1,37 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 sum = vec4(0);
|
||||
vec4 tc = vec4(0);
|
||||
|
||||
for (int i = -4; i < 4; i++)
|
||||
{
|
||||
for (int j = -3; j < 3; j++)
|
||||
{
|
||||
sum += texture2D(texture0, fragTexCoord + vec2(j, i)*0.004) * 0.25;
|
||||
}
|
||||
}
|
||||
|
||||
// Texel color fetching from texture sampler
|
||||
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
||||
|
||||
// Calculate final fragment color
|
||||
if (texelColor.r < 0.3) tc = sum*sum*0.012 + texelColor;
|
||||
else if (texelColor.r < 0.5) tc = sum*sum*0.009 + texelColor;
|
||||
else tc = sum*sum*0.0075 + texelColor;
|
||||
|
||||
gl_FragColor = tc;
|
||||
}
|
54
examples/resources/shaders/glsl100/distortion.fs
Normal file
@@ -0,0 +1,54 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
|
||||
// NOTE: Default parameters for Oculus Rift DK2 device
|
||||
const vec2 LeftLensCenter = vec2(0.2863248, 0.5);
|
||||
const vec2 RightLensCenter = vec2(0.7136753, 0.5);
|
||||
const vec2 LeftScreenCenter = vec2(0.25, 0.5);
|
||||
const vec2 RightScreenCenter = vec2(0.75, 0.5);
|
||||
const vec2 Scale = vec2(0.25, 0.45);
|
||||
const vec2 ScaleIn = vec2(4.0, 2.5);
|
||||
const vec4 HmdWarpParam = vec4(1.0, 0.22, 0.24, 0.0);
|
||||
const vec4 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0);
|
||||
|
||||
void main()
|
||||
{
|
||||
// The following two variables need to be set per eye
|
||||
vec2 LensCenter = fragTexCoord.x < 0.5 ? LeftLensCenter : RightLensCenter;
|
||||
vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter;
|
||||
|
||||
// Scales input texture coordinates for distortion: vec2 HmdWarp(vec2 fragTexCoord, vec2 LensCenter)
|
||||
vec2 theta = (fragTexCoord - LensCenter)*ScaleIn; // Scales to [-1, 1]
|
||||
float rSq = theta.x*theta.x + theta.y*theta.y;
|
||||
vec2 theta1 = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq);
|
||||
//vec2 tc = LensCenter + Scale*theta1;
|
||||
|
||||
// Detect whether blue texture coordinates are out of range since these will scaled out the furthest
|
||||
vec2 thetaBlue = theta1*(ChromaAbParam.z + ChromaAbParam.w*rSq);
|
||||
vec2 tcBlue = LensCenter + Scale*thetaBlue;
|
||||
|
||||
if (any(bvec2(clamp(tcBlue, ScreenCenter - vec2(0.25, 0.5), ScreenCenter + vec2(0.25, 0.5)) - tcBlue))) gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
else
|
||||
{
|
||||
// Do blue texture lookup
|
||||
float blue = texture2D(texture0, tcBlue).b;
|
||||
|
||||
// Do green lookup (no scaling)
|
||||
vec2 tcGreen = LensCenter + Scale*theta1;
|
||||
float green = texture2D(texture0, tcGreen).g;
|
||||
|
||||
// Do red scale and lookup
|
||||
vec2 thetaRed = theta1*(ChromaAbParam.x + ChromaAbParam.y*rSq);
|
||||
vec2 tcRed = LensCenter + Scale*thetaRed;
|
||||
float red = texture2D(texture0, tcRed).r;
|
||||
|
||||
gl_FragColor = vec4(red, green, blue, 1.0);
|
||||
}
|
||||
}
|
25
examples/resources/shaders/glsl100/grayscale.fs
Normal file
@@ -0,0 +1,25 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
// Texel color fetching from texture sampler
|
||||
vec4 texelColor = texture2D(texture0, fragTexCoord)*colDiffuse*fragColor;
|
||||
|
||||
// Convert texel color to grayscale using NTSC conversion weights
|
||||
float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114));
|
||||
|
||||
// Calculate final fragment color
|
||||
gl_FragColor = vec4(gray, gray, gray, texelColor.a);
|
||||
}
|
45
examples/resources/shaders/glsl100/swirl.fs
Normal file
@@ -0,0 +1,45 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
const float renderWidth = 800.0; // HARDCODED for example!
|
||||
const float renderHeight = 480.0; // Use uniforms instead...
|
||||
|
||||
float radius = 250.0;
|
||||
float angle = 0.8;
|
||||
|
||||
uniform vec2 center;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 texSize = vec2(renderWidth, renderHeight);
|
||||
vec2 tc = fragTexCoord*texSize;
|
||||
tc -= center;
|
||||
|
||||
float dist = length(tc);
|
||||
|
||||
if (dist < radius)
|
||||
{
|
||||
float percent = (radius - dist)/radius;
|
||||
float theta = percent*percent*angle*8.0;
|
||||
float s = sin(theta);
|
||||
float c = cos(theta);
|
||||
|
||||
tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c)));
|
||||
}
|
||||
|
||||
tc += center;
|
||||
vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;;
|
||||
|
||||
gl_FragColor = vec4(color.rgb, 1.0);;
|
||||
}
|
26
examples/resources/shaders/glsl330/base.vs
Normal file
@@ -0,0 +1,26 @@
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes
|
||||
in vec3 vertexPosition;
|
||||
in vec2 vertexTexCoord;
|
||||
in vec3 vertexNormal;
|
||||
in vec4 vertexColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform mat4 mvpMatrix;
|
||||
|
||||
// Output vertex attributes (to fragment shader)
|
||||
out vec2 fragTexCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
// Send vertex attributes to fragment shader
|
||||
fragTexCoord = vertexTexCoord;
|
||||
fragColor = vertexColor;
|
||||
|
||||
// Calculate final vertex position
|
||||
gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
|
||||
}
|
38
examples/resources/shaders/glsl330/bloom.fs
Normal file
@@ -0,0 +1,38 @@
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec2 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 sum = vec4(0);
|
||||
vec4 tc = vec4(0);
|
||||
|
||||
for (int i = -4; i < 4; i++)
|
||||
{
|
||||
for (int j = -3; j < 3; j++)
|
||||
{
|
||||
sum += texture(texture0, fragTexCoord + vec2(j, i)*0.004)*0.25;
|
||||
}
|
||||
}
|
||||
|
||||
// Texel color fetching from texture sampler
|
||||
vec4 texelColor = texture(texture0, fragTexCoord);
|
||||
|
||||
// Calculate final fragment color
|
||||
if (texelColor.r < 0.3) tc = sum*sum*0.012 + texelColor;
|
||||
else if (texelColor.r < 0.5) tc = sum*sum*0.009 + texelColor;
|
||||
else tc = sum*sum*0.0075 + texelColor;
|
||||
|
||||
finalColor = tc;
|
||||
}
|
27
examples/resources/shaders/glsl330/depth.fs
Normal file
@@ -0,0 +1,27 @@
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec2 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0; // Depth texture
|
||||
uniform vec4 fragTintColor;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
float zNear = 0.01; // camera z near
|
||||
float zFar = 10.0; // camera z far
|
||||
float z = texture(texture0, fragTexCoord).x;
|
||||
|
||||
// Linearize depth value
|
||||
float depth = (2.0*zNear)/(zFar + zNear - z*(zFar - zNear));
|
||||
|
||||
// Calculate final fragment color
|
||||
finalColor = vec4(depth, depth, depth, 1.0f);
|
||||
}
|
56
examples/resources/shaders/glsl330/distortion.fs
Normal file
@@ -0,0 +1,56 @@
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
||||
// NOTE: Default parameters for Oculus Rift DK2 device
|
||||
const vec2 LeftLensCenter = vec2(0.2863248, 0.5);
|
||||
const vec2 RightLensCenter = vec2(0.7136753, 0.5);
|
||||
const vec2 LeftScreenCenter = vec2(0.25, 0.5);
|
||||
const vec2 RightScreenCenter = vec2(0.75, 0.5);
|
||||
const vec2 Scale = vec2(0.25, 0.45);
|
||||
const vec2 ScaleIn = vec2(4.0, 2.5);
|
||||
const vec4 HmdWarpParam = vec4(1.0, 0.22, 0.24, 0.0);
|
||||
const vec4 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0);
|
||||
|
||||
void main()
|
||||
{
|
||||
// The following two variables need to be set per eye
|
||||
vec2 LensCenter = fragTexCoord.x < 0.5 ? LeftLensCenter : RightLensCenter;
|
||||
vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter;
|
||||
|
||||
// Scales input texture coordinates for distortion: vec2 HmdWarp(vec2 fragTexCoord, vec2 LensCenter)
|
||||
vec2 theta = (fragTexCoord - LensCenter)*ScaleIn; // Scales to [-1, 1]
|
||||
float rSq = theta.x*theta.x + theta.y*theta.y;
|
||||
vec2 theta1 = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq);
|
||||
//vec2 tc = LensCenter + Scale*theta1;
|
||||
|
||||
// Detect whether blue texture coordinates are out of range since these will scaled out the furthest
|
||||
vec2 thetaBlue = theta1*(ChromaAbParam.z + ChromaAbParam.w*rSq);
|
||||
vec2 tcBlue = LensCenter + Scale*thetaBlue;
|
||||
|
||||
if (any(bvec2(clamp(tcBlue, ScreenCenter - vec2(0.25, 0.5), ScreenCenter + vec2(0.25, 0.5)) - tcBlue))) finalColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
else
|
||||
{
|
||||
// Do blue texture lookup
|
||||
float blue = texture(texture0, tcBlue).b;
|
||||
|
||||
// Do green lookup (no scaling)
|
||||
vec2 tcGreen = LensCenter + Scale*theta1;
|
||||
float green = texture(texture0, tcGreen).g;
|
||||
|
||||
// Do red scale and lookup
|
||||
vec2 thetaRed = theta1*(ChromaAbParam.x + ChromaAbParam.y*rSq);
|
||||
vec2 tcRed = LensCenter + Scale*thetaRed;
|
||||
float red = texture(texture0, tcRed).r;
|
||||
|
||||
finalColor = vec4(red, green, blue, 1.0);
|
||||
}
|
||||
}
|
||||
|
26
examples/resources/shaders/glsl330/grayscale.fs
Normal file
@@ -0,0 +1,26 @@
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec2 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
// Texel color fetching from texture sampler
|
||||
vec4 texelColor = texture(texture0, fragTexCoord)*colDiffuse*fragColor;
|
||||
|
||||
// Convert texel color to grayscale using NTSC conversion weights
|
||||
float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114));
|
||||
|
||||
// Calculate final fragment color
|
||||
finalColor = vec4(gray, gray, gray, texelColor.a);
|
||||
}
|
@@ -1,27 +1,32 @@
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec2 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
const float renderWidth = 1280;
|
||||
const float renderHeight = 720;
|
||||
const float renderWidth = 800.0; // HARDCODED for example!
|
||||
const float renderHeight = 480.0; // Use uniforms instead...
|
||||
|
||||
float radius = 250.0;
|
||||
float angle = 0.8;
|
||||
|
||||
uniform vec2 center = vec2(200, 200);
|
||||
uniform vec2 center = vec2(200.0, 200.0);
|
||||
|
||||
void main (void)
|
||||
void main()
|
||||
{
|
||||
vec2 texSize = vec2(renderWidth, renderHeight);
|
||||
vec2 tc = fragTexCoord*texSize;
|
||||
tc -= center;
|
||||
|
||||
float dist = length(tc);
|
||||
|
||||
if (dist < radius)
|
||||
@@ -35,7 +40,7 @@ void main (void)
|
||||
}
|
||||
|
||||
tc += center;
|
||||
vec3 color = texture2D(texture0, tc/texSize).rgb;
|
||||
vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;;
|
||||
|
||||
fragColor = vec4(color, 1.0);;
|
||||
finalColor = vec4(color.rgb, 1.0);;
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
#version 330
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 tintColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 base = texture2D(texture0, fragTexCoord)*tintColor;
|
||||
|
||||
// Convert to grayscale using NTSC conversion weights
|
||||
float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114));
|
||||
|
||||
fragColor = vec4(gray, gray, gray, tintColor.a);
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
#version 110
|
||||
|
||||
attribute vec3 vertexPosition;
|
||||
attribute vec2 vertexTexCoord;
|
||||
attribute vec4 vertexColor;
|
||||
|
||||
uniform mat4 projectionMatrix;
|
||||
uniform mat4 modelviewMatrix;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
fragTexCoord = vertexTexCoord;
|
||||
fragColor = vertexColor;
|
||||
|
||||
gl_Position = projectionMatrix*modelviewMatrix*vec4(vertexPosition, 1.0);
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
#version 110
|
||||
|
||||
uniform sampler2D texture0;
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 base = texture2D(texture0, fragTexCoord)*fragColor;
|
||||
|
||||
// Convert to grayscale using NTSC conversion weights
|
||||
float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114));
|
||||
|
||||
gl_FragColor = vec4(gray, gray, gray, base.a);
|
||||
}
|
393
examples/rlgl_oculus_rift.c
Normal file
@@ -0,0 +1,393 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [rlgl] example - Oculus minimum sample
|
||||
*
|
||||
* NOTE: This example requires OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders but it can also be used.
|
||||
*
|
||||
* Compile rlgl module using:
|
||||
* gcc -c rlgl.c -Wall -std=c99 -DRLGL_STANDALONE -DRAYMATH_IMPLEMENTATION -DGRAPHICS_API_OPENGL_33 -DRLGL_OCULUS_SUPPORT
|
||||
*
|
||||
* NOTE 1: rlgl module requires the following header-only files:
|
||||
* external/glad.h - OpenGL extensions loader (stripped to only required extensions)
|
||||
* shader_standard.h - Standard shader for materials and lighting
|
||||
* shader_distortion.h - Distortion shader for VR
|
||||
* raymath.h - Vector and matrix math functions
|
||||
*
|
||||
* NOTE 2: rlgl requires LibOVR (Oculus PC SDK) to support Oculus Rift CV1
|
||||
*
|
||||
* Compile example using:
|
||||
* gcc -o rlgl_oculus_rift.exe rlgl_oculus_rift.c rlgl.o -L. -lLibOVRRT32_1 -lglfw3 -lopengl32 -lgdi32 -std=c99
|
||||
*
|
||||
* NOTE: Example must be linked against LibOVRRT32_1.dll that comes with Oculus Rift runtime.
|
||||
*
|
||||
* This example has been created using raylib 1.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <GLFW/glfw3.h> // Windows/Context and inputs management
|
||||
|
||||
#define RLGL_STANDALONE
|
||||
#include "rlgl.h" // rlgl library: OpenGL 1.1 immediate-mode style coding
|
||||
|
||||
#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
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module specific Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
static void ErrorCallback(int error, const char* description);
|
||||
static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||
|
||||
// Drawing functions (uses rlgl functionality)
|
||||
static void DrawGrid(int slices, float spacing);
|
||||
static void DrawCube(Vector3 position, float width, float height, float length, Color color);
|
||||
static void DrawCubeWires(Vector3 position, float width, float height, float length, Color color);
|
||||
static void DrawRectangleV(Vector2 position, Vector2 size, Color color);
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Main Entry point
|
||||
//----------------------------------------------------------------------------------
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 1080; // Mirror screen width (set to hmdDesc.Resolution.w/2)
|
||||
int screenHeight = 600; // Mirror screen height (set to hmdDesc.Resolution.h/2)
|
||||
|
||||
// NOTE: Mirror screen size can be set to any desired resolution!
|
||||
|
||||
// GLFW3 Initialization + OpenGL 3.3 Context + Extensions
|
||||
//--------------------------------------------------------
|
||||
glfwSetErrorCallback(ErrorCallback);
|
||||
|
||||
if (!glfwInit())
|
||||
{
|
||||
TraceLog(WARNING, "GLFW3: Can not initialize GLFW");
|
||||
return 1;
|
||||
}
|
||||
else TraceLog(INFO, "GLFW3: GLFW initialized successfully");
|
||||
|
||||
glfwWindowHint(GLFW_SAMPLES, 4);
|
||||
glfwWindowHint(GLFW_DEPTH_BITS, 16);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
|
||||
|
||||
GLFWwindow *window = glfwCreateWindow(screenWidth, screenHeight, "rlgl oculus rift", NULL, NULL);
|
||||
|
||||
if (!window)
|
||||
{
|
||||
glfwTerminate();
|
||||
return 2;
|
||||
}
|
||||
else TraceLog(INFO, "GLFW3: Window created successfully");
|
||||
|
||||
glfwSetKeyCallback(window, KeyCallback);
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval(0);
|
||||
|
||||
// Load OpenGL 3.3 supported extensions
|
||||
rlglLoadExtensions(glfwGetProcAddress);
|
||||
//--------------------------------------------------------
|
||||
|
||||
// Initialize OpenGL context (states and resources)
|
||||
rlglInit(screenWidth, screenHeight);
|
||||
|
||||
rlClearColor(245, 245, 245, 255); // Define clear color
|
||||
rlEnableDepthTest(); // Enable DEPTH_TEST for 3D
|
||||
|
||||
// Define custom camera to initialize projection and view matrices
|
||||
Camera camera;
|
||||
camera.position = (Vector3){ 5.0f, 5.0f, 5.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
|
||||
// Initialize viewport and internal projection/modelview matrices
|
||||
rlViewport(0, 0, screenWidth, screenHeight);
|
||||
rlMatrixMode(RL_PROJECTION); // Switch to PROJECTION matrix
|
||||
rlLoadIdentity(); // Reset current matrix (PROJECTION)
|
||||
|
||||
// Setup perspective projection
|
||||
float aspect = (float)screenWidth/(float)screenHeight;
|
||||
double top = 0.01*tan(camera.fovy*PI/360.0);
|
||||
double right = top*aspect;
|
||||
rlFrustum(-right, right, -top, top, 0.01, 1000.0);
|
||||
|
||||
rlMatrixMode(RL_MODELVIEW); // Switch back to MODELVIEW matrix
|
||||
rlLoadIdentity(); // Reset current matrix (MODELVIEW)
|
||||
|
||||
// Setup Camera view
|
||||
Matrix cameraView = MatrixLookAt(camera.position, camera.target, camera.up);
|
||||
rlMultMatrixf(MatrixToFloat(cameraView)); // Multiply MODELVIEW matrix by view matrix (camera)
|
||||
|
||||
InitOculusDevice(); // Initialize Oculus Rift CV1
|
||||
|
||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateOculusTracking();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginOculusDrawing();
|
||||
|
||||
rlClearScreenBuffers(); // Clear current framebuffer(s)
|
||||
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, RAYWHITE);
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
// NOTE: Internal buffers drawing (3D data)
|
||||
rlglDraw();
|
||||
|
||||
EndOculusDrawing();
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseOculusDevice(); // Close Oculus device and clear resources
|
||||
|
||||
rlglClose(); // Unload rlgl internal buffers and default shader/texture
|
||||
|
||||
glfwDestroyWindow(window); // Close window
|
||||
glfwTerminate(); // Free GLFW3 resources
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module specific Functions Definitions
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// GLFW3: Error callback
|
||||
static void ErrorCallback(int error, const char* description)
|
||||
{
|
||||
TraceLog(ERROR, description);
|
||||
}
|
||||
|
||||
// GLFW3: Keyboard callback
|
||||
static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||
{
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw rectangle using rlgl OpenGL 1.1 style coding (translated to OpenGL 3.3 internally)
|
||||
static void DrawRectangleV(Vector2 position, Vector2 size, Color color)
|
||||
{
|
||||
rlBegin(RL_TRIANGLES);
|
||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||
|
||||
rlVertex2i(position.x, position.y);
|
||||
rlVertex2i(position.x, position.y + size.y);
|
||||
rlVertex2i(position.x + size.x, position.y + size.y);
|
||||
|
||||
rlVertex2i(position.x, position.y);
|
||||
rlVertex2i(position.x + size.x, position.y + size.y);
|
||||
rlVertex2i(position.x + size.x, position.y);
|
||||
rlEnd();
|
||||
}
|
||||
|
||||
// Draw a grid centered at (0, 0, 0)
|
||||
static void DrawGrid(int slices, float spacing)
|
||||
{
|
||||
int halfSlices = slices / 2;
|
||||
|
||||
rlBegin(RL_LINES);
|
||||
for(int i = -halfSlices; i <= halfSlices; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
rlColor3f(0.5f, 0.5f, 0.5f);
|
||||
rlColor3f(0.5f, 0.5f, 0.5f);
|
||||
rlColor3f(0.5f, 0.5f, 0.5f);
|
||||
rlColor3f(0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
rlColor3f(0.75f, 0.75f, 0.75f);
|
||||
rlColor3f(0.75f, 0.75f, 0.75f);
|
||||
rlColor3f(0.75f, 0.75f, 0.75f);
|
||||
rlColor3f(0.75f, 0.75f, 0.75f);
|
||||
}
|
||||
|
||||
rlVertex3f((float)i*spacing, 0.0f, (float)-halfSlices*spacing);
|
||||
rlVertex3f((float)i*spacing, 0.0f, (float)halfSlices*spacing);
|
||||
|
||||
rlVertex3f((float)-halfSlices*spacing, 0.0f, (float)i*spacing);
|
||||
rlVertex3f((float)halfSlices*spacing, 0.0f, (float)i*spacing);
|
||||
}
|
||||
rlEnd();
|
||||
}
|
||||
|
||||
// Draw cube
|
||||
// NOTE: Cube position is the center position
|
||||
void DrawCube(Vector3 position, float width, float height, float length, Color color)
|
||||
{
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
float z = 0.0f;
|
||||
|
||||
rlPushMatrix();
|
||||
|
||||
// NOTE: Be careful! Function order matters (rotate -> scale -> translate)
|
||||
rlTranslatef(position.x, position.y, position.z);
|
||||
//rlScalef(2.0f, 2.0f, 2.0f);
|
||||
//rlRotatef(45, 0, 1, 0);
|
||||
|
||||
rlBegin(RL_TRIANGLES);
|
||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||
|
||||
// Front Face -----------------------------------------------------
|
||||
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
|
||||
// Back Face ------------------------------------------------------
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
||||
|
||||
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
|
||||
// Top Face -------------------------------------------------------
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Bottom Left
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Bottom Right
|
||||
|
||||
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Bottom Right
|
||||
|
||||
// Bottom Face ----------------------------------------------------
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
||||
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Top Right
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left
|
||||
|
||||
// Right face -----------------------------------------------------
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
||||
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Left
|
||||
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Left
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Left
|
||||
|
||||
// Left Face ------------------------------------------------------
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Right
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Right
|
||||
|
||||
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Right
|
||||
rlEnd();
|
||||
rlPopMatrix();
|
||||
}
|
||||
|
||||
// Draw cube wires
|
||||
void DrawCubeWires(Vector3 position, float width, float height, float length, Color color)
|
||||
{
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
float z = 0.0f;
|
||||
|
||||
rlPushMatrix();
|
||||
|
||||
rlTranslatef(position.x, position.y, position.z);
|
||||
//rlRotatef(45, 0, 1, 0);
|
||||
|
||||
rlBegin(RL_LINES);
|
||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||
|
||||
// Front Face -----------------------------------------------------
|
||||
// Bottom Line
|
||||
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
|
||||
// Left Line
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right
|
||||
|
||||
// Top Line
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
|
||||
// Right Line
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
||||
|
||||
// Back Face ------------------------------------------------------
|
||||
// Bottom Line
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
||||
|
||||
// Left Line
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
||||
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
||||
|
||||
// Top Line
|
||||
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
|
||||
// Right Line
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left
|
||||
|
||||
// Top Face -------------------------------------------------------
|
||||
// Left Line
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left Front
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left Back
|
||||
|
||||
// Right Line
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right Front
|
||||
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right Back
|
||||
|
||||
// Bottom Face ---------------------------------------------------
|
||||
// Left Line
|
||||
rlVertex3f(x-width/2, y-height/2, z+length/2); // Top Left Front
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left Back
|
||||
|
||||
// Right Line
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Top Right Front
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Top Right Back
|
||||
rlEnd();
|
||||
rlPopMatrix();
|
||||
}
|
395
examples/rlgl_standalone.c
Normal file
@@ -0,0 +1,395 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [rlgl] example - Using rlgl module as standalone module
|
||||
*
|
||||
* NOTE: This example requires OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders but it can also be used.
|
||||
*
|
||||
* Compile rlgl module using:
|
||||
* gcc -c rlgl.c -Wall -std=c99 -DRLGL_STANDALONE -DRAYMATH_IMPLEMENTATION -DGRAPHICS_API_OPENGL_33
|
||||
*
|
||||
* NOTE: rlgl module requires the following header-only files:
|
||||
* external/glad.h - OpenGL extensions loader (stripped to only required extensions)
|
||||
* shader_standard.h - Standard shader for materials and lighting
|
||||
* shader_distortion.h - Distortion shader for VR
|
||||
* raymath.h - Vector and matrix math functions
|
||||
*
|
||||
* Compile example using:
|
||||
* gcc -o rlgl_standalone.exe rlgl_standalone.c rlgl.o -lglfw3 -lopengl32 -lgdi32 -std=c99
|
||||
*
|
||||
* This example has been created using raylib 1.5 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include <GLFW/glfw3.h> // Windows/Context and inputs management
|
||||
|
||||
#define RLGL_STANDALONE
|
||||
#include "rlgl.h" // rlgl library: OpenGL 1.1 immediate-mode style coding
|
||||
|
||||
#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
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module specific Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
static void ErrorCallback(int error, const char* description);
|
||||
static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||
|
||||
// Drawing functions (uses rlgl functionality)
|
||||
static void DrawGrid(int slices, float spacing);
|
||||
static void DrawCube(Vector3 position, float width, float height, float length, Color color);
|
||||
static void DrawCubeWires(Vector3 position, float width, float height, float length, Color color);
|
||||
static void DrawRectangleV(Vector2 position, Vector2 size, Color color);
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Main Entry point
|
||||
//----------------------------------------------------------------------------------
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
// GLFW3 Initialization + OpenGL 3.3 Context + Extensions
|
||||
//--------------------------------------------------------
|
||||
glfwSetErrorCallback(ErrorCallback);
|
||||
|
||||
if (!glfwInit())
|
||||
{
|
||||
TraceLog(WARNING, "GLFW3: Can not initialize GLFW");
|
||||
return 1;
|
||||
}
|
||||
else TraceLog(INFO, "GLFW3: GLFW initialized successfully");
|
||||
|
||||
glfwWindowHint(GLFW_SAMPLES, 4);
|
||||
glfwWindowHint(GLFW_DEPTH_BITS, 16);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
|
||||
|
||||
GLFWwindow *window = glfwCreateWindow(screenWidth, screenHeight, "rlgl standalone", NULL, NULL);
|
||||
|
||||
if (!window)
|
||||
{
|
||||
glfwTerminate();
|
||||
return 2;
|
||||
}
|
||||
else TraceLog(INFO, "GLFW3: Window created successfully");
|
||||
|
||||
glfwSetWindowPos(window, 200, 200);
|
||||
|
||||
glfwSetKeyCallback(window, KeyCallback);
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
// Load OpenGL 3.3 supported extensions
|
||||
rlglLoadExtensions(glfwGetProcAddress);
|
||||
//--------------------------------------------------------
|
||||
|
||||
// Initialize OpenGL context (states and resources)
|
||||
rlglInit(screenWidth, screenHeight);
|
||||
|
||||
// Initialize viewport and internal projection/modelview matrices
|
||||
rlViewport(0, 0, screenWidth, screenHeight);
|
||||
rlMatrixMode(RL_PROJECTION); // Switch to PROJECTION matrix
|
||||
rlLoadIdentity(); // Reset current matrix (PROJECTION)
|
||||
rlOrtho(0, screenWidth, screenHeight, 0, 0.0f, 1.0f); // Orthographic projection with top-left corner at (0,0)
|
||||
rlMatrixMode(RL_MODELVIEW); // Switch back to MODELVIEW matrix
|
||||
rlLoadIdentity(); // Reset current matrix (MODELVIEW)
|
||||
|
||||
rlClearColor(245, 245, 245, 255); // Define clear color
|
||||
rlEnableDepthTest(); // Enable DEPTH_TEST for 3D
|
||||
|
||||
Camera camera;
|
||||
camera.position = (Vector3){ 5.0f, 5.0f, 5.0f }; // Camera position
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
|
||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; // Cube default position (center)
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// ...
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
rlClearScreenBuffers(); // Clear current framebuffer
|
||||
|
||||
// Calculate projection matrix (from perspective) and view matrix from camera look at
|
||||
Matrix matProj = MatrixPerspective(camera.fovy, (double)screenWidth/(double)screenHeight, 0.01, 1000.0);
|
||||
MatrixTranspose(&matProj);
|
||||
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
|
||||
|
||||
SetMatrixModelview(matView); // Replace internal modelview matrix by a custom one
|
||||
SetMatrixProjection(matProj); // Replace internal projection matrix by a custom one
|
||||
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, RAYWHITE);
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
// NOTE: Internal buffers drawing (3D data)
|
||||
rlglDraw();
|
||||
|
||||
// Draw '2D' elements in the scene (GUI)
|
||||
#define RLGL_CREATE_MATRIX_MANUALLY
|
||||
#if defined(RLGL_CREATE_MATRIX_MANUALLY)
|
||||
matProj = MatrixOrtho(0.0, screenWidth, screenHeight, 0.0, 0.0, 1.0);
|
||||
MatrixTranspose(&matProj);
|
||||
matView = MatrixIdentity();
|
||||
|
||||
SetMatrixModelview(matView); // Replace internal modelview matrix by a custom one
|
||||
SetMatrixProjection(matProj); // Replace internal projection matrix by a custom one
|
||||
|
||||
#else // Let rlgl generate and multiply matrix internally
|
||||
|
||||
rlMatrixMode(RL_PROJECTION); // Enable internal projection matrix
|
||||
rlLoadIdentity(); // Reset internal projection matrix
|
||||
rlOrtho(0.0, screenWidth, screenHeight, 0.0, 0.0, 1.0); // Recalculate internal projection matrix
|
||||
rlMatrixMode(RL_MODELVIEW); // Enable internal modelview matrix
|
||||
rlLoadIdentity(); // Reset internal modelview matrix
|
||||
#endif
|
||||
DrawRectangleV((Vector2){ 10.0f, 10.0f }, (Vector2){ 780.0f, 20.0f }, DARKGRAY);
|
||||
|
||||
// NOTE: Internal buffers drawing (2D data)
|
||||
rlglDraw();
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
rlglClose(); // Unload rlgl internal buffers and default shader/texture
|
||||
|
||||
glfwDestroyWindow(window); // Close window
|
||||
glfwTerminate(); // Free GLFW3 resources
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module specific Functions Definitions
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// GLFW3: Error callback
|
||||
static void ErrorCallback(int error, const char* description)
|
||||
{
|
||||
TraceLog(ERROR, description);
|
||||
}
|
||||
|
||||
// GLFW3: Keyboard callback
|
||||
static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||
{
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw rectangle using rlgl OpenGL 1.1 style coding (translated to OpenGL 3.3 internally)
|
||||
static void DrawRectangleV(Vector2 position, Vector2 size, Color color)
|
||||
{
|
||||
rlBegin(RL_TRIANGLES);
|
||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||
|
||||
rlVertex2i(position.x, position.y);
|
||||
rlVertex2i(position.x, position.y + size.y);
|
||||
rlVertex2i(position.x + size.x, position.y + size.y);
|
||||
|
||||
rlVertex2i(position.x, position.y);
|
||||
rlVertex2i(position.x + size.x, position.y + size.y);
|
||||
rlVertex2i(position.x + size.x, position.y);
|
||||
rlEnd();
|
||||
}
|
||||
|
||||
// Draw a grid centered at (0, 0, 0)
|
||||
static void DrawGrid(int slices, float spacing)
|
||||
{
|
||||
int halfSlices = slices / 2;
|
||||
|
||||
rlBegin(RL_LINES);
|
||||
for(int i = -halfSlices; i <= halfSlices; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
rlColor3f(0.5f, 0.5f, 0.5f);
|
||||
rlColor3f(0.5f, 0.5f, 0.5f);
|
||||
rlColor3f(0.5f, 0.5f, 0.5f);
|
||||
rlColor3f(0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
rlColor3f(0.75f, 0.75f, 0.75f);
|
||||
rlColor3f(0.75f, 0.75f, 0.75f);
|
||||
rlColor3f(0.75f, 0.75f, 0.75f);
|
||||
rlColor3f(0.75f, 0.75f, 0.75f);
|
||||
}
|
||||
|
||||
rlVertex3f((float)i*spacing, 0.0f, (float)-halfSlices*spacing);
|
||||
rlVertex3f((float)i*spacing, 0.0f, (float)halfSlices*spacing);
|
||||
|
||||
rlVertex3f((float)-halfSlices*spacing, 0.0f, (float)i*spacing);
|
||||
rlVertex3f((float)halfSlices*spacing, 0.0f, (float)i*spacing);
|
||||
}
|
||||
rlEnd();
|
||||
}
|
||||
|
||||
// Draw cube
|
||||
// NOTE: Cube position is the center position
|
||||
void DrawCube(Vector3 position, float width, float height, float length, Color color)
|
||||
{
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
float z = 0.0f;
|
||||
|
||||
rlPushMatrix();
|
||||
|
||||
// NOTE: Be careful! Function order matters (rotate -> scale -> translate)
|
||||
rlTranslatef(position.x, position.y, position.z);
|
||||
//rlScalef(2.0f, 2.0f, 2.0f);
|
||||
//rlRotatef(45, 0, 1, 0);
|
||||
|
||||
rlBegin(RL_TRIANGLES);
|
||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||
|
||||
// Front Face -----------------------------------------------------
|
||||
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
|
||||
// Back Face ------------------------------------------------------
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
||||
|
||||
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
|
||||
// Top Face -------------------------------------------------------
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Bottom Left
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Bottom Right
|
||||
|
||||
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Bottom Right
|
||||
|
||||
// Bottom Face ----------------------------------------------------
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
||||
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Top Right
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left
|
||||
|
||||
// Right face -----------------------------------------------------
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
||||
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Left
|
||||
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Left
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Left
|
||||
|
||||
// Left Face ------------------------------------------------------
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Right
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Right
|
||||
|
||||
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Right
|
||||
rlEnd();
|
||||
rlPopMatrix();
|
||||
}
|
||||
|
||||
// Draw cube wires
|
||||
void DrawCubeWires(Vector3 position, float width, float height, float length, Color color)
|
||||
{
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
float z = 0.0f;
|
||||
|
||||
rlPushMatrix();
|
||||
|
||||
rlTranslatef(position.x, position.y, position.z);
|
||||
//rlRotatef(45, 0, 1, 0);
|
||||
|
||||
rlBegin(RL_LINES);
|
||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||
|
||||
// Front Face -----------------------------------------------------
|
||||
// Bottom Line
|
||||
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
|
||||
// Left Line
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right
|
||||
|
||||
// Top Line
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
|
||||
// Right Line
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
||||
|
||||
// Back Face ------------------------------------------------------
|
||||
// Bottom Line
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
||||
|
||||
// Left Line
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
||||
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
||||
|
||||
// Top Line
|
||||
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
|
||||
// Right Line
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left
|
||||
|
||||
// Top Face -------------------------------------------------------
|
||||
// Left Line
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left Front
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left Back
|
||||
|
||||
// Right Line
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right Front
|
||||
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right Back
|
||||
|
||||
// Bottom Face ---------------------------------------------------
|
||||
// Left Line
|
||||
rlVertex3f(x-width/2, y-height/2, z+length/2); // Top Left Front
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left Back
|
||||
|
||||
// Right Line
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Top Right Front
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Top Right Back
|
||||
rlEnd();
|
||||
rlPopMatrix();
|
||||
}
|
@@ -30,24 +30,25 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 3.0, 3.0, 3.0 }, { 0.0, 1.5, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
|
||||
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
|
||||
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture
|
||||
SetModelTexture(&dwarf, texture); // Bind texture to model
|
||||
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture (diffuse map)
|
||||
dwarf.material.texDiffuse = texture; // Set dwarf model diffuse texture
|
||||
|
||||
Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
|
||||
Shader shader = LoadShader("resources/shaders/base.vs",
|
||||
"resources/shaders/swirl.fs"); // Load postpro shader
|
||||
Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
|
||||
"resources/shaders/glsl330/swirl.fs"); // Load postpro shader
|
||||
|
||||
// Get variable (uniform) location on the shader to connect with the program
|
||||
// NOTE: If uniform variable could not be found in the shader, function returns -1
|
||||
int swirlCenterLoc = GetShaderLocation(shader, "center");
|
||||
|
||||
float swirlCenter[2] = { screenWidth/2, screenHeight/2 };
|
||||
float swirlCenter[2] = { (float)screenWidth/2, (float)screenHeight/2 };
|
||||
|
||||
SetPostproShader(shader); // Set fullscreen postprocessing shader
|
||||
// Create a RenderTexture2D to be used for render to texture
|
||||
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
|
||||
|
||||
// Setup orbital camera
|
||||
SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
|
||||
@@ -79,14 +80,27 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
BeginTextureMode(target); // Enable drawing to texture
|
||||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
|
||||
|
||||
DrawGrid(10.0, 1.0); // Draw a grid
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
End3dMode();
|
||||
|
||||
DrawText("TEXT DRAWN IN RENDER TEXTURE", 200, 10, 30, RED);
|
||||
|
||||
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
|
||||
|
||||
BeginShaderMode(shader);
|
||||
|
||||
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
||||
DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
||||
|
||||
EndShaderMode();
|
||||
|
||||
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
@@ -100,6 +114,7 @@ int main()
|
||||
UnloadShader(shader); // Unload shader
|
||||
UnloadTexture(texture); // Unload texture
|
||||
UnloadModel(dwarf); // Unload model
|
||||
UnloadRenderTexture(target); // Unload render texture
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
Before Width: | Height: | Size: 249 KiB After Width: | Height: | Size: 252 KiB |
@@ -30,17 +30,17 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 3.0, 3.0, 3.0 }, { 0.0, 1.5, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
|
||||
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
|
||||
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture
|
||||
Shader shader = LoadShader("resources/shaders/base.vs",
|
||||
"resources/shaders/grayscale.fs"); // Load model shader
|
||||
Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
|
||||
"resources/shaders/glsl330/grayscale.fs"); // Load model shader
|
||||
|
||||
SetModelShader(&dwarf, shader); // Set shader effect to 3d model
|
||||
SetModelTexture(&dwarf, texture); // Bind texture to model
|
||||
dwarf.material.shader = shader; // Set shader effect to 3d model
|
||||
dwarf.material.texDiffuse = texture; // Bind texture to model
|
||||
|
||||
Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
|
||||
// Setup orbital camera
|
||||
SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
|
||||
@@ -68,7 +68,7 @@ int main()
|
||||
|
||||
DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
|
||||
|
||||
DrawGrid(10.0, 1.0); // Draw a grid
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
End3dMode();
|
||||
|
||||
|
@@ -30,18 +30,19 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 3.0, 3.0, 3.0 }, { 0.0, 1.5, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
|
||||
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
|
||||
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture
|
||||
SetModelTexture(&dwarf, texture); // Bind texture to model
|
||||
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture (diffuse map)
|
||||
dwarf.material.texDiffuse = texture; // Set dwarf model diffuse texture
|
||||
|
||||
Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
|
||||
Shader shader = LoadShader("resources/shaders/base.vs",
|
||||
"resources/shaders/bloom.fs"); // Load postpro shader
|
||||
Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
|
||||
"resources/shaders/glsl330/bloom.fs"); // Load postpro shader
|
||||
|
||||
SetPostproShader(shader); // Set fullscreen postprocessing shader
|
||||
// Create a RenderTexture2D to be used for render to texture
|
||||
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
|
||||
|
||||
// Setup orbital camera
|
||||
SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
|
||||
@@ -65,15 +66,28 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
BeginTextureMode(target); // Enable drawing to texture
|
||||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
|
||||
|
||||
DrawGrid(10.0, 1.0); // Draw a grid
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
End3dMode();
|
||||
|
||||
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, BLACK);
|
||||
DrawText("HELLO POSTPROCESSING!", 70, 190, 50, RED);
|
||||
|
||||
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
|
||||
|
||||
BeginShaderMode(shader);
|
||||
|
||||
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
||||
DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
||||
|
||||
EndShaderMode();
|
||||
|
||||
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, DARKGRAY);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
@@ -86,6 +100,7 @@ int main()
|
||||
UnloadShader(shader); // Unload shader
|
||||
UnloadTexture(texture); // Unload texture
|
||||
UnloadModel(dwarf); // Unload model
|
||||
UnloadRenderTexture(target); // Unload render texture
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
Before Width: | Height: | Size: 217 KiB After Width: | Height: | Size: 232 KiB |
@@ -32,10 +32,9 @@ int main()
|
||||
|
||||
Texture2D sonic = LoadTexture("resources/texture_formats/sonic.png");
|
||||
|
||||
// NOTE: This shader is a bit different than model/postprocessing shaders,
|
||||
// it requires the color data for every vertice to use it in every shape or texture independently
|
||||
Shader shader = LoadShader("resources/shaders/shapes_base.vs",
|
||||
"resources/shaders/shapes_grayscale.fs");
|
||||
// NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version
|
||||
Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
|
||||
"resources/shaders/glsl330/grayscale.fs");
|
||||
|
||||
// Shader usage is also different than models/postprocessing, shader is just activated when required
|
||||
|
||||
@@ -66,7 +65,7 @@ int main()
|
||||
|
||||
|
||||
// Activate our custom shader to be applied on next shapes/textures drawings
|
||||
SetCustomShader(shader);
|
||||
BeginShaderMode(shader);
|
||||
|
||||
DrawText("USING CUSTOM SHADER", 190, 40, 10, RED);
|
||||
|
||||
@@ -75,7 +74,7 @@ int main()
|
||||
DrawRectangleLines(250 - 40, 320, 80, 60, ORANGE);
|
||||
|
||||
// Activate our default shader for next drawings
|
||||
SetDefaultShader();
|
||||
EndShaderMode();
|
||||
|
||||
DrawText("USING DEFAULT SHADER", 370, 40, 10, RED);
|
||||
|
||||
@@ -90,12 +89,12 @@ int main()
|
||||
DrawPoly((Vector2){430, 320}, 6, 80, 0, BROWN);
|
||||
|
||||
// Activate our custom shader to be applied on next shapes/textures drawings
|
||||
SetCustomShader(shader);
|
||||
BeginShaderMode(shader);
|
||||
|
||||
DrawTexture(sonic, 380, -10, WHITE); // Using custom shader
|
||||
|
||||
// Activate our default shader for next drawings
|
||||
SetDefaultShader();
|
||||
EndShaderMode();
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
122
examples/shaders_standard_lighting.c
Normal file
@@ -0,0 +1,122 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [shaders] example - Standard lighting (materials and lights)
|
||||
*
|
||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||
*
|
||||
* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example
|
||||
* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
|
||||
* raylib comes with shaders ready for both versions, check raylib/shaders install folder
|
||||
*
|
||||
* 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) 2016 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 4.0f, 4.0f, 4.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
|
||||
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
|
||||
|
||||
Material material = LoadStandardMaterial();
|
||||
|
||||
material.texDiffuse = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model diffuse texture
|
||||
material.texNormal = LoadTexture("resources/model/dwarf_normal.png"); // Load model normal texture
|
||||
material.texSpecular = LoadTexture("resources/model/dwarf_specular.png"); // Load model specular texture
|
||||
material.colDiffuse = WHITE;
|
||||
material.colAmbient = (Color){0, 0, 10, 255};
|
||||
material.colSpecular = WHITE;
|
||||
material.glossiness = 50.0f;
|
||||
|
||||
dwarf.material = material; // Apply material to model
|
||||
|
||||
Light spotLight = CreateLight(LIGHT_SPOT, (Vector3){3.0f, 5.0f, 2.0f}, (Color){255, 255, 255, 255});
|
||||
spotLight->target = (Vector3){0.0f, 0.0f, 0.0f};
|
||||
spotLight->intensity = 2.0f;
|
||||
spotLight->diffuse = (Color){255, 100, 100, 255};
|
||||
spotLight->coneAngle = 60.0f;
|
||||
|
||||
Light dirLight = CreateLight(LIGHT_DIRECTIONAL, (Vector3){0.0f, -3.0f, -3.0f}, (Color){255, 255, 255, 255});
|
||||
dirLight->target = (Vector3){1.0f, -2.0f, -2.0f};
|
||||
dirLight->intensity = 2.0f;
|
||||
dirLight->diffuse = (Color){100, 255, 100, 255};
|
||||
|
||||
Light pointLight = CreateLight(LIGHT_POINT, (Vector3){0.0f, 4.0f, 5.0f}, (Color){255, 255, 255, 255});
|
||||
pointLight->intensity = 2.0f;
|
||||
pointLight->diffuse = (Color){100, 100, 255, 255};
|
||||
pointLight->radius = 3.0f;
|
||||
|
||||
// Setup orbital camera
|
||||
SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
|
||||
SetCameraPosition(camera.position); // Set internal camera position to match our camera position
|
||||
SetCameraTarget(camera.target); // Set internal camera target to match our camera target
|
||||
|
||||
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); // Update internal camera and our camera
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
|
||||
|
||||
DrawLight(spotLight); // Draw spot light
|
||||
DrawLight(dirLight); // Draw directional light
|
||||
DrawLight(pointLight); // Draw point light
|
||||
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
End3dMode();
|
||||
|
||||
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadMaterial(material); // Unload material and assigned textures
|
||||
UnloadModel(dwarf); // Unload model
|
||||
|
||||
// Destroy all created lights
|
||||
DestroyLight(pointLight);
|
||||
DestroyLight(dirLight);
|
||||
DestroyLight(spotLight);
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/shaders_standard_lighting.png
Normal file
After Width: | Height: | Size: 246 KiB |
@@ -19,6 +19,8 @@ int main()
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing");
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 30 KiB |
@@ -19,6 +19,8 @@ int main()
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib color palette");
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
|
@@ -19,6 +19,8 @@ int main()
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes");
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
|
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* raylib [shapes] example - raylib logo animation
|
||||
*
|
||||
* This example has been created using raylib 1.1 (www.raylib.com)
|
||||
* This example has been created using raylib 1.4 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
||||
@@ -32,12 +32,8 @@ int main()
|
||||
int bottomSideRecWidth = 16;
|
||||
int rightSideRecHeight = 16;
|
||||
|
||||
char raylib[8] = " \0"; // raylib text array, max 8 letters
|
||||
|
||||
int state = 0; // Tracking animation states (State Machine)
|
||||
|
||||
float alpha = 1.0; // Useful for fading
|
||||
|
||||
float alpha = 1.0f; // Useful for fading
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -81,24 +77,13 @@ int main()
|
||||
framesCounter = 0;
|
||||
}
|
||||
|
||||
switch (lettersCount)
|
||||
{
|
||||
case 1: raylib[0] = 'r'; break;
|
||||
case 2: raylib[1] = 'a'; break;
|
||||
case 3: raylib[2] = 'y'; break;
|
||||
case 4: raylib[3] = 'l'; break;
|
||||
case 5: raylib[4] = 'i'; break;
|
||||
case 6: raylib[5] = 'b'; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (lettersCount >= 10) // When all letters have appeared, just fade out everything
|
||||
{
|
||||
alpha -= 0.02;
|
||||
alpha -= 0.02f;
|
||||
|
||||
if (alpha <= 0)
|
||||
if (alpha <= 0.0f)
|
||||
{
|
||||
alpha = 0;
|
||||
alpha = 0.0f;
|
||||
state = 4;
|
||||
}
|
||||
}
|
||||
@@ -116,12 +101,7 @@ int main()
|
||||
bottomSideRecWidth = 16;
|
||||
rightSideRecHeight = 16;
|
||||
|
||||
for (int i = 0; i < 7; i++) raylib[i] = ' ';
|
||||
|
||||
raylib[7] = '\0'; // Last character is end-of-line
|
||||
|
||||
alpha = 1.0;
|
||||
|
||||
alpha = 1.0f;
|
||||
state = 0; // Return to State 0
|
||||
}
|
||||
}
|
||||
@@ -160,7 +140,7 @@ int main()
|
||||
|
||||
DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, Fade(RAYWHITE, alpha));
|
||||
|
||||
DrawText(raylib, screenWidth/2 - 44, screenHeight/2 + 48, 50, Fade(BLACK, alpha));
|
||||
DrawText(SubText("raylib", 0, lettersCount), screenWidth/2 - 44, screenHeight/2 + 48, 50, Fade(BLACK, alpha));
|
||||
}
|
||||
else if (state == 4)
|
||||
{
|
||||
|
68
examples/text_bmfont_ttf.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [text] example - BMFont and TTF SpriteFonts loading
|
||||
*
|
||||
* This example has been created using raylib 1.4 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2016 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont and ttf sprite fonts loading");
|
||||
|
||||
const char msgBm[64] = "THIS IS AN AngelCode SPRITE FONT";
|
||||
const char msgTtf[64] = "THIS SPRITE FONT has been GENERATED from a TTF";
|
||||
|
||||
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
|
||||
SpriteFont fontBm = LoadSpriteFont("resources/fonts/bmfont.fnt"); // BMFont (AngelCode)
|
||||
SpriteFont fontTtf = LoadSpriteFont("resources/fonts/pixantiqua.ttf"); // TTF font
|
||||
|
||||
Vector2 fontPosition;
|
||||
|
||||
fontPosition.x = screenWidth/2 - MeasureTextEx(fontBm, msgBm, fontBm.size, 0).x/2;
|
||||
fontPosition.y = screenHeight/2 - fontBm.size/2 - 80;
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update variables here...
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawTextEx(fontBm, msgBm, fontPosition, fontBm.size, 0, MAROON);
|
||||
DrawTextEx(fontTtf, msgTtf, (Vector2){ 75.0f, 240.0f }, fontTtf.size*0.8f, 2, LIME);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadSpriteFont(fontBm); // AngelCode SpriteFont unloading
|
||||
UnloadSpriteFont(fontTtf); // TTF SpriteFont unloading
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/text_bmfont_ttf.png
Normal file
After Width: | Height: | Size: 19 KiB |
60
examples/text_writing_anim.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [text] example - Text Writing Animation
|
||||
*
|
||||
* This example has been created using raylib 1.4 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2016 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [text] example - text writing anim");
|
||||
|
||||
const char message[128] = "This sample illustrates a text writing\nanimation effect! Check it out! ;)";
|
||||
|
||||
int framesCounter = 0;
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
framesCounter++;
|
||||
|
||||
if (IsKeyPressed(KEY_ENTER)) framesCounter = 0;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText(SubText(message, 0, framesCounter/10), 210, 160, 20, MAROON);
|
||||
|
||||
DrawText("PRESS [ENTER] to RESTART!", 240, 280, 20, LIGHTGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/text_writing_anim.png
Normal file
After Width: | Height: | Size: 15 KiB |
@@ -76,7 +76,7 @@ int main()
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 480;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture formats loading");
|
||||
|
||||
@@ -128,8 +128,8 @@ int main()
|
||||
|
||||
for (int i = 0; i < NUM_TEXTURES; i++)
|
||||
{
|
||||
if (i < NUM_TEXTURES/2) selectRecs[i] = (Rectangle){ 40, 45 + 32*i, 150, 30 };
|
||||
else selectRecs[i] = (Rectangle){ 40 + 152, 45 + 32*(i - NUM_TEXTURES/2), 150, 30 };
|
||||
if (i < NUM_TEXTURES/2) selectRecs[i] = (Rectangle){ 40, 30 + 32*i, 150, 30 };
|
||||
else selectRecs[i] = (Rectangle){ 40 + 152, 30 + 32*(i - NUM_TEXTURES/2), 150, 30 };
|
||||
}
|
||||
|
||||
// Texture sizes in KB
|
||||
@@ -215,7 +215,7 @@ int main()
|
||||
// Draw selected texture
|
||||
if (sonic[selectedFormat].id != 0)
|
||||
{
|
||||
DrawTexture(sonic[selectedFormat], 350, 0, WHITE);
|
||||
DrawTexture(sonic[selectedFormat], 350, -10, WHITE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -225,9 +225,9 @@ int main()
|
||||
DrawText("ON YOUR GPU", 520, 240, 20, MAROON);
|
||||
}
|
||||
|
||||
DrawText("Select texture format (use cursor keys):", 40, 26, 10, DARKGRAY);
|
||||
DrawText("Required GPU memory size (VRAM):", 40, 442, 10, DARKGRAY);
|
||||
DrawText(FormatText("%4.0f KB", textureSizes[selectedFormat]), 240, 435, 20, DARKBLUE);
|
||||
DrawText("Select texture format (use cursor keys):", 40, 10, 10, DARKGRAY);
|
||||
DrawText("Required GPU memory size (VRAM):", 40, 427, 10, DARKGRAY);
|
||||
DrawText(FormatText("%4.0f KB", textureSizes[selectedFormat]), 240, 420, 20, DARKBLUE);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 123 KiB |
78
examples/textures_image_drawing.c
Normal file
@@ -0,0 +1,78 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [textures] example - Image loading and drawing on it
|
||||
*
|
||||
* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
|
||||
*
|
||||
* This example has been created using raylib 1.4 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2016 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [textures] example - image drawing");
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
|
||||
Image cat = LoadImage("resources/cat.png"); // Load image in CPU memory (RAM)
|
||||
ImageCrop(&cat, (Rectangle){ 100, 10, 280, 380 }); // Crop an image piece
|
||||
ImageFlipHorizontal(&cat); // Flip cropped image horizontally
|
||||
ImageResize(&cat, 150, 200); // Resize flipped-cropped image
|
||||
|
||||
Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM)
|
||||
|
||||
// Draw one image over the other with a scaling of 1.5f
|
||||
ImageDraw(&parrots, cat, (Rectangle){ 0, 0, cat.width, cat.height }, (Rectangle){ 30, 40, cat.width*1.5f, cat.height*1.5f });
|
||||
ImageCrop(&parrots, (Rectangle){ 0, 50, parrots.width, parrots.height - 100 }); // Crop resulting image
|
||||
|
||||
UnloadImage(cat); // Unload image from RAM
|
||||
|
||||
Texture2D texture = LoadTextureFromImage(parrots); // Image converted to texture, uploaded to GPU memory (VRAM)
|
||||
UnloadImage(parrots); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
|
||||
|
||||
SetTargetFPS(60);
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2 - 40, WHITE);
|
||||
DrawRectangleLines(screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2 - 40, texture.width, texture.height, DARKGRAY);
|
||||
|
||||
DrawText("We are drawing only one texture from various images composed!", 240, 350, 10, DARKGRAY);
|
||||
DrawText("Source images have been cropped, scaled, flipped and copied one over the other.", 190, 370, 10, DARKGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Texture unloading
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/textures_image_drawing.png
Normal file
After Width: | Height: | Size: 410 KiB |
154
examples/textures_image_processing.c
Normal file
@@ -0,0 +1,154 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [textures] example - Image processing
|
||||
*
|
||||
* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
|
||||
*
|
||||
* This example has been created using raylib 1.4 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2016 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include <stdlib.h> // Required for: free()
|
||||
|
||||
#define NUM_PROCESSES 8
|
||||
|
||||
typedef enum {
|
||||
NONE = 0,
|
||||
COLOR_GRAYSCALE,
|
||||
COLOR_TINT,
|
||||
COLOR_INVERT,
|
||||
COLOR_CONTRAST,
|
||||
COLOR_BRIGHTNESS,
|
||||
FLIP_VERTICAL,
|
||||
FLIP_HORIZONTAL
|
||||
} ImageProcess;
|
||||
|
||||
static const char *processText[] = {
|
||||
"NO PROCESSING",
|
||||
"COLOR GRAYSCALE",
|
||||
"COLOR TINT",
|
||||
"COLOR INVERT",
|
||||
"COLOR CONTRAST",
|
||||
"COLOR BRIGHTNESS",
|
||||
"FLIP VERTICAL",
|
||||
"FLIP HORIZONTAL"
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [textures] example - image processing");
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
|
||||
Image image = LoadImage("resources/parrots.png"); // Loaded in CPU memory (RAM)
|
||||
ImageFormat(&image, UNCOMPRESSED_R8G8B8A8); // Format image to RGBA 32bit (required for texture update)
|
||||
Texture2D texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (VRAM)
|
||||
|
||||
int currentProcess = NONE;
|
||||
bool textureReload = false;
|
||||
|
||||
Rectangle selectRecs[NUM_PROCESSES];
|
||||
|
||||
for (int i = 0; i < NUM_PROCESSES; i++) selectRecs[i] = (Rectangle){ 40, 50 + 32*i, 150, 30 };
|
||||
|
||||
SetTargetFPS(60);
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyPressed(KEY_DOWN))
|
||||
{
|
||||
currentProcess++;
|
||||
if (currentProcess > 7) currentProcess = 0;
|
||||
textureReload = true;
|
||||
}
|
||||
else if (IsKeyPressed(KEY_UP))
|
||||
{
|
||||
currentProcess--;
|
||||
if (currentProcess < 0) currentProcess = 7;
|
||||
textureReload = true;
|
||||
}
|
||||
|
||||
if (textureReload)
|
||||
{
|
||||
UnloadImage(image); // Unload current image data
|
||||
image = LoadImage("resources/parrots.png"); // Re-load image data
|
||||
|
||||
// NOTE: Image processing is a costly CPU process to be done every frame,
|
||||
// If image processing is required in a frame-basis, it should be done
|
||||
// with a texture and by shaders
|
||||
switch (currentProcess)
|
||||
{
|
||||
case COLOR_GRAYSCALE: ImageColorGrayscale(&image); break;
|
||||
case COLOR_TINT: ImageColorTint(&image, GREEN); break;
|
||||
case COLOR_INVERT: ImageColorInvert(&image); break;
|
||||
case COLOR_CONTRAST: ImageColorContrast(&image, -40); break;
|
||||
case COLOR_BRIGHTNESS: ImageColorBrightness(&image, -80); break;
|
||||
case FLIP_VERTICAL: ImageFlipVertical(&image); break;
|
||||
case FLIP_HORIZONTAL: ImageFlipHorizontal(&image); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
Color *pixels = GetImageData(image); // Get pixel data from image (RGBA 32bit)
|
||||
UpdateTexture(texture, pixels); // Update texture with new image data
|
||||
free(pixels); // Unload pixels data from RAM
|
||||
|
||||
textureReload = false;
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText("IMAGE PROCESSING:", 40, 30, 10, DARKGRAY);
|
||||
|
||||
// Draw rectangles
|
||||
for (int i = 0; i < NUM_PROCESSES; i++)
|
||||
{
|
||||
if (i == currentProcess)
|
||||
{
|
||||
DrawRectangleRec(selectRecs[i], SKYBLUE);
|
||||
DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, BLUE);
|
||||
DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2, selectRecs[i].y + 11, 10, DARKBLUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawRectangleRec(selectRecs[i], LIGHTGRAY);
|
||||
DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, GRAY);
|
||||
DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2, selectRecs[i].y + 11, 10, DARKGRAY);
|
||||
}
|
||||
}
|
||||
|
||||
DrawTexture(texture, screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, WHITE);
|
||||
DrawRectangleLines(screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, texture.width, texture.height, BLACK);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Unload texture from VRAM
|
||||
UnloadImage(image); // Unload image from RAM
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
BIN
examples/textures_image_processing.png
Normal file
After Width: | Height: | Size: 253 KiB |
@@ -38,8 +38,7 @@ int main()
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawTexture(texture, screenWidth/2 - texture.width/2,
|
||||
screenHeight/2 - texture.height/2, WHITE);
|
||||
DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE);
|
||||
|
||||
DrawText("this IS a texture!", 360, 370, 10, GRAY);
|
||||
|
||||
|
@@ -41,12 +41,12 @@ int main()
|
||||
mouseTail[i].position = (Vector2){ 0, 0 };
|
||||
mouseTail[i].color = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 };
|
||||
mouseTail[i].alpha = 1.0f;
|
||||
mouseTail[i].size = (float)GetRandomValue(1, 30)/20;
|
||||
mouseTail[i].size = (float)GetRandomValue(1, 30)/20.0f;
|
||||
mouseTail[i].rotation = GetRandomValue(0, 360);
|
||||
mouseTail[i].active = false;
|
||||
}
|
||||
|
||||
float gravity = 3;
|
||||
float gravity = 3.0f;
|
||||
|
||||
Texture2D smoke = LoadTexture("resources/smoke.png");
|
||||
|
||||
@@ -85,7 +85,7 @@ int main()
|
||||
|
||||
if (mouseTail[i].alpha <= 0.0f) mouseTail[i].active = false;
|
||||
|
||||
mouseTail[i].rotation += 5;
|
||||
mouseTail[i].rotation += 5.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ int main()
|
||||
|
||||
ClearBackground(DARKGRAY);
|
||||
|
||||
SetBlendMode(blending);
|
||||
BeginBlendMode(blending);
|
||||
|
||||
// Draw active particles
|
||||
for (int i = 0; i < MAX_PARTICLES; i++)
|
||||
@@ -113,9 +113,11 @@ int main()
|
||||
Fade(mouseTail[i].color, mouseTail[i].alpha));
|
||||
}
|
||||
|
||||
DrawText("PRESS SPACE to CHANGE BLENDING MODE", 180, 20, 20, RAYWHITE);
|
||||
EndBlendMode();
|
||||
|
||||
if (blending == BLEND_ALPHA) DrawText("ALPHA BLENDING", 290, screenHeight - 40, 20, RAYWHITE);
|
||||
DrawText("PRESS SPACE to CHANGE BLENDING MODE", 180, 20, 20, BLACK);
|
||||
|
||||
if (blending == BLEND_ALPHA) DrawText("ALPHA BLENDING", 290, screenHeight - 40, 20, BLACK);
|
||||
else DrawText("ADDITIVE BLENDING", 280, screenHeight - 40, 20, RAYWHITE);
|
||||
|
||||
EndDrawing();
|
||||
|
@@ -23,7 +23,7 @@ int main()
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
Texture2D guybrush = LoadTexture("resources/guybrush.png"); // Texture loading
|
||||
|
||||
Vector2 position = { 350, 240 };
|
||||
Vector2 position = { 350.0f, 240.0f };
|
||||
Rectangle frameRec = { 0, 0, guybrush.width/7, guybrush.height };
|
||||
int currentFrame = 0;
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
@@ -55,6 +55,10 @@ int main()
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
// NOTE: Using DrawTexturePro() we can easily rotate and scale the part of the texture we draw
|
||||
// sourceRec defines the part of the texture we use for drawing
|
||||
// destRec defines the rectangle where our texture part will fit (scaling it to fit)
|
||||
// origin defines the point of the texture used as reference for rotation and scaling
|
||||
// rotation defines the texture rotation (using origin as rotation point)
|
||||
DrawTexturePro(guybrush, sourceRec, destRec, origin, rotation, WHITE);
|
||||
|
||||
DrawLine(destRec.x, 0, destRec.x, screenHeight, GRAY);
|
||||
|