Compare commits
912 Commits
pre-merge-
...
mesa_6_5_3
Author | SHA1 | Date | |
---|---|---|---|
|
02e958a1e4 | ||
|
cce5084941 | ||
|
4b1d1b7b18 | ||
|
7ff72a7659 | ||
|
c4b3b8dece | ||
|
65bab0dad8 | ||
|
74edc663a6 | ||
|
54d59cfb70 | ||
|
b7f5b8af65 | ||
|
4099531a0a | ||
|
1606f2c123 | ||
|
1dd7c00214 | ||
|
f42d4ab41e | ||
|
4a28548cbf | ||
|
5814922d25 | ||
|
3de20aead2 | ||
|
6d27194dff | ||
|
c233aa2768 | ||
|
c93b2a1cb7 | ||
|
eca456b63d | ||
|
4003bde6ff | ||
|
ddcf819906 | ||
|
9ede048127 | ||
|
97693436a5 | ||
|
8a8a5bd104 | ||
|
3e5eda9ee9 | ||
|
f38dcc8a6a | ||
|
b1b154c498 | ||
|
286faac68e | ||
|
3b0bd0ce17 | ||
|
208ea84524 | ||
|
7868ab6617 | ||
|
47ad443c55 | ||
|
3db3dc58bc | ||
|
c27adc52ce | ||
|
afc132e7a9 | ||
|
335769a875 | ||
|
0bdf216dd0 | ||
|
d59e6f233b | ||
|
ad02042db2 | ||
|
f793e90e82 | ||
|
112e1f2b5a | ||
|
e5cf37c178 | ||
|
b5e9b0e562 | ||
|
b1502588c4 | ||
|
74afcabd85 | ||
|
b3ab925e91 | ||
|
2d2c6a622d | ||
|
fc3d6bd351 | ||
|
e261d66d81 | ||
|
cd3e39340f | ||
|
ad3cc95485 | ||
|
4e0a64675c | ||
|
d5e7234ba8 | ||
|
bc74cb4c0a | ||
|
257f799849 | ||
|
81c4fee160 | ||
|
1fbdd9d794 | ||
|
82839e8430 | ||
|
ced6f76404 | ||
|
4cc2674aee | ||
|
a7f7366d38 | ||
|
11e3f733ba | ||
|
98ef18909a | ||
|
f2346498aa | ||
|
4b7c6fc5a6 | ||
|
fe16b9f663 | ||
|
c9855a60f4 | ||
|
838a2a2633 | ||
|
e7e5279fc0 | ||
|
7fd3a6c521 | ||
|
720cf3aa13 | ||
|
5491c8194c | ||
|
e4e2068ac9 | ||
|
6346a753c6 | ||
|
4d944b502f | ||
|
6aa5668871 | ||
|
d60009bd6d | ||
|
535c37e85d | ||
|
ba3d384e94 | ||
|
8b5fce6bcc | ||
|
020cdb47cf | ||
|
121f2212cc | ||
|
24a93dd6a4 | ||
|
00da9afb84 | ||
|
4abcaf3949 | ||
|
6bde08815f | ||
|
8e6207396c | ||
|
5ca8d4ccf2 | ||
|
6b3027e291 | ||
|
8d370fb2ee | ||
|
36a6a59972 | ||
|
addd03da2e | ||
|
c93e883b20 | ||
|
274ac7a801 | ||
|
aaa57412c1 | ||
|
2a2f8d806f | ||
|
bac15c8db8 | ||
|
f3e8c32376 | ||
|
6d3d9c1c6d | ||
|
e57e752eee | ||
|
884af40864 | ||
|
30a79f76fc | ||
|
8598f55091 | ||
|
6d01f3f1ec | ||
|
e3caa5f891 | ||
|
d9443c2494 | ||
|
565cd49b5f | ||
|
a4b2b88337 | ||
|
04bda46739 | ||
|
d2d86a3f0b | ||
|
9cbcf7c696 | ||
|
468a33d19a | ||
|
893b368a82 | ||
|
41fc55dd81 | ||
|
1a9483c954 | ||
|
36949abec7 | ||
|
6459adf79b | ||
|
badc346206 | ||
|
4a7c45118d | ||
|
34ca2be769 | ||
|
5888010362 | ||
|
dfee7619d4 | ||
|
96e05da1c9 | ||
|
1560de2c3c | ||
|
921b008419 | ||
|
aa6992a296 | ||
|
4b3835dadf | ||
|
64e8088667 | ||
|
3dfcd48469 | ||
|
e812a2a484 | ||
|
da56df9d72 | ||
|
9519785e29 | ||
|
83ad64d94a | ||
|
fde15a2bae | ||
|
216eb81c53 | ||
|
4fc46a6c82 | ||
|
e19cfabb6e | ||
|
8d8a3cc398 | ||
|
fb1d22d23d | ||
|
3d59042afd | ||
|
967c1056d5 | ||
|
9f8373d5ca | ||
|
50aaabc248 | ||
|
30b6f11de1 | ||
|
f11604a30d | ||
|
99193e4f74 | ||
|
5b74fe0889 | ||
|
431d650f2b | ||
|
3c008a014f | ||
|
bf287356cf | ||
|
bce7043ebc | ||
|
70b0e123c4 | ||
|
f98f4f6d7a | ||
|
afc58f5f7e | ||
|
b61d74c575 | ||
|
9f66025f54 | ||
|
183d8e0620 | ||
|
b0bba03846 | ||
|
ba876be0c0 | ||
|
319ce38fa4 | ||
|
64700be4e1 | ||
|
159ecba4b3 | ||
|
e798d22556 | ||
|
0109b47106 | ||
|
7b2626f7d8 | ||
|
19121e2802 | ||
|
e0bbf46342 | ||
|
702c8f1e6c | ||
|
f9574c3f6b | ||
|
e8292d28e4 | ||
|
c96974f78c | ||
|
6461e91ac3 | ||
|
af807a4696 | ||
|
5c0c60a13c | ||
|
5dba996dba | ||
|
9612a3011f | ||
|
0d3d930912 | ||
|
d8bfc42bb7 | ||
|
ca7885f733 | ||
|
9176752172 | ||
|
79bf692420 | ||
|
f72e7fb1d6 | ||
|
4647f13c43 | ||
|
20ec486baf | ||
|
55000888b9 | ||
|
4f9d3a07bb | ||
|
84803279ca | ||
|
8d2d6e5194 | ||
|
e9c614a1af | ||
|
8f3fc5221c | ||
|
ae55d5322c | ||
|
92b7fa7b48 | ||
|
eb4a8b4bb5 | ||
|
663a3e9ba7 | ||
|
51a894e6eb | ||
|
ac32b644ee | ||
|
487f7a73cb | ||
|
aa1c79eaea | ||
|
885111518e | ||
|
0cae814f36 | ||
|
33c3739628 | ||
|
4d864b087e | ||
|
2f207dcf1e | ||
|
f9c01c33d3 | ||
|
d4dc57bb13 | ||
|
a28e648690 | ||
|
40ae3943f2 | ||
|
dba21ed913 | ||
|
66d336808d | ||
|
dccd9c4f4d | ||
|
3fe47d5c57 | ||
|
3fd88089c0 | ||
|
0683e4ce4b | ||
|
ec42af9263 | ||
|
00831b5b3b | ||
|
ec6c8f86f3 | ||
|
e608d92c5b | ||
|
57dadf71ca | ||
|
adb91c056f | ||
|
6f652c89d7 | ||
|
7439a36785 | ||
|
7eba12edce | ||
|
ba730e14ed | ||
|
1ba858591b | ||
|
f2f5d06853 | ||
|
b2ac30ac36 | ||
|
3b7f2f53a2 | ||
|
8128f7143d | ||
|
393a93ea32 | ||
|
3e7d43cd48 | ||
|
1bbd69251b | ||
|
f841b04601 | ||
|
b463d52143 | ||
|
7e4a7fdddd | ||
|
ee2f31e281 | ||
|
dad97b4688 | ||
|
a01616eed5 | ||
|
d750861dc2 | ||
|
59f7f6dbe9 | ||
|
20d85c609a | ||
|
ad766b5785 | ||
|
0420d8505a | ||
|
05e6fd8398 | ||
|
e5d00e8cf4 | ||
|
31dc7a3c89 | ||
|
17238f1ee5 | ||
|
f407cada8a | ||
|
e713ef66ef | ||
|
a0275b0d2c | ||
|
d6d6d20b13 | ||
|
1f1f582304 | ||
|
811c2e9a91 | ||
|
cda3236092 | ||
|
9b9e056615 | ||
|
ff65fa39e8 | ||
|
3e45db6729 | ||
|
3b8ab88131 | ||
|
32225d06b9 | ||
|
a835939222 | ||
|
98abd1bbc8 | ||
|
a9455bb9a7 | ||
|
63c57a14d3 | ||
|
25f21b5331 | ||
|
da82d86ea0 | ||
|
075d3d892f | ||
|
ae36cfc65e | ||
|
9878e8ff51 | ||
|
6583429f89 | ||
|
037c068460 | ||
|
c042a91b8b | ||
|
813a0e11f1 | ||
|
52cc32378c | ||
|
c3da0bd7dd | ||
|
e508155d16 | ||
|
0426d3c0c8 | ||
|
b53745ce91 | ||
|
768f7231ea | ||
|
680abf8a02 | ||
|
1170268088 | ||
|
38a1c2b495 | ||
|
b5d988dd19 | ||
|
b67d93111d | ||
|
22d9132081 | ||
|
d619cceea4 | ||
|
76f3b66e04 | ||
|
e71c34aaa1 | ||
|
b9fbedd601 | ||
|
ee9bc897f8 | ||
|
1b354bb5e4 | ||
|
bb0393a0cd | ||
|
9fe342d1e6 | ||
|
cfdd07d7d3 | ||
|
1968444bed | ||
|
935f93f966 | ||
|
3493e867e9 | ||
|
49134e8e53 | ||
|
0e71d08e8d | ||
|
b50b036ffb | ||
|
dc3015f157 | ||
|
b2bc563142 | ||
|
44fb5156bb | ||
|
8f9db0f81c | ||
|
d1934c2065 | ||
|
81767eead9 | ||
|
63556fa994 | ||
|
bf020d8d7f | ||
|
2bdac09d16 | ||
|
ad76128204 | ||
|
fe20a619cf | ||
|
e6aeb24b23 | ||
|
0aad9e2627 | ||
|
12229f119d | ||
|
1bf81e3c5d | ||
|
1936b25ebd | ||
|
2eb656ef4f | ||
|
629ec2b06b | ||
|
2500d82d0d | ||
|
97c9b3ecc6 | ||
|
e02b989ff9 | ||
|
23d31efc16 | ||
|
180cc2f845 | ||
|
8ba06464ac | ||
|
76444d042c | ||
|
fdcbbeb55e | ||
|
e01ee3da57 | ||
|
fd1b1fce3f | ||
|
38889f5221 | ||
|
a02870f4f6 | ||
|
e348016253 | ||
|
7ed292a4e9 | ||
|
d63eef4b86 | ||
|
62b4601e53 | ||
|
565d097d8f | ||
|
2dc3e94470 | ||
|
b1a955b518 | ||
|
b01f146fd0 | ||
|
805b1cf482 | ||
|
52363954bf | ||
|
98650bdf89 | ||
|
5186529e57 | ||
|
fdf513e07a | ||
|
8d9db3dd03 | ||
|
fd08463dea | ||
|
c7b2cce418 | ||
|
000b2899b9 | ||
|
a49a865cf5 | ||
|
948c60badc | ||
|
d8070889d7 | ||
|
c000843a14 | ||
|
da55430952 | ||
|
17ad1d12eb | ||
|
8b9842a256 | ||
|
7265e6928e | ||
|
4110fac389 | ||
|
b3a22d0ed6 | ||
|
8946d7f029 | ||
|
d2a6f43eaf | ||
|
5a5b55943d | ||
|
3f7ef618b6 | ||
|
15aa7aaa93 | ||
|
ccb80d7ec4 | ||
|
1c09bcfdda | ||
|
d23dd812ad | ||
|
10b5895597 | ||
|
1fcb4ecc07 | ||
|
c9872b80c8 | ||
|
46bd63819e | ||
|
ff95925e70 | ||
|
b9ea936150 | ||
|
2cf5fd48d1 | ||
|
9f44247acf | ||
|
b03e1712b2 | ||
|
a706b0b8bd | ||
|
05b74e4ae4 | ||
|
2f35a17f38 | ||
|
5761a93bba | ||
|
3e0fbc7efc | ||
|
19a9050548 | ||
|
ee931f8d4d | ||
|
ec89aba7c6 | ||
|
cce4e50569 | ||
|
63772e2a2c | ||
|
b3dd49429b | ||
|
609306de17 | ||
|
c9f486c38f | ||
|
bf86ddaa20 | ||
|
de8172673e | ||
|
6ff0a04f7c | ||
|
7e66cad998 | ||
|
9637c963f5 | ||
|
fb3f0beb42 | ||
|
0aec2bb8f2 | ||
|
da899d190e | ||
|
1e055089a3 | ||
|
29bc4b8974 | ||
|
c3412e9a08 | ||
|
842c782cee | ||
|
faeea574af | ||
|
35d25c0ce4 | ||
|
5b5a80d011 | ||
|
ab673c8527 | ||
|
1dca089149 | ||
|
3efd0c7b8d | ||
|
f3da222839 | ||
|
d25046b648 | ||
|
e61ec95deb | ||
|
cec81eef31 | ||
|
55821d021d | ||
|
6cb0aa12b8 | ||
|
e10a1457e8 | ||
|
87c9ad6fd5 | ||
|
28ab1125c2 | ||
|
c6d930a114 | ||
|
c05b6f800a | ||
|
540e1c70cc | ||
|
180c0d70c4 | ||
|
6a47e35065 | ||
|
07e62084bb | ||
|
381b4b0c91 | ||
|
0e1bd23025 | ||
|
2cf8d24131 | ||
|
fa4d036424 | ||
|
4f26a52908 | ||
|
553fe132d4 | ||
|
aa6f4241f8 | ||
|
b58ea057fe | ||
|
4b8d75e2e6 | ||
|
f446e58e45 | ||
|
6817407d49 | ||
|
365f8fb0dd | ||
|
ed0ae62ad7 | ||
|
ca279b80e6 | ||
|
c4ac5ac9d7 | ||
|
7f01ef171f | ||
|
e63c7e0893 | ||
|
25ea5ea27e | ||
|
4e53ce81cf | ||
|
3c1c999226 | ||
|
313d50e903 | ||
|
b85d4d61a7 | ||
|
33eac56e4a | ||
|
6774f32adb | ||
|
21bcb2e1f6 | ||
|
cfd0011f2f | ||
|
8b34b7da41 | ||
|
085d7d59f0 | ||
|
12fd8faa5d | ||
|
29796b62bd | ||
|
e71a33bbf8 | ||
|
f68067e101 | ||
|
9854a17f29 | ||
|
21625d729c | ||
|
675f7f627b | ||
|
32fbbf38b4 | ||
|
a127537efb | ||
|
fbc4929185 | ||
|
efcfdbd4d1 | ||
|
292a80466d | ||
|
5e80c62f31 | ||
|
197af3dc32 | ||
|
824dcd4399 | ||
|
761728afe8 | ||
|
f183a2d7ea | ||
|
a2786a97d7 | ||
|
f1390a3424 | ||
|
e80d901d98 | ||
|
6df328e84d | ||
|
064ae479a7 | ||
|
36a0ee199d | ||
|
15b3bd1689 | ||
|
cc6a08b2a0 | ||
|
fce8409cbb | ||
|
9fe3e2efc3 | ||
|
0020d1022f | ||
|
ef0cc9db54 | ||
|
aa9d22a1c0 | ||
|
99902198de | ||
|
5186ae9bbe | ||
|
308be21c2f | ||
|
c2a261f493 | ||
|
75d4ed968d | ||
|
c18c75b0b7 | ||
|
afbf7c7e6b | ||
|
d8d07b2a8a | ||
|
0cc9419631 | ||
|
059376c855 | ||
|
ff0cc92757 | ||
|
bc18ac45a3 | ||
|
da46353056 | ||
|
13e3b21b16 | ||
|
7aaefcbe48 | ||
|
f6803de739 | ||
|
e382efc85d | ||
|
6cfe2114f1 | ||
|
fd89396012 | ||
|
7c86e10193 | ||
|
740a8b0b66 | ||
|
ef64cda978 | ||
|
3ed1acd13c | ||
|
b7aeac0de1 | ||
|
79fb4527ca | ||
|
29925c6dcd | ||
|
e47c60443f | ||
|
11b9ef9454 | ||
|
2eeaae6cbc | ||
|
50040573d7 | ||
|
b618ac8c0b | ||
|
776bc9cf55 | ||
|
3f4826a358 | ||
|
6ec7484ae8 | ||
|
96abc6bf72 | ||
|
7b30053b26 | ||
|
29c471aafc | ||
|
6d4cf6be4e | ||
|
5a2c1ad625 | ||
|
917a5086b3 | ||
|
5d89b027ee | ||
|
502c132738 | ||
|
f958aabdf3 | ||
|
78399d23dc | ||
|
f941892829 | ||
|
6531952b3c | ||
|
c3301d038d | ||
|
aa7ddbd0ff | ||
|
760c114b24 | ||
|
10f42ddb9e | ||
|
361b60678e | ||
|
243c2dd746 | ||
|
48d65aabbc | ||
|
bd894c4705 | ||
|
174c555414 | ||
|
3d001b81c2 | ||
|
9449a4d894 | ||
|
61d31ae10d | ||
|
cc153541a2 | ||
|
501ee87180 | ||
|
00647c39de | ||
|
c177191804 | ||
|
1c1a0a23d3 | ||
|
d15059b128 | ||
|
d30806b0c5 | ||
|
9ea2315d2d | ||
|
d003877c66 | ||
|
ed490e4643 | ||
|
5620392d67 | ||
|
942ee02590 | ||
|
383ecc0374 | ||
|
b3893baf80 | ||
|
3d479b9638 | ||
|
cf490a7f81 | ||
|
5e6908944b | ||
|
bd9615bbc5 | ||
|
c0a9f554be | ||
|
6230ae7faf | ||
|
a1c2e87c4b | ||
|
fbf0f400b7 | ||
|
34af2b7194 | ||
|
c81aedeaec | ||
|
b768c48547 | ||
|
97125fb370 | ||
|
2c75ef62ea | ||
|
b35b4566c2 | ||
|
c5e6bf63e6 | ||
|
a7c2c7d6b2 | ||
|
4aa487e796 | ||
|
1f99a7514e | ||
|
f22ed0986a | ||
|
5f7d4668c4 | ||
|
7e73bc32f5 | ||
|
2043364516 | ||
|
d434019633 | ||
|
2755c798f3 | ||
|
8608079647 | ||
|
d9731b26e7 | ||
|
5e73284cee | ||
|
cf92c72797 | ||
|
5db088d70f | ||
|
01001d80e2 | ||
|
dd34fe8679 | ||
|
93b975a1d9 | ||
|
5ee684cba9 | ||
|
82f53f45d9 | ||
|
edf24e699e | ||
|
00d63aafc6 | ||
|
8e0c6fc0be | ||
|
68fc4ff1d7 | ||
|
fee9bbe475 | ||
|
a90e4c3ddf | ||
|
1b3092e4bb | ||
|
bf823b6b77 | ||
|
670e900719 | ||
|
31d2a00192 | ||
|
b4f38a4d60 | ||
|
4bbef7a644 | ||
|
d9dbb3e154 | ||
|
e1b47b68ec | ||
|
1f9def3163 | ||
|
9cfee527f6 | ||
|
3f71282850 | ||
|
72c3672857 | ||
|
0d1cd6d41c | ||
|
1bc71e32ea | ||
|
fe45343df9 | ||
|
884fdfeb22 | ||
|
4a2ef4fd88 | ||
|
6c52dd3852 | ||
|
5c1763e7b5 | ||
|
f65091c947 | ||
|
7ace638da2 | ||
|
4f22bdf3e5 | ||
|
640afdf4f2 | ||
|
452217e29a | ||
|
11e92390f6 | ||
|
b94c14114f | ||
|
8d39610037 | ||
|
fa1fe5f6f3 | ||
|
1b24e2d5a7 | ||
|
5072fd3a64 | ||
|
8b60787e85 | ||
|
d79fd74871 | ||
|
a4f4ca7767 | ||
|
ccd3e7dcef | ||
|
650d46a107 | ||
|
d265bdf81a | ||
|
aa6866d63c | ||
|
b12b13f832 | ||
|
06daf74a71 | ||
|
70570d4199 | ||
|
5c21747783 | ||
|
2f5b3c9607 | ||
|
e53ec3a862 | ||
|
6147ccba63 | ||
|
531348e814 | ||
|
e4f976b8b9 | ||
|
9ab512ad8c | ||
|
462d8f5faf | ||
|
4e7fd7ad96 | ||
|
51bfb8fc8c | ||
|
6b6760d6bc | ||
|
9742547245 | ||
|
abeca8d17d | ||
|
496aa47042 | ||
|
f3e507ef9f | ||
|
81ef03be65 | ||
|
8fa6f7363e | ||
|
3866558c98 | ||
|
f673b24017 | ||
|
d9d33b6fc8 | ||
|
b63c100677 | ||
|
309d5b6650 | ||
|
9d5853813f | ||
|
7162398778 | ||
|
fc5a7ea5de | ||
|
7aece10039 | ||
|
f94e4f216f | ||
|
a06f929362 | ||
|
62e7c033c0 | ||
|
4de6fac4da | ||
|
602dc1a638 | ||
|
bbec2fdb3a | ||
|
513325fa32 | ||
|
d6772f157a | ||
|
ea8b68e0f7 | ||
|
ff13f0ea4d | ||
|
5ef553da9a | ||
|
e713c21bd0 | ||
|
ff917003f6 | ||
|
ccea3ff8a9 | ||
|
0552abce0e | ||
|
07373512c7 | ||
|
c920d201c2 | ||
|
6d4e561e39 | ||
|
223d7cb3c7 | ||
|
bc5d480e2c | ||
|
9595d1935c | ||
|
059e901446 | ||
|
f116fcc328 | ||
|
1f208c3546 | ||
|
5ae49cf3ed | ||
|
a3e938b8da | ||
|
9f07ed00e4 | ||
|
3cec66512d | ||
|
eff9690351 | ||
|
dceae2829e | ||
|
203946e1f9 | ||
|
74b27674a8 | ||
|
a0092c51b1 | ||
|
8374ccb66f | ||
|
16183e6430 | ||
|
ce6640001d | ||
|
d70771752f | ||
|
d885ff470a | ||
|
e4e66476a9 | ||
|
f43eac3ed8 | ||
|
c171166987 | ||
|
8a2368edce | ||
|
89a3bafe04 | ||
|
272622a2e0 | ||
|
2585b74e19 | ||
|
4864aaeb02 | ||
|
f4e345c1a8 | ||
|
eb0c478b17 | ||
|
3a3bb953b6 | ||
|
eabb7e66bd | ||
|
397b807ad5 | ||
|
bb53124fca | ||
|
0bad236cfb | ||
|
46a9241248 | ||
|
811f54fa75 | ||
|
552a65e454 | ||
|
3596903068 | ||
|
271d504ed7 | ||
|
9d0ae967d4 | ||
|
f44ba11815 | ||
|
9b5dc1358a | ||
|
4f027a33b9 | ||
|
0f91310bf3 | ||
|
d90c655b05 | ||
|
99e788fe56 | ||
|
156e583a35 | ||
|
0d55346156 | ||
|
2ccd264695 | ||
|
f6507157e2 | ||
|
c410994653 | ||
|
0a097675f1 | ||
|
82258b7af3 | ||
|
04ac15fd80 | ||
|
83d3ff590d | ||
|
c807169888 | ||
|
a5bbe206a8 | ||
|
8de3dc1701 | ||
|
4f5901b265 | ||
|
629fd78f79 | ||
|
64414ea0e9 | ||
|
691ed5e54b | ||
|
5daa99d2a4 | ||
|
97c7937c65 | ||
|
95a441112e | ||
|
063f3f7fc4 | ||
|
749ed66549 | ||
|
c8e148e38c | ||
|
c0c31024a3 | ||
|
88e2dbfd10 | ||
|
8a48f35574 | ||
|
ee11842bfc | ||
|
29bff4e12d | ||
|
88f7212312 | ||
|
01a91eb657 | ||
|
b7978af693 | ||
|
cc858bfa84 | ||
|
3209c3ed0d | ||
|
5e75db12d7 | ||
|
e8673143ea | ||
|
048412473b | ||
|
21f99792a9 | ||
|
ae80d13f6d | ||
|
829da4c345 | ||
|
855ebb26d1 | ||
|
20aec24ac7 | ||
|
41a4e828d9 | ||
|
8cad795a80 | ||
|
9a78ef980d | ||
|
85e0634b54 | ||
|
42153d7858 | ||
|
483ca39bca | ||
|
d3fe7398e3 | ||
|
27cc9068ce | ||
|
cf4d4342c9 | ||
|
a27d3e43fe | ||
|
6a632de96d | ||
|
92de58f001 | ||
|
caf8010652 | ||
|
5cf7326132 | ||
|
b2ab693d68 | ||
|
eef70ff79a | ||
|
288c5396e6 | ||
|
9805e76744 | ||
|
4cc90ee0b0 | ||
|
4428e8f20f | ||
|
64f78dd6a8 | ||
|
c9db223f90 | ||
|
7edd2ecb55 | ||
|
ff81f074fb | ||
|
de03fe4a3f | ||
|
7b4d10b4a3 | ||
|
e640300602 | ||
|
6a92d98d1a | ||
|
89dc48569a | ||
|
602045fd7b | ||
|
439758353a | ||
|
f34cad0f97 | ||
|
adccb084df | ||
|
d8babcfc57 | ||
|
aa710c3e6b | ||
|
9b694589e9 | ||
|
01f2e7f62f | ||
|
392d9701e3 | ||
|
eb2a6d62f9 | ||
|
2905385744 | ||
|
58af54c767 | ||
|
c155ae1dfe | ||
|
a0d6b506cd | ||
|
356f8ea213 | ||
|
c73e07405c | ||
|
bb1bf8b3aa | ||
|
a33532f5f4 | ||
|
1ff1e89ff4 | ||
|
cec316c9eb | ||
|
8d239a6880 | ||
|
2a62cbd24b | ||
|
3a8e2776a6 | ||
|
83ca3ff384 | ||
|
2cc7dba718 | ||
|
79a340bc15 | ||
|
f2923613a4 | ||
|
d881a9c136 | ||
|
9e4bae9cca | ||
|
65a18442e5 | ||
|
0bf5dbe002 | ||
|
5b01c5e9d2 | ||
|
46b06bdb26 | ||
|
2e76f0a846 | ||
|
af1d46b68a | ||
|
bb8f7627f7 | ||
|
8473ae475f | ||
|
194bc5afbd | ||
|
8e20c417d4 | ||
|
d22079217c | ||
|
b50280e95f | ||
|
fbb71da2b9 | ||
|
1aee657b0f | ||
|
34ae99d604 | ||
|
ad2519ac6b | ||
|
962a9f2f9d | ||
|
ead0f46d5f | ||
|
0031ea7d85 | ||
|
f7159552ae | ||
|
3a2815370d | ||
|
3e1f4bc15b | ||
|
b456413d76 | ||
|
a4be104887 | ||
|
cb7ccc4b14 | ||
|
f167d0e7d5 | ||
|
fa8059a89c | ||
|
9b00fa9ac2 | ||
|
bfc02dd30f | ||
|
6579245800 | ||
|
4b4632f94c | ||
|
d6aff512fe | ||
|
464b9f4f6c | ||
|
9abf73b8cc | ||
|
a7e252026d | ||
|
60a7200c0d | ||
|
89f88058b9 | ||
|
e3b2668865 | ||
|
a7a582296b | ||
|
a90046f109 | ||
|
becb393d42 | ||
|
e55b771a1e | ||
|
39adc30250 | ||
|
c968d3d410 | ||
|
b78fb7abaf | ||
|
6232438acb | ||
|
885afd59ec | ||
|
2c1f975852 | ||
|
901c1bb402 | ||
|
0831ef5038 | ||
|
cc6a141dc1 | ||
|
464b82b1e6 | ||
|
865f88afc0 | ||
|
49f82803cc | ||
|
60417b646d | ||
|
57d9531cd6 | ||
|
c0551f0a46 | ||
|
a7a89e362b | ||
|
0560d81ce9 | ||
|
00cdc0a472 | ||
|
200736ebd8 | ||
|
cc0c8b2248 | ||
|
ef264c2971 | ||
|
d4f7e4cc01 | ||
|
b2a3a8554a | ||
|
e7e4181361 | ||
|
2a9950dcb3 | ||
|
2cbfbcd972 | ||
|
33ae886bbd | ||
|
aed4f2cc2c | ||
|
05dab5eaa2 | ||
|
1fbb1c8d78 | ||
|
a5011d9753 | ||
|
cefc983bec | ||
|
12ef1fbefc | ||
|
a328e469d3 | ||
|
fe1d01cb39 | ||
|
8627bf1452 | ||
|
77b862a849 | ||
|
aff8e204d2 | ||
|
ed7fbad206 | ||
|
4720cd0050 | ||
|
c9795c6ca2 | ||
|
bce82efe1f | ||
|
aeda4c589a | ||
|
696fe3f52e | ||
|
c34d026eb0 | ||
|
de90bbd0b7 | ||
|
d214138910 | ||
|
89433fef0d | ||
|
b4d9c0048f | ||
|
9a94dae4c2 | ||
|
183abbcd6b | ||
|
0536268267 |
28
Makefile
28
Makefile
@@ -92,6 +92,7 @@ linux-alpha-static \
|
||||
linux-debug \
|
||||
linux-directfb \
|
||||
linux-dri \
|
||||
linux-dri-debug \
|
||||
linux-dri-x86 \
|
||||
linux-dri-x86-64 \
|
||||
linux-dri-ppc \
|
||||
@@ -154,10 +155,10 @@ ultrix-gcc:
|
||||
|
||||
# Rules for making release tarballs
|
||||
|
||||
DIRECTORY = Mesa-6.5.2
|
||||
LIB_NAME = MesaLib-6.5.2
|
||||
DEMO_NAME = MesaDemos-6.5.2
|
||||
GLUT_NAME = MesaGLUT-6.5.2
|
||||
DIRECTORY = Mesa-6.5.3
|
||||
LIB_NAME = MesaLib-6.5.3
|
||||
DEMO_NAME = MesaDemos-6.5.3
|
||||
GLUT_NAME = MesaGLUT-6.5.3
|
||||
|
||||
MAIN_FILES = \
|
||||
$(DIRECTORY)/Makefile* \
|
||||
@@ -208,9 +209,6 @@ MAIN_FILES = \
|
||||
$(DIRECTORY)/src/mesa/glapi/*.[chS] \
|
||||
$(DIRECTORY)/src/mesa/glapi/descrip.mms \
|
||||
$(DIRECTORY)/src/mesa/glapi/sources \
|
||||
$(DIRECTORY)/src/mesa/array_cache/*.[ch] \
|
||||
$(DIRECTORY)/src/mesa/array_cache/descrip.mms \
|
||||
$(DIRECTORY)/src/mesa/array_cache/sources \
|
||||
$(DIRECTORY)/src/mesa/math/*.[ch] \
|
||||
$(DIRECTORY)/src/mesa/math/descrip.mms \
|
||||
$(DIRECTORY)/src/mesa/math/sources \
|
||||
@@ -230,6 +228,8 @@ MAIN_FILES = \
|
||||
$(DIRECTORY)/src/mesa/swrast_setup/*.[ch] \
|
||||
$(DIRECTORY)/src/mesa/swrast_setup/descrip.mms \
|
||||
$(DIRECTORY)/src/mesa/swrast_setup/sources \
|
||||
$(DIRECTORY)/src/mesa/vbo/*.[chS] \
|
||||
$(DIRECTORY)/src/mesa/vbo/descrip.mms \
|
||||
$(DIRECTORY)/src/mesa/tnl/*.[chS] \
|
||||
$(DIRECTORY)/src/mesa/tnl/descrip.mms \
|
||||
$(DIRECTORY)/src/mesa/tnl/sources \
|
||||
@@ -288,7 +288,16 @@ MAIN_FILES = \
|
||||
$(DIRECTORY)/windows/VC7/mesa/glu/glu.vcproj \
|
||||
$(DIRECTORY)/windows/VC7/mesa/mesa.sln \
|
||||
$(DIRECTORY)/windows/VC7/mesa/mesa/mesa.vcproj \
|
||||
$(DIRECTORY)/windows/VC7/mesa/osmesa/osmesa.vcproj
|
||||
$(DIRECTORY)/windows/VC7/mesa/osmesa/osmesa.vcproj \
|
||||
$(DIRECTORY)/windows/VC8/mesa/mesa.sln \
|
||||
$(DIRECTORY)/windows/VC8/mesa/gdi/gdi.vcproj \
|
||||
$(DIRECTORY)/windows/VC8/mesa/glu/glu.vcproj \
|
||||
$(DIRECTORY)/windows/VC8/mesa/mesa/mesa.vcproj \
|
||||
$(DIRECTORY)/windows/VC8/mesa/osmesa/osmesa.vcproj \
|
||||
$(DIRECTORY)/windows/VC8/progs/progs.sln \
|
||||
$(DIRECTORY)/windows/VC8/progs/demos/gears.vcproj \
|
||||
$(DIRECTORY)/windows/VC8/progs/glut/glut.vcproj
|
||||
|
||||
|
||||
DRI_FILES = \
|
||||
$(DIRECTORY)/include/GL/internal/dri_interface.h \
|
||||
@@ -364,6 +373,9 @@ DEMO_FILES = \
|
||||
$(DIRECTORY)/progs/samples/Makefile* \
|
||||
$(DIRECTORY)/progs/samples/README \
|
||||
$(DIRECTORY)/progs/samples/*.c \
|
||||
$(DIRECTORY)/progs/glsl/Makefile* \
|
||||
$(DIRECTORY)/progs/glsl/*.c \
|
||||
$(DIRECTORY)/progs/glsl/*.txt \
|
||||
$(DIRECTORY)/progs/windml/Makefile.ugl \
|
||||
$(DIRECTORY)/progs/windml/*.c \
|
||||
$(DIRECTORY)/progs/windml/*.bmp \
|
||||
|
11
bin/mklib
11
bin/mklib
@@ -212,15 +212,16 @@ case $ARCH in
|
||||
# finish up
|
||||
FINAL_LIBS="${LIBNAME}"
|
||||
elif [ $STATIC = 1 ] ; then
|
||||
LIBNAME="lib${LIBNAME}" # prefix with "lib"
|
||||
echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
|
||||
LIBNAME="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
|
||||
echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
|
||||
LINK="ar"
|
||||
OPTS="-ru"
|
||||
rm -f ${LIBNAME}
|
||||
# make lib
|
||||
${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
|
||||
ranlib ${LIBNAME}.a
|
||||
${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
|
||||
ranlib ${LIBNAME}
|
||||
# finish up
|
||||
FINAL_LIBS=${LIBNAME}.a
|
||||
FINAL_LIBS=${LIBNAME}
|
||||
else
|
||||
LIBNAME="lib${LIBNAME}" # prefix with "lib"
|
||||
case $ARCH in 'Linux' | 'GNU' | GNU/*)
|
||||
|
@@ -10,7 +10,7 @@ CONFIG_NAME = default
|
||||
# Version info
|
||||
MESA_MAJOR=6
|
||||
MESA_MINOR=5
|
||||
MESA_TINY=2
|
||||
MESA_TINY=3
|
||||
|
||||
# external projects. This should be useless now that we use libdrm.
|
||||
DRM_SOURCE_PATH=$(TOP)/../drm
|
||||
@@ -63,7 +63,7 @@ SRC_DIRS = mesa glu glut/glx glw
|
||||
GLU_DIRS = sgi
|
||||
DRIVER_DIRS = x11 osmesa
|
||||
# Which subdirs under $(TOP)/progs/ to enter:
|
||||
PROGRAM_DIRS = demos redbook samples xdemos
|
||||
PROGRAM_DIRS = demos redbook samples glsl xdemos
|
||||
|
||||
|
||||
# Library/program dependencies
|
||||
|
@@ -67,4 +67,4 @@ WINDOW_SYSTEM=dri
|
||||
# gamma are missing because they have not been converted to use the new
|
||||
# interface.
|
||||
DRI_DIRS = i810 i915tex i915 i965 mach64 mga r128 r200 r300 radeon s3v \
|
||||
savage sis tdfx trident unichrome ffb
|
||||
savage sis tdfx trident unichrome ffb nouveau
|
||||
|
@@ -22,7 +22,8 @@ ARCH_FLAGS ?=
|
||||
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
|
||||
-D_BSD_SOURCE -D_GNU_SOURCE \
|
||||
-DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \
|
||||
-DGLX_DIRECT_RENDERING -DHAVE_ALIAS -DUSE_XCB -DHAVE_POSIX_MEMALIGN
|
||||
-DGLX_DIRECT_RENDERING -DGLX_INDIRECT_RENDERING \
|
||||
-DHAVE_ALIAS -DUSE_XCB -DHAVE_POSIX_MEMALIGN
|
||||
|
||||
X11_INCLUDES = `pkg-config --cflags-only-I x11` `pkg-config --cflags-only-I xcb` `pkg-config --cflags-only-I x11-xcb` `pkg-config --cflags-only-I xcb-glx`
|
||||
|
||||
@@ -65,4 +66,4 @@ WINDOW_SYSTEM=dri
|
||||
# gamma are missing because they have not been converted to use the new
|
||||
# interface.
|
||||
DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon s3v \
|
||||
savage sis tdfx trident unichrome ffb
|
||||
savage sis tdfx trident unichrome ffb nouveau
|
||||
|
@@ -1,155 +1,163 @@
|
||||
File: docs/README.WIN32
|
||||
|
||||
Last updated: Mar 31, 2006 - Karl Schultz - kschultz@users.sourceforge.net
|
||||
|
||||
Quick Start
|
||||
----- -----
|
||||
|
||||
Unzip the MesaLib, MesaGLUT, and MesaDemos ZIP files into the same
|
||||
directory. The libs and demos build separately, so if you do not care
|
||||
about the demos or GLUT, you only need to unzip MesaLib. If you unzip
|
||||
more than one ZIP file, they all need to be unzipped into the same
|
||||
directory. Don't worry, you will not overwrite anything.
|
||||
|
||||
The Windows build system uses Microsoft Visual Studio. Project files
|
||||
for a specific version of Visual Studio are in their own directory in
|
||||
the top-level "windows" directory. For example, Visual Studio 6 files
|
||||
are in windows/VC6. If a directory does not exist for your version of
|
||||
Visual Studio, you can try importing the project files from an earlier
|
||||
version of Visual Studio. At this time, project files exist for
|
||||
Version 6 and Version 7. The code has been built with a beta version
|
||||
of Version 8 and it runs on 64-bit Windows. If you want to try this,
|
||||
start by importing the VC7 files and create the 64-bit targets in the
|
||||
configuration manager.
|
||||
|
||||
It is likely that the new and free Visual Studio Express can be used
|
||||
to build Mesa, but it hasn't been tried yet. Start with the VC7
|
||||
project files.
|
||||
|
||||
The project files to build the core Mesa library, Windows Mesa
|
||||
drivers, OSMesa, and GLU are in the mesa directory. The project files
|
||||
to build GLUT and some demo programs are in the progs directory.
|
||||
|
||||
Makefiles are no longer shipped or supported, but can be generated
|
||||
from the projects using Visual Studio.
|
||||
|
||||
|
||||
Windows Drivers
|
||||
------- -------
|
||||
|
||||
At this time, only the GDI driver is known to work. Most of the demos
|
||||
in progs/demos should work with this driver.
|
||||
|
||||
Source code also exists in the tree for other drivers in
|
||||
src/mesa/drivers/windows, but the status of this code is unknown.
|
||||
|
||||
The GDI driver operates basically by writing pixel spans into a DIB
|
||||
section and then blitting the DIB to the window. The driver was
|
||||
recently cleaned up and rewitten and so may have bugs or may be
|
||||
missing some functionality. The older versions of the CVS source may
|
||||
be useful in figuring out any problems, or report them to me.
|
||||
|
||||
To build Mesa with the GDI driver, build the mesa, gdi, and glu
|
||||
projects in the Visual Studio workspace found at
|
||||
|
||||
windows/VC6/mesa/mesa.dsw
|
||||
or
|
||||
windows/VC7/mesa/mesa.sln
|
||||
|
||||
The osmesa DLL can also be built with the osmesa project.
|
||||
|
||||
The build system creates a lib top-level directory and copies
|
||||
resulting LIB and DLL files to this lib directory. The files are:
|
||||
|
||||
OPENGL32.LIB, GLU32.LIB, OSMESA32.LIB
|
||||
OPENGL32.DLL, GLU32.DLL, OSMESA32.DLL
|
||||
|
||||
If the MesaDemos ZIP file was extracted, the DLL files are also copied
|
||||
to the demos directory. This facilitates running the demos as described
|
||||
below.
|
||||
|
||||
|
||||
GLUT and Demos
|
||||
---- --- -----
|
||||
|
||||
A Visual Studio workspace can be found at
|
||||
|
||||
windows/VC6/progs/progs.dsw
|
||||
or
|
||||
windows/VC7/progs/progs.sln
|
||||
|
||||
It can be used to build GLUT and a few demos. The GLUT lib and DLL
|
||||
are copied to the top-level lib directory, along with the Mesa libs.
|
||||
|
||||
The demo build system expects to find the LIB files in the top level
|
||||
lib directory, so you must build the Mesa libs first. The demo
|
||||
executables are placed in the demos directory, because some of them
|
||||
rely on data files found there. Also, the Mesa lib DLL's were copied
|
||||
there by the Mesa lib build process. Therefore, you should be able to
|
||||
simply run the demo executables from the demo directory.
|
||||
|
||||
If you want to run the demos from the Visual Studio, you may have to
|
||||
change the startup directory and explicitly state where the executables are.
|
||||
|
||||
You may also build all the demo programs by using a makefile. Go to
|
||||
the progs/demos directory and make sure you have executed VCVARS32.BAT
|
||||
or whatever setup script is appropriate for your compiler. Then,
|
||||
|
||||
nmake -f Makefile.win
|
||||
|
||||
should build all the demos.
|
||||
|
||||
|
||||
Build System Notes
|
||||
----- ------ -----
|
||||
|
||||
VC6
|
||||
---
|
||||
|
||||
Visual Studio 6 does not recognize files with the .cc extension as C++
|
||||
language files, without a lot of unnatural tweaking. So, the VC6
|
||||
build process uses custom build steps to compile these files in the
|
||||
GLU library.
|
||||
|
||||
Two additional configurations are provided, Debug x86 and Release x86
|
||||
that activate the shader code compilation by defining SLANG_86. It is
|
||||
unknown if and how this works.
|
||||
|
||||
VC7
|
||||
---
|
||||
|
||||
The above-mentioned .cc problem does not exist in this version.
|
||||
|
||||
|
||||
General
|
||||
-------
|
||||
|
||||
After building, you can copy the above DLL files to a place in your
|
||||
PATH such as $SystemRoot/SYSTEM32. If you don't like putting things
|
||||
in a system directory, place them in the same directory as the
|
||||
executable(s). Be careful about accidentially overwriting files of
|
||||
the same name in the SYSTEM32 directory.
|
||||
|
||||
The DLL files are built so that the external entry points use the
|
||||
stdcall calling convention.
|
||||
|
||||
Static LIB files are not built. The LIB files that are built with are
|
||||
the linker import files associated with the DLL files.
|
||||
|
||||
The si-glu sources are used to build the GLU libs. This was done
|
||||
mainly to get the better tessellator code.
|
||||
|
||||
To build "mangled" Mesa, add the preprocessor define USE_MGL_NAMESPACE
|
||||
to the project settings. You will also need to edit src/mesa.def to
|
||||
change all the gl* symbols to mgl*. Because this is easy to do with a
|
||||
global replace operation in a text editor, no additional mangled
|
||||
version of mesa.def is maintained or shipped.
|
||||
|
||||
If you have a Windows-related build problem or question, it is
|
||||
probably better to direct it to me (kschultz@users.sourceforge.net),
|
||||
rather than directly to the other Mesa developers. I will help you as
|
||||
much as I can. I also monitor the Mesa mailing lists and will answer
|
||||
questions in this area there as well.
|
||||
|
||||
|
||||
Karl Schultz
|
||||
File: docs/README.WIN32
|
||||
|
||||
Last updated: Apr 25, 2007 - Karl Schultz - kschultz@users.sourceforge.net
|
||||
|
||||
Quick Start
|
||||
----- -----
|
||||
|
||||
Unzip the MesaLib, MesaGLUT, and MesaDemos ZIP files into the same
|
||||
directory. The libs and demos build separately, so if you do not care
|
||||
about the demos or GLUT, you only need to unzip MesaLib. If you unzip
|
||||
more than one ZIP file, they all need to be unzipped into the same
|
||||
directory. Don't worry, you will not overwrite anything.
|
||||
|
||||
The Windows build system uses Microsoft Visual Studio. Project files
|
||||
for a specific version of Visual Studio are in their own directory in
|
||||
the top-level "windows" directory. For example, Visual Studio 8 files
|
||||
are in windows/VC8.
|
||||
|
||||
Support has been dropped for versions of Visual Studio prior to 8. The
|
||||
main reason is because Microsoft now provides a free compiler and
|
||||
developer environment. Visual Studio Express can be found at
|
||||
|
||||
http://msdn.microsoft.com/vstudio/express/visualc/default.aspx
|
||||
|
||||
You'll also need the Platform SDK. Instructions for obtaining and
|
||||
using the SDK with Visual Studio Express can be found at
|
||||
|
||||
http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/
|
||||
|
||||
If you are stuck using VC6 or VC7, you may start with these project
|
||||
files, but you may need to modify them to reflect changes in the
|
||||
Mesa source code tree. If you sucessfully update the project files,
|
||||
please submit them to the author of this document so that they may
|
||||
be included in the next distribution.
|
||||
|
||||
The project files to build the core Mesa library, Windows Mesa
|
||||
drivers, OSMesa, and GLU are in the mesa directory. The project files
|
||||
to build GLUT and some demo programs are in the progs directory.
|
||||
|
||||
Makefiles are no longer shipped or supported, but can be generated
|
||||
from the projects using Visual Studio.
|
||||
|
||||
|
||||
Windows Drivers
|
||||
------- -------
|
||||
|
||||
At this time, only the GDI driver is known to work. Most of the demos
|
||||
in progs/demos should work with this driver.
|
||||
|
||||
Source code also exists in the tree for other drivers in
|
||||
src/mesa/drivers/windows, but the status of this code is unknown.
|
||||
|
||||
The GDI driver operates basically by writing pixel spans into a DIB
|
||||
section and then blitting the DIB to the window. The driver was
|
||||
recently cleaned up and rewitten and so may have bugs or may be
|
||||
missing some functionality. The older versions of the CVS source may
|
||||
be useful in figuring out any problems, or report them to me.
|
||||
|
||||
To build Mesa with the GDI driver, build the mesa, gdi, and glu
|
||||
projects in the Visual Studio workspace found at
|
||||
|
||||
windows/VC8/mesa/mesa.sln
|
||||
|
||||
The osmesa DLL can also be built with the osmesa project.
|
||||
|
||||
The build system creates a lib top-level directory and copies
|
||||
resulting LIB and DLL files to this lib directory. The files are:
|
||||
|
||||
OPENGL32.LIB, GLU32.LIB, OSMESA32.LIB
|
||||
OPENGL32.DLL, GLU32.DLL, OSMESA32.DLL
|
||||
|
||||
If the MesaDemos ZIP file was extracted, the DLL files are also copied
|
||||
to the demos directory. This facilitates running the demos as described
|
||||
below.
|
||||
|
||||
|
||||
GLUT and Demos
|
||||
---- --- -----
|
||||
|
||||
A Visual Studio workspace can be found at
|
||||
|
||||
windows/VC8/progs/progs.sln
|
||||
|
||||
It can be used to build GLUT and a few demos. The GLUT lib and DLL
|
||||
are copied to the top-level lib directory, along with the Mesa libs.
|
||||
|
||||
The demo build system expects to find the LIB files in the top level
|
||||
lib directory, so you must build the Mesa libs first. The demo
|
||||
executables are placed in the demos directory, because some of them
|
||||
rely on data files found there. Also, the Mesa lib DLL's were copied
|
||||
there by the Mesa lib build process. Therefore, you should be able to
|
||||
simply run the demo executables from the demo directory.
|
||||
|
||||
If you want to run the demos from the Visual Studio, you may have to
|
||||
change the startup directory and explicitly state where the executables are.
|
||||
|
||||
You may also build all the demo programs by using a makefile. Go to
|
||||
the progs/demos directory and make sure you have executed VCVARS32.BAT
|
||||
or whatever setup script is appropriate for your compiler. Then,
|
||||
|
||||
nmake -f Makefile.win
|
||||
|
||||
should build all the demos.
|
||||
|
||||
|
||||
Build System Notes
|
||||
----- ------ -----
|
||||
|
||||
VC6 (not actively supported)
|
||||
---
|
||||
|
||||
Visual Studio 6 does not recognize files with the .cc extension as C++
|
||||
language files, without a lot of unnatural tweaking. So, the VC6
|
||||
build process uses custom build steps to compile these files in the
|
||||
GLU library.
|
||||
|
||||
Two additional configurations are provided, Debug x86 and Release x86
|
||||
that activate the shader code compilation by defining SLANG_86. It is
|
||||
unknown if and how this works.
|
||||
|
||||
VC7 (not actively supported)
|
||||
---
|
||||
|
||||
The above-mentioned .cc problem does not exist in this version.
|
||||
|
||||
VC8
|
||||
---
|
||||
|
||||
No notes.
|
||||
|
||||
|
||||
General
|
||||
-------
|
||||
|
||||
After building, you can copy the above DLL files to a place in your
|
||||
PATH such as $SystemRoot/SYSTEM32. If you don't like putting things
|
||||
in a system directory, place them in the same directory as the
|
||||
executable(s). Be careful about accidentially overwriting files of
|
||||
the same name in the SYSTEM32 directory.
|
||||
|
||||
The DLL files are built so that the external entry points use the
|
||||
stdcall calling convention.
|
||||
|
||||
Static LIB files are not built. The LIB files that are built with are
|
||||
the linker import files associated with the DLL files.
|
||||
|
||||
The si-glu sources are used to build the GLU libs. This was done
|
||||
mainly to get the better tessellator code.
|
||||
|
||||
To build "mangled" Mesa, add the preprocessor define USE_MGL_NAMESPACE
|
||||
to the project settings. You will also need to edit src/mesa.def to
|
||||
change all the gl* symbols to mgl*. Because this is easy to do with a
|
||||
global replace operation in a text editor, no additional mangled
|
||||
version of mesa.def is maintained or shipped.
|
||||
|
||||
If you have a Windows-related build problem or question, it is
|
||||
probably better to direct it to me (kschultz@users.sourceforge.net),
|
||||
rather than directly to the other Mesa developers. I will help you as
|
||||
much as I can. I also monitor the Mesa mailing lists and will answer
|
||||
questions in this area there as well.
|
||||
|
||||
|
||||
Karl Schultz
|
||||
|
@@ -25,6 +25,7 @@ a:visited {
|
||||
<ul>
|
||||
<li><a href="intro.html" target="MainFrame">Introduction</a>
|
||||
<li><a href="news.html" target="MainFrame">News</a>
|
||||
<LI><A HREF="developers.html" target="MainFrame">Developers</A>
|
||||
<li><a href="systems.html" target="MainFrame">Platforms and Drivers</a>
|
||||
<li><a href="license.html" target="MainFrame">License & Copyright</a>
|
||||
<li><a href="faq.html" target="MainFrame">FAQ</a>
|
||||
@@ -64,6 +65,8 @@ a:visited {
|
||||
<ul>
|
||||
<li><a href="http://sourceforge.net/projects/mesa3d" target="_parent">SourceForge homepage</a>
|
||||
<li><a href="repository.html" target="MainFrame">Source Code Repository</a>
|
||||
<li><a href="memory.html" target="MainFrame">DRI Memory Management</a>
|
||||
<li><a href="shading.html" target="MainFrame">Shading Language</a>
|
||||
<li><a href="utilities.html" target="MainFrame">Utilities</a>
|
||||
<li><a href="helpwanted.html" target="MainFrame">Help Wanted</a>
|
||||
<li><a href="devinfo.html" target="MainFrame">Development Notes</a>
|
||||
@@ -71,7 +74,6 @@ a:visited {
|
||||
<li><a href="subset.html" target="MainFrame">Subset Information</a>
|
||||
<li><a href="fbdev-dri.html" target="MainFrame">fbdev/DRI Environment</a>
|
||||
<li><a href="glfbdev-driver.html" target="MainFrame">glFBDev Driver</a>
|
||||
<LI><A HREF="custom.html" target="MainFrame">Custom Development</A>
|
||||
<LI><A HREF="dispatch.html" target="MainFrame">GL Dispatch</A>
|
||||
</ul>
|
||||
|
||||
|
@@ -1,27 +0,0 @@
|
||||
<HTML>
|
||||
|
||||
<TITLE>Custom Development</TITLE>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="mesa.css"></head>
|
||||
|
||||
<BODY>
|
||||
|
||||
<H1>Custom Development</H1>
|
||||
|
||||
<p>
|
||||
Mesa is primarily developed and maintained on a volunteer basis.
|
||||
Some Mesa development work has been done in conjuction with contracted
|
||||
projects, such as the XFree86/DRI drivers.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<pre>[Begin shameless plug]</pre>
|
||||
If you have a need for specific or custom Mesa development work,
|
||||
<a href="http://www.tungstengraphics.com/" target="_parent">
|
||||
Tungsten Graphics, Inc.</a> may be able to help you.
|
||||
<pre>[End shameless plug]</pre>
|
||||
</p>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
51
docs/developers.html
Normal file
51
docs/developers.html
Normal file
@@ -0,0 +1,51 @@
|
||||
<HTML>
|
||||
|
||||
<TITLE>Developers</TITLE>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="mesa.css"></head>
|
||||
|
||||
<BODY>
|
||||
|
||||
<H1>Developers</H1>
|
||||
|
||||
<p>
|
||||
Both professional and volunteer developers contribute to Mesa.
|
||||
</p>
|
||||
<p>
|
||||
<a href="http://www.tungstengraphics.com/" target="_parent">Tungsten Graphics</a>
|
||||
employs several of the main Mesa developers including Brian Paul
|
||||
and Keith Whitwell.
|
||||
Much of the on-going work in Mesa is done through Tungsten Graphics engineering
|
||||
contracts.
|
||||
Prominent examples of this work includes:
|
||||
</p>
|
||||
<ul>
|
||||
<li>DRI drivers for Intel i965, i945, i915 and other chips
|
||||
<li>Advanced memory manager and framebuffer object support
|
||||
<li>Shading language compiler and OpenGL 2.0 support
|
||||
<li>MiniGLX environment
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
Other companies including
|
||||
<a href="http://www.intellinuxgraphics.org/index.html" target="_parent">Intel</a>
|
||||
and IBM also actively contribute to the project.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Volunteers have made significant contributions to all parts of Mesa, including
|
||||
complete device drivers.
|
||||
</p>
|
||||
|
||||
|
||||
<H1>Custom Development</H1>
|
||||
<p>
|
||||
Contact <a href="http://www.tungstengraphics.com/" target="_parent">
|
||||
Tungsten Graphics</a>
|
||||
for information about custom development in Mesa, OpenGL, X and other
|
||||
graphics technologies.
|
||||
</p>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -9,7 +9,7 @@
|
||||
<H1>Downloading</H1>
|
||||
|
||||
<p>
|
||||
Last development release: <b>6.5.2</b>
|
||||
Last development release: <b>6.5.3</b>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
@@ -9,35 +9,31 @@
|
||||
<H1>Introduction</H1>
|
||||
|
||||
<p>
|
||||
Mesa is a 3-D graphics library with an API which is very similar to
|
||||
that of <a href="http://www.opengl.org/" target="_parent">OpenGL</a>.*
|
||||
To the extent that Mesa utilizes the OpenGL command syntax or state
|
||||
machine, it is being used with authorization from <a
|
||||
href="http://www.sgi.com/" target="_parent">Silicon Graphics,
|
||||
Inc.</a>(SGI). However, the author does not possess an OpenGL license
|
||||
from SGI, and makes no claim that Mesa is in any way a compatible
|
||||
replacement for OpenGL or associated with SGI. Those who want a
|
||||
licensed implementation of OpenGL should contact a licensed
|
||||
vendor.
|
||||
Mesa is an open-source implementation of the
|
||||
<a href="http://www.opengl.org/" target="_parent">OpenGL</a> specification -
|
||||
a system for rendering interactive 3D graphics.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Please do not refer to the library as <em>MesaGL</em> (for legal
|
||||
reasons). It's just <em>Mesa</em> or <em>The Mesa 3-D graphics
|
||||
library</em>. <br>
|
||||
A variety of device drivers allows Mesa to be used in many different
|
||||
environments ranging from software emulation to complete hardware acceleration
|
||||
for modern GPUs.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
* OpenGL is a trademark of <a href="http://www.sgi.com/"
|
||||
target="_parent">Silicon Graphics Incorporated</a>.
|
||||
Mesa ties into several other open-source projects: the
|
||||
<a href="http://dri.sf.net/" target="_parent">Direct Rendering Infrastructure</a>
|
||||
and <a href="http://x.org" target="_parent">X.org</a> to provide OpenGL
|
||||
support to users of X on Linux, FreeBSD and other operating systems.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<H1>Project History</H1>
|
||||
|
||||
<p>
|
||||
The Mesa project was founded by me, Brian Paul. Here's a short history
|
||||
of the project.
|
||||
The Mesa project was originally started by Brian Paul.
|
||||
Here's a short history of the project.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
@@ -6,6 +6,34 @@
|
||||
|
||||
<BODY>
|
||||
|
||||
<H1>Disclaimer</H1>
|
||||
|
||||
<p>
|
||||
Mesa is a 3-D graphics library with an API which is very similar to
|
||||
that of <a href="http://www.opengl.org/" target="_parent">OpenGL</a>.*
|
||||
To the extent that Mesa utilizes the OpenGL command syntax or state
|
||||
machine, it is being used with authorization from <a
|
||||
href="http://www.sgi.com/" target="_parent">Silicon Graphics,
|
||||
Inc.</a>(SGI). However, the author does not possess an OpenGL license
|
||||
from SGI, and makes no claim that Mesa is in any way a compatible
|
||||
replacement for OpenGL or associated with SGI. Those who want a
|
||||
licensed implementation of OpenGL should contact a licensed
|
||||
vendor.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Please do not refer to the library as <em>MesaGL</em> (for legal
|
||||
reasons). It's just <em>Mesa</em> or <em>The Mesa 3-D graphics
|
||||
library</em>. <br>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
* OpenGL is a trademark of <a href="http://www.sgi.com/"
|
||||
target="_parent">Silicon Graphics Incorporated</a>.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<H1>License / Copyright Information</H1>
|
||||
|
||||
<p>
|
||||
@@ -24,7 +52,7 @@ The default Mesa license is as follows:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
|
||||
Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
|
@@ -11,6 +11,33 @@
|
||||
<H1>News</H1>
|
||||
|
||||
|
||||
<h2>April 27, 2007</h2>
|
||||
<p>
|
||||
<a href="relnotes-6.5.3.html">Mesa 6.5.3</a> is released.
|
||||
This is a development release which will lead up to the Mesa 7.0 release
|
||||
(which will advertise OpenGL 2.1 API support).
|
||||
</p>
|
||||
|
||||
|
||||
<h2>March 26, 2007</h2>
|
||||
<p>
|
||||
The new Shading Language compiler branch has been merged into the git
|
||||
master branch. This is a step toward hardware support for the OpenGL
|
||||
2.0 Shading Language and will be included in the next Mesa release.
|
||||
In conjunction, <a href="http://glean.sf.net" target="_parent">Glean
|
||||
</a> has been updated with a new test that does over 130 tests of the
|
||||
shading language and built-in functions.
|
||||
</p>
|
||||
|
||||
<h2>April 2007</h2>
|
||||
<p>
|
||||
Thomas Hellström of
|
||||
<a href="http://www.tungstengraphics.com" target="_parent">
|
||||
Tungsten Graphics</a> has written a whitepaper describing the new
|
||||
<a href="http://www.tungstengraphics.com/mm.pdf">DRI memory management
|
||||
system</a>.
|
||||
</p>
|
||||
|
||||
<h2>December 5, 2006</h2>
|
||||
<p>
|
||||
Mesa is now using git as its source code management system.
|
||||
|
@@ -8,11 +8,11 @@
|
||||
|
||||
<body bgcolor="#eeeeee">
|
||||
|
||||
<H1>Mesa 6.5.3 Release Notes / (in progress)</H1>
|
||||
<H1>Mesa 6.5.3 Release Notes / April 27, 2007</H1>
|
||||
|
||||
<p>
|
||||
Mesa 6.5.3 is a 6.5 follow-on development release mostly consisting of
|
||||
bug fixes</a>.
|
||||
Mesa 6.5.3 is a development release with many changes and new features.
|
||||
Mesa 7.0 is expected to follow shortly.
|
||||
</p>
|
||||
|
||||
|
||||
@@ -22,10 +22,33 @@ TBD
|
||||
</pre>
|
||||
|
||||
|
||||
<h2>Shared library numbering</h2>
|
||||
<p>
|
||||
Mesa 6.5.3 supports the OpenGL 2.0/2.1 API. However, the (unix)
|
||||
shared library version is still 1.5 (i.e. libGL.so.1.5.xxxxxx).
|
||||
Bumping the shared library version to 2.x would cause linking problems
|
||||
with existing OpenGL applications. Since OpenGL 2.x is backward
|
||||
compatible with OpenGL 1.x the shared library version number doesn't
|
||||
have to be incremented (which would indicate an incompatible ABI).
|
||||
</p>
|
||||
<p>
|
||||
Other OpenGL vendors name their OpenGL 2.x libraries libGL.so.1.0.xxxxx
|
||||
for the same reason.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<h2>New features</h2>
|
||||
<ul>
|
||||
<li>OpenGL 2.0 and 2.1 API support.
|
||||
<li>Entirely new Shading Language code generator. See the
|
||||
<a href="shading.html">Shading Language</a> page for more information.
|
||||
<li>Much faster software execution of vertex, fragment shaders.
|
||||
<li>New vertex buffer object (vbo) infrastructure
|
||||
<li>Updated glext.h file (version 39)
|
||||
<li>Updated glxext.h file (version 18)
|
||||
<li>Updated glxext.h file (version 19)
|
||||
<li>GL_MAX_DRAWBUFFERS is now 4 (software rendering) so
|
||||
"multiple render targets" are really supported.
|
||||
</ul>
|
||||
|
||||
<h2>Bug fixes</h2>
|
||||
@@ -33,27 +56,33 @@ TBD
|
||||
<li>Fog was errantly applied when a fragment shader was enabled (bug 9346)
|
||||
<li>glPush/PopClientAttrib didn't handle VBO bindings correctly (bug 9445)
|
||||
<li>With 32-bit Z buffer, the fragment Z of lines and points was sometimes wrong.
|
||||
<li>GL_POST_CONVOLUTION_ALPHA_BIAS/SCALE was broken.
|
||||
<li>1D convolution state could effect 2D image transfers
|
||||
<li>Overlapping glCopyPixels with negative Y zoom didn't work (bug 10521)
|
||||
<li>Fixed a number of framebuffer/renderbuffer reference counting bugs
|
||||
<li>Fixed a few bugs in software-emulated alpha planes
|
||||
<li>Assorted minor bug fixes in glCopy/DrawPixels, glPixelZoom, etc.
|
||||
<li>Assorted DRI driver bug fixes.
|
||||
<li>Fixed a number of bugs that prevented "depth-peeling" rendering from working.
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Internal code changes</h2>
|
||||
|
||||
<ul>
|
||||
<li>The _MaintainTnlProgram, _MaintainTexEnvProgram, _TexEnvProgram and
|
||||
_TnlProgram fields have been moved.
|
||||
<li>The ctx->FragmentProgram._Active field has been removed.
|
||||
<li>The ctx->Vertex/FragmentProgram._Current fields point to the program
|
||||
in effect, whether it comes from a shader, user-program or generated
|
||||
fixed-function program.
|
||||
<li>The _UseTexEnvProgram field has been removed.
|
||||
<li>Old array_cache module replaced by new vbo module. All geometry
|
||||
rendering is now cast in the form of vertex buffer objects.
|
||||
<li>Massive changes to the Shading Language compiler and related state.
|
||||
<li>Vertex/fragment shaders are compiled into GPU instructions and
|
||||
programs very similar to GL_ARB_vertex/fragment_program.
|
||||
<li>Vertex and fragment programs are executed with the same code now.
|
||||
<li>The SSE-optimized vertex program path has been removed since it didn't
|
||||
support more than 12 temp registers, didn't support branching/looping, etc.
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>To Do (someday) items</h2>
|
||||
<ul>
|
||||
<li>Switch to freeglut
|
||||
<li>Increase MAX_DRAWBUFFERS
|
||||
<li>Fix linux-glide target/driver.
|
||||
<li>Improved lambda and derivative calculation for frag progs.
|
||||
</ul>
|
||||
@@ -65,17 +94,17 @@ fixed-function program.
|
||||
Driver Status
|
||||
---------------------- ----------------------
|
||||
DRI drivers varies with the driver
|
||||
XMesa/GLX (on Xlib) implements OpenGL 1.5
|
||||
OSMesa (off-screen) implements OpenGL 1.5
|
||||
XMesa/GLX (on Xlib) implements OpenGL 2.1
|
||||
OSMesa (off-screen) implements OpenGL 2.1
|
||||
Windows/Win32 implements OpenGL 2.1
|
||||
Glide (3dfx Voodoo1/2) implements OpenGL 1.3
|
||||
SVGA implements OpenGL 1.3
|
||||
Wind River UGL implements OpenGL 1.3
|
||||
Windows/Win32 implements OpenGL 1.5
|
||||
DJGPP implements OpenGL 1.5
|
||||
GGI implements OpenGL 1.3
|
||||
BeOS implements OpenGL 1.5
|
||||
Allegro needs updating
|
||||
D3D needs updating
|
||||
SVGA unsupported
|
||||
Wind River UGL unsupported
|
||||
DJGPP unsupported
|
||||
GGI unsupported
|
||||
BeOS unsupported
|
||||
Allegro unsupported
|
||||
D3D unsupported
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
|
312
docs/shading.html
Normal file
312
docs/shading.html
Normal file
@@ -0,0 +1,312 @@
|
||||
<HTML>
|
||||
|
||||
<TITLE>Shading Language Support</TITLE>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="mesa.css"></head>
|
||||
|
||||
<BODY>
|
||||
|
||||
<H1>Shading Language Support</H1>
|
||||
|
||||
<p>
|
||||
This page describes the features and status of Mesa's support for the
|
||||
<a href="http://opengl.org/documentation/glsl/" target="_parent">
|
||||
OpenGL Shading Language</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Last updated on 28 March 2007.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Contents
|
||||
</p>
|
||||
<ul>
|
||||
<li><a href="#unsup">Unsupported Features</a>
|
||||
<li><a href="#notes">Implementation Notes</a>
|
||||
<li><a href="#hints">Programming Hints</a>
|
||||
<li><a href="#standalone">Stand-alone Compiler</a>
|
||||
<li><a href="#implementation">Compiler Implementation</a>
|
||||
<li><a href="#validation">Compiler Validation</a>
|
||||
</ul>
|
||||
|
||||
|
||||
<a name="unsup">
|
||||
<h2>Unsupported Features</h2>
|
||||
|
||||
<p>
|
||||
The following features of the shading language are not yet supported
|
||||
in Mesa:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>Dereferencing arrays with non-constant indexes
|
||||
<li>Comparison of user-defined structs
|
||||
<li>Linking of multiple shaders is not supported
|
||||
<li>gl_ClipVertex
|
||||
<li>The derivative functions such as dFdx() are not implemented
|
||||
<li>The inverse trig functions asin(), acos(), and atan() are not implemented
|
||||
<li>The gl_Color and gl_SecondaryColor varying vars are interpolated
|
||||
without perspective correction
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
All other major features of the shading language should function.
|
||||
</p>
|
||||
|
||||
|
||||
<a name="notes">
|
||||
<h2>Implementation Notes</h2>
|
||||
|
||||
<ul>
|
||||
<li>Shading language programs are compiled into low-level programs
|
||||
very similar to those of GL_ARB_vertex/fragment_program.
|
||||
<li>All vector types (vec2, vec3, vec4, bvec2, etc) currently occupy full
|
||||
float[4] registers.
|
||||
<li>Float constants and variables are packed so that up to four floats
|
||||
can occupy one program parameter/register.
|
||||
<li>All function calls are inlined.
|
||||
<li>Shaders which use too many registers will not compile.
|
||||
<li>The quality of generated code is pretty good, register usage is fair.
|
||||
<li>Shader error detection and reporting of errors (InfoLog) is not
|
||||
very good yet.
|
||||
<li>The ftransform() function doesn't necessarily match the results of
|
||||
fixed-function transformation.
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
These issues will be addressed/resolved in the future.
|
||||
</p>
|
||||
|
||||
|
||||
<a name="hints">
|
||||
<h2>Programming Hints</h2>
|
||||
|
||||
<ul>
|
||||
<li>Declare <em>in</em> function parameters as <em>const</em> whenever possible.
|
||||
This improves the efficiency of function inlining.
|
||||
</li>
|
||||
<br>
|
||||
<li>To reduce register usage, declare variables within smaller scopes.
|
||||
For example, the following code:
|
||||
<pre>
|
||||
void main()
|
||||
{
|
||||
vec4 a1, a2, b1, b2;
|
||||
gl_Position = expression using a1, a2.
|
||||
gl_Color = expression using b1, b2;
|
||||
}
|
||||
</pre>
|
||||
Can be rewritten as follows to use half as many registers:
|
||||
<pre>
|
||||
void main()
|
||||
{
|
||||
{
|
||||
vec4 a1, a2;
|
||||
gl_Position = expression using a1, a2.
|
||||
}
|
||||
{
|
||||
vec4 b1, b2;
|
||||
gl_Color = expression using b1, b2;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
Alternately, rather than using several float variables, use
|
||||
a vec4 instead. Use swizzling and writemasks to access the
|
||||
components of the vec4 as floats.
|
||||
</li>
|
||||
<br>
|
||||
<li>Use the built-in library functions whenever possible.
|
||||
For example, instead of writing this:
|
||||
<pre>
|
||||
float x = 1.0 / sqrt(y);
|
||||
</pre>
|
||||
Write this:
|
||||
<pre>
|
||||
float x = inversesqrt(y);
|
||||
</pre>
|
||||
<li>
|
||||
Use ++i when possible as it's more efficient than i++
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<a name="standalone">
|
||||
<h2>Stand-alone Compiler</h2>
|
||||
|
||||
<p>
|
||||
A unique stand-alone GLSL compiler driver has been added to Mesa.
|
||||
<p>
|
||||
|
||||
<p>
|
||||
The stand-alone compiler (like a conventional command-line compiler)
|
||||
is a tool that accepts Shading Language programs and emits low-level
|
||||
GPU programs.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
This tool is useful for:
|
||||
<p>
|
||||
<ul>
|
||||
<li>Inspecting GPU code to gain insight into compilation
|
||||
<li>Generating initial GPU code for subsequent hand-tuning
|
||||
<li>Debugging the GLSL compiler itself
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
To build the glslcompiler program (this will be improved someday):
|
||||
</p>
|
||||
<pre>
|
||||
cd src/mesa
|
||||
make libmesa.a
|
||||
cd drivers/glslcompiler
|
||||
make
|
||||
</pre>
|
||||
|
||||
|
||||
<p>
|
||||
Here's an example of using the compiler to compile a vertex shader and
|
||||
emit GL_ARB_vertex_program-style instructions:
|
||||
</p>
|
||||
<pre>
|
||||
glslcompiler --arb --linenumbers --vs vertshader.txt
|
||||
</pre>
|
||||
<p>
|
||||
The output may look similar to this:
|
||||
</p>
|
||||
<pre>
|
||||
!!ARBvp1.0
|
||||
0: MOV result.texcoord[0], vertex.texcoord[0];
|
||||
1: DP4 temp0.x, state.matrix.mvp.row[0], vertex.position;
|
||||
2: DP4 temp0.y, state.matrix.mvp.row[1], vertex.position;
|
||||
3: DP4 temp0.z, state.matrix.mvp.row[2], vertex.position;
|
||||
4: DP4 temp0.w, state.matrix.mvp.row[3], vertex.position;
|
||||
5: MOV result.position, temp0;
|
||||
6: END
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Note that some shading language constructs (such as uniform and varying
|
||||
variables) aren't expressible in ARB or NV-style programs.
|
||||
Therefore, the resulting output is not always legal by definition of
|
||||
those program languages.
|
||||
</p>
|
||||
<p>
|
||||
Also note that this compiler driver is still under development.
|
||||
Over time, the correctness of the GPU programs, with respect to the ARB
|
||||
and NV languagues, should improve.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<a name="implementation">
|
||||
<h2>Compiler Implementation</h2>
|
||||
|
||||
<p>
|
||||
The source code for Mesa's shading language compiler is in the
|
||||
<code>src/mesa/shader/slang/</code> directory.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The compiler follows a fairly standard design and basically works as follows:
|
||||
</p>
|
||||
<ul>
|
||||
<li>The input string is tokenized (see grammar.c) and parsed
|
||||
(see slang_compiler_*.c) to produce an Abstract Syntax Tree (AST).
|
||||
The nodes in this tree are slang_operation structures
|
||||
(see slang_compile_operation.h).
|
||||
The nodes are decorated with symbol table, scoping and datatype information.
|
||||
<li>The AST is converted into an Intermediate representation (IR) tree
|
||||
(see the slang_codegen.c file).
|
||||
The IR nodes represent basic GPU instructions, like add, dot product,
|
||||
move, etc.
|
||||
The IR tree is mostly a binary tree, but a few nodes have three or four
|
||||
children.
|
||||
In principle, the IR tree could be executed by doing an in-order traversal.
|
||||
<li>The IR tree is traversed in-order to emit code (see slang_emit.c).
|
||||
This is also when registers are allocated to store variables and temps.
|
||||
<li>In the future, a pattern-matching code generator-generator may be
|
||||
used for code generation.
|
||||
Programs such as L-BURG (Bottom-Up Rewrite Generator) and Twig look for
|
||||
patterns in IR trees, compute weights for subtrees and use the weights
|
||||
to select the best instructions to represent the sub-tree.
|
||||
<li>The emitted GPU instructions (see prog_instruction.h) are stored in a
|
||||
gl_program object (see mtypes.h).
|
||||
<li>When a fragment shader and vertex shader are linked (see slang_link.c)
|
||||
the varying vars are matched up, uniforms are merged, and vertex
|
||||
attributes are resolved (rewriting instructions as needed).
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
The final vertex and fragment programs may be interpreted in software
|
||||
(see prog_execute.c) or translated into a specific hardware architecture
|
||||
(see drivers/dri/i915/i915_fragprog.c for example).
|
||||
</p>
|
||||
|
||||
<h3>Code Generation Options</h3>
|
||||
|
||||
<p>
|
||||
Internally, there are several options that control the compiler's code
|
||||
generation and instruction selection.
|
||||
These options are seen in the gl_shader_state struct and may be set
|
||||
by the device driver to indicate its preferences:
|
||||
|
||||
<pre>
|
||||
struct gl_shader_state
|
||||
{
|
||||
...
|
||||
/** Driver-selectable options: */
|
||||
GLboolean EmitHighLevelInstructions;
|
||||
GLboolean EmitCondCodes;
|
||||
GLboolean EmitComments;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<ul>
|
||||
<li>EmitHighLevelInstructions
|
||||
<br>
|
||||
This option controls instruction selection for loops and conditionals.
|
||||
If the option is set high-level IF/ELSE/ENDIF, LOOP/ENDLOOP, CONT/BRK
|
||||
instructions will be emitted.
|
||||
Otherwise, those constructs will be implemented with BRA instructions.
|
||||
</li>
|
||||
|
||||
<li>EmitCondCodes
|
||||
<br>
|
||||
If set, condition codes (ala GL_NV_fragment_program) will be used for
|
||||
branching and looping.
|
||||
Otherwise, ordinary registers will be used (the IF instruction will
|
||||
examine the first operand's X component and do the if-part if non-zero).
|
||||
This option is only relevant if EmitHighLevelInstructions is set.
|
||||
</li>
|
||||
|
||||
<li>EmitComments
|
||||
<br>
|
||||
If set, instructions will be annoted with comments to help with debugging.
|
||||
Extra NOP instructions will also be inserted.
|
||||
</br>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<a name="validation">
|
||||
<h2>Compiler Validation</h2>
|
||||
|
||||
<p>
|
||||
A new <a href="http://glean.sf.net" target="_parent">Glean</a> test has
|
||||
been create to exercise the GLSL compiler.
|
||||
</p>
|
||||
<p>
|
||||
The <em>glsl1</em> test runs over 150 sub-tests to check that the language
|
||||
features and built-in functions work properly.
|
||||
This test should be run frequently while working on the compiler to catch
|
||||
regressions.
|
||||
</p>
|
||||
<p>
|
||||
The test coverage is reasonably broad and complete but additional tests
|
||||
should be added.
|
||||
</p>
|
||||
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
@@ -42,7 +42,7 @@ WIDTH="88" HEIGHT="31" ALIGN="BOTTOM" ALT="Sourceforge.net" BORDER="0"></A>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<li>The Mesa CVS repository is hosted by
|
||||
<li>The Mesa git repository is hosted by
|
||||
<a href="http://freedesktop.org/" target="_parent">freedesktop.org</a>.
|
||||
<br>
|
||||
<br>
|
||||
|
@@ -27,10 +27,6 @@
|
||||
#define MANGLE(x) mgl##x
|
||||
#endif /*MANGLE*/
|
||||
|
||||
/* Internal symbols which may collide with other OpenGL implementations. */
|
||||
#define __glCoreCreateContext __mglCoreCreateContext
|
||||
#define __glCoreNopDispatch __mglCoreNopDispatch
|
||||
|
||||
/*REGENERATE_TO_END-----------ALL LINES BELOW HERE GET REPLACED ON REGENERATION */
|
||||
|
||||
#define glAccum MANGLE(Accum)
|
||||
|
@@ -46,9 +46,9 @@ extern "C" {
|
||||
/*************************************************************/
|
||||
|
||||
/* Header file version number, required by OpenGL ABI for Linux */
|
||||
/* glxext.h last updated 2007/02/13 */
|
||||
/* glxext.h last updated 2007/04/21 */
|
||||
/* Current version at http://www.opengl.org/registry/ */
|
||||
#define GLX_GLXEXT_VERSION 18
|
||||
#define GLX_GLXEXT_VERSION 19
|
||||
|
||||
#ifndef GLX_VERSION_1_3
|
||||
#define GLX_WINDOW_BIT 0x00000001
|
||||
@@ -386,7 +386,7 @@ typedef struct {
|
||||
/* (as used in the GLX_OML_sync_control extension). */
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
#include <inttypes.h>
|
||||
#elif defined(__sun__)
|
||||
#elif defined(__sun__) || defined(__digital__)
|
||||
#include <inttypes.h>
|
||||
#if defined(__STDC__)
|
||||
#if defined(__arch64__)
|
||||
|
@@ -38,17 +38,11 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef CAPI
|
||||
#undef CAPI
|
||||
#endif
|
||||
#define CAPI
|
||||
|
||||
#define GL_CORE_SGI 1
|
||||
#define GL_CORE_MESA 2
|
||||
#define GL_CORE_APPLE 4
|
||||
|
||||
typedef struct __GLcontextRec __GLcontext;
|
||||
typedef struct __GLinterfaceRec __GLinterface;
|
||||
|
||||
/*
|
||||
** This file defines the interface between the GL core and the surrounding
|
||||
@@ -186,81 +180,4 @@ typedef struct __GLcontextModesRec {
|
||||
#define GLX_TEXTURE_2D_BIT_EXT 0x00000002
|
||||
#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/*
|
||||
** Procedures which are imported by the GL from the surrounding
|
||||
** "operating system". Math functions are not considered part of the
|
||||
** "operating system".
|
||||
*/
|
||||
typedef struct __GLimportsRec {
|
||||
/* Memory management */
|
||||
void * (*malloc)(__GLcontext *gc, size_t size);
|
||||
void *(*calloc)(__GLcontext *gc, size_t numElem, size_t elemSize);
|
||||
void *(*realloc)(__GLcontext *gc, void *oldAddr, size_t newSize);
|
||||
void (*free)(__GLcontext *gc, void *addr);
|
||||
|
||||
/* Error handling */
|
||||
void (*warning)(__GLcontext *gc, char *fmt);
|
||||
void (*fatal)(__GLcontext *gc, char *fmt);
|
||||
|
||||
/* other system calls */
|
||||
char *(CAPI *getenv)(__GLcontext *gc, const char *var);
|
||||
int (CAPI *atoi)(__GLcontext *gc, const char *str);
|
||||
int (CAPI *sprintf)(__GLcontext *gc, char *str, const char *fmt, ...);
|
||||
void *(CAPI *fopen)(__GLcontext *gc, const char *path, const char *mode);
|
||||
int (CAPI *fclose)(__GLcontext *gc, void *stream);
|
||||
int (CAPI *fprintf)(__GLcontext *gc, void *stream, const char *fmt, ...);
|
||||
|
||||
/* Drawing surface management */
|
||||
void *(*getDrawablePrivate)(__GLcontext *gc);
|
||||
void *(*getReadablePrivate)(__GLcontext *gc);
|
||||
|
||||
/* Operating system dependent data goes here */
|
||||
void *other;
|
||||
} __GLimports;
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/*
|
||||
** Procedures which are exported by the GL to the surrounding "operating
|
||||
** system" so that it can manage multiple GL context's.
|
||||
*/
|
||||
typedef struct __GLexportsRec {
|
||||
/* Context management (return GL_FALSE on failure) */
|
||||
GLboolean (*destroyContext)(__GLcontext *gc);
|
||||
GLboolean (*loseCurrent)(__GLcontext *gc);
|
||||
/* oldglPriv isn't used anymore, kept for backwards compatibility */
|
||||
GLboolean (*makeCurrent)(__GLcontext *gc);
|
||||
GLboolean (*shareContext)(__GLcontext *gc, __GLcontext *gcShare);
|
||||
GLboolean (*copyContext)(__GLcontext *dst, const __GLcontext *src, GLuint mask);
|
||||
GLboolean (*forceCurrent)(__GLcontext *gc);
|
||||
|
||||
/* Drawing surface notification callbacks */
|
||||
GLboolean (*notifyResize)(__GLcontext *gc);
|
||||
void (*notifyDestroy)(__GLcontext *gc);
|
||||
void (*notifySwapBuffers)(__GLcontext *gc);
|
||||
|
||||
/* Dispatch table override control for external agents like libGLS */
|
||||
struct __GLdispatchStateRec* (*dispatchExec)(__GLcontext *gc);
|
||||
void (*beginDispatchOverride)(__GLcontext *gc);
|
||||
void (*endDispatchOverride)(__GLcontext *gc);
|
||||
} __GLexports;
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/*
|
||||
** This must be the first member of a __GLcontext structure. This is the
|
||||
** only part of a context that is exposed to the outside world; everything
|
||||
** else is opaque.
|
||||
*/
|
||||
struct __GLinterfaceRec {
|
||||
__GLimports imports;
|
||||
__GLexports exports;
|
||||
};
|
||||
|
||||
extern __GLcontext *__glCoreCreateContext(__GLimports *, __GLcontextModes *);
|
||||
extern void __glCoreNopDispatch(void);
|
||||
|
||||
#endif /* __gl_core_h_ */
|
||||
|
@@ -180,6 +180,21 @@ extern XMesaContext XMesaCreateContext( XMesaVisual v,
|
||||
extern void XMesaDestroyContext( XMesaContext c );
|
||||
|
||||
|
||||
#ifdef XFree86Server
|
||||
/*
|
||||
* These are the extra routines required for integration with XFree86.
|
||||
* None of these routines should be user visible. -KEM
|
||||
*/
|
||||
extern GLboolean XMesaForceCurrent( XMesaContext c );
|
||||
|
||||
extern GLboolean XMesaLoseCurrent( XMesaContext c );
|
||||
|
||||
extern GLboolean XMesaCopyContext( XMesaContext src,
|
||||
XMesaContext dst,
|
||||
GLuint mask );
|
||||
#endif /* XFree86Server */
|
||||
|
||||
|
||||
/*
|
||||
* Create an XMesaBuffer from an X window.
|
||||
*/
|
||||
|
@@ -41,6 +41,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include "scrnintstr.h"
|
||||
#include "pixmapstr.h"
|
||||
#include "gcstruct.h"
|
||||
|
||||
typedef struct _XMesaImageRec XMesaImage;
|
||||
|
||||
@@ -123,8 +124,7 @@ do { \
|
||||
do { \
|
||||
/* Assumes: Images are always in ZPixmap format */ \
|
||||
(void) __d; \
|
||||
if (__sx || __sy) /* The non-trivial case */ \
|
||||
XMesaPutImageHelper(__d,__b,__gc,__i,__sx,__sy,__x,__y,__w,__h); \
|
||||
ASSERT(!__sx && !__sy); /* The SubImage case */ \
|
||||
ValidateGC(__b, __gc); \
|
||||
(*__gc->ops->PutImage)(__b, __gc, ((XMesaDrawable)(__b))->depth, \
|
||||
__x, __y, __w, __h, 0, ZPixmap, \
|
||||
|
@@ -113,34 +113,46 @@ trackball.o: trackball.c trackball.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) trackball.c
|
||||
|
||||
|
||||
extfuncs.h: $(TOP)/progs/util/extfuncs.h
|
||||
cp $< .
|
||||
|
||||
|
||||
reflect: reflect.o showbuffer.o readtex.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) reflect.o showbuffer.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) reflect.o showbuffer.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
reflect.o: reflect.c showbuffer.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) reflect.c
|
||||
|
||||
|
||||
shadowtex: shadowtex.o showbuffer.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) shadowtex.o showbuffer.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) shadowtex.o showbuffer.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
shadowtex.o: shadowtex.c showbuffer.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) shadowtex.c
|
||||
|
||||
|
||||
gloss: gloss.o trackball.o readtex.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) gloss.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) gloss.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
gloss.o: gloss.c trackball.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) gloss.c
|
||||
|
||||
|
||||
engine: engine.o trackball.o readtex.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) engine.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) engine.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
engine.o: engine.c trackball.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) engine.c
|
||||
|
||||
|
||||
fslight: fslight.o
|
||||
$(CC) fslight.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
fslight.o: fslight.c extfuncs.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) fslight.c
|
||||
|
||||
|
||||
|
||||
clean:
|
||||
-rm -f $(PROGS)
|
||||
-rm -f *.o *~
|
||||
|
@@ -22,9 +22,11 @@ LIBS = GLUT32.LIB OPENGL32.LIB
|
||||
|
||||
all: OPENGL32.DLL GLU32.DLL GLUT32.DLL \
|
||||
readtex.h readtex.c showbuffer.h showbuffer.c \
|
||||
extfuncs.h trackball.h trackball.c \
|
||||
arbfplight.exe arbfslight.exe arbocclude.exe bounce.exe \
|
||||
clearspd.exe cubemap.exe drawpix.exe fire.exe fogcoord.exe \
|
||||
fplight.exe gamma.exe gearbox.exe \
|
||||
clearspd.exe cubemap.exe drawpix.exe engine.exe \
|
||||
fire.exe fogcoord.exe \
|
||||
fplight.exe fslight.exe gamma.exe gearbox.exe \
|
||||
gears.exe geartrain.exe gloss.exe \
|
||||
glinfo.exe glslnoise.exe \
|
||||
gltestperf.exe glutfx.exe ipers.exe isosurf.exe lodbias.exe \
|
||||
@@ -42,14 +44,16 @@ bounce.exe: bounce.obj
|
||||
clearspd.exe: clearspd.obj
|
||||
cubemap.exe: cubemap.obj readtex.obj
|
||||
drawpix.exe: drawpix.obj readtex.obj
|
||||
engine.exe: engine.obj readtex.obj trackball.obj
|
||||
fire.exe: fire.obj readtex.obj
|
||||
fogcoord.exe: fogcoord.obj readtex.obj
|
||||
fplight.exe: fplight.obj
|
||||
fslight.exe: fslight.obj
|
||||
gamma.exe: gamma.obj
|
||||
gearbox.exe: gearbox.obj
|
||||
gears.exe: gears.obj
|
||||
geartrain.exe: geartrain.obj
|
||||
gloss.exe: gloss.obj readtex.obj
|
||||
gloss.exe: gloss.obj readtex.obj trackball.obj
|
||||
glinfo.exe: glinfo.obj
|
||||
glslnoise.exe: glslnoise.obj
|
||||
gltestperf.exe: gltestperf.obj
|
||||
@@ -105,14 +109,23 @@ showbuffer.c: $(TOP)\progs\util\showbuffer.c
|
||||
showbuffer.h: $(TOP)\progs\util\showbuffer.h
|
||||
copy $** .
|
||||
|
||||
trackball.c: $(TOP)\progs\util\trackball.c
|
||||
copy $** .
|
||||
|
||||
trackball.h: $(TOP)\progs\util\trackball.h
|
||||
copy $** .
|
||||
|
||||
extfuncs.h: $(TOP)\progs\util\extfuncs.h
|
||||
copy $** .
|
||||
|
||||
.obj.exe:
|
||||
$(link) $(ldebug) -out:$@ $** /LIBPATH:$(LIBDIR) $(LIBS)
|
||||
|
||||
.c.obj:
|
||||
$(cc) $(cdebug) $(cflags) $(cvars) /I$(INCDIR) $*.c
|
||||
$(cc) $(cdebug) $(cflags) $(cvars) -D_USE_MATH_DEFINES /I$(INCDIR) $*.c
|
||||
|
||||
clean::
|
||||
del *.obj *.exe readtex.* showbuffer.*
|
||||
del *.obj *.exe readtex.* showbuffer.* trackball.*
|
||||
|
||||
clobber::
|
||||
|
||||
|
@@ -24,6 +24,7 @@ static GLuint VertProg;
|
||||
static GLboolean Anim = GL_TRUE;
|
||||
static GLboolean Wire = GL_FALSE;
|
||||
static GLboolean PixelLight = GL_TRUE;
|
||||
static GLint Win;
|
||||
|
||||
static GLint T0 = 0;
|
||||
static GLint Frames = 0;
|
||||
@@ -148,6 +149,7 @@ static void Key( unsigned char key, int x, int y )
|
||||
case 27:
|
||||
glDeleteProgramsARB_func(1, &VertProg);
|
||||
glDeleteProgramsARB_func(1, &FragProg);
|
||||
glutDestroyWindow(Win);
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
@@ -382,7 +384,7 @@ int main( int argc, char *argv[] )
|
||||
glutInitWindowPosition( 0, 0 );
|
||||
glutInitWindowSize( 200, 200 );
|
||||
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
|
||||
glutCreateWindow(argv[0]);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc( Reshape );
|
||||
glutKeyboardFunc( Key );
|
||||
glutSpecialFunc( SpecialKey );
|
||||
|
@@ -62,7 +62,7 @@ static PFNGLUNIFORM3FVARBPROC glUniform4fvARB = NULL;
|
||||
|
||||
static void normalize (GLfloat *dst, const GLfloat *src)
|
||||
{
|
||||
GLfloat len = sqrtf (src[0] * src[0] + src[1] * src[1] + src[2] * src[2]);
|
||||
GLfloat len = sqrt (src[0] * src[0] + src[1] * src[1] + src[2] * src[2]);
|
||||
dst[0] = src[0] / len;
|
||||
dst[1] = src[1] / len;
|
||||
dst[2] = src[2] / len;
|
||||
|
@@ -7,151 +7,136 @@
|
||||
* Daniel Borca
|
||||
*/
|
||||
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include "readtex.h"
|
||||
#define DEPTH 5.0f
|
||||
|
||||
#define TEXTURE_FILE "../images/bw.rgb"
|
||||
static PFNGLFOGCOORDFEXTPROC glFogCoordf_ext;
|
||||
static PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointer_ext;
|
||||
|
||||
#define ARRAYS 0 /* use glDrawElements */
|
||||
|
||||
#define VERBOSE 1 /* tell me what happens */
|
||||
|
||||
#define DEPTH 15.0f
|
||||
|
||||
#if !defined(GLAPIENTRYP)
|
||||
# define GLAPIENTRYP *
|
||||
#endif
|
||||
|
||||
typedef void (GLAPIENTRYP GLFOGCOORDFEXTPROC) (GLfloat f);
|
||||
typedef void (GLAPIENTRYP GLFOGCOORDPOINTEREXTPROC) (GLenum, GLsizei, const GLvoid *);
|
||||
|
||||
static GLFOGCOORDFEXTPROC glFogCoordf_ext;
|
||||
#if ARRAYS
|
||||
static GLFOGCOORDPOINTEREXTPROC glFogCoordPointer_ext;
|
||||
#endif
|
||||
static GLboolean have_fog_coord;
|
||||
|
||||
static GLfloat camz;
|
||||
static GLuint texture[1];
|
||||
|
||||
static GLint fogMode;
|
||||
static GLboolean fogCoord;
|
||||
static GLfloat fogDensity = 0.75;
|
||||
static GLfloat fogStart = 1.0, fogEnd = 40.0;
|
||||
static GLfloat fogStart = 1.0, fogEnd = DEPTH;
|
||||
static GLfloat fogColor[4] = {0.6f, 0.3f, 0.0f, 1.0f};
|
||||
static const char *ModeStr = NULL;
|
||||
static GLboolean Arrays = GL_FALSE;
|
||||
static GLboolean Texture = GL_TRUE;
|
||||
|
||||
|
||||
static void APIENTRY glFogCoordf_nop (GLfloat f)
|
||||
static void
|
||||
Reset(void)
|
||||
{
|
||||
fogMode = 1;
|
||||
fogCoord = 1;
|
||||
fogDensity = 0.75;
|
||||
fogStart = 1.0;
|
||||
fogEnd = DEPTH;
|
||||
Arrays = GL_FALSE;
|
||||
Texture = GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void APIENTRY
|
||||
glFogCoordf_nop (GLfloat f)
|
||||
{
|
||||
(void)f;
|
||||
}
|
||||
|
||||
|
||||
static int BuildTexture (const char *filename, GLuint texid[])
|
||||
static void
|
||||
PrintString(const char *s)
|
||||
{
|
||||
GLubyte *tex_data;
|
||||
GLenum tex_format;
|
||||
GLint tex_width, tex_height;
|
||||
|
||||
tex_data = LoadRGBImage(filename, &tex_width, &tex_height, &tex_format);
|
||||
if (tex_data == NULL) {
|
||||
return -1;
|
||||
while (*s) {
|
||||
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
|
||||
s++;
|
||||
}
|
||||
|
||||
{
|
||||
GLint tex_max;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &tex_max);
|
||||
if ((tex_width > tex_max) || (tex_height > tex_max)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
glGenTextures(1, texid);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texid[0]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, tex_format, tex_width, tex_height, 0,
|
||||
tex_format, GL_UNSIGNED_BYTE, tex_data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int SetFogMode (GLint fogMode)
|
||||
static void
|
||||
PrintInfo(void)
|
||||
{
|
||||
char s[100];
|
||||
|
||||
glDisable(GL_FOG);
|
||||
glColor3f(0, 1, 1);
|
||||
|
||||
sprintf(s, "Mode(m): %s Start(s/S): %g End(e/E): %g Density(d/D): %g",
|
||||
ModeStr, fogStart, fogEnd, fogDensity);
|
||||
glWindowPos2iARB(5, 20);
|
||||
PrintString(s);
|
||||
|
||||
sprintf(s, "Arrays(a): %s glFogCoord(c): %s EyeZ(z/z): %g",
|
||||
(Arrays ? "Yes" : "No"),
|
||||
(fogCoord ? "Yes" : "No"),
|
||||
camz);
|
||||
glWindowPos2iARB(5, 5);
|
||||
PrintString(s);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
SetFogMode(GLint fogMode)
|
||||
{
|
||||
fogMode &= 3;
|
||||
switch (fogMode) {
|
||||
case 0:
|
||||
ModeStr = "Off";
|
||||
glDisable(GL_FOG);
|
||||
#if VERBOSE
|
||||
printf("fog(disable)\n");
|
||||
#endif
|
||||
break;
|
||||
case 1:
|
||||
ModeStr = "GL_LINEAR";
|
||||
glEnable(GL_FOG);
|
||||
glFogi(GL_FOG_MODE, GL_LINEAR);
|
||||
glFogf(GL_FOG_START, fogStart);
|
||||
glFogf(GL_FOG_END, fogEnd);
|
||||
#if VERBOSE
|
||||
printf("fog(GL_LINEAR, %.2f, %.2f)\n", fogStart, fogEnd);
|
||||
#endif
|
||||
break;
|
||||
case 2:
|
||||
ModeStr = "GL_EXP";
|
||||
glEnable(GL_FOG);
|
||||
glFogi(GL_FOG_MODE, GL_EXP);
|
||||
glFogf(GL_FOG_DENSITY, fogDensity);
|
||||
#if VERBOSE
|
||||
printf("fog(GL_EXP, %.2f)\n", fogDensity);
|
||||
#endif
|
||||
break;
|
||||
case 3:
|
||||
ModeStr = "GL_EXP2";
|
||||
glEnable(GL_FOG);
|
||||
glFogi(GL_FOG_MODE, GL_EXP2);
|
||||
glFogf(GL_FOG_DENSITY, fogDensity);
|
||||
#if VERBOSE
|
||||
printf("fog(GL_EXP2, %.2f)\n", fogDensity);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
return fogMode;
|
||||
}
|
||||
|
||||
|
||||
static GLboolean SetFogCoord (GLboolean fogCoord)
|
||||
static GLboolean
|
||||
SetFogCoord(GLboolean fogCoord)
|
||||
{
|
||||
glFogCoordf_ext = glFogCoordf_nop;
|
||||
|
||||
if (!have_fog_coord) {
|
||||
#if VERBOSE
|
||||
printf("fog(GL_FRAGMENT_DEPTH_EXT)%s\n", fogCoord ? " EXT_fog_coord not available!" : "");
|
||||
#endif
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (fogCoord) {
|
||||
glFogCoordf_ext = (GLFOGCOORDFEXTPROC)glutGetProcAddress("glFogCoordfEXT");
|
||||
glFogCoordf_ext = (PFNGLFOGCOORDFEXTPROC)glutGetProcAddress("glFogCoordfEXT");
|
||||
glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
|
||||
#if VERBOSE
|
||||
printf("fog(GL_FOG_COORDINATE_EXT)\n");
|
||||
#endif
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
|
||||
#if VERBOSE
|
||||
printf("fog(GL_FRAGMENT_DEPTH_EXT)\n");
|
||||
#endif
|
||||
}
|
||||
return fogCoord;
|
||||
}
|
||||
|
||||
|
||||
#if ARRAYS
|
||||
/* could reuse vertices */
|
||||
static GLuint vertex_index[] = {
|
||||
/* Back */
|
||||
@@ -172,19 +157,19 @@ static GLuint vertex_index[] = {
|
||||
|
||||
static GLfloat vertex_pointer[][3] = {
|
||||
/* Back */
|
||||
{-2.5f,-2.5f,-DEPTH}, { 2.5f,-2.5f,-DEPTH}, { 2.5f, 2.5f,-DEPTH}, {-2.5f, 2.5f,-DEPTH},
|
||||
{-1.0f,-1.0f,-DEPTH}, { 1.0f,-1.0f,-DEPTH}, { 1.0f, 1.0f,-DEPTH}, {-1.0f, 1.0f,-DEPTH},
|
||||
|
||||
/* Floor */
|
||||
{-2.5f,-2.5f,-DEPTH}, { 2.5f,-2.5f,-DEPTH}, { 2.5f,-2.5f, DEPTH}, {-2.5f,-2.5f, DEPTH},
|
||||
{-1.0f,-1.0f,-DEPTH}, { 1.0f,-1.0f,-DEPTH}, { 1.0f,-1.0f, 0.0}, {-1.0f,-1.0f, 0.0},
|
||||
|
||||
/* Roof */
|
||||
{-2.5f, 2.5f,-DEPTH}, { 2.5f, 2.5f,-DEPTH}, { 2.5f, 2.5f, DEPTH}, {-2.5f, 2.5f, DEPTH},
|
||||
{-1.0f, 1.0f,-DEPTH}, { 1.0f, 1.0f,-DEPTH}, { 1.0f, 1.0f, 0.0}, {-1.0f, 1.0f, 0.0},
|
||||
|
||||
/* Right */
|
||||
{ 2.5f,-2.5f, DEPTH}, { 2.5f, 2.5f, DEPTH}, { 2.5f, 2.5f,-DEPTH}, { 2.5f,-2.5f,-DEPTH},
|
||||
{ 1.0f,-1.0f, 0.0}, { 1.0f, 1.0f, 0.0}, { 1.0f, 1.0f,-DEPTH}, { 1.0f,-1.0f,-DEPTH},
|
||||
|
||||
/* Left */
|
||||
{-2.5f,-2.5f, DEPTH}, {-2.5f, 2.5f, DEPTH}, {-2.5f, 2.5f,-DEPTH}, {-2.5f,-2.5f,-DEPTH}
|
||||
{-1.0f,-1.0f, 0.0}, {-1.0f, 1.0f, 0.0}, {-1.0f, 1.0f,-DEPTH}, {-1.0f,-1.0f,-DEPTH}
|
||||
};
|
||||
|
||||
static GLfloat texcoord_pointer[][2] = {
|
||||
@@ -192,118 +177,139 @@ static GLfloat texcoord_pointer[][2] = {
|
||||
{0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f},
|
||||
|
||||
/* Floor */
|
||||
{0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f},
|
||||
{0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, DEPTH}, {0.0f, DEPTH},
|
||||
|
||||
/* Roof */
|
||||
{0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f},
|
||||
{1.0f, 0.0f}, {0.0f, 0.0f}, {0.0f, DEPTH}, {1.0f, DEPTH},
|
||||
|
||||
/* Right */
|
||||
{0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f},
|
||||
{0.0f, 1.0f}, {0.0f, 0.0f}, {DEPTH, 0.0f}, {DEPTH, 1.0f},
|
||||
|
||||
/* Left */
|
||||
{0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f}
|
||||
{0.0f, 0.0f}, {0.0f, 1.0f}, {DEPTH, 1.0f}, {DEPTH, 0.0f}
|
||||
};
|
||||
|
||||
static GLfloat fogcoord_pointer[][1] = {
|
||||
static GLfloat fogcoord_pointer[] = {
|
||||
/* Back */
|
||||
{1.0f}, {1.0f}, {1.0f}, {1.0f},
|
||||
DEPTH, DEPTH, DEPTH, DEPTH,
|
||||
|
||||
/* Floor */
|
||||
{1.0f}, {1.0f}, {0.0f}, {0.0f},
|
||||
DEPTH, DEPTH, 0.0, 0.0,
|
||||
|
||||
/* Roof */
|
||||
{1.0f}, {1.0f}, {0.0f}, {0.0f},
|
||||
DEPTH, DEPTH, 0.0, 0.0,
|
||||
|
||||
/* Right */
|
||||
{0.0f}, {0.0f}, {1.0f}, {1.0f},
|
||||
0.0, 0.0, DEPTH, DEPTH,
|
||||
|
||||
/* Left */
|
||||
{0.0f}, {0.0f}, {1.0f}, {1.0f}
|
||||
0.0, 0.0, DEPTH, DEPTH
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
static void Display( void )
|
||||
static void
|
||||
Display( void )
|
||||
{
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glLoadIdentity ();
|
||||
|
||||
glTranslatef(0.0f, 0.0f, camz);
|
||||
glTranslatef(0.0f, 0.0f, -camz);
|
||||
|
||||
#if ARRAYS
|
||||
glDrawElements(GL_QUADS, sizeof(vertex_index) / sizeof(vertex_index[0]), GL_UNSIGNED_INT, vertex_index);
|
||||
#else
|
||||
/* Back */
|
||||
glBegin(GL_QUADS);
|
||||
glFogCoordf_ext(1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.5f,-2.5f,-DEPTH);
|
||||
glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 2.5f,-2.5f,-DEPTH);
|
||||
glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 2.5f, 2.5f,-DEPTH);
|
||||
glFogCoordf_ext(1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.5f, 2.5f,-DEPTH);
|
||||
glEnd();
|
||||
SetFogMode(fogMode);
|
||||
|
||||
/* Floor */
|
||||
glBegin(GL_QUADS);
|
||||
glFogCoordf_ext(1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.5f,-2.5f,-DEPTH);
|
||||
glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 2.5f,-2.5f,-DEPTH);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 2.5f,-2.5f, DEPTH);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.5f,-2.5f, DEPTH);
|
||||
glEnd();
|
||||
glColor3f(1, 1, 1);
|
||||
|
||||
/* Roof */
|
||||
glBegin(GL_QUADS);
|
||||
glFogCoordf_ext(1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.5f, 2.5f,-DEPTH);
|
||||
glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 2.5f, 2.5f,-DEPTH);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 2.5f, 2.5f, DEPTH);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.5f, 2.5f, DEPTH);
|
||||
glEnd();
|
||||
if (Texture)
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
/* Right */
|
||||
glBegin(GL_QUADS);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 2.5f,-2.5f, DEPTH);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 2.5f, 2.5f, DEPTH);
|
||||
glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 2.5f, 2.5f,-DEPTH);
|
||||
glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 2.5f,-2.5f,-DEPTH);
|
||||
glEnd();
|
||||
if (Arrays) {
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDrawElements(GL_QUADS, sizeof(vertex_index) / sizeof(vertex_index[0]),
|
||||
GL_UNSIGNED_INT, vertex_index);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
else {
|
||||
/* Back */
|
||||
glBegin(GL_QUADS);
|
||||
glFogCoordf_ext(DEPTH); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,-1.0f,-DEPTH);
|
||||
glFogCoordf_ext(DEPTH); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,-1.0f,-DEPTH);
|
||||
glFogCoordf_ext(DEPTH); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f,-DEPTH);
|
||||
glFogCoordf_ext(DEPTH); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f,-DEPTH);
|
||||
glEnd();
|
||||
|
||||
/* Left */
|
||||
glBegin(GL_QUADS);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.5f,-2.5f, DEPTH);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.5f, 2.5f, DEPTH);
|
||||
glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-2.5f, 2.5f,-DEPTH);
|
||||
glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-2.5f,-2.5f,-DEPTH);
|
||||
glEnd();
|
||||
#endif
|
||||
/* Floor */
|
||||
glBegin(GL_QUADS);
|
||||
glFogCoordf_ext(DEPTH); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,-1.0f,-DEPTH);
|
||||
glFogCoordf_ext(DEPTH); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,-1.0f,-DEPTH);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(1.0f, DEPTH); glVertex3f( 1.0f,-1.0f,0.0);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, DEPTH); glVertex3f(-1.0f,-1.0f,0.0);
|
||||
glEnd();
|
||||
|
||||
/* Roof */
|
||||
glBegin(GL_QUADS);
|
||||
glFogCoordf_ext(DEPTH); glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, 1.0f,-DEPTH);
|
||||
glFogCoordf_ext(DEPTH); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, 1.0f,-DEPTH);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, DEPTH); glVertex3f( 1.0f, 1.0f,0.0);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(1.0f, DEPTH); glVertex3f(-1.0f, 1.0f,0.0);
|
||||
glEnd();
|
||||
|
||||
/* Right */
|
||||
glBegin(GL_QUADS);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,-1.0f,0.0);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, 1.0f,0.0);
|
||||
glFogCoordf_ext(DEPTH); glTexCoord2f(DEPTH, 0.0f); glVertex3f( 1.0f, 1.0f,-DEPTH);
|
||||
glFogCoordf_ext(DEPTH); glTexCoord2f(DEPTH, 1.0f); glVertex3f( 1.0f,-1.0f,-DEPTH);
|
||||
glEnd();
|
||||
|
||||
/* Left */
|
||||
glBegin(GL_QUADS);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,-1.0f,0.0);
|
||||
glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f,0.0);
|
||||
glFogCoordf_ext(DEPTH); glTexCoord2f(DEPTH, 1.0f); glVertex3f(-1.0f, 1.0f,-DEPTH);
|
||||
glFogCoordf_ext(DEPTH); glTexCoord2f(DEPTH, 0.0f); glVertex3f(-1.0f,-1.0f,-DEPTH);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
PrintInfo();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void Reshape( int width, int height )
|
||||
static void
|
||||
Reshape( int width, int height )
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(45.0f, (GLfloat)(width)/(GLfloat)(height), 0.1f, 100.0f);
|
||||
glFrustum(-1, 1, -1, 1, 1.0, 100);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
|
||||
static void Key( unsigned char key, int x, int y )
|
||||
static void
|
||||
Key( unsigned char key, int x, int y )
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case 'a':
|
||||
Arrays = !Arrays;
|
||||
break;
|
||||
case 'f':
|
||||
case 'm':
|
||||
fogMode = SetFogMode(fogMode + 1);
|
||||
break;
|
||||
case '+':
|
||||
if (fogDensity < 1.0) {
|
||||
fogDensity += 0.05;
|
||||
}
|
||||
case 'D':
|
||||
fogDensity += 0.05;
|
||||
SetFogMode(fogMode);
|
||||
break;
|
||||
case '-':
|
||||
case 'd':
|
||||
if (fogDensity > 0.0) {
|
||||
fogDensity -= 0.05;
|
||||
}
|
||||
@@ -311,31 +317,43 @@ static void Key( unsigned char key, int x, int y )
|
||||
break;
|
||||
case 's':
|
||||
if (fogStart > 0.0) {
|
||||
fogStart -= 1.0;
|
||||
fogStart -= 0.25;
|
||||
}
|
||||
SetFogMode(fogMode);
|
||||
break;
|
||||
case 'S':
|
||||
if (fogStart < fogEnd) {
|
||||
fogStart += 1.0;
|
||||
if (fogStart < 100.0) {
|
||||
fogStart += 0.25;
|
||||
}
|
||||
SetFogMode(fogMode);
|
||||
break;
|
||||
case 'e':
|
||||
if (fogEnd > fogStart) {
|
||||
fogEnd -= 1.0;
|
||||
if (fogEnd > 0.0) {
|
||||
fogEnd -= 0.25;
|
||||
}
|
||||
SetFogMode(fogMode);
|
||||
break;
|
||||
case 'E':
|
||||
if (fogEnd < 100.0) {
|
||||
fogEnd += 1.0;
|
||||
fogEnd += 0.25;
|
||||
}
|
||||
SetFogMode(fogMode);
|
||||
break;
|
||||
case 'c':
|
||||
fogCoord = SetFogCoord(fogCoord ^ GL_TRUE);
|
||||
break;
|
||||
case 't':
|
||||
Texture = !Texture;
|
||||
break;
|
||||
case 'z':
|
||||
camz -= 0.1;
|
||||
break;
|
||||
case 'Z':
|
||||
camz += 0.1;
|
||||
break;
|
||||
case 'r':
|
||||
Reset();
|
||||
break;
|
||||
case 27:
|
||||
exit(0);
|
||||
break;
|
||||
@@ -344,37 +362,28 @@ static void Key( unsigned char key, int x, int y )
|
||||
}
|
||||
|
||||
|
||||
static void SpecialKey( int key, int x, int y )
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case GLUT_KEY_UP:
|
||||
if (camz < (DEPTH - 1.0)) {
|
||||
camz += 1.0f;
|
||||
}
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
if (camz > -19.0) {
|
||||
camz -= 1.0f;
|
||||
}
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
static const GLubyte teximage[2][2][4] = {
|
||||
{ { 255, 255, 255, 255}, { 128, 128, 128, 255} },
|
||||
{ { 128, 128, 128, 255}, { 255, 255, 255, 255} }
|
||||
};
|
||||
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
have_fog_coord = glutExtensionSupported("GL_EXT_fog_coord");
|
||||
|
||||
if (BuildTexture(TEXTURE_FILE, texture) == -1) {
|
||||
exit(1);
|
||||
if (!have_fog_coord) {
|
||||
printf("GL_EXT_fog_coord not supported!\n");
|
||||
}
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
|
||||
glClearDepth(1.0f);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, teximage);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glClearColor(0.1f, 0.1f, 0.1f, 0.0f);
|
||||
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
@@ -383,11 +392,8 @@ static void Init( void )
|
||||
glFogfv(GL_FOG_COLOR, fogColor);
|
||||
glHint(GL_FOG_HINT, GL_NICEST);
|
||||
fogCoord = SetFogCoord(GL_TRUE); /* try to enable fog_coord */
|
||||
fogMode = SetFogMode(2); /* GL_EXP */
|
||||
fogMode = SetFogMode(1);
|
||||
|
||||
camz = -19.0f;
|
||||
|
||||
#if ARRAYS
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, 0, vertex_pointer);
|
||||
|
||||
@@ -395,24 +401,24 @@ static void Init( void )
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, texcoord_pointer);
|
||||
|
||||
if (have_fog_coord) {
|
||||
glFogCoordPointer_ext = (GLFOGCOORDPOINTEREXTPROC)glutGetProcAddress("glFogCoordPointerEXT");
|
||||
glFogCoordPointer_ext = (PFNGLFOGCOORDPOINTEREXTPROC)glutGetProcAddress("glFogCoordPointerEXT");
|
||||
glEnableClientState(GL_FOG_COORDINATE_ARRAY_EXT);
|
||||
glFogCoordPointer_ext(GL_FLOAT, 0, fogcoord_pointer);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
int
|
||||
main( int argc, char *argv[] )
|
||||
{
|
||||
glutInit( &argc, argv );
|
||||
glutInitWindowPosition( 0, 0 );
|
||||
glutInitWindowSize( 640, 480 );
|
||||
glutInitWindowSize( 600, 600 );
|
||||
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
|
||||
glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc( Reshape );
|
||||
glutKeyboardFunc( Key );
|
||||
glutSpecialFunc( SpecialKey );
|
||||
glutDisplayFunc( Display );
|
||||
Init();
|
||||
glutMainLoop();
|
||||
|
@@ -24,7 +24,7 @@ static GLuint VertProg;
|
||||
static GLboolean Anim = GL_TRUE;
|
||||
static GLboolean Wire = GL_FALSE;
|
||||
static GLboolean PixelLight = GL_TRUE;
|
||||
|
||||
static GLint Win;
|
||||
static GLfloat Xrot = 0, Yrot = 0;
|
||||
|
||||
|
||||
@@ -136,8 +136,8 @@ static void Key( unsigned char key, int x, int y )
|
||||
}
|
||||
break;
|
||||
case 27:
|
||||
glutDestroyWindow(Win);
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
@@ -272,7 +272,7 @@ int main( int argc, char *argv[] )
|
||||
glutInitWindowPosition( 0, 0 );
|
||||
glutInitWindowSize( 200, 200 );
|
||||
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
|
||||
glutCreateWindow(argv[0]);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc( Reshape );
|
||||
glutKeyboardFunc( Key );
|
||||
glutSpecialFunc( SpecialKey );
|
||||
|
@@ -20,20 +20,30 @@
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
|
||||
|
||||
#define TEXTURE 0
|
||||
|
||||
static GLint CoordAttrib = 0;
|
||||
|
||||
static char *FragProgFile = NULL;
|
||||
static char *VertProgFile = NULL;
|
||||
|
||||
static GLfloat diffuse[4] = { 0.5f, 0.5f, 1.0f, 1.0f };
|
||||
static GLfloat specular[4] = { 0.8f, 0.8f, 0.8f, 1.0f };
|
||||
static GLfloat lightPos[4] = { 0.0f, 10.0f, 20.0f, 1.0f };
|
||||
static GLfloat lightPos[4] = { 0.0f, 10.0f, 20.0f, 0.0f };
|
||||
static GLfloat delta = 1.0f;
|
||||
|
||||
static GLuint fragShader;
|
||||
static GLuint vertShader;
|
||||
static GLuint program;
|
||||
|
||||
static GLint uLightPos;
|
||||
static GLint uDiffuse;
|
||||
static GLint uSpecular;
|
||||
static GLint uTexture;
|
||||
|
||||
static GLuint SphereList, RectList, CurList;
|
||||
static GLint win = 0;
|
||||
static GLboolean anim = GL_TRUE;
|
||||
static GLboolean wire = GL_FALSE;
|
||||
@@ -42,58 +52,47 @@ static GLboolean pixelLight = GL_TRUE;
|
||||
static GLint t0 = 0;
|
||||
static GLint frames = 0;
|
||||
|
||||
static GLfloat xRot = 0.0f, yRot = 0.0f;
|
||||
|
||||
static PFNGLCREATESHADERPROC glCreateShader_func = NULL;
|
||||
static PFNGLSHADERSOURCEPROC glShaderSource_func = NULL;
|
||||
static PFNGLGETSHADERSOURCEPROC glGetShaderSource_func = NULL;
|
||||
static PFNGLCOMPILESHADERPROC glCompileShader_func = NULL;
|
||||
static PFNGLCREATEPROGRAMPROC glCreateProgram_func = NULL;
|
||||
static PFNGLDELETEPROGRAMPROC glDeleteProgram_func = NULL;
|
||||
static PFNGLDELETESHADERPROC glDeleteShader_func = NULL;
|
||||
static PFNGLATTACHSHADERPROC glAttachShader_func = NULL;
|
||||
static PFNGLLINKPROGRAMPROC glLinkProgram_func = NULL;
|
||||
static PFNGLUSEPROGRAMPROC glUseProgram_func = NULL;
|
||||
static PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation_func = NULL;
|
||||
static PFNGLISPROGRAMPROC glIsProgram_func = NULL;
|
||||
static PFNGLISSHADERPROC glIsShader_func = NULL;
|
||||
static PFNGLUNIFORM3FVPROC glUniform3fv_func = NULL;
|
||||
static PFNGLUNIFORM3FVPROC glUniform4fv_func = NULL;
|
||||
|
||||
static GLfloat xRot = 90.0f, yRot = 0.0f;
|
||||
|
||||
|
||||
static void
|
||||
normalize(GLfloat *dst, const GLfloat *src)
|
||||
{
|
||||
GLfloat len = sqrtf(src[0] * src[0] + src[1] * src[1] + src[2] * src[2]);
|
||||
GLfloat len = sqrt(src[0] * src[0] + src[1] * src[1] + src[2] * src[2]);
|
||||
dst[0] = src[0] / len;
|
||||
dst[1] = src[1] / len;
|
||||
dst[2] = src[2] / len;
|
||||
dst[3] = src[3];
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Redisplay(void)
|
||||
{
|
||||
GLfloat vec[4];
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
/* update light position */
|
||||
normalize(vec, lightPos);
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, vec);
|
||||
|
||||
if (pixelLight) {
|
||||
GLfloat vec[3];
|
||||
glUseProgram_func(program);
|
||||
normalize(vec, lightPos);
|
||||
glUniform3fv_func(uLightPos, 1, vec);
|
||||
glDisable(GL_LIGHTING);
|
||||
}
|
||||
else {
|
||||
glUseProgram_func(0);
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
|
||||
/*
|
||||
glutSolidSphere(2.0, 10, 5);
|
||||
*/
|
||||
glCallList(CurList);
|
||||
glPopMatrix();
|
||||
|
||||
glutSwapBuffers();
|
||||
@@ -174,6 +173,12 @@ Key(unsigned char key, int x, int y)
|
||||
else
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
break;
|
||||
case 'o':
|
||||
if (CurList == SphereList)
|
||||
CurList = RectList;
|
||||
else
|
||||
CurList = SphereList;
|
||||
break;
|
||||
case 'p':
|
||||
pixelLight = !pixelLight;
|
||||
if (pixelLight)
|
||||
@@ -216,17 +221,249 @@ SpecialKey(int key, int x, int y)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
TestFunctions(void)
|
||||
{
|
||||
printf("Error 0x%x at line %d\n", glGetError(), __LINE__);
|
||||
{
|
||||
GLfloat pos[3];
|
||||
printf("Error 0x%x at line %d\n", glGetError(), __LINE__);
|
||||
printf("Light pos %g %g %g\n", pos[0], pos[1], pos[2]);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
GLfloat m[16], result[16];
|
||||
GLint mPos;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
m[i] = (float) i;
|
||||
|
||||
mPos = glGetUniformLocation_func(program, "m");
|
||||
printf("Error 0x%x at line %d\n", glGetError(), __LINE__);
|
||||
glUniformMatrix4fv_func(mPos, 1, GL_FALSE, m);
|
||||
printf("Error 0x%x at line %d\n", glGetError(), __LINE__);
|
||||
|
||||
glGetUniformfv_func(program, mPos, result);
|
||||
printf("Error 0x%x at line %d\n", glGetError(), __LINE__);
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
printf("%8g %8g\n", m[i], result[i]);
|
||||
}
|
||||
}
|
||||
|
||||
assert(glIsProgram_func(program));
|
||||
assert(glIsShader_func(fragShader));
|
||||
assert(glIsShader_func(vertShader));
|
||||
|
||||
/* attached shaders */
|
||||
{
|
||||
GLuint shaders[20];
|
||||
GLsizei count;
|
||||
int i;
|
||||
glGetAttachedShaders_func(program, 20, &count, shaders);
|
||||
for (i = 0; i < count; i++) {
|
||||
printf("Attached: %u\n", shaders[i]);
|
||||
assert(shaders[i] == fragShader ||
|
||||
shaders[i] == vertShader);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(vertShader, 1000, &len, log);
|
||||
printf("Vert Shader Info Log: %s\n", log);
|
||||
glGetShaderInfoLog_func(fragShader, 1000, &len, log);
|
||||
printf("Frag Shader Info Log: %s\n", log);
|
||||
glGetProgramInfoLog_func(program, 1000, &len, log);
|
||||
printf("Program Info Log: %s\n", log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if TEXTURE
|
||||
static void
|
||||
MakeTexture(void)
|
||||
{
|
||||
#define SZ0 64
|
||||
#define SZ1 32
|
||||
GLubyte image0[SZ0][SZ0][SZ0][4];
|
||||
GLubyte image1[SZ1][SZ1][SZ1][4];
|
||||
GLuint i, j, k;
|
||||
|
||||
/* level 0: two-tone gray checkboard */
|
||||
for (i = 0; i < SZ0; i++) {
|
||||
for (j = 0; j < SZ0; j++) {
|
||||
for (k = 0; k < SZ0; k++) {
|
||||
if ((i/8 + j/8 + k/8) & 1) {
|
||||
image0[i][j][k][0] =
|
||||
image0[i][j][k][1] =
|
||||
image0[i][j][k][2] = 200;
|
||||
}
|
||||
else {
|
||||
image0[i][j][k][0] =
|
||||
image0[i][j][k][1] =
|
||||
image0[i][j][k][2] = 100;
|
||||
}
|
||||
image0[i][j][k][3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* level 1: two-tone green checkboard */
|
||||
for (i = 0; i < SZ1; i++) {
|
||||
for (j = 0; j < SZ1; j++) {
|
||||
for (k = 0; k < SZ1; k++) {
|
||||
if ((i/8 + j/8 + k/8) & 1) {
|
||||
image1[i][j][k][0] = 0;
|
||||
image1[i][j][k][1] = 250;
|
||||
image1[i][j][k][2] = 0;
|
||||
}
|
||||
else {
|
||||
image1[i][j][k][0] = 0;
|
||||
image1[i][j][k][1] = 200;
|
||||
image1[i][j][k][2] = 0;
|
||||
}
|
||||
image1[i][j][k][3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE2); /* unit 2 */
|
||||
glBindTexture(GL_TEXTURE_2D, 42);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SZ0, SZ0, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, image0);
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, SZ1, SZ1, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, image1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glActiveTexture(GL_TEXTURE4); /* unit 4 */
|
||||
glBindTexture(GL_TEXTURE_3D, 43);
|
||||
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, SZ0, SZ0, SZ0, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, image0);
|
||||
glTexImage3D(GL_TEXTURE_3D, 1, GL_RGBA, SZ1, SZ1, SZ1, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, image1);
|
||||
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, 1);
|
||||
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
MakeSphere(void)
|
||||
{
|
||||
GLUquadricObj *obj = gluNewQuadric();
|
||||
SphereList = glGenLists(1);
|
||||
gluQuadricTexture(obj, GL_TRUE);
|
||||
glNewList(SphereList, GL_COMPILE);
|
||||
gluSphere(obj, 2.0f, 10, 5);
|
||||
glEndList();
|
||||
}
|
||||
|
||||
static void
|
||||
VertAttrib(GLint index, float x, float y)
|
||||
{
|
||||
#if 1
|
||||
glVertexAttrib2f_func(index, x, y);
|
||||
#else
|
||||
glTexCoord2f(x, y);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
MakeRect(void)
|
||||
{
|
||||
RectList = glGenLists(1);
|
||||
glNewList(RectList, GL_COMPILE);
|
||||
glNormal3f(0, 0, 1);
|
||||
glBegin(GL_POLYGON);
|
||||
VertAttrib(CoordAttrib, 0, 0); glVertex2f(-2, -2);
|
||||
VertAttrib(CoordAttrib, 1, 0); glVertex2f( 2, -2);
|
||||
VertAttrib(CoordAttrib, 1, 1); glVertex2f( 2, 2);
|
||||
VertAttrib(CoordAttrib, 0, 1); glVertex2f(-2, 2);
|
||||
glEnd(); /* XXX omit this and crash! */
|
||||
glEndList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
static void
|
||||
ReadShader(GLuint shader, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "fslight: Unable to open shader file %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
printf("fslight: read %d bytes from shader file %s\n", n, filename);
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
LoadAndCompileShader(shader, buffer);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
static const char *fragShaderText =
|
||||
"uniform vec3 lightPos;\n"
|
||||
"uniform vec4 diffuse;\n"
|
||||
"uniform vec4 specular;\n"
|
||||
"varying vec3 normal;\n"
|
||||
"void main() {\n"
|
||||
" // Compute dot product of light direction and normal vector\n"
|
||||
" float dotProd = max(dot(lightPos, normalize(normal)), 0.0);\n"
|
||||
" float dotProd = max(dot(gl_LightSource[0].position.xyz, \n"
|
||||
" normalize(normal)), 0.0);\n"
|
||||
" // Compute diffuse and specular contributions\n"
|
||||
" gl_FragColor = diffuse * dotProd + specular * pow(dotProd, 20.0);\n"
|
||||
"}\n";
|
||||
@@ -236,53 +473,63 @@ Init(void)
|
||||
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
||||
" normal = gl_NormalMatrix * gl_Normal;\n"
|
||||
"}\n";
|
||||
|
||||
|
||||
const char *version;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("Warning: this program expects OpenGL 2.0\n");
|
||||
/*exit(1);*/
|
||||
printf("This program requires OpenGL 2.x, found %s\n", version);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
glCreateShader_func = (PFNGLCREATESHADERPROC) glutGetProcAddress("glCreateShader");
|
||||
glDeleteShader_func = (PFNGLDELETESHADERPROC) glutGetProcAddress("glDeleteShader");
|
||||
glDeleteProgram_func = (PFNGLDELETEPROGRAMPROC) glutGetProcAddress("glDeleteProgram");
|
||||
glShaderSource_func = (PFNGLSHADERSOURCEPROC) glutGetProcAddress("glShaderSource");
|
||||
glGetShaderSource_func = (PFNGLGETSHADERSOURCEPROC) glutGetProcAddress("glGetShaderSource");
|
||||
glCompileShader_func = (PFNGLCOMPILESHADERPROC) glutGetProcAddress("glCompileShader");
|
||||
glCreateProgram_func = (PFNGLCREATEPROGRAMPROC) glutGetProcAddress("glCreateProgram");
|
||||
glAttachShader_func = (PFNGLATTACHSHADERPROC) glutGetProcAddress("glAttachShader");
|
||||
glLinkProgram_func = (PFNGLLINKPROGRAMPROC) glutGetProcAddress("glLinkProgram");
|
||||
glUseProgram_func = (PFNGLUSEPROGRAMPROC) glutGetProcAddress("glUseProgram");
|
||||
glGetUniformLocation_func = (PFNGLGETUNIFORMLOCATIONPROC) glutGetProcAddress("glGetUniformLocation");
|
||||
glIsProgram_func = (PFNGLISPROGRAMPROC) glutGetProcAddress("glIsProgram");
|
||||
glIsShader_func = (PFNGLISSHADERPROC) glutGetProcAddress("glIsShader");
|
||||
glUniform3fv_func = (PFNGLUNIFORM3FVPROC) glutGetProcAddress("glUniform3fv");
|
||||
glUniform4fv_func = (PFNGLUNIFORM3FVPROC) glutGetProcAddress("glUniform4fv");
|
||||
GetExtensionFuncs();
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
glShaderSource_func(fragShader, 1, &fragShaderText, NULL);
|
||||
glCompileShader_func(fragShader);
|
||||
if (FragProgFile)
|
||||
ReadShader(fragShader, FragProgFile);
|
||||
else
|
||||
LoadAndCompileShader(fragShader, fragShaderText);
|
||||
|
||||
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
glShaderSource_func(vertShader, 1, &vertShaderText, NULL);
|
||||
glCompileShader_func(vertShader);
|
||||
if (VertProgFile)
|
||||
ReadShader(vertShader, VertProgFile);
|
||||
else
|
||||
LoadAndCompileShader(vertShader, vertShaderText);
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
|
||||
uLightPos = glGetUniformLocation_func(program, "lightPos");
|
||||
uDiffuse = glGetUniformLocation_func(program, "diffuse");
|
||||
uSpecular = glGetUniformLocation_func(program, "specular");
|
||||
uTexture = glGetUniformLocation_func(program, "texture");
|
||||
printf("DiffusePos %d SpecularPos %d TexturePos %d\n",
|
||||
uDiffuse, uSpecular, uTexture);
|
||||
|
||||
glUniform4fv_func(uDiffuse, 1, diffuse);
|
||||
glUniform4fv_func(uSpecular, 1, specular);
|
||||
/* assert(glGetError() == 0);*/
|
||||
glUniform1i_func(uTexture, 2); /* use texture unit 2 */
|
||||
/*assert(glGetError() == 0);*/
|
||||
|
||||
if (CoordAttrib) {
|
||||
int i;
|
||||
glBindAttribLocation_func(program, CoordAttrib, "coord");
|
||||
i = glGetAttribLocation_func(program, "coord");
|
||||
assert(i >= 0);
|
||||
if (i != CoordAttrib) {
|
||||
printf("Hmmm, NVIDIA bug?\n");
|
||||
CoordAttrib = i;
|
||||
}
|
||||
else {
|
||||
printf("Mesa bind attrib: coord = %d\n", i);
|
||||
}
|
||||
}
|
||||
|
||||
/*assert(glGetError() == 0);*/
|
||||
|
||||
glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
@@ -292,11 +539,20 @@ Init(void)
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
|
||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 20.0f);
|
||||
|
||||
MakeSphere();
|
||||
MakeRect();
|
||||
|
||||
CurList = SphereList;
|
||||
|
||||
#if TEXTURE
|
||||
MakeTexture();
|
||||
#endif
|
||||
|
||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||
printf("Press p to toggle between per-pixel and per-vertex lighting\n");
|
||||
|
||||
/* test glGetShaderSource() */
|
||||
{
|
||||
if (0) {
|
||||
GLsizei len = strlen(fragShaderText) + 1;
|
||||
GLsizei lenOut;
|
||||
GLchar *src =(GLchar *) malloc(len * sizeof(GLchar));
|
||||
@@ -310,6 +566,37 @@ Init(void)
|
||||
assert(glIsProgram_func(program));
|
||||
assert(glIsShader_func(fragShader));
|
||||
assert(glIsShader_func(vertShader));
|
||||
|
||||
glColor3f(1, 0, 0);
|
||||
|
||||
/* for testing state vars */
|
||||
{
|
||||
static GLfloat fc[4] = { 1, 1, 0, 0 };
|
||||
static GLfloat amb[4] = { 1, 0, 1, 0 };
|
||||
glFogfv(GL_FOG_COLOR, fc);
|
||||
glLightfv(GL_LIGHT1, GL_AMBIENT, amb);
|
||||
}
|
||||
|
||||
#if 0
|
||||
TestFunctions();
|
||||
#else
|
||||
(void) TestFunctions;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ParseOptions(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-fs") == 0) {
|
||||
FragProgFile = argv[i+1];
|
||||
}
|
||||
else if (strcmp(argv[i], "-vs") == 0) {
|
||||
VertProgFile = argv[i+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -327,8 +614,10 @@ main(int argc, char *argv[])
|
||||
glutDisplayFunc(Redisplay);
|
||||
if (anim)
|
||||
glutIdleFunc(Idle);
|
||||
ParseOptions(argc, argv);
|
||||
Init();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -296,14 +296,27 @@ RenderShadowMap(void)
|
||||
0, 1, 0); /* up */
|
||||
|
||||
if (UseFBO) {
|
||||
GLenum fbo_status;
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, depthFormat,
|
||||
ShadowTexWidth, ShadowTexHeight, 0,
|
||||
depthFormat, depthType, NULL);
|
||||
|
||||
/* Set the filter mode so that the texture is texture-complete.
|
||||
* Otherwise it will cause the framebuffer to fail the framebuffer
|
||||
* completeness test.
|
||||
*/
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, ShadowFBO);
|
||||
glDrawBuffer(GL_NONE);
|
||||
glReadBuffer(GL_NONE);
|
||||
assert(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)
|
||||
== GL_FRAMEBUFFER_COMPLETE_EXT);
|
||||
|
||||
fbo_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
if (fbo_status != GL_FRAMEBUFFER_COMPLETE_EXT) {
|
||||
fprintf(stderr, "FBO not complete! status = 0x%04x\n", fbo_status);
|
||||
assert(fbo_status == GL_FRAMEBUFFER_COMPLETE_EXT);
|
||||
}
|
||||
}
|
||||
|
||||
assert(!glIsEnabled(GL_TEXTURE_1D));
|
||||
|
@@ -4,10 +4,10 @@
|
||||
* Updated for GLU 1.3 tessellation by Gareth Hughes <gareth@valinux.com>
|
||||
*/
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#define MAX_POINTS 256
|
||||
#define MAX_CONTOURS 32
|
||||
|
36
progs/glsl/CH06-brick.frag.txt
Normal file
36
progs/glsl/CH06-brick.frag.txt
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Fragment shader for procedural bricks
|
||||
//
|
||||
// Authors: Dave Baldwin, Steve Koren, Randi Rost
|
||||
// based on a shader by Darwyn Peachey
|
||||
//
|
||||
// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
|
||||
//
|
||||
// See 3Dlabs-License.txt for license information
|
||||
//
|
||||
|
||||
uniform vec3 BrickColor, MortarColor;
|
||||
uniform vec2 BrickSize;
|
||||
uniform vec2 BrickPct;
|
||||
|
||||
varying vec2 MCposition;
|
||||
varying float LightIntensity;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 color;
|
||||
vec2 position, useBrick;
|
||||
|
||||
position = MCposition / BrickSize;
|
||||
|
||||
if (fract(position.y * 0.5) > 0.5)
|
||||
position.x += 0.5;
|
||||
|
||||
position = fract(position);
|
||||
|
||||
useBrick = step(position, BrickPct);
|
||||
|
||||
color = mix(MortarColor, BrickColor, useBrick.x * useBrick.y);
|
||||
color *= LightIntensity;
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
}
|
41
progs/glsl/CH06-brick.vert.txt
Normal file
41
progs/glsl/CH06-brick.vert.txt
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Vertex shader for procedural bricks
|
||||
//
|
||||
// Authors: Dave Baldwin, Steve Koren, Randi Rost
|
||||
// based on a shader by Darwyn Peachey
|
||||
//
|
||||
// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
|
||||
//
|
||||
// See 3Dlabs-License.txt for license information
|
||||
//
|
||||
|
||||
uniform vec3 LightPosition;
|
||||
|
||||
const float SpecularContribution = 0.3;
|
||||
const float DiffuseContribution = 1.0 - SpecularContribution;
|
||||
|
||||
varying float LightIntensity;
|
||||
varying vec2 MCposition;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
|
||||
vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
|
||||
vec3 lightVec = normalize(LightPosition - ecPosition);
|
||||
vec3 reflectVec = reflect(-lightVec, tnorm);
|
||||
vec3 viewVec = normalize(-ecPosition);
|
||||
float diffuse = max(dot(lightVec, tnorm), 0.0);
|
||||
float spec = 0.0;
|
||||
|
||||
if (diffuse > 0.0)
|
||||
{
|
||||
spec = max(dot(reflectVec, viewVec), 0.0);
|
||||
spec = pow(spec, 16.0);
|
||||
}
|
||||
|
||||
LightIntensity = DiffuseContribution * diffuse +
|
||||
SpecularContribution * spec;
|
||||
|
||||
MCposition = gl_Vertex.xy;
|
||||
gl_Position = ftransform();
|
||||
}
|
41
progs/glsl/CH11-bumpmap.frag.txt
Normal file
41
progs/glsl/CH11-bumpmap.frag.txt
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Fragment shader for procedural bumps
|
||||
//
|
||||
// Authors: John Kessenich, Randi Rost
|
||||
//
|
||||
// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
|
||||
//
|
||||
// See 3Dlabs-License.txt for license information
|
||||
//
|
||||
|
||||
varying vec3 LightDir;
|
||||
varying vec3 EyeDir;
|
||||
|
||||
uniform vec3 SurfaceColor; // = (0.7, 0.6, 0.18)
|
||||
uniform float BumpDensity; // = 16.0
|
||||
uniform float BumpSize; // = 0.15
|
||||
uniform float SpecularFactor; // = 0.5
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 litColor;
|
||||
vec2 c = BumpDensity * gl_TexCoord[0].st;
|
||||
vec2 p = fract(c) - vec2(0.5);
|
||||
|
||||
float d, f;
|
||||
d = p.x * p.x + p.y * p.y;
|
||||
f = 1.0 / sqrt(d + 1.0);
|
||||
|
||||
if (d >= BumpSize)
|
||||
{ p = vec2(0.0); f = 1.0; }
|
||||
|
||||
vec3 normDelta = vec3(p.x, p.y, 1.0) * f;
|
||||
litColor = SurfaceColor * max(dot(normDelta, LightDir), 0.0);
|
||||
vec3 reflectDir = reflect(LightDir, normDelta);
|
||||
|
||||
float spec = max(dot(EyeDir, reflectDir), 0.0);
|
||||
spec *= SpecularFactor;
|
||||
litColor = min(litColor + spec, vec3(1.0));
|
||||
|
||||
gl_FragColor = vec4(litColor, 1.0);
|
||||
}
|
38
progs/glsl/CH11-bumpmap.vert.txt
Normal file
38
progs/glsl/CH11-bumpmap.vert.txt
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Vertex shader for procedural bumps
|
||||
//
|
||||
// Authors: Randi Rost, John Kessenich
|
||||
//
|
||||
// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
|
||||
//
|
||||
// See 3Dlabs-License.txt for license information
|
||||
//
|
||||
|
||||
varying vec3 LightDir;
|
||||
varying vec3 EyeDir;
|
||||
|
||||
uniform vec3 LightPosition;
|
||||
|
||||
attribute vec3 Tangent;
|
||||
|
||||
void main()
|
||||
{
|
||||
EyeDir = vec3(gl_ModelViewMatrix * gl_Vertex);
|
||||
gl_Position = ftransform();
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
|
||||
vec3 n = normalize(gl_NormalMatrix * gl_Normal);
|
||||
vec3 t = normalize(gl_NormalMatrix * Tangent);
|
||||
vec3 b = cross(n, t);
|
||||
|
||||
vec3 v;
|
||||
v.x = dot(LightPosition, t);
|
||||
v.y = dot(LightPosition, b);
|
||||
v.z = dot(LightPosition, n);
|
||||
LightDir = normalize(v);
|
||||
|
||||
v.x = dot(EyeDir, t);
|
||||
v.y = dot(EyeDir, b);
|
||||
v.z = dot(EyeDir, n);
|
||||
EyeDir = normalize(v);
|
||||
}
|
75
progs/glsl/CH11-toyball.frag.txt
Normal file
75
progs/glsl/CH11-toyball.frag.txt
Normal file
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// Fragment shader for procedurally generated toy ball
|
||||
//
|
||||
// Author: Bill Licea-Kane
|
||||
//
|
||||
// Copyright (c) 2002-2003 ATI Research
|
||||
//
|
||||
// See ATI-License.txt for license information
|
||||
//
|
||||
|
||||
varying vec4 ECposition; // surface position in eye coordinates
|
||||
varying vec4 ECballCenter; // ball center in eye coordinates
|
||||
|
||||
uniform vec4 LightDir; // light direction, should be normalized
|
||||
uniform vec4 HVector; // reflection vector for infinite light source
|
||||
uniform vec4 SpecularColor;
|
||||
uniform vec4 Red, Yellow, Blue;
|
||||
|
||||
uniform vec4 HalfSpace0; // half-spaces used to define star pattern
|
||||
uniform vec4 HalfSpace1;
|
||||
uniform vec4 HalfSpace2;
|
||||
uniform vec4 HalfSpace3;
|
||||
uniform vec4 HalfSpace4;
|
||||
|
||||
uniform float InOrOutInit; // = -3
|
||||
uniform float StripeWidth; // = 0.3
|
||||
uniform float FWidth; // = 0.005
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 normal; // Analytically computed normal
|
||||
vec4 p; // Point in shader space
|
||||
vec4 surfColor; // Computed color of the surface
|
||||
float intensity; // Computed light intensity
|
||||
vec4 distance; // Computed distance values
|
||||
float inorout; // Counter for computing star pattern
|
||||
|
||||
p.xyz = normalize(ECposition.xyz - ECballCenter.xyz); // Calculate p
|
||||
p.w = 1.0;
|
||||
|
||||
inorout = InOrOutInit; // initialize inorout to -3
|
||||
|
||||
distance[0] = dot(p, HalfSpace0);
|
||||
distance[1] = dot(p, HalfSpace1);
|
||||
distance[2] = dot(p, HalfSpace2);
|
||||
distance[3] = dot(p, HalfSpace3);
|
||||
|
||||
distance = smoothstep(-FWidth, FWidth, distance);
|
||||
inorout += dot(distance, vec4(1.0));
|
||||
|
||||
distance.x = dot(p, HalfSpace4);
|
||||
distance.y = StripeWidth - abs(p.z);
|
||||
distance = smoothstep(-FWidth, FWidth, distance);
|
||||
inorout += distance.x;
|
||||
|
||||
inorout = clamp(inorout, 0.0, 1.0);
|
||||
|
||||
surfColor = mix(Yellow, Red, inorout);
|
||||
surfColor = mix(surfColor, Blue, distance.y);
|
||||
|
||||
// normal = point on surface for sphere at (0,0,0)
|
||||
normal = p;
|
||||
|
||||
// Per fragment diffuse lighting
|
||||
intensity = 0.2; // ambient
|
||||
intensity += 0.8 * clamp(dot(LightDir, normal), 0.0, 1.0);
|
||||
surfColor *= intensity;
|
||||
|
||||
// Per fragment specular lighting
|
||||
intensity = clamp(dot(HVector, normal), 0.0, 1.0);
|
||||
intensity = pow(intensity, SpecularColor.a);
|
||||
surfColor += SpecularColor * intensity;
|
||||
|
||||
gl_FragColor = surfColor;
|
||||
}
|
24
progs/glsl/CH11-toyball.vert.txt
Normal file
24
progs/glsl/CH11-toyball.vert.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Fragment shader for procedurally generated toy ball
|
||||
//
|
||||
// Author: Bill Licea-Kane
|
||||
//
|
||||
// Copyright (c) 2002-2003 ATI Research
|
||||
//
|
||||
// See ATI-License.txt for license information
|
||||
//
|
||||
|
||||
varying vec4 ECposition; // surface position in eye coordinates
|
||||
varying vec4 ECballCenter; // ball center in eye coordinates
|
||||
uniform vec4 BallCenter; // ball center in modelling coordinates
|
||||
|
||||
void main()
|
||||
{
|
||||
//orig: ECposition = gl_ModelViewMatrix * gl_Vertex;
|
||||
|
||||
ECposition = gl_TextureMatrix[0] * gl_Vertex;
|
||||
ECposition = gl_ModelViewMatrix * ECposition;
|
||||
|
||||
ECballCenter = gl_ModelViewMatrix * BallCenter;
|
||||
gl_Position = ftransform();
|
||||
}
|
55
progs/glsl/CH18-mandel.frag.txt
Normal file
55
progs/glsl/CH18-mandel.frag.txt
Normal file
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// Fragment shader for drawing the Mandelbrot set
|
||||
//
|
||||
// Authors: Dave Baldwin, Steve Koren, Randi Rost
|
||||
// based on a shader by Michael Rivero
|
||||
//
|
||||
// Copyright (c) 2002-2005: 3Dlabs, Inc.
|
||||
//
|
||||
// See 3Dlabs-License.txt for license information
|
||||
//
|
||||
|
||||
varying vec3 Position;
|
||||
varying float LightIntensity;
|
||||
|
||||
uniform float MaxIterations;
|
||||
uniform float Zoom;
|
||||
uniform float Xcenter;
|
||||
uniform float Ycenter;
|
||||
uniform vec3 InnerColor;
|
||||
uniform vec3 OuterColor1;
|
||||
uniform vec3 OuterColor2;
|
||||
|
||||
void main()
|
||||
{
|
||||
float real = Position.x * Zoom + Xcenter;
|
||||
float imag = Position.y * Zoom + Ycenter;
|
||||
float Creal = real; // Change this line...
|
||||
float Cimag = imag; // ...and this one to get a Julia set
|
||||
|
||||
float r2 = 0.0;
|
||||
float iter;
|
||||
|
||||
// for (iter = 0.0; iter < MaxIterations && r2 < 4.0; ++iter)
|
||||
for (iter = 0.0; iter < 12 && r2 < 4.0; ++iter)
|
||||
{
|
||||
float tempreal = real;
|
||||
|
||||
real = (tempreal * tempreal) - (imag * imag) + Creal;
|
||||
imag = 2.0 * tempreal * imag + Cimag;
|
||||
r2 = (real * real) + (imag * imag);
|
||||
}
|
||||
|
||||
// Base the color on the number of iterations
|
||||
|
||||
vec3 color;
|
||||
|
||||
if (r2 < 4.0)
|
||||
color = InnerColor;
|
||||
else
|
||||
color = mix(OuterColor1, OuterColor2, fract(iter * 0.05));
|
||||
|
||||
color *= LightIntensity;
|
||||
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
}
|
35
progs/glsl/CH18-mandel.vert.txt
Normal file
35
progs/glsl/CH18-mandel.vert.txt
Normal file
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Vertex shader for drawing the Mandelbrot set
|
||||
//
|
||||
// Authors: Dave Baldwin, Steve Koren, Randi Rost
|
||||
// based on a shader by Michael Rivero
|
||||
//
|
||||
// Copyright (c) 2002-2005: 3Dlabs, Inc.
|
||||
//
|
||||
// See 3Dlabs-License.txt for license information
|
||||
//
|
||||
|
||||
uniform vec3 LightPosition;
|
||||
uniform float SpecularContribution;
|
||||
uniform float DiffuseContribution;
|
||||
uniform float Shininess;
|
||||
|
||||
varying float LightIntensity;
|
||||
varying vec3 Position;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
|
||||
vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
|
||||
vec3 lightVec = normalize(LightPosition - ecPosition);
|
||||
vec3 reflectVec = reflect(-lightVec, tnorm);
|
||||
vec3 viewVec = normalize(-ecPosition);
|
||||
float spec = max(dot(reflectVec, viewVec), 0.0);
|
||||
spec = pow(spec, Shininess);
|
||||
LightIntensity = DiffuseContribution *
|
||||
max(dot(lightVec, tnorm), 0.0) +
|
||||
SpecularContribution * spec;
|
||||
Position = vec3(gl_MultiTexCoord0 - 0.5) * 5.0;
|
||||
gl_Position = ftransform();
|
||||
|
||||
}
|
74
progs/glsl/Makefile
Normal file
74
progs/glsl/Makefile
Normal file
@@ -0,0 +1,74 @@
|
||||
# progs/demos/Makefile
|
||||
|
||||
TOP = ../..
|
||||
include $(TOP)/configs/current
|
||||
|
||||
INCDIR = $(TOP)/include
|
||||
|
||||
OSMESA_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa -lGLU -lGL $(APP_LIB_DEPS)
|
||||
|
||||
OSMESA16_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa16 -lGLU -lGL $(APP_LIB_DEPS)
|
||||
|
||||
OSMESA32_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa32 -lGLU -lGL $(APP_LIB_DEPS)
|
||||
|
||||
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
|
||||
|
||||
PROGS = \
|
||||
brick \
|
||||
bump \
|
||||
mandelbrot \
|
||||
noise \
|
||||
toyball \
|
||||
texdemo1
|
||||
|
||||
|
||||
##### RULES #####
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c
|
||||
|
||||
|
||||
# make executable from .c file:
|
||||
.c: $(LIB_DEP)
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
|
||||
|
||||
|
||||
##### TARGETS #####
|
||||
|
||||
default: $(PROGS)
|
||||
|
||||
|
||||
|
||||
##### Extra dependencies
|
||||
|
||||
extfuncs.h: $(TOP)/progs/util/extfuncs.h
|
||||
cp $< .
|
||||
|
||||
readtex.c: $(TOP)/progs/util/readtex.c
|
||||
cp $< .
|
||||
|
||||
readtex.h: $(TOP)/progs/util/readtex.h
|
||||
cp $< .
|
||||
|
||||
readtex.o: readtex.c readtex.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) readtex.c
|
||||
|
||||
brick.c: extfuncs.h
|
||||
|
||||
bump.c: extfuncs.h
|
||||
|
||||
mandelbrot.c: extfuncs.h
|
||||
|
||||
toyball.c: extfuncs.h
|
||||
|
||||
texdemo1: texdemo1.o readtex.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) texdemo1.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
texdemo1.o: texdemo1.c readtex.h extfuncs.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c
|
||||
|
||||
|
||||
clean:
|
||||
-rm -f $(PROGS)
|
||||
-rm -f *.o *~
|
||||
-rm -f extfuncs.h
|
311
progs/glsl/brick.c
Normal file
311
progs/glsl/brick.c
Normal file
@@ -0,0 +1,311 @@
|
||||
/**
|
||||
* "Brick" shader demo. Uses the example shaders from chapter 6 of
|
||||
* the OpenGL Shading Language "orange" book.
|
||||
* 10 Jan 2007
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
|
||||
|
||||
static char *FragProgFile = "CH06-brick.frag.txt";
|
||||
static char *VertProgFile = "CH06-brick.vert.txt";
|
||||
|
||||
/* program/shader objects */
|
||||
static GLuint fragShader;
|
||||
static GLuint vertShader;
|
||||
static GLuint program;
|
||||
|
||||
|
||||
struct uniform_info {
|
||||
const char *name;
|
||||
GLuint size;
|
||||
GLint location;
|
||||
GLfloat value[4];
|
||||
};
|
||||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
/* vert */
|
||||
{ "LightPosition", 3, -1, { 0.1, 0.1, 9.0, 0} },
|
||||
/* frag */
|
||||
{ "BrickColor", 3, -1, { 0.8, 0.2, 0.2, 0 } },
|
||||
{ "MortarColor", 3, -1, { 0.6, 0.6, 0.6, 0 } },
|
||||
{ "BrickSize", 2, -1, { 1.0, 0.3, 0, 0 } },
|
||||
{ "BrickPct", 2, -1, { 0.9, 0.8, 0, 0 } },
|
||||
{ NULL, 0, 0, { 0, 0, 0, 0 } }
|
||||
};
|
||||
|
||||
static GLint win = 0;
|
||||
|
||||
|
||||
static GLfloat xRot = 0.0f, yRot = 0.0f, zRot = 0.0f;
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
Redisplay(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
|
||||
glRotatef(zRot, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
glTexCoord2f(0, 0); glVertex2f(-2, -2);
|
||||
glTexCoord2f(1, 0); glVertex2f( 2, -2);
|
||||
glTexCoord2f(1, 1); glVertex2f( 2, 2);
|
||||
glTexCoord2f(0, 1); glVertex2f(-2, 2);
|
||||
glEnd();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Reshape(int width, int height)
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0f, 0.0f, -15.0f);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CleanUp(void)
|
||||
{
|
||||
glDeleteShader_func(fragShader);
|
||||
glDeleteShader_func(vertShader);
|
||||
glDeleteProgram_func(program);
|
||||
glutDestroyWindow(win);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch(key) {
|
||||
case 'z':
|
||||
zRot -= 1.0;
|
||||
break;
|
||||
case 'Z':
|
||||
zRot += 1.0;
|
||||
break;
|
||||
case 27:
|
||||
CleanUp();
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SpecialKey(int key, int x, int y)
|
||||
{
|
||||
const GLfloat step = 3.0f;
|
||||
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch(key) {
|
||||
case GLUT_KEY_UP:
|
||||
xRot -= step;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
xRot += step;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
yRot -= step;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
yRot += step;
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "brick: problem compiling shader: %s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
printf("Shader compiled OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
static void
|
||||
ReadShader(GLuint shader, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "brick: Unable to open shader file %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
printf("brick: read %d bytes from shader file %s\n", n, filename);
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
LoadAndCompileShader(shader, buffer);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Link success!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
const char *version;
|
||||
GLint i;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("Warning: this program expects OpenGL 2.0\n");
|
||||
/*exit(1);*/
|
||||
}
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
ReadShader(vertShader, VertProgFile);
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
ReadShader(fragShader, FragProgFile);
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
|
||||
for (i = 0; Uniforms[i].name; i++) {
|
||||
Uniforms[i].location
|
||||
= glGetUniformLocation_func(program, Uniforms[i].name);
|
||||
printf("Uniform %s location: %d\n", Uniforms[i].name,
|
||||
Uniforms[i].location);
|
||||
switch (Uniforms[i].size) {
|
||||
case 1:
|
||||
glUniform1fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 2:
|
||||
glUniform2fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 3:
|
||||
glUniform3fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 4:
|
||||
glUniform4fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
assert(glGetError() == 0);
|
||||
|
||||
glClearColor(0.4f, 0.4f, 0.8f, 0.0f);
|
||||
|
||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||
|
||||
assert(glIsProgram_func(program));
|
||||
assert(glIsShader_func(fragShader));
|
||||
assert(glIsShader_func(vertShader));
|
||||
|
||||
glColor3f(1, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ParseOptions(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-fs") == 0) {
|
||||
FragProgFile = argv[i+1];
|
||||
}
|
||||
else if (strcmp(argv[i], "-vs") == 0) {
|
||||
VertProgFile = argv[i+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
glutDisplayFunc(Redisplay);
|
||||
ParseOptions(argc, argv);
|
||||
Init();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
|
411
progs/glsl/bump.c
Normal file
411
progs/glsl/bump.c
Normal file
@@ -0,0 +1,411 @@
|
||||
/**
|
||||
* Procedural Bump Mapping demo. Uses the example shaders from
|
||||
* chapter 11 of the OpenGL Shading Language "orange" book.
|
||||
* 16 Jan 2007
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glu.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
|
||||
|
||||
static char *FragProgFile = "CH11-bumpmap.frag.txt";
|
||||
static char *VertProgFile = "CH11-bumpmap.vert.txt";
|
||||
|
||||
/* program/shader objects */
|
||||
static GLuint fragShader;
|
||||
static GLuint vertShader;
|
||||
static GLuint program;
|
||||
|
||||
|
||||
struct uniform_info {
|
||||
const char *name;
|
||||
GLuint size;
|
||||
GLint location;
|
||||
GLfloat value[4];
|
||||
};
|
||||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
{ "LightPosition", 3, -1, { 0.57737, 0.57735, 0.57735, 0.0 } },
|
||||
{ "SurfaceColor", 3, -1, { 0.8, 0.8, 0.2, 0 } },
|
||||
{ "BumpDensity", 1, -1, { 10.0, 0, 0, 0 } },
|
||||
{ "BumpSize", 1, -1, { 0.125, 0, 0, 0 } },
|
||||
{ "SpecularFactor", 1, -1, { 0.5, 0, 0, 0 } },
|
||||
{ NULL, 0, 0, { 0, 0, 0, 0 } }
|
||||
};
|
||||
|
||||
static GLint win = 0;
|
||||
|
||||
static GLfloat xRot = 20.0f, yRot = 0.0f, zRot = 0.0f;
|
||||
|
||||
static GLuint tangentAttrib;
|
||||
|
||||
static GLboolean Anim = GL_FALSE;
|
||||
|
||||
|
||||
static void
|
||||
CheckError(int line)
|
||||
{
|
||||
GLenum err = glGetError();
|
||||
if (err) {
|
||||
printf("GL Error %s (0x%x) at line %d\n",
|
||||
gluErrorString(err), (int) err, line);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Draw a square, specifying normal and tangent vectors.
|
||||
*/
|
||||
static void
|
||||
Square(GLfloat size)
|
||||
{
|
||||
glNormal3f(0, 0, 1);
|
||||
glVertexAttrib3f_func(tangentAttrib, 1, 0, 0);
|
||||
glBegin(GL_POLYGON);
|
||||
glTexCoord2f(0, 0); glVertex2f(-size, -size);
|
||||
glTexCoord2f(1, 0); glVertex2f( size, -size);
|
||||
glTexCoord2f(1, 1); glVertex2f( size, size);
|
||||
glTexCoord2f(0, 1); glVertex2f(-size, size);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Cube(GLfloat size)
|
||||
{
|
||||
/* +X */
|
||||
glPushMatrix();
|
||||
glRotatef(90, 0, 1, 0);
|
||||
glTranslatef(0, 0, size);
|
||||
Square(size);
|
||||
glPopMatrix();
|
||||
|
||||
/* -X */
|
||||
glPushMatrix();
|
||||
glRotatef(-90, 0, 1, 0);
|
||||
glTranslatef(0, 0, size);
|
||||
Square(size);
|
||||
glPopMatrix();
|
||||
|
||||
/* +Y */
|
||||
glPushMatrix();
|
||||
glRotatef(90, 1, 0, 0);
|
||||
glTranslatef(0, 0, size);
|
||||
Square(size);
|
||||
glPopMatrix();
|
||||
|
||||
/* -Y */
|
||||
glPushMatrix();
|
||||
glRotatef(-90, 1, 0, 0);
|
||||
glTranslatef(0, 0, size);
|
||||
Square(size);
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
/* +Z */
|
||||
glPushMatrix();
|
||||
glTranslatef(0, 0, size);
|
||||
Square(size);
|
||||
glPopMatrix();
|
||||
|
||||
/* -Z */
|
||||
glPushMatrix();
|
||||
glRotatef(180, 0, 1, 0);
|
||||
glTranslatef(0, 0, size);
|
||||
Square(size);
|
||||
glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Idle(void)
|
||||
{
|
||||
GLint t = glutGet(GLUT_ELAPSED_TIME);
|
||||
yRot = t * 0.05;
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Redisplay(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
|
||||
glRotatef(zRot, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
Cube(1.5);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glFinish();
|
||||
glFlush();
|
||||
|
||||
CheckError(__LINE__);
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Reshape(int width, int height)
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0f, 0.0f, -15.0f);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CleanUp(void)
|
||||
{
|
||||
glDeleteShader_func(fragShader);
|
||||
glDeleteShader_func(vertShader);
|
||||
glDeleteProgram_func(program);
|
||||
glutDestroyWindow(win);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
const GLfloat step = 2.0;
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch(key) {
|
||||
case 'a':
|
||||
Anim = !Anim;
|
||||
glutIdleFunc(Anim ? Idle : NULL);
|
||||
break;
|
||||
case 'z':
|
||||
zRot += step;
|
||||
break;
|
||||
case 'Z':
|
||||
zRot -= step;
|
||||
break;
|
||||
case 27:
|
||||
CleanUp();
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SpecialKey(int key, int x, int y)
|
||||
{
|
||||
const GLfloat step = 2.0;
|
||||
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch(key) {
|
||||
case GLUT_KEY_UP:
|
||||
xRot += step;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
xRot -= step;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
yRot -= step;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
yRot += step;
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "brick: problem compiling shader: %s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
printf("Shader compiled OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
static void
|
||||
ReadShader(GLuint shader, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "brick: Unable to open shader file %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
printf("brick: read %d bytes from shader file %s\n", n, filename);
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
LoadAndCompileShader(shader, buffer);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Link success!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
const char *version;
|
||||
GLint i;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("Warning: this program expects OpenGL 2.0\n");
|
||||
/*exit(1);*/
|
||||
}
|
||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
ReadShader(vertShader, VertProgFile);
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
ReadShader(fragShader, FragProgFile);
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
|
||||
assert(glIsProgram_func(program));
|
||||
assert(glIsShader_func(fragShader));
|
||||
assert(glIsShader_func(vertShader));
|
||||
|
||||
assert(glGetError() == 0);
|
||||
|
||||
CheckError(__LINE__);
|
||||
|
||||
for (i = 0; Uniforms[i].name; i++) {
|
||||
Uniforms[i].location
|
||||
= glGetUniformLocation_func(program, Uniforms[i].name);
|
||||
printf("Uniform %s location: %d\n", Uniforms[i].name,
|
||||
Uniforms[i].location);
|
||||
switch (Uniforms[i].size) {
|
||||
case 1:
|
||||
glUniform1fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 2:
|
||||
glUniform2fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 3:
|
||||
glUniform3fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 4:
|
||||
glUniform4fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
CheckError(__LINE__);
|
||||
|
||||
tangentAttrib = glGetAttribLocation_func(program, "Tangent");
|
||||
printf("Tangent Attrib: %d\n", tangentAttrib);
|
||||
|
||||
assert(tangentAttrib >= 0);
|
||||
|
||||
CheckError(__LINE__);
|
||||
|
||||
glClearColor(0.4f, 0.4f, 0.8f, 0.0f);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glColor3f(1, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ParseOptions(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-fs") == 0) {
|
||||
FragProgFile = argv[i+1];
|
||||
}
|
||||
else if (strcmp(argv[i], "-vs") == 0) {
|
||||
VertProgFile = argv[i+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
glutDisplayFunc(Redisplay);
|
||||
ParseOptions(argc, argv);
|
||||
Init();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
|
18
progs/glsl/cubemap.frag.txt
Normal file
18
progs/glsl/cubemap.frag.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
// Fragment shader for cube-texture reflection mapping
|
||||
// Brian Paul
|
||||
|
||||
|
||||
uniform samplerCube cubeTex;
|
||||
varying vec3 normal;
|
||||
uniform vec3 lightPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
// simple diffuse, specular lighting:
|
||||
vec3 lp = normalize(lightPos);
|
||||
float dp = dot(lp, normalize(normal));
|
||||
float spec = pow(dp, 5.0);
|
||||
|
||||
// final color:
|
||||
gl_FragColor = dp * textureCube(cubeTex, gl_TexCoord[0].xyz, 0.0) + spec;
|
||||
}
|
328
progs/glsl/mandelbrot.c
Normal file
328
progs/glsl/mandelbrot.c
Normal file
@@ -0,0 +1,328 @@
|
||||
/**
|
||||
* "Mandelbrot" shader demo. Uses the example shaders from
|
||||
* chapter 15 (or 18) of the OpenGL Shading Language "orange" book.
|
||||
* 15 Jan 2007
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
|
||||
|
||||
static char *FragProgFile = "CH18-mandel.frag.txt";
|
||||
static char *VertProgFile = "CH18-mandel.vert.txt";
|
||||
|
||||
/* program/shader objects */
|
||||
static GLuint fragShader;
|
||||
static GLuint vertShader;
|
||||
static GLuint program;
|
||||
|
||||
|
||||
struct uniform_info {
|
||||
const char *name;
|
||||
GLuint size;
|
||||
GLint location;
|
||||
GLfloat value[4];
|
||||
};
|
||||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
/* vert */
|
||||
{ "LightPosition", 3, -1, { 0.1, 0.1, 9.0, 0} },
|
||||
{ "SpecularContribution", 1, -1, { 0.5, 0, 0, 0 } },
|
||||
{ "DiffuseContribution", 1, -1, { 0.5, 0, 0, 0 } },
|
||||
{ "Shininess", 1, -1, { 20.0, 0, 0, 0 } },
|
||||
/* frag */
|
||||
{ "MaxIterations", 1, -1, { 12, 0, 0, 0 } },
|
||||
{ "Zoom", 1, -1, { 0.125, 0, 0, 0 } },
|
||||
{ "Xcenter", 1, -1, { -1.5, 0, 0, 0 } },
|
||||
{ "Ycenter", 1, -1, { .005, 0, 0, 0 } },
|
||||
{ "InnerColor", 3, -1, { 1, 0, 0, 0 } },
|
||||
{ "OuterColor1", 3, -1, { 0, 1, 0, 0 } },
|
||||
{ "OuterColor2", 3, -1, { 0, 0, 1, 0 } },
|
||||
{ NULL, 0, 0, { 0, 0, 0, 0 } }
|
||||
};
|
||||
|
||||
static GLint win = 0;
|
||||
|
||||
static GLfloat xRot = 0.0f, yRot = 0.0f, zRot = 0.0f;
|
||||
|
||||
static GLint uZoom, uXcenter, uYcenter;
|
||||
static GLfloat zoom = 1.0, xCenter = -1.5, yCenter = 0.0;
|
||||
|
||||
|
||||
static void
|
||||
Redisplay(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
/* set interactive uniform parameters */
|
||||
glUniform1fv_func(uZoom, 1, &zoom);
|
||||
glUniform1fv_func(uXcenter, 1, &xCenter);
|
||||
glUniform1fv_func(uYcenter, 1, &yCenter);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
|
||||
glRotatef(zRot, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
glTexCoord2f(0, 0); glVertex2f(-1, -1);
|
||||
glTexCoord2f(1, 0); glVertex2f( 1, -1);
|
||||
glTexCoord2f(1, 1); glVertex2f( 1, 1);
|
||||
glTexCoord2f(0, 1); glVertex2f(-1, 1);
|
||||
glEnd();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glFinish();
|
||||
glFlush();
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Reshape(int width, int height)
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0f, 0.0f, -6.0f);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CleanUp(void)
|
||||
{
|
||||
glDeleteShader_func(fragShader);
|
||||
glDeleteShader_func(vertShader);
|
||||
glDeleteProgram_func(program);
|
||||
glutDestroyWindow(win);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch(key) {
|
||||
case 'z':
|
||||
zoom *= 0.9;
|
||||
break;
|
||||
case 'Z':
|
||||
zoom /= 0.9;
|
||||
break;
|
||||
case 27:
|
||||
CleanUp();
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SpecialKey(int key, int x, int y)
|
||||
{
|
||||
const GLfloat step = 0.1 * zoom;
|
||||
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch(key) {
|
||||
case GLUT_KEY_UP:
|
||||
yCenter += step;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
yCenter -= step;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
xCenter -= step;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
xCenter += step;
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "brick: problem compiling shader: %s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
printf("Shader compiled OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
static void
|
||||
ReadShader(GLuint shader, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "brick: Unable to open shader file %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
printf("brick: read %d bytes from shader file %s\n", n, filename);
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
LoadAndCompileShader(shader, buffer);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Link success!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
const char *version;
|
||||
GLint i;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("Warning: this program expects OpenGL 2.0\n");
|
||||
/*exit(1);*/
|
||||
}
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
ReadShader(vertShader, VertProgFile);
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
ReadShader(fragShader, FragProgFile);
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
|
||||
for (i = 0; Uniforms[i].name; i++) {
|
||||
Uniforms[i].location
|
||||
= glGetUniformLocation_func(program, Uniforms[i].name);
|
||||
printf("Uniform %s location: %d\n", Uniforms[i].name,
|
||||
Uniforms[i].location);
|
||||
switch (Uniforms[i].size) {
|
||||
case 1:
|
||||
glUniform1fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 2:
|
||||
glUniform2fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 3:
|
||||
glUniform3fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 4:
|
||||
glUniform4fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
uZoom = glGetUniformLocation_func(program, "Zoom");
|
||||
uXcenter = glGetUniformLocation_func(program, "Xcenter");
|
||||
uYcenter = glGetUniformLocation_func(program, "Ycenter");
|
||||
|
||||
assert(glGetError() == 0);
|
||||
|
||||
glClearColor(0.4f, 0.4f, 0.8f, 0.0f);
|
||||
|
||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||
|
||||
assert(glIsProgram_func(program));
|
||||
assert(glIsShader_func(fragShader));
|
||||
assert(glIsShader_func(vertShader));
|
||||
|
||||
glColor3f(1, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ParseOptions(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-fs") == 0) {
|
||||
FragProgFile = argv[i+1];
|
||||
}
|
||||
else if (strcmp(argv[i], "-vs") == 0) {
|
||||
VertProgFile = argv[i+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
glutDisplayFunc(Redisplay);
|
||||
ParseOptions(argc, argv);
|
||||
Init();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
|
297
progs/glsl/noise.c
Normal file
297
progs/glsl/noise.c
Normal file
@@ -0,0 +1,297 @@
|
||||
/**
|
||||
* Test noise() functions.
|
||||
* 28 Jan 2007
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
|
||||
|
||||
static const char *VertShaderText =
|
||||
"void main() {\n"
|
||||
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
||||
" gl_TexCoord[0] = gl_MultiTexCoord0;\n"
|
||||
"}\n";
|
||||
|
||||
static const char *FragShaderText =
|
||||
"uniform vec4 Scale, Bias;\n"
|
||||
"uniform float Slice;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec4 scale = vec4(5.0);\n"
|
||||
" vec4 p;\n"
|
||||
" p.xy = gl_TexCoord[0].xy;\n"
|
||||
" p.z = Slice;\n"
|
||||
" vec4 n = noise4(p * scale);\n"
|
||||
" gl_FragColor = n * Scale + Bias;\n"
|
||||
"}\n";
|
||||
|
||||
|
||||
struct uniform_info {
|
||||
const char *name;
|
||||
GLuint size;
|
||||
GLint location;
|
||||
GLfloat value[4];
|
||||
};
|
||||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
{ "Scale", 4, -1, { 0.5, 0.4, 0.0, 0} },
|
||||
{ "Bias", 4, -1, { 0.5, 0.3, 0.0, 0} },
|
||||
{ "Slice", 1, -1, { 0.5, 0, 0, 0} },
|
||||
{ NULL, 0, 0, { 0, 0, 0, 0 } }
|
||||
};
|
||||
|
||||
/* program/shader objects */
|
||||
static GLuint fragShader;
|
||||
static GLuint vertShader;
|
||||
static GLuint program;
|
||||
|
||||
static GLint win = 0;
|
||||
static GLfloat xRot = 0.0f, yRot = 0.0f, zRot = 0.0f;
|
||||
static GLfloat Slice = 0.0;
|
||||
static GLboolean Anim = GL_FALSE;
|
||||
|
||||
|
||||
static void
|
||||
Idle(void)
|
||||
{
|
||||
Slice += 0.01;
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Redisplay(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glUniform1fv_func(Uniforms[2].location, 1, &Slice);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
|
||||
glRotatef(zRot, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
glTexCoord2f(0, 0); glVertex2f(-2, -2);
|
||||
glTexCoord2f(1, 0); glVertex2f( 2, -2);
|
||||
glTexCoord2f(1, 1); glVertex2f( 2, 2);
|
||||
glTexCoord2f(0, 1); glVertex2f(-2, 2);
|
||||
glEnd();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Reshape(int width, int height)
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0f, 0.0f, -15.0f);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CleanUp(void)
|
||||
{
|
||||
glDeleteShader_func(fragShader);
|
||||
glDeleteShader_func(vertShader);
|
||||
glDeleteProgram_func(program);
|
||||
glutDestroyWindow(win);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
const GLfloat step = 0.01;
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch(key) {
|
||||
case 'a':
|
||||
Anim = !Anim;
|
||||
glutIdleFunc(Anim ? Idle : NULL);
|
||||
case 's':
|
||||
Slice -= step;
|
||||
break;
|
||||
case 'S':
|
||||
Slice += step;
|
||||
break;
|
||||
case 'z':
|
||||
zRot -= 1.0;
|
||||
break;
|
||||
case 'Z':
|
||||
zRot += 1.0;
|
||||
break;
|
||||
case 27:
|
||||
CleanUp();
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SpecialKey(int key, int x, int y)
|
||||
{
|
||||
const GLfloat step = 3.0f;
|
||||
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch(key) {
|
||||
case GLUT_KEY_UP:
|
||||
xRot -= step;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
xRot += step;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
yRot -= step;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
yRot += step;
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "brick: problem compiling shader: %s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
printf("Shader compiled OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Link success!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
const char *version;
|
||||
GLint i;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("Warning: this program expects OpenGL 2.0\n");
|
||||
/*exit(1);*/
|
||||
}
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
LoadAndCompileShader(vertShader, VertShaderText);
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
LoadAndCompileShader(fragShader, FragShaderText);
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
|
||||
for (i = 0; Uniforms[i].name; i++) {
|
||||
Uniforms[i].location
|
||||
= glGetUniformLocation_func(program, Uniforms[i].name);
|
||||
printf("Uniform %s location: %d\n", Uniforms[i].name,
|
||||
Uniforms[i].location);
|
||||
switch (Uniforms[i].size) {
|
||||
case 1:
|
||||
glUniform1fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 2:
|
||||
glUniform2fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 3:
|
||||
glUniform3fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 4:
|
||||
glUniform4fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
assert(glGetError() == 0);
|
||||
|
||||
glClearColor(0.4f, 0.4f, 0.8f, 0.0f);
|
||||
|
||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||
|
||||
assert(glIsProgram_func(program));
|
||||
assert(glIsShader_func(fragShader));
|
||||
assert(glIsShader_func(vertShader));
|
||||
|
||||
glColor3f(1, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
glutDisplayFunc(Redisplay);
|
||||
Init();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
|
19
progs/glsl/reflect.vert.txt
Normal file
19
progs/glsl/reflect.vert.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
// Vertex shader for cube-texture reflection mapping
|
||||
// Brian Paul
|
||||
|
||||
|
||||
varying vec3 normal;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 n = gl_NormalMatrix * gl_Normal;
|
||||
vec3 u = normalize(vec3(gl_ModelViewMatrix * gl_Vertex));
|
||||
float two_n_dot_u = 2.0 * dot(n, u);
|
||||
vec4 f;
|
||||
f.xyz = u - n * two_n_dot_u;
|
||||
|
||||
// outputs
|
||||
normal = n;
|
||||
gl_TexCoord[0] = gl_TextureMatrix[0] * f;
|
||||
gl_Position = ftransform();
|
||||
}
|
21
progs/glsl/shadowtex.frag.txt
Normal file
21
progs/glsl/shadowtex.frag.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
// Fragment shader for 2D texture with shadow attenuation
|
||||
// Brian Paul
|
||||
|
||||
|
||||
uniform sampler2D tex2d;
|
||||
uniform vec3 lightPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
// XXX should compute this from lightPos
|
||||
vec2 shadowCenter = vec2(-0.25, -0.25);
|
||||
|
||||
// d = distance from center
|
||||
float d = distance(gl_TexCoord[0].xy, shadowCenter);
|
||||
|
||||
// attenuate and clamp
|
||||
d = clamp(d * d * d, 0.0, 2.0);
|
||||
|
||||
// modulate texture by d for shadow effect
|
||||
gl_FragColor = d * texture2D(tex2d, gl_TexCoord[0].xy, 0.0);
|
||||
}
|
9
progs/glsl/simple.vert.txt
Normal file
9
progs/glsl/simple.vert.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
// Simple vertex shader
|
||||
// Brian Paul
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = ftransform();
|
||||
}
|
570
progs/glsl/texdemo1.c
Normal file
570
progs/glsl/texdemo1.c
Normal file
@@ -0,0 +1,570 @@
|
||||
/**
|
||||
* Test texturing with GL shading language.
|
||||
*
|
||||
* Copyright (C) 2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "GL/glut.h"
|
||||
#include "readtex.h"
|
||||
#include "extfuncs.h"
|
||||
|
||||
static const char *Demo = "texdemo1";
|
||||
|
||||
static const char *ReflectVertFile = "reflect.vert.txt";
|
||||
static const char *CubeFragFile = "cubemap.frag.txt";
|
||||
|
||||
static const char *SimpleVertFile = "simple.vert.txt";
|
||||
static const char *SimpleTexFragFile = "shadowtex.frag.txt";
|
||||
|
||||
static const char *GroundImage = "../images/tile.rgb";
|
||||
|
||||
static GLuint Program1, Program2;
|
||||
|
||||
static GLfloat TexXrot = 0, TexYrot = 0;
|
||||
static GLfloat Xrot = 20.0, Yrot = 20.0, Zrot = 0.0;
|
||||
static GLfloat EyeDist = 10;
|
||||
static GLboolean Anim = GL_TRUE;
|
||||
|
||||
|
||||
struct uniform_info {
|
||||
const char *name;
|
||||
GLuint size;
|
||||
GLint location;
|
||||
GLenum type; /**< GL_FLOAT or GL_INT */
|
||||
GLfloat value[4];
|
||||
};
|
||||
|
||||
static struct uniform_info ReflectUniforms[] = {
|
||||
{ "cubeTex", 1, -1, GL_INT, { 0, 0, 0, 0 } },
|
||||
{ "lightPos", 3, -1, GL_FLOAT, { 10, 10, 20, 0 } },
|
||||
{ NULL, 0, 0, 0, { 0, 0, 0, 0 } }
|
||||
};
|
||||
|
||||
static struct uniform_info SimpleUniforms[] = {
|
||||
{ "tex2d", 1, -1, GL_INT, { 1, 0, 0, 0 } },
|
||||
{ "lightPos", 3, -1, GL_FLOAT, { 10, 10, 20, 0 } },
|
||||
{ NULL, 0, 0, 0, { 0, 0, 0, 0 } }
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
CheckError(int line)
|
||||
{
|
||||
GLenum err = glGetError();
|
||||
if (err) {
|
||||
printf("GL Error %s (0x%x) at line %d\n",
|
||||
gluErrorString(err), (int) err, line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawGround(GLfloat size)
|
||||
{
|
||||
glPushMatrix();
|
||||
glRotatef(90, 1, 0, 0);
|
||||
glNormal3f(0, 0, 1);
|
||||
glBegin(GL_POLYGON);
|
||||
glTexCoord2f(-2, -2); glVertex2f(-size, -size);
|
||||
glTexCoord2f( 2, -2); glVertex2f( size, -size);
|
||||
glTexCoord2f( 2, 2); glVertex2f( size, size);
|
||||
glTexCoord2f(-2, 2); glVertex2f(-size, size);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glPushMatrix(); /* modelview matrix */
|
||||
glTranslatef(0.0, 0.0, -EyeDist);
|
||||
glRotatef(Xrot, 1, 0, 0);
|
||||
glRotatef(Yrot, 0, 1, 0);
|
||||
glRotatef(Zrot, 0, 0, 1);
|
||||
|
||||
/* sphere w/ reflection map */
|
||||
glPushMatrix();
|
||||
glTranslatef(0, 1, 0);
|
||||
glUseProgram_func(Program1);
|
||||
|
||||
/* setup texture matrix */
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
glRotatef(-TexYrot, 0, 1, 0);
|
||||
glRotatef(-TexXrot, 1, 0, 0);
|
||||
|
||||
glEnable(GL_TEXTURE_GEN_S);
|
||||
glEnable(GL_TEXTURE_GEN_T);
|
||||
glEnable(GL_TEXTURE_GEN_R);
|
||||
glutSolidSphere(2.0, 20, 20);
|
||||
|
||||
glLoadIdentity(); /* texture matrix */
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
|
||||
/* ground */
|
||||
glUseProgram_func(Program2);
|
||||
glTranslatef(0, -1.0, 0);
|
||||
DrawGround(5);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
idle(void)
|
||||
{
|
||||
GLfloat t = 0.05 * glutGet(GLUT_ELAPSED_TIME);
|
||||
TexYrot = t;
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
key(unsigned char k, int x, int y)
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (k) {
|
||||
case ' ':
|
||||
case 'a':
|
||||
Anim = !Anim;
|
||||
if (Anim)
|
||||
glutIdleFunc(idle);
|
||||
else
|
||||
glutIdleFunc(NULL);
|
||||
break;
|
||||
case 'z':
|
||||
EyeDist -= 0.5;
|
||||
if (EyeDist < 6.0)
|
||||
EyeDist = 6.0;
|
||||
break;
|
||||
case 'Z':
|
||||
EyeDist += 0.5;
|
||||
if (EyeDist > 90.0)
|
||||
EyeDist = 90;
|
||||
break;
|
||||
case 27:
|
||||
exit(0);
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
specialkey(int key, int x, int y)
|
||||
{
|
||||
GLfloat step = 2.0;
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case GLUT_KEY_UP:
|
||||
Xrot += step;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
Xrot -= step;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
Yrot -= step;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
Yrot += step;
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
Reshape(int width, int height)
|
||||
{
|
||||
GLfloat ar = (float) width / (float) height;
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-2.0*ar, 2.0*ar, -2.0, 2.0, 4.0, 100.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
InitCheckers(void)
|
||||
{
|
||||
#define CUBE_TEX_SIZE 64
|
||||
GLubyte image[CUBE_TEX_SIZE][CUBE_TEX_SIZE][3];
|
||||
static const GLubyte colors[6][3] = {
|
||||
{ 255, 0, 0 }, /* face 0 - red */
|
||||
{ 0, 255, 255 }, /* face 1 - cyan */
|
||||
{ 0, 255, 0 }, /* face 2 - green */
|
||||
{ 255, 0, 255 }, /* face 3 - purple */
|
||||
{ 0, 0, 255 }, /* face 4 - blue */
|
||||
{ 255, 255, 0 } /* face 5 - yellow */
|
||||
};
|
||||
static const GLenum targets[6] = {
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
|
||||
};
|
||||
|
||||
GLint i, j, f;
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
/* make colored checkerboard cube faces */
|
||||
for (f = 0; f < 6; f++) {
|
||||
for (i = 0; i < CUBE_TEX_SIZE; i++) {
|
||||
for (j = 0; j < CUBE_TEX_SIZE; j++) {
|
||||
if ((i/4 + j/4) & 1) {
|
||||
image[i][j][0] = colors[f][0];
|
||||
image[i][j][1] = colors[f][1];
|
||||
image[i][j][2] = colors[f][2];
|
||||
}
|
||||
else {
|
||||
image[i][j][0] = 255;
|
||||
image[i][j][1] = 255;
|
||||
image[i][j][2] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glTexImage2D(targets[f], 0, GL_RGB, CUBE_TEX_SIZE, CUBE_TEX_SIZE, 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
LoadFace(GLenum target, const char *filename,
|
||||
GLboolean flipTB, GLboolean flipLR)
|
||||
{
|
||||
GLint w, h;
|
||||
GLenum format;
|
||||
GLubyte *img = LoadRGBImage(filename, &w, &h, &format);
|
||||
if (!img) {
|
||||
printf("Error: couldn't load texture image %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
assert(format == GL_RGB);
|
||||
|
||||
/* <sigh> the way the texture cube mapping works, we have to flip
|
||||
* images to make things look right.
|
||||
*/
|
||||
if (flipTB) {
|
||||
const int stride = 3 * w;
|
||||
GLubyte temp[3*1024];
|
||||
int i;
|
||||
for (i = 0; i < h / 2; i++) {
|
||||
memcpy(temp, img + i * stride, stride);
|
||||
memcpy(img + i * stride, img + (h - i - 1) * stride, stride);
|
||||
memcpy(img + (h - i - 1) * stride, temp, stride);
|
||||
}
|
||||
}
|
||||
if (flipLR) {
|
||||
const int stride = 3 * w;
|
||||
GLubyte temp[3];
|
||||
GLubyte *row;
|
||||
int i, j;
|
||||
for (i = 0; i < h; i++) {
|
||||
row = img + i * stride;
|
||||
for (j = 0; j < w / 2; j++) {
|
||||
int k = w - j - 1;
|
||||
temp[0] = row[j*3+0];
|
||||
temp[1] = row[j*3+1];
|
||||
temp[2] = row[j*3+2];
|
||||
row[j*3+0] = row[k*3+0];
|
||||
row[j*3+1] = row[k*3+1];
|
||||
row[j*3+2] = row[k*3+2];
|
||||
row[k*3+0] = temp[0];
|
||||
row[k*3+1] = temp[1];
|
||||
row[k*3+2] = temp[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gluBuild2DMipmaps(target, GL_RGB, w, h, format, GL_UNSIGNED_BYTE, img);
|
||||
free(img);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
LoadEnvmaps(void)
|
||||
{
|
||||
LoadFace(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, "right.rgb", GL_TRUE, GL_FALSE);
|
||||
LoadFace(GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, "left.rgb", GL_TRUE, GL_FALSE);
|
||||
LoadFace(GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, "top.rgb", GL_FALSE, GL_TRUE);
|
||||
LoadFace(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, "bottom.rgb", GL_FALSE, GL_TRUE);
|
||||
LoadFace(GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, "front.rgb", GL_TRUE, GL_FALSE);
|
||||
LoadFace(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, "back.rgb", GL_TRUE, GL_FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
InitTextures(GLboolean useImageFiles)
|
||||
{
|
||||
GLenum filter;
|
||||
|
||||
/*
|
||||
* Env map
|
||||
*/
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, 1);
|
||||
if (useImageFiles) {
|
||||
LoadEnvmaps();
|
||||
filter = GL_LINEAR;
|
||||
}
|
||||
else {
|
||||
InitCheckers();
|
||||
filter = GL_NEAREST;
|
||||
}
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, filter);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, filter);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
/*
|
||||
* Ground texture
|
||||
*/
|
||||
{
|
||||
GLint imgWidth, imgHeight;
|
||||
GLenum imgFormat;
|
||||
GLubyte *image = NULL;
|
||||
|
||||
image = LoadRGBImage(GroundImage, &imgWidth, &imgHeight, &imgFormat);
|
||||
if (!image) {
|
||||
printf("Couldn't read %s\n", GroundImage);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, 2);
|
||||
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, imgWidth, imgHeight,
|
||||
imgFormat, GL_UNSIGNED_BYTE, image);
|
||||
free(image);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "%s: problem compiling shader: %s\n", Demo, log);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
printf("Shader compiled OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
static void
|
||||
ReadShader(GLuint shader, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "%s: Unable to open shader file %s\n", Demo, filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
printf("%s: read %d bytes from shader file %s\n", Demo, n, filename);
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
LoadAndCompileShader(shader, buffer);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Link success!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static GLuint
|
||||
CreateProgram(const char *vertProgFile, const char *fragProgFile,
|
||||
struct uniform_info *uniforms)
|
||||
{
|
||||
GLuint fragShader = 0, vertShader = 0, program = 0;
|
||||
GLint i;
|
||||
|
||||
program = glCreateProgram_func();
|
||||
if (vertProgFile) {
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
ReadShader(vertShader, vertProgFile);
|
||||
glAttachShader_func(program, vertShader);
|
||||
}
|
||||
|
||||
if (fragProgFile) {
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
ReadShader(fragShader, fragProgFile);
|
||||
glAttachShader_func(program, fragShader);
|
||||
}
|
||||
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
|
||||
glUseProgram_func(program);
|
||||
|
||||
assert(glIsProgram_func(program));
|
||||
assert(glIsShader_func(fragShader));
|
||||
assert(glIsShader_func(vertShader));
|
||||
|
||||
CheckError(__LINE__);
|
||||
for (i = 0; uniforms[i].name; i++) {
|
||||
uniforms[i].location
|
||||
= glGetUniformLocation_func(program, uniforms[i].name);
|
||||
printf("Uniform %s location: %d\n", uniforms[i].name,
|
||||
uniforms[i].location);
|
||||
|
||||
switch (uniforms[i].size) {
|
||||
case 1:
|
||||
if (uniforms[i].type == GL_INT)
|
||||
glUniform1i_func(uniforms[i].location,
|
||||
(GLint) uniforms[i].value[0]);
|
||||
else
|
||||
glUniform1fv_func(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
case 2:
|
||||
glUniform2fv_func(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
case 3:
|
||||
glUniform3fv_func(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
case 4:
|
||||
glUniform4fv_func(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
CheckError(__LINE__);
|
||||
|
||||
return program;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
InitPrograms(void)
|
||||
{
|
||||
Program1 = CreateProgram(ReflectVertFile, CubeFragFile, ReflectUniforms);
|
||||
Program2 = CreateProgram(SimpleVertFile, SimpleTexFragFile, SimpleUniforms);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(GLboolean useImageFiles)
|
||||
{
|
||||
const char *version = (const char *) glGetString(GL_VERSION);
|
||||
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("Warning: this program expects OpenGL 2.0\n");
|
||||
/*exit(1);*/
|
||||
}
|
||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
InitTextures(useImageFiles);
|
||||
InitPrograms();
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glClearColor(.6, .6, .9, 0);
|
||||
glColor3f(1.0, 1.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowSize(500, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
||||
glutCreateWindow(Demo);
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(key);
|
||||
glutSpecialFunc(specialkey);
|
||||
glutDisplayFunc(draw);
|
||||
if (Anim)
|
||||
glutIdleFunc(idle);
|
||||
if (argc > 1 && strcmp(argv[1] , "-i") == 0)
|
||||
Init(1);
|
||||
else
|
||||
Init(0);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
339
progs/glsl/toyball.c
Normal file
339
progs/glsl/toyball.c
Normal file
@@ -0,0 +1,339 @@
|
||||
/**
|
||||
* "Toy Ball" shader demo. Uses the example shaders from
|
||||
* chapter 11 of the OpenGL Shading Language "orange" book.
|
||||
* 16 Jan 2007
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
|
||||
|
||||
static char *FragProgFile = "CH11-toyball.frag.txt";
|
||||
static char *VertProgFile = "CH11-toyball.vert.txt";
|
||||
|
||||
/* program/shader objects */
|
||||
static GLuint fragShader;
|
||||
static GLuint vertShader;
|
||||
static GLuint program;
|
||||
|
||||
|
||||
struct uniform_info {
|
||||
const char *name;
|
||||
GLuint size;
|
||||
GLint location;
|
||||
GLfloat value[4];
|
||||
};
|
||||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
{ "LightDir", 4, -1, { 0.57737, 0.57735, 0.57735, 0.0 } },
|
||||
{ "HVector", 4, -1, { 0.32506, 0.32506, 0.88808, 0.0 } },
|
||||
{ "BallCenter", 4, -1, { 0.0, 0.0, 0.0, 1.0 } },
|
||||
{ "SpecularColor", 4, -1, { 0.4, 0.4, 0.4, 60.0 } },
|
||||
{ "Red", 4, -1, { 0.6, 0.0, 0.0, 1.0 } },
|
||||
{ "Blue", 4, -1, { 0.0, 0.3, 0.6, 1.0 } },
|
||||
{ "Yellow", 4, -1, { 0.6, 0.5, 0.0, 1.0 } },
|
||||
{ "HalfSpace0", 4, -1, { 1.0, 0.0, 0.0, 0.2 } },
|
||||
{ "HalfSpace1", 4, -1, { 0.309016994, 0.951056516, 0.0, 0.2 } },
|
||||
{ "HalfSpace2", 4, -1, { -0.809016994, 0.587785252, 0.0, 0.2 } },
|
||||
{ "HalfSpace3", 4, -1, { -0.809016994, -0.587785252, 0.0, 0.2 } },
|
||||
{ "HalfSpace4", 4, -1, { 0.309116994, -0.951056516, 0.0, 0.2 } },
|
||||
{ "InOrOutInit", 1, -1, { -3.0, 0, 0, 0 } },
|
||||
{ "StripeWidth", 1, -1, { 0.3, 0, 0, 0 } },
|
||||
{ "FWidth", 1, -1, { 0.005, 0, 0, 0 } },
|
||||
{ NULL, 0, 0, { 0, 0, 0, 0 } }
|
||||
};
|
||||
|
||||
static GLint win = 0;
|
||||
static GLboolean Anim = GL_FALSE;
|
||||
static GLfloat TexRot = 0.0;
|
||||
static GLfloat xRot = 0.0f, yRot = 0.0f, zRot = 0.0f;
|
||||
|
||||
|
||||
static void
|
||||
Idle(void)
|
||||
{
|
||||
TexRot += 2.0;
|
||||
if (TexRot > 360.0)
|
||||
TexRot -= 360.0;
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Redisplay(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
|
||||
glRotatef(zRot, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
glRotatef(TexRot, 0.0f, 1.0f, 0.0f);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
glutSolidSphere(2.0, 20, 10);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glFinish();
|
||||
glFlush();
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Reshape(int width, int height)
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0f, 0.0f, -15.0f);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CleanUp(void)
|
||||
{
|
||||
glDeleteShader_func(fragShader);
|
||||
glDeleteShader_func(vertShader);
|
||||
glDeleteProgram_func(program);
|
||||
glutDestroyWindow(win);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
const GLfloat step = 2.0;
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch(key) {
|
||||
case 'a':
|
||||
Anim = !Anim;
|
||||
if (Anim)
|
||||
glutIdleFunc(Idle);
|
||||
else
|
||||
glutIdleFunc(NULL);
|
||||
break;
|
||||
case 'z':
|
||||
zRot += step;
|
||||
break;
|
||||
case 'Z':
|
||||
zRot -= step;
|
||||
break;
|
||||
case 27:
|
||||
CleanUp();
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SpecialKey(int key, int x, int y)
|
||||
{
|
||||
const GLfloat step = 2.0;
|
||||
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch(key) {
|
||||
case GLUT_KEY_UP:
|
||||
xRot += step;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
xRot -= step;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
yRot -= step;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
yRot += step;
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "brick: problem compiling shader: %s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
printf("Shader compiled OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
static void
|
||||
ReadShader(GLuint shader, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "brick: Unable to open shader file %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
printf("brick: read %d bytes from shader file %s\n", n, filename);
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
LoadAndCompileShader(shader, buffer);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Link success!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
const char *version;
|
||||
GLint i;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("Warning: this program expects OpenGL 2.0\n");
|
||||
/*exit(1);*/
|
||||
}
|
||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
ReadShader(vertShader, VertProgFile);
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
ReadShader(fragShader, FragProgFile);
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
|
||||
assert(glIsProgram_func(program));
|
||||
assert(glIsShader_func(fragShader));
|
||||
assert(glIsShader_func(vertShader));
|
||||
|
||||
|
||||
for (i = 0; Uniforms[i].name; i++) {
|
||||
Uniforms[i].location
|
||||
= glGetUniformLocation_func(program, Uniforms[i].name);
|
||||
printf("Uniform %s location: %d\n", Uniforms[i].name,
|
||||
Uniforms[i].location);
|
||||
switch (Uniforms[i].size) {
|
||||
case 1:
|
||||
glUniform1fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 2:
|
||||
glUniform2fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 3:
|
||||
glUniform3fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
case 4:
|
||||
glUniform4fv_func(Uniforms[i].location, 1, Uniforms[i].value);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
assert(glGetError() == 0);
|
||||
|
||||
glClearColor(0.4f, 0.4f, 0.8f, 0.0f);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glColor3f(1, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ParseOptions(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-fs") == 0) {
|
||||
FragProgFile = argv[i+1];
|
||||
}
|
||||
else if (strcmp(argv[i], "-vs") == 0) {
|
||||
VertProgFile = argv[i+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
glutDisplayFunc(Redisplay);
|
||||
ParseOptions(argc, argv);
|
||||
Init();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,221 +0,0 @@
|
||||
LOCAL_LIBRARIES = $(XLIB) $(TOP)\lib\Mesaaux.a $(TOP)\lib\Mesaglu.a $(TOP)\lib\MesaGL.a
|
||||
|
||||
INCLUDES = -I$(TOP)\include
|
||||
|
||||
SRCS = accanti.c \
|
||||
accnot.c \
|
||||
accpersp.c \
|
||||
accum.c \
|
||||
aim.c \
|
||||
alpha.c \
|
||||
alpha3D.c \
|
||||
anti.c \
|
||||
antiindex.c \
|
||||
antipindex.c \
|
||||
antipoint.c \
|
||||
antipoly.c \
|
||||
bezcurve.c \
|
||||
bezmesh.c \
|
||||
bezsurf.c \
|
||||
checker.c \
|
||||
checker2.c \
|
||||
chess.c \
|
||||
clip.c \
|
||||
colormat.c \
|
||||
cone.c \
|
||||
cube.c \
|
||||
curve.c \
|
||||
depthcue.c \
|
||||
disk.c \
|
||||
dof.c \
|
||||
dofnot.c \
|
||||
double.c \
|
||||
drawf.c \
|
||||
feedback.c \
|
||||
fog.c \
|
||||
fogindex.c \
|
||||
font.c \
|
||||
light.c \
|
||||
linelist.c \
|
||||
lines.c \
|
||||
list.c \
|
||||
list2.c \
|
||||
maplight.c \
|
||||
material.c \
|
||||
mipmap.c \
|
||||
model.c \
|
||||
movelight.c \
|
||||
nurbs.c \
|
||||
pickdepth.c \
|
||||
pickline.c \
|
||||
picksquare.c \
|
||||
plane.c \
|
||||
planet.c \
|
||||
planetup.c \
|
||||
polys.c \
|
||||
robot.c \
|
||||
sccolorlight.c \
|
||||
scene.c \
|
||||
scenebamb.c \
|
||||
sceneflat.c \
|
||||
select.c \
|
||||
simple.c \
|
||||
smooth.c \
|
||||
sphere.c \
|
||||
stencil.c \
|
||||
stroke.c \
|
||||
surface.c \
|
||||
tea.c \
|
||||
teaambient.c \
|
||||
teapots.c \
|
||||
texgen.c \
|
||||
texturesurf.c \
|
||||
trim.c \
|
||||
xfont.c
|
||||
|
||||
PROGRAMS = ProgramTargetName(accanti) \
|
||||
ProgramTargetName(accnot) \
|
||||
ProgramTargetName(accpersp) \
|
||||
ProgramTargetName(accum) \
|
||||
ProgramTargetName(aim) \
|
||||
ProgramTargetName(alpha) \
|
||||
ProgramTargetName(alpha3D) \
|
||||
ProgramTargetName(anti) \
|
||||
ProgramTargetName(antiindex) \
|
||||
ProgramTargetName(antipindex) \
|
||||
ProgramTargetName(antipoint) \
|
||||
ProgramTargetName(antipoly) \
|
||||
ProgramTargetName(bezcurve) \
|
||||
ProgramTargetName(bezmesh) \
|
||||
ProgramTargetName(bezsurf) \
|
||||
ProgramTargetName(checker) \
|
||||
ProgramTargetName(checker2) \
|
||||
ProgramTargetName(chess) \
|
||||
ProgramTargetName(clip) \
|
||||
ProgramTargetName(colormat) \
|
||||
ProgramTargetName(cone) \
|
||||
ProgramTargetName(cube) \
|
||||
ProgramTargetName(curve) \
|
||||
ProgramTargetName(depthcue) \
|
||||
ProgramTargetName(disk) \
|
||||
ProgramTargetName(dof) \
|
||||
ProgramTargetName(dofnot) \
|
||||
ProgramTargetName(double) \
|
||||
ProgramTargetName(drawf) \
|
||||
ProgramTargetName(feedback) \
|
||||
ProgramTargetName(fog) \
|
||||
ProgramTargetName(fogindex) \
|
||||
ProgramTargetName(font) \
|
||||
ProgramTargetName(light) \
|
||||
ProgramTargetName(linelist) \
|
||||
ProgramTargetName(lines) \
|
||||
ProgramTargetName(list) \
|
||||
ProgramTargetName(list2) \
|
||||
ProgramTargetName(maplight) \
|
||||
ProgramTargetName(material) \
|
||||
ProgramTargetName(mipmap) \
|
||||
ProgramTargetName(model) \
|
||||
ProgramTargetName(movelight) \
|
||||
ProgramTargetName(nurbs) \
|
||||
ProgramTargetName(pickdepth) \
|
||||
ProgramTargetName(pickline) \
|
||||
ProgramTargetName(picksquare) \
|
||||
ProgramTargetName(plane) \
|
||||
ProgramTargetName(planet) \
|
||||
ProgramTargetName(planetup) \
|
||||
ProgramTargetName(polys) \
|
||||
ProgramTargetName(robot) \
|
||||
ProgramTargetName(sccolorlight) \
|
||||
ProgramTargetName(scene) \
|
||||
ProgramTargetName(scenebamb) \
|
||||
ProgramTargetName(sceneflat) \
|
||||
ProgramTargetName(select) \
|
||||
ProgramTargetName(simple) \
|
||||
ProgramTargetName(smooth) \
|
||||
ProgramTargetName(sphere) \
|
||||
ProgramTargetName(stencil) \
|
||||
ProgramTargetName(stroke) \
|
||||
ProgramTargetName(surface) \
|
||||
ProgramTargetName(tea) \
|
||||
ProgramTargetName(teaambient) \
|
||||
ProgramTargetName(teapots) \
|
||||
ProgramTargetName(texgen) \
|
||||
ProgramTargetName(texturesurf) \
|
||||
ProgramTargetName(trim) \
|
||||
ProgramTargetName(xfont)
|
||||
|
||||
AllTarget($(PROGRAMS))
|
||||
|
||||
NormalProgramTarget(accanti,accanti.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(accnot,accnot.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(accpersp,accpersp.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(accum,accum.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(aim,aim.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(alpha,alpha.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(alpha3D,alpha3D.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(anti,anti.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(antiindex,antiindex.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(antipindex,antipindex.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(antipoint,antipoint.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(antipoly,antipoly.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(bezcurve,bezcurve.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(bezmesh,bezmesh.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(bezsurf,bezsurf.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(checker,checker.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(checker2,checker2.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(chess,chess.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(clip,clip.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(colormat,colormat.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(cone,cone.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(cube,cube.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(curve,curve.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(depthcue,depthcue.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(disk,disk.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(dof,dof.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(dofnot,dofnot.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(double,double.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(drawf,drawf.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(feedback,feedback.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(fog,fog.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(fogindex,fogindex.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(font,font.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(light,light.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(linelist,linelist.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(lines,lines.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(list,list.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(list2,list2.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(maplight,maplight.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(material,material.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(mipmap,mipmap.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(model,model.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(movelight,movelight.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(nurbs,nurbs.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(pickdepth,pickdepth.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(pickline,pickline.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(picksquare,picksquare.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(plane,plane.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(planet,planet.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(planetup,planetup.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(polys,polys.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(robot,robot.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(sccolorlight,sccolorlight.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(scene,scene.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(scenebamb,scenebamb.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(sceneflat,sceneflat.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(select,select.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(simple,simple.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(smooth,smooth.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(sphere,sphere.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(stencil,stencil.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(stroke,stroke.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(surface,surface.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(tea,tea.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(teaambient,teaambient.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(teapots,teapots.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(texgen,texgen.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(texturesurf,texturesurf.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(trim,trim.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(xfont,xfont.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
|
||||
DependTarget()
|
||||
|
@@ -1,101 +0,0 @@
|
||||
LOCAL_LIBRARIES = $(XLIB) $(TOP)\lib\glut.a $(TOP)\lib\Mesaglu.a $(TOP)\lib\MesaGL.a
|
||||
|
||||
INCLUDES = -I$(TOP)\include
|
||||
|
||||
SRCS = accum.c \
|
||||
bitmap1.c \
|
||||
bitmap2.c \
|
||||
blendeq.c \
|
||||
blendxor.c \
|
||||
copy.c \
|
||||
cursor.c \
|
||||
depth.c \
|
||||
eval.c \
|
||||
fog.c \
|
||||
font.c \
|
||||
line.c \
|
||||
logo.c \
|
||||
nurb.c \
|
||||
oglinfo.c \
|
||||
olympic.c \
|
||||
overlay.c \
|
||||
point.c \
|
||||
prim.c \
|
||||
quad.c \
|
||||
select.c \
|
||||
shape.c \
|
||||
speed.c \
|
||||
sphere.c \
|
||||
star.c \
|
||||
stencil.c \
|
||||
stretch.c \
|
||||
texture.c \
|
||||
tri.c \
|
||||
wave.c
|
||||
|
||||
PROGRAMS = ProgramTargetName(accum) \
|
||||
ProgramTargetName(bitmap1) \
|
||||
ProgramTargetName(bitmap2) \
|
||||
ProgramTargetName(blendeq) \
|
||||
ProgramTargetName(blendxor) \
|
||||
ProgramTargetName(copy) \
|
||||
ProgramTargetName(cursor) \
|
||||
ProgramTargetName(depth) \
|
||||
ProgramTargetName(eval) \
|
||||
ProgramTargetName(fog) \
|
||||
ProgramTargetName(font) \
|
||||
ProgramTargetName(line) \
|
||||
ProgramTargetName(logo) \
|
||||
ProgramTargetName(nurb) \
|
||||
ProgramTargetName(oglinfo) \
|
||||
ProgramTargetName(olympic) \
|
||||
ProgramTargetName(overlay) \
|
||||
ProgramTargetName(point) \
|
||||
ProgramTargetName(prim) \
|
||||
ProgramTargetName(quad) \
|
||||
ProgramTargetName(select) \
|
||||
ProgramTargetName(shape) \
|
||||
ProgramTargetName(speed) \
|
||||
ProgramTargetName(sphere) \
|
||||
ProgramTargetName(star) \
|
||||
ProgramTargetName(stencil) \
|
||||
ProgramTargetName(stretch) \
|
||||
ProgramTargetName(texture) \
|
||||
ProgramTargetName(tri) \
|
||||
ProgramTargetName(wave)
|
||||
|
||||
AllTarget($(PROGRAMS))
|
||||
|
||||
NormalProgramTarget(accum,accum.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(bitmap1,bitmap1.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(bitmap2,bitmap2.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(blendeq,blendeq.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(blendxor,blendxor.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(copy,copy.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(cursor,cursor.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(depth,depth.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(eval,eval.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(fog,fog.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(font,font.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(line,line.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(logo,logo.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(nurb,nurb.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(oglinfo,oglinfo.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(olympic,olympic.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(overlay,overlay.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(point,point.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(prim,prim.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(quad,quad.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(select,select.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(shape,shape.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(speed,speed.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(sphere,sphere.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(star,star.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(stencil,stencil.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(stretch,stretch.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(texture,texture.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(tri,tri.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(wave,wave.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
|
||||
DependTarget()
|
||||
|
@@ -33,6 +33,7 @@ SOURCES = \
|
||||
crossbar.c \
|
||||
cva.c \
|
||||
dinoshade.c \
|
||||
drawbuffers.c \
|
||||
floattex.c \
|
||||
fbotest1.c \
|
||||
fbotest2.c \
|
||||
@@ -122,6 +123,12 @@ afsmultiarb: afsmultiarb.o readtex.o
|
||||
afsmultiarb.o: afsmultiarb.c readtex.h
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
|
||||
drawbuffers: drawbuffers.o
|
||||
$(CC) $(CFLAGS) drawbuffers.o $(LIBS) -o $@
|
||||
|
||||
drawbuffers.o: drawbuffers.c extfuncs.h
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
|
||||
texrect: texrect.o readtex.o
|
||||
$(CC) $(CFLAGS) texrect.o readtex.o $(LIBS) -o $@
|
||||
|
||||
@@ -150,6 +157,8 @@ readtex.h: $(TOP)/progs/util/readtex.h
|
||||
readtex.c: $(TOP)/progs/util/readtex.c
|
||||
ln -s $(TOP)/progs/util/readtex.c .
|
||||
|
||||
extfuncs.h: $(TOP)/progs/util/extfuncs.h
|
||||
ln -s $(TOP)/progs/util/extfuncs.h .
|
||||
|
||||
|
||||
|
||||
|
298
progs/tests/drawbuffers.c
Normal file
298
progs/tests/drawbuffers.c
Normal file
@@ -0,0 +1,298 @@
|
||||
/*
|
||||
* Test GL_ARB_draw_buffers, GL_EXT_framebuffer_object
|
||||
* and GLSL's gl_FragData[].
|
||||
*
|
||||
* Brian Paul
|
||||
* 11 March 2007
|
||||
*/
|
||||
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glut.h>
|
||||
#include "extfuncs.h"
|
||||
|
||||
static int Win;
|
||||
static int Width = 400, Height = 400;
|
||||
static GLuint FBobject, RBobjects[3];
|
||||
static GLfloat Xrot = 0.0, Yrot = 0.0;
|
||||
|
||||
|
||||
static void
|
||||
CheckError(int line)
|
||||
{
|
||||
GLenum err = glGetError();
|
||||
if (err) {
|
||||
printf("GL Error 0x%x at line %d\n", (int) err, line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Display(void)
|
||||
{
|
||||
GLubyte *buffer = malloc(Width * Height * 4);
|
||||
static const GLenum buffers[2] = {
|
||||
GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_COLOR_ATTACHMENT1_EXT
|
||||
};
|
||||
|
||||
/* draw to user framebuffer */
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject);
|
||||
|
||||
/* Clear color buffer 0 (blue) */
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glClearColor(0.5, 0.5, 1.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
/* Clear color buffer 1 (1 - blue) */
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
|
||||
glClearColor(0.5, 0.5, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
/* draw to two buffers w/ fragment shader */
|
||||
glDrawBuffersARB(2, buffers);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(Xrot, 1, 0, 0);
|
||||
glRotatef(Yrot, 0, 1, 0);
|
||||
glutSolidTorus(0.75, 2.0, 10, 20);
|
||||
glPopMatrix();
|
||||
|
||||
/* read from user framebuffer */
|
||||
/* bottom half = colorbuffer 0 */
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadPixels(0, 0, Width, Height / 2, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
buffer);
|
||||
/* top half = colorbuffer 1 */
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
|
||||
glReadPixels(0, Height/2, Width, Height / 2, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
buffer + Width * Height / 2 * 4);
|
||||
|
||||
/* draw to window */
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
glWindowPos2iARB(0, 0);
|
||||
glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||
|
||||
free(buffer);
|
||||
glutSwapBuffers();
|
||||
CheckError(__LINE__);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Reshape(int width, int height)
|
||||
{
|
||||
float ar = (float) width / (float) height;
|
||||
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-ar, ar, -1.0, 1.0, 5.0, 35.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -20.0);
|
||||
|
||||
Width = width;
|
||||
Height = height;
|
||||
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[0]);
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[1]);
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[2]);
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
|
||||
Width, Height);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CleanUp(void)
|
||||
{
|
||||
glDeleteFramebuffersEXT(1, &FBobject);
|
||||
glDeleteRenderbuffersEXT(3, RBobjects);
|
||||
glutDestroyWindow(Win);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case 'x':
|
||||
Xrot += 5.0;
|
||||
break;
|
||||
case 'y':
|
||||
Yrot += 5.0;
|
||||
break;
|
||||
case 27:
|
||||
CleanUp();
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckExtensions(void)
|
||||
{
|
||||
const char *version = (const char *) glGetString(GL_VERSION);
|
||||
GLint numBuf;
|
||||
|
||||
if (!glutExtensionSupported("GL_EXT_framebuffer_object")) {
|
||||
printf("Sorry, GL_EXT_framebuffer_object is required!\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!glutExtensionSupported("GL_ARB_draw_buffers")) {
|
||||
printf("Sorry, GL_ARB_draw_buffers is required!\n");
|
||||
exit(1);
|
||||
}
|
||||
if (version[0] != '2') {
|
||||
printf("Sorry, OpenGL 2.0 is required!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &numBuf);
|
||||
printf("GL_MAX_DRAW_BUFFERS_ARB = %d\n", numBuf);
|
||||
if (numBuf < 2) {
|
||||
printf("Sorry, GL_MAX_DRAW_BUFFERS_ARB needs to be >= 2\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SetupRenderbuffers(void)
|
||||
{
|
||||
glGenFramebuffersEXT(1, &FBobject);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject);
|
||||
|
||||
glGenRenderbuffersEXT(3, RBobjects);
|
||||
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[0]);
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
|
||||
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[1]);
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
|
||||
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[2]);
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
|
||||
Width, Height);
|
||||
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_RENDERBUFFER_EXT, RBobjects[0]);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT,
|
||||
GL_RENDERBUFFER_EXT, RBobjects[1]);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
|
||||
GL_RENDERBUFFER_EXT, RBobjects[2]);
|
||||
|
||||
CheckError(__LINE__);
|
||||
}
|
||||
|
||||
|
||||
static GLuint
|
||||
LoadAndCompileShader(GLenum target, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
GLuint shader = glCreateShader_func(target);
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
glCompileShader_func(shader);
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "drawbuffers: problem compiling shader:\n%s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
return shader;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "drawbuffers: shader link error:\n%s\n", log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SetupShaders(void)
|
||||
{
|
||||
/* second color output = 1 - first color */
|
||||
static const char *fragShaderText =
|
||||
"void main() {\n"
|
||||
" gl_FragData[0] = gl_Color; \n"
|
||||
" gl_FragData[1] = vec4(1.0) - gl_Color; \n"
|
||||
"}\n";
|
||||
|
||||
GLuint fragShader, program;
|
||||
|
||||
fragShader = LoadAndCompileShader(GL_FRAGMENT_SHADER, fragShaderText);
|
||||
program = glCreateProgram_func();
|
||||
|
||||
glAttachShader_func(program, fragShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SetupLighting(void)
|
||||
{
|
||||
static const GLfloat frontMat[4] = { 1.0, 0.5, 0.5, 1.0 };
|
||||
static const GLfloat backMat[4] = { 1.0, 0.5, 0.5, 1.0 };
|
||||
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, frontMat);
|
||||
glMaterialfv(GL_BACK, GL_AMBIENT_AND_DIFFUSE, backMat);
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
CheckExtensions();
|
||||
GetExtensionFuncs();
|
||||
SetupRenderbuffers();
|
||||
SetupShaders();
|
||||
SetupLighting();
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition(0, 0);
|
||||
glutInitWindowSize(Width, Height);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Display);
|
||||
Init();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
138
progs/util/extfuncs.h
Normal file
138
progs/util/extfuncs.h
Normal file
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* Utility for getting OpenGL extension function pointers
|
||||
* Meant to be #included.
|
||||
*/
|
||||
|
||||
/* OpenGL 2.0 */
|
||||
static PFNGLATTACHSHADERPROC glAttachShader_func = NULL;
|
||||
static PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation_func = NULL;
|
||||
static PFNGLCOMPILESHADERPROC glCompileShader_func = NULL;
|
||||
static PFNGLCREATEPROGRAMPROC glCreateProgram_func = NULL;
|
||||
static PFNGLCREATESHADERPROC glCreateShader_func = NULL;
|
||||
static PFNGLDELETEPROGRAMPROC glDeleteProgram_func = NULL;
|
||||
static PFNGLDELETESHADERPROC glDeleteShader_func = NULL;
|
||||
static PFNGLGETACTIVEATTRIBPROC glGetActiveAttrib_func = NULL;
|
||||
static PFNGLGETATTACHEDSHADERSPROC glGetAttachedShaders_func = NULL;
|
||||
static PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation_func = NULL;
|
||||
static PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog_func = NULL;
|
||||
static PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog_func = NULL;
|
||||
static PFNGLGETSHADERIVPROC glGetShaderiv_func = NULL;
|
||||
static PFNGLGETPROGRAMIVPROC glGetProgramiv_func = NULL;
|
||||
static PFNGLGETSHADERSOURCEPROC glGetShaderSource_func = NULL;
|
||||
static PFNGLGETUNIFORMFVPROC glGetUniformfv_func = NULL;
|
||||
static PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation_func = NULL;
|
||||
static PFNGLISPROGRAMPROC glIsProgram_func = NULL;
|
||||
static PFNGLISSHADERPROC glIsShader_func = NULL;
|
||||
static PFNGLLINKPROGRAMPROC glLinkProgram_func = NULL;
|
||||
static PFNGLSHADERSOURCEPROC glShaderSource_func = NULL;
|
||||
static PFNGLUNIFORM1IPROC glUniform1i_func = NULL;
|
||||
static PFNGLUNIFORM1FVPROC glUniform1fv_func = NULL;
|
||||
static PFNGLUNIFORM2FVPROC glUniform2fv_func = NULL;
|
||||
static PFNGLUNIFORM3FVPROC glUniform3fv_func = NULL;
|
||||
static PFNGLUNIFORM4FVPROC glUniform4fv_func = NULL;
|
||||
static PFNGLUNIFORMMATRIX2FVPROC glUniformMatrix2fv_func = NULL;
|
||||
static PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fv_func = NULL;
|
||||
static PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv_func = NULL;
|
||||
static PFNGLUSEPROGRAMPROC glUseProgram_func = NULL;
|
||||
static PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f_func = NULL;
|
||||
static PFNGLVERTEXATTRIB2FPROC glVertexAttrib2f_func = NULL;
|
||||
static PFNGLVERTEXATTRIB3FPROC glVertexAttrib3f_func = NULL;
|
||||
static PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f_func = NULL;
|
||||
|
||||
/* OpenGL 2.1 */
|
||||
static PFNGLUNIFORMMATRIX2X3FVPROC glUniformMatrix2x3fv_func = NULL;
|
||||
static PFNGLUNIFORMMATRIX3X2FVPROC glUniformMatrix3x2fv_func = NULL;
|
||||
static PFNGLUNIFORMMATRIX2X4FVPROC glUniformMatrix2x4fv_func = NULL;
|
||||
static PFNGLUNIFORMMATRIX4X2FVPROC glUniformMatrix4x2fv_func = NULL;
|
||||
static PFNGLUNIFORMMATRIX3X4FVPROC glUniformMatrix3x4fv_func = NULL;
|
||||
static PFNGLUNIFORMMATRIX4X3FVPROC glUniformMatrix4x3fv_func = NULL;
|
||||
|
||||
/* GL_ARB_vertex/fragment_program */
|
||||
static PFNGLBINDPROGRAMARBPROC glBindProgramARB_func = NULL;
|
||||
static PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB_func = NULL;
|
||||
static PFNGLGENPROGRAMSARBPROC glGenProgramsARB_func = NULL;
|
||||
static PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC glGetProgramLocalParameterdvARB_func = NULL;
|
||||
static PFNGLISPROGRAMARBPROC glIsProgramARB_func = NULL;
|
||||
static PFNGLPROGRAMLOCALPARAMETER4DARBPROC glProgramLocalParameter4dARB_func = NULL;
|
||||
static PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glProgramLocalParameter4fvARB_func = NULL;
|
||||
static PFNGLPROGRAMSTRINGARBPROC glProgramStringARB_func = NULL;
|
||||
static PFNGLVERTEXATTRIB1FARBPROC glVertexAttrib1fARB_func = NULL;
|
||||
|
||||
/* GL_APPLE_vertex_array_object */
|
||||
static PFNGLBINDVERTEXARRAYAPPLEPROC glBindVertexArrayAPPLE_func = NULL;
|
||||
static PFNGLDELETEVERTEXARRAYSAPPLEPROC glDeleteVertexArraysAPPLE_func = NULL;
|
||||
static PFNGLGENVERTEXARRAYSAPPLEPROC glGenVertexArraysAPPLE_func = NULL;
|
||||
static PFNGLISVERTEXARRAYAPPLEPROC glIsVertexArrayAPPLE_func = NULL;
|
||||
|
||||
/* GL_EXT_stencil_two_side */
|
||||
static PFNGLACTIVESTENCILFACEEXTPROC glActiveStencilFaceEXT_func = NULL;
|
||||
|
||||
|
||||
static void
|
||||
GetExtensionFuncs(void)
|
||||
{
|
||||
/* OpenGL 2.0 */
|
||||
glAttachShader_func = (PFNGLATTACHSHADERPROC) glutGetProcAddress("glAttachShader");
|
||||
glBindAttribLocation_func = (PFNGLBINDATTRIBLOCATIONPROC) glutGetProcAddress("glBindAttribLocation");
|
||||
glCompileShader_func = (PFNGLCOMPILESHADERPROC) glutGetProcAddress("glCompileShader");
|
||||
glCreateProgram_func = (PFNGLCREATEPROGRAMPROC) glutGetProcAddress("glCreateProgram");
|
||||
glCreateShader_func = (PFNGLCREATESHADERPROC) glutGetProcAddress("glCreateShader");
|
||||
glDeleteProgram_func = (PFNGLDELETEPROGRAMPROC) glutGetProcAddress("glDeleteProgram");
|
||||
glDeleteShader_func = (PFNGLDELETESHADERPROC) glutGetProcAddress("glDeleteShader");
|
||||
glGetActiveAttrib_func = (PFNGLGETACTIVEATTRIBPROC) glutGetProcAddress("glGetActiveAttrib");
|
||||
glGetAttachedShaders_func = (PFNGLGETATTACHEDSHADERSPROC) glutGetProcAddress("glGetAttachedShaders");
|
||||
glGetAttribLocation_func = (PFNGLGETATTRIBLOCATIONPROC) glutGetProcAddress("glGetAttribLocation");
|
||||
glGetProgramInfoLog_func = (PFNGLGETPROGRAMINFOLOGPROC) glutGetProcAddress("glGetProgramInfoLog");
|
||||
glGetShaderInfoLog_func = (PFNGLGETSHADERINFOLOGPROC) glutGetProcAddress("glGetShaderInfoLog");
|
||||
glGetProgramiv_func = (PFNGLGETPROGRAMIVPROC) glutGetProcAddress("glGetProgramiv");
|
||||
glGetShaderiv_func = (PFNGLGETSHADERIVPROC) glutGetProcAddress("glGetShaderiv");
|
||||
glGetShaderSource_func = (PFNGLGETSHADERSOURCEPROC) glutGetProcAddress("glGetShaderSource");
|
||||
glGetUniformLocation_func = (PFNGLGETUNIFORMLOCATIONPROC) glutGetProcAddress("glGetUniformLocation");
|
||||
glGetUniformfv_func = (PFNGLGETUNIFORMFVPROC) glutGetProcAddress("glGetUniformfv");
|
||||
glIsProgram_func = (PFNGLISPROGRAMPROC) glutGetProcAddress("glIsProgram");
|
||||
glIsShader_func = (PFNGLISSHADERPROC) glutGetProcAddress("glIsShader");
|
||||
glLinkProgram_func = (PFNGLLINKPROGRAMPROC) glutGetProcAddress("glLinkProgram");
|
||||
glShaderSource_func = (PFNGLSHADERSOURCEPROC) glutGetProcAddress("glShaderSource");
|
||||
glUniform1i_func = (PFNGLUNIFORM1IPROC) glutGetProcAddress("glUniform1i");
|
||||
glUniform1fv_func = (PFNGLUNIFORM1FVPROC) glutGetProcAddress("glUniform1fv");
|
||||
glUniform2fv_func = (PFNGLUNIFORM2FVPROC) glutGetProcAddress("glUniform2fv");
|
||||
glUniform3fv_func = (PFNGLUNIFORM3FVPROC) glutGetProcAddress("glUniform3fv");
|
||||
glUniform4fv_func = (PFNGLUNIFORM3FVPROC) glutGetProcAddress("glUniform4fv");
|
||||
glUniformMatrix2fv_func = (PFNGLUNIFORMMATRIX2FVPROC) glutGetProcAddress("glUniformMatrix2fv");
|
||||
glUniformMatrix3fv_func = (PFNGLUNIFORMMATRIX3FVPROC) glutGetProcAddress("glUniformMatrix3fv");
|
||||
glUniformMatrix4fv_func = (PFNGLUNIFORMMATRIX4FVPROC) glutGetProcAddress("glUniformMatrix4fv");
|
||||
glUseProgram_func = (PFNGLUSEPROGRAMPROC) glutGetProcAddress("glUseProgram");
|
||||
glVertexAttrib1f_func = (PFNGLVERTEXATTRIB1FPROC) glutGetProcAddress("glVertexAttrib1f");
|
||||
glVertexAttrib2f_func = (PFNGLVERTEXATTRIB2FPROC) glutGetProcAddress("glVertexAttrib2f");
|
||||
glVertexAttrib3f_func = (PFNGLVERTEXATTRIB3FPROC) glutGetProcAddress("glVertexAttrib3f");
|
||||
glVertexAttrib4f_func = (PFNGLVERTEXATTRIB4FPROC) glutGetProcAddress("glVertexAttrib4f");
|
||||
|
||||
/* OpenGL 2.1 */
|
||||
glUniformMatrix2x3fv_func = (PFNGLUNIFORMMATRIX2X3FVPROC) glutGetProcAddress("glUniformMatrix2x3fv");
|
||||
glUniformMatrix3x2fv_func = (PFNGLUNIFORMMATRIX3X2FVPROC) glutGetProcAddress("glUniformMatrix3x2fv");
|
||||
glUniformMatrix2x4fv_func = (PFNGLUNIFORMMATRIX2X4FVPROC) glutGetProcAddress("glUniformMatrix2x4fv");
|
||||
glUniformMatrix4x2fv_func = (PFNGLUNIFORMMATRIX4X2FVPROC) glutGetProcAddress("glUniformMatrix4x2fv");
|
||||
glUniformMatrix3x4fv_func = (PFNGLUNIFORMMATRIX3X4FVPROC) glutGetProcAddress("glUniformMatrix3x4fv");
|
||||
glUniformMatrix4x3fv_func = (PFNGLUNIFORMMATRIX4X3FVPROC) glutGetProcAddress("glUniformMatrix4x3fv");
|
||||
|
||||
/* GL_ARB_vertex/fragment_program */
|
||||
glBindProgramARB_func = (PFNGLBINDPROGRAMARBPROC) glutGetProcAddress("glBindProgramARB");
|
||||
glDeleteProgramsARB_func = (PFNGLDELETEPROGRAMSARBPROC) glutGetProcAddress("glDeleteProgramsARB");
|
||||
glGenProgramsARB_func = (PFNGLGENPROGRAMSARBPROC) glutGetProcAddress("glGenProgramsARB");
|
||||
glGetProgramLocalParameterdvARB_func = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) glutGetProcAddress("glGetProgramLocalParameterdvARB");
|
||||
glIsProgramARB_func = (PFNGLISPROGRAMARBPROC) glutGetProcAddress("glIsProgramARB");
|
||||
glProgramLocalParameter4dARB_func = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC) glutGetProcAddress("glProgramLocalParameter4dARB");
|
||||
glProgramLocalParameter4fvARB_func = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) glutGetProcAddress("glProgramLocalParameter4fvARB");
|
||||
glProgramStringARB_func = (PFNGLPROGRAMSTRINGARBPROC) glutGetProcAddress("glProgramStringARB");
|
||||
glVertexAttrib1fARB_func = (PFNGLVERTEXATTRIB1FARBPROC) glutGetProcAddress("glVertexAttrib1fARB");
|
||||
|
||||
/* GL_APPLE_vertex_array_object */
|
||||
glBindVertexArrayAPPLE_func = (PFNGLBINDVERTEXARRAYAPPLEPROC) glutGetProcAddress("glBindVertexArrayAPPLE");
|
||||
glDeleteVertexArraysAPPLE_func = (PFNGLDELETEVERTEXARRAYSAPPLEPROC) glutGetProcAddress("glDeleteVertexArraysAPPLE");
|
||||
glGenVertexArraysAPPLE_func = (PFNGLGENVERTEXARRAYSAPPLEPROC) glutGetProcAddress("glGenVertexArraysAPPLE");
|
||||
glIsVertexArrayAPPLE_func = (PFNGLISVERTEXARRAYAPPLEPROC) glutGetProcAddress("glIsVertexArrayAPPLE");
|
||||
|
||||
/* GL_EXT_stencil_two_side */
|
||||
glActiveStencilFaceEXT_func = (PFNGLACTIVESTENCILFACEEXTPROC) glutGetProcAddress("glActiveStencilFaceEXT");
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
DESCRIPTION 'Mesa GLU (OpenGL work-alike) for Win32'
|
||||
;DESCRIPTION 'Mesa GLU (OpenGL work-alike) for Win32'
|
||||
VERSION 5.1
|
||||
;
|
||||
; Module definition file for GLU (GLU32.DLL)
|
||||
|
@@ -349,12 +349,18 @@ getVisualInfoRGB(unsigned int mode)
|
||||
__glutScreen, list);
|
||||
}
|
||||
|
||||
#ifndef VisualIDMask
|
||||
#define VisualIDMask 0
|
||||
#endif
|
||||
|
||||
static XVisualInfo *
|
||||
getVisualInfoID(int id)
|
||||
{
|
||||
XVisualInfo temp;
|
||||
int count;
|
||||
#if !defined(_WIN32)
|
||||
temp.visualid = id;
|
||||
#endif
|
||||
return XGetVisualInfo(__glutDisplay, VisualIDMask, &temp, &count);
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ C_SOURCES = \
|
||||
$(TOP)/src/mesa/main/dispatch.c \
|
||||
$(TOP)/src/mesa/glapi/glapi.c \
|
||||
$(TOP)/src/mesa/glapi/glthread.c \
|
||||
$(TOP)/src/mesa/drivers/dri/common/glcontextmodes.c \
|
||||
$(TOP)/src/glx/x11/glcontextmodes.c \
|
||||
miniglx.c \
|
||||
miniglx_events.c
|
||||
|
||||
@@ -27,10 +27,7 @@ INCLUDE_DIRS = \
|
||||
-I$(TOP)/src/mesa \
|
||||
-I$(TOP)/src/mesa/main \
|
||||
-I$(TOP)/src/mesa/glapi \
|
||||
-I$(TOP)/src/mesa/math \
|
||||
-I$(TOP)/src/mesa/transform \
|
||||
-I$(TOP)/src/mesa/swrast \
|
||||
-I$(TOP)/src/mesa/swrast_setup \
|
||||
-I$(TOP)/src/glx/x11 \
|
||||
-I$(TOP)/src/mesa/drivers/dri/common \
|
||||
`pkg-config --cflags libdrm`
|
||||
|
||||
|
@@ -47,8 +47,6 @@
|
||||
#ifndef _driver_H_
|
||||
#define _driver_H_
|
||||
|
||||
#define CAPI /* XXX this should be globally defined somewhere */
|
||||
|
||||
#include "GL/gl.h"
|
||||
#include "GL/internal/glcore.h"
|
||||
|
||||
|
@@ -46,7 +46,6 @@ INCLUDES = -I. \
|
||||
-I$(TOP)/include/GL/internal \
|
||||
-I$(TOP)/src/mesa/main \
|
||||
-I$(TOP)/src/mesa/glapi \
|
||||
-I$(TOP)/src/mesa/drivers/dri/common \
|
||||
$(LIBDRM_CFLAGS) \
|
||||
$(X11_INCLUDES)
|
||||
|
||||
@@ -63,9 +62,6 @@ INCLUDES = -I. \
|
||||
|
||||
default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
|
||||
|
||||
glcontextmodes.c:
|
||||
ln -s $(TOP)/src/mesa/drivers/dri/common/glcontextmodes.c .
|
||||
|
||||
# Make libGL
|
||||
$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) Makefile
|
||||
$(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
|
||||
@@ -81,7 +77,7 @@ depend: $(SOURCES) $(MESA_GLAPI_SOURCES) $(MESA_ASM_API) Makefile
|
||||
|
||||
# Emacs tags
|
||||
tags:
|
||||
etags `find . -name \*.[ch]` `find ../include`
|
||||
etags `find . -name \*.[ch]` `find $(TOP)/include`
|
||||
|
||||
# Dummy install target
|
||||
install:
|
||||
|
@@ -39,6 +39,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#include <X11/Xlibint.h>
|
||||
#include <X11/extensions/Xext.h>
|
||||
#include <X11/extensions/extutil.h>
|
||||
#include "glheader.h"
|
||||
#include "glxclient.h"
|
||||
#include "xf86dri.h"
|
||||
#include "sarea.h"
|
||||
@@ -81,11 +82,15 @@ static void InfoMessageF(const char *f, ...)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print error to stderr, unless LIBGL_DEBUG=="quiet".
|
||||
*/
|
||||
static void ErrorMessageF(const char *f, ...)
|
||||
{
|
||||
va_list args;
|
||||
const char *env;
|
||||
|
||||
if (getenv("LIBGL_DEBUG")) {
|
||||
if ((env = getenv("LIBGL_DEBUG")) && !strstr(env, "quiet")) {
|
||||
fprintf(stderr, "libGL error: ");
|
||||
va_start(args, f);
|
||||
vfprintf(stderr, f, args);
|
||||
@@ -338,7 +343,7 @@ __DRIdriver *driGetDriver(Display *dpy, int scrNum)
|
||||
* The returned char pointer points to a static array that will be
|
||||
* overwritten by subsequent calls.
|
||||
*/
|
||||
const char *glXGetScreenDriver (Display *dpy, int scrNum) {
|
||||
PUBLIC const char *glXGetScreenDriver (Display *dpy, int scrNum) {
|
||||
static char ret[32];
|
||||
char *driverName;
|
||||
if (GetDriverName(dpy, scrNum, &driverName)) {
|
||||
@@ -367,7 +372,7 @@ const char *glXGetScreenDriver (Display *dpy, int scrNum) {
|
||||
*
|
||||
* Note: The driver remains opened after this function returns.
|
||||
*/
|
||||
const char *glXGetDriverConfig (const char *driverName) {
|
||||
PUBLIC const char *glXGetDriverConfig (const char *driverName) {
|
||||
__DRIdriver *driver = OpenDriver (driverName);
|
||||
if (driver)
|
||||
return dlsym (driver->handle, "__driConfigOptions");
|
||||
|
@@ -31,21 +31,25 @@
|
||||
* \author Ian Romanick <idr@us.ibm.com>
|
||||
*/
|
||||
|
||||
#if defined(IN_MINI_GLX)
|
||||
#include <GL/gl.h>
|
||||
#else
|
||||
#if defined(HAVE_DIX_CONFIG_H)
|
||||
# include <dix-config.h>
|
||||
#endif
|
||||
#include <X11/X.h>
|
||||
#include <GL/glx.h>
|
||||
#include "GL/glxint.h"
|
||||
#endif
|
||||
|
||||
/* Memory macros */
|
||||
#if defined(IN_MINI_GLX)
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <GL/gl.h>
|
||||
# include "GL/internal/dri_interface.h"
|
||||
# include "imports.h"
|
||||
# define _mesa_malloc(b) malloc(b)
|
||||
# define _mesa_free(m) free(m)
|
||||
# define _mesa_memset memset
|
||||
#else
|
||||
# if defined(HAVE_DIX_CONFIG_H)
|
||||
# include <dix-config.h>
|
||||
# endif
|
||||
# include <X11/X.h>
|
||||
# include <GL/glx.h>
|
||||
# include "GL/glxint.h"
|
||||
|
||||
# ifdef XFree86Server
|
||||
# include <os.h>
|
||||
# include <string.h>
|
@@ -1246,7 +1246,7 @@ __GLXdisplayPrivate *__glXInitialize(Display* dpy)
|
||||
__glXUnlock();
|
||||
return 0;
|
||||
}
|
||||
dpyPriv = (__GLXdisplayPrivate *) Xmalloc(sizeof(__GLXdisplayPrivate));
|
||||
dpyPriv = (__GLXdisplayPrivate *) Xcalloc(1, sizeof(__GLXdisplayPrivate));
|
||||
if (!dpyPriv) {
|
||||
__glXUnlock();
|
||||
Xfree((char*) private);
|
||||
@@ -1271,12 +1271,7 @@ __GLXdisplayPrivate *__glXInitialize(Display* dpy)
|
||||
** Note: This _must_ be done before calling any other DRI routines
|
||||
** (e.g., those called in AllocAndFetchScreenConfigs).
|
||||
*/
|
||||
if (getenv("LIBGL_ALWAYS_INDIRECT")) {
|
||||
/* Assinging zero here assures we'll never go direct */
|
||||
dpyPriv->driDisplay.private = 0;
|
||||
dpyPriv->driDisplay.destroyDisplay = 0;
|
||||
}
|
||||
else {
|
||||
if (getenv("LIBGL_ALWAYS_INDIRECT") == NULL) {
|
||||
dpyPriv->driDisplay.private =
|
||||
driCreateDisplay(dpy, &dpyPriv->driDisplay);
|
||||
}
|
||||
@@ -1488,7 +1483,7 @@ void __glXSendLargeCommand(__GLXcontext *ctx,
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
GLXContext glXGetCurrentContext(void)
|
||||
PUBLIC GLXContext glXGetCurrentContext(void)
|
||||
{
|
||||
GLXContext cx = __glXGetCurrentContext();
|
||||
|
||||
@@ -1499,7 +1494,7 @@ GLXContext glXGetCurrentContext(void)
|
||||
}
|
||||
}
|
||||
|
||||
GLXDrawable glXGetCurrentDrawable(void)
|
||||
PUBLIC GLXDrawable glXGetCurrentDrawable(void)
|
||||
{
|
||||
GLXContext gc = __glXGetCurrentContext();
|
||||
return gc->currentDrawable;
|
||||
|
@@ -145,9 +145,10 @@ GLenum __indirect_glGetError(void)
|
||||
* On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned.
|
||||
*/
|
||||
static GLboolean
|
||||
get_client_data( __GLXattribute * state, GLenum cap, GLintptr * data )
|
||||
get_client_data( __GLXcontext * gc, GLenum cap, GLintptr * data )
|
||||
{
|
||||
GLboolean retval = GL_TRUE;
|
||||
__GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
|
||||
const GLint tex_unit = __glXGetActiveTextureUnit( state );
|
||||
|
||||
|
||||
@@ -281,6 +282,9 @@ get_client_data( __GLXattribute * state, GLenum cap, GLintptr * data )
|
||||
case GL_UNPACK_LSB_FIRST:
|
||||
*data = (GLintptr)state->storeUnpack.lsbFirst;
|
||||
break;
|
||||
case GL_CLIENT_ATTRIB_STACK_DEPTH:
|
||||
*data = (GLintptr)(gc->attributes.stackPointer - gc->attributes.stack);
|
||||
break;
|
||||
case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
|
||||
*data = (GLintptr)__GL_CLIENT_ATTRIB_STACK_DEPTH;
|
||||
break;
|
||||
@@ -302,7 +306,6 @@ void __indirect_glGetBooleanv(GLenum val, GLboolean *b)
|
||||
{
|
||||
const GLenum origVal = val;
|
||||
__GLX_SINGLE_DECLARE_VARIABLES();
|
||||
__GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
|
||||
xGLXSingleReply reply;
|
||||
|
||||
val = RemapTransposeEnum( val );
|
||||
@@ -326,7 +329,7 @@ void __indirect_glGetBooleanv(GLenum val, GLboolean *b)
|
||||
** for example, to call a query between glBegin() and glEnd()).
|
||||
*/
|
||||
|
||||
if ( get_client_data( state, val, & data ) ) {
|
||||
if ( get_client_data( gc, val, & data ) ) {
|
||||
*b = (GLboolean) data;
|
||||
}
|
||||
else {
|
||||
@@ -351,7 +354,6 @@ void __indirect_glGetDoublev(GLenum val, GLdouble *d)
|
||||
{
|
||||
const GLenum origVal = val;
|
||||
__GLX_SINGLE_DECLARE_VARIABLES();
|
||||
__GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
|
||||
xGLXSingleReply reply;
|
||||
|
||||
val = RemapTransposeEnum( val );
|
||||
@@ -375,7 +377,7 @@ void __indirect_glGetDoublev(GLenum val, GLdouble *d)
|
||||
** for example, to call a query between glBegin() and glEnd()).
|
||||
*/
|
||||
|
||||
if ( get_client_data( state, val, & data ) ) {
|
||||
if ( get_client_data( gc, val, & data ) ) {
|
||||
*d = (GLdouble) data;
|
||||
}
|
||||
else {
|
||||
@@ -400,7 +402,6 @@ void __indirect_glGetFloatv(GLenum val, GLfloat *f)
|
||||
{
|
||||
const GLenum origVal = val;
|
||||
__GLX_SINGLE_DECLARE_VARIABLES();
|
||||
__GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
|
||||
xGLXSingleReply reply;
|
||||
|
||||
val = RemapTransposeEnum( val );
|
||||
@@ -424,7 +425,7 @@ void __indirect_glGetFloatv(GLenum val, GLfloat *f)
|
||||
** for example, to call a query between glBegin() and glEnd()).
|
||||
*/
|
||||
|
||||
if ( get_client_data( state, val, & data ) ) {
|
||||
if ( get_client_data( gc, val, & data ) ) {
|
||||
*f = (GLfloat) data;
|
||||
}
|
||||
else {
|
||||
@@ -449,7 +450,6 @@ void __indirect_glGetIntegerv(GLenum val, GLint *i)
|
||||
{
|
||||
const GLenum origVal = val;
|
||||
__GLX_SINGLE_DECLARE_VARIABLES();
|
||||
__GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
|
||||
xGLXSingleReply reply;
|
||||
|
||||
val = RemapTransposeEnum( val );
|
||||
@@ -473,7 +473,7 @@ void __indirect_glGetIntegerv(GLenum val, GLint *i)
|
||||
** for example, to call a query between glBegin() and glEnd()).
|
||||
*/
|
||||
|
||||
if ( get_client_data( state, val, & data ) ) {
|
||||
if ( get_client_data( gc, val, & data ) ) {
|
||||
*i = (GLint) data;
|
||||
}
|
||||
else {
|
||||
|
@@ -89,9 +89,7 @@ fbdev: $(CORE_OBJECTS) $(FBDEV_DRIVER_OBJECTS) $(COMMON_DRIVER_OBJECTS)
|
||||
# Stand-alone Mesa libGL and libOSMesa
|
||||
STAND_ALONE_DRIVER_SOURCES = \
|
||||
$(COMMON_DRIVER_SOURCES) \
|
||||
$(X11_DRIVER_SOURCES) \
|
||||
$(GLIDE_DRIVER_SOURCES) \
|
||||
$(SVGA_DRIVER_SOURCES)
|
||||
$(X11_DRIVER_SOURCES)
|
||||
|
||||
STAND_ALONE_DRIVER_OBJECTS = $(STAND_ALONE_DRIVER_SOURCES:.c=.o)
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -28,8 +28,9 @@
|
||||
#include "buffers.h"
|
||||
#include "context.h"
|
||||
#include "framebuffer.h"
|
||||
#include "occlude.h"
|
||||
#include "program.h"
|
||||
#include "prog_execute.h"
|
||||
#include "queryobj.h"
|
||||
#include "renderbuffer.h"
|
||||
#include "texcompress.h"
|
||||
#include "texformat.h"
|
||||
@@ -43,6 +44,7 @@
|
||||
#include "fbobject.h"
|
||||
#include "texrender.h"
|
||||
#endif
|
||||
#include "shader_api.h"
|
||||
#include "arrayobj.h"
|
||||
|
||||
#include "driverfuncs.h"
|
||||
@@ -127,7 +129,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
|
||||
driver->NewProgram = _mesa_new_program;
|
||||
driver->DeleteProgram = _mesa_delete_program;
|
||||
#if FEATURE_MESA_program_debug
|
||||
driver->GetFragmentProgramRegister = _swrast_get_program_register;
|
||||
driver->GetProgramRegister = _mesa_get_program_register;
|
||||
#endif /* FEATURE_MESA_program_debug */
|
||||
|
||||
/* simple state commands */
|
||||
@@ -248,4 +250,45 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
|
||||
driver->EndList = NULL;
|
||||
driver->BeginCallList = NULL;
|
||||
driver->EndCallList = NULL;
|
||||
|
||||
|
||||
/* XXX temporary here */
|
||||
_mesa_init_glsl_driver_functions(driver);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Plug in Mesa's GLSL functions.
|
||||
*/
|
||||
void
|
||||
_mesa_init_glsl_driver_functions(struct dd_function_table *driver)
|
||||
{
|
||||
driver->AttachShader = _mesa_attach_shader;
|
||||
driver->BindAttribLocation = _mesa_bind_attrib_location;
|
||||
driver->CompileShader = _mesa_compile_shader;
|
||||
driver->CreateProgram = _mesa_create_program;
|
||||
driver->CreateShader = _mesa_create_shader;
|
||||
driver->DeleteProgram2 = _mesa_delete_program2;
|
||||
driver->DeleteShader = _mesa_delete_shader;
|
||||
driver->DetachShader = _mesa_detach_shader;
|
||||
driver->GetActiveAttrib = _mesa_get_active_attrib;
|
||||
driver->GetActiveUniform = _mesa_get_active_uniform;
|
||||
driver->GetAttachedShaders = _mesa_get_attached_shaders;
|
||||
driver->GetAttribLocation = _mesa_get_attrib_location;
|
||||
driver->GetHandle = _mesa_get_handle;
|
||||
driver->GetProgramiv = _mesa_get_programiv;
|
||||
driver->GetProgramInfoLog = _mesa_get_program_info_log;
|
||||
driver->GetShaderiv = _mesa_get_shaderiv;
|
||||
driver->GetShaderInfoLog = _mesa_get_shader_info_log;
|
||||
driver->GetShaderSource = _mesa_get_shader_source;
|
||||
driver->GetUniformfv = _mesa_get_uniformfv;
|
||||
driver->GetUniformLocation = _mesa_get_uniform_location;
|
||||
driver->IsProgram = _mesa_is_program;
|
||||
driver->IsShader = _mesa_is_shader;
|
||||
driver->LinkProgram = _mesa_link_program;
|
||||
driver->ShaderSource = _mesa_shader_source;
|
||||
driver->Uniform = _mesa_uniform;
|
||||
driver->UniformMatrix = _mesa_uniform_matrix;
|
||||
driver->UseProgram = _mesa_use_program;
|
||||
driver->ValidateProgram = _mesa_validate_program;
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.1
|
||||
* Version: 6.5.3
|
||||
*
|
||||
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -29,4 +29,8 @@
|
||||
extern void
|
||||
_mesa_init_driver_functions(struct dd_function_table *driver);
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_init_glsl_driver_functions(struct dd_function_table *driver);
|
||||
|
||||
#endif
|
||||
|
@@ -190,11 +190,16 @@ driBOKernel(struct _DriBufferObject *buf)
|
||||
void
|
||||
driBOWaitIdle(struct _DriBufferObject *buf, int lazy)
|
||||
{
|
||||
assert(buf->private != NULL);
|
||||
struct _DriBufferPool *pool;
|
||||
void *priv;
|
||||
|
||||
_glthread_LOCK_MUTEX(buf->mutex);
|
||||
BM_CKFATAL(buf->pool->waitIdle(buf->pool, buf->private, lazy));
|
||||
pool = buf->pool;
|
||||
priv = buf->private;
|
||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
||||
|
||||
assert(priv != NULL);
|
||||
BM_CKFATAL(buf->pool->waitIdle(pool, priv, lazy));
|
||||
}
|
||||
|
||||
void *
|
||||
@@ -296,7 +301,8 @@ driBOData(struct _DriBufferObject *buf,
|
||||
pool->destroy(pool, buf->private);
|
||||
if (!flags)
|
||||
flags = buf->flags;
|
||||
buf->private = pool->create(pool, size, flags, 0, buf->alignment);
|
||||
buf->private = pool->create(pool, size, flags, DRM_BO_HINT_DONT_FENCE,
|
||||
buf->alignment);
|
||||
if (!buf->private)
|
||||
BM_CKFATAL(-ENOMEM);
|
||||
BM_CKFATAL(pool->map(pool, buf->private,
|
||||
|
@@ -185,7 +185,7 @@ pool_setstatic(struct _DriBufferPool *pool, unsigned long offset,
|
||||
return NULL;
|
||||
|
||||
ret = drmBOCreate(pool->fd, offset, size, 0, NULL, drm_bo_type_fake,
|
||||
flags, 0, buf);
|
||||
flags, DRM_BO_HINT_DONT_FENCE, buf);
|
||||
|
||||
if (ret) {
|
||||
free(buf);
|
||||
|
@@ -49,8 +49,6 @@
|
||||
#ifndef _DRI_UTIL_H_
|
||||
#define _DRI_UTIL_H_
|
||||
|
||||
#define CAPI /* XXX this should be globally defined somewhere */
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include "drm.h"
|
||||
#include "drm_sarea.h"
|
||||
|
@@ -208,7 +208,7 @@ driUpdateFramebufferSize(GLcontext *ctx, const __DRIdrawablePrivate *dPriv)
|
||||
{
|
||||
struct gl_framebuffer *fb = (struct gl_framebuffer *) dPriv->driverPrivate;
|
||||
if (fb && (dPriv->w != fb->Width || dPriv->h != fb->Height)) {
|
||||
_mesa_resize_framebuffer(ctx, fb, dPriv->w, dPriv->h);
|
||||
ctx->Driver.ResizeBuffers(ctx, fb, dPriv->w, dPriv->h);
|
||||
assert(fb->Width == dPriv->w);
|
||||
assert(fb->Height == dPriv->h);
|
||||
}
|
||||
|
@@ -40,6 +40,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#include "extensions.h"
|
||||
#include "framebuffer.h"
|
||||
#include "imports.h"
|
||||
#include "points.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
@@ -278,6 +279,11 @@ i810CreateContext( const __GLcontextModes *mesaVis,
|
||||
ctx->Const.MaxPointSizeAA = 3.0;
|
||||
ctx->Const.PointSizeGranularity = 1.0;
|
||||
|
||||
/* reinitialize the context point state.
|
||||
* It depend on constants in __GLcontextRec::Const
|
||||
*/
|
||||
_mesa_init_point(ctx);
|
||||
|
||||
ctx->Driver.GetBufferSize = i810BufferSize;
|
||||
ctx->Driver.GetString = i810GetString;
|
||||
|
||||
|
@@ -167,8 +167,8 @@ GLboolean i915CreateContext( const __GLcontextModes *mesaVis,
|
||||
I915_MAX_TEX_INSN);
|
||||
ctx->Const.FragmentProgram.MaxNativeTexIndirections = I915_MAX_TEX_INDIRECT;
|
||||
ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0; /* I don't think we have one */
|
||||
ctx->_MaintainTexEnvProgram = 1;
|
||||
ctx->_UseTexEnvProgram = 1;
|
||||
ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
|
||||
ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE;
|
||||
|
||||
|
||||
driInitExtensions( ctx, i915_extensions, GL_FALSE );
|
||||
|
@@ -37,7 +37,8 @@
|
||||
#include "i915_context.h"
|
||||
#include "i915_program.h"
|
||||
|
||||
#include "program_instruction.h"
|
||||
#include "prog_instruction.h"
|
||||
#include "prog_parameter.h"
|
||||
#include "program.h"
|
||||
#include "programopt.h"
|
||||
|
||||
@@ -782,9 +783,6 @@ static void fixup_depth_write( struct i915_fragment_program *p )
|
||||
}
|
||||
|
||||
|
||||
#define FRAG_BIT_TEX(n) (FRAG_BIT_TEX0 << (n))
|
||||
|
||||
|
||||
static void check_wpos( struct i915_fragment_program *p )
|
||||
{
|
||||
GLuint inputs = p->FragProg.Base.InputsRead;
|
||||
|
@@ -430,17 +430,17 @@ void i915_fini_program( struct i915_fragment_program *p )
|
||||
|
||||
if (p->error) {
|
||||
p->FragProg.Base.NumNativeInstructions = 0;
|
||||
p->FragProg.NumNativeAluInstructions = 0;
|
||||
p->FragProg.NumNativeTexInstructions = 0;
|
||||
p->FragProg.NumNativeTexIndirections = 0;
|
||||
p->FragProg.Base.NumNativeAluInstructions = 0;
|
||||
p->FragProg.Base.NumNativeTexInstructions = 0;
|
||||
p->FragProg.Base.NumNativeTexIndirections = 0;
|
||||
}
|
||||
else {
|
||||
p->FragProg.Base.NumNativeInstructions = (p->nr_alu_insn +
|
||||
p->nr_tex_insn +
|
||||
p->nr_decl_insn);
|
||||
p->FragProg.NumNativeAluInstructions = p->nr_alu_insn;
|
||||
p->FragProg.NumNativeTexInstructions = p->nr_tex_insn;
|
||||
p->FragProg.NumNativeTexIndirections = p->nr_tex_indirect;
|
||||
p->FragProg.Base.NumNativeAluInstructions = p->nr_alu_insn;
|
||||
p->FragProg.Base.NumNativeTexInstructions = p->nr_tex_insn;
|
||||
p->FragProg.Base.NumNativeTexIndirections = p->nr_tex_indirect;
|
||||
}
|
||||
|
||||
p->declarations[0] |= program_size + decl_size - 2;
|
||||
|
@@ -541,17 +541,19 @@ void i915_update_fog( GLcontext *ctx )
|
||||
else {
|
||||
enabled = ctx->Fog.Enabled;
|
||||
mode = ctx->Fog.Mode;
|
||||
|
||||
try_pixel_fog = (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT &&
|
||||
ctx->Hint.Fog == GL_NICEST &&
|
||||
0); /* XXX - DISABLE -- Need ortho fallback */
|
||||
#if 0
|
||||
/* XXX - DISABLED -- Need ortho fallback */
|
||||
try_pixel_fog = (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT
|
||||
&&ctx->Hint.Fog == GL_NICEST);
|
||||
#else
|
||||
try_pixel_fog = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
i915->vertex_fog = I915_FOG_NONE;
|
||||
}
|
||||
else if (try_pixel_fog) {
|
||||
|
||||
I915_STATECHANGE(i915, I915_UPLOAD_FOG);
|
||||
i915->state.Fog[I915_FOGREG_MODE1] &= ~FMC1_FOGFUNC_MASK;
|
||||
i915->vertex_fog = I915_FOG_PIXEL;
|
||||
@@ -567,8 +569,8 @@ void i915_update_fog( GLcontext *ctx )
|
||||
i915->vertex_fog = I915_FOG_VERTEX;
|
||||
}
|
||||
else {
|
||||
GLfloat c1 = ctx->Fog.End/(ctx->Fog.End-ctx->Fog.Start);
|
||||
GLfloat c2 = 1.0/(ctx->Fog.End-ctx->Fog.Start);
|
||||
GLfloat c2 = 1.0 / (ctx->Fog.End - ctx->Fog.Start);
|
||||
GLfloat c1 = ctx->Fog.End * c2;
|
||||
|
||||
i915->state.Fog[I915_FOGREG_MODE1] &= ~FMC1_C1_MASK;
|
||||
i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_PIXEL_LINEAR;
|
||||
@@ -576,10 +578,11 @@ void i915_update_fog( GLcontext *ctx )
|
||||
((GLuint)(c1 * FMC1_C1_ONE)) & FMC1_C1_MASK;
|
||||
|
||||
if (i915->state.Fog[I915_FOGREG_MODE1] & FMC1_FOGINDEX_Z) {
|
||||
i915->state.Fog[I915_FOGREG_MODE2] = (GLuint)(c2 * FMC2_C2_ONE);
|
||||
i915->state.Fog[I915_FOGREG_MODE2]
|
||||
= (GLuint)(c2 * FMC2_C2_ONE);
|
||||
}
|
||||
else {
|
||||
union { float f; int i; } fi;
|
||||
fi_type fi;
|
||||
fi.f = c2;
|
||||
i915->state.Fog[I915_FOGREG_MODE2] = fi.i;
|
||||
}
|
||||
@@ -602,24 +605,22 @@ void i915_update_fog( GLcontext *ctx )
|
||||
i915->vertex_fog = I915_FOG_VERTEX;
|
||||
}
|
||||
|
||||
{
|
||||
I915_STATECHANGE(i915, I915_UPLOAD_CTX);
|
||||
I915_ACTIVESTATE(i915, I915_UPLOAD_FOG, enabled);
|
||||
if (enabled)
|
||||
i915->state.Ctx[I915_CTXREG_LIS5] |= S5_FOG_ENABLE;
|
||||
else
|
||||
i915->state.Ctx[I915_CTXREG_LIS5] &= ~S5_FOG_ENABLE;
|
||||
}
|
||||
I915_STATECHANGE(i915, I915_UPLOAD_CTX);
|
||||
I915_ACTIVESTATE(i915, I915_UPLOAD_FOG, enabled);
|
||||
if (enabled)
|
||||
i915->state.Ctx[I915_CTXREG_LIS5] |= S5_FOG_ENABLE;
|
||||
else
|
||||
i915->state.Ctx[I915_CTXREG_LIS5] &= ~S5_FOG_ENABLE;
|
||||
|
||||
/* always enbale pixel fog
|
||||
* vertex fog use precaculted fog coord will conflict with appended
|
||||
* fog program
|
||||
/* Always enable pixel fog. Vertex fog using fog coord will conflict
|
||||
* with fog code appended onto fragment program.
|
||||
*/
|
||||
_tnl_allow_vertex_fog( ctx, 0 );
|
||||
_tnl_allow_pixel_fog( ctx, 1 );
|
||||
}
|
||||
|
||||
static void i915Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
|
||||
static void
|
||||
i915Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
|
||||
{
|
||||
i915ContextPtr i915 = I915_CONTEXT(ctx);
|
||||
|
||||
@@ -634,8 +635,8 @@ static void i915Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
|
||||
I915_STATECHANGE(i915, I915_UPLOAD_FOG);
|
||||
|
||||
if (i915->state.Fog[I915_FOGREG_MODE1] & FMC1_FOGINDEX_Z) {
|
||||
i915->state.Fog[I915_FOGREG_MODE3] = (GLuint)(ctx->Fog.Density *
|
||||
FMC3_D_ONE);
|
||||
i915->state.Fog[I915_FOGREG_MODE3]
|
||||
= (GLuint)(ctx->Fog.Density * FMC3_D_ONE);
|
||||
}
|
||||
else {
|
||||
union { float f; int i; } fi;
|
||||
|
@@ -49,7 +49,7 @@ static void i915_render_start( intelContextPtr intel )
|
||||
if (ctx->FragmentProgram._Active)
|
||||
i915ValidateFragmentProgram( i915 );
|
||||
else {
|
||||
assert(!ctx->_MaintainTexEnvProgram);
|
||||
assert(!ctx->FragmentProgram._MaintainTexEnvProgram);
|
||||
i915ValidateTextureProgram( i915 );
|
||||
}
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include "extensions.h"
|
||||
#include "framebuffer.h"
|
||||
#include "imports.h"
|
||||
#include "points.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
@@ -195,7 +196,6 @@ static const struct tnl_pipeline_stage *intel_pipeline[] = {
|
||||
&_tnl_texgen_stage,
|
||||
&_tnl_texture_transform_stage,
|
||||
&_tnl_point_attenuation_stage,
|
||||
&_tnl_arb_vertex_program_stage,
|
||||
&_tnl_vertex_program_stage,
|
||||
#if 1
|
||||
&_intel_render_stage, /* ADD: unclipped rastersetup-to-dma */
|
||||
@@ -302,6 +302,11 @@ GLboolean intelInitContext( intelContextPtr intel,
|
||||
ctx->Const.MaxPointSizeAA = 3.0;
|
||||
ctx->Const.PointSizeGranularity = 1.0;
|
||||
|
||||
/* reinitialize the context point state.
|
||||
* It depend on constants in __GLcontextRec::Const
|
||||
*/
|
||||
_mesa_init_point(ctx);
|
||||
|
||||
/* Initialize the software rasterizer and helper modules. */
|
||||
_swrast_CreateContext( ctx );
|
||||
_vbo_CreateContext( ctx );
|
||||
@@ -563,7 +568,7 @@ void intelWindowMoved( intelContextPtr intel )
|
||||
GLint areaB = driIntersectArea( drw_rect, pipeB_rect );
|
||||
GLuint flags = intel->vblank_flags;
|
||||
|
||||
if (areaB > areaA || (areaA > 0 && areaB > 0)) {
|
||||
if (areaB > areaA || (areaA == areaB && areaB > 0)) {
|
||||
flags = intel->vblank_flags | VBLANK_FLAG_SECONDARY;
|
||||
} else {
|
||||
flags = intel->vblank_flags & ~VBLANK_FLAG_SECONDARY;
|
||||
|
@@ -157,8 +157,8 @@ i915CreateContext(const __GLcontextModes * mesaVis,
|
||||
I915_MAX_TEX_INDIRECT;
|
||||
ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0; /* I don't think we have one */
|
||||
|
||||
ctx->_MaintainTexEnvProgram = 1;
|
||||
ctx->_UseTexEnvProgram = 1;
|
||||
ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
|
||||
ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE;
|
||||
|
||||
driInitExtensions(ctx, i915_extensions, GL_FALSE);
|
||||
|
||||
|
@@ -37,7 +37,8 @@
|
||||
#include "i915_context.h"
|
||||
#include "i915_program.h"
|
||||
|
||||
#include "program_instruction.h"
|
||||
#include "prog_instruction.h"
|
||||
#include "prog_parameter.h"
|
||||
#include "program.h"
|
||||
#include "programopt.h"
|
||||
|
||||
@@ -772,9 +773,6 @@ fixup_depth_write(struct i915_fragment_program *p)
|
||||
}
|
||||
|
||||
|
||||
#define FRAG_BIT_TEX(n) (FRAG_BIT_TEX0 << (n))
|
||||
|
||||
|
||||
static void
|
||||
check_wpos(struct i915_fragment_program *p)
|
||||
{
|
||||
|
@@ -446,17 +446,17 @@ i915_fini_program(struct i915_fragment_program *p)
|
||||
|
||||
if (p->error) {
|
||||
p->FragProg.Base.NumNativeInstructions = 0;
|
||||
p->FragProg.NumNativeAluInstructions = 0;
|
||||
p->FragProg.NumNativeTexInstructions = 0;
|
||||
p->FragProg.NumNativeTexIndirections = 0;
|
||||
p->FragProg.Base.NumNativeAluInstructions = 0;
|
||||
p->FragProg.Base.NumNativeTexInstructions = 0;
|
||||
p->FragProg.Base.NumNativeTexIndirections = 0;
|
||||
}
|
||||
else {
|
||||
p->FragProg.Base.NumNativeInstructions = (p->nr_alu_insn +
|
||||
p->nr_tex_insn +
|
||||
p->nr_decl_insn);
|
||||
p->FragProg.NumNativeAluInstructions = p->nr_alu_insn;
|
||||
p->FragProg.NumNativeTexInstructions = p->nr_tex_insn;
|
||||
p->FragProg.NumNativeTexIndirections = p->nr_tex_indirect;
|
||||
p->FragProg.Base.NumNativeAluInstructions = p->nr_alu_insn;
|
||||
p->FragProg.Base.NumNativeTexInstructions = p->nr_tex_insn;
|
||||
p->FragProg.Base.NumNativeTexIndirections = p->nr_tex_indirect;
|
||||
}
|
||||
|
||||
p->declarations[0] |= program_size + decl_size - 2;
|
||||
|
@@ -563,7 +563,6 @@ i915_update_fog(GLcontext * ctx)
|
||||
|
||||
if (ctx->FragmentProgram._Active) {
|
||||
/* Pull in static fog state from program */
|
||||
|
||||
mode = ctx->FragmentProgram._Current->FogOption;
|
||||
enabled = (mode != GL_NONE);
|
||||
try_pixel_fog = 0;
|
||||
@@ -571,15 +570,19 @@ i915_update_fog(GLcontext * ctx)
|
||||
else {
|
||||
enabled = ctx->Fog.Enabled;
|
||||
mode = ctx->Fog.Mode;
|
||||
|
||||
try_pixel_fog = (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT && ctx->Hint.Fog == GL_NICEST && 0); /* XXX - DISABLE -- Need ortho fallback */
|
||||
#if 0
|
||||
/* XXX - DISABLED -- Need ortho fallback */
|
||||
try_pixel_fog = (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT
|
||||
&& ctx->Hint.Fog == GL_NICEST);
|
||||
#else
|
||||
try_pixel_fog = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
i915->vertex_fog = I915_FOG_NONE;
|
||||
}
|
||||
else if (try_pixel_fog) {
|
||||
|
||||
I915_STATECHANGE(i915, I915_UPLOAD_FOG);
|
||||
i915->state.Fog[I915_FOGREG_MODE1] &= ~FMC1_FOGFUNC_MASK;
|
||||
i915->vertex_fog = I915_FOG_PIXEL;
|
||||
@@ -591,12 +594,13 @@ i915_update_fog(GLcontext * ctx)
|
||||
* either fallback or append fog instructions to end of
|
||||
* program in the case of linear fog.
|
||||
*/
|
||||
printf("vertex fog!\n");
|
||||
i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_VERTEX;
|
||||
i915->vertex_fog = I915_FOG_VERTEX;
|
||||
}
|
||||
else {
|
||||
GLfloat c1 = ctx->Fog.End / (ctx->Fog.End - ctx->Fog.Start);
|
||||
GLfloat c2 = 1.0 / (ctx->Fog.End - ctx->Fog.Start);
|
||||
GLfloat c1 = ctx->Fog.End * c2;
|
||||
|
||||
i915->state.Fog[I915_FOGREG_MODE1] &= ~FMC1_C1_MASK;
|
||||
i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_PIXEL_LINEAR;
|
||||
@@ -604,15 +608,11 @@ i915_update_fog(GLcontext * ctx)
|
||||
((GLuint) (c1 * FMC1_C1_ONE)) & FMC1_C1_MASK;
|
||||
|
||||
if (i915->state.Fog[I915_FOGREG_MODE1] & FMC1_FOGINDEX_Z) {
|
||||
i915->state.Fog[I915_FOGREG_MODE2] =
|
||||
(GLuint) (c2 * FMC2_C2_ONE);
|
||||
i915->state.Fog[I915_FOGREG_MODE2]
|
||||
= (GLuint) (c2 * FMC2_C2_ONE);
|
||||
}
|
||||
else {
|
||||
union
|
||||
{
|
||||
float f;
|
||||
int i;
|
||||
} fi;
|
||||
fi_type fi;
|
||||
fi.f = c2;
|
||||
i915->state.Fog[I915_FOGREG_MODE2] = fi.i;
|
||||
}
|
||||
@@ -628,26 +628,22 @@ i915_update_fog(GLcontext * ctx)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else { /* if (i915->vertex_fog != I915_FOG_VERTEX) */
|
||||
|
||||
else { /* if (i915->vertex_fog != I915_FOG_VERTEX) */
|
||||
I915_STATECHANGE(i915, I915_UPLOAD_FOG);
|
||||
i915->state.Fog[I915_FOGREG_MODE1] &= ~FMC1_FOGFUNC_MASK;
|
||||
i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_VERTEX;
|
||||
i915->vertex_fog = I915_FOG_VERTEX;
|
||||
}
|
||||
|
||||
{
|
||||
I915_STATECHANGE(i915, I915_UPLOAD_CTX);
|
||||
I915_ACTIVESTATE(i915, I915_UPLOAD_FOG, enabled);
|
||||
if (enabled)
|
||||
i915->state.Ctx[I915_CTXREG_LIS5] |= S5_FOG_ENABLE;
|
||||
else
|
||||
i915->state.Ctx[I915_CTXREG_LIS5] &= ~S5_FOG_ENABLE;
|
||||
}
|
||||
I915_STATECHANGE(i915, I915_UPLOAD_CTX);
|
||||
I915_ACTIVESTATE(i915, I915_UPLOAD_FOG, enabled);
|
||||
if (enabled)
|
||||
i915->state.Ctx[I915_CTXREG_LIS5] |= S5_FOG_ENABLE;
|
||||
else
|
||||
i915->state.Ctx[I915_CTXREG_LIS5] &= ~S5_FOG_ENABLE;
|
||||
|
||||
/* always enbale pixel fog
|
||||
* vertex fog use precaculted fog coord will conflict with appended
|
||||
* fog program
|
||||
/* Always enable pixel fog. Vertex fog using fog coord will conflict
|
||||
* with fog code appended onto fragment program.
|
||||
*/
|
||||
_tnl_allow_vertex_fog( ctx, 0 );
|
||||
_tnl_allow_pixel_fog( ctx, 1 );
|
||||
@@ -669,15 +665,11 @@ i915Fogfv(GLcontext * ctx, GLenum pname, const GLfloat * param)
|
||||
I915_STATECHANGE(i915, I915_UPLOAD_FOG);
|
||||
|
||||
if (i915->state.Fog[I915_FOGREG_MODE1] & FMC1_FOGINDEX_Z) {
|
||||
i915->state.Fog[I915_FOGREG_MODE3] = (GLuint) (ctx->Fog.Density *
|
||||
FMC3_D_ONE);
|
||||
i915->state.Fog[I915_FOGREG_MODE3] =
|
||||
(GLuint) (ctx->Fog.Density * FMC3_D_ONE);
|
||||
}
|
||||
else {
|
||||
union
|
||||
{
|
||||
float f;
|
||||
int i;
|
||||
} fi;
|
||||
fi_type fi;
|
||||
fi.f = ctx->Fog.Density;
|
||||
i915->state.Fog[I915_FOGREG_MODE3] = fi.i;
|
||||
}
|
||||
|
@@ -96,7 +96,7 @@ createBPool(int fd, unsigned long bufSize, unsigned numBufs, unsigned flags,
|
||||
_glthread_INIT_MUTEX(p->mutex);
|
||||
|
||||
if (drmBOCreate(fd, 0, numBufs * bufSize, 0, NULL, drm_bo_type_dc,
|
||||
flags, 0, &p->kernelBO)) {
|
||||
flags, DRM_BO_HINT_DONT_FENCE, &p->kernelBO)) {
|
||||
free(p->bufs);
|
||||
free(p);
|
||||
return NULL;
|
||||
|
@@ -76,7 +76,9 @@ intel_bufferobj_release_region(struct intel_context *intel,
|
||||
*/
|
||||
driGenBuffers(intel->intelScreen->regionPool,
|
||||
"buffer object", 1, &intel_obj->buffer, 64, 0, 0);
|
||||
LOCK_HARDWARE(intel);
|
||||
driBOData(intel_obj->buffer, intel_obj->Base.Size, NULL, 0);
|
||||
UNLOCK_HARDWARE(intel);
|
||||
}
|
||||
|
||||
/* Break the COW tie to the region. Both the pbo and the region end
|
||||
@@ -137,7 +139,9 @@ intel_bufferobj_data(GLcontext * ctx,
|
||||
if (intel_obj->region)
|
||||
intel_bufferobj_release_region(intel, intel_obj);
|
||||
|
||||
LOCK_HARDWARE(intel);
|
||||
driBOData(intel_obj->buffer, size, data, 0);
|
||||
UNLOCK_HARDWARE(intel);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include "extensions.h"
|
||||
#include "framebuffer.h"
|
||||
#include "imports.h"
|
||||
#include "points.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
@@ -208,7 +209,6 @@ static const struct tnl_pipeline_stage *intel_pipeline[] = {
|
||||
&_tnl_texgen_stage,
|
||||
&_tnl_texture_transform_stage,
|
||||
&_tnl_point_attenuation_stage,
|
||||
&_tnl_arb_vertex_program_stage,
|
||||
&_tnl_vertex_program_stage,
|
||||
#if 1
|
||||
&_intel_render_stage, /* ADD: unclipped rastersetup-to-dma */
|
||||
@@ -346,7 +346,15 @@ intelInitContext(struct intel_context *intel,
|
||||
drmI830Sarea *saPriv = (drmI830Sarea *)
|
||||
(((GLubyte *) sPriv->pSAREA) + intelScreen->sarea_priv_offset);
|
||||
int fthrottle_mode;
|
||||
GLboolean havePools;
|
||||
|
||||
DRM_LIGHT_LOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
|
||||
havePools = intelCreatePools(intelScreen);
|
||||
DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
|
||||
|
||||
if (!havePools)
|
||||
return GL_FALSE;
|
||||
|
||||
if (!_mesa_initialize_context(&intel->ctx,
|
||||
mesaVis, shareCtx,
|
||||
functions, (void *) intel))
|
||||
@@ -390,6 +398,11 @@ intelInitContext(struct intel_context *intel,
|
||||
ctx->Const.MaxPointSizeAA = 3.0;
|
||||
ctx->Const.PointSizeGranularity = 1.0;
|
||||
|
||||
/* reinitialize the context point state.
|
||||
* It depend on constants in __GLcontextRec::Const
|
||||
*/
|
||||
_mesa_init_point(ctx);
|
||||
|
||||
ctx->Const.MaxColorAttachments = 4; /* XXX FBO: review this */
|
||||
|
||||
/* Initialize the software rasterizer and helper modules. */
|
||||
@@ -581,10 +594,11 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
|
||||
}
|
||||
|
||||
/* set GLframebuffer size to match window, if needed */
|
||||
if (driReadPriv != driDrawPriv && readFb->Width != driReadPriv->w) {
|
||||
_mesa_resize_framebuffer(&intel->ctx, readFb,
|
||||
driReadPriv->w, driReadPriv->h);
|
||||
}
|
||||
driUpdateFramebufferSize(&intel->ctx, driDrawPriv);
|
||||
|
||||
if (driReadPriv != driDrawPriv) {
|
||||
driUpdateFramebufferSize(&intel->ctx, driReadPriv);
|
||||
}
|
||||
|
||||
_mesa_make_current(&intel->ctx, &intel_fb->Base, readFb);
|
||||
|
||||
|
@@ -80,21 +80,33 @@ intel_flip_renderbuffers(struct intel_framebuffer *intel_fb)
|
||||
{
|
||||
int current_page = intel_fb->pf_current_page;
|
||||
int next_page = (current_page + 1) % intel_fb->pf_num_pages;
|
||||
struct gl_renderbuffer *tmp_rb;
|
||||
|
||||
/* Exchange renderbuffers if necessary but make sure their reference counts
|
||||
* are preserved.
|
||||
*/
|
||||
if (intel_fb->color_rb[current_page] &&
|
||||
intel_fb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer !=
|
||||
&intel_fb->color_rb[current_page]->Base) {
|
||||
_mesa_remove_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT);
|
||||
_mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT,
|
||||
&intel_fb->color_rb[current_page]->Base);
|
||||
tmp_rb = NULL;
|
||||
_mesa_reference_renderbuffer(&tmp_rb,
|
||||
intel_fb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
|
||||
tmp_rb = &intel_fb->color_rb[current_page]->Base;
|
||||
_mesa_reference_renderbuffer(
|
||||
&intel_fb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer, tmp_rb);
|
||||
_mesa_reference_renderbuffer(&tmp_rb, NULL);
|
||||
}
|
||||
|
||||
if (intel_fb->color_rb[next_page] &&
|
||||
intel_fb->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer !=
|
||||
&intel_fb->color_rb[next_page]->Base) {
|
||||
_mesa_remove_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT);
|
||||
_mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT,
|
||||
&intel_fb->color_rb[next_page]->Base);
|
||||
tmp_rb = NULL;
|
||||
_mesa_reference_renderbuffer(&tmp_rb,
|
||||
intel_fb->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer);
|
||||
tmp_rb = &intel_fb->color_rb[next_page]->Base;
|
||||
_mesa_reference_renderbuffer(
|
||||
&intel_fb->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer, tmp_rb);
|
||||
_mesa_reference_renderbuffer(&tmp_rb, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,27 +309,39 @@ static GLboolean
|
||||
intel_alloc_window_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
|
||||
GLenum internalFormat, GLuint width, GLuint height)
|
||||
{
|
||||
struct intel_context *intel = intel_context(ctx);
|
||||
struct intel_framebuffer *intel_fb;
|
||||
|
||||
ASSERT(rb->Name == 0);
|
||||
rb->Width = width;
|
||||
rb->Height = height;
|
||||
rb->_ActualFormat = internalFormat;
|
||||
|
||||
if (intel && intel->driDrawable &&
|
||||
(intel_fb = intel->driDrawable->driverPrivate) &&
|
||||
intel_fb->pf_num_pages == 3 &&
|
||||
rb == &intel_fb->color_rb[intel_fb->pf_current_page]->Base &&
|
||||
(rb = &intel_fb->color_rb[(intel_fb->pf_current_page + 2) % 3]->Base)) {
|
||||
rb->Width = width;
|
||||
rb->Height = height;
|
||||
rb->_ActualFormat = internalFormat;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb,
|
||||
GLuint width, GLuint height)
|
||||
{
|
||||
struct intel_framebuffer *intel_fb = (struct intel_framebuffer*)fb;
|
||||
int i;
|
||||
|
||||
_mesa_resize_framebuffer(ctx, fb, width, height);
|
||||
|
||||
fb->Initialized = GL_TRUE; /* XXX remove someday */
|
||||
|
||||
if (fb->Name != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Make sure all window system renderbuffers are up to date */
|
||||
for (i = 0; i < 3; i++) {
|
||||
struct gl_renderbuffer *rb = &intel_fb->color_rb[i]->Base;
|
||||
|
||||
/* only resize if size is changing */
|
||||
if (rb && (rb->Width != width || rb->Height != height)) {
|
||||
rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
intel_nop_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
|
||||
@@ -496,7 +520,7 @@ intel_framebuffer_renderbuffer(GLcontext * ctx,
|
||||
|
||||
/**
|
||||
* When glFramebufferTexture[123]D is called this function sets up the
|
||||
* gl_renderbuffer wrapp around the texture image.
|
||||
* gl_renderbuffer wrapper around the texture image.
|
||||
* This will have the region info needed for hardware rendering.
|
||||
*/
|
||||
static struct intel_renderbuffer *
|
||||
@@ -582,7 +606,7 @@ intel_render_texture(GLcontext * ctx,
|
||||
irb = intel_wrap_texture(ctx, newImage);
|
||||
if (irb) {
|
||||
/* bind the wrapper to the attachment point */
|
||||
att->Renderbuffer = &irb->Base;
|
||||
_mesa_reference_renderbuffer(&att->Renderbuffer, &irb->Base);
|
||||
}
|
||||
else {
|
||||
/* fallback to software rendering */
|
||||
@@ -659,4 +683,5 @@ intel_fbo_init(struct intel_context *intel)
|
||||
intel->ctx.Driver.FramebufferRenderbuffer = intel_framebuffer_renderbuffer;
|
||||
intel->ctx.Driver.RenderTexture = intel_render_texture;
|
||||
intel->ctx.Driver.FinishRenderTexture = intel_finish_render_texture;
|
||||
intel->ctx.Driver.ResizeBuffers = intel_resize_buffers;
|
||||
}
|
||||
|
@@ -317,7 +317,7 @@ intel_miptree_image_data(struct intel_context *intel,
|
||||
0, 0, /* source x, y */
|
||||
dst->level[level].width, height); /* width, height */
|
||||
|
||||
src += src_image_pitch;
|
||||
src += src_image_pitch * dst->cpp;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -90,6 +90,7 @@ intel_region_alloc(intelScreenPrivate *intelScreen,
|
||||
GLuint cpp, GLuint pitch, GLuint height)
|
||||
{
|
||||
struct intel_region *region = calloc(sizeof(*region), 1);
|
||||
struct intel_context *intel = intelScreenContext(intelScreen);
|
||||
|
||||
DBG("%s\n", __FUNCTION__);
|
||||
|
||||
@@ -107,7 +108,9 @@ intel_region_alloc(intelScreenPrivate *intelScreen,
|
||||
0,
|
||||
#endif
|
||||
0);
|
||||
LOCK_HARDWARE(intel);
|
||||
driBOData(region->buffer, pitch * cpp * height, NULL, 0);
|
||||
UNLOCK_HARDWARE(intel);
|
||||
return region;
|
||||
}
|
||||
|
||||
@@ -392,6 +395,8 @@ void
|
||||
intel_region_release_pbo(intelScreenPrivate *intelScreen,
|
||||
struct intel_region *region)
|
||||
{
|
||||
struct intel_context *intel = intelScreenContext(intelScreen);
|
||||
|
||||
assert(region->buffer == region->pbo->buffer);
|
||||
region->pbo->region = NULL;
|
||||
region->pbo = NULL;
|
||||
@@ -400,8 +405,11 @@ intel_region_release_pbo(intelScreenPrivate *intelScreen,
|
||||
|
||||
driGenBuffers(intelScreen->regionPool,
|
||||
"region", 1, ®ion->buffer, 64, 0, 0);
|
||||
|
||||
LOCK_HARDWARE(intel);
|
||||
driBOData(region->buffer,
|
||||
region->cpp * region->pitch * region->height, NULL, 0);
|
||||
UNLOCK_HARDWARE(intel);
|
||||
}
|
||||
|
||||
/* Break the COW tie to the pbo. Both the pbo and the region end up
|
||||
|
@@ -386,6 +386,45 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen,
|
||||
intelPrintSAREA(sarea);
|
||||
}
|
||||
|
||||
GLboolean
|
||||
intelCreatePools(intelScreenPrivate *intelScreen)
|
||||
{
|
||||
unsigned batchPoolSize = 1024*1024;
|
||||
__DRIscreenPrivate * sPriv = intelScreen->driScrnPriv;
|
||||
|
||||
if (intelScreen->havePools)
|
||||
return GL_TRUE;
|
||||
|
||||
batchPoolSize /= intelScreen->maxBatchSize;
|
||||
intelScreen->regionPool = driDRMPoolInit(sPriv->fd);
|
||||
|
||||
if (!intelScreen->regionPool)
|
||||
return GL_FALSE;
|
||||
|
||||
intelScreen->staticPool = driDRMStaticPoolInit(sPriv->fd);
|
||||
|
||||
if (!intelScreen->staticPool)
|
||||
return GL_FALSE;
|
||||
|
||||
intelScreen->texPool = intelScreen->regionPool;
|
||||
|
||||
intelScreen->batchPool = driBatchPoolInit(sPriv->fd,
|
||||
DRM_BO_FLAG_EXE |
|
||||
DRM_BO_FLAG_MEM_TT |
|
||||
DRM_BO_FLAG_MEM_LOCAL,
|
||||
intelScreen->maxBatchSize,
|
||||
batchPoolSize, 5);
|
||||
if (!intelScreen->batchPool) {
|
||||
fprintf(stderr, "Failed to initialize batch pool - possible incorrect agpgart installed\n");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
intel_recreate_static_regions(intelScreen);
|
||||
intelScreen->havePools = GL_TRUE;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static GLboolean
|
||||
intelInitDriver(__DRIscreenPrivate * sPriv)
|
||||
@@ -393,7 +432,6 @@ intelInitDriver(__DRIscreenPrivate * sPriv)
|
||||
intelScreenPrivate *intelScreen;
|
||||
I830DRIPtr gDRIPriv = (I830DRIPtr) sPriv->pDevPriv;
|
||||
drmI830Sarea *sarea;
|
||||
unsigned batchPoolSize = 1024*1024;
|
||||
|
||||
PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
|
||||
(PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->
|
||||
@@ -426,7 +464,6 @@ intelInitDriver(__DRIscreenPrivate * sPriv)
|
||||
intelScreen->deviceID = gDRIPriv->deviceID;
|
||||
if (intelScreen->deviceID == PCI_CHIP_I865_G)
|
||||
intelScreen->maxBatchSize = 4096;
|
||||
batchPoolSize /= intelScreen->maxBatchSize;
|
||||
|
||||
intelScreen->mem = gDRIPriv->mem;
|
||||
intelScreen->cpp = gDRIPriv->cpp;
|
||||
@@ -517,31 +554,6 @@ intelInitDriver(__DRIscreenPrivate * sPriv)
|
||||
(*glx_enable_extension) (psc, "GLX_SGI_make_current_read");
|
||||
}
|
||||
|
||||
intelScreen->regionPool = driDRMPoolInit(sPriv->fd);
|
||||
|
||||
if (!intelScreen->regionPool)
|
||||
return GL_FALSE;
|
||||
|
||||
intelScreen->staticPool = driDRMStaticPoolInit(sPriv->fd);
|
||||
|
||||
if (!intelScreen->staticPool)
|
||||
return GL_FALSE;
|
||||
|
||||
intelScreen->texPool = intelScreen->regionPool;
|
||||
|
||||
intelScreen->batchPool = driBatchPoolInit(sPriv->fd,
|
||||
DRM_BO_FLAG_EXE |
|
||||
DRM_BO_FLAG_MEM_TT |
|
||||
DRM_BO_FLAG_MEM_LOCAL,
|
||||
intelScreen->maxBatchSize,
|
||||
batchPoolSize, 5);
|
||||
if (!intelScreen->batchPool) {
|
||||
fprintf(stderr, "Failed to initialize batch pool - possible incorrect agpgart installed\n");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
intel_recreate_static_regions(intelScreen);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
@@ -553,9 +565,11 @@ intelDestroyScreen(__DRIscreenPrivate * sPriv)
|
||||
|
||||
intelUnmapScreenRegions(intelScreen);
|
||||
|
||||
driPoolTakeDown(intelScreen->regionPool);
|
||||
driPoolTakeDown(intelScreen->staticPool);
|
||||
driPoolTakeDown(intelScreen->batchPool);
|
||||
if (intelScreen->havePools) {
|
||||
driPoolTakeDown(intelScreen->regionPool);
|
||||
driPoolTakeDown(intelScreen->staticPool);
|
||||
driPoolTakeDown(intelScreen->batchPool);
|
||||
}
|
||||
FREE(intelScreen);
|
||||
sPriv->private = NULL;
|
||||
}
|
||||
@@ -613,6 +627,8 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
|
||||
&intel_fb->color_rb[1]->Base);
|
||||
|
||||
if (screen->third.handle) {
|
||||
struct gl_renderbuffer *tmp_rb = NULL;
|
||||
|
||||
intel_fb->color_rb[2]
|
||||
= intel_create_renderbuffer(rgbFormat,
|
||||
screen->width, screen->height,
|
||||
@@ -621,6 +637,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
|
||||
screen->cpp,
|
||||
screen->third.map);
|
||||
intel_set_span_functions(&intel_fb->color_rb[2]->Base);
|
||||
_mesa_reference_renderbuffer(&tmp_rb, &intel_fb->color_rb[2]->Base);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -889,6 +906,7 @@ __driCreateNewScreen_20050727(__DRInativeDisplay * dpy, int scrn,
|
||||
ddx_version, dri_version, drm_version,
|
||||
frame_buffer, pSAREA, fd,
|
||||
internal_api_version, &intelAPI);
|
||||
|
||||
if (psp != NULL) {
|
||||
I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
|
||||
*driver_modes = intelFillInModes(dri_priv->cpp * 8,
|
||||
|
@@ -95,6 +95,7 @@ typedef struct
|
||||
struct _DriBufferPool *regionPool;
|
||||
struct _DriBufferPool *staticPool;
|
||||
unsigned int maxBatchSize;
|
||||
GLboolean havePools;
|
||||
} intelScreenPrivate;
|
||||
|
||||
|
||||
@@ -130,5 +131,7 @@ extern struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
|
||||
|
||||
extern void
|
||||
intelUpdateScreenRotation(__DRIscreenPrivate * sPriv, drmI830Sarea * sarea);
|
||||
extern GLboolean
|
||||
intelCreatePools(intelScreenPrivate *intelScreen);
|
||||
|
||||
#endif
|
||||
|
@@ -329,25 +329,7 @@ intelTexImage(GLcontext * ctx,
|
||||
texImage->TexFormat = intelChooseTextureFormat(ctx, internalFormat,
|
||||
format, type);
|
||||
|
||||
assert(texImage->TexFormat);
|
||||
|
||||
switch (dims) {
|
||||
case 1:
|
||||
texImage->FetchTexelc = texImage->TexFormat->FetchTexel1D;
|
||||
texImage->FetchTexelf = texImage->TexFormat->FetchTexel1Df;
|
||||
break;
|
||||
case 2:
|
||||
texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D;
|
||||
texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df;
|
||||
break;
|
||||
case 3:
|
||||
texImage->FetchTexelc = texImage->TexFormat->FetchTexel3D;
|
||||
texImage->FetchTexelf = texImage->TexFormat->FetchTexel3Df;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
_mesa_set_fetch_functions(texImage, dims);
|
||||
|
||||
if (texImage->TexFormat->TexelBytes == 0) {
|
||||
/* must be a compressed format */
|
||||
@@ -632,6 +614,7 @@ intel_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
|
||||
intelImage->level,
|
||||
&intelImage->base.RowStride,
|
||||
intelImage->base.ImageOffsets);
|
||||
intelImage->base.RowStride /= intelImage->mt->cpp;
|
||||
}
|
||||
else {
|
||||
/* Otherwise, the image should actually be stored in
|
||||
|
@@ -148,7 +148,7 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
|
||||
|
||||
brw->emit_state_always = 0;
|
||||
|
||||
ctx->_MaintainTexEnvProgram = 1;
|
||||
ctx->FragmentProgram._MaintainTexEnvProgram = 1;
|
||||
|
||||
brw_draw_init( brw );
|
||||
|
||||
|
@@ -35,7 +35,8 @@
|
||||
#include "context.h"
|
||||
#include "macros.h"
|
||||
#include "enums.h"
|
||||
#include "shader/program.h"
|
||||
#include "shader/prog_parameter.h"
|
||||
#include "shader/prog_statevars.h"
|
||||
#include "intel_batchbuffer.h"
|
||||
#include "brw_context.h"
|
||||
#include "brw_defines.h"
|
||||
|
@@ -35,7 +35,7 @@
|
||||
|
||||
#include "brw_structs.h"
|
||||
#include "brw_defines.h"
|
||||
#include "shader/program.h"
|
||||
#include "shader/prog_instruction.h"
|
||||
|
||||
#define BRW_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<2) | ((c)<<4) | ((d)<<6))
|
||||
#define BRW_GET_SWZ(swz, idx) (((swz) >> ((idx)*2)) & 0x3)
|
||||
|
@@ -35,8 +35,6 @@
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "macros.h"
|
||||
#include "enums.h"
|
||||
#include "dd.h"
|
||||
|
||||
#include "shader/arbprogparse.h"
|
||||
|
||||
|
@@ -29,7 +29,7 @@
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "shader/prog_parameter.h"
|
||||
#include "brw_context.h"
|
||||
#include "brw_aub.h"
|
||||
#include "brw_util.h"
|
||||
|
@@ -30,9 +30,9 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "brw_util.h"
|
||||
#include "mtypes.h"
|
||||
#include "shader/program.h"
|
||||
#include "shader/prog_parameter.h"
|
||||
#include "brw_util.h"
|
||||
#include "brw_defines.h"
|
||||
|
||||
GLuint brw_count_bits( GLuint val )
|
||||
@@ -45,7 +45,7 @@ GLuint brw_count_bits( GLuint val )
|
||||
}
|
||||
|
||||
|
||||
static GLuint brw_parameter_state_flags(const enum state_index state[])
|
||||
static GLuint brw_parameter_state_flags(const gl_state_index state[])
|
||||
{
|
||||
switch (state[0]) {
|
||||
case STATE_MATERIAL:
|
||||
@@ -70,22 +70,16 @@ static GLuint brw_parameter_state_flags(const enum state_index state[])
|
||||
case STATE_POINT_ATTENUATION:
|
||||
return _NEW_POINT;
|
||||
|
||||
case STATE_MATRIX:
|
||||
switch (state[1]) {
|
||||
case STATE_MODELVIEW:
|
||||
return _NEW_MODELVIEW;
|
||||
case STATE_PROJECTION:
|
||||
return _NEW_PROJECTION;
|
||||
case STATE_MVP:
|
||||
return _NEW_MODELVIEW | _NEW_PROJECTION;
|
||||
case STATE_TEXTURE:
|
||||
return _NEW_TEXTURE_MATRIX;
|
||||
case STATE_PROGRAM:
|
||||
return _NEW_TRACK_MATRIX;
|
||||
default:
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
case STATE_MODELVIEW_MATRIX:
|
||||
return _NEW_MODELVIEW;
|
||||
case STATE_PROJECTION_MATRIX:
|
||||
return _NEW_PROJECTION;
|
||||
case STATE_MVP_MATRIX:
|
||||
return _NEW_MODELVIEW | _NEW_PROJECTION;
|
||||
case STATE_TEXTURE_MATRIX:
|
||||
return _NEW_TEXTURE_MATRIX;
|
||||
case STATE_PROGRAM_MATRIX:
|
||||
return _NEW_TRACK_MATRIX;
|
||||
|
||||
case STATE_DEPTH_RANGE:
|
||||
return _NEW_VIEWPORT;
|
||||
|
@@ -34,8 +34,7 @@
|
||||
#include "brw_vs.h"
|
||||
#include "brw_util.h"
|
||||
#include "brw_state.h"
|
||||
#include "program.h"
|
||||
#include "shader/arbprogparse.h"
|
||||
#include "shader/prog_print.h"
|
||||
|
||||
|
||||
|
||||
|
@@ -30,10 +30,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "brw_context.h"
|
||||
#include "program.h"
|
||||
#include "program_instruction.h"
|
||||
#include "macros.h"
|
||||
#include "brw_context.h"
|
||||
#include "brw_vs.h"
|
||||
|
||||
/* Component is active if it may diverge from [0,0,0,1]. Undef values
|
||||
|
@@ -30,10 +30,11 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "brw_context.h"
|
||||
#include "program.h"
|
||||
#include "program_instruction.h"
|
||||
#include "macros.h"
|
||||
#include "shader/prog_parameter.h"
|
||||
#include "shader/prog_print.h"
|
||||
#include "brw_context.h"
|
||||
#include "brw_vs.h"
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user