Compare commits
299 Commits
mesa_7_5_r
...
mesa_7_5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd10996d4f | ||
|
|
ee0b1bc7d3 | ||
|
|
a77b455af0 | ||
|
|
71b9e10291 | ||
|
|
7fd3674672 | ||
|
|
27587f46e5 | ||
|
|
8c6e81f97d | ||
|
|
2ba98efdf6 | ||
|
|
cf7e8fbc2e | ||
|
|
5807ccb41b | ||
|
|
d4e6df9ab6 | ||
|
|
0c4350790a | ||
|
|
4e1e18a772 | ||
|
|
3ab3209a1f | ||
|
|
6b7b13b5eb | ||
|
|
d970313b66 | ||
|
|
0474b5cb2a | ||
|
|
c68f659be3 | ||
|
|
fdeb778990 | ||
|
|
59de430de7 | ||
|
|
df5f7a6761 | ||
|
|
6c9d8a6f24 | ||
|
|
9aca6769df | ||
|
|
26e58a42b0 | ||
|
|
b0a17581e2 | ||
|
|
a36b9987cd | ||
|
|
6ec955efaf | ||
|
|
7325c1ebc8 | ||
|
|
4ed1de8b84 | ||
|
|
680f7d09b0 | ||
|
|
022e8e582e | ||
|
|
1c1307e7c5 | ||
|
|
cff2126f52 | ||
|
|
a79586ce18 | ||
|
|
f01af4dbd2 | ||
|
|
762c1d11ff | ||
|
|
baa7ff47d5 | ||
|
|
ca1b71b78d | ||
|
|
6ff1a5385e | ||
|
|
cade071d52 | ||
|
|
fcd3572edf | ||
|
|
78af70be37 | ||
|
|
c86b076668 | ||
|
|
abdb0fdcc0 | ||
|
|
36e906aad6 | ||
|
|
4adc9b4a5b | ||
|
|
7b861b9b9e | ||
|
|
71633abafc | ||
|
|
25b492b976 | ||
|
|
96601ec8e0 | ||
|
|
a4d952358d | ||
|
|
7fb4becf98 | ||
|
|
1068c15c61 | ||
|
|
6f4167c8a2 | ||
|
|
5470a67335 | ||
|
|
fc6e02ce62 | ||
|
|
c30f23c123 | ||
|
|
94e1117c9b | ||
|
|
f580494bef | ||
|
|
b928d18398 | ||
|
|
aa98575ebb | ||
|
|
cffe7c8bd0 | ||
|
|
2a2236606f | ||
|
|
588c862571 | ||
|
|
798cd2a98d | ||
|
|
1668a679c4 | ||
|
|
b3e8e1cd4c | ||
|
|
1fa4cde757 | ||
|
|
70ae7ba818 | ||
|
|
c48c01c9e7 | ||
|
|
1ca836f0de | ||
|
|
d6c2347d79 | ||
|
|
09a3a28fc8 | ||
|
|
7e91d035b9 | ||
|
|
2e570be852 | ||
|
|
1730eaa2a2 | ||
|
|
4147bb24d4 | ||
|
|
6af783bea0 | ||
|
|
a9ae89d104 | ||
|
|
6dfb89e4a0 | ||
|
|
cea259f039 | ||
|
|
79047cc1dd | ||
|
|
f6c8ca06f6 | ||
|
|
4c31632817 | ||
|
|
fa5b0364f9 | ||
|
|
52f895df51 | ||
|
|
14a2b5445a | ||
|
|
6e09c1fd08 | ||
|
|
18a6f0f1a7 | ||
|
|
4ffe2844a4 | ||
|
|
578230dbbf | ||
|
|
a4fd94a54a | ||
|
|
ba7f45ac0c | ||
|
|
f2de2d5f37 | ||
|
|
e2a8ef4430 | ||
|
|
6c913411d3 | ||
|
|
1c04731b87 | ||
|
|
e8c4663c11 | ||
|
|
c72261f2a8 | ||
|
|
57955451f8 | ||
|
|
e5cb11adda | ||
|
|
53f8dccd0c | ||
|
|
00438bb94a | ||
|
|
0846c88ec3 | ||
|
|
aa688d1579 | ||
|
|
8d24160a40 | ||
|
|
47173cf67f | ||
|
|
4e43126a59 | ||
|
|
b1f2f92d9b | ||
|
|
9014f475ff | ||
|
|
b799af91d5 | ||
|
|
9a5ee12434 | ||
|
|
bb8f3090ba | ||
|
|
72ad039d19 | ||
|
|
418987ff05 | ||
|
|
21320b24c5 | ||
|
|
4181a107cb | ||
|
|
2a41df86a3 | ||
|
|
318122b60a | ||
|
|
dd585db687 | ||
|
|
f08bebfe24 | ||
|
|
2d86503471 | ||
|
|
077a06c140 | ||
|
|
62ad606065 | ||
|
|
928e1ce47f | ||
|
|
af7fb892d8 | ||
|
|
f5dc352e5f | ||
|
|
e80ecdf659 | ||
|
|
8e6dd8bf79 | ||
|
|
aa48becb82 | ||
|
|
16787c513b | ||
|
|
ac05996b81 | ||
|
|
0efd25b502 | ||
|
|
2ae297c318 | ||
|
|
ddf64be258 | ||
|
|
f652f15e6d | ||
|
|
dd453fa37c | ||
|
|
2f1c5c58b3 | ||
|
|
65eaafee25 | ||
|
|
e139434d44 | ||
|
|
b04605d544 | ||
|
|
515513b409 | ||
|
|
09313043e7 | ||
|
|
5951ab311d | ||
|
|
e5b53c071b | ||
|
|
3c6480ea42 | ||
|
|
fc0896b50b | ||
|
|
f4b1a69b7d | ||
|
|
454a717d94 | ||
|
|
02edc8da36 | ||
|
|
08025cd4a5 | ||
|
|
2102e301a7 | ||
|
|
541594b044 | ||
|
|
38ddbc5588 | ||
|
|
4dafac2b2f | ||
|
|
aba93643be | ||
|
|
7e0eaca201 | ||
|
|
c1f74a6734 | ||
|
|
f38872473c | ||
|
|
f66733bbee | ||
|
|
c4fd947bee | ||
|
|
c20bb48d3a | ||
|
|
eb1eee03a6 | ||
|
|
4bc74a0756 | ||
|
|
625b0fe268 | ||
|
|
4031ea1520 | ||
|
|
84c5e4805b | ||
|
|
72aed16aee | ||
|
|
25f6c936fe | ||
|
|
3e94521912 | ||
|
|
c9f8c400ab | ||
|
|
c25534f30d | ||
|
|
b79e6a59d8 | ||
|
|
2f184d0d9f | ||
|
|
9d367d43b2 | ||
|
|
0584b6e433 | ||
|
|
19218fe712 | ||
|
|
a5b7e0c7d7 | ||
|
|
54f425b5ce | ||
|
|
810df8317d | ||
|
|
19ca5ee1db | ||
|
|
ad0514b24d | ||
|
|
00e203fe17 | ||
|
|
abfd56c24c | ||
|
|
daacac1c24 | ||
|
|
43bb78f2bb | ||
|
|
9dfce365c7 | ||
|
|
a120778c72 | ||
|
|
3cf92e936a | ||
|
|
0487656245 | ||
|
|
8f382fd3f3 | ||
|
|
21bfd0f4bd | ||
|
|
d609df1dae | ||
|
|
2af0173e9e | ||
|
|
42882897c6 | ||
|
|
4b4855c717 | ||
|
|
1b05b5b4fe | ||
|
|
0491142152 | ||
|
|
39366ed995 | ||
|
|
d446d3acac | ||
|
|
56235ae504 | ||
|
|
e15aebe10e | ||
|
|
a70c45bdab | ||
|
|
ff3da0966f | ||
|
|
1b8e4dd2c8 | ||
|
|
cee73ffdaf | ||
|
|
7805c3b57b | ||
|
|
97974b7e51 | ||
|
|
957f3c8c3d | ||
|
|
66bfd025c8 | ||
|
|
fbd554d074 | ||
|
|
6e0df938d4 | ||
|
|
988b61be27 | ||
|
|
320a303be0 | ||
|
|
d9e35d51fd | ||
|
|
61a2c9668f | ||
|
|
2770107d87 | ||
|
|
3f856c6b6b | ||
|
|
d18c57aaea | ||
|
|
3705f48688 | ||
|
|
c6f71eabd8 | ||
|
|
1bee650ef3 | ||
|
|
6e24fdeae5 | ||
|
|
557421b6de | ||
|
|
25f0c33bb3 | ||
|
|
c53705ed7b | ||
|
|
ebe0796ba2 | ||
|
|
d22828f716 | ||
|
|
992000cce7 | ||
|
|
6b917d0b17 | ||
|
|
742ba08406 | ||
|
|
3e48dd0445 | ||
|
|
ed7f4b4230 | ||
|
|
3463b1479d | ||
|
|
077c5e62d8 | ||
|
|
06075711af | ||
|
|
566bdbe67d | ||
|
|
d027e8feff | ||
|
|
227d233cff | ||
|
|
7585cbffe0 | ||
|
|
c6af9b2947 | ||
|
|
053d8eb891 | ||
|
|
6214c7262f | ||
|
|
37f2117cd1 | ||
|
|
c33ef1f7c6 | ||
|
|
940cb7ce16 | ||
|
|
5d0cf9ebb4 | ||
|
|
0e1abced56 | ||
|
|
db22b35d21 | ||
|
|
cbe5af766e | ||
|
|
fb64365642 | ||
|
|
476685c63c | ||
|
|
c6de08fff4 | ||
|
|
3754c4135c | ||
|
|
322e8556b9 | ||
|
|
0ddc38309a | ||
|
|
e1700009b7 | ||
|
|
d5ba39ad08 | ||
|
|
de413b1ba9 | ||
|
|
3f2e006b75 | ||
|
|
7cafd49c93 | ||
|
|
862c7b8cd3 | ||
|
|
bb0b954f12 | ||
|
|
9d5479eeeb | ||
|
|
cc09724a50 | ||
|
|
41cf681535 | ||
|
|
e3f14f2f3b | ||
|
|
48d816b8ff | ||
|
|
96aca15c9d | ||
|
|
337f559cd2 | ||
|
|
8fa8669aeb | ||
|
|
0a4fcabe44 | ||
|
|
dbab657fe7 | ||
|
|
9225b67383 | ||
|
|
88527220e4 | ||
|
|
506989b20e | ||
|
|
6f50c9865d | ||
|
|
5450281ff7 | ||
|
|
4d16eb5e18 | ||
|
|
978bca8b2a | ||
|
|
52411a1951 | ||
|
|
8bfbb7ec8b | ||
|
|
76a1017e97 | ||
|
|
9192347443 | ||
|
|
cb549775a5 | ||
|
|
34bb024cf2 | ||
|
|
7eed6ab5b5 | ||
|
|
304ba4bba4 | ||
|
|
77c329a277 | ||
|
|
b6753adbc7 | ||
|
|
e09f78d8dc | ||
|
|
42678dba94 | ||
|
|
33d6327770 | ||
|
|
0bced6a326 | ||
|
|
0d3c8fbf12 | ||
|
|
fce4ee12a6 | ||
|
|
4d9d0e6230 | ||
|
|
283e84bfb3 | ||
|
|
78dad27564 |
2
Makefile
2
Makefile
@@ -182,7 +182,7 @@ ultrix-gcc:
|
|||||||
|
|
||||||
# Rules for making release tarballs
|
# Rules for making release tarballs
|
||||||
|
|
||||||
VERSION=7.5-rc3
|
VERSION=7.5
|
||||||
DIRECTORY = Mesa-$(VERSION)
|
DIRECTORY = Mesa-$(VERSION)
|
||||||
LIB_NAME = MesaLib-$(VERSION)
|
LIB_NAME = MesaLib-$(VERSION)
|
||||||
DEMO_NAME = MesaDemos-$(VERSION)
|
DEMO_NAME = MesaDemos-$(VERSION)
|
||||||
|
|||||||
19
bin/mklib
19
bin/mklib
@@ -885,6 +885,17 @@ case $ARCH in
|
|||||||
|
|
||||||
CYGWIN*)
|
CYGWIN*)
|
||||||
# GCC-based environment
|
# GCC-based environment
|
||||||
|
if [ $NOPREFIX = 1 ] ; then
|
||||||
|
# No "lib" or ".so" part
|
||||||
|
echo "mklib: Making CYGWIN shared library: " ${LIBNAME}
|
||||||
|
OPTS="-shared -Wl,--enable-auto-image-base"
|
||||||
|
if [ "${ALTOPTS}" ] ; then
|
||||||
|
OPTS=${ALTOPTS}
|
||||||
|
fi
|
||||||
|
rm -f ${LIBNAME}
|
||||||
|
${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
|
||||||
|
FINAL_LIBS=${LIBNAME}
|
||||||
|
else
|
||||||
CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
|
CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
|
||||||
LIBNAME="lib${LIBNAME}" # prefix with "lib"
|
LIBNAME="lib${LIBNAME}" # prefix with "lib"
|
||||||
|
|
||||||
@@ -901,11 +912,11 @@ case $ARCH in
|
|||||||
# finish up
|
# finish up
|
||||||
FINAL_LIBS=${LIBNAME}.a
|
FINAL_LIBS=${LIBNAME}.a
|
||||||
else
|
else
|
||||||
OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
|
OPTS="-shared -Wl,--enable-auto-image-base -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
|
||||||
if [ "${ALTOPTS}" ] ; then
|
if [ "${ALTOPTS}" ] ; then
|
||||||
OPTS=${ALTOPTS}
|
OPTS=${ALTOPTS}
|
||||||
fi
|
fi
|
||||||
echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll
|
echo "mklib: Making" $ARCH "shared library: " ${CYGNAME}-${MAJOR}.dll
|
||||||
|
|
||||||
if [ $CPLUSPLUS = 1 ] ; then
|
if [ $CPLUSPLUS = 1 ] ; then
|
||||||
LINK="g++"
|
LINK="g++"
|
||||||
@@ -914,7 +925,8 @@ case $ARCH in
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# rm any old libs
|
# rm any old libs
|
||||||
rm -f ${LIBNAME}-${MAJOR}.dll
|
rm -f ${CYGNAME}-${MAJOR}.dll
|
||||||
|
rm -f ${LIBNAME}-${MAJOR}.dll.a
|
||||||
rm -f ${LIBNAME}.dll.a
|
rm -f ${LIBNAME}.dll.a
|
||||||
rm -f ${LIBNAME}.a
|
rm -f ${LIBNAME}.a
|
||||||
|
|
||||||
@@ -927,6 +939,7 @@ case $ARCH in
|
|||||||
# special case for installing in bin
|
# special case for installing in bin
|
||||||
FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
|
FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
'example')
|
'example')
|
||||||
|
|||||||
@@ -222,6 +222,8 @@ else
|
|||||||
case "$host_os" in
|
case "$host_os" in
|
||||||
darwin* )
|
darwin* )
|
||||||
LIB_EXTENSION='dylib' ;;
|
LIB_EXTENSION='dylib' ;;
|
||||||
|
cygwin* )
|
||||||
|
LIB_EXTENSION='dll' ;;
|
||||||
* )
|
* )
|
||||||
LIB_EXTENSION='so' ;;
|
LIB_EXTENSION='so' ;;
|
||||||
esac
|
esac
|
||||||
@@ -640,7 +642,7 @@ dnl Which drivers to build - default is chosen by platform
|
|||||||
AC_ARG_WITH([dri-drivers],
|
AC_ARG_WITH([dri-drivers],
|
||||||
[AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
|
[AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
|
||||||
[comma delimited DRI drivers list, e.g.
|
[comma delimited DRI drivers list, e.g.
|
||||||
"swrast,i965,radeon,nouveau" @<:@default=auto@:>@])],
|
"swrast,i965,radeon" @<:@default=auto@:>@])],
|
||||||
[with_dri_drivers="$withval"],
|
[with_dri_drivers="$withval"],
|
||||||
[with_dri_drivers=yes])
|
[with_dri_drivers=yes])
|
||||||
if test "x$with_dri_drivers" = x; then
|
if test "x$with_dri_drivers" = x; then
|
||||||
@@ -1073,6 +1075,9 @@ if test "x$APP_LIB_DEPS" = x; then
|
|||||||
solaris*)
|
solaris*)
|
||||||
APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
|
APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
|
||||||
;;
|
;;
|
||||||
|
cygwin*)
|
||||||
|
APP_LIB_DEPS="-lX11"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
APP_LIB_DEPS="-lm"
|
APP_LIB_DEPS="-lm"
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
The Mesa
|
The Mesa
|
||||||
<a href="http://en.wikipedia.org/wiki/Cell_%28microprocessor%29" target="_parent">Cell</a>
|
<a href="http://en.wikipedia.org/wiki/Cell_%28microprocessor%29" target="_parent">Cell</a>
|
||||||
driver is part of the
|
driver is part of the
|
||||||
<a href="http://www.tungstengraphics.com/wiki/index.php/Gallium3D" target="_parent">Gallium3D</a>
|
<a href="http://wiki.freedesktop.org/wiki/Software/gallium" target="_parent">Gallium3D</a>
|
||||||
architecture.
|
architecture.
|
||||||
Tungsten Graphics did the original implementation of the Cell driver.
|
Tungsten Graphics did the original implementation of the Cell driver.
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -123,48 +123,46 @@ These are the instructions for making a new Mesa release.
|
|||||||
|
|
||||||
<H3>Get latest source files</H3>
|
<H3>Get latest source files</H3>
|
||||||
<p>
|
<p>
|
||||||
Use "cvs update -dAP " to get the latest Mesa files from CVS.
|
Use git to get the latest Mesa files from the git repository, from whatever
|
||||||
|
branch is relevant.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3>Verify and update version info</H3>
|
<H3>Verify and update version info</H3>
|
||||||
<p>
|
<p>
|
||||||
Create/edit the docs/RELNOTES-X.Y file to document what's new in the release.
|
Create/edit the docs/relnotes-x.y.html file to document what's new in the release.
|
||||||
Add the new RELNOTES-X.Y file to <a href="relnotes.html">relnotes.html</a>.
|
Add the new relnotes-x.y.html file to <a href="relnotes.html">relnotes.html</a>.
|
||||||
Update the docs/VERSIONS file too.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Edit the MESA_MAJOR, MESA_MINOR and MESA_TINY version numbers in
|
Update the MESA_MAJOR, MESA_MINOR and MESA_TINY version numbers in
|
||||||
configs/default.
|
configs/default.
|
||||||
|
Also update the VERSION line in the top-level Makefile.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Make sure the values in src/mesa/main/version.h are correct.
|
Make sure the values in src/mesa/main/version.h are correct.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
|
||||||
Edit the top-level Makefile and verify that DIRECTORY, LIB_NAME and
|
|
||||||
DEMO_NAME are correct.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Update the docs/news.html file and docs/download.html files.
|
Update the docs/news.html file and docs/download.html files.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Check in all updates to CVS.
|
Check in all updates to git.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Tag the CVS files with the release name (in the form <b>mesa_X_Y</b>).
|
Tag the files with the release name (in the form <b>mesa_X_Y</b>)
|
||||||
|
with: <code>git tag -a mesa_X_Y</code>
|
||||||
|
Then: <code>git push origin mesa_X_Y</code>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<H3>Make the tarballs</H3>
|
<H3>Make the tarballs</H3>
|
||||||
<p>
|
<p>
|
||||||
Make a symbolic link from $(DIRECTORY) to 'Mesa'. For example,
|
Make a symbolic link from $(DIRECTORY) to 'Mesa'. For example,
|
||||||
ln -s Mesa Mesa-6.3
|
<code>ln -s Mesa Mesa-7.5</code>
|
||||||
This is needed in order to make a correct tar file in the next step.
|
This is needed in order to make a correct tar file in the next step.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@@ -177,7 +175,7 @@ Make the distribution files. From inside the Mesa directory:
|
|||||||
<p>
|
<p>
|
||||||
After the tarballs are created, the md5 checksums for the files will
|
After the tarballs are created, the md5 checksums for the files will
|
||||||
be computed.
|
be computed.
|
||||||
Add them to the docs/news.html file.
|
Add them to the docs/relnotes-X.Y.html file.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@@ -191,9 +189,21 @@ Follow the directions on SourceForge for creating a new "release" and
|
|||||||
uploading the tarballs.
|
uploading the tarballs.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Basically, to upload the tarball files with:
|
||||||
|
<br>
|
||||||
|
<code>
|
||||||
|
rsync -avP ssh Mesa*-X.Y.* USERNAME@frs.sourceforge.net:uploads/
|
||||||
|
</code>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Update the web site by copying the docs/ directory's files to
|
Update the web site by copying the docs/ directory's files to
|
||||||
/home/users/b/br/brianp/mesa-www/htdocs/
|
/home/users/b/br/brianp/mesa-www/htdocs/ with:
|
||||||
|
<br>
|
||||||
|
<code>
|
||||||
|
sftp USERNAME,mesa3d@web.sourceforge.net
|
||||||
|
</code>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
<li><a href="#pkg-config">Building OpenGL programs with pkg-config
|
<li><a href="#pkg-config">Building OpenGL programs with pkg-config
|
||||||
</ul>
|
</ul>
|
||||||
<li><a href="#windows">Windows</a>
|
<li><a href="#windows">Windows</a>
|
||||||
|
<li><a href="#scons">SCons</a>
|
||||||
<li><a href="#other">Other</a>
|
<li><a href="#other">Other</a>
|
||||||
</ol>
|
</ol>
|
||||||
<br>
|
<br>
|
||||||
@@ -328,13 +329,60 @@ For example, compiling and linking a GLUT application can be done with:
|
|||||||
<H2>2. Windows Compilation and Installation</H1>
|
<H2>2. Windows Compilation and Installation</H1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Please see the <a href="README.WIN32">README.WIN32</a> file.
|
Please see the <a href="#scons">instructions on building with SCons</a>.
|
||||||
|
Alternatively see <a href="README.WIN32">README.WIN32</a> file.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="scons">
|
||||||
|
<H2>3. Building with SCons</H1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
To build Mesa with SCons on Linux or Windows do
|
||||||
|
</p>
|
||||||
|
<pre>
|
||||||
|
scons
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
The build output will be placed in
|
||||||
|
build/<i>platform</i>-<i>machine</i>-<i>debug</i>/..., where <i>platform</i> is for
|
||||||
|
example linux or windows, <i>machine</i> is x86 or x86_64, optionally followed
|
||||||
|
by -debug for debug builds.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The sample programs are built seperately. To build them do
|
||||||
|
<pre>
|
||||||
|
scons -C progs
|
||||||
|
</pre>
|
||||||
|
And the build output will be placed in progs/build/...
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
To build Mesa with SCons for Windows on Linux using the MinGW crosscompiler toolchain do
|
||||||
|
</p>
|
||||||
|
<pre>
|
||||||
|
scons platform=windows toolchain=crossmingw machine=x86 statetrackers=mesa drivers=softpipe,trace winsys=gdi
|
||||||
|
scons -C progs platform=windows toolchain=crossmingw machine=x86 -k
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
This will create:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>build/windows-x86-debug/gallium/winsys/gdi/opengl32.dll — Mesa + Gallium + softpipe, binary compatible with Windows's opengl32.dll
|
||||||
|
<li>build/windows-x86-debug/glut/glx/glut32.dll
|
||||||
|
<li>progs/build/windows-x86-debug/wgl/wglinfo.exe
|
||||||
|
<li>progs/build/windows-x86-debug/trivial/tri.exe
|
||||||
|
<li>and many other samples in progs/build/windows-x86-debug/...
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
Put them all in the same directory to test them.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<a name="other">
|
<a name="other">
|
||||||
<H2>3. Other systems</H1>
|
<H2>4. Other systems</H1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Documentation for other environments (some may be very out of date):
|
Documentation for other environments (some may be very out of date):
|
||||||
|
|||||||
@@ -11,6 +11,29 @@
|
|||||||
<H1>News</H1>
|
<H1>News</H1>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>July 17, 2009</h2>
|
||||||
|
<p>
|
||||||
|
<a href="relnotes-7.5.html">Mesa 7.5</a> is released.
|
||||||
|
This is a new features release. People especially concerned about
|
||||||
|
stability may want to wait for the follow-on 7.5.1 bug-fix release.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>June 23, 2009</h2>
|
||||||
|
<p>
|
||||||
|
<a href="relnotes-7.4.4.html">Mesa 7.4.4</a> is released.
|
||||||
|
This is a stable release that fixes a regression in the i915/i965 drivers
|
||||||
|
that slipped into the 7.4.3 release.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>June 19, 2009</h2>
|
||||||
|
<p>
|
||||||
|
<a href="relnotes-7.4.3.html">Mesa 7.4.3</a> is released.
|
||||||
|
This is a stable release fixing bugs since the 7.4.2 release.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<h2>May 15, 2009</h2>
|
<h2>May 15, 2009</h2>
|
||||||
<p>
|
<p>
|
||||||
<a href="relnotes-7.4.2.html">Mesa 7.4.2</a> is released.
|
<a href="relnotes-7.4.2.html">Mesa 7.4.2</a> is released.
|
||||||
@@ -84,7 +107,7 @@ Added a new page describing the <a href="cell.html">Mesa Cell driver</a>.
|
|||||||
<p>
|
<p>
|
||||||
Gallium3D is the codename for the new Mesa device driver architecture
|
Gallium3D is the codename for the new Mesa device driver architecture
|
||||||
which is currently under development.
|
which is currently under development.
|
||||||
A <a href="http://www.tungstengraphics.com/wiki/index.php/Gallium3D"
|
A <a href="http://wiki.freedesktop.org/wiki/Software/gallium"
|
||||||
target="_parent"> summary</a> of the architecture can be found on the
|
target="_parent"> summary</a> of the architecture can be found on the
|
||||||
Tungsten Graphics website.
|
Tungsten Graphics website.
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
79
docs/relnotes-7.4.3.html
Normal file
79
docs/relnotes-7.4.3.html
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<HTML>
|
||||||
|
|
||||||
|
<TITLE>Mesa Release Notes</TITLE>
|
||||||
|
|
||||||
|
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
|
||||||
|
|
||||||
|
<BODY>
|
||||||
|
|
||||||
|
<body bgcolor="#eeeeee">
|
||||||
|
|
||||||
|
<H1>Mesa 7.4.3 Release Notes / 19 June 2009</H1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Mesa 7.4.3 is a stable development release fixing bugs since the 7.4.2 release.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Mesa 7.4.3 implements the OpenGL 2.1 API, but the version reported by
|
||||||
|
glGetString(GL_VERSION) depends on the particular driver being used.
|
||||||
|
Some drivers don't support all the features required in OpenGL 2.1.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
See the <a href="install.html">Compiling/Installing page</a> for prerequisites
|
||||||
|
for DRI hardware acceleration.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>MD5 checksums</h2>
|
||||||
|
<pre>
|
||||||
|
34c5a6c47ed51f31c4fa36e269831352 MesaLib-7.4.3.tar.gz
|
||||||
|
70a983ba3deaa8bd63b18bbab283f698 MesaLib-7.4.3.tar.bz2
|
||||||
|
34f21b3205b271d575030aa98a2dda51 MesaLib-7.4.3.zip
|
||||||
|
56752b7adede212e6097afb10d0c0d59 MesaDemos-7.4.3.tar.gz
|
||||||
|
8ffa51c4833b1e298300a005e2d7ca2a MesaDemos-7.4.3.tar.bz2
|
||||||
|
0037d24d41400d6fb9800ae55b8c863f MesaDemos-7.4.3.zip
|
||||||
|
20e24f6692c0c90e7e3b220f79c4108d MesaGLUT-7.4.3.tar.gz
|
||||||
|
03a4beeef74fc5ef0b1d6d04710e5a8a MesaGLUT-7.4.3.tar.bz2
|
||||||
|
273788230adbdb9d57371309adedcf5f MesaGLUT-7.4.3.zip
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Bug fixes</h2>
|
||||||
|
<ul>
|
||||||
|
<li>Fixed texture object reference counting bug (bug 21756)
|
||||||
|
<li>Allow depth/stencil textures to be attached to GL_STENCIL_ATTACHMENT point
|
||||||
|
(SF bug 2793846)
|
||||||
|
<li>Added missing glGet case for GL_VERTEX_ARRAY_BINDING_APPLE
|
||||||
|
<li>Fixed some OSMesa build issues
|
||||||
|
<li>Fixed a vertex buffer object crash
|
||||||
|
<li>Fixed broken glTexImage3D() when image type = GL_BITMAP
|
||||||
|
<li>Fixed some GLSL preprocessor bugs
|
||||||
|
<li>Fixed framebuffer mem leak in i945/i965 DRI drivers
|
||||||
|
<li>Fixed texture coordinate repeat bug in swrast (bug 21872)
|
||||||
|
<li>Fixed incorrect viewport clamping (lower bound is zero, not one)
|
||||||
|
<li>GLX fix for glean's makeCurrent test case
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Driver Status</h2>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
Driver Status
|
||||||
|
---------------------- ----------------------
|
||||||
|
DRI drivers varies with the driver
|
||||||
|
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 unsupported
|
||||||
|
Wind River UGL unsupported
|
||||||
|
DJGPP unsupported
|
||||||
|
GGI unsupported
|
||||||
|
BeOS unsupported
|
||||||
|
Allegro unsupported
|
||||||
|
D3D unsupported
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
68
docs/relnotes-7.4.4.html
Normal file
68
docs/relnotes-7.4.4.html
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<HTML>
|
||||||
|
|
||||||
|
<TITLE>Mesa Release Notes</TITLE>
|
||||||
|
|
||||||
|
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
|
||||||
|
|
||||||
|
<BODY>
|
||||||
|
|
||||||
|
<body bgcolor="#eeeeee">
|
||||||
|
|
||||||
|
<H1>Mesa 7.4.4 Release Notes / 23 June 2009</H1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Mesa 7.4.4 is a stable development release fixing bugs since the 7.4.3 release.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Mesa 7.4.4 implements the OpenGL 2.1 API, but the version reported by
|
||||||
|
glGetString(GL_VERSION) depends on the particular driver being used.
|
||||||
|
Some drivers don't support all the features required in OpenGL 2.1.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
See the <a href="install.html">Compiling/Installing page</a> for prerequisites
|
||||||
|
for DRI hardware acceleration.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>MD5 checksums</h2>
|
||||||
|
<pre>
|
||||||
|
0b56fe5a88ab0c3c5b2da5068f63f416 MesaLib-7.4.4.tar.gz
|
||||||
|
b66528d314c574dccbe0ed963cac5e93 MesaLib-7.4.4.tar.bz2
|
||||||
|
2818076f3ba23fa87fdfe4602a637a18 MesaLib-7.4.4.zip
|
||||||
|
3e77b208386c47b18165bce5ae317e2c MesaDemos-7.4.4.tar.gz
|
||||||
|
628142ec9a54cd28cc027e6ce26cff47 MesaDemos-7.4.4.tar.bz2
|
||||||
|
d08a30d30ab7174859aa709cba6c726d MesaDemos-7.4.4.zip
|
||||||
|
e6e91ba16e274d40cf3a97ad3218af01 MesaGLUT-7.4.4.tar.gz
|
||||||
|
e14bbb52517e8121b31f1387515365ab MesaGLUT-7.4.4.tar.bz2
|
||||||
|
f10ed20469753c2b3d68c99854f80fd4 MesaGLUT-7.4.4.zip
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Bug fixes</h2>
|
||||||
|
<ul>
|
||||||
|
<li>Fixed i965/i915 segfault in screen destruction (bug 22408)
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Driver Status</h2>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
Driver Status
|
||||||
|
---------------------- ----------------------
|
||||||
|
DRI drivers varies with the driver
|
||||||
|
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 unsupported
|
||||||
|
Wind River UGL unsupported
|
||||||
|
DJGPP unsupported
|
||||||
|
GGI unsupported
|
||||||
|
BeOS unsupported
|
||||||
|
Allegro unsupported
|
||||||
|
D3D unsupported
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<body bgcolor="#eeeeee">
|
<body bgcolor="#eeeeee">
|
||||||
|
|
||||||
<H1>Mesa 7.5 Release Notes / date TBD</H1>
|
<H1>Mesa 7.5 Release Notes / 17 July 2009</H1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Mesa 7.5 is a new development release.
|
Mesa 7.5 is a new development release.
|
||||||
@@ -17,7 +17,7 @@ with the 7.4.x branch or wait for Mesa 7.5.1.
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
The main new feature of Mesa 7.5 is the
|
The main new feature of Mesa 7.5 is the
|
||||||
<a href="http://www.tungstengraphics.com/wiki/index.php/Gallium3D"
|
<a href="http://wiki.freedesktop.org/wiki/Software/gallium"
|
||||||
target="_parent">Gallium3D</a> infrastructure.
|
target="_parent">Gallium3D</a> infrastructure.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
@@ -68,12 +68,18 @@ including GL_ATI_separate_stencil, GL_EXT_stencil_two_side and OpenGL 2.0
|
|||||||
<li>GL_EXT_texture_swizzle extension (software drivers, i965 driver)
|
<li>GL_EXT_texture_swizzle extension (software drivers, i965 driver)
|
||||||
<li>Updated SPARC assembly optimizations (David S. Miller)
|
<li>Updated SPARC assembly optimizations (David S. Miller)
|
||||||
<li>Initial support for separate compilation units in GLSL compiler.
|
<li>Initial support for separate compilation units in GLSL compiler.
|
||||||
|
<li>Increased max number of generic GLSL varying variables to 16 (formerly 8).
|
||||||
|
<li>GLSL linker now detects when too many varying variables are used.
|
||||||
|
<li>Optimize-out redundant glMaterial and glShadeModel calls in display lists
|
||||||
|
<li>Fixed gl_TextureMatrix[i][j] array indexing bug in GLSL compiler.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
<h2>Bug fixes</h2>
|
<h2>Bug fixes</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Lots of i965 driver bug fixes
|
<li>Lots of i965 driver bug fixes
|
||||||
|
<li>Fixed some GLSL preprocessor bugs
|
||||||
|
<li>GLSL: continue inside of a for-loop didn't work
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,19 +8,14 @@
|
|||||||
|
|
||||||
<H1>Release Notes</H1>
|
<H1>Release Notes</H1>
|
||||||
|
|
||||||
<p>
|
|
||||||
Mesa uses an even/odd version number scheme like the Linux kernel.
|
|
||||||
Odd numbered versions (such as 6.5) designate new developmental releases.
|
|
||||||
Even numbered versions (such as 6.4) designate stable releases.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The release notes summarize what's new or changed in each Mesa release.
|
The release notes summarize what's new or changed in each Mesa release.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<UL>
|
<UL>
|
||||||
<LI><A HREF="relnotes-7.5.html">7.5 release notes</A>
|
<LI><A HREF="relnotes-7.5.html">7.5 release notes</A>
|
||||||
|
<LI><A HREF="relnotes-7.4.4.html">7.4.4 release notes</A>
|
||||||
|
<LI><A HREF="relnotes-7.4.3.html">7.4.3 release notes</A>
|
||||||
<LI><A HREF="relnotes-7.4.2.html">7.4.2 release notes</A>
|
<LI><A HREF="relnotes-7.4.2.html">7.4.2 release notes</A>
|
||||||
<LI><A HREF="relnotes-7.4.1.html">7.4.1 release notes</A>
|
<LI><A HREF="relnotes-7.4.1.html">7.4.1 release notes</A>
|
||||||
<LI><A HREF="relnotes-7.4.html">7.4 release notes</A>
|
<LI><A HREF="relnotes-7.4.html">7.4 release notes</A>
|
||||||
|
|||||||
@@ -2702,7 +2702,7 @@ typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target);
|
|||||||
typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint* framebuffers);
|
typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint* framebuffers);
|
||||||
typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint* renderbuffers);
|
typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint* renderbuffers);
|
||||||
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
|
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
|
||||||
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURLAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer);
|
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer);
|
||||||
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
||||||
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
||||||
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer);
|
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer);
|
||||||
@@ -2723,7 +2723,7 @@ typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum targ
|
|||||||
#define glDeleteFramebuffers GLEW_GET_FUN(__glewDeleteFramebuffers)
|
#define glDeleteFramebuffers GLEW_GET_FUN(__glewDeleteFramebuffers)
|
||||||
#define glDeleteRenderbuffers GLEW_GET_FUN(__glewDeleteRenderbuffers)
|
#define glDeleteRenderbuffers GLEW_GET_FUN(__glewDeleteRenderbuffers)
|
||||||
#define glFramebufferRenderbuffer GLEW_GET_FUN(__glewFramebufferRenderbuffer)
|
#define glFramebufferRenderbuffer GLEW_GET_FUN(__glewFramebufferRenderbuffer)
|
||||||
#define glFramebufferTexturLayer GLEW_GET_FUN(__glewFramebufferTexturLayer)
|
#define glFramebufferTextureLayer GLEW_GET_FUN(__glewFramebufferTextureLayer)
|
||||||
#define glFramebufferTexture1D GLEW_GET_FUN(__glewFramebufferTexture1D)
|
#define glFramebufferTexture1D GLEW_GET_FUN(__glewFramebufferTexture1D)
|
||||||
#define glFramebufferTexture2D GLEW_GET_FUN(__glewFramebufferTexture2D)
|
#define glFramebufferTexture2D GLEW_GET_FUN(__glewFramebufferTexture2D)
|
||||||
#define glFramebufferTexture3D GLEW_GET_FUN(__glewFramebufferTexture3D)
|
#define glFramebufferTexture3D GLEW_GET_FUN(__glewFramebufferTexture3D)
|
||||||
@@ -10563,7 +10563,7 @@ GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus;
|
|||||||
GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers;
|
GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers;
|
||||||
GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers;
|
GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers;
|
||||||
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer;
|
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer;
|
||||||
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURLAYERPROC __glewFramebufferTexturLayer;
|
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer;
|
||||||
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D;
|
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D;
|
||||||
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D;
|
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D;
|
||||||
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D;
|
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
SConscript([
|
SConscript([
|
||||||
'util/SConscript',
|
'util/SConscript',
|
||||||
'demos/SConscript',
|
'demos/SConscript',
|
||||||
|
'glsl/SConscript',
|
||||||
'redbook/SConscript',
|
'redbook/SConscript',
|
||||||
'samples/SConscript',
|
'samples/SConscript',
|
||||||
'tests/SConscript',
|
'tests/SConscript',
|
||||||
|
|||||||
@@ -145,6 +145,13 @@ engine.o: engine.c trackball.h
|
|||||||
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) engine.c
|
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) engine.c
|
||||||
|
|
||||||
|
|
||||||
|
fbotexture: fbotexture.o
|
||||||
|
$(APP_CC) $(CFLAGS) $(LDFLAGS) fbotexture.o $(LIBS) -o $@
|
||||||
|
|
||||||
|
fbotexture.o: fbotexture.c extfuncs.h
|
||||||
|
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) fbotexture.c
|
||||||
|
|
||||||
|
|
||||||
fslight: fslight.o
|
fslight: fslight.o
|
||||||
$(APP_CC) $(CFLAGS) $(LDFLAGS) fslight.o $(LIBS) -o $@
|
$(APP_CC) $(CFLAGS) $(LDFLAGS) fslight.o $(LIBS) -o $@
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <GL/glew.h>
|
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include "extfuncs.h"
|
||||||
|
|
||||||
/* For debug */
|
/* For debug */
|
||||||
#define DEPTH 1
|
#define DEPTH 1
|
||||||
@@ -80,9 +80,9 @@ RenderTexture(void)
|
|||||||
glTranslatef(0.0, 0.0, -15.0);
|
glTranslatef(0.0, 0.0, -15.0);
|
||||||
|
|
||||||
/* draw to texture image */
|
/* draw to texture image */
|
||||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
|
glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, MyFB);
|
||||||
|
|
||||||
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
|
||||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
|
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
|
||||||
printf("Framebuffer incomplete!!!\n");
|
printf("Framebuffer incomplete!!!\n");
|
||||||
}
|
}
|
||||||
@@ -171,7 +171,7 @@ RenderTexture(void)
|
|||||||
|
|
||||||
#if DRAW
|
#if DRAW
|
||||||
/* Bind normal framebuffer */
|
/* Bind normal framebuffer */
|
||||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CheckError(__LINE__);
|
CheckError(__LINE__);
|
||||||
@@ -252,12 +252,12 @@ static void
|
|||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
#if DEPTH
|
#if DEPTH
|
||||||
glDeleteRenderbuffersEXT(1, &DepthRB);
|
glDeleteRenderbuffers_func(1, &DepthRB);
|
||||||
#endif
|
#endif
|
||||||
#if STENCIL
|
#if STENCIL
|
||||||
glDeleteRenderbuffersEXT(1, &StencilRB);
|
glDeleteRenderbuffers_func(1, &StencilRB);
|
||||||
#endif
|
#endif
|
||||||
glDeleteFramebuffersEXT(1, &MyFB);
|
glDeleteFramebuffers_func(1, &MyFB);
|
||||||
|
|
||||||
glDeleteTextures(1, &TexObj);
|
glDeleteTextures(1, &TexObj);
|
||||||
|
|
||||||
@@ -318,14 +318,14 @@ AttachDepthAndStencilBuffers(GLuint fbo,
|
|||||||
|
|
||||||
*depthRbOut = *stencilRbOut = 0;
|
*depthRbOut = *stencilRbOut = 0;
|
||||||
|
|
||||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
|
glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, fbo);
|
||||||
|
|
||||||
if (tryDepthStencil) {
|
if (tryDepthStencil) {
|
||||||
GLuint rb;
|
GLuint rb;
|
||||||
|
|
||||||
glGenRenderbuffersEXT(1, &rb);
|
glGenRenderbuffers_func(1, &rb);
|
||||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
|
glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, rb);
|
||||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
|
glRenderbufferStorage_func(GL_RENDERBUFFER_EXT,
|
||||||
GL_DEPTH24_STENCIL8_EXT,
|
GL_DEPTH24_STENCIL8_EXT,
|
||||||
width, height);
|
width, height);
|
||||||
if (glGetError())
|
if (glGetError())
|
||||||
@@ -333,7 +333,7 @@ AttachDepthAndStencilBuffers(GLuint fbo,
|
|||||||
|
|
||||||
if (bindDepthStencil) {
|
if (bindDepthStencil) {
|
||||||
/* attach to both depth and stencil at once */
|
/* attach to both depth and stencil at once */
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
|
||||||
GL_DEPTH_STENCIL_ATTACHMENT,
|
GL_DEPTH_STENCIL_ATTACHMENT,
|
||||||
GL_RENDERBUFFER_EXT, rb);
|
GL_RENDERBUFFER_EXT, rb);
|
||||||
if (glGetError())
|
if (glGetError())
|
||||||
@@ -341,21 +341,21 @@ AttachDepthAndStencilBuffers(GLuint fbo,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* attach to depth attachment point */
|
/* attach to depth attachment point */
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
|
||||||
GL_DEPTH_ATTACHMENT_EXT,
|
GL_DEPTH_ATTACHMENT_EXT,
|
||||||
GL_RENDERBUFFER_EXT, rb);
|
GL_RENDERBUFFER_EXT, rb);
|
||||||
if (glGetError())
|
if (glGetError())
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
/* and attach to stencil attachment point */
|
/* and attach to stencil attachment point */
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
|
||||||
GL_STENCIL_ATTACHMENT_EXT,
|
GL_STENCIL_ATTACHMENT_EXT,
|
||||||
GL_RENDERBUFFER_EXT, rb);
|
GL_RENDERBUFFER_EXT, rb);
|
||||||
if (glGetError())
|
if (glGetError())
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
|
||||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
@@ -367,22 +367,22 @@ AttachDepthAndStencilBuffers(GLuint fbo,
|
|||||||
{
|
{
|
||||||
GLuint rb;
|
GLuint rb;
|
||||||
|
|
||||||
glGenRenderbuffersEXT(1, &rb);
|
glGenRenderbuffers_func(1, &rb);
|
||||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
|
glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, rb);
|
||||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
|
glRenderbufferStorage_func(GL_RENDERBUFFER_EXT,
|
||||||
GL_DEPTH_COMPONENT,
|
GL_DEPTH_COMPONENT,
|
||||||
width, height);
|
width, height);
|
||||||
if (glGetError())
|
if (glGetError())
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
/* attach to depth attachment point */
|
/* attach to depth attachment point */
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
|
||||||
GL_DEPTH_ATTACHMENT_EXT,
|
GL_DEPTH_ATTACHMENT_EXT,
|
||||||
GL_RENDERBUFFER_EXT, rb);
|
GL_RENDERBUFFER_EXT, rb);
|
||||||
if (glGetError())
|
if (glGetError())
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
|
||||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
@@ -393,26 +393,26 @@ AttachDepthAndStencilBuffers(GLuint fbo,
|
|||||||
{
|
{
|
||||||
GLuint rb;
|
GLuint rb;
|
||||||
|
|
||||||
glGenRenderbuffersEXT(1, &rb);
|
glGenRenderbuffers_func(1, &rb);
|
||||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
|
glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, rb);
|
||||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
|
glRenderbufferStorage_func(GL_RENDERBUFFER_EXT,
|
||||||
GL_STENCIL_INDEX,
|
GL_STENCIL_INDEX,
|
||||||
width, height);
|
width, height);
|
||||||
if (glGetError())
|
if (glGetError())
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
/* attach to depth attachment point */
|
/* attach to depth attachment point */
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
|
||||||
GL_STENCIL_ATTACHMENT_EXT,
|
GL_STENCIL_ATTACHMENT_EXT,
|
||||||
GL_RENDERBUFFER_EXT, rb);
|
GL_RENDERBUFFER_EXT, rb);
|
||||||
if (glGetError())
|
if (glGetError())
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
|
||||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
|
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
|
||||||
glDeleteRenderbuffersEXT(1, depthRbOut);
|
glDeleteRenderbuffers_func(1, depthRbOut);
|
||||||
*depthRbOut = 0;
|
*depthRbOut = 0;
|
||||||
glDeleteRenderbuffersEXT(1, &rb);
|
glDeleteRenderbuffers_func(1, &rb);
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,6 +463,37 @@ ParseArgs(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
SetupFunctionPointers(void)
|
||||||
|
{
|
||||||
|
GetExtensionFuncs();
|
||||||
|
|
||||||
|
if (Use_ARB_fbo) {
|
||||||
|
/* no-op: use the ARB functions as-is */
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* set the ARB-flavor function pointers to point to the EXT functions */
|
||||||
|
glIsRenderbuffer_func = glIsRenderbufferEXT_func;
|
||||||
|
glBindRenderbuffer_func = glBindRenderbufferEXT_func;
|
||||||
|
glDeleteRenderbuffers_func = glDeleteRenderbuffersEXT_func;
|
||||||
|
glGenRenderbuffers_func = glGenRenderbuffersEXT_func;
|
||||||
|
glRenderbufferStorage_func = glRenderbufferStorageEXT_func;
|
||||||
|
glGetRenderbufferParameteriv_func = glGetRenderbufferParameterivEXT_func;
|
||||||
|
glIsFramebuffer_func = glIsFramebufferEXT_func;
|
||||||
|
glBindFramebuffer_func = glBindFramebufferEXT_func;
|
||||||
|
glDeleteFramebuffers_func = glDeleteFramebuffersEXT_func;
|
||||||
|
glGenFramebuffers_func = glGenFramebuffersEXT_func;
|
||||||
|
glCheckFramebufferStatus_func = glCheckFramebufferStatusEXT_func;
|
||||||
|
glFramebufferTexture1D_func = glFramebufferTexture1DEXT_func;
|
||||||
|
glFramebufferTexture2D_func = glFramebufferTexture2DEXT_func;
|
||||||
|
glFramebufferTexture3D_func = glFramebufferTexture3DEXT_func;
|
||||||
|
glFramebufferRenderbuffer_func = glFramebufferRenderbufferEXT_func;
|
||||||
|
glGetFramebufferAttachmentParameteriv_func = glGetFramebufferAttachmentParameterivEXT_func;
|
||||||
|
glGenerateMipmap_func = glGenerateMipmapEXT_func;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make FBO to render into given texture.
|
* Make FBO to render into given texture.
|
||||||
*/
|
*/
|
||||||
@@ -472,10 +503,10 @@ MakeFBO_RenderTexture(GLuint TexObj)
|
|||||||
GLuint fb;
|
GLuint fb;
|
||||||
GLint sizeFudge = 0;
|
GLint sizeFudge = 0;
|
||||||
|
|
||||||
glGenFramebuffersEXT(1, &fb);
|
glGenFramebuffers_func(1, &fb);
|
||||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
|
glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, fb);
|
||||||
/* Render color to texture */
|
/* Render color to texture */
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
glFramebufferTexture2D_func(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||||
TexTarget, TexObj, TextureLevel);
|
TexTarget, TexObj, TextureLevel);
|
||||||
|
|
||||||
if (Use_ARB_fbo) {
|
if (Use_ARB_fbo) {
|
||||||
@@ -512,26 +543,26 @@ MakeFBO_RenderTexture(GLuint TexObj)
|
|||||||
{
|
{
|
||||||
GLint bits, w, h;
|
GLint bits, w, h;
|
||||||
|
|
||||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB);
|
glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, DepthRB);
|
||||||
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
|
glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
|
||||||
GL_RENDERBUFFER_WIDTH_EXT, &w);
|
GL_RENDERBUFFER_WIDTH_EXT, &w);
|
||||||
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
|
glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
|
||||||
GL_RENDERBUFFER_HEIGHT_EXT, &h);
|
GL_RENDERBUFFER_HEIGHT_EXT, &h);
|
||||||
printf("Color/Texture size: %d x %d\n", TexWidth, TexHeight);
|
printf("Color/Texture size: %d x %d\n", TexWidth, TexHeight);
|
||||||
printf("Depth buffer size: %d x %d\n", w, h);
|
printf("Depth buffer size: %d x %d\n", w, h);
|
||||||
|
|
||||||
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
|
glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
|
||||||
GL_RENDERBUFFER_DEPTH_SIZE_EXT, &bits);
|
GL_RENDERBUFFER_DEPTH_SIZE_EXT, &bits);
|
||||||
printf("Depth renderbuffer size = %d bits\n", bits);
|
printf("Depth renderbuffer size = %d bits\n", bits);
|
||||||
|
|
||||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, StencilRB);
|
glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, StencilRB);
|
||||||
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
|
glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
|
||||||
GL_RENDERBUFFER_STENCIL_SIZE_EXT, &bits);
|
GL_RENDERBUFFER_STENCIL_SIZE_EXT, &bits);
|
||||||
printf("Stencil renderbuffer size = %d bits\n", bits);
|
printf("Stencil renderbuffer size = %d bits\n", bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bind the regular framebuffer */
|
/* bind the regular framebuffer */
|
||||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, 0);
|
||||||
|
|
||||||
return fb;
|
return fb;
|
||||||
}
|
}
|
||||||
@@ -547,6 +578,8 @@ Init(void)
|
|||||||
|
|
||||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
|
SetupFunctionPointers();
|
||||||
|
|
||||||
/* lighting */
|
/* lighting */
|
||||||
{
|
{
|
||||||
static const GLfloat mat[4] = { 1.0, 0.5, 0.5, 1.0 };
|
static const GLfloat mat[4] = { 1.0, 0.5, 0.5, 1.0 };
|
||||||
@@ -605,7 +638,6 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(Width, Height);
|
glutInitWindowSize(Width, Height);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||||
Win = glutCreateWindow(argv[0]);
|
Win = glutCreateWindow(argv[0]);
|
||||||
glewInit();
|
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutDisplayFunc(Display);
|
glutDisplayFunc(Display);
|
||||||
|
|||||||
@@ -583,10 +583,14 @@ ParseOptions(int argc, char *argv[])
|
|||||||
int i;
|
int i;
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (strcmp(argv[i], "-fs") == 0) {
|
if (strcmp(argv[i], "-fs") == 0) {
|
||||||
FragProgFile = argv[i+1];
|
FragProgFile = argv[++i];
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[i], "-vs") == 0) {
|
else if (strcmp(argv[i], "-vs") == 0) {
|
||||||
VertProgFile = argv[i+1];
|
VertProgFile = argv[++i];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stderr, "unknown option %s\n", argv[i]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -514,12 +514,27 @@ static void draw_surface( unsigned int with_state )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case (GLVERTEX|STRIPS):
|
case (GLVERTEX|STRIPS):
|
||||||
glBegin( GL_TRIANGLE_STRIP );
|
if (with_state & MATERIALS) {
|
||||||
for (i=0;i<numverts;i++) {
|
glBegin( GL_TRIANGLE_STRIP );
|
||||||
glNormal3fv( &data[i][3] );
|
for (i=0;i<numverts;i++) {
|
||||||
glVertex3fv( &data[i][0] );
|
if (i % 600 == 0 && i != 0) {
|
||||||
|
unsigned j = i / 600;
|
||||||
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, col[j]);
|
||||||
|
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, col[j]);
|
||||||
|
}
|
||||||
|
glNormal3fv( &data[i][3] );
|
||||||
|
glVertex3fv( &data[i][0] );
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
glBegin( GL_TRIANGLE_STRIP );
|
||||||
|
for (i=0;i<numverts;i++) {
|
||||||
|
glNormal3fv( &data[i][3] );
|
||||||
|
glVertex3fv( &data[i][0] );
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
}
|
}
|
||||||
glEnd();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -11,7 +11,20 @@ env.Prepend(CPPPATH = [
|
|||||||
|
|
||||||
env.Prepend(LIBS = ['$GLUT_LIB'])
|
env.Prepend(LIBS = ['$GLUT_LIB'])
|
||||||
|
|
||||||
env.Program(
|
progs = [
|
||||||
target = 'fp-tri',
|
'fp-tri',
|
||||||
source = ['fp-tri.c'],
|
'tri-depth',
|
||||||
|
'tri-depth2',
|
||||||
|
'tri-depthwrite',
|
||||||
|
'tri-depthwrite2',
|
||||||
|
'tri-inv',
|
||||||
|
'tri-param',
|
||||||
|
'tri-tex',
|
||||||
|
'point-position',
|
||||||
|
]
|
||||||
|
|
||||||
|
for prog in progs:
|
||||||
|
env.Program(
|
||||||
|
target = prog,
|
||||||
|
source = [prog + '.c'],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ static void Init( void )
|
|||||||
}
|
}
|
||||||
fprintf(stderr, "%.*s\n", sz, buf);
|
fprintf(stderr, "%.*s\n", sz, buf);
|
||||||
|
|
||||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
if (!GLEW_ARB_fragment_program) {
|
||||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include "GL/gl.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -17,7 +16,7 @@ static void Init( void )
|
|||||||
;
|
;
|
||||||
GLuint modulateProg;
|
GLuint modulateProg;
|
||||||
|
|
||||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
if (!GLEW_ARB_fragment_program) {
|
||||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -109,6 +108,8 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glewInit();
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include "GL/gl.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ static void Init( void )
|
|||||||
;
|
;
|
||||||
GLuint modulateProg;
|
GLuint modulateProg;
|
||||||
|
|
||||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
if (!GLEW_ARB_fragment_program) {
|
||||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -89,8 +88,6 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
glutInit(&argc, argv);
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||||
|
|
||||||
type = GLUT_RGB;
|
type = GLUT_RGB;
|
||||||
@@ -101,6 +98,8 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glewInit();
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include "GL/gl.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -21,7 +20,7 @@ static void Init( void )
|
|||||||
;
|
;
|
||||||
GLuint modulateProg;
|
GLuint modulateProg;
|
||||||
|
|
||||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
if (!GLEW_ARB_fragment_program) {
|
||||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -106,6 +105,8 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glewInit();
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ static void Init(void)
|
|||||||
;
|
;
|
||||||
GLuint modulateProg;
|
GLuint modulateProg;
|
||||||
|
|
||||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
if (!GLEW_ARB_fragment_program) {
|
||||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -97,6 +97,8 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glewInit();
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ static void Init(void)
|
|||||||
;
|
;
|
||||||
GLuint modulateProg;
|
GLuint modulateProg;
|
||||||
|
|
||||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
if (!GLEW_ARB_fragment_program) {
|
||||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -97,6 +97,8 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glewInit();
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ static void Init( void )
|
|||||||
;
|
;
|
||||||
GLuint modulateProg;
|
GLuint modulateProg;
|
||||||
|
|
||||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
if (!GLEW_ARB_fragment_program) {
|
||||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -99,6 +99,8 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glewInit();
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include "GL/gl.h"
|
|
||||||
|
|
||||||
static void Init( void )
|
static void Init( void )
|
||||||
{
|
{
|
||||||
@@ -15,7 +15,7 @@ static void Init( void )
|
|||||||
;
|
;
|
||||||
GLuint modulateProg;
|
GLuint modulateProg;
|
||||||
|
|
||||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
if (!GLEW_ARB_fragment_program) {
|
||||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -104,6 +104,8 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glewInit();
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
|
|
||||||
#include "readtex.c"
|
#include "readtex.c"
|
||||||
@@ -23,7 +23,7 @@ static void Init( void )
|
|||||||
GLuint modulateProg;
|
GLuint modulateProg;
|
||||||
GLuint Texture;
|
GLuint Texture;
|
||||||
|
|
||||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
if (!GLEW_ARB_fragment_program) {
|
||||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -120,6 +120,8 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glewInit();
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ LIB_DEP = \
|
|||||||
$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
|
$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
|
||||||
$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
|
$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
|
||||||
|
|
||||||
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
|
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
|
||||||
|
|
||||||
INCLUDE_DIRS = -I$(TOP)/progs/util
|
INCLUDE_DIRS = -I$(TOP)/progs/util
|
||||||
|
|
||||||
|
|||||||
55
progs/glsl/SConscript
Normal file
55
progs/glsl/SConscript
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
Import('*')
|
||||||
|
|
||||||
|
if not env['GLUT']:
|
||||||
|
Return()
|
||||||
|
|
||||||
|
env = env.Clone()
|
||||||
|
|
||||||
|
env.Prepend(CPPPATH = [
|
||||||
|
'../util',
|
||||||
|
])
|
||||||
|
|
||||||
|
env.Prepend(LIBS = [
|
||||||
|
util,
|
||||||
|
'$GLUT_LIB'
|
||||||
|
])
|
||||||
|
|
||||||
|
if env['platform'] == 'windows':
|
||||||
|
env.Append(CPPDEFINES = ['NOMINMAX'])
|
||||||
|
env.Prepend(LIBS = ['winmm'])
|
||||||
|
|
||||||
|
progs = [
|
||||||
|
'array',
|
||||||
|
'bitmap',
|
||||||
|
'brick',
|
||||||
|
'bump',
|
||||||
|
'convolutions',
|
||||||
|
'deriv',
|
||||||
|
'fragcoord',
|
||||||
|
'identity',
|
||||||
|
'linktest',
|
||||||
|
'mandelbrot',
|
||||||
|
'multinoise',
|
||||||
|
'multitex',
|
||||||
|
'noise',
|
||||||
|
'noise2',
|
||||||
|
'pointcoord',
|
||||||
|
'points',
|
||||||
|
'samplers',
|
||||||
|
'shadow_sampler',
|
||||||
|
'skinning',
|
||||||
|
'texaaline',
|
||||||
|
'texdemo1',
|
||||||
|
'toyball',
|
||||||
|
'trirast',
|
||||||
|
'twoside',
|
||||||
|
'vert-or-frag-only',
|
||||||
|
'vert-tex',
|
||||||
|
]
|
||||||
|
|
||||||
|
for prog in progs:
|
||||||
|
env.Program(
|
||||||
|
target = prog,
|
||||||
|
source = prog + '.c',
|
||||||
|
)
|
||||||
|
|
||||||
@@ -9,10 +9,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -144,9 +142,9 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(fragShader);
|
glDeleteShader(fragShader);
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
glDeleteProgram_func(program);
|
glDeleteProgram(program);
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,19 +217,17 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
vertShader = CompileShaderText(GL_VERTEX_SHADER, VertShaderText);
|
vertShader = CompileShaderText(GL_VERTEX_SHADER, VertShaderText);
|
||||||
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, FragShaderText);
|
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, FragShaderText);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
/* Setup the HeightArray[] uniform */
|
/* Setup the HeightArray[] uniform */
|
||||||
for (i = 0; i < 20; i++)
|
for (i = 0; i < 20; i++)
|
||||||
HeightArray[i] = i / 20.0;
|
HeightArray[i] = i / 20.0;
|
||||||
u = glGetUniformLocation_func(program, "HeightArray");
|
u = glGetUniformLocation(program, "HeightArray");
|
||||||
glUniform1fv_func(u, 20, HeightArray);
|
glUniform1fv(u, 20, HeightArray);
|
||||||
|
|
||||||
assert(glGetError() == 0);
|
assert(glGetError() == 0);
|
||||||
|
|
||||||
@@ -248,6 +244,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(500, 500);
|
glutInitWindowSize(500, 500);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutSpecialFunc(SpecialKey);
|
glutSpecialFunc(SpecialKey);
|
||||||
|
|||||||
@@ -9,10 +9,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -78,11 +76,11 @@ Redisplay(void)
|
|||||||
BitmapText("-X");
|
BitmapText("-X");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
glUseProgram_func(Program);
|
glUseProgram(Program);
|
||||||
|
|
||||||
/* vertex positions (deltas) depend on texture size and window size */
|
/* vertex positions (deltas) depend on texture size and window size */
|
||||||
if (uScale != -1) {
|
if (uScale != -1) {
|
||||||
glUniform2f_func(uScale,
|
glUniform2f(uScale,
|
||||||
2.0 * TEX_WIDTH / WinWidth,
|
2.0 * TEX_WIDTH / WinWidth,
|
||||||
2.0 * TEX_HEIGHT / WinHeight);
|
2.0 * TEX_HEIGHT / WinHeight);
|
||||||
}
|
}
|
||||||
@@ -105,7 +103,7 @@ Redisplay(void)
|
|||||||
glTexCoord2f(0, 1); glVertex3fv(nx);
|
glTexCoord2f(0, 1); glVertex3fv(nx);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glUseProgram_func(0);
|
glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
@@ -160,9 +158,9 @@ Key(unsigned char key, int x, int y)
|
|||||||
printf("Using billboard texture\n");
|
printf("Using billboard texture\n");
|
||||||
break;
|
break;
|
||||||
case 27:
|
case 27:
|
||||||
glDeleteShader_func(FragShader);
|
glDeleteShader(FragShader);
|
||||||
glDeleteShader_func(VertShader);
|
glDeleteShader(VertShader);
|
||||||
glDeleteProgram_func(Program);
|
glDeleteProgram(Program);
|
||||||
glutDestroyWindow(Win);
|
glutDestroyWindow(Win);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@@ -277,21 +275,19 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
VertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
VertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
||||||
FragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
FragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
||||||
Program = LinkShaders(VertShader, FragShader);
|
Program = LinkShaders(VertShader, FragShader);
|
||||||
|
|
||||||
glUseProgram_func(Program);
|
glUseProgram(Program);
|
||||||
|
|
||||||
uScale = glGetUniformLocation_func(Program, "scale");
|
uScale = glGetUniformLocation(Program, "scale");
|
||||||
uTex = glGetUniformLocation_func(Program, "tex2d");
|
uTex = glGetUniformLocation(Program, "tex2d");
|
||||||
if (uTex != -1) {
|
if (uTex != -1) {
|
||||||
glUniform1i_func(uTex, 0); /* tex unit 0 */
|
glUniform1i(uTex, 0); /* tex unit 0 */
|
||||||
}
|
}
|
||||||
|
|
||||||
glUseProgram_func(0);
|
glUseProgram(0);
|
||||||
|
|
||||||
glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
|
glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
@@ -309,6 +305,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(WinWidth, WinHeight);
|
glutInitWindowSize(WinWidth, WinHeight);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
Win = glutCreateWindow(argv[0]);
|
Win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutSpecialFunc(SpecialKey);
|
glutSpecialFunc(SpecialKey);
|
||||||
|
|||||||
@@ -9,10 +9,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -82,9 +80,9 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(fragShader);
|
glDeleteShader(fragShader);
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
glDeleteProgram_func(program);
|
glDeleteProgram(program);
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,13 +142,11 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
|
vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
|
||||||
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
InitUniforms(program, Uniforms);
|
InitUniforms(program, Uniforms);
|
||||||
|
|
||||||
@@ -160,9 +156,9 @@ Init(void)
|
|||||||
|
|
||||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
assert(glIsProgram_func(program));
|
assert(glIsProgram(program));
|
||||||
assert(glIsShader_func(fragShader));
|
assert(glIsShader(fragShader));
|
||||||
assert(glIsShader_func(vertShader));
|
assert(glIsShader(vertShader));
|
||||||
|
|
||||||
glColor3f(1, 0, 0);
|
glColor3f(1, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -191,6 +187,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(400, 400);
|
glutInitWindowSize(400, 400);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutSpecialFunc(SpecialKey);
|
glutSpecialFunc(SpecialKey);
|
||||||
|
|||||||
@@ -9,10 +9,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glu.h>
|
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -60,7 +58,7 @@ static void
|
|||||||
Square(GLfloat size)
|
Square(GLfloat size)
|
||||||
{
|
{
|
||||||
glNormal3f(0, 0, 1);
|
glNormal3f(0, 0, 1);
|
||||||
glVertexAttrib3f_func(tangentAttrib, 1, 0, 0);
|
glVertexAttrib3f(tangentAttrib, 1, 0, 0);
|
||||||
glBegin(GL_POLYGON);
|
glBegin(GL_POLYGON);
|
||||||
glTexCoord2f(0, 0); glVertex2f(-size, -size);
|
glTexCoord2f(0, 0); glVertex2f(-size, -size);
|
||||||
glTexCoord2f(1, 0); glVertex2f( size, -size);
|
glTexCoord2f(1, 0); glVertex2f( size, -size);
|
||||||
@@ -164,9 +162,9 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(fragShader);
|
glDeleteShader(fragShader);
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
glDeleteProgram_func(program);
|
glDeleteProgram(program);
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,17 +228,15 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
|
vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
|
||||||
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
assert(glIsProgram_func(program));
|
assert(glIsProgram(program));
|
||||||
assert(glIsShader_func(fragShader));
|
assert(glIsShader(fragShader));
|
||||||
assert(glIsShader_func(vertShader));
|
assert(glIsShader(vertShader));
|
||||||
|
|
||||||
assert(glGetError() == 0);
|
assert(glGetError() == 0);
|
||||||
|
|
||||||
@@ -250,7 +246,7 @@ Init(void)
|
|||||||
|
|
||||||
CheckError(__LINE__);
|
CheckError(__LINE__);
|
||||||
|
|
||||||
tangentAttrib = glGetAttribLocation_func(program, "Tangent");
|
tangentAttrib = glGetAttribLocation(program, "Tangent");
|
||||||
printf("Tangent Attrib: %d\n", tangentAttrib);
|
printf("Tangent Attrib: %d\n", tangentAttrib);
|
||||||
|
|
||||||
assert(tangentAttrib >= 0);
|
assert(tangentAttrib >= 0);
|
||||||
@@ -288,6 +284,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(400, 400);
|
glutInitWindowSize(400, 400);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutSpecialFunc(SpecialKey);
|
glutSpecialFunc(SpecialKey);
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
* Author: Zack Rusin
|
* Author: Zack Rusin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <GL/glew.h>
|
||||||
|
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#define GL_GLEXT_PROTOTYPES
|
||||||
#include "readtex.h"
|
#include "readtex.h"
|
||||||
|
|
||||||
@@ -455,6 +457,7 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glewInit();
|
||||||
init();
|
init();
|
||||||
|
|
||||||
glutReshapeFunc(reshape);
|
glutReshapeFunc(reshape);
|
||||||
|
|||||||
@@ -13,10 +13,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -70,9 +68,9 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(fragShader);
|
glDeleteShader(fragShader);
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
glDeleteProgram_func(program);
|
glDeleteProgram(program);
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,13 +175,11 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
||||||
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
/*assert(glGetError() == 0);*/
|
/*assert(glGetError() == 0);*/
|
||||||
|
|
||||||
@@ -197,9 +193,9 @@ Init(void)
|
|||||||
|
|
||||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
assert(glIsProgram_func(program));
|
assert(glIsProgram(program));
|
||||||
assert(glIsShader_func(fragShader));
|
assert(glIsShader(fragShader));
|
||||||
assert(glIsShader_func(vertShader));
|
assert(glIsShader(vertShader));
|
||||||
|
|
||||||
glColor3f(1, 0, 0);
|
glColor3f(1, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -228,6 +224,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(200, 200);
|
glutInitWindowSize(200, 200);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutSpecialFunc(SpecialKey);
|
glutSpecialFunc(SpecialKey);
|
||||||
|
|||||||
@@ -12,10 +12,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -85,9 +83,9 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(fragShader);
|
glDeleteShader(fragShader);
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
glDeleteProgram_func(program);
|
glDeleteProgram(program);
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,13 +127,11 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
||||||
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
/*assert(glGetError() == 0);*/
|
/*assert(glGetError() == 0);*/
|
||||||
|
|
||||||
@@ -143,9 +139,9 @@ Init(void)
|
|||||||
|
|
||||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
assert(glIsProgram_func(program));
|
assert(glIsProgram(program));
|
||||||
assert(glIsShader_func(fragShader));
|
assert(glIsShader(fragShader));
|
||||||
assert(glIsShader_func(vertShader));
|
assert(glIsShader(vertShader));
|
||||||
|
|
||||||
glColor3f(1, 0, 0);
|
glColor3f(1, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -174,6 +170,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(WinWidth, WinHeight);
|
glutInitWindowSize(WinWidth, WinHeight);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutDisplayFunc(Redisplay);
|
glutDisplayFunc(Redisplay);
|
||||||
|
|||||||
@@ -9,10 +9,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -69,9 +67,9 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(fragShader);
|
glDeleteShader(fragShader);
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
glDeleteProgram_func(program);
|
glDeleteProgram(program);
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,8 +139,6 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
if (FragProgFile)
|
if (FragProgFile)
|
||||||
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
||||||
else
|
else
|
||||||
@@ -155,7 +151,7 @@ Init(void)
|
|||||||
|
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
/*assert(glGetError() == 0);*/
|
/*assert(glGetError() == 0);*/
|
||||||
|
|
||||||
@@ -164,9 +160,9 @@ Init(void)
|
|||||||
|
|
||||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
assert(glIsProgram_func(program));
|
assert(glIsProgram(program));
|
||||||
assert(glIsShader_func(fragShader));
|
assert(glIsShader(fragShader));
|
||||||
assert(glIsShader_func(vertShader));
|
assert(glIsShader(vertShader));
|
||||||
|
|
||||||
glColor3f(1, 0, 0);
|
glColor3f(1, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -195,6 +191,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(200, 200);
|
glutInitWindowSize(200, 200);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutSpecialFunc(SpecialKey);
|
glutSpecialFunc(SpecialKey);
|
||||||
|
|||||||
@@ -9,10 +9,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -132,11 +130,11 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(VertShader1);
|
glDeleteShader(VertShader1);
|
||||||
glDeleteShader_func(VertShader2);
|
glDeleteShader(VertShader2);
|
||||||
glDeleteShader_func(FragShader1);
|
glDeleteShader(FragShader1);
|
||||||
glDeleteShader_func(FragShader2);
|
glDeleteShader(FragShader2);
|
||||||
glDeleteProgram_func(Program);
|
glDeleteProgram(Program);
|
||||||
glutDestroyWindow(Win);
|
glutDestroyWindow(Win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,11 +173,11 @@ static void
|
|||||||
CheckLink(GLuint prog)
|
CheckLink(GLuint prog)
|
||||||
{
|
{
|
||||||
GLint stat;
|
GLint stat;
|
||||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
glGetProgramiv(prog, GL_LINK_STATUS, &stat);
|
||||||
if (!stat) {
|
if (!stat) {
|
||||||
GLchar log[1000];
|
GLchar log[1000];
|
||||||
GLsizei len;
|
GLsizei len;
|
||||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
glGetProgramInfoLog(prog, 1000, &len, log);
|
||||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,8 +189,6 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
VertShader1 = CompileShaderText(GL_VERTEX_SHADER, VertShaderSource1);
|
VertShader1 = CompileShaderText(GL_VERTEX_SHADER, VertShaderSource1);
|
||||||
@@ -200,26 +196,26 @@ Init(void)
|
|||||||
FragShader1 = CompileShaderText(GL_FRAGMENT_SHADER, FragShaderSource1);
|
FragShader1 = CompileShaderText(GL_FRAGMENT_SHADER, FragShaderSource1);
|
||||||
FragShader2 = CompileShaderText(GL_FRAGMENT_SHADER, FragShaderSource2);
|
FragShader2 = CompileShaderText(GL_FRAGMENT_SHADER, FragShaderSource2);
|
||||||
|
|
||||||
Program = glCreateProgram_func();
|
Program = glCreateProgram();
|
||||||
glAttachShader_func(Program, VertShader1);
|
glAttachShader(Program, VertShader1);
|
||||||
glAttachShader_func(Program, VertShader2);
|
glAttachShader(Program, VertShader2);
|
||||||
glAttachShader_func(Program, FragShader1);
|
glAttachShader(Program, FragShader1);
|
||||||
glAttachShader_func(Program, FragShader2);
|
glAttachShader(Program, FragShader2);
|
||||||
|
|
||||||
glLinkProgram_func(Program);
|
glLinkProgram(Program);
|
||||||
|
|
||||||
CheckLink(Program);
|
CheckLink(Program);
|
||||||
|
|
||||||
glUseProgram_func(Program);
|
glUseProgram(Program);
|
||||||
|
|
||||||
uDiffuse = glGetUniformLocation_func(Program, "diffuse");
|
uDiffuse = glGetUniformLocation(Program, "diffuse");
|
||||||
uSpecular = glGetUniformLocation_func(Program, "specular");
|
uSpecular = glGetUniformLocation(Program, "specular");
|
||||||
uTexture = glGetUniformLocation_func(Program, "texture");
|
uTexture = glGetUniformLocation(Program, "texture");
|
||||||
printf("DiffusePos %d SpecularPos %d TexturePos %d\n",
|
printf("DiffusePos %d SpecularPos %d TexturePos %d\n",
|
||||||
uDiffuse, uSpecular, uTexture);
|
uDiffuse, uSpecular, uTexture);
|
||||||
|
|
||||||
glUniform4fv_func(uDiffuse, 1, diffuse);
|
glUniform4fv(uDiffuse, 1, diffuse);
|
||||||
glUniform4fv_func(uSpecular, 1, specular);
|
glUniform4fv(uSpecular, 1, specular);
|
||||||
|
|
||||||
glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
|
glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
@@ -228,11 +224,11 @@ Init(void)
|
|||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
|
||||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 10.0f);
|
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 10.0f);
|
||||||
|
|
||||||
assert(glIsProgram_func(Program));
|
assert(glIsProgram(Program));
|
||||||
assert(glIsShader_func(VertShader1));
|
assert(glIsShader(VertShader1));
|
||||||
assert(glIsShader_func(VertShader2));
|
assert(glIsShader(VertShader2));
|
||||||
assert(glIsShader_func(FragShader1));
|
assert(glIsShader(FragShader1));
|
||||||
assert(glIsShader_func(FragShader2));
|
assert(glIsShader(FragShader2));
|
||||||
|
|
||||||
glColor3f(1, 0, 0);
|
glColor3f(1, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -245,6 +241,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(300, 300);
|
glutInitWindowSize(300, 300);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
Win = glutCreateWindow(argv[0]);
|
Win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutDisplayFunc(Redisplay);
|
glutDisplayFunc(Redisplay);
|
||||||
|
|||||||
@@ -9,10 +9,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -56,9 +54,9 @@ Redisplay(void)
|
|||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
/* set interactive uniform parameters */
|
/* set interactive uniform parameters */
|
||||||
glUniform1fv_func(uZoom, 1, &zoom);
|
glUniform1fv(uZoom, 1, &zoom);
|
||||||
glUniform1fv_func(uXcenter, 1, &xCenter);
|
glUniform1fv(uXcenter, 1, &xCenter);
|
||||||
glUniform1fv_func(uYcenter, 1, &yCenter);
|
glUniform1fv(uYcenter, 1, &yCenter);
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
|
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
|
||||||
@@ -94,9 +92,9 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(fragShader);
|
glDeleteShader(fragShader);
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
glDeleteProgram_func(program);
|
glDeleteProgram(program);
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,19 +153,17 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
|
vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
|
||||||
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
InitUniforms(program, Uniforms);
|
InitUniforms(program, Uniforms);
|
||||||
|
|
||||||
uZoom = glGetUniformLocation_func(program, "Zoom");
|
uZoom = glGetUniformLocation(program, "Zoom");
|
||||||
uXcenter = glGetUniformLocation_func(program, "Xcenter");
|
uXcenter = glGetUniformLocation(program, "Xcenter");
|
||||||
uYcenter = glGetUniformLocation_func(program, "Ycenter");
|
uYcenter = glGetUniformLocation(program, "Ycenter");
|
||||||
|
|
||||||
assert(glGetError() == 0);
|
assert(glGetError() == 0);
|
||||||
|
|
||||||
@@ -175,9 +171,9 @@ Init(void)
|
|||||||
|
|
||||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
assert(glIsProgram_func(program));
|
assert(glIsProgram(program));
|
||||||
assert(glIsShader_func(fragShader));
|
assert(glIsShader(fragShader));
|
||||||
assert(glIsShader_func(vertShader));
|
assert(glIsShader(vertShader));
|
||||||
|
|
||||||
glColor3f(1, 0, 0);
|
glColor3f(1, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -206,6 +202,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(400, 400);
|
glutInitWindowSize(400, 400);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutSpecialFunc(SpecialKey);
|
glutSpecialFunc(SpecialKey);
|
||||||
|
|||||||
@@ -8,10 +8,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
|
|
||||||
static const char *VertShaderText =
|
static const char *VertShaderText =
|
||||||
"void main() {\n"
|
"void main() {\n"
|
||||||
@@ -107,10 +105,10 @@ CleanUp(void)
|
|||||||
{
|
{
|
||||||
GLint i;
|
GLint i;
|
||||||
|
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
for( i = 0; i < 4; i++ ) {
|
for( i = 0; i < 4; i++ ) {
|
||||||
glDeleteShader_func(fragShader[ i ]);
|
glDeleteShader(fragShader[ i ]);
|
||||||
glDeleteProgram_func(program[ i ]);
|
glDeleteProgram(program[ i ]);
|
||||||
}
|
}
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
@@ -143,7 +141,7 @@ Key(unsigned char key, int x, int y)
|
|||||||
case '2':
|
case '2':
|
||||||
case '3':
|
case '3':
|
||||||
case '4':
|
case '4':
|
||||||
glUseProgram_func(program[ key - '1' ]);
|
glUseProgram(program[ key - '1' ]);
|
||||||
break;
|
break;
|
||||||
case 27:
|
case 27:
|
||||||
CleanUp();
|
CleanUp();
|
||||||
@@ -186,15 +184,15 @@ LoadAndCompileShader(GLuint shader, const char *text)
|
|||||||
{
|
{
|
||||||
GLint stat;
|
GLint stat;
|
||||||
|
|
||||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
glShaderSource(shader, 1, (const GLchar **) &text, NULL);
|
||||||
|
|
||||||
glCompileShader_func(shader);
|
glCompileShader(shader);
|
||||||
|
|
||||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
glGetShaderiv(shader, GL_COMPILE_STATUS, &stat);
|
||||||
if (!stat) {
|
if (!stat) {
|
||||||
GLchar log[1000];
|
GLchar log[1000];
|
||||||
GLsizei len;
|
GLsizei len;
|
||||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
glGetShaderInfoLog(shader, 1000, &len, log);
|
||||||
fprintf(stderr, "noise: problem compiling shader: %s\n", log);
|
fprintf(stderr, "noise: problem compiling shader: %s\n", log);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -208,11 +206,11 @@ static void
|
|||||||
CheckLink(GLuint prog)
|
CheckLink(GLuint prog)
|
||||||
{
|
{
|
||||||
GLint stat;
|
GLint stat;
|
||||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
glGetProgramiv(prog, GL_LINK_STATUS, &stat);
|
||||||
if (!stat) {
|
if (!stat) {
|
||||||
GLchar log[1000];
|
GLchar log[1000];
|
||||||
GLsizei len;
|
GLsizei len;
|
||||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
glGetProgramInfoLog(prog, 1000, &len, log);
|
||||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -233,22 +231,20 @@ Init(void)
|
|||||||
/*exit(1);*/
|
/*exit(1);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
GetExtensionFuncs();
|
vertShader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
|
||||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
|
||||||
LoadAndCompileShader(vertShader, VertShaderText);
|
LoadAndCompileShader(vertShader, VertShaderText);
|
||||||
|
|
||||||
for( i = 0; i < 4; i++ ) {
|
for( i = 0; i < 4; i++ ) {
|
||||||
fragShader[ i ] = glCreateShader_func(GL_FRAGMENT_SHADER);
|
fragShader[ i ] = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
LoadAndCompileShader(fragShader[ i ], FragShaderText[ i ]);
|
LoadAndCompileShader(fragShader[ i ], FragShaderText[ i ]);
|
||||||
program[ i ] = glCreateProgram_func();
|
program[ i ] = glCreateProgram();
|
||||||
glAttachShader_func(program[ i ], fragShader[ i ]);
|
glAttachShader(program[ i ], fragShader[ i ]);
|
||||||
glAttachShader_func(program[ i ], vertShader);
|
glAttachShader(program[ i ], vertShader);
|
||||||
glLinkProgram_func(program[ i ]);
|
glLinkProgram(program[ i ]);
|
||||||
CheckLink(program[ i ]);
|
CheckLink(program[ i ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
glUseProgram_func(program[ 0 ]);
|
glUseProgram(program[ 0 ]);
|
||||||
|
|
||||||
assert(glGetError() == 0);
|
assert(glGetError() == 0);
|
||||||
|
|
||||||
@@ -270,6 +266,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(400, 400);
|
glutInitWindowSize(400, 400);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutSpecialFunc(SpecialKey);
|
glutSpecialFunc(SpecialKey);
|
||||||
|
|||||||
@@ -28,9 +28,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <GL/glew.h>
|
||||||
#include "GL/glut.h"
|
#include "GL/glut.h"
|
||||||
#include "readtex.h"
|
#include "readtex.h"
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
static const char *Demo = "multitex";
|
static const char *Demo = "multitex";
|
||||||
@@ -80,22 +80,22 @@ static void
|
|||||||
DrawPolygonArray(void)
|
DrawPolygonArray(void)
|
||||||
{
|
{
|
||||||
if (VertCoord_attr >= 0) {
|
if (VertCoord_attr >= 0) {
|
||||||
glVertexAttribPointer_func(VertCoord_attr, 2, GL_FLOAT, GL_FALSE,
|
glVertexAttribPointer(VertCoord_attr, 2, GL_FLOAT, GL_FALSE,
|
||||||
0, VertCoords);
|
0, VertCoords);
|
||||||
glEnableVertexAttribArray_func(VertCoord_attr);
|
glEnableVertexAttribArray(VertCoord_attr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
glVertexPointer(2, GL_FLOAT, 0, VertCoords);
|
glVertexPointer(2, GL_FLOAT, 0, VertCoords);
|
||||||
glEnable(GL_VERTEX_ARRAY);
|
glEnable(GL_VERTEX_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
glVertexAttribPointer_func(TexCoord0_attr, 2, GL_FLOAT, GL_FALSE,
|
glVertexAttribPointer(TexCoord0_attr, 2, GL_FLOAT, GL_FALSE,
|
||||||
0, Tex0Coords);
|
0, Tex0Coords);
|
||||||
glEnableVertexAttribArray_func(TexCoord0_attr);
|
glEnableVertexAttribArray(TexCoord0_attr);
|
||||||
|
|
||||||
glVertexAttribPointer_func(TexCoord1_attr, 2, GL_FLOAT, GL_FALSE,
|
glVertexAttribPointer(TexCoord1_attr, 2, GL_FLOAT, GL_FALSE,
|
||||||
0, Tex1Coords);
|
0, Tex1Coords);
|
||||||
glEnableVertexAttribArray_func(TexCoord1_attr);
|
glEnableVertexAttribArray(TexCoord1_attr);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
}
|
}
|
||||||
@@ -109,11 +109,11 @@ DrawPolygonVert(void)
|
|||||||
glBegin(GL_TRIANGLE_FAN);
|
glBegin(GL_TRIANGLE_FAN);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
glVertexAttrib2fv_func(TexCoord0_attr, Tex0Coords[i]);
|
glVertexAttrib2fv(TexCoord0_attr, Tex0Coords[i]);
|
||||||
glVertexAttrib2fv_func(TexCoord1_attr, Tex1Coords[i]);
|
glVertexAttrib2fv(TexCoord1_attr, Tex1Coords[i]);
|
||||||
|
|
||||||
if (VertCoord_attr >= 0)
|
if (VertCoord_attr >= 0)
|
||||||
glVertexAttrib2fv_func(VertCoord_attr, VertCoords[i]);
|
glVertexAttrib2fv(VertCoord_attr, VertCoords[i]);
|
||||||
else
|
else
|
||||||
glVertex2fv(VertCoords[i]);
|
glVertex2fv(VertCoords[i]);
|
||||||
}
|
}
|
||||||
@@ -267,27 +267,27 @@ CreateProgram(const char *vertProgFile, const char *fragProgFile,
|
|||||||
assert(vertShader);
|
assert(vertShader);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
InitUniforms(program, uniforms);
|
InitUniforms(program, uniforms);
|
||||||
|
|
||||||
VertCoord_attr = glGetAttribLocation_func(program, "VertCoord");
|
VertCoord_attr = glGetAttribLocation(program, "VertCoord");
|
||||||
if (VertCoord_attr > 0) {
|
if (VertCoord_attr > 0) {
|
||||||
/* We want the VertCoord attrib to have position zero so that
|
/* We want the VertCoord attrib to have position zero so that
|
||||||
* the call to glVertexAttrib(0, xyz) triggers vertex processing.
|
* the call to glVertexAttrib(0, xyz) triggers vertex processing.
|
||||||
* Otherwise, if TexCoord0 or TexCoord1 gets position 0 we'd have
|
* Otherwise, if TexCoord0 or TexCoord1 gets position 0 we'd have
|
||||||
* to set that attribute last (which is a PITA to manage).
|
* to set that attribute last (which is a PITA to manage).
|
||||||
*/
|
*/
|
||||||
glBindAttribLocation_func(program, 0, "VertCoord");
|
glBindAttribLocation(program, 0, "VertCoord");
|
||||||
/* re-link */
|
/* re-link */
|
||||||
glLinkProgram_func(program);
|
glLinkProgram(program);
|
||||||
/* VertCoord_attr should be zero now */
|
/* VertCoord_attr should be zero now */
|
||||||
VertCoord_attr = glGetAttribLocation_func(program, "VertCoord");
|
VertCoord_attr = glGetAttribLocation(program, "VertCoord");
|
||||||
assert(VertCoord_attr == 0);
|
assert(VertCoord_attr == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TexCoord0_attr = glGetAttribLocation_func(program, "TexCoord0");
|
TexCoord0_attr = glGetAttribLocation(program, "TexCoord0");
|
||||||
TexCoord1_attr = glGetAttribLocation_func(program, "TexCoord1");
|
TexCoord1_attr = glGetAttribLocation(program, "TexCoord1");
|
||||||
|
|
||||||
printf("TexCoord0_attr = %d\n", TexCoord0_attr);
|
printf("TexCoord0_attr = %d\n", TexCoord0_attr);
|
||||||
printf("TexCoord1_attr = %d\n", TexCoord1_attr);
|
printf("TexCoord1_attr = %d\n", TexCoord1_attr);
|
||||||
@@ -315,8 +315,6 @@ InitGL(void)
|
|||||||
}
|
}
|
||||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
InitTextures();
|
InitTextures();
|
||||||
InitPrograms();
|
InitPrograms();
|
||||||
|
|
||||||
@@ -334,6 +332,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(500, 400);
|
glutInitWindowSize(500, 400);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
||||||
glutCreateWindow(Demo);
|
glutCreateWindow(Demo);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(key);
|
glutKeyboardFunc(key);
|
||||||
glutSpecialFunc(specialkey);
|
glutSpecialFunc(specialkey);
|
||||||
|
|||||||
@@ -8,10 +8,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -67,7 +65,7 @@ Redisplay(void)
|
|||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
glUniform1fv_func(Uniforms[2].location, 1, &Slice);
|
glUniform1fv(Uniforms[2].location, 1, &Slice);
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
|
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
|
||||||
@@ -103,9 +101,9 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(fragShader);
|
glDeleteShader(fragShader);
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
glDeleteProgram_func(program);
|
glDeleteProgram(program);
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,13 +173,11 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
vertShader = CompileShaderText(GL_VERTEX_SHADER, VertShaderText);
|
vertShader = CompileShaderText(GL_VERTEX_SHADER, VertShaderText);
|
||||||
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, FragShaderText);
|
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, FragShaderText);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
InitUniforms(program, Uniforms);
|
InitUniforms(program, Uniforms);
|
||||||
|
|
||||||
@@ -191,9 +187,9 @@ Init(void)
|
|||||||
|
|
||||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
assert(glIsProgram_func(program));
|
assert(glIsProgram(program));
|
||||||
assert(glIsShader_func(fragShader));
|
assert(glIsShader(fragShader));
|
||||||
assert(glIsShader_func(vertShader));
|
assert(glIsShader(vertShader));
|
||||||
|
|
||||||
glColor3f(1, 0, 0);
|
glColor3f(1, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -207,6 +203,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(400, 400);
|
glutInitWindowSize(400, 400);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutSpecialFunc(SpecialKey);
|
glutSpecialFunc(SpecialKey);
|
||||||
|
|||||||
@@ -10,10 +10,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -64,9 +62,9 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(fragShader);
|
glDeleteShader(fragShader);
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
glDeleteProgram_func(program);
|
glDeleteProgram(program);
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,18 +139,16 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
||||||
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
tex0 = glGetUniformLocation_func(program, "tex0");
|
tex0 = glGetUniformLocation(program, "tex0");
|
||||||
printf("Uniforms: tex0: %d\n", tex0);
|
printf("Uniforms: tex0: %d\n", tex0);
|
||||||
|
|
||||||
glUniform1i_func(tex0, 0); /* tex unit 0 */
|
glUniform1i(tex0, 0); /* tex unit 0 */
|
||||||
|
|
||||||
/*assert(glGetError() == 0);*/
|
/*assert(glGetError() == 0);*/
|
||||||
|
|
||||||
@@ -160,9 +156,9 @@ Init(void)
|
|||||||
|
|
||||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
assert(glIsProgram_func(program));
|
assert(glIsProgram(program));
|
||||||
assert(glIsShader_func(fragShader));
|
assert(glIsShader(fragShader));
|
||||||
assert(glIsShader_func(vertShader));
|
assert(glIsShader(vertShader));
|
||||||
|
|
||||||
MakeTexture();
|
MakeTexture();
|
||||||
|
|
||||||
@@ -195,6 +191,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(WinWidth, WinHeight);
|
glutInitWindowSize(WinWidth, WinHeight);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutDisplayFunc(Redisplay);
|
glutDisplayFunc(Redisplay);
|
||||||
|
|||||||
@@ -10,10 +10,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -99,7 +97,7 @@ Redisplay(void)
|
|||||||
*/
|
*/
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(0, 1.2, 0);
|
glTranslatef(0, 1.2, 0);
|
||||||
glUseProgram_func(0);
|
glUseProgram(0);
|
||||||
DrawPoints(GL_FALSE);
|
DrawPoints(GL_FALSE);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
@@ -108,9 +106,9 @@ Redisplay(void)
|
|||||||
*/
|
*/
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(0, -1.2, 0);
|
glTranslatef(0, -1.2, 0);
|
||||||
glUseProgram_func(Program);
|
glUseProgram(Program);
|
||||||
if (uViewportInv != -1) {
|
if (uViewportInv != -1) {
|
||||||
glUniform2f_func(uViewportInv, 1.0 / WinWidth, 1.0 / WinHeight);
|
glUniform2f(uViewportInv, 1.0 / WinWidth, 1.0 / WinHeight);
|
||||||
}
|
}
|
||||||
DrawPoints(GL_TRUE);
|
DrawPoints(GL_TRUE);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
@@ -150,9 +148,9 @@ Key(unsigned char key, int x, int y)
|
|||||||
Smooth = !Smooth;
|
Smooth = !Smooth;
|
||||||
break;
|
break;
|
||||||
case 27:
|
case 27:
|
||||||
glDeleteShader_func(FragShader);
|
glDeleteShader(FragShader);
|
||||||
glDeleteShader_func(VertShader);
|
glDeleteShader(VertShader);
|
||||||
glDeleteProgram_func(Program);
|
glDeleteProgram(Program);
|
||||||
glutDestroyWindow(Win);
|
glutDestroyWindow(Win);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@@ -225,17 +223,15 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
VertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
VertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
||||||
FragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
FragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
||||||
Program = LinkShaders(VertShader, FragShader);
|
Program = LinkShaders(VertShader, FragShader);
|
||||||
|
|
||||||
glUseProgram_func(Program);
|
glUseProgram(Program);
|
||||||
|
|
||||||
uViewportInv = glGetUniformLocation_func(Program, "viewportInv");
|
uViewportInv = glGetUniformLocation(Program, "viewportInv");
|
||||||
|
|
||||||
glUseProgram_func(0);
|
glUseProgram(0);
|
||||||
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
}
|
}
|
||||||
@@ -248,6 +244,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(WinWidth, WinHeight);
|
glutInitWindowSize(WinWidth, WinHeight);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
Win = glutCreateWindow(argv[0]);
|
Win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutSpecialFunc(SpecialKey);
|
glutSpecialFunc(SpecialKey);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ void main()
|
|||||||
float two_n_dot_u = 2.0 * dot(n, u);
|
float two_n_dot_u = 2.0 * dot(n, u);
|
||||||
vec4 f;
|
vec4 f;
|
||||||
f.xyz = u - n * two_n_dot_u;
|
f.xyz = u - n * two_n_dot_u;
|
||||||
|
f.w = 1.0;
|
||||||
|
|
||||||
// outputs
|
// outputs
|
||||||
normal = n;
|
normal = n;
|
||||||
|
|||||||
@@ -39,9 +39,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <GL/glew.h>
|
||||||
#include "GL/glut.h"
|
#include "GL/glut.h"
|
||||||
#include "readtex.h"
|
#include "readtex.h"
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -290,7 +290,7 @@ CreateProgram(void)
|
|||||||
assert(vertShader);
|
assert(vertShader);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
free(fragShaderText);
|
free(fragShaderText);
|
||||||
|
|
||||||
@@ -315,10 +315,10 @@ InitProgram(void)
|
|||||||
#else
|
#else
|
||||||
sprintf(uname, "tex[%d]", s);
|
sprintf(uname, "tex[%d]", s);
|
||||||
#endif
|
#endif
|
||||||
loc = glGetUniformLocation_func(Program, uname);
|
loc = glGetUniformLocation(Program, uname);
|
||||||
assert(loc >= 0);
|
assert(loc >= 0);
|
||||||
|
|
||||||
glUniform1i_func(loc, s);
|
glUniform1i(loc, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,8 +333,6 @@ InitGL(void)
|
|||||||
|
|
||||||
printf("GL_RENDERER = %s\n", (const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n", (const char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &NumSamplers);
|
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &NumSamplers);
|
||||||
if (NumSamplers > MAX_SAMPLERS)
|
if (NumSamplers > MAX_SAMPLERS)
|
||||||
NumSamplers = MAX_SAMPLERS;
|
NumSamplers = MAX_SAMPLERS;
|
||||||
@@ -357,6 +355,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(500, 400);
|
glutInitWindowSize(500, 400);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
||||||
glutCreateWindow(Demo);
|
glutCreateWindow(Demo);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(key);
|
glutKeyboardFunc(key);
|
||||||
glutSpecialFunc(specialkey);
|
glutSpecialFunc(specialkey);
|
||||||
|
|||||||
@@ -10,10 +10,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
|
|
||||||
|
|
||||||
/** Use GL_RECTANGLE texture (with projective texcoords)? */
|
/** Use GL_RECTANGLE texture (with projective texcoords)? */
|
||||||
@@ -66,7 +64,7 @@ Redisplay(void)
|
|||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
CheckError(__LINE__);
|
CheckError(__LINE__);
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
CheckError(__LINE__);
|
CheckError(__LINE__);
|
||||||
|
|
||||||
glBegin(GL_POLYGON);
|
glBegin(GL_POLYGON);
|
||||||
@@ -86,7 +84,7 @@ Redisplay(void)
|
|||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
glUseProgram_func(0);
|
glUseProgram(0);
|
||||||
glWindowPos2iARB(80, 20);
|
glWindowPos2iARB(80, 20);
|
||||||
PrintString("white black white black");
|
PrintString("white black white black");
|
||||||
|
|
||||||
@@ -110,9 +108,9 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(fragShader);
|
glDeleteShader(fragShader);
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
glDeleteProgram_func(program);
|
glDeleteProgram(program);
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,13 +176,13 @@ static void
|
|||||||
LoadAndCompileShader(GLuint shader, const char *text)
|
LoadAndCompileShader(GLuint shader, const char *text)
|
||||||
{
|
{
|
||||||
GLint stat;
|
GLint stat;
|
||||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
glShaderSource(shader, 1, (const GLchar **) &text, NULL);
|
||||||
glCompileShader_func(shader);
|
glCompileShader(shader);
|
||||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
glGetShaderiv(shader, GL_COMPILE_STATUS, &stat);
|
||||||
if (!stat) {
|
if (!stat) {
|
||||||
GLchar log[1000];
|
GLchar log[1000];
|
||||||
GLsizei len;
|
GLsizei len;
|
||||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
glGetShaderInfoLog(shader, 1000, &len, log);
|
||||||
fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log);
|
fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -222,11 +220,11 @@ static void
|
|||||||
CheckLink(GLuint prog)
|
CheckLink(GLuint prog)
|
||||||
{
|
{
|
||||||
GLint stat;
|
GLint stat;
|
||||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
glGetProgramiv(prog, GL_LINK_STATUS, &stat);
|
||||||
if (!stat) {
|
if (!stat) {
|
||||||
GLchar log[1000];
|
GLchar log[1000];
|
||||||
GLsizei len;
|
GLsizei len;
|
||||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
glGetProgramInfoLog(prog, 1000, &len, log);
|
||||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -266,35 +264,33 @@ Init(void)
|
|||||||
}
|
}
|
||||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
GetExtensionFuncs();
|
fragShader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
|
|
||||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
|
||||||
if (FragProgFile)
|
if (FragProgFile)
|
||||||
ReadShader(fragShader, FragProgFile);
|
ReadShader(fragShader, FragProgFile);
|
||||||
else
|
else
|
||||||
LoadAndCompileShader(fragShader, fragShaderText);
|
LoadAndCompileShader(fragShader, fragShaderText);
|
||||||
|
|
||||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
vertShader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
if (VertProgFile)
|
if (VertProgFile)
|
||||||
ReadShader(vertShader, VertProgFile);
|
ReadShader(vertShader, VertProgFile);
|
||||||
else
|
else
|
||||||
LoadAndCompileShader(vertShader, vertShaderText);
|
LoadAndCompileShader(vertShader, vertShaderText);
|
||||||
|
|
||||||
program = glCreateProgram_func();
|
program = glCreateProgram();
|
||||||
glAttachShader_func(program, fragShader);
|
glAttachShader(program, fragShader);
|
||||||
glAttachShader_func(program, vertShader);
|
glAttachShader(program, vertShader);
|
||||||
glLinkProgram_func(program);
|
glLinkProgram(program);
|
||||||
CheckLink(program);
|
CheckLink(program);
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
uTexture2D = glGetUniformLocation_func(program, "shadowTex2D");
|
uTexture2D = glGetUniformLocation(program, "shadowTex2D");
|
||||||
uTextureRect = glGetUniformLocation_func(program, "shadowTexRect");
|
uTextureRect = glGetUniformLocation(program, "shadowTexRect");
|
||||||
printf("uTexture2D %d uTextureRect %d\n", uTexture2D, uTextureRect);
|
printf("uTexture2D %d uTextureRect %d\n", uTexture2D, uTextureRect);
|
||||||
if (uTexture2D >= 0) {
|
if (uTexture2D >= 0) {
|
||||||
glUniform1i_func(uTexture2D, 0); /* use texture unit 0 */
|
glUniform1i(uTexture2D, 0); /* use texture unit 0 */
|
||||||
}
|
}
|
||||||
if (uTextureRect >= 0) {
|
if (uTextureRect >= 0) {
|
||||||
glUniform1i_func(uTextureRect, 1); /* use texture unit 0 */
|
glUniform1i(uTextureRect, 1); /* use texture unit 0 */
|
||||||
}
|
}
|
||||||
CheckError(__LINE__);
|
CheckError(__LINE__);
|
||||||
|
|
||||||
@@ -329,6 +325,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(400, 300);
|
glutInitWindowSize(400, 300);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutDisplayFunc(Redisplay);
|
glutDisplayFunc(Redisplay);
|
||||||
|
|||||||
@@ -12,10 +12,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -64,11 +62,11 @@ Cylinder(GLfloat length, GLfloat radius, GLint slices, GLint stacks)
|
|||||||
float a = (float) i / (slices - 1) * M_PI * 2.0;
|
float a = (float) i / (slices - 1) * M_PI * 2.0;
|
||||||
float x = radius * cos(a);
|
float x = radius * cos(a);
|
||||||
float y = radius * sin(a);
|
float y = radius * sin(a);
|
||||||
glVertexAttrib1f_func(WeightAttr, w0);
|
glVertexAttrib1f(WeightAttr, w0);
|
||||||
glNormal3f(x, y, 0.0);
|
glNormal3f(x, y, 0.0);
|
||||||
glVertex3f(x, y, z0);
|
glVertex3f(x, y, z0);
|
||||||
|
|
||||||
glVertexAttrib1f_func(WeightAttr, w0 + dw);
|
glVertexAttrib1f(WeightAttr, w0 + dw);
|
||||||
glNormal3f(x, y, 0.0);
|
glNormal3f(x, y, 0.0);
|
||||||
glVertex3f(x, y, z0 + dz);
|
glVertex3f(x, y, z0 + dz);
|
||||||
}
|
}
|
||||||
@@ -106,8 +104,8 @@ Redisplay(void)
|
|||||||
{
|
{
|
||||||
UpdateMatrices();
|
UpdateMatrices();
|
||||||
|
|
||||||
glUniformMatrix4fv_func(uMat0, 1, GL_FALSE, Matrices[0]);
|
glUniformMatrix4fv(uMat0, 1, GL_FALSE, Matrices[0]);
|
||||||
glUniformMatrix4fv_func(uMat1, 1, GL_FALSE, Matrices[1]);
|
glUniformMatrix4fv(uMat1, 1, GL_FALSE, Matrices[1]);
|
||||||
|
|
||||||
if (WireFrame)
|
if (WireFrame)
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
@@ -148,9 +146,9 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(fragShader);
|
glDeleteShader(fragShader);
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
glDeleteProgram_func(program);
|
glDeleteProgram(program);
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,18 +219,16 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
|
vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
|
||||||
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
uMat0 = glGetUniformLocation_func(program, "mat0");
|
uMat0 = glGetUniformLocation(program, "mat0");
|
||||||
uMat1 = glGetUniformLocation_func(program, "mat1");
|
uMat1 = glGetUniformLocation(program, "mat1");
|
||||||
|
|
||||||
WeightAttr = glGetAttribLocation_func(program, "weight");
|
WeightAttr = glGetAttribLocation(program, "weight");
|
||||||
|
|
||||||
assert(glGetError() == 0);
|
assert(glGetError() == 0);
|
||||||
|
|
||||||
@@ -266,6 +262,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(500, 500);
|
glutInitWindowSize(500, 500);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutSpecialFunc(SpecialKey);
|
glutSpecialFunc(SpecialKey);
|
||||||
|
|||||||
@@ -11,10 +11,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
|
|
||||||
|
|
||||||
static GLint WinWidth = 300, WinHeight = 300;
|
static GLint WinWidth = 300, WinHeight = 300;
|
||||||
@@ -328,8 +326,6 @@ Init(void)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
|
glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
|
||||||
|
|
||||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||||
@@ -359,6 +355,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(WinWidth, WinHeight);
|
glutInitWindowSize(WinWidth, WinHeight);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutDisplayFunc(Redisplay);
|
glutDisplayFunc(Redisplay);
|
||||||
|
|||||||
@@ -28,9 +28,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <GL/glew.h>
|
||||||
#include "GL/glut.h"
|
#include "GL/glut.h"
|
||||||
#include "readtex.h"
|
#include "readtex.h"
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
static const char *Demo = "texdemo1";
|
static const char *Demo = "texdemo1";
|
||||||
@@ -97,7 +97,7 @@ draw(void)
|
|||||||
/* sphere w/ reflection map */
|
/* sphere w/ reflection map */
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(0, 1, 0);
|
glTranslatef(0, 1, 0);
|
||||||
glUseProgram_func(Program1);
|
glUseProgram(Program1);
|
||||||
|
|
||||||
/* setup texture matrix */
|
/* setup texture matrix */
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
@@ -116,7 +116,7 @@ draw(void)
|
|||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
/* ground */
|
/* ground */
|
||||||
glUseProgram_func(Program2);
|
glUseProgram(Program2);
|
||||||
glTranslatef(0, -1.0, 0);
|
glTranslatef(0, -1.0, 0);
|
||||||
DrawGround(5);
|
DrawGround(5);
|
||||||
|
|
||||||
@@ -380,7 +380,7 @@ CreateProgram(const char *vertProgFile, const char *fragProgFile,
|
|||||||
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, fragProgFile);
|
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, fragProgFile);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
InitUniforms(program, uniforms);
|
InitUniforms(program, uniforms);
|
||||||
|
|
||||||
@@ -407,8 +407,6 @@ Init(GLboolean useImageFiles)
|
|||||||
}
|
}
|
||||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
InitTextures(useImageFiles);
|
InitTextures(useImageFiles);
|
||||||
InitPrograms();
|
InitPrograms();
|
||||||
|
|
||||||
@@ -426,6 +424,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(500, 400);
|
glutInitWindowSize(500, 400);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
||||||
win = glutCreateWindow(Demo);
|
win = glutCreateWindow(Demo);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(key);
|
glutKeyboardFunc(key);
|
||||||
glutSpecialFunc(specialkey);
|
glutSpecialFunc(specialkey);
|
||||||
|
|||||||
@@ -9,10 +9,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -99,9 +97,9 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(fragShader);
|
glDeleteShader(fragShader);
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
glDeleteProgram_func(program);
|
glDeleteProgram(program);
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,13 +167,11 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
|
vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
|
||||||
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
InitUniforms(program, Uniforms);
|
InitUniforms(program, Uniforms);
|
||||||
|
|
||||||
@@ -212,6 +208,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(400, 400);
|
glutInitWindowSize(400, 400);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutSpecialFunc(SpecialKey);
|
glutSpecialFunc(SpecialKey);
|
||||||
|
|||||||
@@ -15,10 +15,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -85,9 +83,9 @@ Redisplay(void)
|
|||||||
RotateVerts(Zrot, 3, TriVerts, v);
|
RotateVerts(Zrot, 3, TriVerts, v);
|
||||||
ComputeBounds(3, v, &xmin, &ymin, &xmax, &ymax);
|
ComputeBounds(3, v, &xmin, &ymin, &xmax, &ymax);
|
||||||
|
|
||||||
glUniform2fv_func(uv0, 1, v[0]);
|
glUniform2fv(uv0, 1, v[0]);
|
||||||
glUniform2fv_func(uv1, 1, v[1]);
|
glUniform2fv(uv1, 1, v[1]);
|
||||||
glUniform2fv_func(uv2, 1, v[2]);
|
glUniform2fv(uv2, 1, v[2]);
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
@@ -132,9 +130,9 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(fragShader);
|
glDeleteShader(fragShader);
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
glDeleteProgram_func(program);
|
glDeleteProgram(program);
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,17 +194,15 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
||||||
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
uv0 = glGetUniformLocation_func(program, "v0");
|
uv0 = glGetUniformLocation(program, "v0");
|
||||||
uv1 = glGetUniformLocation_func(program, "v1");
|
uv1 = glGetUniformLocation(program, "v1");
|
||||||
uv2 = glGetUniformLocation_func(program, "v2");
|
uv2 = glGetUniformLocation(program, "v2");
|
||||||
printf("Uniforms: %d %d %d\n", uv0, uv1, uv2);
|
printf("Uniforms: %d %d %d\n", uv0, uv1, uv2);
|
||||||
|
|
||||||
/*assert(glGetError() == 0);*/
|
/*assert(glGetError() == 0);*/
|
||||||
@@ -216,9 +212,9 @@ Init(void)
|
|||||||
|
|
||||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
assert(glIsProgram_func(program));
|
assert(glIsProgram(program));
|
||||||
assert(glIsShader_func(fragShader));
|
assert(glIsShader(fragShader));
|
||||||
assert(glIsShader_func(vertShader));
|
assert(glIsShader(vertShader));
|
||||||
|
|
||||||
glColor3f(1, 0, 0);
|
glColor3f(1, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -247,6 +243,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(WinWidth, WinHeight);
|
glutInitWindowSize(WinWidth, WinHeight);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutDisplayFunc(Redisplay);
|
glutDisplayFunc(Redisplay);
|
||||||
|
|||||||
@@ -12,10 +12,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -59,11 +57,11 @@ Redisplay(void)
|
|||||||
glFrontFace(FrontWinding);
|
glFrontFace(FrontWinding);
|
||||||
|
|
||||||
if (DetermineFacingInFragProg) {
|
if (DetermineFacingInFragProg) {
|
||||||
glUniform1i_func(u_fragface, 1);
|
glUniform1i(u_fragface, 1);
|
||||||
glDisable(GL_VERTEX_PROGRAM_TWO_SIDE);
|
glDisable(GL_VERTEX_PROGRAM_TWO_SIDE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
glUniform1i_func(u_fragface, 0);
|
glUniform1i(u_fragface, 0);
|
||||||
glEnable(GL_VERTEX_PROGRAM_TWO_SIDE);
|
glEnable(GL_VERTEX_PROGRAM_TWO_SIDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +73,7 @@ Redisplay(void)
|
|||||||
/* Draw a tristrip ring */
|
/* Draw a tristrip ring */
|
||||||
glBegin(GL_TRIANGLE_STRIP);
|
glBegin(GL_TRIANGLE_STRIP);
|
||||||
glColor4fv(Red);
|
glColor4fv(Red);
|
||||||
glSecondaryColor3fv_func(Green);
|
glSecondaryColor3fv(Green);
|
||||||
for (i = 0; i <= sections; i++) {
|
for (i = 0; i <= sections; i++) {
|
||||||
float a = (float) i / (sections) * M_PI * 2.0;
|
float a = (float) i / (sections) * M_PI * 2.0;
|
||||||
float x = radius * cos(a);
|
float x = radius * cos(a);
|
||||||
@@ -125,9 +123,9 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(fragShader);
|
glDeleteShader(fragShader);
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
glDeleteProgram_func(program);
|
glDeleteProgram(program);
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,15 +227,13 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
|
||||||
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
u_fragface = glGetUniformLocation_func(program, "fragface");
|
u_fragface = glGetUniformLocation(program, "fragface");
|
||||||
printf("Uniforms: %d\n", u_fragface);
|
printf("Uniforms: %d\n", u_fragface);
|
||||||
|
|
||||||
/*assert(glGetError() == 0);*/
|
/*assert(glGetError() == 0);*/
|
||||||
@@ -246,9 +242,9 @@ Init(void)
|
|||||||
|
|
||||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
assert(glIsProgram_func(program));
|
assert(glIsProgram(program));
|
||||||
assert(glIsShader_func(fragShader));
|
assert(glIsShader(fragShader));
|
||||||
assert(glIsShader_func(vertShader));
|
assert(glIsShader(vertShader));
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
@@ -293,6 +289,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(WinWidth, WinHeight);
|
glutInitWindowSize(WinWidth, WinHeight);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutDisplayFunc(Redisplay);
|
glutDisplayFunc(Redisplay);
|
||||||
|
|||||||
@@ -11,10 +11,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -58,14 +56,14 @@ Redisplay(void)
|
|||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
/* render with vertex shader only */
|
/* render with vertex shader only */
|
||||||
glUseProgram_func(VertProgram);
|
glUseProgram(VertProgram);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(-1.5, 0, 0);
|
glTranslatef(-1.5, 0, 0);
|
||||||
DrawQuadTex();
|
DrawQuadTex();
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
/* render with fragment shader only */
|
/* render with fragment shader only */
|
||||||
glUseProgram_func(FragProgram);
|
glUseProgram(FragProgram);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(+1.5, 0, 0);
|
glTranslatef(+1.5, 0, 0);
|
||||||
DrawQuadColor();
|
DrawQuadColor();
|
||||||
@@ -90,10 +88,10 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(FragShader);
|
glDeleteShader(FragShader);
|
||||||
glDeleteShader_func(VertShader);
|
glDeleteShader(VertShader);
|
||||||
glDeleteProgram_func(VertProgram);
|
glDeleteProgram(VertProgram);
|
||||||
glDeleteProgram_func(FragProgram);
|
glDeleteProgram(FragProgram);
|
||||||
glutDestroyWindow(Win);
|
glutDestroyWindow(Win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,8 +127,6 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
if (FragProgFile)
|
if (FragProgFile)
|
||||||
FragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
FragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
|
||||||
else
|
else
|
||||||
@@ -149,10 +145,10 @@ Init(void)
|
|||||||
|
|
||||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
assert(glIsProgram_func(VertProgram));
|
assert(glIsProgram(VertProgram));
|
||||||
assert(glIsProgram_func(FragProgram));
|
assert(glIsProgram(FragProgram));
|
||||||
assert(glIsShader_func(FragShader));
|
assert(glIsShader(FragShader));
|
||||||
assert(glIsShader_func(VertShader));
|
assert(glIsShader(VertShader));
|
||||||
|
|
||||||
glColor3f(1, 0, 0);
|
glColor3f(1, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -181,6 +177,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(400, 200);
|
glutInitWindowSize(400, 200);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
Win = glutCreateWindow(argv[0]);
|
Win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutDisplayFunc(Redisplay);
|
glutDisplayFunc(Redisplay);
|
||||||
|
|||||||
@@ -9,10 +9,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -133,9 +131,9 @@ Reshape(int width, int height)
|
|||||||
static void
|
static void
|
||||||
CleanUp(void)
|
CleanUp(void)
|
||||||
{
|
{
|
||||||
glDeleteShader_func(fragShader);
|
glDeleteShader(fragShader);
|
||||||
glDeleteShader_func(vertShader);
|
glDeleteShader(vertShader);
|
||||||
glDeleteProgram_func(program);
|
glDeleteProgram(program);
|
||||||
glutDestroyWindow(win);
|
glutDestroyWindow(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,13 +237,11 @@ Init(void)
|
|||||||
if (!ShadersSupported())
|
if (!ShadersSupported())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
GetExtensionFuncs();
|
|
||||||
|
|
||||||
vertShader = CompileShaderText(GL_VERTEX_SHADER, VertShaderText);
|
vertShader = CompileShaderText(GL_VERTEX_SHADER, VertShaderText);
|
||||||
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, FragShaderText);
|
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, FragShaderText);
|
||||||
program = LinkShaders(vertShader, fragShader);
|
program = LinkShaders(vertShader, fragShader);
|
||||||
|
|
||||||
glUseProgram_func(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
assert(glGetError() == 0);
|
assert(glGetError() == 0);
|
||||||
|
|
||||||
@@ -266,6 +262,7 @@ main(int argc, char *argv[])
|
|||||||
glutInitWindowSize(500, 500);
|
glutInitWindowSize(500, 500);
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
win = glutCreateWindow(argv[0]);
|
win = glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
glutReshapeFunc(Reshape);
|
glutReshapeFunc(Reshape);
|
||||||
glutKeyboardFunc(Key);
|
glutKeyboardFunc(Key);
|
||||||
glutSpecialFunc(SpecialKey);
|
glutSpecialFunc(SpecialKey);
|
||||||
|
|||||||
8
progs/tests/.gitignore
vendored
8
progs/tests/.gitignore
vendored
@@ -5,6 +5,7 @@ arbfpspec
|
|||||||
arbfptest1
|
arbfptest1
|
||||||
arbfptexture
|
arbfptexture
|
||||||
arbfptrig
|
arbfptrig
|
||||||
|
arbgpuprog
|
||||||
arbnpot
|
arbnpot
|
||||||
arbnpot-mipmap
|
arbnpot-mipmap
|
||||||
arbvptest1
|
arbvptest1
|
||||||
@@ -38,6 +39,7 @@ fptest1
|
|||||||
fptexture
|
fptexture
|
||||||
getprocaddress
|
getprocaddress
|
||||||
getproclist.h
|
getproclist.h
|
||||||
|
getteximage
|
||||||
glutfx
|
glutfx
|
||||||
interleave
|
interleave
|
||||||
invert
|
invert
|
||||||
@@ -49,12 +51,15 @@ mapvbo
|
|||||||
minmag
|
minmag
|
||||||
mipgen
|
mipgen
|
||||||
mipmap_comp
|
mipmap_comp
|
||||||
|
mipmap_comp_tests
|
||||||
mipmap_limits
|
mipmap_limits
|
||||||
mipmap_view
|
mipmap_view
|
||||||
multipal
|
multipal
|
||||||
no_s3tc
|
no_s3tc
|
||||||
packedpixels
|
packedpixels
|
||||||
|
persp_hint
|
||||||
pbo
|
pbo
|
||||||
|
prim
|
||||||
prog_parameter
|
prog_parameter
|
||||||
quads
|
quads
|
||||||
random
|
random
|
||||||
@@ -62,6 +67,8 @@ readrate
|
|||||||
readtex.c
|
readtex.c
|
||||||
readtex.h
|
readtex.h
|
||||||
rubberband
|
rubberband
|
||||||
|
scissor
|
||||||
|
scissor-viewport
|
||||||
seccolor
|
seccolor
|
||||||
shader_api
|
shader_api
|
||||||
shaderutil.c
|
shaderutil.c
|
||||||
@@ -75,6 +82,7 @@ subtex
|
|||||||
subtexrate
|
subtexrate
|
||||||
tex1d
|
tex1d
|
||||||
texcompress2
|
texcompress2
|
||||||
|
texcompsub
|
||||||
texdown
|
texdown
|
||||||
texfilt
|
texfilt
|
||||||
texline
|
texline
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ SOURCES = \
|
|||||||
minmag.c \
|
minmag.c \
|
||||||
mipgen.c \
|
mipgen.c \
|
||||||
mipmap_comp.c \
|
mipmap_comp.c \
|
||||||
|
mipmap_comp_tests.c \
|
||||||
mipmap_limits.c \
|
mipmap_limits.c \
|
||||||
mipmap_view.c \
|
mipmap_view.c \
|
||||||
multipal.c \
|
multipal.c \
|
||||||
@@ -70,6 +71,8 @@ SOURCES = \
|
|||||||
random.c \
|
random.c \
|
||||||
readrate.c \
|
readrate.c \
|
||||||
rubberband.c \
|
rubberband.c \
|
||||||
|
scissor.c \
|
||||||
|
scissor-viewport.c \
|
||||||
seccolor.c \
|
seccolor.c \
|
||||||
shader_api.c \
|
shader_api.c \
|
||||||
sharedtex.c \
|
sharedtex.c \
|
||||||
@@ -81,6 +84,7 @@ SOURCES = \
|
|||||||
subtexrate.c \
|
subtexrate.c \
|
||||||
tex1d.c \
|
tex1d.c \
|
||||||
texcompress2.c \
|
texcompress2.c \
|
||||||
|
texcompsub.c \
|
||||||
texdown \
|
texdown \
|
||||||
texfilt.c \
|
texfilt.c \
|
||||||
texline.c \
|
texline.c \
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ progs = [
|
|||||||
'minmag',
|
'minmag',
|
||||||
'mipgen',
|
'mipgen',
|
||||||
'mipmap_comp',
|
'mipmap_comp',
|
||||||
|
'mipmap_comp_tests',
|
||||||
'mipmap_limits',
|
'mipmap_limits',
|
||||||
'mipmap_view',
|
'mipmap_view',
|
||||||
'multipal',
|
'multipal',
|
||||||
@@ -95,6 +96,8 @@ progs = [
|
|||||||
'random',
|
'random',
|
||||||
'readrate',
|
'readrate',
|
||||||
'rubberband',
|
'rubberband',
|
||||||
|
'scissor',
|
||||||
|
'scissor-viewport',
|
||||||
'seccolor',
|
'seccolor',
|
||||||
'shader_api',
|
'shader_api',
|
||||||
'stencil_twoside',
|
'stencil_twoside',
|
||||||
@@ -106,6 +109,7 @@ progs = [
|
|||||||
'tex1d',
|
'tex1d',
|
||||||
'texcmp',
|
'texcmp',
|
||||||
'texcompress2',
|
'texcompress2',
|
||||||
|
'texcompsub',
|
||||||
'texdown',
|
'texdown',
|
||||||
'texfilt',
|
'texfilt',
|
||||||
'texgenmix',
|
'texgenmix',
|
||||||
|
|||||||
318
progs/tests/mipmap_comp_tests.c
Normal file
318
progs/tests/mipmap_comp_tests.c
Normal file
@@ -0,0 +1,318 @@
|
|||||||
|
/* Copyright (c) Mark J. Kilgard, 1994. */
|
||||||
|
/*
|
||||||
|
* (c) Copyright 1993, Silicon Graphics, Inc.
|
||||||
|
* ALL RIGHTS RESERVED
|
||||||
|
* Permission to use, copy, modify, and distribute this software for
|
||||||
|
* any purpose and without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice appear in all copies and that both the copyright notice
|
||||||
|
* and this permission notice appear in supporting documentation, and that
|
||||||
|
* the name of Silicon Graphics, Inc. not be used in advertising
|
||||||
|
* or publicity pertaining to distribution of the software without specific,
|
||||||
|
* written prior permission.
|
||||||
|
*
|
||||||
|
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
||||||
|
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
||||||
|
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
||||||
|
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
||||||
|
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
||||||
|
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
||||||
|
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
||||||
|
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
* US Government Users Restricted Rights
|
||||||
|
* Use, duplication, or disclosure by the Government is subject to
|
||||||
|
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
||||||
|
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
||||||
|
* clause at DFARS 252.227-7013 and/or in similar or successor
|
||||||
|
* clauses in the FAR or the DOD or NASA FAR Supplement.
|
||||||
|
* Unpublished-- rights reserved under the copyright laws of the
|
||||||
|
* United States. Contractor/manufacturer is Silicon Graphics,
|
||||||
|
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
||||||
|
*
|
||||||
|
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* mipmap_comp
|
||||||
|
* Test compressed texture mipmaps
|
||||||
|
*
|
||||||
|
* Based on mipmap_limits
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
#include "readtex.h"
|
||||||
|
|
||||||
|
#define SIZE 16 /* not larger then 16 */
|
||||||
|
|
||||||
|
static GLint BaseLevel = 0, MaxLevel ;
|
||||||
|
static GLfloat MinLod, MaxLod;
|
||||||
|
static GLfloat LodBias;
|
||||||
|
static GLboolean NearestFilter;
|
||||||
|
static GLuint texImage;
|
||||||
|
static GLuint View;
|
||||||
|
|
||||||
|
struct view {
|
||||||
|
GLfloat minLod;
|
||||||
|
GLfloat maxLod;
|
||||||
|
const char *string;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct view views[] =
|
||||||
|
{
|
||||||
|
{ 0, 0, "Green" },
|
||||||
|
{ 0, 1, "Green, Red" },
|
||||||
|
{ 0, 2, "Green, Red, Blue" },
|
||||||
|
{ 0, 3, "Green, Red, Blue, Black" },
|
||||||
|
{ 0, 4, "Green, Red, Blue, Black, White" },
|
||||||
|
{ 1, 4, "Red, Blue, Black, White" },
|
||||||
|
{ 2, 4, "Blue, Black, White" },
|
||||||
|
{ 3, 4, "Black, White" },
|
||||||
|
{ 4, 4, "White" },
|
||||||
|
{ 3, 3, "Black" },
|
||||||
|
{ 2, 2, "Blue" },
|
||||||
|
{ 1, 1, "Red" },
|
||||||
|
{ 1, 3, "Red, Blue, Black" },
|
||||||
|
{ 1, 2, "Red, Blue" },
|
||||||
|
{ 2, 3, "Blue, Black" },
|
||||||
|
{ 0, 0, NULL },
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
initValues(void)
|
||||||
|
{
|
||||||
|
View = 12;
|
||||||
|
BaseLevel = 0;
|
||||||
|
MaxLevel = 9;
|
||||||
|
MinLod = views[View].minLod;
|
||||||
|
MaxLod = views[View].maxLod;
|
||||||
|
LodBias = 5.0;
|
||||||
|
NearestFilter = GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
changeView(void)
|
||||||
|
{
|
||||||
|
if (views[++View].string == NULL)
|
||||||
|
View = 0;
|
||||||
|
|
||||||
|
MinLod = views[View].minLod;
|
||||||
|
MaxLod = views[View].maxLod;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
makeImage(int level, int width, int height)
|
||||||
|
{
|
||||||
|
GLubyte img[SIZE*SIZE*3];
|
||||||
|
GLubyte color[5][3] = {
|
||||||
|
{ 0, 255, 0 },
|
||||||
|
{ 255, 0, 0 },
|
||||||
|
{ 0, 0, 255 },
|
||||||
|
{ 0, 0, 0 },
|
||||||
|
{ 255, 255, 255 },
|
||||||
|
};
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for (i = 0; i < height; i++) {
|
||||||
|
for (j = 0; j < width; j++) {
|
||||||
|
int k = (i * width + j) * 3;
|
||||||
|
img[k + 0] = color[level][0];
|
||||||
|
img[k + 1] = color[level][1];
|
||||||
|
img[k + 2] = color[level][2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, level,
|
||||||
|
GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
||||||
|
width, height, 0,
|
||||||
|
GL_RGB, GL_UNSIGNED_BYTE, img);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
makeImages(void)
|
||||||
|
{
|
||||||
|
int i, sz;
|
||||||
|
|
||||||
|
for (i = 0, sz = SIZE; sz >= 1; i++, sz /= 2) {
|
||||||
|
makeImage(i, sz, sz);
|
||||||
|
printf("Level %d size: %d x %d\n", i, sz, sz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
myInit(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
initValues();
|
||||||
|
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glDepthFunc(GL_LESS);
|
||||||
|
glShadeModel(GL_FLAT);
|
||||||
|
|
||||||
|
glTranslatef(0.0, 0.0, -3.6);
|
||||||
|
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
glGenTextures(1, &texImage);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texImage);
|
||||||
|
makeImages();
|
||||||
|
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
display(void)
|
||||||
|
{
|
||||||
|
GLfloat tcm = 1.0;
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texImage);
|
||||||
|
|
||||||
|
printf("BASE_LEVEL=%d MAX_LEVEL=%d MIN_LOD=%.2g MAX_LOD=%.2g Bias=%.2g Filter=%s\n",
|
||||||
|
BaseLevel, MaxLevel, MinLod, MaxLod, LodBias,
|
||||||
|
NearestFilter ? "NEAREST" : "LINEAR");
|
||||||
|
printf("You should see: %s\n", views[View].string );
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, BaseLevel);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, MaxLevel);
|
||||||
|
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, MinLod);
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, MaxLod);
|
||||||
|
|
||||||
|
if (NearestFilter) {
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||||
|
GL_NEAREST_MIPMAP_NEAREST);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||||
|
GL_LINEAR_MIPMAP_LINEAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, LodBias);
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0);
|
||||||
|
glTexCoord2f(0.0, tcm); glVertex3f(-2.0, 1.0, 0.0);
|
||||||
|
glTexCoord2f(tcm * 3000.0, tcm); glVertex3f(3000.0, 1.0, -6000.0);
|
||||||
|
glTexCoord2f(tcm * 3000.0, 0.0); glVertex3f(3000.0, -1.0, -6000.0);
|
||||||
|
glEnd();
|
||||||
|
glFlush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
myReshape(int w, int h)
|
||||||
|
{
|
||||||
|
glViewport(0, 0, w, h);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30000.0);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
key(unsigned char k, int x, int y)
|
||||||
|
{
|
||||||
|
(void) x;
|
||||||
|
(void) y;
|
||||||
|
switch (k) {
|
||||||
|
#if 0
|
||||||
|
case 'b':
|
||||||
|
BaseLevel--;
|
||||||
|
if (BaseLevel < 0)
|
||||||
|
BaseLevel = 0;
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
BaseLevel++;
|
||||||
|
if (BaseLevel > 10)
|
||||||
|
BaseLevel = 10;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
MaxLevel--;
|
||||||
|
if (MaxLevel < 0)
|
||||||
|
MaxLevel = 0;
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
MaxLevel++;
|
||||||
|
if (MaxLevel > 10)
|
||||||
|
MaxLevel = 10;
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
LodBias -= 0.25;
|
||||||
|
break;
|
||||||
|
case 'L':
|
||||||
|
LodBias += 0.25;
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
MinLod -= 0.25;
|
||||||
|
break;
|
||||||
|
case 'N':
|
||||||
|
MinLod += 0.25;
|
||||||
|
break;
|
||||||
|
case 'x':
|
||||||
|
MaxLod -= 0.25;
|
||||||
|
break;
|
||||||
|
case 'X':
|
||||||
|
MaxLod += 0.25;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
NearestFilter = !NearestFilter;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
case ' ':
|
||||||
|
initValues();
|
||||||
|
break;
|
||||||
|
case 27: /* Escape */
|
||||||
|
exit(0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
changeView();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
glutPostRedisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
printf("usage:\n");
|
||||||
|
printf(" Any Change view\n");
|
||||||
|
printf(" SPACE reset values\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
|
||||||
|
glutInitWindowSize (600, 600);
|
||||||
|
glutCreateWindow (argv[0]);
|
||||||
|
glewInit();
|
||||||
|
myInit();
|
||||||
|
glutReshapeFunc (myReshape);
|
||||||
|
glutDisplayFunc(display);
|
||||||
|
glutKeyboardFunc(key);
|
||||||
|
usage();
|
||||||
|
glutMainLoop();
|
||||||
|
return 0; /* ANSI C requires main to return int. */
|
||||||
|
}
|
||||||
138
progs/tests/scissor-viewport.c
Normal file
138
progs/tests/scissor-viewport.c
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||||
|
* Copyright (c) 2009 VMware, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and
|
||||||
|
* its documentation for any purpose is hereby granted without fee, provided
|
||||||
|
* that (i) the above copyright notices and this permission notice appear in
|
||||||
|
* all copies of the software and related documentation, and (ii) the name of
|
||||||
|
* Silicon Graphics may not be used in any advertising or
|
||||||
|
* publicity relating to the software without the specific, prior written
|
||||||
|
* permission of Silicon Graphics.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||||
|
* ANY KIND,
|
||||||
|
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||||
|
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||||
|
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||||
|
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
struct program
|
||||||
|
{
|
||||||
|
unsigned width;
|
||||||
|
unsigned height;
|
||||||
|
int i;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct program prog;
|
||||||
|
|
||||||
|
static void init(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||||
|
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||||
|
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||||
|
fflush(stderr);
|
||||||
|
|
||||||
|
prog.i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void reshape(int width, int height)
|
||||||
|
{
|
||||||
|
glViewport(0, 0, 100, 100);
|
||||||
|
|
||||||
|
prog.width = width;
|
||||||
|
prog.height = height;
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void key(unsigned char key, int x, int y)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case 27:
|
||||||
|
exit(1);
|
||||||
|
default:
|
||||||
|
glutPostRedisplay();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void drawQuad(void)
|
||||||
|
{
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glVertex2d(-1.0, -1.0);
|
||||||
|
glVertex2d( 1.0, -1.0);
|
||||||
|
glVertex2d( 1.0, 1.0);
|
||||||
|
glVertex2d(-1.0, 1.0);
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void draw(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
i = prog.i++;
|
||||||
|
if (prog.i >= 3)
|
||||||
|
prog.i = 0;
|
||||||
|
|
||||||
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
|
{
|
||||||
|
glColor4d(1.0, 0.0, 0.0, 1.0);
|
||||||
|
|
||||||
|
glScissor(i, i, 10 - 2*i, 10 - 2*i);
|
||||||
|
drawQuad();
|
||||||
|
}
|
||||||
|
|
||||||
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
|
//glutSwapBuffers();
|
||||||
|
glFlush();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLenum type;
|
||||||
|
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
|
prog.width = 200;
|
||||||
|
prog.height = 200;
|
||||||
|
|
||||||
|
glutInitWindowPosition(100, 0);
|
||||||
|
glutInitWindowSize(prog.width, prog.height);
|
||||||
|
|
||||||
|
//type = GLUT_RGB | GLUT_DOUBLE;
|
||||||
|
type = GLUT_RGB | GLUT_SINGLE;
|
||||||
|
glutInitDisplayMode(type);
|
||||||
|
|
||||||
|
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
glutReshapeFunc(reshape);
|
||||||
|
glutKeyboardFunc(key);
|
||||||
|
glutDisplayFunc(draw);
|
||||||
|
glutMainLoop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
168
progs/tests/scissor.c
Normal file
168
progs/tests/scissor.c
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||||
|
* Copyright (c) 2009 VMware, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and
|
||||||
|
* its documentation for any purpose is hereby granted without fee, provided
|
||||||
|
* that (i) the above copyright notices and this permission notice appear in
|
||||||
|
* all copies of the software and related documentation, and (ii) the name of
|
||||||
|
* Silicon Graphics may not be used in any advertising or
|
||||||
|
* publicity relating to the software without the specific, prior written
|
||||||
|
* permission of Silicon Graphics.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||||
|
* ANY KIND,
|
||||||
|
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||||
|
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||||
|
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||||
|
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
struct program
|
||||||
|
{
|
||||||
|
unsigned width;
|
||||||
|
unsigned height;
|
||||||
|
unsigned quads;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct program prog;
|
||||||
|
|
||||||
|
static void init(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||||
|
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||||
|
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||||
|
fflush(stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void reshape(int width, int height)
|
||||||
|
{
|
||||||
|
|
||||||
|
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||||
|
|
||||||
|
prog.width = width;
|
||||||
|
prog.height = height;
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void key(unsigned char key, int x, int y)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case 27:
|
||||||
|
exit(1);
|
||||||
|
default:
|
||||||
|
prog.quads = !prog.quads;
|
||||||
|
glutPostRedisplay();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void drawQuad(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (prog.quads) {
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glVertex2d(-1.0, -1.0);
|
||||||
|
glVertex2d( 1.0, -1.0);
|
||||||
|
glVertex2d( 1.0, 1.0);
|
||||||
|
glVertex2d(-1.0, 1.0);
|
||||||
|
glEnd();
|
||||||
|
} else {
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void draw(void)
|
||||||
|
{
|
||||||
|
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
printf("drawing with %s\n", prog.quads ? "quads" : "clears");
|
||||||
|
|
||||||
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
|
{
|
||||||
|
glClearColor(1.0, 0.0, 0.0, 1.0);
|
||||||
|
glColor4d(1.0, 0.0, 0.0, 1.0);
|
||||||
|
|
||||||
|
glScissor(1, 1, 10, 10);
|
||||||
|
drawQuad();
|
||||||
|
glScissor(1, prog.height - 11, 10, 10);
|
||||||
|
drawQuad();
|
||||||
|
glScissor(prog.width - 11, prog.height - 11, 10, 10);
|
||||||
|
drawQuad();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
glClearColor(0.0, 1.0, 0.0, 1.0);
|
||||||
|
glColor4d(0.0, 1.0, 0.0, 1.0);
|
||||||
|
|
||||||
|
glScissor(12, 1, 10, 10);
|
||||||
|
drawQuad();
|
||||||
|
glScissor(12, prog.height - 11, 10, 10);
|
||||||
|
drawQuad();
|
||||||
|
glScissor(prog.width - 22, prog.height - 11, 10, 10);
|
||||||
|
drawQuad();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
glClearColor(1.0, 1.0, 0.0, 1.0);
|
||||||
|
glColor4d(1.0, 1.0, 0.0, 1.0);
|
||||||
|
|
||||||
|
glScissor(1, 12, 10, 10);
|
||||||
|
drawQuad();
|
||||||
|
glScissor(1, prog.height - 22, 10, 10);
|
||||||
|
drawQuad();
|
||||||
|
glScissor(prog.width - 11, prog.height - 22, 10, 10);
|
||||||
|
drawQuad();
|
||||||
|
}
|
||||||
|
|
||||||
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
|
//glutSwapBuffers();
|
||||||
|
glFlush();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLenum type;
|
||||||
|
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
|
prog.width = 200;
|
||||||
|
prog.height = 200;
|
||||||
|
|
||||||
|
glutInitWindowPosition(100, 0);
|
||||||
|
glutInitWindowSize(prog.width, prog.height);
|
||||||
|
|
||||||
|
//type = GLUT_RGB | GLUT_DOUBLE;
|
||||||
|
type = GLUT_RGB | GLUT_SINGLE;
|
||||||
|
glutInitDisplayMode(type);
|
||||||
|
|
||||||
|
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
glutReshapeFunc(reshape);
|
||||||
|
glutKeyboardFunc(key);
|
||||||
|
glutDisplayFunc(draw);
|
||||||
|
glutMainLoop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
4100
progs/tests/texcomp_image.h
Normal file
4100
progs/tests/texcomp_image.h
Normal file
File diff suppressed because it is too large
Load Diff
165
progs/tests/texcompsub.c
Normal file
165
progs/tests/texcompsub.c
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
/*
|
||||||
|
* Test texture compression.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
#include "texcomp_image.h"
|
||||||
|
|
||||||
|
static int ImgWidth = 512;
|
||||||
|
static int ImgHeight = 512;
|
||||||
|
static GLenum CompFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||||
|
static GLfloat EyeDist = 5.0;
|
||||||
|
static GLfloat Rot = 0.0;
|
||||||
|
const GLenum Target = GL_TEXTURE_2D;
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
CheckError(int line)
|
||||||
|
{
|
||||||
|
GLenum err = glGetError();
|
||||||
|
if (err) {
|
||||||
|
printf("GL Error %d at line %d\n", (int) err, line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
LoadCompressedImage(void)
|
||||||
|
{
|
||||||
|
const GLenum filter = GL_LINEAR;
|
||||||
|
glTexImage2D(Target, 0, CompFormat, ImgWidth, ImgHeight, 0,
|
||||||
|
GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
|
||||||
|
/* bottom half */
|
||||||
|
glCompressedTexSubImage2DARB(Target, 0,
|
||||||
|
0, 0, /* pos */
|
||||||
|
ImgWidth, ImgHeight / 2,
|
||||||
|
CompFormat, ImgSize / 2, ImgData + ImgSize / 2);
|
||||||
|
/* top half */
|
||||||
|
glCompressedTexSubImage2DARB(Target, 0,
|
||||||
|
0, ImgHeight / 2, /* pos */
|
||||||
|
ImgWidth, ImgHeight / 2,
|
||||||
|
CompFormat, ImgSize / 2, ImgData);
|
||||||
|
|
||||||
|
glTexParameteri(Target, GL_TEXTURE_MIN_FILTER, filter);
|
||||||
|
glTexParameteri(Target, GL_TEXTURE_MAG_FILTER, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
Init()
|
||||||
|
{
|
||||||
|
GLint numFormats, formats[100];
|
||||||
|
GLint p;
|
||||||
|
|
||||||
|
if (!glutExtensionSupported("GL_ARB_texture_compression")) {
|
||||||
|
printf("Sorry, GL_ARB_texture_compression is required.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (!glutExtensionSupported("GL_EXT_texture_compression_s3tc")) {
|
||||||
|
printf("Sorry, GL_EXT_texture_compression_s3tc is required.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||||
|
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
|
glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, &numFormats);
|
||||||
|
glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS_ARB, formats);
|
||||||
|
printf("%d supported compression formats: ", numFormats);
|
||||||
|
for (p = 0; p < numFormats; p++)
|
||||||
|
printf("0x%x ", formats[p]);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
LoadCompressedImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
Reshape( int width, int height )
|
||||||
|
{
|
||||||
|
glViewport( 0, 0, width, height );
|
||||||
|
glMatrixMode( GL_PROJECTION );
|
||||||
|
glLoadIdentity();
|
||||||
|
glFrustum(-1, 1, -1, 1, 4, 100);
|
||||||
|
glMatrixMode( GL_MODELVIEW );
|
||||||
|
glLoadIdentity();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
Key( unsigned char key, int x, int y )
|
||||||
|
{
|
||||||
|
(void) x;
|
||||||
|
(void) y;
|
||||||
|
switch (key) {
|
||||||
|
case 'd':
|
||||||
|
EyeDist -= 1.0;
|
||||||
|
if (EyeDist < 4.0)
|
||||||
|
EyeDist = 4.0;
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
EyeDist += 1.0;
|
||||||
|
break;
|
||||||
|
case 'z':
|
||||||
|
Rot += 5.0;
|
||||||
|
break;
|
||||||
|
case 'Z':
|
||||||
|
Rot -= 5.0;
|
||||||
|
break;
|
||||||
|
case 27:
|
||||||
|
exit(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
glutPostRedisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
Draw( void )
|
||||||
|
{
|
||||||
|
glClearColor(0.3, 0.3, .8, 0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
CheckError(__LINE__);
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(0, 0, -(EyeDist+0.01));
|
||||||
|
glRotatef(Rot, 0, 0, 1);
|
||||||
|
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();
|
||||||
|
|
||||||
|
glutSwapBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main( int argc, char *argv[] )
|
||||||
|
{
|
||||||
|
glutInit( &argc, argv );
|
||||||
|
glutInitWindowSize( 600, 600 );
|
||||||
|
|
||||||
|
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE);
|
||||||
|
|
||||||
|
glutCreateWindow(argv[0]);
|
||||||
|
glewInit();
|
||||||
|
|
||||||
|
glutReshapeFunc( Reshape );
|
||||||
|
glutKeyboardFunc( Key );
|
||||||
|
glutDisplayFunc( Draw );
|
||||||
|
|
||||||
|
Init();
|
||||||
|
|
||||||
|
glutMainLoop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -21,7 +21,7 @@ static void Display(void)
|
|||||||
GLfloat min, max;
|
GLfloat min, max;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
glClearColor(0.5, 0.5, 0.5, 0);
|
glClearColor(0.5, 0.5, 0.5, 1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
/* draw a sphere */
|
/* draw a sphere */
|
||||||
@@ -82,7 +82,7 @@ static void Key(unsigned char key, int x, int y)
|
|||||||
|
|
||||||
static void Init(void)
|
static void Init(void)
|
||||||
{
|
{
|
||||||
const GLfloat blue[4] = {.1, .1, 1.0, 0.0};
|
const GLfloat blue[4] = {.1, .1, 1.0, 1.0};
|
||||||
const GLfloat gray[4] = {0.2, 0.2, 0.2, 1.0};
|
const GLfloat gray[4] = {0.2, 0.2, 0.2, 1.0};
|
||||||
const GLfloat white[4] = {1.0, 1.0, 1.0, 1.0};
|
const GLfloat white[4] = {1.0, 1.0, 1.0, 1.0};
|
||||||
const GLfloat pos[4] = {0, 0, 10, 0};
|
const GLfloat pos[4] = {0, 0, 10, 0};
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ SOURCES = \
|
|||||||
clear-random.c \
|
clear-random.c \
|
||||||
clear.c \
|
clear.c \
|
||||||
dlist-dangling.c \
|
dlist-dangling.c \
|
||||||
|
dlist-flat-tri.c \
|
||||||
|
dlist-mat-tri.c \
|
||||||
|
dlist-tri-flat-tri.c \
|
||||||
|
dlist-tri-mat-tri.c \
|
||||||
|
dlist-recursive-call.c \
|
||||||
|
dlist-begin-call-end.c \
|
||||||
dlist-edgeflag-dangling.c \
|
dlist-edgeflag-dangling.c \
|
||||||
dlist-edgeflag.c \
|
dlist-edgeflag.c \
|
||||||
dlist-degenerate.c \
|
dlist-degenerate.c \
|
||||||
@@ -105,6 +111,7 @@ SOURCES = \
|
|||||||
tri-fp.c \
|
tri-fp.c \
|
||||||
tri-fp-const-imm.c \
|
tri-fp-const-imm.c \
|
||||||
tri-lit.c \
|
tri-lit.c \
|
||||||
|
tri-lit-material.c \
|
||||||
tri-mask-tri.c \
|
tri-mask-tri.c \
|
||||||
tri-orig.c \
|
tri-orig.c \
|
||||||
tri-query.c \
|
tri-query.c \
|
||||||
|
|||||||
159
progs/trivial/dlist-begin-call-end.c
Normal file
159
progs/trivial/dlist-begin-call-end.c
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and
|
||||||
|
* its documentation for any purpose is hereby granted without fee, provided
|
||||||
|
* that (i) the above copyright notices and this permission notice appear in
|
||||||
|
* all copies of the software and related documentation, and (ii) the name of
|
||||||
|
* Silicon Graphics may not be used in any advertising or
|
||||||
|
* publicity relating to the software without the specific, prior written
|
||||||
|
* permission of Silicon Graphics.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||||
|
* ANY KIND,
|
||||||
|
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||||
|
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||||
|
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||||
|
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define CI_OFFSET_1 16
|
||||||
|
#define CI_OFFSET_2 32
|
||||||
|
|
||||||
|
|
||||||
|
GLenum doubleBuffer;
|
||||||
|
GLint first_list, list;
|
||||||
|
|
||||||
|
static void Init(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||||
|
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||||
|
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||||
|
fflush(stderr);
|
||||||
|
|
||||||
|
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||||
|
|
||||||
|
/* First list will disrupt state which might potentially be
|
||||||
|
* short-circuited in calling list:
|
||||||
|
*/
|
||||||
|
first_list = glGenLists(1);
|
||||||
|
glNewList(first_list, GL_COMPILE);
|
||||||
|
// glColor3f(0,1,0);
|
||||||
|
glEndList();
|
||||||
|
|
||||||
|
|
||||||
|
/* List that looks like it might have redundant state:
|
||||||
|
*/
|
||||||
|
list = glGenLists(1);
|
||||||
|
glNewList(list, GL_COMPILE);
|
||||||
|
|
||||||
|
glShadeModel(GL_FLAT);
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glColor3f(1,0,0);
|
||||||
|
glVertex3f( -0.9, 0.9, -30.0);
|
||||||
|
glVertex3f( -0.9, -0.9, -30.0);
|
||||||
|
glCallList( first_list );
|
||||||
|
glVertex3f( 0.9, 0.0, -30.0);
|
||||||
|
glEnd();
|
||||||
|
glEndList();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Reshape(int width, int height)
|
||||||
|
{
|
||||||
|
|
||||||
|
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Key(unsigned char key, int x, int y)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case 27:
|
||||||
|
exit(1);
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
glutPostRedisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void Draw(void)
|
||||||
|
{
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glShadeModel( GL_SMOOTH );
|
||||||
|
glCallList(list);
|
||||||
|
|
||||||
|
glFlush();
|
||||||
|
|
||||||
|
if (doubleBuffer) {
|
||||||
|
glutSwapBuffers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GLenum Args(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLint i;
|
||||||
|
|
||||||
|
doubleBuffer = GL_FALSE;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
if (strcmp(argv[i], "-sb") == 0) {
|
||||||
|
doubleBuffer = GL_FALSE;
|
||||||
|
} else if (strcmp(argv[i], "-db") == 0) {
|
||||||
|
doubleBuffer = GL_TRUE;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLenum type;
|
||||||
|
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
|
if (Args(argc, argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||||
|
|
||||||
|
type = GLUT_RGB | GLUT_ALPHA;
|
||||||
|
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||||
|
glutInitDisplayMode(type);
|
||||||
|
|
||||||
|
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Init();
|
||||||
|
|
||||||
|
glutReshapeFunc(Reshape);
|
||||||
|
glutKeyboardFunc(Key);
|
||||||
|
glutDisplayFunc(Draw);
|
||||||
|
glutMainLoop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
171
progs/trivial/dlist-flat-tri.c
Normal file
171
progs/trivial/dlist-flat-tri.c
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and
|
||||||
|
* its documentation for any purpose is hereby granted without fee, provided
|
||||||
|
* that (i) the above copyright notices and this permission notice appear in
|
||||||
|
* all copies of the software and related documentation, and (ii) the name of
|
||||||
|
* Silicon Graphics may not be used in any advertising or
|
||||||
|
* publicity relating to the software without the specific, prior written
|
||||||
|
* permission of Silicon Graphics.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||||
|
* ANY KIND,
|
||||||
|
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||||
|
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||||
|
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||||
|
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define CI_OFFSET_1 16
|
||||||
|
#define CI_OFFSET_2 32
|
||||||
|
|
||||||
|
|
||||||
|
GLenum doubleBuffer;
|
||||||
|
GLint list;
|
||||||
|
|
||||||
|
static void Init(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||||
|
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||||
|
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||||
|
fflush(stderr);
|
||||||
|
|
||||||
|
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||||
|
|
||||||
|
list = glGenLists(1);
|
||||||
|
glNewList(list, GL_COMPILE);
|
||||||
|
|
||||||
|
/* XXX: this state-change will only be executed if list is called
|
||||||
|
* from outside a begin/end pair:
|
||||||
|
*/
|
||||||
|
glShadeModel( GL_FLAT );
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glColor3f(0,0,.7);
|
||||||
|
glVertex3f( -0.9, 0.9, -30.0);
|
||||||
|
glColor3f(0,.9,0);
|
||||||
|
glVertex3f( -0.9, -0.9, -30.0);
|
||||||
|
glColor3f(.8,0,0);
|
||||||
|
glVertex3f( 0.9, 0.0, -30.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
/* This statechange is potentially NOT redundant:
|
||||||
|
*/
|
||||||
|
glShadeModel( GL_FLAT );
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glColor3f(0,1,0);
|
||||||
|
glVertex3f( -0.5, 0.5, -30.0);
|
||||||
|
glColor3f(0,0,1);
|
||||||
|
glVertex3f( -0.5, -0.5, -30.0);
|
||||||
|
glColor3f(1,0,0);
|
||||||
|
glVertex3f( 0.5, 0.0, -30.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glEndList();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Reshape(int width, int height)
|
||||||
|
{
|
||||||
|
|
||||||
|
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Key(unsigned char key, int x, int y)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case 27:
|
||||||
|
exit(1);
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
glutPostRedisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void Draw(void)
|
||||||
|
{
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glShadeModel( GL_SMOOTH );
|
||||||
|
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
|
||||||
|
/* Note: call the list from inside a begin/end pair. The end is
|
||||||
|
* provided by the display list...
|
||||||
|
*/
|
||||||
|
glCallList(list);
|
||||||
|
|
||||||
|
glFlush();
|
||||||
|
|
||||||
|
if (doubleBuffer) {
|
||||||
|
glutSwapBuffers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GLenum Args(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLint i;
|
||||||
|
|
||||||
|
doubleBuffer = GL_FALSE;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
if (strcmp(argv[i], "-sb") == 0) {
|
||||||
|
doubleBuffer = GL_FALSE;
|
||||||
|
} else if (strcmp(argv[i], "-db") == 0) {
|
||||||
|
doubleBuffer = GL_TRUE;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLenum type;
|
||||||
|
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
|
if (Args(argc, argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||||
|
|
||||||
|
type = GLUT_RGB | GLUT_ALPHA;
|
||||||
|
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||||
|
glutInitDisplayMode(type);
|
||||||
|
|
||||||
|
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Init();
|
||||||
|
|
||||||
|
glutReshapeFunc(Reshape);
|
||||||
|
glutKeyboardFunc(Key);
|
||||||
|
glutDisplayFunc(Draw);
|
||||||
|
glutMainLoop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
182
progs/trivial/dlist-mat-tri.c
Normal file
182
progs/trivial/dlist-mat-tri.c
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and
|
||||||
|
* its documentation for any purpose is hereby granted without fee, provided
|
||||||
|
* that (i) the above copyright notices and this permission notice appear in
|
||||||
|
* all copies of the software and related documentation, and (ii) the name of
|
||||||
|
* Silicon Graphics may not be used in any advertising or
|
||||||
|
* publicity relating to the software without the specific, prior written
|
||||||
|
* permission of Silicon Graphics.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||||
|
* ANY KIND,
|
||||||
|
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||||
|
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||||
|
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||||
|
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define CI_OFFSET_1 16
|
||||||
|
#define CI_OFFSET_2 32
|
||||||
|
|
||||||
|
|
||||||
|
GLenum doubleBuffer;
|
||||||
|
GLint list;
|
||||||
|
|
||||||
|
static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0};
|
||||||
|
static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0};
|
||||||
|
/*static GLfloat blue[4] = {0.2, 0.2, .7, 1.0};*/
|
||||||
|
|
||||||
|
static void Init(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||||
|
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||||
|
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||||
|
fflush(stderr);
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glEnable(GL_LIGHTING);
|
||||||
|
glEnable(GL_LIGHT0);
|
||||||
|
|
||||||
|
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||||
|
|
||||||
|
list = glGenLists(1);
|
||||||
|
glNewList(list, GL_COMPILE);
|
||||||
|
|
||||||
|
/* XXX: this state-change will be executed regardless of whether
|
||||||
|
* the list is called from outside a begin/end pair:
|
||||||
|
*/
|
||||||
|
glMaterialfv(GL_FRONT, GL_AMBIENT, red);
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glVertex3f( -0.9, 0.9, -30.0);
|
||||||
|
glVertex3f( -0.9, -0.9, -30.0);
|
||||||
|
glVertex3f( 0.9, 0.0, -30.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glMaterialfv(GL_FRONT, GL_DIFFUSE, red);
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glVertex3f( -0.7, 0.7, -30.0);
|
||||||
|
glVertex3f( -0.7, -0.7, -30.0);
|
||||||
|
glVertex3f( 0.7, 0.0, -30.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
/* This statechange is redundant:
|
||||||
|
*/
|
||||||
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glVertex3f( -0.5, 0.5, -30.0);
|
||||||
|
glVertex3f( -0.5, -0.5, -30.0);
|
||||||
|
glVertex3f( 0.5, 0.0, -30.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glEndList();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Reshape(int width, int height)
|
||||||
|
{
|
||||||
|
|
||||||
|
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Key(unsigned char key, int x, int y)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case 27:
|
||||||
|
exit(1);
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
glutPostRedisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void Draw(void)
|
||||||
|
{
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glShadeModel( GL_SMOOTH );
|
||||||
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
|
||||||
|
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
|
||||||
|
/* Note: call the list from inside a begin/end pair. The end is
|
||||||
|
* provided by the display list...
|
||||||
|
*/
|
||||||
|
glCallList(list);
|
||||||
|
|
||||||
|
glFlush();
|
||||||
|
|
||||||
|
if (doubleBuffer) {
|
||||||
|
glutSwapBuffers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GLenum Args(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLint i;
|
||||||
|
|
||||||
|
doubleBuffer = GL_FALSE;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
if (strcmp(argv[i], "-sb") == 0) {
|
||||||
|
doubleBuffer = GL_FALSE;
|
||||||
|
} else if (strcmp(argv[i], "-db") == 0) {
|
||||||
|
doubleBuffer = GL_TRUE;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLenum type;
|
||||||
|
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
|
if (Args(argc, argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||||
|
|
||||||
|
type = GLUT_RGB | GLUT_ALPHA;
|
||||||
|
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||||
|
glutInitDisplayMode(type);
|
||||||
|
|
||||||
|
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Init();
|
||||||
|
|
||||||
|
glutReshapeFunc(Reshape);
|
||||||
|
glutKeyboardFunc(Key);
|
||||||
|
glutDisplayFunc(Draw);
|
||||||
|
glutMainLoop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
190
progs/trivial/dlist-recursive-call.c
Normal file
190
progs/trivial/dlist-recursive-call.c
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and
|
||||||
|
* its documentation for any purpose is hereby granted without fee, provided
|
||||||
|
* that (i) the above copyright notices and this permission notice appear in
|
||||||
|
* all copies of the software and related documentation, and (ii) the name of
|
||||||
|
* Silicon Graphics may not be used in any advertising or
|
||||||
|
* publicity relating to the software without the specific, prior written
|
||||||
|
* permission of Silicon Graphics.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||||
|
* ANY KIND,
|
||||||
|
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||||
|
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||||
|
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||||
|
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define CI_OFFSET_1 16
|
||||||
|
#define CI_OFFSET_2 32
|
||||||
|
|
||||||
|
|
||||||
|
GLenum doubleBuffer;
|
||||||
|
GLint first_list, list;
|
||||||
|
|
||||||
|
static void Init(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||||
|
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||||
|
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||||
|
fflush(stderr);
|
||||||
|
|
||||||
|
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||||
|
|
||||||
|
/* First list will disrupt state which might potentially be
|
||||||
|
* short-circuited in calling list:
|
||||||
|
*/
|
||||||
|
first_list = glGenLists(1);
|
||||||
|
glNewList(first_list, GL_COMPILE);
|
||||||
|
glShadeModel( GL_SMOOTH );
|
||||||
|
glEndList();
|
||||||
|
|
||||||
|
|
||||||
|
/* List that looks like it might have redundant state:
|
||||||
|
*/
|
||||||
|
list = glGenLists(1);
|
||||||
|
glNewList(list, GL_COMPILE);
|
||||||
|
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glColor3f(0,0,.7);
|
||||||
|
glVertex3f( 0.9, -0.9, -30.0);
|
||||||
|
glColor3f(.8,0,0);
|
||||||
|
glVertex3f( 0.9, 0.9, -30.0);
|
||||||
|
glColor3f(0,.9,0);
|
||||||
|
glVertex3f(-0.9, 0.0, -30.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glShadeModel( GL_FLAT );
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glColor3f(0,0,.7);
|
||||||
|
glVertex3f( -0.9, 0.9, -30.0);
|
||||||
|
glColor3f(0,.9,0);
|
||||||
|
glVertex3f( -0.9, -0.9, -30.0);
|
||||||
|
glColor3f(.8,0,0);
|
||||||
|
glVertex3f( 0.9, 0.0, -30.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glCallList( first_list );
|
||||||
|
|
||||||
|
/* Do a quick begin/end to ensure we are not inside a dangling
|
||||||
|
* primitive from the called list:
|
||||||
|
*/
|
||||||
|
glBegin( GL_POINTS );
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
/* This statechange is NOT redundant:
|
||||||
|
*/
|
||||||
|
glShadeModel( GL_FLAT );
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glColor3f(1,0,0);
|
||||||
|
glVertex3f( -0.5, 0.5, -30.0);
|
||||||
|
glColor3f(0,1,0);
|
||||||
|
glVertex3f( -0.5, -0.5, -30.0);
|
||||||
|
glColor3f(0,0,1);
|
||||||
|
glVertex3f( 0.5, 0.0, -30.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glEndList();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Reshape(int width, int height)
|
||||||
|
{
|
||||||
|
|
||||||
|
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Key(unsigned char key, int x, int y)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case 27:
|
||||||
|
exit(1);
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
glutPostRedisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void Draw(void)
|
||||||
|
{
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glShadeModel( GL_SMOOTH );
|
||||||
|
glCallList(list);
|
||||||
|
|
||||||
|
glFlush();
|
||||||
|
|
||||||
|
if (doubleBuffer) {
|
||||||
|
glutSwapBuffers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GLenum Args(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLint i;
|
||||||
|
|
||||||
|
doubleBuffer = GL_FALSE;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
if (strcmp(argv[i], "-sb") == 0) {
|
||||||
|
doubleBuffer = GL_FALSE;
|
||||||
|
} else if (strcmp(argv[i], "-db") == 0) {
|
||||||
|
doubleBuffer = GL_TRUE;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLenum type;
|
||||||
|
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
|
if (Args(argc, argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||||
|
|
||||||
|
type = GLUT_RGB | GLUT_ALPHA;
|
||||||
|
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||||
|
glutInitDisplayMode(type);
|
||||||
|
|
||||||
|
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Init();
|
||||||
|
|
||||||
|
glutReshapeFunc(Reshape);
|
||||||
|
glutKeyboardFunc(Key);
|
||||||
|
glutDisplayFunc(Draw);
|
||||||
|
glutMainLoop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
171
progs/trivial/dlist-tri-flat-tri.c
Normal file
171
progs/trivial/dlist-tri-flat-tri.c
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and
|
||||||
|
* its documentation for any purpose is hereby granted without fee, provided
|
||||||
|
* that (i) the above copyright notices and this permission notice appear in
|
||||||
|
* all copies of the software and related documentation, and (ii) the name of
|
||||||
|
* Silicon Graphics may not be used in any advertising or
|
||||||
|
* publicity relating to the software without the specific, prior written
|
||||||
|
* permission of Silicon Graphics.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||||
|
* ANY KIND,
|
||||||
|
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||||
|
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||||
|
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||||
|
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define CI_OFFSET_1 16
|
||||||
|
#define CI_OFFSET_2 32
|
||||||
|
|
||||||
|
|
||||||
|
GLenum doubleBuffer;
|
||||||
|
GLint list;
|
||||||
|
|
||||||
|
static void Init(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||||
|
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||||
|
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||||
|
fflush(stderr);
|
||||||
|
|
||||||
|
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||||
|
|
||||||
|
list = glGenLists(1);
|
||||||
|
glNewList(list, GL_COMPILE);
|
||||||
|
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glColor3f(0,0,.7);
|
||||||
|
glVertex3f( 0.9, -0.9, -30.0);
|
||||||
|
glColor3f(.8,0,0);
|
||||||
|
glVertex3f( 0.9, 0.9, -30.0);
|
||||||
|
glColor3f(0,.9,0);
|
||||||
|
glVertex3f(-0.9, 0.0, -30.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glShadeModel( GL_FLAT );
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glColor3f(0,0,.7);
|
||||||
|
glVertex3f( -0.9, 0.9, -30.0);
|
||||||
|
glColor3f(0,.9,0);
|
||||||
|
glVertex3f( -0.9, -0.9, -30.0);
|
||||||
|
glColor3f(.8,0,0);
|
||||||
|
glVertex3f( 0.9, 0.0, -30.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
/* This statechange is redundant:
|
||||||
|
*/
|
||||||
|
glShadeModel( GL_FLAT );
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glColor3f(1,0,0);
|
||||||
|
glVertex3f( -0.5, 0.5, -30.0);
|
||||||
|
glColor3f(0,1,0);
|
||||||
|
glVertex3f( -0.5, -0.5, -30.0);
|
||||||
|
glColor3f(0,0,1);
|
||||||
|
glVertex3f( 0.5, 0.0, -30.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glEndList();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Reshape(int width, int height)
|
||||||
|
{
|
||||||
|
|
||||||
|
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Key(unsigned char key, int x, int y)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case 27:
|
||||||
|
exit(1);
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
glutPostRedisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void Draw(void)
|
||||||
|
{
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glShadeModel( GL_SMOOTH );
|
||||||
|
glCallList(list);
|
||||||
|
|
||||||
|
glFlush();
|
||||||
|
|
||||||
|
if (doubleBuffer) {
|
||||||
|
glutSwapBuffers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GLenum Args(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLint i;
|
||||||
|
|
||||||
|
doubleBuffer = GL_FALSE;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
if (strcmp(argv[i], "-sb") == 0) {
|
||||||
|
doubleBuffer = GL_FALSE;
|
||||||
|
} else if (strcmp(argv[i], "-db") == 0) {
|
||||||
|
doubleBuffer = GL_TRUE;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLenum type;
|
||||||
|
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
|
if (Args(argc, argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||||
|
|
||||||
|
type = GLUT_RGB | GLUT_ALPHA;
|
||||||
|
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||||
|
glutInitDisplayMode(type);
|
||||||
|
|
||||||
|
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Init();
|
||||||
|
|
||||||
|
glutReshapeFunc(Reshape);
|
||||||
|
glutKeyboardFunc(Key);
|
||||||
|
glutDisplayFunc(Draw);
|
||||||
|
glutMainLoop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
174
progs/trivial/dlist-tri-mat-tri.c
Normal file
174
progs/trivial/dlist-tri-mat-tri.c
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and
|
||||||
|
* its documentation for any purpose is hereby granted without fee, provided
|
||||||
|
* that (i) the above copyright notices and this permission notice appear in
|
||||||
|
* all copies of the software and related documentation, and (ii) the name of
|
||||||
|
* Silicon Graphics may not be used in any advertising or
|
||||||
|
* publicity relating to the software without the specific, prior written
|
||||||
|
* permission of Silicon Graphics.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||||
|
* ANY KIND,
|
||||||
|
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||||
|
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||||
|
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||||
|
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define CI_OFFSET_1 16
|
||||||
|
#define CI_OFFSET_2 32
|
||||||
|
|
||||||
|
|
||||||
|
GLenum doubleBuffer;
|
||||||
|
GLint list;
|
||||||
|
|
||||||
|
static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0};
|
||||||
|
static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0};
|
||||||
|
static GLfloat blue[4] = {0.2, 0.2, .9, 1.0};
|
||||||
|
|
||||||
|
static void Init(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||||
|
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||||
|
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||||
|
fflush(stderr);
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glEnable(GL_LIGHTING);
|
||||||
|
glEnable(GL_LIGHT0);
|
||||||
|
|
||||||
|
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||||
|
|
||||||
|
list = glGenLists(1);
|
||||||
|
glNewList(list, GL_COMPILE);
|
||||||
|
|
||||||
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
|
||||||
|
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glNormal3f(0,0,.7);
|
||||||
|
glVertex3f( 0.9, -0.9, -30.0);
|
||||||
|
glVertex3f( 0.9, 0.9, -30.0);
|
||||||
|
glVertex3f(-0.9, 0.0, -30.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
|
||||||
|
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glVertex3f( -0.9, 0.9, -30.0);
|
||||||
|
glVertex3f( -0.9, -0.9, -30.0);
|
||||||
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
||||||
|
glVertex3f( 0.9, 0.0, -30.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glVertex3f( -0.5, 0.5, -30.0);
|
||||||
|
glVertex3f( -0.5, -0.5, -30.0);
|
||||||
|
glVertex3f( 0.5, 0.0, -30.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glEndList();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Reshape(int width, int height)
|
||||||
|
{
|
||||||
|
|
||||||
|
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Key(unsigned char key, int x, int y)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case 27:
|
||||||
|
exit(1);
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
glutPostRedisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void Draw(void)
|
||||||
|
{
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glShadeModel( GL_SMOOTH );
|
||||||
|
glCallList(list);
|
||||||
|
|
||||||
|
glFlush();
|
||||||
|
|
||||||
|
if (doubleBuffer) {
|
||||||
|
glutSwapBuffers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GLenum Args(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLint i;
|
||||||
|
|
||||||
|
doubleBuffer = GL_FALSE;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
if (strcmp(argv[i], "-sb") == 0) {
|
||||||
|
doubleBuffer = GL_FALSE;
|
||||||
|
} else if (strcmp(argv[i], "-db") == 0) {
|
||||||
|
doubleBuffer = GL_TRUE;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLenum type;
|
||||||
|
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
|
if (Args(argc, argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||||
|
|
||||||
|
type = GLUT_RGB | GLUT_ALPHA;
|
||||||
|
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||||
|
glutInitDisplayMode(type);
|
||||||
|
|
||||||
|
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Init();
|
||||||
|
|
||||||
|
glutReshapeFunc(Reshape);
|
||||||
|
glutKeyboardFunc(Key);
|
||||||
|
glutDisplayFunc(Draw);
|
||||||
|
glutMainLoop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
149
progs/trivial/tri-lit-material.c
Normal file
149
progs/trivial/tri-lit-material.c
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and
|
||||||
|
* its documentation for any purpose is hereby granted without fee, provided
|
||||||
|
* that (i) the above copyright notices and this permission notice appear in
|
||||||
|
* all copies of the software and related documentation, and (ii) the name of
|
||||||
|
* Silicon Graphics may not be used in any advertising or
|
||||||
|
* publicity relating to the software without the specific, prior written
|
||||||
|
* permission of Silicon Graphics.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||||
|
* ANY KIND,
|
||||||
|
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||||
|
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||||
|
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||||
|
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define CI_OFFSET_1 16
|
||||||
|
#define CI_OFFSET_2 32
|
||||||
|
|
||||||
|
|
||||||
|
GLenum doubleBuffer;
|
||||||
|
|
||||||
|
static void Init(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||||
|
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||||
|
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||||
|
fflush(stderr);
|
||||||
|
|
||||||
|
glEnable(GL_LIGHTING);
|
||||||
|
glEnable(GL_LIGHT0);
|
||||||
|
|
||||||
|
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Reshape(int width, int height)
|
||||||
|
{
|
||||||
|
|
||||||
|
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Key(unsigned char key, int x, int y)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case 27:
|
||||||
|
exit(1);
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
glutPostRedisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Draw(void)
|
||||||
|
{
|
||||||
|
static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0};
|
||||||
|
static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0};
|
||||||
|
static GLfloat blue[4] = {0.2, 0.2, .9, 1.0};
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
|
||||||
|
glNormal3f(0,0,.7);
|
||||||
|
glVertex3f( 0.9, -0.9, -0.0);
|
||||||
|
|
||||||
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
|
||||||
|
glNormal3f(0,0,.8);
|
||||||
|
glVertex3f( 0.9, 0.9, -0.0);
|
||||||
|
|
||||||
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
||||||
|
glNormal3f(0,0,.9);
|
||||||
|
glVertex3f(-0.9, 0.0, -0.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glFlush();
|
||||||
|
|
||||||
|
if (doubleBuffer) {
|
||||||
|
glutSwapBuffers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GLenum Args(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLint i;
|
||||||
|
|
||||||
|
doubleBuffer = GL_FALSE;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
if (strcmp(argv[i], "-sb") == 0) {
|
||||||
|
doubleBuffer = GL_FALSE;
|
||||||
|
} else if (strcmp(argv[i], "-db") == 0) {
|
||||||
|
doubleBuffer = GL_TRUE;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLenum type;
|
||||||
|
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
|
if (Args(argc, argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||||
|
|
||||||
|
type = GLUT_RGB | GLUT_ALPHA;
|
||||||
|
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||||
|
glutInitDisplayMode(type);
|
||||||
|
|
||||||
|
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Init();
|
||||||
|
|
||||||
|
glutReshapeFunc(Reshape);
|
||||||
|
glutKeyboardFunc(Key);
|
||||||
|
glutDisplayFunc(Draw);
|
||||||
|
glutMainLoop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -86,6 +86,57 @@ static PFNGLISVERTEXARRAYAPPLEPROC glIsVertexArrayAPPLE_func = NULL;
|
|||||||
/* GL_EXT_stencil_two_side */
|
/* GL_EXT_stencil_two_side */
|
||||||
static PFNGLACTIVESTENCILFACEEXTPROC glActiveStencilFaceEXT_func = NULL;
|
static PFNGLACTIVESTENCILFACEEXTPROC glActiveStencilFaceEXT_func = NULL;
|
||||||
|
|
||||||
|
/* GL_ARB_buffer_object */
|
||||||
|
static PFNGLGENBUFFERSARBPROC glGenBuffersARB_func = NULL;
|
||||||
|
static PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB_func = NULL;
|
||||||
|
static PFNGLBINDBUFFERARBPROC glBindBufferARB_func = NULL;
|
||||||
|
static PFNGLBUFFERDATAARBPROC glBufferDataARB_func = NULL;
|
||||||
|
static PFNGLBUFFERSUBDATAARBPROC glBufferSubDataARB_func = NULL;
|
||||||
|
static PFNGLMAPBUFFERARBPROC glMapBufferARB_func = NULL;
|
||||||
|
static PFNGLUNMAPBUFFERARBPROC glUnmapBufferARB_func = NULL;
|
||||||
|
|
||||||
|
/* GL_EXT_framebuffer_object */
|
||||||
|
static PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT_func = NULL;
|
||||||
|
static PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT_func = NULL;
|
||||||
|
static PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT_func = NULL;
|
||||||
|
static PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT_func = NULL;
|
||||||
|
static PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT_func = NULL;
|
||||||
|
static PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glGetRenderbufferParameterivEXT_func = NULL;
|
||||||
|
static PFNGLISFRAMEBUFFEREXTPROC glIsFramebufferEXT_func = NULL;
|
||||||
|
static PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT_func = NULL;
|
||||||
|
static PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT_func = NULL;
|
||||||
|
static PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT_func = NULL;
|
||||||
|
static PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT_func = NULL;
|
||||||
|
static PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glFramebufferTexture1DEXT_func = NULL;
|
||||||
|
static PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT_func = NULL;
|
||||||
|
static PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT_func = NULL;
|
||||||
|
static PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT_func = NULL;
|
||||||
|
static PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT_func = NULL;
|
||||||
|
static PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT_func = NULL;
|
||||||
|
|
||||||
|
/* GL_ARB_framebuffer_object */
|
||||||
|
static PFNGLISRENDERBUFFERPROC glIsRenderbuffer_func = NULL;
|
||||||
|
static PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer_func = NULL;
|
||||||
|
static PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers_func = NULL;
|
||||||
|
static PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers_func = NULL;
|
||||||
|
static PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage_func = NULL;
|
||||||
|
static PFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv_func = NULL;
|
||||||
|
static PFNGLISFRAMEBUFFERPROC glIsFramebuffer_func = NULL;
|
||||||
|
static PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer_func = NULL;
|
||||||
|
static PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers_func = NULL;
|
||||||
|
static PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers_func = NULL;
|
||||||
|
static PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus_func = NULL;
|
||||||
|
static PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D_func = NULL;
|
||||||
|
static PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D_func = NULL;
|
||||||
|
static PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D_func = NULL;
|
||||||
|
static PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer_func = NULL;
|
||||||
|
static PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv_func = NULL;
|
||||||
|
static PFNGLGENERATEMIPMAPPROC glGenerateMipmap_func = NULL;
|
||||||
|
static PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer_func = NULL;
|
||||||
|
static PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample_func = NULL;
|
||||||
|
static PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer_func = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
GetExtensionFuncs(void)
|
GetExtensionFuncs(void)
|
||||||
@@ -173,5 +224,55 @@ GetExtensionFuncs(void)
|
|||||||
|
|
||||||
/* GL_EXT_stencil_two_side */
|
/* GL_EXT_stencil_two_side */
|
||||||
glActiveStencilFaceEXT_func = (PFNGLACTIVESTENCILFACEEXTPROC) glutGetProcAddress("glActiveStencilFaceEXT");
|
glActiveStencilFaceEXT_func = (PFNGLACTIVESTENCILFACEEXTPROC) glutGetProcAddress("glActiveStencilFaceEXT");
|
||||||
|
|
||||||
|
/* GL_ARB_vertex_buffer_object */
|
||||||
|
glGenBuffersARB_func = (PFNGLGENBUFFERSARBPROC) glutGetProcAddress("glGenBuffersARB");
|
||||||
|
glDeleteBuffersARB_func = (PFNGLDELETEBUFFERSARBPROC) glutGetProcAddress("glDeleteBuffersARB");
|
||||||
|
glBindBufferARB_func = (PFNGLBINDBUFFERARBPROC) glutGetProcAddress("glBindBufferARB");
|
||||||
|
glBufferDataARB_func = (PFNGLBUFFERDATAARBPROC) glutGetProcAddress("glBufferDataARB");
|
||||||
|
glBufferSubDataARB_func = (PFNGLBUFFERSUBDATAARBPROC) glutGetProcAddress("glBufferSubDataARB");
|
||||||
|
glMapBufferARB_func = (PFNGLMAPBUFFERARBPROC) glutGetProcAddress("glMapBufferARB");
|
||||||
|
glUnmapBufferARB_func = (PFNGLUNMAPBUFFERARBPROC) glutGetProcAddress("glUnmapBufferARB");
|
||||||
|
|
||||||
|
/* GL_EXT_framebuffer_object */
|
||||||
|
glIsRenderbufferEXT_func = (PFNGLISRENDERBUFFEREXTPROC) glutGetProcAddress("glIsRenderbufferEXT");
|
||||||
|
glBindRenderbufferEXT_func = (PFNGLBINDRENDERBUFFEREXTPROC) glutGetProcAddress("glBindRenderbufferEXT");
|
||||||
|
glDeleteRenderbuffersEXT_func = (PFNGLDELETERENDERBUFFERSEXTPROC) glutGetProcAddress("glDeleteRenderbuffersEXT");
|
||||||
|
glGenRenderbuffersEXT_func = (PFNGLGENRENDERBUFFERSEXTPROC) glutGetProcAddress("glGenRenderbuffersEXT");
|
||||||
|
glRenderbufferStorageEXT_func = (PFNGLRENDERBUFFERSTORAGEEXTPROC) glutGetProcAddress("glRenderbufferStorageEXT");
|
||||||
|
glGetRenderbufferParameterivEXT_func = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) glutGetProcAddress("glGetRenderbufferParameterivEXT");
|
||||||
|
glIsFramebufferEXT_func = (PFNGLISFRAMEBUFFEREXTPROC) glutGetProcAddress("glIsFramebufferEXT");
|
||||||
|
glBindFramebufferEXT_func = (PFNGLBINDFRAMEBUFFEREXTPROC) glutGetProcAddress("glBindFramebufferEXT");
|
||||||
|
glDeleteFramebuffersEXT_func = (PFNGLDELETEFRAMEBUFFERSEXTPROC) glutGetProcAddress("glDeleteFramebuffersEXT");
|
||||||
|
glGenFramebuffersEXT_func = (PFNGLGENFRAMEBUFFERSEXTPROC) glutGetProcAddress("glGenFramebuffersEXT");
|
||||||
|
glCheckFramebufferStatusEXT_func = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) glutGetProcAddress("glCheckFramebufferStatusEXT");
|
||||||
|
glFramebufferTexture1DEXT_func = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) glutGetProcAddress("glFramebufferTexture1DEXT");
|
||||||
|
glFramebufferTexture2DEXT_func = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) glutGetProcAddress("glFramebufferTexture2DEXT");
|
||||||
|
glFramebufferTexture3DEXT_func = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) glutGetProcAddress("glFramebufferTexture3DEXT");
|
||||||
|
glFramebufferRenderbufferEXT_func = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) glutGetProcAddress("glFramebufferRenderbufferEXT");
|
||||||
|
glGetFramebufferAttachmentParameterivEXT_func = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) glutGetProcAddress("glGetFramebufferAttachmentParameterivEXT");
|
||||||
|
glGenerateMipmapEXT_func = (PFNGLGENERATEMIPMAPEXTPROC) glutGetProcAddress("glGenerateMipmapEXT");
|
||||||
|
|
||||||
|
/* GL_ARB_framebuffer_object */
|
||||||
|
glIsRenderbuffer_func = (PFNGLISRENDERBUFFERPROC) glutGetProcAddress("glIsRenderbuffer");
|
||||||
|
glBindRenderbuffer_func = (PFNGLBINDRENDERBUFFERPROC) glutGetProcAddress("glBindRenderbuffer");
|
||||||
|
glDeleteRenderbuffers_func = (PFNGLDELETERENDERBUFFERSPROC) glutGetProcAddress("glDeleteRenderbuffers");
|
||||||
|
glGenRenderbuffers_func = (PFNGLGENRENDERBUFFERSPROC) glutGetProcAddress("glGenRenderbuffers");
|
||||||
|
glRenderbufferStorage_func = (PFNGLRENDERBUFFERSTORAGEPROC) glutGetProcAddress("glRenderbufferStorage");
|
||||||
|
glGetRenderbufferParameteriv_func = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) glutGetProcAddress("glGetRenderbufferParameteriv");
|
||||||
|
glIsFramebuffer_func = (PFNGLISFRAMEBUFFERPROC) glutGetProcAddress("glIsFramebuffer");
|
||||||
|
glBindFramebuffer_func = (PFNGLBINDFRAMEBUFFERPROC) glutGetProcAddress("glBindFramebuffer");
|
||||||
|
glDeleteFramebuffers_func = (PFNGLDELETEFRAMEBUFFERSPROC) glutGetProcAddress("glDeleteFramebuffers");
|
||||||
|
glGenFramebuffers_func = (PFNGLGENFRAMEBUFFERSPROC) glutGetProcAddress("glGenFramebuffers");
|
||||||
|
glCheckFramebufferStatus_func = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) glutGetProcAddress("glCheckFramebufferStatus");
|
||||||
|
glFramebufferTexture1D_func = (PFNGLFRAMEBUFFERTEXTURE1DPROC) glutGetProcAddress("glFramebufferTexture1D");
|
||||||
|
glFramebufferTexture2D_func = (PFNGLFRAMEBUFFERTEXTURE2DPROC) glutGetProcAddress("glFramebufferTexture2D");
|
||||||
|
glFramebufferTexture3D_func = (PFNGLFRAMEBUFFERTEXTURE3DPROC) glutGetProcAddress("glFramebufferTexture3D");
|
||||||
|
glFramebufferRenderbuffer_func = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) glutGetProcAddress("glFramebufferRenderbuffer");
|
||||||
|
glGetFramebufferAttachmentParameteriv_func = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) glutGetProcAddress("glGetFramebufferAttachmentParameteriv");
|
||||||
|
glGenerateMipmap_func = (PFNGLGENERATEMIPMAPPROC) glutGetProcAddress("glGenerateMipmap");
|
||||||
|
glBlitFramebuffer_func = (PFNGLBLITFRAMEBUFFERPROC) glutGetProcAddress("glBlitFramebuffer");
|
||||||
|
glRenderbufferStorageMultisample_func = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) glutGetProcAddress("glRenderbufferStorageMultisample");
|
||||||
|
glFramebufferTextureLayer_func = (PFNGLFRAMEBUFFERTEXTURELAYERPROC) glutGetProcAddress("glFramebufferTextureLayer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <GL/glew.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include "extfuncs.h"
|
|
||||||
#include "shaderutil.h"
|
#include "shaderutil.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -19,7 +19,6 @@ Init(void)
|
|||||||
{
|
{
|
||||||
static GLboolean firstCall = GL_TRUE;
|
static GLboolean firstCall = GL_TRUE;
|
||||||
if (firstCall) {
|
if (firstCall) {
|
||||||
GetExtensionFuncs();
|
|
||||||
firstCall = GL_FALSE;
|
firstCall = GL_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,14 +49,14 @@ CompileShaderText(GLenum shaderType, const char *text)
|
|||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
shader = glCreateShader_func(shaderType);
|
shader = glCreateShader(shaderType);
|
||||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
glShaderSource(shader, 1, (const GLchar **) &text, NULL);
|
||||||
glCompileShader_func(shader);
|
glCompileShader(shader);
|
||||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
glGetShaderiv(shader, GL_COMPILE_STATUS, &stat);
|
||||||
if (!stat) {
|
if (!stat) {
|
||||||
GLchar log[1000];
|
GLchar log[1000];
|
||||||
GLsizei len;
|
GLsizei len;
|
||||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
glGetShaderInfoLog(shader, 1000, &len, log);
|
||||||
fprintf(stderr, "Error: problem compiling shader: %s\n", log);
|
fprintf(stderr, "Error: problem compiling shader: %s\n", log);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -78,8 +77,12 @@ CompileShaderFile(GLenum shaderType, const char *filename)
|
|||||||
int n;
|
int n;
|
||||||
char *buffer = (char*) malloc(max);
|
char *buffer = (char*) malloc(max);
|
||||||
GLuint shader;
|
GLuint shader;
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
FILE *f = fopen(filename, "r");
|
Init();
|
||||||
|
|
||||||
|
|
||||||
|
f = fopen(filename, "r");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
fprintf(stderr, "Unable to open shader file %s\n", filename);
|
fprintf(stderr, "Unable to open shader file %s\n", filename);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -105,24 +108,24 @@ CompileShaderFile(GLenum shaderType, const char *filename)
|
|||||||
GLuint
|
GLuint
|
||||||
LinkShaders(GLuint vertShader, GLuint fragShader)
|
LinkShaders(GLuint vertShader, GLuint fragShader)
|
||||||
{
|
{
|
||||||
GLuint program = glCreateProgram_func();
|
GLuint program = glCreateProgram();
|
||||||
|
|
||||||
assert(vertShader || fragShader);
|
assert(vertShader || fragShader);
|
||||||
|
|
||||||
if (fragShader)
|
if (fragShader)
|
||||||
glAttachShader_func(program, fragShader);
|
glAttachShader(program, fragShader);
|
||||||
if (vertShader)
|
if (vertShader)
|
||||||
glAttachShader_func(program, vertShader);
|
glAttachShader(program, vertShader);
|
||||||
glLinkProgram_func(program);
|
glLinkProgram(program);
|
||||||
|
|
||||||
/* check link */
|
/* check link */
|
||||||
{
|
{
|
||||||
GLint stat;
|
GLint stat;
|
||||||
glGetProgramiv_func(program, GL_LINK_STATUS, &stat);
|
glGetProgramiv(program, GL_LINK_STATUS, &stat);
|
||||||
if (!stat) {
|
if (!stat) {
|
||||||
GLchar log[1000];
|
GLchar log[1000];
|
||||||
GLsizei len;
|
GLsizei len;
|
||||||
glGetProgramInfoLog_func(program, 1000, &len, log);
|
glGetProgramInfoLog(program, 1000, &len, log);
|
||||||
fprintf(stderr, "Shader link error:\n%s\n", log);
|
fprintf(stderr, "Shader link error:\n%s\n", log);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -139,7 +142,7 @@ InitUniforms(GLuint program, struct uniform_info uniforms[])
|
|||||||
|
|
||||||
for (i = 0; uniforms[i].name; i++) {
|
for (i = 0; uniforms[i].name; i++) {
|
||||||
uniforms[i].location
|
uniforms[i].location
|
||||||
= glGetUniformLocation_func(program, uniforms[i].name);
|
= glGetUniformLocation(program, uniforms[i].name);
|
||||||
|
|
||||||
printf("Uniform %s location: %d\n", uniforms[i].name,
|
printf("Uniform %s location: %d\n", uniforms[i].name,
|
||||||
uniforms[i].location);
|
uniforms[i].location);
|
||||||
@@ -147,19 +150,19 @@ InitUniforms(GLuint program, struct uniform_info uniforms[])
|
|||||||
switch (uniforms[i].size) {
|
switch (uniforms[i].size) {
|
||||||
case 1:
|
case 1:
|
||||||
if (uniforms[i].type == GL_INT)
|
if (uniforms[i].type == GL_INT)
|
||||||
glUniform1i_func(uniforms[i].location,
|
glUniform1i(uniforms[i].location,
|
||||||
(GLint) uniforms[i].value[0]);
|
(GLint) uniforms[i].value[0]);
|
||||||
else
|
else
|
||||||
glUniform1fv_func(uniforms[i].location, 1, uniforms[i].value);
|
glUniform1fv(uniforms[i].location, 1, uniforms[i].value);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
glUniform2fv_func(uniforms[i].location, 1, uniforms[i].value);
|
glUniform2fv(uniforms[i].location, 1, uniforms[i].value);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
glUniform3fv_func(uniforms[i].location, 1, uniforms[i].value);
|
glUniform3fv(uniforms[i].location, 1, uniforms[i].value);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
glUniform4fv_func(uniforms[i].location, 1, uniforms[i].value);
|
glUniform4fv(uniforms[i].location, 1, uniforms[i].value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ struct window {
|
|||||||
float Angle;
|
float Angle;
|
||||||
int Id;
|
int Id;
|
||||||
HGLRC sharedContext;
|
HGLRC sharedContext;
|
||||||
|
HANDLE hEventInitialised;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -414,6 +415,10 @@ threadRunner (void *arg)
|
|||||||
Error("Couldn't obtain HDC");
|
Error("Couldn't obtain HDC");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Wait for the previous thread */
|
||||||
|
if(tia->id > 0)
|
||||||
|
WaitForSingleObject(Windows[tia->id - 1].hEventInitialised, INFINITE);
|
||||||
|
|
||||||
pfd.cColorBits = 24;
|
pfd.cColorBits = 24;
|
||||||
pfd.cDepthBits = 24;
|
pfd.cDepthBits = 24;
|
||||||
pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
|
pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
|
||||||
@@ -434,9 +439,16 @@ threadRunner (void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (win->sharedContext) {
|
if (win->sharedContext) {
|
||||||
wglShareLists(win->sharedContext, win->Context);
|
if(!wglShareLists(win->sharedContext, win->Context))
|
||||||
|
Error("Couldn't share WGL context lists");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetEvent(win->hEventInitialised);
|
||||||
|
|
||||||
|
/* Wait for all threads to initialize otherwise wglShareLists will fail */
|
||||||
|
if(tia->id < NumWindows - 1)
|
||||||
|
WaitForSingleObject(Windows[NumWindows - 1].hEventInitialised, INFINITE);
|
||||||
|
|
||||||
SendMessage(win->Win, WM_SIZE, 0, 0);
|
SendMessage(win->Win, WM_SIZE, 0, 0);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
@@ -511,20 +523,26 @@ main(int argc, char *argv[])
|
|||||||
h[2] = AddWindow( 10, 350, gCtx);
|
h[2] = AddWindow( 10, 350, gCtx);
|
||||||
h[3] = AddWindow(330, 350, gCtx);
|
h[3] = AddWindow(330, 350, gCtx);
|
||||||
|
|
||||||
if (!wglMakeCurrent(gHDC, gCtx)) {
|
for (i = 0; i < NumWindows; i++) {
|
||||||
Error("wglMakeCurrent failed for init thread.");
|
Windows[i].hEventInitialised = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InitGLstuff();
|
|
||||||
|
|
||||||
for (i = 0; i < NumWindows; i++) {
|
for (i = 0; i < NumWindows; i++) {
|
||||||
DWORD id;
|
DWORD id;
|
||||||
|
|
||||||
tia[i].id = i;
|
tia[i].id = i;
|
||||||
threads[i] = CreateThread(NULL, 0, threadRunner, &tia[i], 0, &id);
|
threads[i] = CreateThread(NULL, 0, threadRunner, &tia[i], 0, &id);
|
||||||
|
|
||||||
|
WaitForSingleObject(Windows[i].hEventInitialised, INFINITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!wglMakeCurrent(gHDC, gCtx)) {
|
||||||
|
Error("wglMakeCurrent failed for init thread.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
InitGLstuff();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ struct winthread {
|
|||||||
int WinWidth, WinHeight;
|
int WinWidth, WinHeight;
|
||||||
GLboolean NewSize;
|
GLboolean NewSize;
|
||||||
HANDLE hEventInitialised;
|
HANDLE hEventInitialised;
|
||||||
|
GLboolean Initialized;
|
||||||
GLboolean MakeNewTexture;
|
GLboolean MakeNewTexture;
|
||||||
HANDLE hEventRedraw;
|
HANDLE hEventRedraw;
|
||||||
};
|
};
|
||||||
@@ -114,20 +115,20 @@ static void
|
|||||||
MakeNewTexture(struct winthread *wt)
|
MakeNewTexture(struct winthread *wt)
|
||||||
{
|
{
|
||||||
#define TEX_SIZE 128
|
#define TEX_SIZE 128
|
||||||
static float step = 0.0;
|
static float step = 0.0f;
|
||||||
GLfloat image[TEX_SIZE][TEX_SIZE][4];
|
GLfloat image[TEX_SIZE][TEX_SIZE][4];
|
||||||
GLint width;
|
GLint width;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
for (j = 0; j < TEX_SIZE; j++) {
|
for (j = 0; j < TEX_SIZE; j++) {
|
||||||
for (i = 0; i < TEX_SIZE; i++) {
|
for (i = 0; i < TEX_SIZE; i++) {
|
||||||
float dt = 5.0 * (j - 0.5 * TEX_SIZE) / TEX_SIZE;
|
float dt = 5.0f * (j - 0.5f * TEX_SIZE) / TEX_SIZE;
|
||||||
float ds = 5.0 * (i - 0.5 * TEX_SIZE) / TEX_SIZE;
|
float ds = 5.0f * (i - 0.5f * TEX_SIZE) / TEX_SIZE;
|
||||||
float r = dt * dt + ds * ds + step;
|
float r = dt * dt + ds * ds + step;
|
||||||
image[j][i][0] =
|
image[j][i][0] =
|
||||||
image[j][i][1] =
|
image[j][i][1] =
|
||||||
image[j][i][2] = 0.75 + 0.25 * cos(r);
|
image[j][i][2] = 0.75f + 0.25f * (float) cos(r);
|
||||||
image[j][i][3] = 1.0;
|
image[j][i][3] = 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +160,7 @@ static void
|
|||||||
draw_object(void)
|
draw_object(void)
|
||||||
{
|
{
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glScalef(0.75, 0.75, 0.75);
|
glScalef(0.75f, 0.75f, 0.75f);
|
||||||
|
|
||||||
glColor3f(1, 0, 0);
|
glColor3f(1, 0, 0);
|
||||||
|
|
||||||
@@ -288,6 +289,15 @@ draw_loop(struct winthread *wt)
|
|||||||
|
|
||||||
wglMakeCurrent(wt->hDC, wt->Context);
|
wglMakeCurrent(wt->hDC, wt->Context);
|
||||||
|
|
||||||
|
if (!wt->Initialized) {
|
||||||
|
printf("wglthreads: %d: GL_RENDERER = %s\n", wt->Index,
|
||||||
|
(char *) glGetString(GL_RENDERER));
|
||||||
|
if (Texture /*&& wt->Index == 0*/) {
|
||||||
|
MakeNewTexture(wt);
|
||||||
|
}
|
||||||
|
wt->Initialized = GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (Locking)
|
if (Locking)
|
||||||
LeaveCriticalSection(&Mutex);
|
LeaveCriticalSection(&Mutex);
|
||||||
|
|
||||||
@@ -315,13 +325,15 @@ draw_loop(struct winthread *wt)
|
|||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glRotatef(wt->Angle, 0, 1, 0);
|
glRotatef(wt->Angle, 0, 1, 0);
|
||||||
glRotatef(wt->Angle, 1, 0, 0);
|
glRotatef(wt->Angle, 1, 0, 0);
|
||||||
glScalef(0.7, 0.7, 0.7);
|
glScalef(0.7f, 0.7f, 0.7f);
|
||||||
draw_object();
|
draw_object();
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
if (Locking)
|
if (Locking)
|
||||||
EnterCriticalSection(&Mutex);
|
EnterCriticalSection(&Mutex);
|
||||||
|
|
||||||
SwapBuffers(wt->hDC);
|
SwapBuffers(wt->hDC);
|
||||||
|
|
||||||
if (Locking)
|
if (Locking)
|
||||||
LeaveCriticalSection(&Mutex);
|
LeaveCriticalSection(&Mutex);
|
||||||
|
|
||||||
@@ -433,7 +445,7 @@ create_window(struct winthread *wt, HGLRC shareCtx)
|
|||||||
win = CreateWindowEx(0,
|
win = CreateWindowEx(0,
|
||||||
wc.lpszClassName,
|
wc.lpszClassName,
|
||||||
"wglthreads",
|
"wglthreads",
|
||||||
WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
|
WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TILEDWINDOW,
|
||||||
xpos,
|
xpos,
|
||||||
ypos,
|
ypos,
|
||||||
width,
|
width,
|
||||||
@@ -471,7 +483,8 @@ create_window(struct winthread *wt, HGLRC shareCtx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shareCtx) {
|
if (shareCtx) {
|
||||||
wglShareLists(shareCtx, ctx);
|
if(!wglShareLists(shareCtx, ctx))
|
||||||
|
Error("Couldn't share WGL context lists");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save the info for this window/context */
|
/* save the info for this window/context */
|
||||||
@@ -482,14 +495,6 @@ create_window(struct winthread *wt, HGLRC shareCtx)
|
|||||||
wt->WinWidth = width;
|
wt->WinWidth = width;
|
||||||
wt->WinHeight = height;
|
wt->WinHeight = height;
|
||||||
wt->NewSize = GL_TRUE;
|
wt->NewSize = GL_TRUE;
|
||||||
|
|
||||||
wglMakeCurrent(hdc, ctx);
|
|
||||||
printf("wglthreads: %d: GL_RENDERER = %s\n", wt->Index, (char *) glGetString(GL_RENDERER));
|
|
||||||
wglMakeCurrent(NULL, NULL);
|
|
||||||
|
|
||||||
if (Texture/* && wt->Index == 0*/) {
|
|
||||||
MakeNewTexture(wt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -502,10 +507,22 @@ ThreadProc(void *p)
|
|||||||
struct winthread *wt = (struct winthread *) p;
|
struct winthread *wt = (struct winthread *) p;
|
||||||
HGLRC share;
|
HGLRC share;
|
||||||
|
|
||||||
|
/* Wait for the previous thread */
|
||||||
|
if(Texture && wt->Index > 0) {
|
||||||
|
WaitForSingleObject(WinThreads[wt->Index - 1].hEventInitialised, INFINITE);
|
||||||
|
share = WinThreads[0].Context;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
share = 0;
|
||||||
|
|
||||||
share = (Texture && wt->Index > 0) ? WinThreads[0].Context : 0;
|
share = (Texture && wt->Index > 0) ? WinThreads[0].Context : 0;
|
||||||
create_window(wt, share);
|
create_window(wt, share);
|
||||||
SetEvent(wt->hEventInitialised);
|
SetEvent(wt->hEventInitialised);
|
||||||
|
|
||||||
|
/* Wait for all threads to initialize otherwise wglShareLists will fail */
|
||||||
|
if(wt->Index < NumWinThreads - 1)
|
||||||
|
WaitForSingleObject(WinThreads[NumWinThreads - 1].hEventInitialised, INFINITE);
|
||||||
|
|
||||||
draw_loop(wt);
|
draw_loop(wt);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -539,6 +556,7 @@ main(int argc, char *argv[])
|
|||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (strcmp(argv[i], "-h") == 0) {
|
if (strcmp(argv[i], "-h") == 0) {
|
||||||
usage();
|
usage();
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[i], "-l") == 0) {
|
else if (strcmp(argv[i], "-l") == 0) {
|
||||||
Locking = 1;
|
Locking = 1;
|
||||||
@@ -588,13 +606,17 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
printf("wglthreads: creating threads\n");
|
printf("wglthreads: creating threads\n");
|
||||||
|
|
||||||
|
/* Create the events */
|
||||||
|
for (i = 0; i < NumWinThreads; i++) {
|
||||||
|
WinThreads[i].Index = i;
|
||||||
|
WinThreads[i].hEventInitialised = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
WinThreads[i].hEventRedraw = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* Create the threads */
|
/* Create the threads */
|
||||||
for (i = 0; i < NumWinThreads; i++) {
|
for (i = 0; i < NumWinThreads; i++) {
|
||||||
DWORD id;
|
DWORD id;
|
||||||
|
|
||||||
WinThreads[i].Index = i;
|
|
||||||
WinThreads[i].hEventInitialised = CreateEvent(NULL, TRUE, FALSE, NULL);
|
|
||||||
WinThreads[i].hEventRedraw = CreateEvent(NULL, FALSE, FALSE, NULL);
|
|
||||||
WinThreads[i].Thread = CreateThread(NULL,
|
WinThreads[i].Thread = CreateThread(NULL,
|
||||||
0,
|
0,
|
||||||
ThreadProc,
|
ThreadProc,
|
||||||
@@ -603,8 +625,6 @@ main(int argc, char *argv[])
|
|||||||
&id);
|
&id);
|
||||||
printf("wglthreads: Created thread %p\n", (void *) WinThreads[i].Thread);
|
printf("wglthreads: Created thread %p\n", (void *) WinThreads[i].Thread);
|
||||||
|
|
||||||
WaitForSingleObject(WinThreads[i].hEventInitialised, INFINITE);
|
|
||||||
|
|
||||||
threads[i] = WinThreads[i].Thread;
|
threads[i] = WinThreads[i].Thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
* -p Open a display connection for each thread
|
* -p Open a display connection for each thread
|
||||||
* -l Enable application-side locking
|
* -l Enable application-side locking
|
||||||
* -n <num threads> Number of threads to create (default is 2)
|
* -n <num threads> Number of threads to create (default is 2)
|
||||||
* -display <display name> Specify X display (default is :0.0)
|
* -display <display name> Specify X display (default is $DISPLAY)
|
||||||
* -t Use texture mapping
|
* -t Use texture mapping
|
||||||
*
|
*
|
||||||
* Brian Paul 20 July 2000
|
* Brian Paul 20 July 2000
|
||||||
@@ -573,7 +573,7 @@ usage(void)
|
|||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *displayName = ":0.0";
|
char *displayName = NULL;
|
||||||
int numThreads = 2;
|
int numThreads = 2;
|
||||||
Display *dpy = NULL;
|
Display *dpy = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -20,16 +20,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is a port of the infamous "gears" demo to straight GLX (i.e. no GLUT)
|
* Version of glxgears that creates/destroys the rendering context for each
|
||||||
* Port by Brian Paul 23 March 2001
|
* frame. Also periodically destroy/recreate the window.
|
||||||
|
* Good for finding memory leaks, etc.
|
||||||
*
|
*
|
||||||
* Command line options:
|
* Command line options:
|
||||||
* -info print GL implementation information
|
* -info print GL implementation information
|
||||||
* -stereo use stereo enabled GLX visual
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -92,13 +93,8 @@ static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
|
|||||||
static GLint gear1, gear2, gear3;
|
static GLint gear1, gear2, gear3;
|
||||||
static GLfloat angle = 0.0;
|
static GLfloat angle = 0.0;
|
||||||
|
|
||||||
static GLboolean fullscreen = GL_FALSE; /* Create a single fullscreen window */
|
static XVisualInfo *visinfo = NULL;
|
||||||
static GLboolean stereo = GL_FALSE; /* Enable stereo. */
|
static int WinWidth = 300, WinHeight = 300;
|
||||||
static GLfloat eyesep = 5.0; /* Eye separation. */
|
|
||||||
static GLfloat fix_point = 40.0; /* Fixation point distance. */
|
|
||||||
static GLfloat left, right, asp; /* Stereo frustum params. */
|
|
||||||
|
|
||||||
XVisualInfo *visinfo;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -272,22 +268,13 @@ do_draw(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* new window size or exposure */
|
/* new window size or exposure */
|
||||||
static void
|
static void
|
||||||
reshape(int width, int height)
|
reshape(int width, int height)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||||
|
|
||||||
if (stereo) {
|
{
|
||||||
GLfloat w;
|
|
||||||
|
|
||||||
asp = (GLfloat) height / (GLfloat) width;
|
|
||||||
w = fix_point * (1.0 / 5.0);
|
|
||||||
|
|
||||||
left = -5.0 * ((w - 0.5 * eyesep) / fix_point);
|
|
||||||
right = 5.0 * ((w + 0.5 * eyesep) / fix_point);
|
|
||||||
} else {
|
|
||||||
GLfloat h = (GLfloat) height / (GLfloat) width;
|
GLfloat h = (GLfloat) height / (GLfloat) width;
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
@@ -301,7 +288,6 @@ reshape(int width, int height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init(void)
|
init(void)
|
||||||
{
|
{
|
||||||
@@ -354,36 +340,9 @@ draw( Display *dpy, Window win )
|
|||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
if (stereo) {
|
reshape(WinWidth, WinHeight);
|
||||||
/* First left eye. */
|
|
||||||
glDrawBuffer(GL_BACK_LEFT);
|
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
do_draw();
|
||||||
glLoadIdentity();
|
|
||||||
glFrustum(left, right, -asp, asp, 5.0, 60.0);
|
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslated(+0.5 * eyesep, 0.0, 0.0);
|
|
||||||
do_draw();
|
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
/* Then right eye. */
|
|
||||||
glDrawBuffer(GL_BACK_RIGHT);
|
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glLoadIdentity();
|
|
||||||
glFrustum(-right, -left, -asp, asp, 5.0, 60.0);
|
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslated(-0.5 * eyesep, 0.0, 0.0);
|
|
||||||
do_draw();
|
|
||||||
glPopMatrix();
|
|
||||||
} else
|
|
||||||
do_draw();
|
|
||||||
|
|
||||||
glDeleteLists(gear1, 1);
|
glDeleteLists(gear1, 1);
|
||||||
glDeleteLists(gear2, 1);
|
glDeleteLists(gear2, 1);
|
||||||
@@ -410,14 +369,6 @@ make_window( Display *dpy, const char *name,
|
|||||||
GLX_DOUBLEBUFFER,
|
GLX_DOUBLEBUFFER,
|
||||||
GLX_DEPTH_SIZE, 1,
|
GLX_DEPTH_SIZE, 1,
|
||||||
None };
|
None };
|
||||||
int stereoAttribs[] = { GLX_RGBA,
|
|
||||||
GLX_RED_SIZE, 1,
|
|
||||||
GLX_GREEN_SIZE, 1,
|
|
||||||
GLX_BLUE_SIZE, 1,
|
|
||||||
GLX_DOUBLEBUFFER,
|
|
||||||
GLX_DEPTH_SIZE, 1,
|
|
||||||
GLX_STEREO,
|
|
||||||
None };
|
|
||||||
int scrnum;
|
int scrnum;
|
||||||
XSetWindowAttributes attr;
|
XSetWindowAttributes attr;
|
||||||
unsigned long mask;
|
unsigned long mask;
|
||||||
@@ -427,22 +378,9 @@ make_window( Display *dpy, const char *name,
|
|||||||
scrnum = DefaultScreen( dpy );
|
scrnum = DefaultScreen( dpy );
|
||||||
root = RootWindow( dpy, scrnum );
|
root = RootWindow( dpy, scrnum );
|
||||||
|
|
||||||
if (fullscreen) {
|
visinfo = glXChooseVisual( dpy, scrnum, attribs );
|
||||||
x = 0; y = 0;
|
|
||||||
width = DisplayWidth( dpy, scrnum );
|
|
||||||
height = DisplayHeight( dpy, scrnum );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stereo)
|
|
||||||
visinfo = glXChooseVisual( dpy, scrnum, stereoAttribs );
|
|
||||||
else
|
|
||||||
visinfo = glXChooseVisual( dpy, scrnum, attribs );
|
|
||||||
if (!visinfo) {
|
if (!visinfo) {
|
||||||
if (stereo) {
|
printf("Error: couldn't get an RGB, Double-buffered visual\n");
|
||||||
printf("Error: couldn't get an RGB, "
|
|
||||||
"Double-buffered, Stereo visual\n");
|
|
||||||
} else
|
|
||||||
printf("Error: couldn't get an RGB, Double-buffered visual\n");
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,7 +389,7 @@ make_window( Display *dpy, const char *name,
|
|||||||
attr.border_pixel = 0;
|
attr.border_pixel = 0;
|
||||||
attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
|
attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
|
||||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||||
attr.override_redirect = fullscreen;
|
attr.override_redirect = 0;
|
||||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
|
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
|
||||||
|
|
||||||
win = XCreateWindow( dpy, root, x, y, width, height,
|
win = XCreateWindow( dpy, root, x, y, width, height,
|
||||||
@@ -479,10 +417,9 @@ static void
|
|||||||
event_loop(Display *dpy)
|
event_loop(Display *dpy)
|
||||||
{
|
{
|
||||||
Window win;
|
Window win;
|
||||||
make_window(dpy, "glxgears", 0, 0, 300, 300, &win);
|
make_window(dpy, "glxgears", 0, 0, WinWidth, WinHeight, &win);
|
||||||
XMapWindow(dpy, win);
|
XMapWindow(dpy, win);
|
||||||
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
while (XPending(dpy) > 0) {
|
while (XPending(dpy) > 0) {
|
||||||
XEvent event;
|
XEvent event;
|
||||||
@@ -492,34 +429,35 @@ event_loop(Display *dpy)
|
|||||||
/* we'll redraw below */
|
/* we'll redraw below */
|
||||||
break;
|
break;
|
||||||
case ConfigureNotify:
|
case ConfigureNotify:
|
||||||
reshape(event.xconfigure.width, event.xconfigure.height);
|
WinWidth = event.xconfigure.width;
|
||||||
|
WinHeight = event.xconfigure.height;
|
||||||
break;
|
break;
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
{
|
{
|
||||||
char buffer[10];
|
char buffer[10];
|
||||||
int r, code;
|
int r, code;
|
||||||
code = XLookupKeysym(&event.xkey, 0);
|
code = XLookupKeysym(&event.xkey, 0);
|
||||||
if (code == XK_Left) {
|
if (code == XK_Left) {
|
||||||
view_roty += 5.0;
|
view_roty += 5.0;
|
||||||
}
|
}
|
||||||
else if (code == XK_Right) {
|
else if (code == XK_Right) {
|
||||||
view_roty -= 5.0;
|
view_roty -= 5.0;
|
||||||
}
|
}
|
||||||
else if (code == XK_Up) {
|
else if (code == XK_Up) {
|
||||||
view_rotx += 5.0;
|
view_rotx += 5.0;
|
||||||
}
|
}
|
||||||
else if (code == XK_Down) {
|
else if (code == XK_Down) {
|
||||||
view_rotx -= 5.0;
|
view_rotx -= 5.0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
if (buffer[0] == 27) {
|
if (buffer[0] == 27) {
|
||||||
/* escape */
|
/* escape */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,8 +489,11 @@ event_loop(Display *dpy)
|
|||||||
fps);
|
fps);
|
||||||
tRate0 = t;
|
tRate0 = t;
|
||||||
|
|
||||||
|
/* Destroy window and create new one */
|
||||||
XDestroyWindow(dpy, win);
|
XDestroyWindow(dpy, win);
|
||||||
make_window(dpy, "glxgears", (int)(fps * 100) % 100, (int)(fps * 100) % 100, 300, 300, &win);
|
make_window(dpy, "glxgears",
|
||||||
|
(int)(fps * 100) % 100, (int)(fps * 100) % 100, /* x,y */
|
||||||
|
WinWidth, WinHeight, &win);
|
||||||
XMapWindow(dpy, win);
|
XMapWindow(dpy, win);
|
||||||
|
|
||||||
frames = 0;
|
frames = 0;
|
||||||
@@ -562,7 +503,6 @@ event_loop(Display *dpy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@@ -579,12 +519,6 @@ main(int argc, char *argv[])
|
|||||||
else if (strcmp(argv[i], "-info") == 0) {
|
else if (strcmp(argv[i], "-info") == 0) {
|
||||||
printInfo = GL_TRUE;
|
printInfo = GL_TRUE;
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[i], "-stereo") == 0) {
|
|
||||||
stereo = GL_TRUE;
|
|
||||||
}
|
|
||||||
else if (strcmp(argv[i], "-fullscreen") == 0) {
|
|
||||||
fullscreen = GL_TRUE;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
printf("Warrning: unknown parameter: %s\n", argv[i]);
|
printf("Warrning: unknown parameter: %s\n", argv[i]);
|
||||||
}
|
}
|
||||||
@@ -596,7 +530,6 @@ main(int argc, char *argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (printInfo) {
|
if (printInfo) {
|
||||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||||
@@ -604,7 +537,6 @@ main(int argc, char *argv[])
|
|||||||
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
|
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
event_loop(dpy);
|
event_loop(dpy);
|
||||||
|
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
|
|||||||
@@ -39,6 +39,12 @@
|
|||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
|
|
||||||
|
#ifndef GLX_MESA_swap_control
|
||||||
|
#define GLX_MESA_swap_control 1
|
||||||
|
typedef int (*PFNGLXGETSWAPINTERVALMESAPROC)(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int is_glx_extension_supported(Display *dpy, const char *query);
|
static int is_glx_extension_supported(Display *dpy, const char *query);
|
||||||
|
|
||||||
static void query_vsync(Display *dpy);
|
static void query_vsync(Display *dpy);
|
||||||
@@ -592,31 +598,22 @@ query_vsync(Display *dpy)
|
|||||||
int interval = 0;
|
int interval = 0;
|
||||||
|
|
||||||
|
|
||||||
#ifdef GLX_MESA_swap_control
|
if (is_glx_extension_supported(dpy, "GLX_MESA_swap_control")) {
|
||||||
if ((interval <= 0)
|
|
||||||
&& is_glx_extension_supported(dpy, "GLX_MESA_swap_control")) {
|
|
||||||
PFNGLXGETSWAPINTERVALMESAPROC pglXGetSwapIntervalMESA =
|
PFNGLXGETSWAPINTERVALMESAPROC pglXGetSwapIntervalMESA =
|
||||||
(PFNGLXGETSWAPINTERVALMESAPROC)
|
(PFNGLXGETSWAPINTERVALMESAPROC)
|
||||||
glXGetProcAddressARB((const GLubyte *) "glXGetSwapIntervalMESA");
|
glXGetProcAddressARB((const GLubyte *) "glXGetSwapIntervalMESA");
|
||||||
|
|
||||||
interval = (*pglXGetSwapIntervalMESA)();
|
interval = (*pglXGetSwapIntervalMESA)();
|
||||||
|
} else if (is_glx_extension_supported(dpy, "GLX_SGI_swap_control")) {
|
||||||
|
/* The default swap interval with this extension is 1. Assume that it
|
||||||
|
* is set to the default.
|
||||||
|
*
|
||||||
|
* Many Mesa-based drivers default to 0, but all of these drivers also
|
||||||
|
* export GLX_MESA_swap_control. In that case, this branch will never
|
||||||
|
* be taken, and the correct result should be reported.
|
||||||
|
*/
|
||||||
|
interval = 1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef GLX_SGI_video_sync
|
|
||||||
if ((interval <= 0)
|
|
||||||
&& is_glx_extension_supported(dpy, "GLX_SGI_video_sync")) {
|
|
||||||
PFNGLXGETVIDEOSYNCSGIPROC pglXGetVideoSyncSGI =
|
|
||||||
(PFNGLXGETVIDEOSYNCSGIPROC)
|
|
||||||
glXGetProcAddressARB((const GLubyte *) "glXGetVideoSyncSGI");
|
|
||||||
unsigned count;
|
|
||||||
|
|
||||||
if ((*pglXGetVideoSyncSGI)(& count) == 0) {
|
|
||||||
interval = (int) count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
if (interval > 0) {
|
if (interval > 0) {
|
||||||
|
|||||||
@@ -267,7 +267,8 @@ main(int argc, char *argv[])
|
|||||||
printf(" glxheads xdisplayname ...\n");
|
printf(" glxheads xdisplayname ...\n");
|
||||||
printf("Example:\n");
|
printf("Example:\n");
|
||||||
printf(" glxheads :0 mars:0 venus:1\n");
|
printf(" glxheads :0 mars:0 venus:1\n");
|
||||||
h = AddHead(":0");
|
|
||||||
|
h = AddHead(XDisplayName(NULL));
|
||||||
if (h)
|
if (h)
|
||||||
PrintInfo(h);
|
PrintInfo(h);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -759,7 +759,7 @@ main(int argc, char *argv[])
|
|||||||
Display *dpy;
|
Display *dpy;
|
||||||
Window win;
|
Window win;
|
||||||
GLXContext ctx;
|
GLXContext ctx;
|
||||||
char *dpyName = ":0";
|
char *dpyName = NULL;
|
||||||
int swap_interval = 1;
|
int swap_interval = 1;
|
||||||
GLboolean do_swap_interval = GL_FALSE;
|
GLboolean do_swap_interval = GL_FALSE;
|
||||||
GLboolean force_get_rate = GL_FALSE;
|
GLboolean force_get_rate = GL_FALSE;
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ main(int argc, char *argv[])
|
|||||||
Display *dpy;
|
Display *dpy;
|
||||||
Window win;
|
Window win;
|
||||||
GLXContext ctx;
|
GLXContext ctx;
|
||||||
char *dpyName = ":0";
|
char *dpyName = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ def shlib_emitter(target, source, env):
|
|||||||
return (target, source)
|
return (target, source)
|
||||||
|
|
||||||
|
|
||||||
shlib_action = SCons.Action.Action(shlib_generator, generator=1)
|
shlib_action = SCons.Action.Action(shlib_generator, '$SHLINKCOMSTR', generator=1)
|
||||||
|
|
||||||
res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR')
|
res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR')
|
||||||
|
|
||||||
|
|||||||
64
scons/dxsdk.py
Normal file
64
scons/dxsdk.py
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
"""dxsdk
|
||||||
|
|
||||||
|
Tool-specific initialization for Microsoft DirectX SDK
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009 VMware, Inc.
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
# a copy of this software and associated documentation files (the
|
||||||
|
# "Software"), to deal in the Software without restriction, including
|
||||||
|
# without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
# permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
# the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included
|
||||||
|
# in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
||||||
|
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||||
|
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
import SCons.Errors
|
||||||
|
import SCons.Util
|
||||||
|
|
||||||
|
|
||||||
|
def get_dxsdk_root(env):
|
||||||
|
try:
|
||||||
|
return os.environ['DXSDK_DIR']
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def generate(env):
|
||||||
|
dxsdk_root = get_dxsdk_root(env)
|
||||||
|
if dxsdk_root is None:
|
||||||
|
# DirectX SDK not found
|
||||||
|
return
|
||||||
|
|
||||||
|
if env['machine'] in ('generic', 'x86'):
|
||||||
|
target_cpu = 'x86'
|
||||||
|
elif env['machine'] == 'x86_64':
|
||||||
|
target_cpu = 'x64'
|
||||||
|
else:
|
||||||
|
raise SCons.Errors.InternalError, "Unsupported target machine"
|
||||||
|
include_dir = 'Include'
|
||||||
|
|
||||||
|
env.Append(CPPDEFINES = [('HAVE_DXSDK', '1')])
|
||||||
|
env.Prepend(CPPPATH = [os.path.join(dxsdk_root, 'Include')])
|
||||||
|
env.Prepend(LIBPATH = [os.path.join(dxsdk_root, 'Lib', target_cpu)])
|
||||||
|
|
||||||
|
def exists(env):
|
||||||
|
return get_dxsdk_root(env) is not None
|
||||||
|
|
||||||
|
# vim:set ts=4 sw=4 et:
|
||||||
27
scons/fixes.py
Normal file
27
scons/fixes.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
# Monkey patch os.spawnve on windows to become thread safe
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
import os
|
||||||
|
import threading
|
||||||
|
from os import spawnve as old_spawnve
|
||||||
|
|
||||||
|
spawn_lock = threading.Lock()
|
||||||
|
|
||||||
|
def new_spawnve(mode, file, args, env):
|
||||||
|
spawn_lock.acquire()
|
||||||
|
try:
|
||||||
|
if mode == os.P_WAIT:
|
||||||
|
ret = old_spawnve(os.P_NOWAIT, file, args, env)
|
||||||
|
else:
|
||||||
|
ret = old_spawnve(mode, file, args, env)
|
||||||
|
finally:
|
||||||
|
spawn_lock.release()
|
||||||
|
if mode == os.P_WAIT:
|
||||||
|
pid, status = os.waitpid(ret, 0)
|
||||||
|
ret = status >> 8
|
||||||
|
return ret
|
||||||
|
|
||||||
|
os.spawnve = new_spawnve
|
||||||
|
|
||||||
|
|
||||||
@@ -38,6 +38,8 @@ import SCons.Action
|
|||||||
import SCons.Builder
|
import SCons.Builder
|
||||||
import SCons.Scanner
|
import SCons.Scanner
|
||||||
|
|
||||||
|
import fixes
|
||||||
|
|
||||||
|
|
||||||
def quietCommandLines(env):
|
def quietCommandLines(env):
|
||||||
# Quiet command lines
|
# Quiet command lines
|
||||||
@@ -318,89 +320,80 @@ def generate(env):
|
|||||||
env.Append(CPPDEFINES = cppdefines)
|
env.Append(CPPDEFINES = cppdefines)
|
||||||
|
|
||||||
# C compiler options
|
# C compiler options
|
||||||
cflags = []
|
cflags = [] # C
|
||||||
|
cxxflags = [] # C++
|
||||||
|
ccflags = [] # C & C++
|
||||||
if gcc:
|
if gcc:
|
||||||
if debug:
|
if debug:
|
||||||
cflags += ['-O0', '-g3']
|
ccflags += ['-O0', '-g3']
|
||||||
elif env['toolchain'] == 'crossmingw':
|
elif env['CCVERSION'].startswith('4.2.'):
|
||||||
cflags += ['-O0', '-g3'] # mingw 4.2.1 optimizer is broken
|
# gcc 4.2.x optimizer is broken
|
||||||
|
print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations"
|
||||||
|
ccflags += ['-O0', '-g3']
|
||||||
else:
|
else:
|
||||||
cflags += ['-O3', '-g3']
|
ccflags += ['-O3', '-g3']
|
||||||
if env['profile']:
|
if env['profile']:
|
||||||
cflags += ['-pg']
|
ccflags += ['-pg']
|
||||||
if env['machine'] == 'x86':
|
if env['machine'] == 'x86':
|
||||||
cflags += [
|
ccflags += [
|
||||||
'-m32',
|
'-m32',
|
||||||
#'-march=pentium4',
|
#'-march=pentium4',
|
||||||
'-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
|
'-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
|
||||||
#'-mfpmath=sse',
|
#'-mfpmath=sse',
|
||||||
]
|
]
|
||||||
if env['machine'] == 'x86_64':
|
if env['machine'] == 'x86_64':
|
||||||
cflags += ['-m64']
|
ccflags += ['-m64']
|
||||||
# See also:
|
# See also:
|
||||||
# - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
|
# - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
|
||||||
cflags += [
|
ccflags += [
|
||||||
'-Werror=declaration-after-statement',
|
|
||||||
'-Wall',
|
'-Wall',
|
||||||
'-Wmissing-prototypes',
|
|
||||||
'-Wmissing-field-initializers',
|
'-Wmissing-field-initializers',
|
||||||
'-Wpointer-arith',
|
'-Wpointer-arith',
|
||||||
'-Wno-long-long',
|
'-Wno-long-long',
|
||||||
'-ffast-math',
|
'-ffast-math',
|
||||||
'-std=gnu99',
|
|
||||||
'-fmessage-length=0', # be nice to Eclipse
|
'-fmessage-length=0', # be nice to Eclipse
|
||||||
]
|
]
|
||||||
|
cflags += [
|
||||||
|
'-Werror=declaration-after-statement',
|
||||||
|
'-Wmissing-prototypes',
|
||||||
|
'-std=gnu99',
|
||||||
|
]
|
||||||
if msvc:
|
if msvc:
|
||||||
# See also:
|
# See also:
|
||||||
# - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
|
# - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
|
||||||
# - cl /?
|
# - cl /?
|
||||||
if debug:
|
if debug:
|
||||||
cflags += [
|
ccflags += [
|
||||||
'/Od', # disable optimizations
|
'/Od', # disable optimizations
|
||||||
'/Oi', # enable intrinsic functions
|
'/Oi', # enable intrinsic functions
|
||||||
'/Oy-', # disable frame pointer omission
|
'/Oy-', # disable frame pointer omission
|
||||||
'/GL-', # disable whole program optimization
|
'/GL-', # disable whole program optimization
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
if env['machine'] == 'x86_64':
|
ccflags += [
|
||||||
cflags += [
|
'/O2', # optimize for speed
|
||||||
# Same as /O2, but without global optimizations or auto-inlining
|
|
||||||
# http://msdn.microsoft.com/en-us/library/8f8h5cxt.aspx
|
|
||||||
'/Ob1', # enable inline expansion, disable auto-inlining
|
|
||||||
'/Oi', # enable intrinsic functions
|
|
||||||
'/Ot', # favors fast code
|
|
||||||
'/Oy', # omit frame pointer
|
|
||||||
'/Gs', # enable stack probes
|
|
||||||
'/GF', # eliminate duplicate strings
|
|
||||||
'/Gy', # enable function-level linking
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
cflags += [
|
|
||||||
'/O2', # optimize for speed
|
|
||||||
]
|
|
||||||
cflags += [
|
|
||||||
#'/fp:fast', # fast floating point
|
#'/fp:fast', # fast floating point
|
||||||
]
|
]
|
||||||
if env['profile']:
|
if env['profile']:
|
||||||
cflags += [
|
ccflags += [
|
||||||
'/Gh', # enable _penter hook function
|
'/Gh', # enable _penter hook function
|
||||||
'/GH', # enable _pexit hook function
|
'/GH', # enable _pexit hook function
|
||||||
]
|
]
|
||||||
cflags += [
|
ccflags += [
|
||||||
'/W3', # warning level
|
'/W3', # warning level
|
||||||
#'/Wp64', # enable 64 bit porting warnings
|
#'/Wp64', # enable 64 bit porting warnings
|
||||||
]
|
]
|
||||||
if env['machine'] == 'x86':
|
if env['machine'] == 'x86':
|
||||||
cflags += [
|
ccflags += [
|
||||||
#'/QIfist', # Suppress _ftol
|
#'/QIfist', # Suppress _ftol
|
||||||
#'/arch:SSE2', # use the SSE2 instructions
|
#'/arch:SSE2', # use the SSE2 instructions
|
||||||
]
|
]
|
||||||
if platform == 'windows':
|
if platform == 'windows':
|
||||||
cflags += [
|
ccflags += [
|
||||||
# TODO
|
# TODO
|
||||||
]
|
]
|
||||||
if platform == 'winddk':
|
if platform == 'winddk':
|
||||||
cflags += [
|
ccflags += [
|
||||||
'/Zl', # omit default library name in .OBJ
|
'/Zl', # omit default library name in .OBJ
|
||||||
'/Zp8', # 8bytes struct member alignment
|
'/Zp8', # 8bytes struct member alignment
|
||||||
'/Gy', # separate functions for linker
|
'/Gy', # separate functions for linker
|
||||||
@@ -419,7 +412,7 @@ def generate(env):
|
|||||||
]
|
]
|
||||||
if platform == 'wince':
|
if platform == 'wince':
|
||||||
# See also C:\WINCE600\public\common\oak\misc\makefile.def
|
# See also C:\WINCE600\public\common\oak\misc\makefile.def
|
||||||
cflags += [
|
ccflags += [
|
||||||
'/Zl', # omit default library name in .OBJ
|
'/Zl', # omit default library name in .OBJ
|
||||||
'/GF', # enable read-only string pooling
|
'/GF', # enable read-only string pooling
|
||||||
'/GR-', # disable C++ RTTI
|
'/GR-', # disable C++ RTTI
|
||||||
@@ -436,8 +429,9 @@ def generate(env):
|
|||||||
# See http://scons.tigris.org/issues/show_bug.cgi?id=1656
|
# See http://scons.tigris.org/issues/show_bug.cgi?id=1656
|
||||||
env.EnsureSConsVersion(0, 98, 0)
|
env.EnsureSConsVersion(0, 98, 0)
|
||||||
env['PDB'] = '${TARGET.base}.pdb'
|
env['PDB'] = '${TARGET.base}.pdb'
|
||||||
|
env.Append(CCFLAGS = ccflags)
|
||||||
env.Append(CFLAGS = cflags)
|
env.Append(CFLAGS = cflags)
|
||||||
env.Append(CXXFLAGS = cflags)
|
env.Append(CXXFLAGS = cxxflags)
|
||||||
|
|
||||||
if env['platform'] == 'windows' and msvc:
|
if env['platform'] == 'windows' and msvc:
|
||||||
# Choose the appropriate MSVC CRT
|
# Choose the appropriate MSVC CRT
|
||||||
@@ -458,11 +452,15 @@ def generate(env):
|
|||||||
|
|
||||||
# Linker options
|
# Linker options
|
||||||
linkflags = []
|
linkflags = []
|
||||||
|
shlinkflags = []
|
||||||
if gcc:
|
if gcc:
|
||||||
if env['machine'] == 'x86':
|
if env['machine'] == 'x86':
|
||||||
linkflags += ['-m32']
|
linkflags += ['-m32']
|
||||||
if env['machine'] == 'x86_64':
|
if env['machine'] == 'x86_64':
|
||||||
linkflags += ['-m64']
|
linkflags += ['-m64']
|
||||||
|
shlinkflags += [
|
||||||
|
'-Wl,-Bsymbolic',
|
||||||
|
]
|
||||||
if platform == 'windows' and msvc:
|
if platform == 'windows' and msvc:
|
||||||
# See also:
|
# See also:
|
||||||
# - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
|
# - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
|
||||||
@@ -510,6 +508,7 @@ def generate(env):
|
|||||||
'/entry:_DllMainCRTStartup',
|
'/entry:_DllMainCRTStartup',
|
||||||
]
|
]
|
||||||
env.Append(LINKFLAGS = linkflags)
|
env.Append(LINKFLAGS = linkflags)
|
||||||
|
env.Append(SHLINKFLAGS = shlinkflags)
|
||||||
|
|
||||||
# Default libs
|
# Default libs
|
||||||
env.Append(LIBS = [])
|
env.Append(LIBS = [])
|
||||||
|
|||||||
@@ -416,16 +416,18 @@ def generate(env):
|
|||||||
# See also:
|
# See also:
|
||||||
# - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
|
# - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
|
||||||
ccflags += [
|
ccflags += [
|
||||||
'-Werror=declaration-after-statement',
|
|
||||||
'-Wall',
|
'-Wall',
|
||||||
'-Wmissing-prototypes',
|
|
||||||
'-Wmissing-field-initializers',
|
'-Wmissing-field-initializers',
|
||||||
'-Wpointer-arith',
|
'-Wpointer-arith',
|
||||||
'-Wno-long-long',
|
'-Wno-long-long',
|
||||||
'-ffast-math',
|
'-ffast-math',
|
||||||
'-std=gnu99',
|
|
||||||
'-fmessage-length=0', # be nice to Eclipse
|
'-fmessage-length=0', # be nice to Eclipse
|
||||||
]
|
]
|
||||||
|
cflags += [
|
||||||
|
'-Werror=declaration-after-statement',
|
||||||
|
'-Wmissing-prototypes',
|
||||||
|
'-std=gnu99',
|
||||||
|
]
|
||||||
if msvc:
|
if msvc:
|
||||||
# See also:
|
# See also:
|
||||||
# - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
|
# - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ static unsigned elt_ubyte( const void *elts, unsigned idx )
|
|||||||
|
|
||||||
static unsigned elt_vert( const void *elts, unsigned idx )
|
static unsigned elt_vert( const void *elts, unsigned idx )
|
||||||
{
|
{
|
||||||
return (const ubyte *)elts - (const ubyte *)NULL + idx;
|
/* unsigned index is packed in the pointer */
|
||||||
|
return (unsigned)(uintptr_t)elts + idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
pt_elt_func draw_pt_elt_func( struct draw_context *draw )
|
pt_elt_func draw_pt_elt_func( struct draw_context *draw )
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ int u_index_generator( unsigned hw_mask,
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
*out_generate = generate[out_idx][in_pv][out_pv][prim];
|
*out_generate = generate[out_idx][in_pv][out_pv][PIPE_PRIM_POINTS];
|
||||||
*out_prim = PIPE_PRIM_POINTS;
|
*out_prim = PIPE_PRIM_POINTS;
|
||||||
*out_nr = nr;
|
*out_nr = nr;
|
||||||
return U_TRANSLATE_ERROR;
|
return U_TRANSLATE_ERROR;
|
||||||
|
|||||||
@@ -71,6 +71,12 @@ struct pb_desc
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Size. Regular (32bit) unsigned for now.
|
||||||
|
*/
|
||||||
|
typedef unsigned pb_size;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all pb_* buffers.
|
* Base class for all pb_* buffers.
|
||||||
*/
|
*/
|
||||||
@@ -126,7 +132,7 @@ struct pb_vtbl
|
|||||||
*/
|
*/
|
||||||
void (*get_base_buffer)( struct pb_buffer *buf,
|
void (*get_base_buffer)( struct pb_buffer *buf,
|
||||||
struct pb_buffer **base_buf,
|
struct pb_buffer **base_buf,
|
||||||
unsigned *offset );
|
pb_size *offset );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -177,7 +183,7 @@ pb_unmap(struct pb_buffer *buf)
|
|||||||
static INLINE void
|
static INLINE void
|
||||||
pb_get_base_buffer( struct pb_buffer *buf,
|
pb_get_base_buffer( struct pb_buffer *buf,
|
||||||
struct pb_buffer **base_buf,
|
struct pb_buffer **base_buf,
|
||||||
unsigned *offset )
|
pb_size *offset )
|
||||||
{
|
{
|
||||||
assert(buf);
|
assert(buf);
|
||||||
if(!buf) {
|
if(!buf) {
|
||||||
@@ -241,7 +247,7 @@ pb_reference(struct pb_buffer **dst,
|
|||||||
* the requested or not.
|
* the requested or not.
|
||||||
*/
|
*/
|
||||||
static INLINE boolean
|
static INLINE boolean
|
||||||
pb_check_alignment(size_t requested, size_t provided)
|
pb_check_alignment(pb_size requested, pb_size provided)
|
||||||
{
|
{
|
||||||
if(!requested)
|
if(!requested)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -269,7 +275,7 @@ pb_check_usage(unsigned requested, unsigned provided)
|
|||||||
* hardware.
|
* hardware.
|
||||||
*/
|
*/
|
||||||
struct pb_buffer *
|
struct pb_buffer *
|
||||||
pb_malloc_buffer_create(size_t size,
|
pb_malloc_buffer_create(pb_size size,
|
||||||
const struct pb_desc *desc);
|
const struct pb_desc *desc);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -65,11 +65,11 @@ struct fenced_buffer_list
|
|||||||
|
|
||||||
struct pb_fence_ops *ops;
|
struct pb_fence_ops *ops;
|
||||||
|
|
||||||
size_t numDelayed;
|
pb_size numDelayed;
|
||||||
struct list_head delayed;
|
struct list_head delayed;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
size_t numUnfenced;
|
pb_size numUnfenced;
|
||||||
struct list_head unfenced;
|
struct list_head unfenced;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -433,7 +433,7 @@ fenced_buffer_fence(struct pb_buffer *buf,
|
|||||||
static void
|
static void
|
||||||
fenced_buffer_get_base_buffer(struct pb_buffer *buf,
|
fenced_buffer_get_base_buffer(struct pb_buffer *buf,
|
||||||
struct pb_buffer **base_buf,
|
struct pb_buffer **base_buf,
|
||||||
unsigned *offset)
|
pb_size *offset)
|
||||||
{
|
{
|
||||||
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
|
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
|
||||||
pb_get_base_buffer(fenced_buf->buffer, base_buf, offset);
|
pb_get_base_buffer(fenced_buf->buffer, base_buf, offset);
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ malloc_buffer_fence(struct pb_buffer *buf,
|
|||||||
static void
|
static void
|
||||||
malloc_buffer_get_base_buffer(struct pb_buffer *buf,
|
malloc_buffer_get_base_buffer(struct pb_buffer *buf,
|
||||||
struct pb_buffer **base_buf,
|
struct pb_buffer **base_buf,
|
||||||
unsigned *offset)
|
pb_size *offset)
|
||||||
{
|
{
|
||||||
*base_buf = buf;
|
*base_buf = buf;
|
||||||
*offset = 0;
|
*offset = 0;
|
||||||
@@ -121,7 +121,7 @@ malloc_buffer_vtbl = {
|
|||||||
|
|
||||||
|
|
||||||
struct pb_buffer *
|
struct pb_buffer *
|
||||||
pb_malloc_buffer_create(size_t size,
|
pb_malloc_buffer_create(pb_size size,
|
||||||
const struct pb_desc *desc)
|
const struct pb_desc *desc)
|
||||||
{
|
{
|
||||||
struct malloc_buffer *buf;
|
struct malloc_buffer *buf;
|
||||||
@@ -150,7 +150,7 @@ pb_malloc_buffer_create(size_t size,
|
|||||||
|
|
||||||
static struct pb_buffer *
|
static struct pb_buffer *
|
||||||
pb_malloc_bufmgr_create_buffer(struct pb_manager *mgr,
|
pb_malloc_bufmgr_create_buffer(struct pb_manager *mgr,
|
||||||
size_t size,
|
pb_size size,
|
||||||
const struct pb_desc *desc)
|
const struct pb_desc *desc)
|
||||||
{
|
{
|
||||||
return pb_malloc_buffer_create(size, desc);
|
return pb_malloc_buffer_create(size, desc);
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ struct pb_manager
|
|||||||
|
|
||||||
struct pb_buffer *
|
struct pb_buffer *
|
||||||
(*create_buffer)( struct pb_manager *mgr,
|
(*create_buffer)( struct pb_manager *mgr,
|
||||||
size_t size,
|
pb_size size,
|
||||||
const struct pb_desc *desc);
|
const struct pb_desc *desc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,7 +106,7 @@ pb_malloc_bufmgr_create(void);
|
|||||||
*/
|
*/
|
||||||
struct pb_manager *
|
struct pb_manager *
|
||||||
pool_bufmgr_create(struct pb_manager *provider,
|
pool_bufmgr_create(struct pb_manager *provider,
|
||||||
size_t n, size_t size,
|
pb_size n, pb_size size,
|
||||||
const struct pb_desc *desc);
|
const struct pb_desc *desc);
|
||||||
|
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ pool_bufmgr_create(struct pb_manager *provider,
|
|||||||
*/
|
*/
|
||||||
struct pb_manager *
|
struct pb_manager *
|
||||||
mm_bufmgr_create(struct pb_manager *provider,
|
mm_bufmgr_create(struct pb_manager *provider,
|
||||||
size_t size, size_t align2);
|
pb_size size, pb_size align2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as mm_bufmgr_create.
|
* Same as mm_bufmgr_create.
|
||||||
@@ -128,7 +128,7 @@ mm_bufmgr_create(struct pb_manager *provider,
|
|||||||
*/
|
*/
|
||||||
struct pb_manager *
|
struct pb_manager *
|
||||||
mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
|
mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
|
||||||
size_t size, size_t align2);
|
pb_size size, pb_size align2);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -136,8 +136,8 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
|
|||||||
*/
|
*/
|
||||||
struct pb_manager *
|
struct pb_manager *
|
||||||
pb_slab_manager_create(struct pb_manager *provider,
|
pb_slab_manager_create(struct pb_manager *provider,
|
||||||
size_t bufSize,
|
pb_size bufSize,
|
||||||
size_t slabSize,
|
pb_size slabSize,
|
||||||
const struct pb_desc *desc);
|
const struct pb_desc *desc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -146,9 +146,9 @@ pb_slab_manager_create(struct pb_manager *provider,
|
|||||||
*/
|
*/
|
||||||
struct pb_manager *
|
struct pb_manager *
|
||||||
pb_slab_range_manager_create(struct pb_manager *provider,
|
pb_slab_range_manager_create(struct pb_manager *provider,
|
||||||
size_t minBufSize,
|
pb_size minBufSize,
|
||||||
size_t maxBufSize,
|
pb_size maxBufSize,
|
||||||
size_t slabSize,
|
pb_size slabSize,
|
||||||
const struct pb_desc *desc);
|
const struct pb_desc *desc);
|
||||||
|
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ pb_ondemand_manager_create(struct pb_manager *provider);
|
|||||||
*/
|
*/
|
||||||
struct pb_manager *
|
struct pb_manager *
|
||||||
pb_debug_manager_create(struct pb_manager *provider,
|
pb_debug_manager_create(struct pb_manager *provider,
|
||||||
size_t underflow_size, size_t overflow_size);
|
pb_size underflow_size, pb_size overflow_size);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ pb_alt_manager(struct pb_manager *mgr)
|
|||||||
|
|
||||||
static struct pb_buffer *
|
static struct pb_buffer *
|
||||||
pb_alt_manager_create_buffer(struct pb_manager *_mgr,
|
pb_alt_manager_create_buffer(struct pb_manager *_mgr,
|
||||||
size_t size,
|
pb_size size,
|
||||||
const struct pb_desc *desc)
|
const struct pb_desc *desc)
|
||||||
{
|
{
|
||||||
struct pb_alt_manager *mgr = pb_alt_manager(_mgr);
|
struct pb_alt_manager *mgr = pb_alt_manager(_mgr);
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ struct pb_cache_manager
|
|||||||
pipe_mutex mutex;
|
pipe_mutex mutex;
|
||||||
|
|
||||||
struct list_head delayed;
|
struct list_head delayed;
|
||||||
size_t numDelayed;
|
pb_size numDelayed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ pb_cache_buffer_fence(struct pb_buffer *_buf,
|
|||||||
static void
|
static void
|
||||||
pb_cache_buffer_get_base_buffer(struct pb_buffer *_buf,
|
pb_cache_buffer_get_base_buffer(struct pb_buffer *_buf,
|
||||||
struct pb_buffer **base_buf,
|
struct pb_buffer **base_buf,
|
||||||
unsigned *offset)
|
pb_size *offset)
|
||||||
{
|
{
|
||||||
struct pb_cache_buffer *buf = pb_cache_buffer(_buf);
|
struct pb_cache_buffer *buf = pb_cache_buffer(_buf);
|
||||||
pb_get_base_buffer(buf->buffer, base_buf, offset);
|
pb_get_base_buffer(buf->buffer, base_buf, offset);
|
||||||
@@ -224,7 +224,7 @@ pb_cache_buffer_vtbl = {
|
|||||||
|
|
||||||
static INLINE boolean
|
static INLINE boolean
|
||||||
pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
|
pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
|
||||||
size_t size,
|
pb_size size,
|
||||||
const struct pb_desc *desc)
|
const struct pb_desc *desc)
|
||||||
{
|
{
|
||||||
if(buf->base.base.size < size)
|
if(buf->base.base.size < size)
|
||||||
@@ -246,7 +246,7 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
|
|||||||
|
|
||||||
static struct pb_buffer *
|
static struct pb_buffer *
|
||||||
pb_cache_manager_create_buffer(struct pb_manager *_mgr,
|
pb_cache_manager_create_buffer(struct pb_manager *_mgr,
|
||||||
size_t size,
|
pb_size size,
|
||||||
const struct pb_desc *desc)
|
const struct pb_desc *desc)
|
||||||
{
|
{
|
||||||
struct pb_cache_manager *mgr = pb_cache_manager(_mgr);
|
struct pb_cache_manager *mgr = pb_cache_manager(_mgr);
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ struct pb_debug_buffer
|
|||||||
struct pb_buffer *buffer;
|
struct pb_buffer *buffer;
|
||||||
struct pb_debug_manager *mgr;
|
struct pb_debug_manager *mgr;
|
||||||
|
|
||||||
size_t underflow_size;
|
pb_size underflow_size;
|
||||||
size_t overflow_size;
|
pb_size overflow_size;
|
||||||
|
|
||||||
struct debug_stack_frame create_backtrace[PB_DEBUG_CREATE_BACKTRACE];
|
struct debug_stack_frame create_backtrace[PB_DEBUG_CREATE_BACKTRACE];
|
||||||
|
|
||||||
@@ -91,8 +91,8 @@ struct pb_debug_manager
|
|||||||
|
|
||||||
struct pb_manager *provider;
|
struct pb_manager *provider;
|
||||||
|
|
||||||
size_t underflow_size;
|
pb_size underflow_size;
|
||||||
size_t overflow_size;
|
pb_size overflow_size;
|
||||||
|
|
||||||
pipe_mutex mutex;
|
pipe_mutex mutex;
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
@@ -124,9 +124,9 @@ static const uint8_t random_pattern[32] = {
|
|||||||
|
|
||||||
|
|
||||||
static INLINE void
|
static INLINE void
|
||||||
fill_random_pattern(uint8_t *dst, size_t size)
|
fill_random_pattern(uint8_t *dst, pb_size size)
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
pb_size i = 0;
|
||||||
while(size--) {
|
while(size--) {
|
||||||
*dst++ = random_pattern[i++];
|
*dst++ = random_pattern[i++];
|
||||||
i &= sizeof(random_pattern) - 1;
|
i &= sizeof(random_pattern) - 1;
|
||||||
@@ -135,11 +135,11 @@ fill_random_pattern(uint8_t *dst, size_t size)
|
|||||||
|
|
||||||
|
|
||||||
static INLINE boolean
|
static INLINE boolean
|
||||||
check_random_pattern(const uint8_t *dst, size_t size,
|
check_random_pattern(const uint8_t *dst, pb_size size,
|
||||||
size_t *min_ofs, size_t *max_ofs)
|
pb_size *min_ofs, pb_size *max_ofs)
|
||||||
{
|
{
|
||||||
boolean result = TRUE;
|
boolean result = TRUE;
|
||||||
size_t i;
|
pb_size i;
|
||||||
*min_ofs = size;
|
*min_ofs = size;
|
||||||
*max_ofs = 0;
|
*max_ofs = 0;
|
||||||
for(i = 0; i < size; ++i) {
|
for(i = 0; i < size; ++i) {
|
||||||
@@ -183,7 +183,7 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf)
|
|||||||
assert(map);
|
assert(map);
|
||||||
if(map) {
|
if(map) {
|
||||||
boolean underflow, overflow;
|
boolean underflow, overflow;
|
||||||
size_t min_ofs, max_ofs;
|
pb_size min_ofs, max_ofs;
|
||||||
|
|
||||||
underflow = !check_random_pattern(map, buf->underflow_size,
|
underflow = !check_random_pattern(map, buf->underflow_size,
|
||||||
&min_ofs, &max_ofs);
|
&min_ofs, &max_ofs);
|
||||||
@@ -287,7 +287,7 @@ pb_debug_buffer_unmap(struct pb_buffer *_buf)
|
|||||||
static void
|
static void
|
||||||
pb_debug_buffer_get_base_buffer(struct pb_buffer *_buf,
|
pb_debug_buffer_get_base_buffer(struct pb_buffer *_buf,
|
||||||
struct pb_buffer **base_buf,
|
struct pb_buffer **base_buf,
|
||||||
unsigned *offset)
|
pb_size *offset)
|
||||||
{
|
{
|
||||||
struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
|
struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
|
||||||
pb_get_base_buffer(buf->buffer, base_buf, offset);
|
pb_get_base_buffer(buf->buffer, base_buf, offset);
|
||||||
@@ -363,13 +363,13 @@ pb_debug_manager_dump(struct pb_debug_manager *mgr)
|
|||||||
|
|
||||||
static struct pb_buffer *
|
static struct pb_buffer *
|
||||||
pb_debug_manager_create_buffer(struct pb_manager *_mgr,
|
pb_debug_manager_create_buffer(struct pb_manager *_mgr,
|
||||||
size_t size,
|
pb_size size,
|
||||||
const struct pb_desc *desc)
|
const struct pb_desc *desc)
|
||||||
{
|
{
|
||||||
struct pb_debug_manager *mgr = pb_debug_manager(_mgr);
|
struct pb_debug_manager *mgr = pb_debug_manager(_mgr);
|
||||||
struct pb_debug_buffer *buf;
|
struct pb_debug_buffer *buf;
|
||||||
struct pb_desc real_desc;
|
struct pb_desc real_desc;
|
||||||
size_t real_size;
|
pb_size real_size;
|
||||||
|
|
||||||
buf = CALLOC_STRUCT(pb_debug_buffer);
|
buf = CALLOC_STRUCT(pb_debug_buffer);
|
||||||
if(!buf)
|
if(!buf)
|
||||||
@@ -455,7 +455,7 @@ pb_debug_manager_destroy(struct pb_manager *_mgr)
|
|||||||
|
|
||||||
struct pb_manager *
|
struct pb_manager *
|
||||||
pb_debug_manager_create(struct pb_manager *provider,
|
pb_debug_manager_create(struct pb_manager *provider,
|
||||||
size_t underflow_size, size_t overflow_size)
|
pb_size underflow_size, pb_size overflow_size)
|
||||||
{
|
{
|
||||||
struct pb_debug_manager *mgr;
|
struct pb_debug_manager *mgr;
|
||||||
|
|
||||||
@@ -485,7 +485,7 @@ pb_debug_manager_create(struct pb_manager *provider,
|
|||||||
|
|
||||||
struct pb_manager *
|
struct pb_manager *
|
||||||
pb_debug_manager_create(struct pb_manager *provider,
|
pb_debug_manager_create(struct pb_manager *provider,
|
||||||
size_t underflow_size, size_t overflow_size)
|
pb_size underflow_size, pb_size overflow_size)
|
||||||
{
|
{
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ fenced_pb_manager(struct pb_manager *mgr)
|
|||||||
|
|
||||||
static struct pb_buffer *
|
static struct pb_buffer *
|
||||||
fenced_bufmgr_create_buffer(struct pb_manager *mgr,
|
fenced_bufmgr_create_buffer(struct pb_manager *mgr,
|
||||||
size_t size,
|
pb_size size,
|
||||||
const struct pb_desc *desc)
|
const struct pb_desc *desc)
|
||||||
{
|
{
|
||||||
struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr);
|
struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr);
|
||||||
|
|||||||
@@ -55,10 +55,10 @@ struct mm_pb_manager
|
|||||||
|
|
||||||
pipe_mutex mutex;
|
pipe_mutex mutex;
|
||||||
|
|
||||||
size_t size;
|
pb_size size;
|
||||||
struct mem_block *heap;
|
struct mem_block *heap;
|
||||||
|
|
||||||
size_t align2;
|
pb_size align2;
|
||||||
|
|
||||||
struct pb_buffer *buffer;
|
struct pb_buffer *buffer;
|
||||||
void *map;
|
void *map;
|
||||||
@@ -148,7 +148,7 @@ mm_buffer_fence(struct pb_buffer *buf,
|
|||||||
static void
|
static void
|
||||||
mm_buffer_get_base_buffer(struct pb_buffer *buf,
|
mm_buffer_get_base_buffer(struct pb_buffer *buf,
|
||||||
struct pb_buffer **base_buf,
|
struct pb_buffer **base_buf,
|
||||||
unsigned *offset)
|
pb_size *offset)
|
||||||
{
|
{
|
||||||
struct mm_buffer *mm_buf = mm_buffer(buf);
|
struct mm_buffer *mm_buf = mm_buffer(buf);
|
||||||
struct mm_pb_manager *mm = mm_buf->mgr;
|
struct mm_pb_manager *mm = mm_buf->mgr;
|
||||||
@@ -170,15 +170,15 @@ mm_buffer_vtbl = {
|
|||||||
|
|
||||||
static struct pb_buffer *
|
static struct pb_buffer *
|
||||||
mm_bufmgr_create_buffer(struct pb_manager *mgr,
|
mm_bufmgr_create_buffer(struct pb_manager *mgr,
|
||||||
size_t size,
|
pb_size size,
|
||||||
const struct pb_desc *desc)
|
const struct pb_desc *desc)
|
||||||
{
|
{
|
||||||
struct mm_pb_manager *mm = mm_pb_manager(mgr);
|
struct mm_pb_manager *mm = mm_pb_manager(mgr);
|
||||||
struct mm_buffer *mm_buf;
|
struct mm_buffer *mm_buf;
|
||||||
|
|
||||||
/* We don't handle alignments larger then the one initially setup */
|
/* We don't handle alignments larger then the one initially setup */
|
||||||
assert(pb_check_alignment(desc->alignment, 1 << mm->align2));
|
assert(pb_check_alignment(desc->alignment, (pb_size)1 << mm->align2));
|
||||||
if(!pb_check_alignment(desc->alignment, 1 << mm->align2))
|
if(!pb_check_alignment(desc->alignment, (pb_size)1 << mm->align2))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pipe_mutex_lock(mm->mutex);
|
pipe_mutex_lock(mm->mutex);
|
||||||
@@ -198,10 +198,10 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
|
|||||||
|
|
||||||
mm_buf->mgr = mm;
|
mm_buf->mgr = mm;
|
||||||
|
|
||||||
mm_buf->block = u_mmAllocMem(mm->heap, size, mm->align2, 0);
|
mm_buf->block = u_mmAllocMem(mm->heap, (int)size, (int)mm->align2, 0);
|
||||||
if(!mm_buf->block) {
|
if(!mm_buf->block) {
|
||||||
debug_printf("warning: heap full\n");
|
|
||||||
#if 0
|
#if 0
|
||||||
|
debug_printf("warning: heap full\n");
|
||||||
mmDumpMemInfo(mm->heap);
|
mmDumpMemInfo(mm->heap);
|
||||||
#endif
|
#endif
|
||||||
FREE(mm_buf);
|
FREE(mm_buf);
|
||||||
@@ -210,8 +210,8 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Some sanity checks */
|
/* Some sanity checks */
|
||||||
assert(0 <= (unsigned)mm_buf->block->ofs && (unsigned)mm_buf->block->ofs < mm->size);
|
assert(0 <= (pb_size)mm_buf->block->ofs && (pb_size)mm_buf->block->ofs < mm->size);
|
||||||
assert(size <= (unsigned)mm_buf->block->size && (unsigned)mm_buf->block->ofs + (unsigned)mm_buf->block->size <= mm->size);
|
assert(size <= (pb_size)mm_buf->block->size && (pb_size)mm_buf->block->ofs + (pb_size)mm_buf->block->size <= mm->size);
|
||||||
|
|
||||||
pipe_mutex_unlock(mm->mutex);
|
pipe_mutex_unlock(mm->mutex);
|
||||||
return SUPER(mm_buf);
|
return SUPER(mm_buf);
|
||||||
@@ -245,7 +245,7 @@ mm_bufmgr_destroy(struct pb_manager *mgr)
|
|||||||
|
|
||||||
struct pb_manager *
|
struct pb_manager *
|
||||||
mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
|
mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
|
||||||
size_t size, size_t align2)
|
pb_size size, pb_size align2)
|
||||||
{
|
{
|
||||||
struct mm_pb_manager *mm;
|
struct mm_pb_manager *mm;
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
|
|||||||
if(!mm->map)
|
if(!mm->map)
|
||||||
goto failure;
|
goto failure;
|
||||||
|
|
||||||
mm->heap = u_mmInit(0, size);
|
mm->heap = u_mmInit(0, (int)size);
|
||||||
if (!mm->heap)
|
if (!mm->heap)
|
||||||
goto failure;
|
goto failure;
|
||||||
|
|
||||||
@@ -292,7 +292,7 @@ if(mm->heap)
|
|||||||
|
|
||||||
struct pb_manager *
|
struct pb_manager *
|
||||||
mm_bufmgr_create(struct pb_manager *provider,
|
mm_bufmgr_create(struct pb_manager *provider,
|
||||||
size_t size, size_t align2)
|
pb_size size, pb_size align2)
|
||||||
{
|
{
|
||||||
struct pb_buffer *buffer;
|
struct pb_buffer *buffer;
|
||||||
struct pb_manager *mgr;
|
struct pb_manager *mgr;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ struct pb_ondemand_buffer
|
|||||||
|
|
||||||
/** Real buffer */
|
/** Real buffer */
|
||||||
struct pb_buffer *buffer;
|
struct pb_buffer *buffer;
|
||||||
size_t size;
|
pb_size size;
|
||||||
struct pb_desc desc;
|
struct pb_desc desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ pb_ondemand_buffer_fence(struct pb_buffer *_buf,
|
|||||||
static void
|
static void
|
||||||
pb_ondemand_buffer_get_base_buffer(struct pb_buffer *_buf,
|
pb_ondemand_buffer_get_base_buffer(struct pb_buffer *_buf,
|
||||||
struct pb_buffer **base_buf,
|
struct pb_buffer **base_buf,
|
||||||
unsigned *offset)
|
pb_size *offset)
|
||||||
{
|
{
|
||||||
struct pb_ondemand_buffer *buf = pb_ondemand_buffer(_buf);
|
struct pb_ondemand_buffer *buf = pb_ondemand_buffer(_buf);
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ pb_ondemand_buffer_vtbl = {
|
|||||||
|
|
||||||
static struct pb_buffer *
|
static struct pb_buffer *
|
||||||
pb_ondemand_manager_create_buffer(struct pb_manager *_mgr,
|
pb_ondemand_manager_create_buffer(struct pb_manager *_mgr,
|
||||||
size_t size,
|
pb_size size,
|
||||||
const struct pb_desc *desc)
|
const struct pb_desc *desc)
|
||||||
{
|
{
|
||||||
struct pb_ondemand_manager *mgr = pb_ondemand_manager(_mgr);
|
struct pb_ondemand_manager *mgr = pb_ondemand_manager(_mgr);
|
||||||
|
|||||||
@@ -58,11 +58,11 @@ struct pool_pb_manager
|
|||||||
|
|
||||||
pipe_mutex mutex;
|
pipe_mutex mutex;
|
||||||
|
|
||||||
size_t bufSize;
|
pb_size bufSize;
|
||||||
size_t bufAlign;
|
pb_size bufAlign;
|
||||||
|
|
||||||
size_t numFree;
|
pb_size numFree;
|
||||||
size_t numTot;
|
pb_size numTot;
|
||||||
|
|
||||||
struct list_head free;
|
struct list_head free;
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ struct pool_buffer
|
|||||||
|
|
||||||
struct list_head head;
|
struct list_head head;
|
||||||
|
|
||||||
size_t start;
|
pb_size start;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ pool_buffer_fence(struct pb_buffer *buf,
|
|||||||
static void
|
static void
|
||||||
pool_buffer_get_base_buffer(struct pb_buffer *buf,
|
pool_buffer_get_base_buffer(struct pb_buffer *buf,
|
||||||
struct pb_buffer **base_buf,
|
struct pb_buffer **base_buf,
|
||||||
unsigned *offset)
|
pb_size *offset)
|
||||||
{
|
{
|
||||||
struct pool_buffer *pool_buf = pool_buffer(buf);
|
struct pool_buffer *pool_buf = pool_buffer(buf);
|
||||||
struct pool_pb_manager *pool = pool_buf->mgr;
|
struct pool_pb_manager *pool = pool_buf->mgr;
|
||||||
@@ -184,7 +184,7 @@ pool_buffer_vtbl = {
|
|||||||
|
|
||||||
static struct pb_buffer *
|
static struct pb_buffer *
|
||||||
pool_bufmgr_create_buffer(struct pb_manager *mgr,
|
pool_bufmgr_create_buffer(struct pb_manager *mgr,
|
||||||
size_t size,
|
pb_size size,
|
||||||
const struct pb_desc *desc)
|
const struct pb_desc *desc)
|
||||||
{
|
{
|
||||||
struct pool_pb_manager *pool = pool_pb_manager(mgr);
|
struct pool_pb_manager *pool = pool_pb_manager(mgr);
|
||||||
@@ -251,13 +251,13 @@ pool_bufmgr_destroy(struct pb_manager *mgr)
|
|||||||
|
|
||||||
struct pb_manager *
|
struct pb_manager *
|
||||||
pool_bufmgr_create(struct pb_manager *provider,
|
pool_bufmgr_create(struct pb_manager *provider,
|
||||||
size_t numBufs,
|
pb_size numBufs,
|
||||||
size_t bufSize,
|
pb_size bufSize,
|
||||||
const struct pb_desc *desc)
|
const struct pb_desc *desc)
|
||||||
{
|
{
|
||||||
struct pool_pb_manager *pool;
|
struct pool_pb_manager *pool;
|
||||||
struct pool_buffer *pool_buf;
|
struct pool_buffer *pool_buf;
|
||||||
size_t i;
|
pb_size i;
|
||||||
|
|
||||||
if(!provider)
|
if(!provider)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user