Compare commits

..

85 Commits

Author SHA1 Message Date
Brian Paul
b0294cbbfe added Win32 and MacOS files to tar file list 1999-12-14 20:54:24 +00:00
Brian Paul
e2ff9be0b6 disable diagnostic printf 1999-12-14 20:51:33 +00:00
Brian Paul
16283fea40 removed bad call to fxMultipassBlend 1999-12-14 19:47:25 +00:00
Brian Paul
82ba9449e1 print messages with new message() function 1999-12-14 16:23:57 +00:00
Brian Paul
2377ea9c66 added reference to INSTALL file 1999-12-14 15:12:52 +00:00
Brian Paul
ac3593ada5 changes for 3.1 1999-12-14 07:18:57 +00:00
Brian Paul
d6dd996e56 minor 3.1 changes 1999-12-14 07:17:42 +00:00
Brian Paul
cee556daea updates for 3.1 final release 1999-12-14 07:15:38 +00:00
Brian Paul
313f225a2e removed beta from version string 1999-12-13 21:58:42 +00:00
Brian Paul
95d565b64c removed beta designation 1999-12-13 21:56:18 +00:00
Brian Paul
32ea1fdc7e applied Daryll's patches 1999-12-13 21:53:01 +00:00
Keith Whitwell
8d52ee9ae1 Added logicOp driver callback 1999-12-12 18:30:47 +00:00
Brian Paul
9a07202f5e added glXUseXFont() bugfix 1999-12-12 17:55:45 +00:00
Brian Paul
0f953d69e5 removed unneeded code in gluBuild1DMipmaps() 1999-12-12 17:23:33 +00:00
Brian Paul
b3a1034c05 bitmaps were vertically shifted by one pixel 1999-12-12 17:03:07 +00:00
Brian Paul
8956d5131d added default cases to switches to silence compiler warnings 1999-12-12 15:50:44 +00:00
Brian Paul
428cf99956 added GLX_ARB_get_proc_address to extension list 1999-12-11 09:20:03 +00:00
Brian Paul
1e5dab20fd applied patch from Ralph Giles 1999-12-10 15:54:09 +00:00
Brian Paul
aa5251d170 removed GLX_EXT_get_proc_address 1999-12-10 14:55:38 +00:00
Brian Paul
607add71d9 patches from Daryll 1999-12-10 14:21:08 +00:00
Brian Paul
074710629d added GLX_ARB_get_proc_address 1999-12-10 14:10:02 +00:00
Brian Paul
7f0b5dd69c added glXGetProcAddressARB() 1999-12-10 13:45:39 +00:00
Brian Paul
09b83c889b many functions added to gl_get_proc_address() 1999-12-10 13:45:08 +00:00
Brian Paul
9c416c235b added GLX_ARB_get_proc_address 1999-12-10 13:44:31 +00:00
Jouk Jansen
6ce3f22ae9 Committing in .
Updating compilation on VMS

 Modified Files:
  Tag: mesa_3_2_dev
 	Mesa/src-glu/descrip.mms Mesa/src-glu/gluP.h
 ----------------------------------------------------------------------
1999-12-06 05:24:36 +00:00
Gareth Hughes
32093ccc86 Removed axis-aligned plane projection stuff. I received a patch that
did this a while ago and was playing around with it, but I think it's
better to have a robust plane projection mechanism - after all, we can
be given a non-axis-aligned plane normal through gluTessNormal().
1999-12-05 17:01:17 +00:00
Gareth Hughes
d5ff1d782b Fixed contour orientation issues, so clockwise input contours will be
tessellated correctly.  Fixed text3d screensaver bugs associated with
contour orientation.

There is still a bug in the contour stacking calculations, which
causes letters like 'B' to have the inner loops oriented the wrong way
due to them being classified as outside the outer loop.  This should
be relatively straight forward to fix (see O'Rourke 1992).
1999-12-05 02:04:30 +00:00
Brian Paul
2ed8894aca Clearing stencil buffer now observes the stencil write mask
Optimized gl_depth_stencil_span/pixels() functions
1999-12-04 21:15:31 +00:00
Brian Paul
33cd8a5490 minor stencil-related changes 1999-12-04 21:13:44 +00:00
Brian Paul
dd25e9852a added glCopyPixels bug fix 1999-12-03 18:49:05 +00:00
Brian Paul
05df9bb6e0 added WM_SYSKEYDOWN case in __wglMonitor() (Eero Pajarre) 1999-12-02 15:21:04 +00:00
Gareth Hughes
a335bf404f Fixed bug in tessellatin for xlockmore's text3d screensaver. The
external maximums weren't being handled correctly.

Output contours seem to be oriented incorrectly, as they appear as
solidly-filled areas.
1999-12-02 06:18:25 +00:00
Brian Paul
783a67260a gl_BindTexture was broken when target==GL_TEXTURE_3D 1999-12-01 21:07:26 +00:00
Keith Whitwell
e99e126479 check ctx before dereferencing it 1999-12-01 12:45:42 +00:00
Keith Whitwell
98fce32683 Normal, stipple and varray bug fixes 1999-12-01 12:18:47 +00:00
Brian Paul
9493e540f9 fxInitPixelTables() change for Voodoo 1/2 vs 3 1999-12-01 01:10:42 +00:00
Brian Paul
7138d38cc1 print debug info in gl_make_current() if MESA_INFO env var set 1999-11-30 20:31:57 +00:00
Gareth Hughes
9e7f0e1f7c Fixed errors associated with Win32 build warnings. 1999-11-29 18:16:11 +00:00
Brian Paul
52345bfa1e removed Mesa-isms 1999-11-27 01:40:09 +00:00
Brian Paul
93070bceca updated for 3.1 1999-11-27 01:39:50 +00:00
Brian Paul
5b90676fc7 added a few prototypes for BeOS/g++ 1999-11-27 01:37:17 +00:00
Brian Paul
92ad030cb7 added a cast to silence a g++ warning 1999-11-27 01:35:42 +00:00
Brian Paul
9afe0e4278 generate Z values when fog enabled (Andree Borrmann) 1999-11-26 16:28:03 +00:00
Keith Whitwell
3e63be01d1 allow drivers to request fog coordinates 1999-11-25 16:51:24 +00:00
Brian Paul
c73eedbe96 bumped version to 3.1 1999-11-24 18:39:17 +00:00
Brian Paul
8c54c4d9f7 bumped version to 3.1, updated copyright 1999-11-24 18:38:52 +00:00
Keith Whitwell
33817940c4 another typo 1999-11-23 21:13:55 +00:00
Miklos Fazekas
7ec2e161ac Glide3 now uses the same layout as Glide2. 1999-11-23 18:29:53 +00:00
Brian Paul
fc2e8cd0d0 fixed new cut/paste error in FX_grSstWinOpen() call 1999-11-23 13:30:15 +00:00
Brian Paul
a3ea9edfda removed GL_EXT_get_proc_address from ext strings 1999-11-22 22:19:50 +00:00
Brian Paul
7fa9891de2 removed GLU_EXT_get_proc_address from ext string 1999-11-22 22:18:13 +00:00
Brian Paul
ddd9410a67 potential bug fix and clean-up in gl_ShadeModel() 1999-11-22 19:01:39 +00:00
Brian Paul
532dde3e99 fixed shade model bug (A.Borrmann) 1999-11-22 18:26:51 +00:00
Brian Paul
2a6f393fa7 added pragma 4615 (Eero), added copyright 1999-11-22 14:05:15 +00:00
Brian Paul
2d1b9e0402 removed redundant fxCloseHardware() decl 1999-11-22 14:01:35 +00:00
Brian Paul
19c878467f removed reference to GL_EXT_texture_env_add 1999-11-22 13:54:02 +00:00
Miklos Fazekas
1041d573ff Fixed FXMESA_USE_ARGB. 1999-11-21 05:52:10 +00:00
Miklos Fazekas
fda834160b Created the correct pixel table with:FXMESA_USE_ARGB. 1999-11-21 05:38:26 +00:00
Miklos Fazekas
7d35435bb6 Added gl_extension_is_enabled. 1999-11-20 13:13:50 +00:00
Gareth Hughes
5c191a62bc Fixed exterior intersection point insertion. Removed flag from vertex
left over from previous clipping algorithms.  Self-intersecting
contours are now tessellated correctly.
1999-11-20 02:37:20 +00:00
Brian Paul
eca3b6e47e replace encounteed with encountered 1999-11-19 21:22:07 +00:00
Miklos Fazekas
aa0a8624fb Removed #ifdef form inside a macro call. 1999-11-19 15:40:47 +00:00
Miklos Fazekas
f16a627115 Added GL_ADD. 1999-11-19 15:31:05 +00:00
Miklos Fazekas
1d39975c4e Added gl_extension_is_enabled. 1999-11-19 15:29:51 +00:00
Keith Whitwell
62d5f4c73e fixes for andree's drawarrays problems 1999-11-19 00:00:09 +00:00
Brian Paul
d42cd99c66 two fixes in gl_DrawArrays (Andree Borrman) 1999-11-18 23:54:25 +00:00
Brian Paul
03ef882735 fixed FX_grSstControl(), now returns FxBool 1999-11-18 19:31:08 +00:00
Brian Paul
19d0fcafb3 removed unused fxTMNewTMFreeNode decl 1999-11-18 19:30:27 +00:00
Brian Paul
cc6e92ff49 merge from 3.3 branch of Daryll's X server changes 1999-11-18 19:18:44 +00:00
Brian Paul
463c2b6b77 test visinfo, not vishandle in save_glx_visual (Wolfram Gloger) 1999-11-18 15:16:03 +00:00
Brian Paul
09c133e16f fixed some glitches (Eero Pajarre) 1999-11-17 21:21:29 +00:00
Brian Paul
bb1d3c1ad1 new PixelTo[RGB] lookup tables for pixel readback 1999-11-16 19:47:47 +00:00
Brian Paul
cabb6a91cd also remove .lo .la and .libs/ 1999-11-16 15:25:50 +00:00
Gareth Hughes
c76ac6b644 Added combine callback. Converted vertices from ints to floats. 1999-11-16 11:09:09 +00:00
Gareth Hughes
6842075a09 Fixed some vertex insertion bugs. Added boundary intersection
handling, although it is still slightly broken.  Horizontal edges need
to make it into the AET table, I think.  This will fix book/tess at
least, and possibly book/tesswind as well.
1999-11-16 11:07:22 +00:00
Brian Paul
b1da189fe5 removed unused finished: label 1999-11-15 22:21:18 +00:00
Brian Paul
9b635315be fixed several texture state update bugs found with objbug.c program 1999-11-15 22:17:44 +00:00
Gareth Hughes
702baf4cd3 Added scanbeam polygon clipping for intersection handling and boolean
operations.  Lots of other bug fixes and code cleanups.
1999-11-15 21:21:31 +00:00
Gareth Hughes
b27ee886e4 Added new tessellation polygon clipping file tess_clip.c 1999-11-15 21:15:43 +00:00
Josh Vanderhoof
276465cec6 fixed SSE bugs 1999-11-13 02:34:02 +00:00
Brian Paul
5428538d65 added 3.1 final section 1999-11-12 15:45:45 +00:00
Brian Paul
ab5d4d6233 added glxdpyinfo 1999-11-12 15:43:25 +00:00
Brian Paul
2450ce124b initial check-in 1999-11-12 15:43:12 +00:00
Brian Paul
cf22eb77a7 added some braces to silence gcc warnings 1999-11-12 00:13:33 +00:00
Brian Paul
569802cdb1 added missing braces in array initializations 1999-11-11 15:05:27 +00:00
285 changed files with 24822 additions and 60938 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,9 @@
# $Id: Makefile.X11,v 1.32 2000/07/21 16:36:35 brianp Exp $
# $Id: Makefile.X11,v 1.12.2.2 1999/12/14 20:54:24 brianp Exp $
# Mesa 3-D graphics library
# Version: 3.3
# Version: 3.1
#
# Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
# Copyright (C) 1999 Brian Paul All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
@@ -66,24 +66,25 @@ default:
@echo " make irix6-64 for SGI systems with IRIX 6.x, make 64-bit libs"
@echo " make irix6-64-dso for SGI systems with IRIX 6.x, make 64-bit DSOs"
@echo " make linux for Linux systems, make shared .so libs"
@echo " make linux-static for Linux systems, make static .a libs"
@echo " make linux-386 for Linux on Intel, make shared .so libs"
@echo " make linux-386-static for Linux on Intel, make static .a libs"
@echo " make linux for Linux systems, make static .a libs"
@echo " make linux-elf for Linux systems, make ELF shared libs"
@echo " make linux-386 for Linux w/ Intel assembly"
@echo " make linux-386-elf for Linux w/ Intel assembly, make ELF shared libs"
@echo " make linux-ggi for Linux systems with libggi"
@echo " make linux-386-ggi for Linux systems with libggi w/ Intel assembly"
@echo " make linux-alpha for Linux on Alpha systems"
@echo " make linux-alpha-elf for Linux on Alpha systems, make ELF shared libs"
@echo " make linux-ppc for Linux on PowerPC systems"
@echo " make linux-ppc-so for Linux on PowerPC systems, make shared libs"
@echo " make linux-glide for Linux w/ 3Dfx Glide driver"
@echo " make linux-386-glide for Linux w/ 3Dfx Glide driver, Intel assembly"
@echo " make linux-386-opt-glide for Linux with 3Dfx Voodoo1 for GLQuake"
@echo " make linux-386-opt-V2-glide for Linux with 3Dfx Voodoo2 for GLQuake"
@echo " make linux-3dnow for Linux on AMD w/ 3DNow!"
@echo " make linux-3dnow-glide for Linux on AMD w/ 3DNow! for Glide"
@echo " make linux-katmai for Linux on PentiumIII w/ SSE"
@echo " make linux-katmai-glide for Linux on PentiumIII w/ SSE for Glide"
@echo " make linux-alpha for Linux on Alpha systems"
@echo " make linux-alpha-static for Linux on Alpha systems, static libs"
@echo " make linux-ppc for Linux on PowerPC systems"
@echo " make linux-ppc-static for Linux on PowerPC systems, static libs"
@echo " make linux-386-pthread for Linux w/ Intel assembly and linuxthreads"
@echo " make linux-386-pthread-shared for Linux w/ Intel assembly and linuxthreads"
@echo " make linux-386-pthread-shared-glide for Linux w/ Intel assembly, linuxthreads, and 3Dfx Glide driver"
@echo " make linux-sparc for Linux on Sparc systems"
@echo " make linux-sparc5-elf for Sparc5 systems, make ELF shared libs"
@echo " make linux-sparc-ultra for UltraSparc systems, make ELF shared libs"
@@ -139,15 +140,14 @@ aix aix-sl amix bsdos bsdos4 dgux freebsd freebsd-386 gcc \
hpux9 hpux9-sl hpux9-gcc hpux9-gcc-sl \
hpux10 hpux10-sl hpux10-gcc hpux10-gcc-sl \
irix4 irix5 irix5-gcc irix5-dso irix6-o32 irix6-o32-dso \
linux-static-debug linux-elf-debug linux-prof linux-glide-debug \
linux linux-static \
linux-386 linux-386-static \
linux linux-debug linux-prof linux-elf linux-elf-debug linux-glide-debug \
linux-glide linux-386-glide linux-386-opt-glide \
linux-386-opt-V2-glide \
linux-386 linux-386-elf \
linux-3dnow linux-3dnow-glide \
linux-katmai linux-katmai-glide \
linux-alpha-static linux-alpha \
linux-ppc-static linux-ppc \
linux-alpha linux-alpha-elf \
linux-ppc linux-ppc-so \
linux-386-pthread linux-386-pthread-shared linux-386-pthread-shared-glide \
linux-sparc \
linux-sparc5-elf \
linux-sparc-ultra \
@@ -159,34 +159,30 @@ sunos5 sunos5-sl sunos5-ultra sunos5-ultra-sl sunos5-gcc sunos5-gcc-sl \
sunos5-thread sunos5-pthread sunos5-gcc-thread sunos5-gcc-pthread \
sunos5-x11r6-gcc-sl ultrix-gcc unicos unixware uwin vistra:
-mkdir lib
if [ -d src ] ; then touch src/depend ; fi
if [ -d src-glu ] ; then touch src-glu/depend ; fi
touch src/depend
touch src-glu/depend
if [ -d src-glut ] ; then touch src-glut/depend ; fi
if [ -d widgets-sgi ] ; then touch widgets-sgi/depend ; fi
if [ -d src ] ; then cd src ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d src-glu ] ; then cd src-glu ; $(MAKE) -f Makefile.X11 $@ ; fi
cd src ; $(MAKE) -f Makefile.X11 $@
cd src-glu ; $(MAKE) -f Makefile.X11 $@
if [ -d src-glut ] ; then cd src-glut ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d demos ] ; then cd demos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d xdemos ] ; then cd xdemos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d samples ] ; then cd samples ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d book ] ; then cd book ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d widgets-sgi ] ; then cd widgets-sgi; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d demos ] ; then cd demos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d xdemos ] ; then cd xdemos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d samples ] ; then cd samples ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d book ] ; then cd book ; $(MAKE) -f Makefile.X11 $@ ; fi
irix6-n32 irix6-n32-dso irix6-gcc-n32-sl irix-debug:
-mkdir lib32
if [ -d src ] ; then touch src/depend ; fi
if [ -d src-glu ] ; then touch src-glu/depend ; fi
touch src/depend
touch src-glu/depend
if [ -d src-glut ] ; then touch src-glut/depend ; fi
if [ -d src-glut ] ; then touch src-glut/depend ; fi
if [ -d widgets-sgi ] ; then touch widgets-sgi/depend ; fi
if [ -d src ] ; then cd src ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d src-glu ] ; then cd src-glu ; $(MAKE) -f Makefile.X11 $@ ; fi
cd src ; $(MAKE) -f Makefile.X11 $@
cd src-glu ; $(MAKE) -f Makefile.X11 $@
if [ -d src-glut ] ; then cd src-glut ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d demos ] ; then cd demos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d xdemos ] ; then cd xdemos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d samples ] ; then cd samples ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d book ] ; then cd book ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d widgets-sgi ] ; then cd widgets-sgi; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d demos ] ; then cd demos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d xdemos ] ; then cd xdemos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d samples ] ; then cd samples ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d book ] ; then cd book ; $(MAKE) -f Makefile.X11 $@ ; fi
irix6-64 irix6-64-dso:
@@ -194,15 +190,13 @@ irix6-64 irix6-64-dso:
touch src/depend
touch src-glu/depend
if [ -d src-glut ] ; then touch src-glut/depend ; fi
if [ -d widgets-sgi ] ; then touch widgets-sgi/depend ; fi
if [ -d src ] ; then cd src ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d src-glu ] ; then cd src-glu ; $(MAKE) -f Makefile.X11 $@ ; fi
cd src ; $(MAKE) -f Makefile.X11 $@
cd src-glu ; $(MAKE) -f Makefile.X11 $@
if [ -d src-glut ] ; then cd src-glut ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d demos ] ; then cd demos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d xdemos ] ; then cd xdemos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d samples ] ; then cd samples ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d book ] ; then cd book ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d widgets-sgi ] ; then cd widgets-sgi; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d demos ] ; then cd demos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d xdemos ] ; then cd xdemos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d samples ] ; then cd samples ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d book ] ; then cd book ; $(MAKE) -f Makefile.X11 $@ ; fi
amiwin:
@@ -215,27 +209,25 @@ beos-r4:
touch src/depend
-rm src-glu/depend
touch src-glu/depend
if [ -d src ] ; then cd src ; $(MAKE) -f Makefile.BeOS-R4 $@ ; fi
if [ -d src-glu ] ; then cd src-glu ; $(MAKE) -f Makefile.BeOS-R4 $@ ; fi
if [ -d BeOS ] ; then cd BeOS ; $(MAKE) ; fi
if [ -d src-glut.beos ] ; then cd src-glut.beos ; $(MAKE) ; fi
cd src ; $(MAKE) -f Makefile.BeOS-R4 $@
cd src-glu ; $(MAKE) -f Makefile.BeOS-R4 $@
if [ -d BeOS ] ; then cd BeOS ; $(MAKE) ; fi
if [ -d src-glut.beos ] ; then cd src-glut.beos ; $(MAKE) ; fi
if [ -d src-glut.beos ] ; then cp src-glut.beos/obj*/libglut.so lib ; fi
if [ -d demos ] ; then cd demos ; $(MAKE) -f Makefile.BeOS-R4 $@ ; fi
if [ -d demos ] ; then cd demos ; $(MAKE) -f Makefile.BeOS-R4 $@ ; fi
if [ -d samples ] ; then cd samples ; $(MAKE) -f Makefile.BeOS-R4 $@ ; fi
if [ -d book ] ; then cd book ; $(MAKE) -f Makefile.BeOS-R4 $@ ; fi
if [ -d book ] ; then cd book ; $(MAKE) -f Makefile.BeOS-R4 $@ ; fi
pgi-cygnus pgi-mingw32 \
cygnus cygnus-linux:
-mkdir lib
touch src/depend
touch src-glu/depend
if [ -d widgets-sgi ] ; then touch widgets-sgi/depend ; fi
if [ -d src ] ; then cd src ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d src-glu ] ; then cd src-glu ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d src-glut ] ; then cd src-glut ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d demos ] ; then cd demos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d xdemos ] ; then cd xdemos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d widgets-sgi ] ; then cd widgets-sgi; $(MAKE) -f Makefile.X11 $@ ; fi
cd src ; $(MAKE) -f Makefile.X11 $@
cd src-glu ; $(MAKE) -f Makefile.X11 $@
cd src-glut ; $(MAKE) -f Makefile.X11 $@
cd demos ; $(MAKE) -f Makefile.X11 $@
if [ -d xdemos ] ; then cd xdemos ; $(MAKE) -f Makefile.X11 $@ ; fi
macintosh:
@echo "See the README file for Macintosh intallation information"
@@ -267,21 +259,19 @@ linux-ggi linux-386-ggi:
-mkdir lib
touch src/depend
touch src-glu/depend
if [ -d src-glut ] ; then touch src-glut/depend ; fi
if [ -d widgets-sgi ] ; then touch widgets-sgi/depend ; fi
if [ -d ggi ] ; then touch ggi/depend ; fi
if [ -d src ] ; then cd src ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d src/GGI/default ] ; then cd src/GGI/default ; $(MAKE) ; fi
if [ -d src/GGI/display ] ; then cd src/GGI/display ; $(MAKE) ; fi
if [ -d src-glut ] ; then cd src-glu ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d src-glut ] ; then touch src-glut/depend ; fi
if [ -d ggi ] ; then touch ggi/depend ; fi
cd src ; $(MAKE) -f Makefile.X11 $@
cd src/GGI/default ; $(MAKE)
cd src/GGI/display ; $(MAKE)
cd src-glu ; $(MAKE) -f Makefile.X11 $@
# if [ -d src-glut ] ; then cd src-glut ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d ggi ] ; then cd ggi ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d ggi ] ; then cd ggi/demos; $(MAKE) ; fi
if [ -d ggi ] ; then cd ggi/demos; $(MAKE) ; fi
if [ -d demos ] ; then cd demos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d xdemos ] ; then cd xdemos ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d samples ] ; then cd samples ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d book ] ; then cd book ; $(MAKE) -f Makefile.X11 $@ ; fi
if [ -d widgets-sgi ] ; then cd widgets-sgi; $(MAKE) -f Makefile.X11 $@ ; fi
# if you change GGI_DEST please change it in ggimesa.conf, too.
DESTDIR=/usr/local
@@ -311,8 +301,6 @@ clean:
-rm -f xdemos/*.o xdemos/*~
-rm -f samples/*.o samples/*~
-rm -f ggi/*.o ggi/demos/*.o ggi/*.a
-rm -f widgets-sgi/*.o
-rm -f widgets-mesa/*/*.o
# Remove everything that can be remade
realclean: clean
@@ -326,105 +314,103 @@ realclean: clean
DIRECTORY = Mesa-3.3
LIB_NAME = MesaLib-3.3
DEMO_NAME = MesaDemos-3.3
GLU_NAME = MesaGLU-3.3
GLUT_NAME = GLUT-3.7
DIRECTORY = Mesa-3.1
LIB_NAME = MesaLib-3.1
DEMO_NAME = MesaDemos-3.1
LIB_FILES = \
$(DIRECTORY)/Makefile* \
$(DIRECTORY)/Make-config \
$(DIRECTORY)/acconfig.h \
$(DIRECTORY)/acinclude.m4 \
$(DIRECTORY)/aclocal.m4 \
$(DIRECTORY)/conf.h.in \
$(DIRECTORY)/config.guess \
$(DIRECTORY)/config.sub \
$(DIRECTORY)/configure \
$(DIRECTORY)/configure.in \
$(DIRECTORY)/install-sh \
$(DIRECTORY)/ltconfig \
$(DIRECTORY)/ltmain.sh \
$(DIRECTORY)/missing \
$(DIRECTORY)/mkinstalldirs \
$(DIRECTORY)/stamp-h.in \
$(DIRECTORY)/docs/CONFIG \
$(DIRECTORY)/docs/CONFORM \
$(DIRECTORY)/docs/COPYING \
$(DIRECTORY)/docs/COPYRIGHT \
$(DIRECTORY)/docs/DEVINFO \
$(DIRECTORY)/docs/IAFA-PACKAGE \
$(DIRECTORY)/docs/INSTALL \
$(DIRECTORY)/docs/INSTALL.GNU \
$(DIRECTORY)/docs/README \
$(DIRECTORY)/docs/README.* \
$(DIRECTORY)/docs/RELNOTES* \
$(DIRECTORY)/docs/VERSIONS \
$(DIRECTORY)/docs/*.spec \
$(DIRECTORY)/bin/README \
$(DIRECTORY)/bin/mklib* \
$(DIRECTORY)/*.BAT \
$(DIRECTORY)/*.bat \
$(DIRECTORY)/descrip.mms \
$(DIRECTORY)/mms-config \
$(DIRECTORY)/xlib.opt \
$(DIRECTORY)/STARTUP.MK \
$(DIRECTORY)/mesawin32.mak \
$(DIRECTORY)/Names.win \
$(DIRECTORY)/win32-openstep.sh \
$(DIRECTORY)/common.dja \
$(DIRECTORY)/include/GL/Makefile.in \
$(DIRECTORY)/include/GL/Makefile.am \
$(DIRECTORY)/include/GL/dosmesa.h \
$(DIRECTORY)/include/GL/amesa.h \
$(DIRECTORY)/include/GL/fxmesa.h \
$(DIRECTORY)/include/GL/ggimesa.h \
$(DIRECTORY)/include/GL/gl.h \
$(DIRECTORY)/include/GL/glext.h \
$(DIRECTORY)/include/GL/gl_mangle.h \
$(DIRECTORY)/include/GL/glu.h \
$(DIRECTORY)/include/GL/glu_mangle.h \
$(DIRECTORY)/include/GL/glx.h \
$(DIRECTORY)/include/GL/glx_mangle.h \
$(DIRECTORY)/include/GL/mglmesa.h \
$(DIRECTORY)/include/GL/osmesa.h \
$(DIRECTORY)/include/GL/svgamesa.h \
$(DIRECTORY)/include/GL/wmesa.h \
$(DIRECTORY)/include/GL/xmesa.h \
$(DIRECTORY)/include/GL/xmesa_x.h \
$(DIRECTORY)/include/GL/xmesa_xf86.h \
$(DIRECTORY)/include/GLView.h \
$(DIRECTORY)/include/Makefile.in \
$(DIRECTORY)/include/Makefile.am \
$(DIRECTORY)/src/Makefile* \
$(DIRECTORY)/src/descrip.mms \
$(DIRECTORY)/src/mms_depend \
$(DIRECTORY)/src/mesa.conf \
$(DIRECTORY)/src/*.def \
$(DIRECTORY)/src/depend \
$(DIRECTORY)/src/*.[chS] \
$(DIRECTORY)/src/Allegro/*.[ch] \
$(DIRECTORY)/src/BeOS/*.cpp \
$(DIRECTORY)/src/D3D/*.cpp \
$(DIRECTORY)/src/D3D/*.CPP \
$(DIRECTORY)/src/D3D/*.h \
$(DIRECTORY)/src/D3D/*.H \
$(DIRECTORY)/src/D3D/*.c \
$(DIRECTORY)/src/D3D/*.C \
$(DIRECTORY)/src/D3D/MAKEFILE \
$(DIRECTORY)/src/D3D/*bat \
$(DIRECTORY)/src/D3D/*DEF \
$(DIRECTORY)/src/DOS/DEPEND.DOS \
$(DIRECTORY)/src/DOS/*.c \
$(DIRECTORY)/src/FX/Makefile.am \
$(DIRECTORY)/src/FX/Makefile.in \
$(DIRECTORY)/src/FX/*.[ch] \
$(DIRECTORY)/src/FX/*.def \
$(DIRECTORY)/src/FX/X86/Makefile.am \
$(DIRECTORY)/src/FX/X86/Makefile.in \
$(DIRECTORY)/src/FX/X86/*.[Shc] \
$(DIRECTORY)/Makefile* \
$(DIRECTORY)/Make-config \
$(DIRECTORY)/acconfig.h \
$(DIRECTORY)/acinclude.m4 \
$(DIRECTORY)/aclocal.m4 \
$(DIRECTORY)/conf.h.in \
$(DIRECTORY)/config.guess \
$(DIRECTORY)/config.sub \
$(DIRECTORY)/configure \
$(DIRECTORY)/configure.in \
$(DIRECTORY)/install-sh \
$(DIRECTORY)/ltconfig \
$(DIRECTORY)/ltmain.sh \
$(DIRECTORY)/missing \
$(DIRECTORY)/mkinstalldirs \
$(DIRECTORY)/stamp-h.in \
$(DIRECTORY)/configure \
$(DIRECTORY)/docs/CONFIG \
$(DIRECTORY)/docs/CONFORM \
$(DIRECTORY)/docs/COPYING \
$(DIRECTORY)/docs/COPYRIGHT \
$(DIRECTORY)/docs/DEVINFO \
$(DIRECTORY)/docs/IAFA-PACKAGE \
$(DIRECTORY)/docs/INSTALL \
$(DIRECTORY)/docs/INSTALL.GNU \
$(DIRECTORY)/docs/README \
$(DIRECTORY)/docs/README.* \
$(DIRECTORY)/docs/RELNOTES \
$(DIRECTORY)/docs/VERSIONS \
$(DIRECTORY)/docs/*.spec \
$(DIRECTORY)/bin/README \
$(DIRECTORY)/bin/mklib* \
$(DIRECTORY)/*.BAT \
$(DIRECTORY)/*.bat \
$(DIRECTORY)/descrip.mms \
$(DIRECTORY)/mms-config \
$(DIRECTORY)/xlib.opt \
$(DIRECTORY)/STARTUP.MK \
$(DIRECTORY)/mesawin32.mak \
$(DIRECTORY)/Names.win \
$(DIRECTORY)/win32-openstep.sh \
$(DIRECTORY)/*.dja \
$(DIRECTORY)/include/GL/Makefile.in \
$(DIRECTORY)/include/GL/Makefile.am \
$(DIRECTORY)/include/GL/dosmesa.h \
$(DIRECTORY)/include/GL/foomesa.h \
$(DIRECTORY)/include/GL/fxmesa.h \
$(DIRECTORY)/include/GL/ggimesa.h \
$(DIRECTORY)/include/GL/gl.h \
$(DIRECTORY)/include/GL/gl_mangle.h \
$(DIRECTORY)/include/GL/glu.h \
$(DIRECTORY)/include/GL/glu_mangle.h \
$(DIRECTORY)/include/GL/glx.h \
$(DIRECTORY)/include/GL/glx_mangle.h \
$(DIRECTORY)/include/GL/mglmesa.h \
$(DIRECTORY)/include/GL/osmesa.h \
$(DIRECTORY)/include/GL/svgamesa.h \
$(DIRECTORY)/include/GL/wmesa.h \
$(DIRECTORY)/include/GL/xmesa.h \
$(DIRECTORY)/include/GL/xmesa_x.h \
$(DIRECTORY)/include/GL/xmesa_xf86.h \
$(DIRECTORY)/include/GLView.h \
$(DIRECTORY)/include/Makefile.in \
$(DIRECTORY)/include/Makefile.am \
$(DIRECTORY)/src/Makefile* \
$(DIRECTORY)/src/descrip.mms \
$(DIRECTORY)/src/mms_depend \
$(DIRECTORY)/src/mesa.conf \
$(DIRECTORY)/src/*.def \
$(DIRECTORY)/src/depend \
$(DIRECTORY)/src/*.[chS] \
$(DIRECTORY)/src/Allegro/*.[ch] \
$(DIRECTORY)/src/BeOS/*.cpp \
$(DIRECTORY)/src/D3D/*.cpp \
$(DIRECTORY)/src/D3D/*.CPP \
$(DIRECTORY)/src/D3D/*.h \
$(DIRECTORY)/src/D3D/*.H \
$(DIRECTORY)/src/D3D/*.c \
$(DIRECTORY)/src/D3D/*.C \
$(DIRECTORY)/src/D3D/MAKEFILE \
$(DIRECTORY)/src/D3D/*bat \
$(DIRECTORY)/src/D3D/*DEF \
$(DIRECTORY)/src/DOS/DEPEND.DOS \
$(DIRECTORY)/src/DOS/*.c \
$(DIRECTORY)/src/FX/Makefile.am \
$(DIRECTORY)/src/FX/Makefile.in \
$(DIRECTORY)/src/FX/*.[ch] \
$(DIRECTORY)/src/FX/*.def \
$(DIRECTORY)/src/FX/X86/Makefile.am \
$(DIRECTORY)/src/FX/X86/Makefile.in \
$(DIRECTORY)/src/FX/X86/*.[Shc] \
$(DIRECTORY)/src/GGI/Makefile.am \
$(DIRECTORY)/src/GGI/Makefile.in \
$(DIRECTORY)/src/GGI/*.[ch] \
@@ -445,6 +431,8 @@ LIB_FILES = \
$(DIRECTORY)/src/GGI/include/ggi/mesa/Makefile.in \
$(DIRECTORY)/src/GGI/include/ggi/mesa/*.h \
$(DIRECTORY)/src/KNOWN_BUGS \
$(DIRECTORY)/src/MGL/*.[ch] \
$(DIRECTORY)/src/MGL/*.txt \
$(DIRECTORY)/src/OSmesa/Makefile.am \
$(DIRECTORY)/src/OSmesa/Makefile.in \
$(DIRECTORY)/src/OSmesa/*.[ch] \
@@ -465,46 +453,22 @@ LIB_FILES = \
$(DIRECTORY)/src/X86/Makefile.in \
$(DIRECTORY)/src/X86/*.m4 \
$(DIRECTORY)/src/X86/*.S \
$(DIRECTORY)/src/*.dja \
$(DIRECTORY)/src-glu/README[12] \
$(DIRECTORY)/src-glu/Makefile* \
$(DIRECTORY)/src-glu/descrip.mms \
$(DIRECTORY)/src-glu/mms_depend \
$(DIRECTORY)/src-glu/*.def \
$(DIRECTORY)/src-glu/*.dja \
$(DIRECTORY)/src-glu/depend \
$(DIRECTORY)/src-glu/*.[ch] \
$(DIRECTORY)/widgets-mesa/ChangeLog \
$(DIRECTORY)/widgets-mesa/INSTALL \
$(DIRECTORY)/widgets-mesa/Makefile.in \
$(DIRECTORY)/widgets-mesa/README \
$(DIRECTORY)/widgets-mesa/TODO \
$(DIRECTORY)/widgets-mesa/configure \
$(DIRECTORY)/widgets-mesa/demos/ChangeLog \
$(DIRECTORY)/widgets-mesa/demos/Cube \
$(DIRECTORY)/widgets-mesa/demos/Ed \
$(DIRECTORY)/widgets-mesa/demos/Makefile.in \
$(DIRECTORY)/widgets-mesa/demos/Mcube \
$(DIRECTORY)/widgets-mesa/demos/Tea \
$(DIRECTORY)/widgets-mesa/demos/*.[ch] \
$(DIRECTORY)/widgets-mesa/demos/events \
$(DIRECTORY)/widgets-mesa/include/GL/ChangeLog \
$(DIRECTORY)/widgets-mesa/include/GL/*.h \
$(DIRECTORY)/widgets-mesa/include/GL/Makefile.in \
$(DIRECTORY)/widgets-mesa/man/ChangeLog \
$(DIRECTORY)/widgets-mesa/man/GL* \
$(DIRECTORY)/widgets-mesa/man/Makefile.in \
$(DIRECTORY)/widgets-mesa/man/Mesa* \
$(DIRECTORY)/widgets-mesa/src/ChangeLog \
$(DIRECTORY)/widgets-sgi/*.[ch] \
$(DIRECTORY)/widgets-sgi/Makefile* \
$(DIRECTORY)/widgets-sgi/README \
$(DIRECTORY)/widgets-mesa \
$(DIRECTORY)/widgets-sgi \
$(DIRECTORY)/util/README \
$(DIRECTORY)/util/Makefile.am \
$(DIRECTORY)/util/Makefile.in \
$(DIRECTORY)/util/*.[ch] \
$(DIRECTORY)/util/sampleMakefile \
$(DIRECTORY)/vms/analyze_map.com \
$(DIRECTORY)/vms/xlib.opt \
$(DIRECTORY)/vms/xlib_share.opt \
$(DIRECTORY)/BeOS/Makefile \
$(DIRECTORY)/BeOS/*.cpp \
$(DIRECTORY)/WIN32/NMAKE.MAK \
@@ -515,7 +479,6 @@ LIB_FILES = \
$(DIRECTORY)/WIN32/RULES/progs.* \
$(DIRECTORY)/macos/README \
$(DIRECTORY)/macos/gli_api/*.h \
$(DIRECTORY)/macos/cglpane/CGLPane.* \
$(DIRECTORY)/macos/include-mac/*.h \
$(DIRECTORY)/macos/libraries/*.stub \
$(DIRECTORY)/macos/libraries/*Stub \
@@ -527,8 +490,8 @@ LIB_FILES = \
$(DIRECTORY)/macos/resources/*.rsrc \
$(DIRECTORY)/macos/src-agl/*.exp \
$(DIRECTORY)/macos/src-agl/*.[ch] \
$(DIRECTORY)/macos/src-gli/*.[ch] \
$(DIRECTORY)/OpenStep
$(DIRECTORY)/macos/src-gli/*.[ch]
DEMO_FILES = \
$(DIRECTORY)/include/GL/glut.h \
@@ -548,9 +511,7 @@ DEMO_FILES = \
$(DIRECTORY)/demos/Makefile* \
$(DIRECTORY)/demos/descrip.mms \
$(DIRECTORY)/demos/*.[ch] \
$(DIRECTORY)/demos/*.cxx \
$(DIRECTORY)/demos/*.dat \
$(DIRECTORY)/demos/README \
$(DIRECTORY)/xdemos/Makefile* \
$(DIRECTORY)/xdemos/descrip.mms \
$(DIRECTORY)/xdemos/*.[cf] \
@@ -560,52 +521,13 @@ DEMO_FILES = \
$(DIRECTORY)/samples/Makefile* \
$(DIRECTORY)/samples/README \
$(DIRECTORY)/samples/*.c \
$(DIRECTORY)/samples/*.dja \
$(DIRECTORY)/3Dfx \
$(DIRECTORY)/mtdemos \
$(DIRECTORY)/ggi
GLU_FILES = \
$(DIRECTORY)/Makefile* \
$(DIRECTORY)/Make-config \
$(DIRECTORY)/bin/mklib* \
$(DIRECTORY)/include/GL/gl.h \
$(DIRECTORY)/include/GL/gl_mangle.h \
$(DIRECTORY)/include/GL/glext.h \
$(DIRECTORY)/include/GL/glu.h \
$(DIRECTORY)/include/GL/glu_mangle.h \
$(DIRECTORY)/src-glu/README[12] \
$(DIRECTORY)/src-glu/Makefile* \
$(DIRECTORY)/src-glu/descrip.mms \
$(DIRECTORY)/src-glu/mms_depend \
$(DIRECTORY)/src-glu/*.def \
$(DIRECTORY)/src-glu/depend \
$(DIRECTORY)/src-glu/*.[ch]
GLUT_FILES = \
$(DIRECTORY)/Makefile* \
$(DIRECTORY)/Make-config \
$(DIRECTORY)/bin/mklib* \
$(DIRECTORY)/include/GL/gl.h \
$(DIRECTORY)/include/GL/gl_mangle.h \
$(DIRECTORY)/include/GL/glext.h \
$(DIRECTORY)/include/GL/glu.h \
$(DIRECTORY)/include/GL/glu_mangle.h \
$(DIRECTORY)/include/GL/glut.h \
$(DIRECTORY)/include/GL/glutf90.h \
$(DIRECTORY)/include/GL/glut_h.dja \
$(DIRECTORY)/src-glut/Makefile* \
$(DIRECTORY)/src-glut/depend \
$(DIRECTORY)/src-glut/*def \
$(DIRECTORY)/src-glut/descrip.mms \
$(DIRECTORY)/src-glut/mms_depend \
$(DIRECTORY)/src-glut/*.[ch] \
$(DIRECTORY)/src-glut.dja/* \
$(DIRECTORY)/src-glut.beos/Makefile \
$(DIRECTORY)/src-glut.beos/*.cpp \
$(DIRECTORY)/src-glut.beos/*.h
lib_tar:
cp Makefile.X11 Makefile ; \
cd .. ; \
tar -cvf $(LIB_NAME).tar $(LIB_FILES) ; \
gzip $(LIB_NAME).tar ; \
@@ -617,30 +539,14 @@ demo_tar:
gzip $(DEMO_NAME).tar ; \
mv $(DEMO_NAME).tar.gz $(DIRECTORY)
glu_tar:
cp Makefile.X11 Makefile ; \
cd .. ; \
tar -cvf $(GLU_NAME).tar $(GLU_FILES) ; \
gzip $(GLU_NAME).tar ; \
mv $(GLU_NAME).tar.gz $(DIRECTORY)
glut_tar:
cp Makefile.X11 Makefile ; \
cd .. ; \
tar -cvf $(GLUT_NAME).tar $(GLUT_FILES) ; \
gzip $(GLUT_NAME).tar ; \
mv $(GLUT_NAME).tar.gz $(DIRECTORY)
lib_zip:
-rm $(LIB_NAME).zip ; \
cp Makefile.X11 Makefile ; \
-rm $(LIB_NAME).zip
cd .. ; \
zip -r $(LIB_NAME).zip $(LIB_FILES) ; \
mv $(LIB_NAME).zip $(DIRECTORY)
demo_zip:
-rm $(DEMO_NAME).zip ; \
-rm $(DEMO_NAME).zip
cd .. ; \
zip -r $(DEMO_NAME).zip $(DEMO_FILES) ; \
mv $(DEMO_NAME).zip $(DIRECTORY)

View File

@@ -1,88 +0,0 @@
Name
MESA_copy_sub_buffer
Name Strings
GLX_MESA_copy_sub_buffer
Contact
Brian Paul (brian 'at' mesa3d.org)
Status
Shipping since Mesa 2.6 in February, 1998.
Version
Last Modified Date: 8 June 2000
Number
215
Dependencies
OpenGL 1.0 or later is required.
GLX 1.0 or later is required.
Overview
The glxCopySubBufferMESA() function copies a rectangular region
of the back color buffer to the front color buffer. This can be
used to quickly repaint 3D windows in response to expose events
when the back color buffer cannot be damaged by other windows.
IP Status
Open-source; freely implementable.
Issues
None.
New Procedures and Functions
void glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
int x, int y, int width, int height );
New Tokens
None.
Additions to Chapter 3 of the GLX 1.3 Specification (Functions and Errors)
Add to section 3.3.10 Double Buffering:
The function
void glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
int x, int y, int width, int height );
may be used to copy a rectangular region of the back color buffer to
the front color buffer. This can be used to quickly repaint 3D windows
in response to expose events when the back color buffer cannot be
damaged by other windows.
<x> and <y> indicates the lower-left corner of the region to copy and
<width> and <height> indicate the size in pixels. Coordinate (0,0)
corresponds to the lower-left pixel of the window, like glReadPixels.
GLX Protocol
None at this time. The extension is implemented in terms of ordinary
Xlib protocol inside of Mesa.
Errors
None.
New State
None.
Revision History
8 June 2000 - initial specification

View File

@@ -1,90 +0,0 @@
Name
MESA_pixmap_colormap
Name Strings
GLX_MESA_pixmap_colormap
Contact
Brian Paul (brian 'at' mesa3d.org)
Status
Shipping since Mesa 1.2.8 in May, 1996.
Version
Last Modified Date: 8 June 2000
Number
216
Dependencies
OpenGL 1.0 or later is required.
GLX 1.0 or later is required.
Overview
Since Mesa allows RGB rendering into drawables with PseudoColor,
StaticColor, GrayScale and StaticGray visuals, Mesa needs a colormap
in order to compute pixel values during rendering.
The colormap associated with a window can be queried with normal
Xlib functions but there is no colormap associated with pixmaps.
The glXCreateGLXPixmapMESA function is an alternative to glXCreateGLXPixmap
which allows specification of a colormap.
IP Status
Open-source; freely implementable.
Issues
None.
New Procedures and Functions
GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual,
Pixmap pixmap, Colormap cmap );
New Tokens
None.
Additions to Chapter 3 of the GLX 1.3 Specification (Functions and Errors)
Add to section 3.4.2 Off Screen Rendering
The Mesa implementation of GLX allows RGB rendering into X windows and
pixmaps of any visual class, not just TrueColor or DirectColor. In order
to compute pixel values from RGB values Mesa requires a colormap.
The function
GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual,
Pixmap pixmap, Colormap cmap );
allows one to create a GLXPixmap with a specific colormap. The image
rendered into the pixmap may then be copied to a window (which uses the
same colormap and visual) with the expected results.
GLX Protocol
None since this is a client-side extension.
Errors
None.
New State
None.
Revision History
8 June 2000 - initial specification

View File

@@ -1,85 +0,0 @@
Name
MESA_release_buffers
Name Strings
GLX_MESA_release_buffers
Contact
Brian Paul (brian 'at' mesa3d.org)
Status
Shipping since Mesa 2.0 in October, 1996.
Version
Last Modified Date: 8 June 2000
Number
217
Dependencies
OpenGL 1.0 or later is required.
GLX 1.0 or later is required.
Overview
Mesa's implementation of GLX is entirely implemented on the client side.
Therefore, Mesa cannot immediately detect when an X window or pixmap is
destroyed in order to free any ancilliary data associated with the window
or pixmap.
The glxMesaReleaseBuffers() function can be used to explicitly indicate
when the back color buffer, depth buffer, stencil buffer, and/or accum-
ulation buffer associated with a drawable can be freed.
IP Status
Open-source; freely implementable.
Issues
None.
New Procedures and Functions
Bool glXReleaseBuffersMESA( Display *dpy, GLXDrawable d );
New Tokens
None.
Additions to Chapter 3 of the GLX 1.3 Specification (Functions and Errors)
The function
Bool glXReleaseBuffersMESA( Display *dpy, GLXDrawable d );
causes all software ancilliary buffers (back buffer, depth, stencil,
accum, etc) associated with the named drawable to be immediately
deallocated. True is returned if <d> is a valid Mesa GLX drawable,
else False is returned. After calling glXReleaseBuffersMESA, the
drawable should no longer be used for GL rendering. Results of
attempting to do so are undefined.
GLX Protocol
None, since this is a client-side operation.
Errors
None.
New State
None.
Revision History
8 June 2000 - initial specification

View File

@@ -16,11 +16,11 @@ Status
Version
$Id: MESA_resize_buffers.spec,v 1.2 2000/04/04 23:29:32 brianp Exp $
$Id: MESA_resize_buffers.spec,v 1.1 1999/07/20 00:30:41 brianp Exp $
Number
196
XXX none assigned
Dependencies

View File

@@ -1,85 +0,0 @@
Name
MESA_set_3dfx_mode
Name Strings
GLX_MESA_set_3dfx_mode
Contact
Brian Paul (brian 'at' mesa3d.org)
Status
Shipping since Mesa 2.6 in February, 1998.
Version
Last Modified Date: 8 June 2000
Number
218
Dependencies
OpenGL 1.0 or later is required.
GLX 1.0 or later is required.
Overview
The Mesa Glide driver allows full-screen rendering or rendering into
an X window. The glXSet3DfxModeMESA() function allows an application
to switch between full-screen and windowed rendering.
IP Status
Open-source; freely implementable.
Issues
None.
New Procedures and Functions
GLboolean glXSet3DfxModeMESA( GLint mode );
New Tokens
GLX_3DFX_WINDOW_MODE_MESA 0x1
GLX_3DFX_FULLSCREEN_MODE_MESA 0x2
Additions to Chapter 3 of the GLX 1.3 Specification (Functions and Errors)
The Mesa Glide device driver allows either rendering in full-screen
mode or rendering into an X window. An application can switch between
full-screen and window rendering with the command:
GLboolean glXSet3DfxModeMESA( GLint mode );
<mode> may either be GLX_3DFX_WINDOW_MODE_MESA to indicate window
rendering or GLX_3DFX_FULLSCREEN_MODE_MESA to indicate full-screen mode.
GL_TRUE is returned if <mode> is valid and the operation completed
normally. GL_FALSE is returned if <mode> is invalid or if the Glide
driver is not being used.
Note that only one drawable and context can be created at any given
time with the Mesa Glide driver.
GLX Protocol
None since this is a client-side extension.
Errors
None.
New State
None.
Revision History
8 June 2000 - initial specification

View File

@@ -16,11 +16,11 @@ Status
Version
$Id: MESA_window_pos.spec,v 1.3 2000/04/04 23:29:32 brianp Exp $
$Id: MESA_window_pos.spec,v 1.1 1999/07/20 00:30:41 brianp Exp $
Number
197
XXX non assigned
Dependencies
@@ -33,7 +33,7 @@ Overview
coordinate with the RasterPos command, the modelview matrix, projection
matrix and viewport must be set very carefully. Furthermore, if the
desired window coordinate is outside of the window's bounds one must
rely on a subtle side-effect of the Bitmap command in order to circumvent
rely a subtle side-effect of the Bitmap command in order to circumvent
frustum clipping.
This extension provides a set of functions to directly set the
@@ -51,26 +51,6 @@ New Procedures and Functions
void WindowPos2fMESA(float x, float y)
void WindowPos2iMESA(int x, int y)
void WindowPos2sMESA(short x, short y)
void WindowPos2ivMESA(const int *p)
void WindowPos2svMESA(const short *p)
void WindowPos2fvMESA(const float *p)
void WindowPos2dvMESA(const double *p)
void WindowPos3iMESA(int x, int y, int z)
void WindowPos3sMESA(short x, short y, short z)
void WindowPos3fMESA(float x, float y, float z)
void WindowPos3dMESA(double x, double y, double z)
void WindowPos3ivMESA(const int *p)
void WindowPos3svMESA(const short *p)
void WindowPos3fvMESA(const float *p)
void WindowPos3dvMESA(const double *p)
void WindowPos4iMESA(int x, int y, int z, int w)
void WindowPos4sMESA(short x, short y, short z, short w)
void WindowPos4fMESA(float x, float y, float z, float w)
void WindowPos4dMESA(double x, double y, double z, double )
void WindowPos4ivMESA(const int *p)
void WindowPos4svMESA(const short *p)
void WindowPos4fvMESA(const float *p)
void WindowPos4dvMESA(const double *p)
New Tokens
@@ -84,7 +64,7 @@ Additions to Chapter 2 of the OpenGL 1.2 Specification (OpenGL Operation)
WindowPosMESA commands:
void WindowPos{234}{sidf}MESA( T coords );
void WindowPos{234}{sidf}vMESA( T coords );
void Window Pos{234}{sidf}vMESA( T coords );
WindosPos4MESA takes four values indicating x, y, z, and w.
WindowPos3MESA (or WindowPos2MESA) is analaguos, but sets only
@@ -98,6 +78,14 @@ Additions to Chapter 2 of the OpenGL 1.2 Specification (OpenGL Operation)
color, color index and texture coordinate update the current raster
position's associated data.
The current raster distance ??? XXX ???
Additions to the AGL/GLX/WGL Specifications
None
@@ -112,6 +100,7 @@ Errors
INVALID_OPERATION is generated if WindowPosMESA is called betweeen
Begin and End.
New State
None.
@@ -123,5 +112,3 @@ New Implementation Dependent State
Revision History
* Revision 1.0 - Initial specification
* Revision 1.1 - Minor clean-up (7 Jan 2000, Brian Paul)

View File

@@ -1,8 +1,12 @@
3Dfx Glide device driver for Mesa 3.3
3Dfx Glide device driver for Mesa 3.1
(see below for FAQ)
This software is distributed under the terms of the GNU Library
General Public License, see the LICENSE file for details.
What do you need ?
------------------
@@ -185,9 +189,9 @@ Doing more with Mesa & Linux Glide:
quality. However you can use any visual depth supported by X.
2. Set the following environment variables:
export MESA_GLX_FX="window" # to enable window rendering
export SST_VGA_PASS=1 # to stop video signal switching
export SST_NOSHUTDOWN=1 # to stop video signal switching
export MESA_GLX_FX="window" // to enable window rendering
export SST_VGA_PASS=1 // to stop video signal switching
export SST_NOSHUTDOWN=1 // to stop video signal switching
OR
setenv MESA_GLX_FX window
setenv SST_VGA_PASS 1
@@ -205,9 +209,6 @@ Doing more with Mesa & Linux Glide:
visual depth doesn't match the Voodoo framebufffer bit per pixel, it
is required also a pixel format translation).
NOTE: the in-window rendering feature only works with double-buffering.
On the fly switching between in window rendering and full screen rendering
--------------------------------------------------------------------------
@@ -326,11 +327,6 @@ The Mesa/Voodoo Environment Variables:
export MESA_FX_INFO=1
you will get some useful statistic.
- If you define the env. var. MESA_FX_NO_SIGNALS:
export MESA_FX_NO_SIGNALS=1
Mesa/FX will not install atexit() or signal() handlers.
Know BUGS and Problems:
-----------------------
@@ -545,7 +541,9 @@ No because the Linux Glide doesn't (yet) support the Voodoo Rush.
a binary copy of the Mesa in order to make the software
working out of the box ?
Yes.
Yes, you have simply to include some informations about authors
and where the library sources are available (check the LICENSE
file for more informations about the GNU GPL).
11. Which is the best make target for compiling the Mesa for

View File

@@ -99,4 +99,4 @@ of February, 1999.
----------------------------------------------------------------------
$Id: README.BEOS,v 1.6 1999/11/27 01:40:40 brianp Exp $
$Id: README.BEOS,v 1.5.6.1 1999/11/27 01:39:50 brianp Exp $

View File

@@ -1,50 +1,120 @@
August 30, 1998 -- Paul Garceau
Updated January 13, 2000 -- Paul Garceau (pgarceau@teleport.com)
August 30, 1998 -- Paul Garceau (pgarceau@teleport.com)
DISCLAIMER: I make this port of the Mesa 3-D Graphics Library as a service
DISCLAIMER: I make this extension to the Mesa 3-D Graphics Library as a service
to the general public. I can, in no way support or make any guarantee that the
build will work for your system.
The associated packages and batch files I have included as part of the GCC-2.95.2/Mingw32 extension are provided "As-is" with out any guarantee of support or functionality from this author.
EGCS-Mingw32 build or any Gnu-Win32 build will work for your system. The
associated packages and batch files I have included as part of the EGCS-Mingw32
extension are provided "As-is" with out any guarantee of support or functionality
from the author of this EGCS-Mingw32 native windows port of the Mesa 3-D Graphics
Library.
Feel free to modify or change things as you see fit, just remember that
I can't support any modifications you might want to make to the files which I
have included OR the lgpl protected Mesa 3-D Graphics Library.
I recommend using GCC-2.95.2/Mingw32 which is available at Mumit Khans' ftp site:
(ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/)
EGCS-Mingw32 Beta 3.08 Archive Manifest:
mingw32.bat
src/makefile.nt4
src/wmesa.c
src-glu/makefile.nt4
This build has been tested under WinNT4/SP6. Win9x and WinNT5 remain untested by me. I have not tested any of the demos included with Mesa3d.
###############
I recommend using the GCC-2.95.2/Mingw32.
Greetings,
ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/gcc-2.95.2
In order to build the Mingw32 set of Mesa 3-D Graphics Library for Beta3.08
it will be necessary for you to use the Dos or Command Prompt that is available
on most of the i86 based MS Windows machines. Also, I believe that this build
will run on Win95, Win98, WinNT4 and WinNT5.
I haven't tested Win95/98 or WinNT5. This build was generated under
WinNT4 with SP3 installed.
This has not been tested under any systems outside of
a WinNT4 Workstation with EGCS-Mingw32 toolchain, v.1.0.2 installed.
EGCS-Mingw32 uses a variation of gcc to handle its build. The Mesa 3-D
Graphics Library build that I have generated is based, in small part, on the
Cygwin32 build and associated makefiles that Stephane Rehel (rehel@worldnet.fr)
defined back in 1997. The EGCS-Mingw32 toolchain is capable of generating
native windows code and, as of the date of this readme, can be obtained from:
http://www.xraylith.wisc.edu/~khan/software/gnu-win32/egcs-mingw32-102.html
Much thanks to the combined efforts of Mumit Khan, Jan-Jaap Vanderhagen
and Colin Peters for making it possible for the Mingw32 toolchain to exist. Also, thanks go out to Stephane Rehel for the work that was completed on the Cygwin build.
and Colin Peters for making it possible for the EGCS-Mingw32 toolchain to exist.
Installing GCC-2.95.2/Mingw32 Build:
Installing EGCS-Mingw32 Build Revisions:
a) Open the file archive (either tar.gz or .zip extensions)
To install the makefile and source revisions incorporated with this build
of the Mesa 3-D Graphics Library, you'll have to use a version of winzip. I am
in the process of finding a suitable Win32 compatible tar executable so that if
you don't have winzip, you can still decompress the files into their respective
folders/directories.
b) Decide the directory you want to move the archived files to.
a) Move the mingw32.zip file to the top level of the hard drive on your
system.
d) Extract the files from the archive.
e) Edit the mingw32.bat file to accomodate your choice of directory structure.
b) Copy all of the Beta 3.08 src/windows files to the src/ directory.
%mesaroot%: This is your root directory (Mesa-3.3)
%mesasrc%: This is the Mesa-3.3 src directory (Mesa-3.3\src)
%mesalib%: This is where the build will put libGL.a and libGLU.a
b) Open the Winzip file
c) Verify that the files will be properly extracted.
d) Extract the files with the Winzip "Overwrite" and "Use Folder Names"
options enabled.
The zip file directory structure extraction defaults to the top level of
the hard drive where the mingw32.zip file exists unless otherwise instructed by
you.
The version of wmesa.c included with the mingw32 archive needs to replace
the current version of the Beta 3.08 wmesa.c file in order for the egcs-mingw32
build to work. This is because the original Win32 stuff assumes that the glut
utilities are to be installed. The Glut utilities are not part of the
egcs-mingw32 build for Beta 3.08.
Build Considerations:
In order to get the build to work, I needed to create a special makefile
for each library which the Mesa 3-D Graphics Library requires since there is no
comparable make-config/config on a native windows platform.
Since I was only creating a few of the possible libraries for
Mesa (gl, glu), I only created the new make files in their respective libraries
src, src-glu). For libMesaaux.a. you will find a makefile for it in the
src-aux directory. libMesatk.a and libglut.a were not ported.
The build itself is a .bat based build and uses Gnu Make,Version 3.76.1 to
process the makefiles noted above. The build must be run from the directory
where the mingw32.bat file is. You can get the binary version of Make 3.76.1
from Jan-Jaap van der Heijden's site in Germany:
http://agnes.dida.physik.uni-essen.de/~janjaap/mingw32/download.html
It was necessary to modify some source code, specifically the source code
in the src-glu directory. I needed to modify nurbs.c, quadric.c and tess.c in
order to get them to work using the EGCS-Mingw32 toolchain.
The original EGCS-Mingw32 Toolchain, is available from:
http://www.xraylith.wisc.edu/~khan/software/gnu-win32/egcs-mingw32-102.html
Running the Build:
Open your Command Prompt or MS-DOS prompt.
Go to your Mesa-3.3 'root' directory
At the command line type: mingw32
Ok, now that we've got the basics out of the way, follows is all you need
to do in order to build the EGCS-Mingw32 version of libMesaGL.a and libMesaGLU.a:
That's all there is to it.
Open your Command Prompt/Dos prompt.
Go to your Mesa-3.0 beta 'root' directory.
This is the same directory that the Mesa mingw32.zip file was
originally stored in if you've installed the Mesa-3.0 beta 3-D
Graphics Library source as outlined in the "readme" file included
with the Mesa-3.0 beta distribution.
At the command line type: mingw32
mingw32 is the .bat file that actually does the build.
Enjoy!

View File

@@ -1,9 +1,7 @@
Mesa 3.0 MITS Information
This software is distributed under the terms of the GNU Library
General Public License, see the LICENSE file for details.
[The MITS code hasn't been update for Mesa 3.1 and may no longer work]
This document is a preliminary introduction to help you get

View File

@@ -1,33 +1,45 @@
NOTE: this information is obsolete for Mesa 3.1. Due to the big
changes in the Mesa code, the threads support is out of date.
Someone will have to review/update it.
Mesa Threads README
-------------------
Thread safety was introduced in Mesa 2.6 by John Stone and
Christoph Poliwoda.
It was redesigned in Mesa 3.3 so that thread safety is
supported by default (on systems which support threads,
that is). There is no measurable penalty on single
threaded applications.
NOTE that the only _driver_ which is thread safe at this time
is the OS/Mesa driver!
At present the mthreads code supports three thread APIS:
Mesa 2.6 is the starting point for an effort to make Mesa
safe in multithreaded applications. The files src/mthreads.c and
src/mthreads.h provide a platform independent threads API which Mesa
uses internally to provide thread-safe operation. At present the mthreads
code supports three thread APIS:
1) POSIX threads (aka pthreads).
2) Solaris / Unix International threads.
3) Win32 threads (Win 95/NT).
Support for other thread libraries can be added src/glthread.[ch]
Here's the current list of targets which enable multithreaded handling
in Mesa:
linux-386-pthread for Linux w/ Intel assembly and linuxthreads
sunos5-thread for Suns with SunOS 5.x, using Solaris threads
sunos5-pthread for Suns with SunOS 5.[56] using POSIX threads
sunos5-gcc-thread for Suns with SunOS 5.x and GCC, using Solaris threads
sunos5-gcc-pthread for Suns with SunOS 5.[56] and GCC, using POSIX threads
In order to guarantee proper operation, it is
In order to use Mesa with a multithreaded application, Mesa must be compiled
using one of the thread-enabled configurations. In cases where a platform
supports multiple APIs which are acceptable to Mesa, Mesa must be built
with the same threads API as the application in order for things to work
properly. For example, Solaris >= 2.5 support both POSIX threads and
Sun's own threads API. In order to guarantee proper operation, it is
necessary for both Mesa and application code to use the same threads API.
So, if your application uses Sun's thread API, then you should build Mesa
using one of the targets for Sun threads.
Since this effort is still very much a work in progress, not all
aspects of Mesa are thread safe. As of this release (Mesa 2.6) only the
osmesa drivers have been made MT-safe. As work continues, other drivers
such as the X11 drivers will also incorporate MT-safe features.
The mtdemos directory contains some example programs which use
multiple threads to render to osmesa rendering context(s).
@@ -38,15 +50,17 @@ only one that really supports multiprocessor machines (AFAIK). See
http://pauillac.inria.fr/~xleroy/linuxthreads/README for further
information about the usage of linuxthreads.
If you are interested in helping with thread safety work in Mesa
join the Mesa developers mailing list and post your proposal.
If you are interested in helping develop MT-safe Mesa, please send email
to j.stone@acm.org and poliwoda@volumegraphics.com who are the two most
directly involved in this effort currently. Similarly, if you have problems
using the MT-safe builds of Mesa, please send us comments/bugs etc.
Future versions of Mesa will include more extensive documentation related
to multithreading. This is the first release of our work, so please bear
with us.
Regards,
John Stone -- j.stone@acm.org johns@cs.umr.edu
Christoph Poliwoda -- poliwoda@volumegraphics.com
Version info:
Mesa 2.6 - initial thread support.
Mesa 3.3 - thread support mostly rewritten (Brian Paul)

View File

@@ -1,5 +1,5 @@
Mesa 3.3 Unix/X11 Information
Mesa 3.1 Unix/X11 Information
@@ -25,7 +25,7 @@ There are two ways to compile Mesa on Unix/X11 systems:
The top-level makefile will execute the makefiles in a number of sub-
directories. When finished, the Mesa libraries will be in the Mesa-3.3/lib/
directories. When finished, the Mesa libraries will be in the Mesa-3.1/lib/
directory. A few GLUT demos in the demos/ directory should be ready to run.
If you also downloaded and unpacked the demos there should be executables
@@ -35,20 +35,6 @@ If you have compilation problems you should try to fix them and return the
patches to the author.
Notes on assembly language optimizations:
When using the old-style Makefiles, you can specify a configuration
that uses X86 assembly language optimizations (linux-3dnow for example).
The detection of MMX, 3DNow!, PIII/SSE, etc capability is done at
runtime. That means you can compile Mesa for 3DNow! optimizations
even if you don't have an AMD CPU.
However, your Linux binutils and assembler must understand the
special instructions in order to compile them. If you have
compilation problems, try upgrading your binutils.
Header and library files:
After you've compiled Mesa and tried the demos I recommend the following
procedure for "installing" Mesa.
@@ -141,7 +127,7 @@ Xt/Motif Widgets:
Togl:
Togl is an OpenGL/Mesa widget for Tcl/Tk.
See http://togl.sourceforge.net for more information.
See http://www.ssec.wisc.edu/~brianp/Togl.html for more information.
@@ -260,7 +246,6 @@ Extensions:
The following OpenGL GLX extensions are currently implemented:
GLX_EXT_visual_info - GLX visual and transparent pixel extension
GLX_EXT_visual_rating - GLX visual caveats
For detailed information about the extensions see www.opengl.org
@@ -323,4 +308,4 @@ Summary of X-related environment variables:
----------------------------------------------------------------------
$Id: README.X11,v 3.5 2000/04/04 15:14:48 brianp Exp $
$Id: README.X11,v 3.3.2.2 1999/12/14 15:12:52 brianp Exp $

View File

@@ -1,146 +0,0 @@
Mesa 3.1 release notes
PLEASE READ!!!!
New copyright
-------------
Mesa 3.1 will be distributed under an XFree86-style copyright instead
of the GNU LGPL.
New directories
---------------
All documentation files are now in the docs/ directory.
All shell scripts are now in the bin/ directory.
New library names
-----------------
Formerly, the main Mesa library was named libMesaGL.so (or libMesaGL.a)
and the GLU library was named libMesaGLU.so (or libMesaGLU.a).
Now, the main library is named libGL.so (or libGL.a) and the GLU library
is named libGLU.so (or libGLU.a).
The change allows Mesa to be more easily substituted for OpenGL.
Specifically, the linker/loader on some Unix-like systems won't
allow libMesaGL.so to be used instead of libGL.so if the application
was linked with the former.
Warning: if you have another OpenGL implementation installed on your
system (i.e. you have another OpenGL libGL.so) you'll have to be
carefull about which library (OpenGL or Mesa) you link against. Be
aware of -L linker flags and the value of the LD_LIBRARY_PATH environment
variable.
New library versioning
----------------------
Previously, the Mesa GL library was named libMesaGL.so.3.0
To better support Linux/OpenGL standards, the Mesa GL library is now
named libGL.so.1.2.030100 This indicates version 1.2 of the OpenGL spec
and Mesa implementation 3.1.0
In the long term this will allow better interoperability with other
OpenGL implementations, especially on Linux. In the short term,
OpenGL apps may have to be relinked to use the new library naming.
New makefiles
-------------
The old Makefiles found in the various directories have been renamed
to Makefile.X11 in order to prevent filename collisions with autoconfig-
generated Makefiles.
The top-level Makefile simply includes Makefile.X11
If your top-level Makefile get's overwritten/destroyed you can restore
it by copying Makefile.X11 to Makefile
New extensions
--------------
GL_EXT_stencil_wrap
Implements two new stencil operations: GL_INCR_WRAP_EXT and
GL_DECR_WRAP_EXT which allow stencil increment and decrement
without clamping.
GL_INGR_blend_func_separate
Allows specification of blend factors for RGB and Alpha independently.
(INGR = Intergraph)
GL_ARB_multitexture
Multiple simultaneous textures. (ARB = Architecture Review Board)
GL_NV_texgen_reflection
nVidia texgen extension for better reflection mapping.
GL_PGI_misc_hints
Assorted transformation hints.
GL_EXT_compiled_vertex_array
Compiled vertex arrays.
GL_EXT_clip_volume_hint
Allows one to disable clip volume (frustum) testing.
Extensions removed
------------------
GL_EXT_multitexture - obsolete in favor of GL_ARB_multitexture
Config file
-----------
By default, /etc/mesa.conf will be read when Mesa starts. This
file controls default hints, enable/disable of extensions, and
more. See the CONFIG file for documentation.
Optimizations
-------------
Keith Whitwell has contributed significant optimizations to Mesa's
vertex transformation code. Basically, the whole transformation
stage of Mesa has been rewritten.
It's impossible to give a speedup factor. You'll just have to
try your app and see how it performs.
Device Driver changes
---------------------
A bunch of new device driver functions have been added. See src/dd.h
Keith Harrison contributed many of them. I've been planning on adding
a bunch of functions like these to make writing hardware drivers easier.
More such function will probably be added in the near future.
Miscellaneous
-------------
util/glstate.c has some handy functions for debugging. Basically, it
offers a simple function for printing GL state variables. It's not
finished yet. There's a LOT more GLenum records to be added (see the
code). Anyone want to help?
----------------------------------------------------------------------
$Id: RELNOTES-3.1,v 1.2 2000/04/07 17:08:06 brianp Exp $

View File

@@ -1,12 +0,0 @@
Mesa 3.2 release notes
PLEASE READ!!!!
Mesa 3.2 is a stabilization of the Mesa 3.1 release. No new features
have been added. For a list of bug fixes please read the VERSIONS file.
----------------------------------------------------------------------
$Id: RELNOTES-3.2,v 1.2 2000/04/07 17:08:06 brianp Exp $

View File

@@ -1,32 +0,0 @@
Mesa 3.2.1 release notes
PLEASE READ!!!!
The Mesa 3.2.1 release mainly just fixes bugs since the 3.2 release.
See the VERSIONS file for the exact list.
GLU Polygon Tessellator
-----------------------
The GLU tessellator has been reverted back to the version included
with Mesa 3.0 since it's more stable. The Mesa 3.1/3.2 tessellator
implemented the GLU 1.3 specification but suffered from a number of
bugs.
Mesa implements GLU 1.1.
Ideally, people should use the GLU 1.3 library included in SGI's
OpenGL Sample Implementation (SI) available from
http://oss.sgi.com/projects/ogl-sample/
People are working to make easy-to-install Linux RPMs of the
GLU library.
----------------------------------------------------------------------
$Id: RELNOTES-3.2.1,v 1.2 2000/07/21 16:32:33 brianp Exp $

View File

@@ -1,271 +0,0 @@
Mesa 3.3 release notes
July 21, 2000
PLEASE READ!!!!
Introduction
------------
Mesa uses an even/odd version number scheme like the Linux kernel.
Odd numbered versions (such as 3.3) designate new developmental releases.
Even numbered versions (such as 3.2.1) designate stable releases.
Mesa 3.3 has a undergone many internal changes since version 3.2
and features a lot of new extensions. 3.3 is expected to be pretty
stable, but perhaps not as stable as 3.2 which has been used by
thousands of users over the past months.
Everyone is encouraged to try Mesa 3.3. Bugs should be reported to
the Mesa bug database on www.sourceforge.net.
Header file / GLenum changes
----------------------------
The gl.h and glu.h headers now use #defines to define all GL_* tokens
instead of C-language enums. This change improves Mesa/OpenGL
interoperability.
New API dispatch code
---------------------
The core Mesa gl* functions are now implemented with a new dispatch
(jump table) which will allow simultaneous direct/indirect rendering.
The code is found in the glapi*.[ch] files.
Of interest: the actual "glFooBar" functions are generated with
templatized code defined in glapitemp.h and included by glapi.c
The glapitemp.h template should be reusable for all sorts of OpenGL
projects.
The new dispatch code has also optimized with x86 assembly code.
This optimization eliminates copying the function arguments during
dispatch.
New thread support
------------------
Thread support in Mesa has been rewritten. The glthread.[ch] files
replace mthreads.[ch]. Thread safety is always enabled (on platforms
which support threads, that is). There is virtually no performance
penalty for typical single-thread applications. See the glapi.c
file for details.
The Xlib driver (XMesa) is now thread-safe as well. Be sure to
call XInitThreads() in your app first. See the xdemos/glthreads.c
demo for an example.
Make configuration changes
--------------------------
If you use the old-style (non GNU automake) method to build Mesa note
that several of the configuration names have changed:
Old name New name
------------- ----------------
linux-elf linux
linux linux-static
linux-386-elf linux-386
linux-386 linux-386-static
etc.
New extensions
--------------
GL_ARB_transpose_matrix
Adds glLoadTransposeMatrixARB() and glMultTransposeMatrixARB()
functions.
GL_ARB_texture_cube_map
For cube-based reflection mapping.
GL_EXT_texture_add_env
Adds GL_ADD texture environment mode.
See http://www.berkelium.com/OpenGL/EXT/texture_env_add.txt
GL_EXT_texture_lod_bias
Allows mipmapped texture blurring and sharpening.
GLX_EXT_visual_rating extension
This extension has no effect in stand-alone Mesa (used for DRI).
GL_HP_occlusion_test
Used for bounding box occlusion testing (see demos/occlude.c).
GL_SGIX_pixel_texture / GL_SGIS_pixel_texture
Lets glDraw/CopyPixels draw a texture coordinate image.
GL_SGI_color_matrix
Adds a color matrix and another set of scale and bias parameters
to the glDraw/CopyPixels paths.
GL_SGI_color_table
Adds additional color tables to the glDraw/Read/CopyPixels paths.
GL_EXT_histogram
Compute histograms for glDraw/Read/CopyPixels.
GL_EXT_blend_func_separate
This is the same as GL_INGR_blend_func_separate.
GL_ARB_texture_cube_mapping
6-face cube mapping, nicer than sphere mapping
GL_EXT_texture_env_combine
For advanced texture environment effects.
Documentation for all these functions can be found at
http://oss.sgi.com/projects/ogl-sample/registry/
GLX_SGI_make_current_read functionality
---------------------------------------
The functionality of this extension is needed for GLX 1.3 (and required
for the Linux/OpenGL standards base).
Implementing this function required a **DEVICE DRIVER CHANGE**.
The old SetBuffer() function has been replaced by SetReadBuffer() and
SetDrawBuffer(). All device drivers will have to be updated because
of this change.
The new function, glXMakeContextCurrent(), in GLX 1.3 now works in Mesa.
The xdemos/wincopy.c program demonstrates it.
Image-related code changes
--------------------------
The imaging path code used by glDrawPixels, glTexImage[123]D,
glTexSubImage[123], etc has been rewritten. It's now faster,
uses less memory and has several bug fixes. This work was
actually started in Mesa 3.1 with the glTexImage paths but has now
been carried over to glDrawPixels as well.
Device driver interface changes
-------------------------------
Added new functions for hardware stencil buffer support:
WriteStencilSpan
ReadStencilSpan
WriteStencilPixels
ReadStencilPixels
Removed old depth buffer functions:
AllocDepthBuffer
DepthTestSpan
DepthTestPixels
ReadDepthSpanFloat
ReadDepthSpanInt
Added new depth buffer functions:
WriteDepthSpan
ReadDepthSpan
WriteDepthPixels
ReadDepthPixels
These functions always read/write 32-bit GLuints. This will allow
drivers to have anywhere from 0 to 32-bit Z buffers without
recompiling for 16 vs 32 bits as was previously needed.
New texture image functions
The entire interface for texture image specification has been updated.
With the new functions, it's optional for Mesa to keep an internal copy
of all textures. Texture download should be a lot faster when the extra
copy isn't made.
Misc changes
TexEnv now takes a target argument
Removed UseGlobalTexturePalette (use Enable function instead)
Also added
ReadPixels
CopyPixels
The SetBufffer function has been replaced by SetDrawBuffer and
SetReadBuffer functions. This lets core Mesa independently
specify which buffer is to be used for reading and which for
drawing.
The Clear function's mask parameter has changed. Instead of
mask being the flags specified by the user to glClear, the
mask is now a bitmask of the DD_*_BIT flags in dd.h. Now
multiple color buffers can be specified for clearing (ala
glDrawBuffers). The driver's Clear function must also
check the glColorMask glIndexMask, and glStencilMask settings
and do the right thing. See the X/Mesa, OS/Mesa, or FX/Mesa
drivers for examples.
The depth buffer changes shouldn't be hard to make for existing
drivers. In fact, it should simply the code. Be careful with
the depthBits value passed to gl_create_context(). 1 is a bad
value! It should normally be 0, 16, 24, or 32.
gl_create_framebuffer() takes new arguments which explicitly tell
core Mesa which ancillary buffers (depth, stencil, accum, alpha)
should be implemented in software. Mesa hardware drivers should
carefully set these flags depending on which buffers are in the
graphics card.
Internal constants
------------------
Point and line size range and granularity limits are now stored
in the gl_constants struct, which is the Const member of GLcontext.
The limits are initialized from values in config.h but may be
overridden by device drivers to reflect the limits of that driver's
hardware.
Also added constants for NumAuxBuffers and SubPixelBits.
OpenGL Conformance
------------------
Mesa now passes all the OpenGL 1.1 conformance tests, except for
antialiased lines. AA lines fail on some, but not all, the tests.
In order to fix the remaining failures, a new AA line algorithm will
be needed (which computes coverage values for end-point fragments).
This will be done for Mesa 3.5/3.6.
OpenGL 1.2 GL_ARB_imaging subset
--------------------------------
Mesa 3.3 implements all the features of GL_ARB_imaging except for
image convolution. This will (hopefully) be done for Mesa 3.5/3.6.
----------------------------------------------------------------------
$Id: RELNOTES-3.3,v 1.8 2000/07/21 16:26:41 brianp Exp $

View File

@@ -1,4 +1,4 @@
$Id: VERSIONS,v 1.38 2000/07/21 15:41:59 brianp Exp $
$Id: VERSIONS,v 1.13.2.5 1999/12/14 07:17:42 brianp Exp $
Mesa Version History
@@ -666,83 +666,7 @@ Mesa Version History
- added demos/gloss.c
- added xdemos/glxdpyinfo.c
- added GLX_ARB_get_proc_address extension
- rewritten glTexImage code paths (faster, less memory, bug fixes)
Bug Fixes:
Bug fixes:
- several vertex array bug fixes
- overlapping glCopyPixels with pixel zooming now works
- glXUseXFont() bitmaps were vertically shifted by one pixel
- glCopyPixels with pixel zooming now works
3.2 final April 24, 2000
Bug fixes:
- fixed memcpy bugs in span.c
- fixed missing glEnd problem in demos/tessdemo.c
- fixed bug when clearing 24bpp Ximages
- fixed clipping problem found in Unreal Tournament
- fixed Loki's "ice bug" and "crazy triangles" seen in Heretic2
- fixed Loki's 3dfx RGB vs BGR bug
- fixed Loki's 3dfx smooth/flat shading bug in SoF
Changes:
- updated docs/README file
- use bcopy() optimizations on FreeBSD
- re-enabled the optimized persp_textured_triangle() function
3.2.1 July 19, 2000
Bug fixes:
- gluBuild2DMipmaps() didn't accept GL_BGRA
- Fixed compile/makefile problems on IRIX
- fixed segfault in 3dfx driver when using GL selection/feedback
- no longer cull very, very tiny triangles
- blending w/ drawbuffer==GL_FRONT_BACK caused segfault (sw rendering)
- fixed Motif detection code in widgets-mesa/configure.in
- glColorMaterial and glMaterial updates to emissive and ambient
didn't always work right
- Specular highlights weren't always in the right place
- clipped GL_LINE mode polygons had interior lines appear
- blend term GL_ONE_MINUS_CONSTANT_ALPHA was broken
- GL_NICEST fog didn't always work with flat shading
- glRect commands in display lists were sometimes miscolored
- Line Z offset didn't always work
- fixed texgen normal vector problem (gloss's teapot)
- numerous GL conformance bugs fixed
Changes:
- glColorMask(false, false, false, false) handled better/faster
- reverted to old GLU polygon tessellator, GLU 1.1
- updated Win32 build files
3.3 July 21, 2000
New:
- antialiased triangles now implemented
- GL_EXT_texture_env_add texture mode extension
- GLX 1.3 API
- support for separate draw/read buffers (ie GL_SGI_make_current_read)
- thread-safe API dispath
- improved glxinfo program
- demos/texdown program to measure texture download performance
- glext.h header file
- demos/geartrain program
- GL_EXT_texture_lod_bias extension
- demos/lodbias program
- further optimized glRead/DrawPixels for 16-bit TrueColor X visuals
- GLX_EXT_visual_rating extension (a no-op, however)
- GL_HP_occlusion_test extension (for X and OS/Mesa drivers)
- demos/occlude program
- GL_SGIS_pixel_texture and GL_SGIX_pixel_texture extensions
- demos/pixeltex program
- GL_SGI_color_matrix extension
- GL_SGI_color_table extension
- GL_EXT_histogram extension
- GL_ARB_texture_cube_map extension
- added xdemos/glxheads and xdemos/manywin
- demos/texenv.c demo
- GL_EXT_texture_env_combine extension (by Holger Waechtler)
- Xlib driver is now thread-safe (see xdemos/glthreads)
Bug Fixes:
- various GL conformance failures fixed since 3.2.1
Changes:
- gl.h now uses #defines instead of C enums for all tokens
- glu.h now uses #defines instead of C enums for all tokens
- moved programs from 3Dfx/demos/ into demos/ directory

View File

@@ -1,10 +1,10 @@
/* $Id: amesa.h,v 1.2 2000/02/09 19:03:28 brianp Exp $ */
/* $Id: amesa.h,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.3
* Version: 3.1
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -25,17 +25,25 @@
*/
/*
* $Log: amesa.h,v $
* Revision 1.1 1999/08/19 00:55:40 jtg
* Initial revision
*
* Revision 1.1 1999/03/16 01:24:13 brianp
* initial check-in
*
*/
/* Allegro (DJGPP) driver by Bernhard Tschirren (bernie-t@geocities.com) */
#ifndef AMESA_H
#define AMESA_H
#define AMESA_MAJOR_VERSION 3
#define AMESA_MINOR_VERSION 3
typedef struct amesa_visual *AMesaVisual;
typedef struct amesa_buffer *AMesaBuffer;
typedef struct amesa_context *AMesaContext;

View File

@@ -1,23 +1,27 @@
/* $Id: fxmesa.h,v 1.2 1999/11/24 18:44:53 brianp Exp $ */
/* $Id: fxmesa.h,v 1.1.1.1.2.1 1999/11/24 18:38:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.3
* Copyright (C) 1995-1999 Brian Paul
* Version: 3.1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
* 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:
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
@@ -41,7 +45,7 @@ extern "C" {
#define FXMESA_MAJOR_VERSION 3
#define FXMESA_MINOR_VERSION 3
#define FXMESA_MINOR_VERSION 1
/*

View File

@@ -1,9 +1,9 @@
/* $Id: ggimesa.h,v 1.3 2000/02/09 19:03:28 brianp Exp $ */
/* $Id: ggimesa.h,v 1.2 1999/08/23 22:34:08 jtaylor Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.3
* Copyright (C) 1995-2000 Brian Paul
* Version: 3.1
* Copyright (C) 1995-1998 Brian Paul
* Copyright (C) 1998 Uwe Maurer
*
* This library is free software; you can redistribute it and/or
@@ -22,14 +22,23 @@
*/
/*
* $Log: ggimesa.h,v $
* Revision 1.2 1999/08/23 22:34:08 jtaylor
* Misc small cleanups
*
* Revision 1.1.1.1 1999/08/19 00:55:40 jtg
* Imported sources
*
* Revision 1.2 1998/09/29 01:46:40 brianp
* applied Emmanuel Marty's patches for latest GGI
*
*/
#ifndef GGIMESA_H
#define GGIMESA_H
#define GGIMESA_MAJOR_VERSION 3
#define GGIMESA_MINOR_VERSION 3
#ifdef __cplusplus
extern "C" {
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
/* $Id: gl_mangle.h,v 1.4 2000/01/04 08:07:09 brianp Exp $ */
/* $Id: gl_mangle.h,v 1.3 1999/11/04 00:43:09 miklos Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.3
* Version: 3.1
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
@@ -396,8 +396,6 @@
#define glTexSubImage3DEXT mglTexSubImage3DEXT
#define glCopyTexSubImage3DEXT mglCopyTexSubImage3DEXT
#define glColorTable mglColorTable
#define glColorTableParameteriv mglColorTableParameteriv
#define glColorTableParameterfv mglColorTableParameterfv
#define glColorSubTable mglColorSubTable
#define glGetColorTable mglGetColorTable
#define glGetColorTableParameteriv mglGetColorTableParameteriv

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,10 @@
/* $Id: glu.h,v 1.22 2000/07/11 14:11:44 brianp Exp $ */
/* $Id: glu.h,v 1.16 1999/11/11 03:21:43 kendallb Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.3
* Copyright (C) 1995-2000 Brian Paul
*
* Copyright (C) 1995-1999 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -35,11 +36,10 @@ extern "C" {
#endif
#include <GL/gl.h>
#include "GL/gl.h"
/* to facilitate clean DLL building ... */
#if !defined(OPENSTEP) && (defined(__WIN32__) || defined(__CYGWIN__))
#if !defined(OPENSTEP) && (defined(__WIN32__) || defined(__CYGWIN32__))
# if defined(_MSC_VER) && defined(BUILD_GLU32) /* tag specify we're building mesa as a DLL */
# define GLUAPI __declspec(dllexport)
# elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
@@ -47,19 +47,9 @@ extern "C" {
# else /* for use with static link lib build of Win32 edition only */
# define GLUAPI extern
# endif /* _STATIC_MESA support */
# define GLCALLBACK __stdcall
# define GLCALLBACKP __stdcall *
#else
# define GLUAPI extern
# define GLCALLBACK
# define GLCALLBACKP *
#endif /* WIN32 / CYGWIN bracket */
/* compatability guard so we don't need to change client code */
#if defined(_WIN32) && !defined(_WINDEF_) && !defined(_GNU_H_WINDOWS32_BASE) && !defined(OPENSTEP)
# define CALLBACK GLCALLBACK
#endif
#endif /* WIN32 / CYGWIN32 bracket */
#ifdef macintosh
#pragma enumsalwaysint on
@@ -82,7 +72,7 @@ extern "C" {
#define GLU_VERSION_1_1 1
#define GLU_VERSION_1_2 1
#define GLU_TRUE 1
@@ -199,22 +189,17 @@ extern "C" {
#define GLU_NURBS_ERROR36 100286 /* null control point reference */
#define GLU_NURBS_ERROR37 100287 /* duplicate point on pwlcurve */
/* GLU 1.3 and later */
#define GLU_NURBS_MODE ?
/* Errors */
#define GLU_INVALID_ENUM 100900
#define GLU_INVALID_VALUE 100901
#define GLU_OUT_OF_MEMORY 100902
#define GLU_INCOMPATIBLE_GL_VERSION 100903
/* GLU 1.1 and later */
/* New in GLU 1.1 */
#define GLU_VERSION 100800
#define GLU_EXTENSIONS 100801
/*** GLU 1.0 tessellation ***/
/*** GLU 1.0 tessellation - obsolete! ***/
/* Contour types */
#define GLU_CW 100120
@@ -231,26 +216,20 @@ extern "C" {
#define GLU_EDGE_FLAG GLU_TESS_EDGE_FLAG
/*
* These are the GLU 1.1 typedefs. GLU 1.3 has different ones!
*/
#if defined(__BEOS__)
/* The BeOS does something funky and makes these typedefs in one
* of its system headers.
*/
#else
#if defined GLU_VERSION_1_2
typedef struct GLUquadric GLUquadricObj;
typedef struct GLUnurbs GLUnurbsObj;
/* FIXME: We need to implement the other 1.3 typedefs - GH */
typedef struct GLUtesselator GLUtesselator;
typedef GLUtesselator GLUtriangulatorObj;
#else
/* GLU 1.1 and older */
typedef struct GLUquadric GLUquadricObj;
typedef struct GLUtriangulatorObj GLUtriangulatorObj;
typedef struct GLUnurbs GLUnurbsObj;
#endif
#endif
@@ -310,17 +289,17 @@ GLUAPI const GLubyte* GLAPIENTRY gluErrorString( GLenum errorCode );
*/
GLUAPI GLint GLAPIENTRY gluScaleImage( GLenum format,
GLsizei widthin, GLsizei heightin,
GLint widthin, GLint heightin,
GLenum typein, const void *datain,
GLsizei widthout, GLsizei heightout,
GLint widthout, GLint heightout,
GLenum typeout, void *dataout );
GLUAPI GLint GLAPIENTRY gluBuild1DMipmaps( GLenum target, GLint components,
GLsizei width, GLenum format,
GLint width, GLenum format,
GLenum type, const void *data );
GLUAPI GLint GLAPIENTRY gluBuild2DMipmaps( GLenum target, GLint components,
GLsizei width, GLsizei height,
GLint width, GLint height,
GLenum format,
GLenum type, const void *data );
@@ -359,15 +338,14 @@ GLUAPI void GLAPIENTRY gluCylinder( GLUquadricObj *qobj,
GLint slices, GLint stacks );
GLUAPI void GLAPIENTRY gluSphere( GLUquadricObj *qobj,
GLdouble radius,
GLint slices, GLint stacks );
GLdouble radius, GLint slices,
GLint stacks );
GLUAPI void GLAPIENTRY gluDisk( GLUquadricObj *qobj,
GLdouble innerRadius, GLdouble outerRadius,
GLint slices, GLint loops );
GLUAPI void GLAPIENTRY gluPartialDisk( GLUquadricObj *qobj,
GLdouble innerRadius,
GLUAPI void GLAPIENTRY gluPartialDisk( GLUquadricObj *qobj, GLdouble innerRadius,
GLdouble outerRadius, GLint slices,
GLint loops, GLdouble startAngle,
GLdouble sweepAngle );
@@ -421,8 +399,8 @@ GLUAPI void GLAPIENTRY gluBeginTrim( GLUnurbsObj *nobj );
GLUAPI void GLAPIENTRY gluEndTrim( GLUnurbsObj *nobj );
GLUAPI void GLAPIENTRY gluPwlCurve( GLUnurbsObj *nobj, GLint count,
GLfloat *array,
GLint stride, GLenum type );
GLfloat *array, GLint stride,
GLenum type );
GLUAPI void GLAPIENTRY gluNurbsCallback( GLUnurbsObj *nobj, GLenum which,
void (GLCALLBACK *fn)() );
@@ -435,8 +413,6 @@ GLUAPI void GLAPIENTRY gluNurbsCallback( GLUnurbsObj *nobj, GLenum which,
*
*/
#ifdef GLU_VERSION_1_2
GLUAPI GLUtesselator* GLAPIENTRY gluNewTess( void );
GLUAPI void GLAPIENTRY gluDeleteTess( GLUtesselator *tobj );
@@ -465,26 +441,17 @@ GLUAPI void GLAPIENTRY gluTessCallback( GLUtesselator *tobj, GLenum which,
GLUAPI void GLAPIENTRY gluGetTessProperty( GLUtesselator *tobj, GLenum which,
GLdouble *value );
#else
/*
*
* Obsolete 1.0 tessellation functions
*
*/
GLUAPI GLUtriangulatorObj* GLAPIENTRY gluNewTess( void );
GLUAPI void GLAPIENTRY gluBeginPolygon( GLUtesselator *tobj );
GLUAPI void GLAPIENTRY gluTessCallback( GLUtriangulatorObj *tobj, GLenum which,
void (GLCALLBACK *fn)() );
GLUAPI void GLAPIENTRY gluDeleteTess( GLUtriangulatorObj *tobj );
GLUAPI void GLAPIENTRY gluBeginPolygon( GLUtriangulatorObj *tobj );
GLUAPI void GLAPIENTRY gluEndPolygon( GLUtriangulatorObj *tobj );
GLUAPI void GLAPIENTRY gluNextContour( GLUtriangulatorObj *tobj, GLenum type );
GLUAPI void GLAPIENTRY gluTessVertex( GLUtriangulatorObj *tobj, GLdouble v[3],
void *data );
#endif
GLUAPI void GLAPIENTRY gluNextContour( GLUtesselator *tobj, GLenum type );
GLUAPI void GLAPIENTRY gluEndPolygon( GLUtesselator *tobj );
@@ -498,21 +465,6 @@ GLUAPI const GLubyte* GLAPIENTRY gluGetString( GLenum name );
/*
*
* GLU 1.3 functions
*
*/
#ifdef GLU_VERSION_1_3
GLUAPI GLboolean GLAPIENTRY
gluCheckExtension( const char *extName, const GLubyte *extString );
#endif
#if defined(__BEOS__) || defined(__QUICKDRAW__)
#pragma export off
#endif

View File

@@ -108,7 +108,7 @@ extern _CRTIMP void __cdecl exit(int);
and redifinition of Windows system defs, also removes requirement of
pretty much any standard windows header from this file */
#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__CYGWIN32__)
#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
# define GLUTAPIENTRY __stdcall
#else
# define GLUTAPIENTRY
@@ -199,7 +199,7 @@ WGLAPI int GLAPIENTRY SetPixelFormat(HDC,int,const PIXELFORMATDESCRIPTOR *);
# define GLUTCALLBACK
# define GLUTAPI extern
/* Prototype exit for the non-Win32 case (see above). */
/*extern void exit(int); this screws up gcc -ansi -pedantic! */
extern void exit(int);
#endif

View File

@@ -1,10 +1,10 @@
/* $Id: glx.h,v 1.22 2000/06/23 17:39:18 brianp Exp $ */
/* $Id: glx.h,v 1.5.2.2 1999/12/10 14:55:38 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.3
* Version: 3.1
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -25,25 +25,17 @@
*/
#ifndef GLX_H
#define GLX_H
#ifdef __VMS
# ifdef __cplusplus
/* VMS Xlib.h gives problems with C++.
* this avoids a bunch of trivial warnings */
#pragma message disable nosimpint
#endif
#endif
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#ifdef __VMS
# ifdef __cplusplus
#pragma message enable nosimpint
#endif
#endif
#include "GL/gl.h"
#ifdef MESA
#include "GL/xmesa.h"
#endif
#if defined(USE_MGL_NAMESPACE)
@@ -57,33 +49,39 @@ extern "C" {
#define GLX_VERSION_1_1 1
#define GLX_VERSION_1_2 1
#define GLX_VERSION_1_3 1
#define GLX_EXTENSION_NAME "GLX"
/*
* Tokens for glXChooseVisual and glXGetConfig:
*/
#define GLX_USE_GL 1
#define GLX_BUFFER_SIZE 2
#define GLX_LEVEL 3
#define GLX_RGBA 4
#define GLX_DOUBLEBUFFER 5
#define GLX_STEREO 6
#define GLX_AUX_BUFFERS 7
#define GLX_RED_SIZE 8
#define GLX_GREEN_SIZE 9
#define GLX_BLUE_SIZE 10
#define GLX_ALPHA_SIZE 11
#define GLX_DEPTH_SIZE 12
#define GLX_STENCIL_SIZE 13
#define GLX_ACCUM_RED_SIZE 14
#define GLX_ACCUM_GREEN_SIZE 15
#define GLX_ACCUM_BLUE_SIZE 16
#define GLX_ACCUM_ALPHA_SIZE 17
enum _GLX_CONFIGS {
GLX_USE_GL = 1,
GLX_BUFFER_SIZE = 2,
GLX_LEVEL = 3,
GLX_RGBA = 4,
GLX_DOUBLEBUFFER = 5,
GLX_STEREO = 6,
GLX_AUX_BUFFERS = 7,
GLX_RED_SIZE = 8,
GLX_GREEN_SIZE = 9,
GLX_BLUE_SIZE = 10,
GLX_ALPHA_SIZE = 11,
GLX_DEPTH_SIZE = 12,
GLX_STENCIL_SIZE = 13,
GLX_ACCUM_RED_SIZE = 14,
GLX_ACCUM_GREEN_SIZE = 15,
GLX_ACCUM_BLUE_SIZE = 16,
GLX_ACCUM_ALPHA_SIZE = 17,
/* GLX_EXT_visual_info extension */
GLX_X_VISUAL_TYPE_EXT = 0x22,
GLX_TRANSPARENT_TYPE_EXT = 0x23,
GLX_TRANSPARENT_INDEX_VALUE_EXT = 0x24,
GLX_TRANSPARENT_RED_VALUE_EXT = 0x25,
GLX_TRANSPARENT_GREEN_VALUE_EXT = 0x26,
GLX_TRANSPARENT_BLUE_VALUE_EXT = 0x27,
GLX_TRANSPARENT_ALPHA_VALUE_EXT = 0x28
};
/*
@@ -107,70 +105,42 @@ extern "C" {
/*
* GLX 1.3 and later:
* GLX_visual_info extension
*/
#define GLX_CONFIG_CAVEAT 0x20
#define GLX_DONT_CARE 0xFFFFFFFF
#define GLX_SLOW_CONFIG 0x8001
#define GLX_NON_CONFORMANT_CONFIG 0x800D
#define GLX_X_VISUAL_TYPE 0x22
#define GLX_TRANSPARENT_TYPE 0x23
#define GLX_TRANSPARENT_INDEX_VALUE 0x24
#define GLX_TRANSPARENT_RED_VALUE 0x25
#define GLX_TRANSPARENT_GREEN_VALUE 0x26
#define GLX_TRANSPARENT_BLUE_VALUE 0x27
#define GLX_TRANSPARENT_ALPHA_VALUE 0x28
#define GLX_MAX_PBUFFER_WIDTH 0x8016
#define GLX_MAX_PBUFFER_HEIGHT 0x8017
#define GLX_MAX_PBUFFER_PIXELS 0x8018
#define GLX_PRESERVED_CONTENTS 0x801B
#define GLX_LARGEST_BUFFER 0x801C
#define GLX_DRAWABLE_TYPE 0x8010
#define GLX_FBCONFIG_ID 0x8013
#define GLX_VISUAL_ID 0x800B
#define GLX_WINDOW_BIT 0x00000001
#define GLX_PIXMAP_BIT 0x00000002
#define GLX_PBUFFER_BIT 0x00000004
#define GLX_AUX_BUFFERS_BIT 0x00000010
#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004
#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008
#define GLX_AUX_BUFFERS_BIT 0x00000010
#define GLX_DEPTH_BUFFER_BIT 0x00000020
#define GLX_STENCIL_BUFFER_BIT 0x00000040
#define GLX_ACCUM_BUFFER_BIT 0x00000080
#define GLX_DRAWABLE_TYPE 0x8010
#define GLX_RENDER_TYPE 0x8011
#define GLX_X_RENDERABLE 0x8012
#define GLX_NONE 0x8000
#define GLX_TRUE_COLOR 0x8002
#define GLX_DIRECT_COLOR 0x8003
#define GLX_PSEUDO_COLOR 0x8004
#define GLX_STATIC_COLOR 0x8005
#define GLX_GRAY_SCALE 0x8006
#define GLX_STATIC_GRAY 0x8007
#define GLX_TRANSPARENT_INDEX 0x8009
#define GLX_COLOR_INDEX_TYPE 0x8015
#define GLX_COLOR_INDEX_BIT 0x00000002
#define GLX_SCREEN 0x800C
#define GLX_PBUFFER_CLOBBER_MASK 0x08000000
#define GLX_DAMAGED 0x8020
#define GLX_SAVED 0x8021
#define GLX_WINDOW 0x8022
#define GLX_PBUFFER 0x8033
#define GLX_TRUE_COLOR_EXT 0x8002
#define GLX_DIRECT_COLOR_EXT 0x8003
#define GLX_PSEUDO_COLOR_EXT 0x8004
#define GLX_STATIC_COLOR_EXT 0x8005
#define GLX_GRAY_SCALE_EXT 0x8006
#define GLX_STATIC_GRAY_EXT 0x8007
#define GLX_NONE_EXT 0x8000
#define GLX_TRANSPARENT_RGB_EXT 0x8008
#define GLX_TRANSPARENT_INDEX_EXT 0x8009
/*
* Compile-time extension tests
*/
#define GLX_EXT_visual_info 1
#define GLX_MESA_pixmap_colormap 1
#define GLX_MESA_release_buffers 1
#define GLX_MESA_copy_sub_buffer 1
#define GLX_MESA_set_3dfx_mode 1
#define GLX_SGI_video_sync 1
#define GLX_ARB_get_proc_address 1
typedef void * GLXContext;
typedef XID GLXPixmap;
typedef XID GLXDrawable;
/* GLX 1.3 and later */
typedef void * GLXFBConfig;
typedef XID GLXFBConfigID;
#ifdef MESA
typedef XMesaContext GLXContext;
typedef Pixmap GLXPixmap;
typedef Drawable GLXDrawable;
#else
typedef void * GLXContext;
typedef XID GLXPixmap;
typedef XID GLXDrawable;
#endif
typedef XID GLXContextID;
typedef XID GLXWindow;
typedef XID GLXPbuffer;
@@ -186,7 +156,7 @@ extern Bool glXMakeCurrent( Display *dpy, GLXDrawable drawable,
GLXContext ctx);
extern void glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
unsigned long mask );
GLuint mask );
extern void glXSwapBuffers( Display *dpy, GLXDrawable drawable );
@@ -224,215 +194,34 @@ extern const char *glXQueryServerString( Display *dpy, int screen, int name );
extern const char *glXGetClientString( Display *dpy, int name );
/* GLX 1.2 and later */
extern Display *glXGetCurrentDisplay( void );
/* GLX 1.3 and later */
extern GLXFBConfig *glXChooseFBConfig( Display *dpy, int screen,
const int *attribList, int *nitems );
extern int glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
int attribute, int *value );
extern GLXFBConfig *glXGetFBConfigs( Display *dpy, int screen,
int *nelements );
extern XVisualInfo *glXGetVisualFromFBConfig( Display *dpy,
GLXFBConfig config );
extern GLXWindow glXCreateWindow( Display *dpy, GLXFBConfig config,
Window win, const int *attribList );
extern void glXDestroyWindow( Display *dpy, GLXWindow window );
extern GLXPixmap glXCreatePixmap( Display *dpy, GLXFBConfig config,
Pixmap pixmap, const int *attribList );
extern void glXDestroyPixmap( Display *dpy, GLXPixmap pixmap );
extern GLXPbuffer glXCreatePbuffer( Display *dpy, GLXFBConfig config,
const int *attribList );
extern void glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf );
extern void glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
unsigned int *value );
extern GLXContext glXCreateNewContext( Display *dpy, GLXFBConfig config,
int renderType, GLXContext shareList,
Bool direct );
extern Bool glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
GLXDrawable read, GLXContext ctx );
extern GLXDrawable glXGetCurrentReadDrawable( void );
extern int glXQueryContext( Display *dpy, GLXContext ctx, int attribute,
int *value );
extern void glXSelectEvent( Display *dpy, GLXDrawable drawable,
unsigned long mask );
extern void glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
unsigned long *mask );
/*#ifndef GLX_GLXEXT_LEGACY*/
/*#include <GL/glxext.h>*/
/*#else*/
/*
* 28. GLX_EXT_visual_info extension
*/
#ifndef GLX_EXT_visual_info
#define GLX_EXT_visual_info 1
#define GLX_X_VISUAL_TYPE_EXT 0x22
#define GLX_TRANSPARENT_TYPE_EXT 0x23
#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24
#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25
#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26
#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27
#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28
#define GLX_TRUE_COLOR_EXT 0x8002
#define GLX_DIRECT_COLOR_EXT 0x8003
#define GLX_PSEUDO_COLOR_EXT 0x8004
#define GLX_STATIC_COLOR_EXT 0x8005
#define GLX_GRAY_SCALE_EXT 0x8006
#define GLX_STATIC_GRAY_EXT 0x8007
#define GLX_NONE_EXT 0x8000
#define GLX_TRANSPARENT_RGB_EXT 0x8008
#define GLX_TRANSPARENT_INDEX_EXT 0x8009
#endif /* 28. GLX_EXT_visual_info extension */
/*
* 41. GLX_SGI_video_sync
*/
#ifndef GLX_SGI_video_sync
#define GLX_SGI_video_sync 1
extern int glXGetVideoSyncSGI(unsigned int *count);
extern int glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count);
#endif /* GLX_SGI_video_sync */
/*
* 42. GLX_EXT_visual_rating
*/
#ifndef GLX_EXT_visual_rating
#define GLX_EXT_visual_rating 1
#define GLX_VISUAL_CAVEAT_EXT 0x20
/*#define GLX_NONE_EXT 0x8000*/
#define GLX_SLOW_VISUAL_EXT 0x8001
#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D
#endif /* GLX_EXT_visual_rating */
/*
* 47. GLX_EXT_import_context
*/
#ifndef GLX_EXT_import_context
#define GLX_EXT_import_context 1
#define GLX_SHARE_CONTEXT_EXT 0x800A
#define GLX_VISUAL_ID_EXT 0x800B
#define GLX_SCREEN_EXT 0x800C
extern void glXFreeContextEXT(Display *dpy, GLXContext context);
extern GLXContextID glXGetContextIDEXT(const GLXContext context);
extern Display *glXGetCurrentDisplayEXT(void);
extern GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID);
extern int glXQueryContextInfoEXT(Display *dpy, GLXContext context,
int attribute,int *value);
#endif /* GLX_EXT_import_context */
/*
* 215. GLX_MESA_copy_sub_buffer
*/
#ifndef GLX_MESA_copy_sub_buffer
#define GLX_MESA_copy_sub_buffer 1
extern void glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
int x, int y, int width, int height );
#endif
/*
* 216. GLX_MESA_pixmap_colormap
*/
#ifndef GLX_MESA_pixmap_colormap
#define GLX_MESA_pixmap_colormap 1
/* GLX_MESA_pixmap_colormap */
extern GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual,
Pixmap pixmap, Colormap cmap );
#endif /* GLX_MESA_pixmap_colormap */
/*
* 217. GLX_MESA_release_buffers
*/
#ifndef GLX_MESA_release_buffers
#define GLX_MESA_release_buffers 1
/* GLX_MESA_release_buffers */
extern Bool glXReleaseBuffersMESA( Display *dpy, GLXDrawable d );
#endif /* GLX_MESA_release_buffers */
/* GLX_MESA_copy_sub_buffer */
extern void glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
int x, int y, int width, int height );
/*
* 218. GLX_MESA_set_3dfx_mode
*/
#ifndef GLX_MESA_set_3dfx_mode
#define GLX_MESA_set_3dfx_mode 1
#define GLX_3DFX_WINDOW_MODE_MESA 0x1
#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2
/* GLX_MESA_set_3dfx_mode */
extern GLboolean glXSet3DfxModeMESA( GLint mode );
#endif /* GLX_MESA_set_3dfx_mode */
/* GLX_SGI_video_sync */
extern int glXGetVideoSyncSGI(unsigned int *count);
extern int glXWaitVideoSyncSGI(int divisor, int remainder,
unsigned int *count);
/*
* ARB 2. GLX_ARB_get_proc_address
*/
#ifndef GLX_ARB_get_proc_address
#define GLX_ARB_get_proc_address 1
/* GLX_ARB_get_proc_address */
extern void (*glXGetProcAddressARB(const GLubyte *procName))();
#endif /* GLX_ARB_get_proc_address */
/*#endif*/ /* GLX_GLXEXT_LEGACY */
#ifdef __cplusplus

View File

@@ -1,4 +1,4 @@
/* $Id: mesa_wgl.h,v 1.5 2000/05/22 16:21:27 brianp Exp $ */
/* $Id: mesa_wgl.h,v 1.2.2.2 1999/11/22 14:05:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -39,41 +39,6 @@ extern "C" {
#endif
#if !defined(OPENSTEP) && (defined(__WIN32__) || defined(__CYGWIN32__))
# if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
# define GLAPI __declspec(dllexport)
# define WGLAPI __declspec(dllexport)
# elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
# define GLAPI __declspec(dllimport)
# define WGLAPI __declspec(dllimport)
# else /* for use with static link lib build of Win32 edition only */
# define GLAPI extern
# define WGLAPI __declspec(dllimport)
# endif /* _STATIC_MESA support */
# define GLAPIENTRY __stdcall
#else
/* non-Windows compilation */
# define GLAPI extern
# define GLAPIENTRY
#endif /* WIN32 / CYGWIN32 bracket */
#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP)
#ifndef _GNU_H_WINDOWS32_FUNCTIONS
# ifdef UNICODE
# define wglUseFontBitmaps wglUseFontBitmapsW
# define wglUseFontOutlines wglUseFontOutlinesW
# else
# define wglUseFontBitmaps wglUseFontBitmapsA
# define wglUseFontOutlines wglUseFontOutlinesA
# endif /* !UNICODE */
#endif /* _GNU_H_WINDOWS32_FUNCTIONS */
typedef struct tagLAYERPLANEDESCRIPTOR LAYERPLANEDESCRIPTOR, *PLAYERPLANEDESCRIPTOR, *LPLAYERPLANEDESCRIPTOR;
typedef struct _GLYPHMETRICSFLOAT GLYPHMETRICSFLOAT, *PGLYPHMETRICSFLOAT, *LPGLYPHMETRICSFLOAT;
typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR;
#endif
#ifdef _MSC_VER
# pragma warning( disable : 4615 ) /* pragma warning : unknown user warning type*/
# pragma warning( push )

View File

@@ -1,10 +1,10 @@
/* $Id: osmesa.h,v 1.5 2000/03/28 16:59:39 rjfrank Exp $ */
/* $Id: osmesa.h,v 1.1.1.1.2.1 1999/11/24 18:39:17 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.3
* Version: 3.1
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -25,6 +25,29 @@
*/
/*
* $Log: osmesa.h,v $
* Revision 1.1.1.1.2.1 1999/11/24 18:39:17 brianp
* bumped version to 3.1
*
* Revision 1.1.1.1 1999/08/19 00:55:40 jtg
* Imported sources
*
* Revision 1.4 1999/02/14 03:39:09 brianp
* new copyright
*
* Revision 1.3 1999/01/03 02:52:30 brianp
* now using GLAPI and GLAPIENTRY keywords (Ted Jump)
*
* Revision 1.2 1998/07/26 01:33:51 brianp
* added WINGDIAPI and APIENTRY keywords per Ted Jump
*
* Revision 1.1 1998/02/13 03:17:50 brianp
* Initial revision
*
*/
/*
* Mesa Off-Screen rendering interface.
*
@@ -50,10 +73,12 @@
*/
#ifndef OSMESA_H
#define OSMESA_H
#ifdef __cplusplus
extern "C" {
#endif
@@ -62,8 +87,9 @@ extern "C" {
#include "GL/gl.h"
#define OSMESA_MAJOR_VERSION 3
#define OSMESA_MINOR_VERSION 3
#define OSMESA_MINOR_VERSION 1
@@ -96,6 +122,7 @@ extern "C" {
#define OSMESA_TYPE 0x23
typedef struct osmesa_context *OSMesaContext;
@@ -115,7 +142,7 @@ typedef struct osmesa_context *OSMesaContext;
* Return: an OSMesaContext or 0 if error
*/
GLAPI OSMesaContext GLAPIENTRY OSMesaCreateContext( GLenum format,
OSMesaContext sharelist );
OSMesaContext sharelist );
@@ -157,8 +184,8 @@ GLAPI void GLAPIENTRY OSMesaDestroyContext( OSMesaContext ctx );
* width>internal limit or height>internal limit.
*/
GLAPI GLboolean GLAPIENTRY OSMesaMakeCurrent( OSMesaContext ctx,
void *buffer, GLenum type,
GLsizei width, GLsizei height );
void *buffer, GLenum type,
GLsizei width, GLsizei height );
@@ -188,7 +215,7 @@ GLAPI void GLAPIENTRY OSMesaPixelStore( GLint pname, GLint value );
/*
* Return an integer value like glGetIntegerv.
* Return context info. This is like glGetIntegerv.
* Input: pname -
* OSMESA_WIDTH return current image width
* OSMESA_HEIGHT return current image height
@@ -213,25 +240,10 @@ GLAPI void GLAPIENTRY OSMesaGetIntegerv( GLint pname, GLint *value );
* New in Mesa 2.4.
*/
GLAPI GLboolean GLAPIENTRY OSMesaGetDepthBuffer( OSMesaContext c,
GLint *width, GLint *height,
GLint *bytesPerValue,
void **buffer );
GLint *width, GLint *height,
GLint *bytesPerValue, void **buffer );
/*
* Return the color buffer associated with an OSMesa context.
* Input: c - the OSMesa context
* Output: width, height - size of buffer in pixels
* format - buffer format (OSMESA_FORMAT)
* buffer - pointer to depth buffer values
* Return: GL_TRUE or GL_FALSE to indicate success or failure.
*
* New in Mesa 3.3.
*/
GLAPI GLboolean GLAPIENTRY OSMesaGetColorBuffer( OSMesaContext c,
GLint *width, GLint *height,
GLint *format,
void **buffer );
#if defined(__BEOS__) || defined(__QUICKDRAW__)

View File

@@ -1,9 +1,9 @@
/* $Id: svgamesa.h,v 1.4 2000/02/09 19:03:28 brianp Exp $ */
/* $Id: svgamesa.h,v 1.1.1.1.2.1 1999/11/24 18:40:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.3
* Copyright (C) 1995-2000 Brian Paul
* Version: 3.1
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -21,6 +21,21 @@
*/
/*
* $Log: svgamesa.h,v $
* Revision 1.1.1.1.2.1 1999/11/24 18:40:45 brianp
* bumped version to 3.1
*
* Revision 1.1.1.1 1999/08/19 00:55:40 jtg
* Imported sources
*
* Revision 3.0 1998/02/20 05:07:24 brianp
* initial rev
*
*/
/*
* SVGA/Mesa interface for Linux.
*/
@@ -53,7 +68,7 @@
#define SVGAMESA_MAJOR_VERSION 3
#define SVGAMESA_MINOR_VERSION 3
#define SVGAMESA_MINOR_VERSION 1
#ifdef __cplusplus
@@ -75,21 +90,16 @@ typedef struct svgamesa_context *SVGAMesaContext;
/*
* doubleBuffer flag new in version 2.4
*/
extern int SVGAMesaInit( int GraphMode );
extern int SVGAMesaClose( void );
extern SVGAMesaContext SVGAMesaCreateContext( GLboolean doubleBuffer );
extern void SVGAMesaDestroyContext( SVGAMesaContext ctx );
extern void SVGAMesaMakeCurrent( SVGAMesaContext ctx );
extern SVGAMesaContext SVGAMesaGetCurrentContext( void );
extern void SVGAMesaSwapBuffers( void );
extern void SVGAMesaSetCI(int ndx, GLubyte red, GLubyte green, GLubyte blue);
extern SVGAMesaContext SVGAMesaGetCurrentContext( void );
#ifdef __cplusplus
}

View File

@@ -1,10 +1,10 @@
/* $Id: xmesa.h,v 1.8 2000/05/02 02:30:01 brianp Exp $ */
/* $Id: xmesa.h,v 1.1.1.1.2.2 1999/12/13 21:54:19 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.3
* Version: 3.1
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -25,6 +25,29 @@
*/
/*
* $Log: xmesa.h,v $
* Revision 1.1.1.1.2.2 1999/12/13 21:54:19 brianp
* applied Daryll's patches
*
* Revision 1.1.1.1.2.1 1999/11/24 18:41:37 brianp
* bumped version to 3.1
*
* Revision 1.1.1.1 1999/08/19 00:55:40 jtg
* Imported sources
*
* Revision 1.3 1999/02/24 22:43:27 jens
* Name changes to get XMesa to compile standalone inside XFree86
*
* Revision 1.2 1999/02/14 03:39:09 brianp
* new copyright
*
* Revision 1.1 1998/02/13 03:17:32 brianp
* Initial revision
*
*/
/*
* Mesa/X11 interface. This header file serves as the documentation for
* the Mesa/X11 interface functions.
@@ -79,6 +102,9 @@ extern "C" {
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "xmesa_x.h"
#ifdef GLX_DIRECT_RENDERING
#include "dri_mesa.h"
#endif
#endif
#include "GL/gl.h"
@@ -89,7 +115,7 @@ extern struct Library *XLibBase;
#define XMESA_MAJOR_VERSION 3
#define XMESA_MINOR_VERSION 3
#define XMESA_MINOR_VERSION 1
@@ -114,6 +140,17 @@ typedef struct xmesa_visual *XMesaVisual;
typedef struct xmesa_buffer *XMesaBuffer;
#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
/*
* Initialize the XMesa driver.
*/
extern GLboolean XMesaInitDriver( __DRIscreenPrivate *driScrnPriv );
/*
* Reset the XMesa driver when the X server resets.
*/
extern void XMesaResetDriver( __DRIscreenPrivate *driScrnPriv );
#endif
/*
@@ -126,35 +163,24 @@ typedef struct xmesa_buffer *XMesaBuffer;
* db_flag - GL_TRUE = double-buffered,
* GL_FALSE = single buffered
* stereo_flag - stereo visual?
* ximage_flag - GL_TRUE = use an XImage for back buffer,
* GL_FALSE = use an off-screen pixmap for back buffer
* depth_size - requested bits/depth values, or zero
* stencil_size - requested bits/stencil values, or zero
* accum_red_size - requested bits/red accum values, or zero
* accum_green_size - requested bits/green accum values, or zero
* accum_blue_size - requested bits/blue accum values, or zero
* accum_alpha_size - requested bits/alpha accum values, or zero
* num_samples - number of samples/pixel if multisampling, or zero
* level - visual level, usually 0
* visualCaveat - ala the GLX extension, usually GLX_NONE_EXT
* accum_size - requested bits/component values, or zero
* ximage_flag - GL_TRUE = use an XImage for back buffer,
* GL_FALSE = use an off-screen pixmap for back buffer
* Return; a new XMesaVisual or 0 if error.
*/
extern XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
XMesaVisualInfo visinfo,
GLboolean rgb_flag,
GLboolean alpha_flag,
GLboolean db_flag,
GLboolean stereo_flag,
GLboolean ximage_flag,
GLint depth_size,
GLint stencil_size,
GLint accum_red_size,
GLint accum_green_size,
GLint accum_blue_size,
GLint accum_alpha_size,
GLint num_samples,
GLint level,
GLint visualCaveat );
XMesaVisualInfo visinfo,
GLboolean rgb_flag,
GLboolean alpha_flag,
GLboolean db_flag,
GLboolean stereo_flag,
GLboolean ximage_flag,
GLint depth_size,
GLint stencil_size,
GLint accum_size,
GLint level );
/*
* Destroy an XMesaVisual, but not the associated XVisualInfo.
@@ -172,7 +198,11 @@ extern void XMesaDestroyVisual( XMesaVisual v );
* Return: an XMesaContext or NULL if error.
*/
extern XMesaContext XMesaCreateContext( XMesaVisual v,
XMesaContext share_list );
XMesaContext share_list
#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
, __DRIcontextPrivate *driContextPriv
#endif
);
/*
@@ -184,7 +214,13 @@ extern void XMesaDestroyContext( XMesaContext c );
/*
* Create an XMesaBuffer from an X window.
*/
extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v, XMesaWindow w );
extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v,
XMesaWindow w
#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
, __DRIdrawablePrivate *driDrawPriv
#endif
);
/*
@@ -192,7 +228,12 @@ extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v, XMesaWindow w );
*/
extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
XMesaPixmap p,
XMesaColormap cmap );
XMesaColormap cmap
#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
, __DRIdrawablePrivate *driDrawPriv
#endif
);
/*
@@ -218,22 +259,6 @@ extern GLboolean XMesaMakeCurrent( XMesaContext c,
XMesaBuffer b );
/*
* Bind two buffers (read and draw) to a context and make the
* context the current one.
* New in Mesa 3.3
*/
extern GLboolean XMesaMakeCurrent2( XMesaContext c,
XMesaBuffer drawBuffer,
XMesaBuffer readBuffer );
/*
* Unbind the current context from its buffer.
*/
extern GLboolean XMesaUnbindContext( XMesaContext c );
/*
* Return a handle to the current context.
*/
@@ -241,18 +266,11 @@ extern XMesaContext XMesaGetCurrentContext( void );
/*
* Return handle to the current (draw) buffer.
* Return handle to the current buffer.
*/
extern XMesaBuffer XMesaGetCurrentBuffer( void );
/*
* Return handle to the current read buffer.
* New in Mesa 3.3
*/
extern XMesaBuffer XMesaGetCurrentReadBuffer( void );
/*
* Swap the front and back buffers for the given buffer. No action is
* taken if the buffer is not double buffered.

View File

@@ -30,7 +30,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Authors:
* Kevin E. Martin <kevin@precisioninsight.com>
*
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/include/GL/xmesa_x.h,v 1.2 2000/02/25 20:31:11 brianp Exp $
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/include/GL/xmesa_x.h,v 1.1 1999/08/19 00:55:40 jtg Exp $
*/
#ifndef _XMESA_X_H_
@@ -78,6 +78,7 @@ typedef XColor XMesaColor;
#define GET_REDMASK(__v) __v->visinfo->red_mask
#define GET_GREENMASK(__v) __v->visinfo->green_mask
#define GET_BLUEMASK(__v) __v->visinfo->blue_mask
#define GET_BITS_PER_PIXEL(__v) bits_per_pixel(__v->display, __v->visinfo)
#if defined(__cplusplus) || defined(c_plusplus)
#define GET_VISUAL_CLASS(__v) __v->visinfo->c_class
#else

View File

@@ -30,7 +30,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Authors:
* Kevin E. Martin <kevin@precisioninsight.com>
*
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/include/GL/xmesa_xf86.h,v 1.5 2000/04/05 22:09:10 brianp Exp $
* $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/include/GL/xmesa_xf86.h,v 1.1.1.1.2.1 1999/12/13 21:54:19 brianp Exp $
*/
#ifndef _XMESA_XF86_H_
@@ -128,12 +128,12 @@ do { \
do { \
xRectangle __r[1]; \
(void) __d; \
ValidateGC((DrawablePtr)__b, __gc); \
ValidateGC(__b, __gc); \
__r[0].x = __x; \
__r[0].y = __y; \
__r[0].width = __w; \
__r[0].height = __h; \
(*__gc->ops->PolyFillRect)((DrawablePtr)__b, __gc, 1, __r); \
(*__gc->ops->PolyFillRect)(__b, __gc, 1, __r); \
} while (0)
#define XMesaPutImage(__d,__b,__gc,__i,__sx,__sy,__x,__y,__w,__h) \
@@ -179,6 +179,7 @@ do { \
#define GET_REDMASK(__v) __v->visinfo->redMask
#define GET_GREENMASK(__v) __v->visinfo->greenMask
#define GET_BLUEMASK(__v) __v->visinfo->blueMask
#define GET_BITS_PER_PIXEL(__v) __v->visinfo->bitsPerRGBValue
#define GET_VISUAL_CLASS(__v) __v->visinfo->class
#define GET_VISUAL_DEPTH(__v) __v->visinfo->nplanes
#define GET_BLACK_PIXEL(__v) __v->display->blackPixel

View File

@@ -1,8 +1,8 @@
# $Id: Makefile.BeOS-R4,v 1.12 2000/06/27 16:54:18 brianp Exp $
# $Id: Makefile.BeOS-R4,v 1.3 1999/10/22 20:36:38 brianp Exp $
# Mesa 3-D graphics library
# Version: 3.3
# Copyright (C) 1995-2000 Brian Paul
# Version: 3.1
# Copyright (C) 1995-1999 Brian Paul
# Makefile for GLUT-based demo programs for BeOS R4
@@ -17,45 +17,9 @@ GL_LIBS = -L$(LIBDIR) -L/boot/home/config/lib -Xlinker -rpath $(LIBDIR) -lbe -lg
LIB_DEP = $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(GLU_LIB) $(LIBDIR)/$(GLUT_LIB)
PROGS = bounce \
clearspd \
cubemap \
drawpix \
fire \
gamma \
gears \
geartrain \
glinfo \
gloss \
gltestperf \
glutfx \
isosurf \
ipers \
lodbias \
morph3d \
multiarb \
occlude \
osdemo \
paltex \
pixeltex \
pointblast \
ray \
readpix \
reflect \
renormal \
spectex \
stex3d \
teapot \
terrain \
tessdemo \
texcyl \
texdown \
texenv \
texobj \
trispd \
tunnel \
tunnel2 \
winpos
PROGS = bounce clearspd drawpix gamma gears glinfo gloss isosurf \
morph3d multiarb osdemo paltex pointblast reflect \
renormal spectex stex3d texcyl texobj trispd winpos
##### RULES #####

View File

@@ -1,8 +1,9 @@
# $Id: Makefile.X11,v 1.14 2000/06/27 16:54:18 brianp Exp $
# $Id: Makefile.X11,v 1.3 1999/10/27 10:09:53 brianp Exp $
# Mesa 3-D graphics library
# Version: 3.3
# Copyright (C) 1995-2000 Brian Paul
# Version: 3.1
# Copyright (C) 1995-1998 Brian Paul
# Makefile for GLUT-based demo programs for Unix/X11
@@ -12,49 +13,13 @@
INCDIR = ../include
LIBDIR = ../lib
GL_LIBS = -L$(LIBDIR) -lglut -lGLU -lGL $(APP_LIB_DEPS)
GL_LIBS = -L$(LIBDIR) -lglut -lGLU -lGL $(XLIBS)
LIB_DEP = $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(GLU_LIB) $(LIBDIR)/$(GLUT_LIB)
PROGS = bounce \
clearspd \
cubemap \
drawpix \
fire \
gamma \
gears \
geartrain \
glinfo \
gloss \
gltestperf \
glutfx \
isosurf \
ipers \
lodbias \
morph3d \
multiarb \
occlude \
osdemo \
paltex \
pixeltex \
pointblast \
ray \
readpix \
reflect \
renormal \
spectex \
stex3d \
teapot \
terrain \
tessdemo \
texcyl \
texdown \
texenv \
texobj \
trispd \
tunnel \
tunnel2 \
winpos
PROGS = bounce clearspd drawpix gamma gears glinfo gloss glutfx isosurf \
morph3d multiarb osdemo paltex pointblast reflect \
renormal spectex stex3d tessdemo texcyl texobj trispd winpos \
##### RULES #####

View File

@@ -1,8 +1,8 @@
# $Id: Makefile.cygnus,v 1.11 2000/06/27 16:54:18 brianp Exp $
# $Id: Makefile.cygnus,v 1.2 1999/10/22 20:37:23 brianp Exp $
# Mesa 3-D graphics library
# Version: 3.3
# Copyright (C) 1995-2000 Brian Paul
# Version: 3.1
# Copyright (C) 1995-1999 Brian Paul
# Makefile for demo programs for cygnus
@@ -19,45 +19,9 @@ GL_LIBS = -L$(LIBDIR) -lglut -lMesaGLU -lMesaGL -lm $(WLIBS)
LIB_DEP = $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(GLU_LIB) $(LIBDIR)/$(GLUT_LIB)
PROGS = bounce \
clearspd \
cubemap \
drawpix \
fire \
gamma \
gears \
geartrain \
glinfo \
gloss \
gltestperf \
glutfx \
isosurf \
ipers \
lodbias \
morph3d \
multiarb \
occlude \
osdemo \
paltex \
pixeltex \
pointblast \
ray \
readpix \
reflect \
renormal \
spectex \
stex3d \
teapot \
terrain \
tessdemo \
texcyl \
texdown \
texenv \
texobj \
trispd \
tunnel \
tunnel2 \
winpos
PROGS = clearspd drawpix gamma gears glinfo glutfx gloss isosurf \
morph3d multiext osdemo paltex pointblast reflect \
renormal spectex stex3d tessdemo texcyl texobj trispd winpos
##### RULES #####

View File

@@ -1,230 +0,0 @@
INTRODUCTION
------------
This directory is usually included in the Mesa demos distribution or
in the GLUT distribution.
I have written the demos included in this directory mainly for showing
the capabilities of the Mesa library when using the Voodoo driver.
However all the demos are written using the GLUT and OpenGL so they
work with any GLUT/OpenGL platform (tested: Linux+Mesa+Voodoo driver,
Linux+Mesa+X11 driver, Win95+Mesa+Voodoo driver and SGI Onyx IR thanks
to Mark Kilgard).
All the demos make an heavy use of texture mapping, blending, etc. so
you _need_ some kind of hardware support for the OpenGL otherwise they
will run at ~1fps. You need also a OpenGL 1.1 compliant library.
You can find some screenshot of these demos at
http://www-hmw.caribel.pisa.it/fxmesa/fxdemos.hmtl
Write me if you find some bug in the demos.
David Bucciarelli (tech.hmw@plus.it)
Humanware s.r.l.
Via XXIV Maggio 62
Pisa, Italy
Tel./Fax +39-50-554108
email: info.hmw@plus.it
www: www-hmw.caribel.pisa.it
A BRIEF DESCRIPTION OF THE DEMOS
--------------------------------
IPERS
-----
Sources: ipers.c image.c
A nice spinning fractal object.
RAY
---
Sources: ray.c
I'm using ray tracing to dynamically generate texture maps with
specular, diffuse, shadows, and mirror colors. Each frame the texture
maps of the plane and of the sphere are partially updated. With this
technique you can obtain true mirrors, shadows, specular highlights,
bump mapping, etc. in realtime. This demo is really CPU intensive
(~25fps on a PentiumII@300MHz with a Pure3D). Support on-the-fly
switching between fullscreen and in-window rendering under Linux/Mesa
(start your X server in 16 bpp mode and press the spacebar).
TUNNEL
------
Sources: tunnel.c image.c sources.c
Data: bw.rgb tile.rgb
The model was designed and prelighted with Alias|Wavefront
PowerAnimator V8. Triangle strips were built with a tool written by me
and then statically included in the sources. This demo doesn't
require the ZBuffer and use antialiased polygons. Support on-the-fly
switching between fullscreen and in-window rendering under Linux/Mesa
(start your X server in 16 bpp mode and press the spacebar).
TUNNEL2
------
Sources: tunnel2.c image.c sources.c
Data: bw.rgb tile.rgb
The some tunnel demo but with two output channels. A nice
example of the Mesa/Voodoo support for multiple boards in
the some PC.
TEAPOT
------
Sources: teapot.c image.c dteapot.c shadow.c
Data: bw.rgb tile.rgb
The shadow is drawn projecting the teapot geometry over the plane. All
other light effects are drawn using the standard OpenGL capabilities.
Support on-the-fly switching between fullscreen and in-window
rendering under Linux/Mesa (start your X server in 16 bpp mode and
press the spacebar).
FIRE
----
Sources: fire.c image.c
Data: s128.rgb tree2.rgb
The demo use a small particle system to draw some nice visual effect.
You can interactively change many parameters of the particle system
and you can choose the number of particles at the startup ('fire
4000'). This demo should be called fountain. Support on-the-fly
switching between fullscreen and in-window rendering under Linux/Mesa
(start your X server in 16 bpp mode and press the spacebar).
TERRAIN
-------
Sources: mesaland.c
This demo is base on another demo written by Mikael SkiZoWalker. I
have added the capabilities to freely fly around, view culling and
some nice color. Support on-the-fly switching between fullscreen and
in-window rendering under Linux/Mesa (start your X server in 16 bpp
mode and press the spacebar).
GLTEST
------
Sources: gltest.c
This is a simple benchmark suite that I'm using in the development of
the Mesa/Voodoo driver. Type 'gltest >my.res' and you will get some
data about the performances of your OpenGL. Follow the results with my
PC (Linux+Mesa-2.6+PentiumII@300MHz+Pure3D):
Simple Points
587900.080674 Pnts/sec
Smooth Lines
SIZE=480 => 39007.426183 Lins/sec
SIZE=250 => 74575.016485 Lins/sec
SIZE=100 => 179734.882409 Lins/sec
SIZE=050 => 183987.795297 Lins/sec
SIZE=025 => 183820.086309 Lins/sec
ZSmooth Triangles
SIZE=480 => 784.954997 Tris/sec
SIZE=250 => 2862.325889 Tris/sec
SIZE=100 => 17779.492938 Tris/sec
SIZE=050 => 159339.829844 Tris/sec
SIZE=025 => 428602.984008 Tris/sec
ZSmooth Tex Blend Triangles
SIZE=480 => 784.473931 Tris/sec
SIZE=250 => 2853.781513 Tris/sec
SIZE=100 => 17598.252146 Tris/sec
SIZE=050 => 152632.578337 Tris/sec
SIZE=025 => 377584.760048 Tris/sec
ZSmooth Tex Blend TMesh Triangles
SIZE=400 => 563.900695 Tris/sec, MPixel Fill/sec: 45.112056
SIZE=250 => 1449.777225 Tris/sec, MPixel Fill/sec: 45.305538
SIZE=100 => 8702.869121 Tris/sec, MPixel Fill/sec: 43.514346
SIZE=050 => 31896.867466 Tris/sec, MPixel Fill/sec: 39.871084
SIZE=025 => 114037.262894 Tris/sec, MPixel Fill/sec: 35.636645
SIZE=010 => 220494.235839 Tris/sec, MPixel Fill/sec: 11.024712
SIZE=005 => 225615.506651 Tris/sec, MPixel Fill/sec: 2.820194
SIZE=002 => 225607.681439 Tris/sec, MPixel Fill/sec: 0.451215
Color/Depth Buffer Clears
295.042474 Clrs/sec, MPixel Fill/sec: 90.553256
Follow the results with my
PC (Linux+Mesa-3.0beta5+PentiumII@300MHz+Voodoo2):
Simple Points
1620113.525130 Pnts/sec
Smooth Lines
SIZE=480 => 73841.166065 Lins/sec
SIZE=250 => 140794.035316 Lins/sec
SIZE=100 => 344185.242157 Lins/sec
SIZE=050 => 420399.008289 Lins/sec
SIZE=025 => 420261.389773 Lins/sec
ZSmooth Triangles
SIZE=480 => 1434.668506 Tris/sec
SIZE=250 => 5228.449614 Tris/sec
SIZE=100 => 46603.815842 Tris/sec
SIZE=050 => 325757.045961 Tris/sec
SIZE=025 => 589022.403336 Tris/sec
ZSmooth Tex Blend Triangles
SIZE=480 => 1414.900041 Tris/sec
SIZE=250 => 5006.055235 Tris/sec
SIZE=100 => 43602.252031 Tris/sec
SIZE=050 => 303497.092692 Tris/sec
SIZE=025 => 517087.428669 Tris/sec
ZSmooth Tex Blend TMesh Triangles
SIZE=400 => 1023.273112 Tris/sec, MPixel Fill/sec: 81.861849
SIZE=250 => 2595.692121 Tris/sec, MPixel Fill/sec: 81.115379
SIZE=100 => 15788.198912 Tris/sec, MPixel Fill/sec: 78.940995
SIZE=050 => 58784.121300 Tris/sec, MPixel Fill/sec: 73.480152
SIZE=025 => 244233.873481 Tris/sec, MPixel Fill/sec: 76.323085
SIZE=010 => 474995.004191 Tris/sec, MPixel Fill/sec: 23.749750
SIZE=005 => 475124.354163 Tris/sec, MPixel Fill/sec: 5.939054
SIZE=002 => 474959.089503 Tris/sec, MPixel Fill/sec: 0.949918
Color/Depth Buffer Clears
478.654830 Clrs/sec, MPixel Fill/sec: 146.906826
PALTEX and GLBPALTX
-------------------
Sources: paltex.c and glbpaltx.c
The PALTEX example was written by Brian Paul and it shows the
capabilities of the GL_EXT_paletted_texture extension. I have written
the other example in order to show the capabilities of the
gl3DfxSetPaletteEXT() (it used only by GLQuake and Quake2).

View File

@@ -1,4 +1,4 @@
/* $Id: bounce.c,v 1.2 2000/06/27 17:04:43 brianp Exp $ */
/* $Id: bounce.c,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
/*
* Bouncing ball demo. Color index mode only!
@@ -12,11 +12,8 @@
/*
* $Log: bounce.c,v $
* Revision 1.2 2000/06/27 17:04:43 brianp
* fixed compiler warnings
*
* Revision 1.1.1.1 1999/08/19 00:55:40 jtg
* Imported sources
* Revision 1.1 1999/08/19 00:55:40 jtg
* Initial revision
*
* Revision 3.3 1999/03/18 08:16:14 joukj
*
@@ -198,7 +195,7 @@ idle(void)
glutPostRedisplay();
}
static void
void
visible(int vis)
{
if (vis == GLUT_VISIBLE)

View File

@@ -1,4 +1,4 @@
/* $Id: clearspd.c,v 1.2 2000/04/10 16:25:15 brianp Exp $ */
/* $Id: clearspd.c,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
/*
* Simple GLUT program to measure glClear() and glutSwapBuffers() speed.
@@ -7,11 +7,8 @@
/*
* $Log: clearspd.c,v $
* Revision 1.2 2000/04/10 16:25:15 brianp
* fixed visual selection and reporting results
*
* Revision 1.1.1.1 1999/08/19 00:55:40 jtg
* Imported sources
* Revision 1.1 1999/08/19 00:55:40 jtg
* Initial revision
*
* Revision 3.3 1999/03/28 18:18:33 brianp
* minor clean-up
@@ -77,7 +74,6 @@ static void Display( void )
t0 = glutGet(GLUT_ELAPSED_TIME) * 0.001;
for (i=0;i<Loops;i++) {
glClear( BufferMask );
glFlush();
}
t1 = glutGet(GLUT_ELAPSED_TIME) * 0.001;
glutSwapBuffers();
@@ -92,12 +88,12 @@ static void Display( void )
clearRate = Loops / (t1-t0);
pixelRate = clearRate * Width * Height;
if (SwapFlag) {
printf("Rate: %d clears+swaps in %gs = %g clears+swaps/s %g pixels/s\n",
Loops, t1-t0, clearRate, pixelRate );
printf("Rate: %d clears+swaps in %gs = %g clears+swaps/s %d pixels/s\n",
Loops, t1-t0, clearRate, (int)pixelRate );
}
else {
printf("Rate: %d clears in %gs = %g clears/s %g pixels/s\n",
Loops, t1-t0, clearRate, pixelRate);
printf("Rate: %d clears in %gs = %g clears/s %d pixels/s\n",
Loops, t1-t0, clearRate, (int)pixelRate);
}
}
@@ -198,8 +194,6 @@ static void Help( const char *program )
int main( int argc, char *argv[] )
{
GLint mode;
printf("For options: %s -help\n", argv[0]);
Init( argc, argv );
@@ -208,15 +202,7 @@ int main( int argc, char *argv[] )
glutInitWindowSize( (int) Width, (int) Height );
glutInitWindowPosition( 0, 0 );
mode = ColorMode | GLUT_DOUBLE;
if (BufferMask & GL_STENCIL_BUFFER_BIT)
mode |= GLUT_STENCIL;
if (BufferMask & GL_ACCUM_BUFFER_BIT)
mode |= GLUT_ACCUM;
if (BufferMask & GL_DEPTH_BUFFER_BIT)
mode |= GLUT_DEPTH;
glutInitDisplayMode(mode);
glutInitDisplayMode( ColorMode | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL | GLUT_ACCUM );
glutCreateWindow( argv[0] );

View File

@@ -1,250 +0,0 @@
/* $Id: cubemap.c,v 1.3 2000/06/27 17:04:43 brianp Exp $ */
/*
* GL_ARB_texture_cube_map demo
*
* Brian Paul
* May 2000
*
*
* Copyright (C) 2000 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* This is a pretty minimalistic demo for now. Eventually, use some
* interesting cube map textures and 3D objects.
* For now, we use 6 checkerboard "walls" and a sphere (good for
* verification purposes).
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "GL/glut.h"
static GLfloat Xrot = 0, Yrot = 0;
static void draw( void )
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glRotatef(Xrot, 1, 0, 0);
glRotatef(Yrot, 0, 1, 0);
glutSolidSphere(2.0, 20, 20);
glMatrixMode(GL_MODELVIEW);
glutSwapBuffers();
}
static void idle(void)
{
Yrot += 5.0;
glutPostRedisplay();
}
static void set_mode(GLuint mode)
{
if (mode == 0) {
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
printf("GL_REFLECTION_MAP_ARB mode\n");
}
else if (mode == 1) {
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
printf("GL_NORMAL_MAP_ARB mode\n");
}
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
}
static void key(unsigned char k, int x, int y)
{
static GLboolean anim = GL_TRUE;
static GLuint mode = 0;
(void) x;
(void) y;
switch (k) {
case ' ':
anim = !anim;
if (anim)
glutIdleFunc(idle);
else
glutIdleFunc(NULL);
break;
case 'm':
mode = !mode;
set_mode(mode);
break;
case 27:
exit(0);
}
glutPostRedisplay();
}
static void specialkey(int key, int x, int y)
{
GLfloat step = 10;
(void) x;
(void) y;
switch (key) {
case GLUT_KEY_UP:
Xrot -= step;
break;
case GLUT_KEY_DOWN:
Xrot += step;
break;
case GLUT_KEY_LEFT:
Yrot -= step;
break;
case GLUT_KEY_RIGHT:
Yrot += step;
break;
}
glutPostRedisplay();
}
/* new window size or exposure */
static void reshape(int width, int height)
{
glViewport(0, 0, (GLint)width, (GLint)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum( -2.0, 2.0, -2.0, 2.0, 6.0, 20.0 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef( 0.0, 0.0, -8.0 );
}
static void init( void )
{
#define CUBE_TEX_SIZE 64
GLubyte image[CUBE_TEX_SIZE][CUBE_TEX_SIZE][3];
static const GLubyte colors[6][3] = {
{ 255, 0, 0 },
{ 0, 255, 255 },
{ 0, 255, 0 },
{ 255, 0, 255 },
{ 0, 0, 255 },
{ 255, 255, 0 }
};
static const GLenum targets[6] = {
GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
};
GLint i, j, f;
/* check for extension */
{
char *exten = (char *) glGetString(GL_EXTENSIONS);
if (!strstr(exten, "GL_ARB_texture_cube_map")) {
printf("Sorry, this demo requires GL_ARB_texture_cube_map\n");
exit(0);
}
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
/* make colored checkerboard cube faces */
for (f = 0; f < 6; f++) {
for (i = 0; i < CUBE_TEX_SIZE; i++) {
for (j = 0; j < CUBE_TEX_SIZE; j++) {
if ((i/4 + j/4) & 1) {
image[i][j][0] = colors[f][0];
image[i][j][1] = colors[f][1];
image[i][j][2] = colors[f][2];
}
else {
image[i][j][0] = 255;
image[i][j][1] = 255;
image[i][j][2] = 255;
}
}
}
glTexImage2D(targets[f], 0, GL_RGB, CUBE_TEX_SIZE, CUBE_TEX_SIZE, 0,
GL_RGB, GL_UNSIGNED_BYTE, image);
}
#if 1
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
#else
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
#endif
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glClearColor(.3, .3, .3, 0);
glColor3f( 1.0, 1.0, 1.0 );
set_mode(0);
}
static void usage(void)
{
printf("keys:\n");
printf(" SPACE - toggle animation\n");
printf(" CURSOR KEYS - rotation\n");
printf(" m - toggle texgen reflection mode\n");
}
int main( int argc, char *argv[] )
{
glutInitWindowPosition(0, 0);
glutInitWindowSize(300, 300);
glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
glutCreateWindow("Texture Cube Maping");
init();
glutReshapeFunc( reshape );
glutKeyboardFunc( key );
glutSpecialFunc( specialkey );
glutIdleFunc( idle );
glutDisplayFunc( draw );
usage();
glutMainLoop();
return 0;
}

View File

@@ -1,738 +0,0 @@
/*
* This program is under the GNU GPL.
* Use at your own risk.
*
* written by David Bucciarelli (tech.hmw@plus.it)
* Humanware s.r.l.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#ifdef WIN32
#include <windows.h>
#include <mmsystem.h>
#endif
#include <GL/glut.h>
#include "../util/readtex.c"
#ifdef XMESA
#include "GL/xmesa.h"
static int fullscreen = 1;
#endif
#ifndef M_PI
#define M_PI 3.1415926535
#endif
#define vinit(a,i,j,k) {\
(a)[0]=i;\
(a)[1]=j;\
(a)[2]=k;\
}
#define vinit4(a,i,j,k,w) {\
(a)[0]=i;\
(a)[1]=j;\
(a)[2]=k;\
(a)[3]=w;\
}
#define vadds(a,dt,b) {\
(a)[0]+=(dt)*(b)[0];\
(a)[1]+=(dt)*(b)[1];\
(a)[2]+=(dt)*(b)[2];\
}
#define vequ(a,b) {\
(a)[0]=(b)[0];\
(a)[1]=(b)[1];\
(a)[2]=(b)[2];\
}
#define vinter(a,dt,b,c) {\
(a)[0]=(dt)*(b)[0]+(1.0-dt)*(c)[0];\
(a)[1]=(dt)*(b)[1]+(1.0-dt)*(c)[1];\
(a)[2]=(dt)*(b)[2]+(1.0-dt)*(c)[2];\
}
#define clamp(a) ((a) < 0.0 ? 0.0 : ((a) < 1.0 ? (a) : 1.0))
#define vclamp(v) {\
(v)[0]=clamp((v)[0]);\
(v)[1]=clamp((v)[1]);\
(v)[2]=clamp((v)[2]);\
}
static int WIDTH = 640;
static int HEIGHT = 480;
#define FRAME 50
#define DIMP 20.0
#define DIMTP 16.0
#define RIDCOL 0.4
#define NUMTREE 50
#define TREEINR 2.5
#define TREEOUTR 8.0
#define AGRAV -9.8
typedef struct
{
int age;
float p[3][3];
float v[3];
float c[3][4];
}
part;
static float treepos[NUMTREE][3];
static float black[3] = { 0.0, 0.0, 0.0 };
static float blu[3] = { 0.0, 0.2, 1.0 };
static float blu2[3] = { 0.0, 1.0, 1.0 };
static float fogcolor[4] = { 1.0, 1.0, 1.0, 1.0 };
static float q[4][3] = {
{-DIMP, 0.0, -DIMP},
{DIMP, 0.0, -DIMP},
{DIMP, 0.0, DIMP},
{-DIMP, 0.0, DIMP}
};
static float qt[4][2] = {
{-DIMTP, -DIMTP},
{DIMTP, -DIMTP},
{DIMTP, DIMTP},
{-DIMTP, DIMTP}
};
static int win = 0;
static int np;
static float eject_r, dt, maxage, eject_vy, eject_vl;
static short shadows;
static float ridtri;
static int fog = 1;
static int help = 1;
static int joyavailable = 0;
static int joyactive = 0;
static part *p;
static GLuint groundid;
static GLuint treeid;
static float obs[3] = { 2.0, 1.0, 0.0 };
static float dir[3];
static float v = 0.0;
static float alpha = -90.0;
static float beta = 90.0;
static float
gettime(void)
{
static clock_t told = 0;
clock_t tnew, ris;
tnew = clock();
ris = tnew - told;
told = tnew;
return (ris / (float) CLOCKS_PER_SEC);
}
static float
vrnd(void)
{
return (((float) rand()) / RAND_MAX);
}
static void
setnewpart(part * p)
{
float a, v[3], *c;
p->age = 0;
a = vrnd() * 3.14159265359 * 2.0;
vinit(v, sin(a) * eject_r * vrnd(), 0.15, cos(a) * eject_r * vrnd());
vinit(p->p[0], v[0] + vrnd() * ridtri, v[1] + vrnd() * ridtri,
v[2] + vrnd() * ridtri);
vinit(p->p[1], v[0] + vrnd() * ridtri, v[1] + vrnd() * ridtri,
v[2] + vrnd() * ridtri);
vinit(p->p[2], v[0] + vrnd() * ridtri, v[1] + vrnd() * ridtri,
v[2] + vrnd() * ridtri);
vinit(p->v, v[0] * eject_vl / (eject_r / 2),
vrnd() * eject_vy + eject_vy / 2, v[2] * eject_vl / (eject_r / 2));
c = blu;
vinit4(p->c[0], c[0] * ((1.0 - RIDCOL) + vrnd() * RIDCOL),
c[1] * ((1.0 - RIDCOL) + vrnd() * RIDCOL),
c[2] * ((1.0 - RIDCOL) + vrnd() * RIDCOL), 1.0);
vinit4(p->c[1], c[0] * ((1.0 - RIDCOL) + vrnd() * RIDCOL),
c[1] * ((1.0 - RIDCOL) + vrnd() * RIDCOL),
c[2] * ((1.0 - RIDCOL) + vrnd() * RIDCOL), 1.0);
vinit4(p->c[2], c[0] * ((1.0 - RIDCOL) + vrnd() * RIDCOL),
c[1] * ((1.0 - RIDCOL) + vrnd() * RIDCOL),
c[2] * ((1.0 - RIDCOL) + vrnd() * RIDCOL), 1.0);
}
static void
setpart(part * p)
{
float fact;
if (p->p[0][1] < 0.1) {
setnewpart(p);
return;
}
p->v[1] += AGRAV * dt;
vadds(p->p[0], dt, p->v);
vadds(p->p[1], dt, p->v);
vadds(p->p[2], dt, p->v);
p->age++;
if ((p->age) > maxage) {
vequ(p->c[0], blu2);
vequ(p->c[1], blu2);
vequ(p->c[2], blu2);
}
else {
fact = 1.0 / maxage;
vadds(p->c[0], fact, blu2);
vclamp(p->c[0]);
p->c[0][3] = fact * (maxage - p->age);
vadds(p->c[1], fact, blu2);
vclamp(p->c[1]);
p->c[1][3] = fact * (maxage - p->age);
vadds(p->c[2], fact, blu2);
vclamp(p->c[2]);
p->c[2][3] = fact * (maxage - p->age);
}
}
static void
drawtree(float x, float y, float z)
{
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex3f(x - 1.5, y + 0.0, z);
glTexCoord2f(1.0, 0.0);
glVertex3f(x + 1.5, y + 0.0, z);
glTexCoord2f(1.0, 1.0);
glVertex3f(x + 1.5, y + 3.0, z);
glTexCoord2f(0.0, 1.0);
glVertex3f(x - 1.5, y + 3.0, z);
glTexCoord2f(0.0, 0.0);
glVertex3f(x, y + 0.0, z - 1.5);
glTexCoord2f(1.0, 0.0);
glVertex3f(x, y + 0.0, z + 1.5);
glTexCoord2f(1.0, 1.0);
glVertex3f(x, y + 3.0, z + 1.5);
glTexCoord2f(0.0, 1.0);
glVertex3f(x, y + 3.0, z - 1.5);
glEnd();
}
static void
calcposobs(void)
{
dir[0] = sin(alpha * M_PI / 180.0);
dir[2] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
dir[1] = cos(beta * M_PI / 180.0);
obs[0] += v * dir[0];
obs[1] += v * dir[1];
obs[2] += v * dir[2];
}
static void
printstring(void *font, char *string)
{
int len, i;
len = (int) strlen(string);
for (i = 0; i < len; i++)
glutBitmapCharacter(font, string[i]);
}
static void
reshape(int width, int height)
{
WIDTH = width;
HEIGHT = height;
glViewport(0, 0, (GLint) width, (GLint) height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(70.0, width / (float) height, 0.1, 30.0);
glMatrixMode(GL_MODELVIEW);
}
static void
printhelp(void)
{
glColor4f(0.0, 0.0, 0.0, 0.5);
glRecti(40, 40, 600, 440);
glColor3f(1.0, 0.0, 0.0);
glRasterPos2i(300, 420);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "Help");
glRasterPos2i(60, 390);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "h - Togle Help");
glRasterPos2i(60, 360);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "t - Increase particle size");
glRasterPos2i(60, 330);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "T - Decrease particle size");
glRasterPos2i(60, 300);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "r - Increase emission radius");
glRasterPos2i(60, 270);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "R - Decrease emission radius");
glRasterPos2i(60, 240);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "f - Togle Fog");
glRasterPos2i(60, 210);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "s - Togle shadows");
glRasterPos2i(60, 180);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "Arrow Keys - Rotate");
glRasterPos2i(60, 150);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "a - Increase velocity");
glRasterPos2i(60, 120);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "z - Decrease velocity");
glRasterPos2i(60, 90);
if (joyavailable)
printstring(GLUT_BITMAP_TIMES_ROMAN_24,
"j - Togle jostick control (Joystick control available)");
else
printstring(GLUT_BITMAP_TIMES_ROMAN_24,
"(No Joystick control available)");
}
static void
dojoy(void)
{
#ifdef WIN32
static UINT max[2] = { 0, 0 };
static UINT min[2] = { 0xffffffff, 0xffffffff }, center[2];
MMRESULT res;
JOYINFO joy;
res = joyGetPos(JOYSTICKID1, &joy);
if (res == JOYERR_NOERROR) {
joyavailable = 1;
if (max[0] < joy.wXpos)
max[0] = joy.wXpos;
if (min[0] > joy.wXpos)
min[0] = joy.wXpos;
center[0] = (max[0] + min[0]) / 2;
if (max[1] < joy.wYpos)
max[1] = joy.wYpos;
if (min[1] > joy.wYpos)
min[1] = joy.wYpos;
center[1] = (max[1] + min[1]) / 2;
if (joyactive) {
if (fabs(center[0] - (float) joy.wXpos) > 0.1 * (max[0] - min[0]))
alpha +=
2.5 * (center[0] - (float) joy.wXpos) / (max[0] - min[0]);
if (fabs(center[1] - (float) joy.wYpos) > 0.1 * (max[1] - min[1]))
beta += 2.5 * (center[1] - (float) joy.wYpos) / (max[1] - min[1]);
if (joy.wButtons & JOY_BUTTON1)
v += 0.01;
if (joy.wButtons & JOY_BUTTON2)
v -= 0.01;
}
}
else
joyavailable = 0;
#endif
}
static void
drawfire(void)
{
static int count = 0;
static char frbuf[80];
int j;
float fr;
dojoy();
glEnable(GL_DEPTH_TEST);
if (fog)
glEnable(GL_FOG);
else
glDisable(GL_FOG);
glDepthMask(GL_TRUE);
glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
calcposobs();
gluLookAt(obs[0], obs[1], obs[2],
obs[0] + dir[0], obs[1] + dir[1], obs[2] + dir[2],
0.0, 1.0, 0.0);
glColor4f(1.0, 1.0, 1.0, 1.0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, groundid);
glBegin(GL_QUADS);
glTexCoord2fv(qt[0]);
glVertex3fv(q[0]);
glTexCoord2fv(qt[1]);
glVertex3fv(q[1]);
glTexCoord2fv(qt[2]);
glVertex3fv(q[2]);
glTexCoord2fv(qt[3]);
glVertex3fv(q[3]);
glEnd();
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GEQUAL, 0.9);
glBindTexture(GL_TEXTURE_2D, treeid);
for (j = 0; j < NUMTREE; j++)
drawtree(treepos[j][0], treepos[j][1], treepos[j][2]);
glDisable(GL_TEXTURE_2D);
glDepthMask(GL_FALSE);
glDisable(GL_ALPHA_TEST);
if (shadows) {
glBegin(GL_TRIANGLES);
for (j = 0; j < np; j++) {
glColor4f(black[0], black[1], black[2], p[j].c[0][3]);
glVertex3f(p[j].p[0][0], 0.1, p[j].p[0][2]);
glColor4f(black[0], black[1], black[2], p[j].c[1][3]);
glVertex3f(p[j].p[1][0], 0.1, p[j].p[1][2]);
glColor4f(black[0], black[1], black[2], p[j].c[2][3]);
glVertex3f(p[j].p[2][0], 0.1, p[j].p[2][2]);
}
glEnd();
}
glBegin(GL_TRIANGLES);
for (j = 0; j < np; j++) {
glColor4fv(p[j].c[0]);
glVertex3fv(p[j].p[0]);
glColor4fv(p[j].c[1]);
glVertex3fv(p[j].p[1]);
glColor4fv(p[j].c[2]);
glVertex3fv(p[j].p[2]);
setpart(&p[j]);
}
glEnd();
if ((count % FRAME) == 0) {
fr = gettime();
sprintf(frbuf, "Frame rate: %f", FRAME / fr);
}
glDisable(GL_TEXTURE_2D);
glDisable(GL_ALPHA_TEST);
glDisable(GL_DEPTH_TEST);
glDisable(GL_FOG);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-0.5, 639.5, -0.5, 479.5, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(1.0, 0.0, 0.0);
glRasterPos2i(10, 10);
printstring(GLUT_BITMAP_HELVETICA_18, frbuf);
glRasterPos2i(370, 470);
printstring(GLUT_BITMAP_HELVETICA_10,
"Fire V1.5 Written by David Bucciarelli (tech.hmw@plus.it)");
if (help)
printhelp();
reshape(WIDTH, HEIGHT);
glPopMatrix();
glutSwapBuffers();
count++;
}
static void
special(int key, int x, int y)
{
switch (key) {
case GLUT_KEY_LEFT:
alpha += 2.0;
break;
case GLUT_KEY_RIGHT:
alpha -= 2.0;
break;
case GLUT_KEY_DOWN:
beta -= 2.0;
break;
case GLUT_KEY_UP:
beta += 2.0;
break;
}
}
static void
key(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(0);
break;
case 'a':
v += 0.01;
break;
case 'z':
v -= 0.01;
break;
case 'j':
joyactive = (!joyactive);
break;
case 'h':
help = (!help);
break;
case 'f':
fog = (!fog);
break;
case 's':
shadows = !shadows;
break;
case 'R':
eject_r -= 0.03;
break;
case 'r':
eject_r += 0.03;
break;
case 't':
ridtri += 0.005;
break;
case 'T':
ridtri -= 0.005;
break;
#ifdef XMESA
case ' ':
XMesaSetFXmode(fullscreen ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW);
fullscreen = (!fullscreen);
break;
#endif
}
}
static void
inittextures(void)
{
GLenum gluerr;
GLubyte tex[128][128][4];
glGenTextures(1, &groundid);
glBindTexture(GL_TEXTURE_2D, groundid);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
if (!LoadRGBMipmaps("../images/s128.rgb", GL_RGB)) {
fprintf(stderr, "Error reading a texture.\n");
exit(-1);
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glGenTextures(1, &treeid);
glBindTexture(GL_TEXTURE_2D, treeid);
if (1)
{
int w, h;
GLenum format;
int x, y;
GLubyte *image = LoadRGBImage("../images/tree3.rgb", &w, &h, &format);
if (!image) {
fprintf(stderr, "Error reading a texture.\n");
exit(-1);
}
for (y = 0; y < 128; y++)
for (x = 0; x < 128; x++) {
tex[x][y][0] = image[(y + x * 128) * 3];
tex[x][y][1] = image[(y + x * 128) * 3 + 1];
tex[x][y][2] = image[(y + x * 128) * 3 + 2];
if ((tex[x][y][0] == tex[x][y][1]) &&
(tex[x][y][1] == tex[x][y][2]) && (tex[x][y][2] == 255))
tex[x][y][3] = 0;
else
tex[x][y][3] = 255;
}
if ((gluerr = gluBuild2DMipmaps(GL_TEXTURE_2D, 4, 128, 128, GL_RGBA,
GL_UNSIGNED_BYTE, (GLvoid *) (tex)))) {
fprintf(stderr, "GLULib%s\n", gluErrorString(gluerr));
exit(-1);
}
}
else {
if (!LoadRGBMipmaps("../images/tree2.rgba", GL_RGBA)) {
fprintf(stderr, "Error reading a texture.\n");
exit(-1);
}
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
static void
inittree(void)
{
int i;
float dist;
for (i = 0; i < NUMTREE; i++)
do {
treepos[i][0] = vrnd() * TREEOUTR * 2.0 - TREEOUTR;
treepos[i][1] = 0.0;
treepos[i][2] = vrnd() * TREEOUTR * 2.0 - TREEOUTR;
dist =
sqrt(treepos[i][0] * treepos[i][0] +
treepos[i][2] * treepos[i][2]);
} while ((dist < TREEINR) || (dist > TREEOUTR));
}
int
main(int ac, char **av)
{
int i;
fprintf(stderr,
"Fire V1.5\nWritten by David Bucciarelli (tech.hmw@plus.it)\n");
/* Default settings */
WIDTH = 640;
HEIGHT = 480;
np = 800;
eject_r = 0.1;
dt = 0.015;
eject_vy = 4;
eject_vl = 1;
shadows = 1;
ridtri = 0.1;
maxage = 1.0 / dt;
if (ac == 2)
np = atoi(av[1]);
if (ac == 4) {
WIDTH = atoi(av[2]);
HEIGHT = atoi(av[3]);
}
glutInitWindowPosition(0, 0);
glutInitWindowSize(WIDTH, HEIGHT);
glutInit(&ac, av);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
if (!(win = glutCreateWindow("Fire"))) {
fprintf(stderr, "Error opening a window.\n");
exit(-1);
}
reshape(WIDTH, HEIGHT);
inittextures();
glShadeModel(GL_FLAT);
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_FOG);
glFogi(GL_FOG_MODE, GL_EXP);
glFogfv(GL_FOG_COLOR, fogcolor);
glFogf(GL_FOG_DENSITY, 0.1);
#ifdef FX
glHint(GL_FOG_HINT, GL_NICEST);
#endif
p = malloc(sizeof(part) * np);
for (i = 0; i < np; i++)
setnewpart(&p[i]);
inittree();
glutKeyboardFunc(key);
glutSpecialFunc(special);
glutDisplayFunc(drawfire);
glutIdleFunc(drawfire);
glutReshapeFunc(reshape);
glutMainLoop();
return (0);
}

View File

@@ -1,5 +1,5 @@
/* $Id: gamma.c,v 1.2 2000/03/18 01:13:29 brianp Exp $ */
/* $Id: gamma.c,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
/* Draw test patterns to help determine correct gamma value for a display.
When the intensities of the inner squares nearly match the intensities
@@ -25,11 +25,8 @@
/*
* $Log: gamma.c,v $
* Revision 1.2 2000/03/18 01:13:29 brianp
* colors were computed incorrectly (Hans Nelles)
*
* Revision 1.1.1.1 1999/08/19 00:55:40 jtg
* Imported sources
* Revision 1.1 1999/08/19 00:55:40 jtg
* Initial revision
*
* Revision 3.1 1999/06/19 01:35:38 brianp
* merged in Kai Schuetz's RGB changes
@@ -133,9 +130,8 @@ gamma_ramp(GLfloat yoffs, GLfloat r, GLfloat g, GLfloat b)
for(d = 1; d < 4; d++) { /* increasing density from 25% to 75% */
GLfloat xcoord = (-1.0 + d*0.4);
GLfloat t = d * 0.25;
glColor3f(r*t, g*t, b*t); /* draw outer rect */
glColor3f(r*d / 5.0, g*d / 5.0, b*d / 5.0); /* draw outer rect */
glRectf(xcoord, yoffs, xcoord+0.4, yoffs + 0.5);
glColor3f(0.0, 0.0, 0.0); /* "clear" inner rect */

View File

@@ -1,11 +1,10 @@
/* $Id: gears.c,v 1.6 2000/04/06 02:22:59 brianp Exp $ */
/* $Id: gears.c,v 1.2 1999/10/21 16:39:06 brianp Exp $ */
/*
* 3-D gear wheels. This program is in the public domain.
*
* Command line options:
* -info print GL implementation information
* -exit automatically exit after 30 seconds
*
*
* Brian Paul
@@ -13,6 +12,24 @@
/* Conversion to GLUT by Mark J. Kilgard */
/*
* $Log: gears.c,v $
* Revision 1.2 1999/10/21 16:39:06 brianp
* added -info command line option
*
* Revision 1.1.1.1 1999/08/19 00:55:40 jtg
* Imported sources
*
* Revision 3.2 1999/06/03 17:07:36 brianp
* an extra quad was being drawn in front and back faces
*
* Revision 3.1 1998/11/03 02:49:10 brianp
* added fps output
*
* Revision 3.0 1998/02/14 18:42:29 brianp
* initial rev
*
*/
#include <math.h>
@@ -27,7 +44,7 @@
static GLint T0 = 0;
static GLint Frames = 0;
static GLint autoexit = 0;
/**
@@ -170,44 +187,41 @@ draw(void)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(view_rotx, 1.0, 0.0, 0.0);
glRotatef(view_roty, 0.0, 1.0, 0.0);
glRotatef(view_rotz, 0.0, 0.0, 1.0);
glRotatef(view_rotx, 1.0, 0.0, 0.0);
glRotatef(view_roty, 0.0, 1.0, 0.0);
glRotatef(view_rotz, 0.0, 0.0, 1.0);
glPushMatrix();
glTranslatef(-3.0, -2.0, 0.0);
glRotatef(angle, 0.0, 0.0, 1.0);
glCallList(gear1);
glPopMatrix();
glPushMatrix();
glTranslatef(-3.0, -2.0, 0.0);
glRotatef(angle, 0.0, 0.0, 1.0);
glCallList(gear1);
glPopMatrix();
glPushMatrix();
glTranslatef(3.1, -2.0, 0.0);
glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
glCallList(gear2);
glPopMatrix();
glPushMatrix();
glTranslatef(3.1, -2.0, 0.0);
glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
glCallList(gear2);
glPopMatrix();
glPushMatrix();
glTranslatef(-3.1, 4.2, 0.0);
glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0);
glCallList(gear3);
glPopMatrix();
glPushMatrix();
glTranslatef(-3.1, 4.2, 0.0);
glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0);
glCallList(gear3);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
Frames++;
{
GLint t = glutGet(GLUT_ELAPSED_TIME);
if (t - T0 >= 5000) {
GLfloat seconds = (t - T0) / 1000.0;
GLfloat fps = Frames / seconds;
printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps);
printf("%d frames in %g seconds = %g FPS\n", Frames, seconds, fps);
T0 = t;
Frames = 0;
if ((t >= 999.0 * autoexit) && (autoexit))
exit(0);
}
}
}
@@ -283,11 +297,14 @@ reshape(int width, int height)
static void
init(int argc, char *argv[])
{
static GLfloat pos[4] = {5.0, 5.0, 10.0, 0.0};
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, 1.0, 1.0};
GLint i;
static GLfloat pos[4] =
{5.0, 5.0, 10.0, 0.0};
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, 1.0, 1.0};
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glEnable(GL_CULL_FACE);
@@ -316,21 +333,15 @@ init(int argc, char *argv[])
glEnable(GL_NORMALIZE);
for ( i=1; i<argc; i++ ) {
if (strcmp(argv[i], "-info")==0) {
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
}
else if ( strcmp(argv[i], "-exit")==0) {
autoexit = 30;
printf("Auto Exit after %i seconds.\n", autoexit );
}
if (argc > 1 && strcmp(argv[1], "-info")==0) {
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
}
}
static void
void
visible(int vis)
{
if (vis == GLUT_VISIBLE)

File diff suppressed because it is too large Load Diff

View File

@@ -1,119 +0,0 @@
BACKGROUND = 0.000 0.500 0.700
ANAME = AXLE1
ARADIUS = 1.000
AAXIS = 2
APOSITION = -7.000 0.000 0.000
ACOLOR = 0.800 0.500 0.200
ALENGTH = 6.000
AMOTORED = 1
AANGULARVELOCITY = 2.000
ADIRECTION = 1
ANAME = AXLE2
ARADIUS = 1.000
AAXIS = 2
APOSITION = -3.000 0.000 0.000
ACOLOR = 0.800 0.500 0.200
ALENGTH = 12.000
AMOTORED = 0
ANAME = AXLE3
ARADIUS = 1.000
AAXIS = 2
APOSITION = 1.000 0.000 0.000
ACOLOR = 0.800 0.500 0.200
ALENGTH = 6.000
AMOTORED = 0
ANAME = AXLE4
ARADIUS = 1.000
AAXIS = 2
APOSITION = 8.000 0.000 0.000
ACOLOR = 0.800 0.500 0.200
ALENGTH = 18.000
AMOTORED = 0
ANAME = AXLE5
ARADIUS = 1.000
AAXIS = 1
APOSITION = 8.000 -8.200 -7.400
ACOLOR = 0.800 0.500 0.200
ALENGTH = 12.000
AMOTORED = 0
GNAME = GEAR1
GTYPE = NORMAL
GRADIUS = 2.200
GWIDTH = 3.000
GTEETH = 40
GTOOTHDEPTH = 0.500
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE1
GPOSITION = 0.000
GNAME = GEAR2
GTYPE = NORMAL
GRADIUS = 2.200
GWIDTH = 3.000
GTEETH = 30
GTOOTHDEPTH = 0.500
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE2
GPOSITION = 0.000
GNAME = GEAR3
GTYPE = NORMAL
GRADIUS = 2.200
GWIDTH = 3.000
GTEETH = 20
GTOOTHDEPTH = 0.500
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE3
GPOSITION = 0.000
GNAME = GEAR4
GTYPE = NORMAL
GRADIUS = 1.700
GWIDTH = 1.000
GTEETH = 20
GTOOTHDEPTH = 0.500
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE2
GPOSITION = 5.000
GNAME = GEAR5
GTYPE = NORMAL
GRADIUS = 3.000
GWIDTH = 1.000
GTEETH = 20
GTOOTHDEPTH = 0.500
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE4
GPOSITION = 5.000
GNAME = GEAR6
GTYPE = BEVEL
GFACE = 0
GRADIUS = 4.000
GWIDTH = 1.000
GTEETH = 20
GTOOTHDEPTH = 1.700
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE4
GPOSITION = -4.000
GNAME = GEAR7
GTYPE = BEVEL
GFACE = 0
GRADIUS = 4.000
GWIDTH = 1.000
GTEETH = 20
GTOOTHDEPTH = 1.700
GCOLOR = 0.500 0.500 0.500
GAXLE = AXLE5
GPOSITION = 5.000
BELTNAME = BELT1
GEAR1NAME = GEAR5
GEAR2NAME = GEAR4

View File

@@ -1,4 +1,4 @@
/* $Id: gloss.c,v 1.4 2000/06/27 17:04:43 brianp Exp $ */
/* $Id: gloss.c,v 1.3 1999/10/26 17:08:31 brianp Exp $ */
/*
* Specular reflection demo. The specular highlight is modulated by
@@ -245,7 +245,7 @@ static void Init( int argc, char *argv[] )
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
/*glScalef(8.0, 4.0, 2.0);*/
glScalef(8.0, 4.0, 2.0);
glMatrixMode(GL_MODELVIEW);
/* cylinder */
@@ -322,14 +322,8 @@ static void Init( int argc, char *argv[] )
glBindTexture(GL_TEXTURE_2D, SpecularTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
#if 1
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
#else
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
#endif
if (!LoadRGBMipmaps(SPECULAR_TEXTURE_FILE, GL_RGB)) {
printf("Error: couldn't load texture image file %s\n", SPECULAR_TEXTURE_FILE);
exit(1);

View File

@@ -1,580 +0,0 @@
/*
* This program is under the GNU GPL.
* Use at your own risk.
*
* written by David Bucciarelli (tech.hmw@plus.it)
* Humanware s.r.l.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <GL/glut.h>
typedef struct
{
char *name;
char *unit;
void (*init) (void);
int (*run) (int, int);
int type;
int numsize;
int size[10];
}
benchmark;
static int frontbuffer = 1;
/***************************************************************************/
static void
init_test01(void)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-0.5, 639.5, -0.5, 479.5);
glMatrixMode(GL_MODELVIEW);
glShadeModel(GL_FLAT);
glDisable(GL_DEPTH_TEST);
glClearColor(0.0, 0.1, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0.0, 0.0);
}
static int
test01(int size, int num)
{
int x, y;
glBegin(GL_POINTS);
for (y = 0; y < num; y++)
for (x = 0; x < 480; x++)
glVertex2i(x, x);
glEnd();
return 480 * num;
}
/***************************************************************************/
static void
init_test02(void)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-0.5, 639.5, -0.5, 479.5);
glMatrixMode(GL_MODELVIEW);
glShadeModel(GL_SMOOTH);
glDisable(GL_DEPTH_TEST);
glClearColor(0.0, 0.1, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
}
static int
test02(int size, int num)
{
int x, y;
glBegin(GL_LINES);
for (y = 0; y < num; y++)
for (x = 0; x < size; x++) {
glColor3f(0.0, 1.0, y / (float) num);
glVertex2i(0, size - 1);
glColor3f(1.0, 0.0, x / (float) size);
glVertex2i(x, x);
}
glEnd();
return num * size;
}
/***************************************************************************/
static void
init_test03(void)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-0.5, 639.5, -0.5, 479.5, 1.0, -1000.0 * 480.0);
glMatrixMode(GL_MODELVIEW);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glClearColor(0.0, 0.1, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
static int
test03(int size, int num)
{
int x, y, z;
glBegin(GL_TRIANGLES);
for (y = 0; y < num; y++)
for (x = 0; x < size; x += 5) {
z = num * size - (y * size + x);
glColor3f(0.0, 1.0, 0.0);
glVertex3i(0, x, z);
glColor3f(1.0, 0.0, x / (float) size);
glVertex3i(size - 1 - x, 0, z);
glColor3f(1.0, x / (float) size, 0.0);
glVertex3i(x, size - 1 - x, z);
}
glEnd();
return size * num / 5;
}
/***************************************************************************/
static void
init_test04(void)
{
int x, y;
GLubyte tex[128 * 128 * 3];
GLenum gluerr;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-0.5, 639.5, -0.5, 479.5, 1.0, -1000.0 * 480.0);
glMatrixMode(GL_MODELVIEW);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for (y = 0; y < 128; y++)
for (x = 0; x < 128; x++) {
tex[(x + y * 128) * 3 + 0] = ((x % (128 / 4)) < (128 / 8)) ? 255 : 0;
tex[(x + y * 128) * 3 + 1] = ((y % (128 / 4)) < (128 / 8)) ? 255 : 0;
tex[(x + y * 128) * 3 + 2] = x;
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if ((gluerr = gluBuild2DMipmaps(GL_TEXTURE_2D, 3, 128, 128, GL_RGB,
GL_UNSIGNED_BYTE, (GLvoid *) (&tex[0])))) {
fprintf(stderr, "GLULib%s\n", gluErrorString(gluerr));
exit(-1);
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_2D);
glClearColor(0.0, 0.1, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
static int
test04(int size, int num)
{
int x, y, z;
glBegin(GL_TRIANGLES);
for (y = 0; y < num; y++)
for (x = 0; x < size; x += 5) {
z = num * size - (y * size + x);
glTexCoord2f(1.0, 1.0);
glColor3f(1.0, 0.0, 0.0);
glVertex3i(0, x, z);
glTexCoord2f(0.0, 1.0);
glColor3f(0.0, 1.0, 0.0);
glVertex3i(size - 1 - x, 0, z);
glTexCoord2f(1.0, 0.0);
glColor3f(0.0, 0.0, 1.0);
glVertex3i(x, size - 1 - x, z);
}
glEnd();
return num * size / 5;
}
/***************************************************************************/
static void
init_test05(void)
{
int x, y;
GLubyte tex[128 * 128 * 3];
GLenum gluerr;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-0.5, 639.5, -0.5, 479.5, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for (y = 0; y < 128; y++)
for (x = 0; x < 128; x++) {
tex[(x + y * 128) * 3 + 0] = ((x % (128 / 4)) < (128 / 8)) ? 255 : 0;
tex[(x + y * 128) * 3 + 1] = ((y % (128 / 4)) < (128 / 8)) ? 255 : 0;
tex[(x + y * 128) * 3 + 2] = x;
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if ((gluerr = gluBuild2DMipmaps(GL_TEXTURE_2D, 3, 128, 128, GL_RGB,
GL_UNSIGNED_BYTE, (GLvoid *) (&tex[0])))) {
fprintf(stderr, "GLULib%s\n", gluErrorString(gluerr));
exit(-1);
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_2D);
glDepthFunc(GL_ALWAYS);
glClearColor(0.0, 0.1, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
static int
test05(int size, int num)
{
int y;
float v0[3], v1[3], v2[3], v3[3];
float cv0[3], cv1[3], cv2[3], cv3[3];
float tv0[3], tv1[3], tv2[3], tv3[3];
v0[0] = 320 - size / 2;
v0[1] = 240 - size / 2;
v0[2] = 0.0;
v1[0] = 320 + size / 2;
v1[1] = 240 - size / 2;
v1[2] = 0.0;
v2[0] = 320 - size / 2;
v2[1] = 240 + size / 2;
v2[2] = 0.0;
v3[0] = 320 + size / 2;
v3[1] = 240 + size / 2;
v3[2] = 0.0;
cv0[0] = 1.0;
cv0[1] = 0.0;
cv0[2] = 0.0;
cv1[0] = 1.0;
cv1[1] = 1.0;
cv1[2] = 0.0;
cv2[0] = 1.0;
cv2[1] = 0.0;
cv2[2] = 1.0;
cv3[0] = 1.0;
cv3[1] = 1.0;
cv3[2] = 1.0;
tv0[0] = 0.0;
tv0[1] = 0.0;
tv0[2] = 0.0;
tv1[0] = 1.0;
tv1[1] = 0.0;
tv1[2] = 0.0;
tv2[0] = 0.0;
tv2[1] = 1.0;
tv2[2] = 0.0;
tv3[0] = 1.0;
tv3[1] = 1.0;
tv3[2] = 0.0;
glBegin(GL_TRIANGLE_STRIP);
for (y = 0; y < num; y++) {
glColor3fv(cv0);
glTexCoord2fv(tv0);
glVertex3fv(v0);
glColor3fv(cv1);
glTexCoord2fv(tv1);
glVertex3fv(v1);
glColor3fv(cv2);
glTexCoord2fv(tv2);
glVertex3fv(v2);
glColor3fv(cv3);
glTexCoord2fv(tv3);
glVertex3fv(v3);
}
glEnd();
return 4 * num - 2;
}
/***************************************************************************/
static void
init_test06(void)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-0.5, 639.5, -0.5, 479.5);
glMatrixMode(GL_MODELVIEW);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glClearColor(0.0, 0.1, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
static int
test06(int size, int num)
{
int y;
for (y = 0; y < num; y++) {
glClearColor(y / (float) num, 0.1, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
return num;
}
/***************************************************************************/
#define BMARKS_TIME 5.0
#define NUM_BMARKS 6
/* 554 ~= sqrt(640*480) */
static benchmark bmarks[NUM_BMARKS] = {
{"Simple Points", "Pnts", init_test01, test01, 0, 0,
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{"Smooth Lines", "Lins", init_test02, test02, 1, 5,
{480, 250, 100, 50, 25, 0, 0, 0, 0, 0}},
{"ZSmooth Triangles", "Tris", init_test03, test03, 1, 5,
{480, 250, 100, 50, 25, 0, 0, 0, 0, 0}},
{"ZSmooth Tex Blend Triangles", "Tris", init_test04, test04, 1, 5,
{480, 250, 100, 50, 25, 0, 0, 0, 0, 0}},
{"ZSmooth Tex Blend TMesh Triangles", "Tris", init_test05, test05, 2, 8,
{400, 250, 100, 50, 25, 10, 5, 2, 0, 0}},
{"Color/Depth Buffer Clears", "Clrs", init_test06, test06, 3, 0,
{554, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
};
/***************************************************************************/
static void
dotest0param(benchmark * bmark)
{
float stime, etime, dtime, tottime, maxtime, mintime;
int num, numelem, calibnum, j;
glPushAttrib(GL_ALL_ATTRIB_BITS);
bmark->init();
stime = glutGet(GLUT_ELAPSED_TIME);
dtime = 0.0;
calibnum = 0;
while (dtime < 2.0) {
bmark->run(0, 1);
glFinish();
etime = glutGet(GLUT_ELAPSED_TIME);
dtime = (etime - stime) / 1000.0;
calibnum++;
}
glPopAttrib();
fprintf(stderr, "Elapsed time for the calibration test (%d): %f\n",
calibnum, dtime);
num = (int) ((BMARKS_TIME / dtime) * calibnum);
if (num < 1)
num = 1;
fprintf(stderr, "Selected number of benchmark iterations: %d\n", num);
mintime = HUGE_VAL;
maxtime = -HUGE_VAL;
for (tottime = 0.0, j = 0; j < 5; j++) {
glPushAttrib(GL_ALL_ATTRIB_BITS);
bmark->init();
stime = glutGet(GLUT_ELAPSED_TIME);
numelem = bmark->run(0, num);
glFinish();
etime = glutGet(GLUT_ELAPSED_TIME);
glPopAttrib();
dtime = (etime - stime) / 1000.0;
tottime += dtime;
fprintf(stderr, "Elapsed time for run %d: %f\n", j, dtime);
if (dtime < mintime)
mintime = dtime;
if (dtime > maxtime)
maxtime = dtime;
}
tottime -= mintime + maxtime;
fprintf(stdout, "%s\n%f %s/sec", bmark->name, numelem / (tottime / 3.0),
bmark->unit);
if (bmark->type == 3)
fprintf(stdout, ", MPixel Fill/sec: %f\n\n",
(numelem * bmark->size[0] * (float) bmark->size[0]) /
(1000000.0 * tottime / 3.0));
else
fprintf(stdout, "\n\n");
}
/***************************************************************************/
static void
dotest1param(benchmark * bmark)
{
float stime, etime, dtime, tottime, maxtime, mintime;
int num, numelem, calibnum, j, k;
fprintf(stdout, "%s\n", bmark->name);
for (j = 0; j < bmark->numsize; j++) {
fprintf(stderr, "Current size: %d\n", bmark->size[j]);
glPushAttrib(GL_ALL_ATTRIB_BITS);
bmark->init();
stime = glutGet(GLUT_ELAPSED_TIME);
dtime = 0.0;
calibnum = 0;
while (dtime < 2.0) {
bmark->run(bmark->size[j], 1);
glFinish();
etime = glutGet(GLUT_ELAPSED_TIME);
dtime = (etime - stime) / 1000.0;
calibnum++;
}
glPopAttrib();
fprintf(stderr, "Elapsed time for the calibration test (%d): %f\n",
calibnum, dtime);
num = (int) ((BMARKS_TIME / dtime) * calibnum);
if (num < 1)
num = 1;
fprintf(stderr, "Selected number of benchmark iterations: %d\n", num);
mintime = HUGE_VAL;
maxtime = -HUGE_VAL;
for (numelem = 1, tottime = 0.0, k = 0; k < 5; k++) {
glPushAttrib(GL_ALL_ATTRIB_BITS);
bmark->init();
stime = glutGet(GLUT_ELAPSED_TIME);
numelem = bmark->run(bmark->size[j], num);
glFinish();
etime = glutGet(GLUT_ELAPSED_TIME);
glPopAttrib();
dtime = (etime - stime) / 1000.0;
tottime += dtime;
fprintf(stderr, "Elapsed time for run %d: %f\n", k, dtime);
if (dtime < mintime)
mintime = dtime;
if (dtime > maxtime)
maxtime = dtime;
}
tottime -= mintime + maxtime;
fprintf(stdout, "SIZE=%03d => %f %s/sec", bmark->size[j],
numelem / (tottime / 3.0), bmark->unit);
if (bmark->type == 2)
fprintf(stdout, ", MPixel Fill/sec: %f\n",
(numelem * bmark->size[j] * bmark->size[j] / 2) /
(1000000.0 * tottime / 3.0));
else
fprintf(stdout, "\n");
}
fprintf(stdout, "\n\n");
}
/***************************************************************************/
static void
display(void)
{
int i;
if (frontbuffer)
glDrawBuffer(GL_FRONT);
else
glDrawBuffer(GL_BACK);
for (i = 0; i < NUM_BMARKS; i++) {
fprintf(stderr, "Benchmark: %d\n", i);
switch (bmarks[i].type) {
case 0:
case 3:
dotest0param(&bmarks[i]);
break;
case 1:
case 2:
dotest1param(&bmarks[i]);
break;
}
}
exit(0);
}
int
main(int ac, char **av)
{
fprintf(stderr, "GLTest v1.0\nWritten by David Bucciarelli\n");
if (ac == 2)
frontbuffer = 0;
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowPosition(0, 0);
glutInitWindowSize(640, 480);
glutCreateWindow("OpenGL/Mesa Performances");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

View File

@@ -1,4 +1,4 @@
/* $Id: glutfx.c,v 1.2 2000/06/27 17:04:43 brianp Exp $ */
/* $Id: glutfx.c,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
/*
* Example of how one might use GLUT with the 3Dfx driver in full-screen mode.
@@ -16,11 +16,8 @@
/*
* $Log: glutfx.c,v $
* Revision 1.2 2000/06/27 17:04:43 brianp
* fixed compiler warnings
*
* Revision 1.1.1.1 1999/08/19 00:55:40 jtg
* Imported sources
* Revision 1.1 1999/08/19 00:55:40 jtg
* Initial revision
*
* Revision 3.2 1999/03/28 18:18:33 brianp
* minor clean-up
@@ -167,6 +164,7 @@ int main( int argc, char *argv[] )
printf("NOTE: if you've got 3Dfx VooDoo hardware you must run this");
printf(" program as root.\n\n");
printf("Move the mouse. Press ESC to exit.\n\n");
sleep(2);
#endif
/* Tell Mesa GLX to use 3Dfx driver in fullscreen mode. */

View File

@@ -1,704 +0,0 @@
/*
* This program is under the GNU GPL.
* Use at your own risk.
*
* written by David Bucciarelli (tech.hmw@plus.it)
* Humanware s.r.l.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#ifdef WIN32
#include <windows.h>
#include <mmsystem.h>
#endif
#include <GL/glut.h>
#include "../util/readtex.c"
#ifdef XMESA
#include "GL/xmesa.h"
static int fullscreen = 1;
#endif
static int WIDTH = 640;
static int HEIGHT = 480;
#define MAX_LOD 9
#define TEX_SKY_WIDTH 256
#define TEX_SKY_HEIGHT TEX_SKY_WIDTH
#ifndef M_PI
#define M_PI 3.1415926535
#endif
#define FROM_NONE 0
#define FROM_DOWN 1
#define FROM_UP 2
#define FROM_LEFT 3
#define FROM_RIGHT 4
#define FROM_FRONT 5
#define FROM_BACK 6
static int win = 0;
static float obs[3] = { 3.8, 0.0, 0.0 };
static float dir[3];
static float v = 0.0;
static float alpha = -90.0;
static float beta = 90.0;
static int fog = 1;
static int bfcull = 1;
static int usetex = 1;
static int help = 1;
static int poutline = 0;
static int normext = 1;
static int joyavailable = 0;
static int joyactive = 0;
static int LODbias = 3;
static int maxdepth = MAX_LOD;
static unsigned int totpoly = 0;
static GLuint t1id, t2id;
static GLuint skydlist, LODdlist[MAX_LOD], LODnumpoly[MAX_LOD];
static void
initlight(void)
{
GLfloat lspec[4] = { 1.0, 1.0, 1.0, 1.0 };
static GLfloat lightpos[4] = { 30, 15.0, 30.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, lightpos);
glLightfv(GL_LIGHT0, GL_SPECULAR, lspec);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 32.0);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, lspec);
}
static void
initdlists(void)
{
static int slicetable[MAX_LOD][2] = {
{21, 10},
{18, 9},
{15, 8},
{12, 7},
{9, 6},
{7, 5},
{5, 4},
{4, 3},
{3, 2}
};
GLUquadricObj *obj;
int i, xslices, yslices;
obj = gluNewQuadric();
skydlist = glGenLists(1);
glNewList(skydlist, GL_COMPILE);
glBindTexture(GL_TEXTURE_2D, t2id);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glColor3f(1.0f, 1.0f, 1.0f);
gluQuadricDrawStyle(obj, GLU_FILL);
gluQuadricNormals(obj, GLU_NONE);
gluQuadricTexture(obj, GL_TRUE);
gluQuadricOrientation(obj, GLU_INSIDE);
gluSphere(obj, 40.0f, 18, 9);
glEndList();
for (i = 0; i < MAX_LOD; i++) {
LODdlist[i] = glGenLists(1);
glNewList(LODdlist[i], GL_COMPILE);
gluQuadricDrawStyle(obj, GLU_FILL);
gluQuadricNormals(obj, GLU_SMOOTH);
gluQuadricTexture(obj, GL_TRUE);
gluQuadricOrientation(obj, GLU_OUTSIDE);
xslices = slicetable[i][0];
yslices = slicetable[i][1];
gluSphere(obj, 1.0f, xslices, yslices);
LODnumpoly[i] = xslices * (yslices - 2) + 2 * (xslices - 1);
glEndList();
}
}
static void
inittextures(void)
{
GLubyte tsky[TEX_SKY_HEIGHT][TEX_SKY_WIDTH][3];
GLuint x, y;
GLfloat fact;
GLenum gluerr;
/* Brick */
glGenTextures(1, &t1id);
glBindTexture(GL_TEXTURE_2D, t1id);
if (!LoadRGBMipmaps("../images/bw.rgb", 3)) {
fprintf(stderr, "Error reading a texture.\n");
exit(-1);
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
/* Sky */
glGenTextures(1, &t2id);
glBindTexture(GL_TEXTURE_2D, t2id);
for (y = 0; y < TEX_SKY_HEIGHT; y++)
for (x = 0; x < TEX_SKY_WIDTH; x++)
if (y < TEX_SKY_HEIGHT / 2) {
fact = y / (GLfloat) (TEX_SKY_HEIGHT / 2);
tsky[y][x][0] =
(GLubyte) (255.0f * (0.1f * fact + 0.3f * (1.0f - fact)));
tsky[y][x][1] =
(GLubyte) (255.0f * (0.2f * fact + 1.0f * (1.0f - fact)));
tsky[y][x][2] = 255;
}
else {
tsky[y][x][0] = tsky[TEX_SKY_HEIGHT - y - 1][x][0];
tsky[y][x][1] = tsky[TEX_SKY_HEIGHT - y - 1][x][1];
tsky[y][x][2] = 255;
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if (
(gluerr =
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TEX_SKY_WIDTH, TEX_SKY_HEIGHT,
GL_RGB, GL_UNSIGNED_BYTE, (GLvoid *) (tsky)))) {
fprintf(stderr, "GLULib%s\n", gluErrorString(gluerr));
exit(-1);
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
static float
gettime(void)
{
static clock_t told = 0;
clock_t tnew, ris;
tnew = clock();
ris = tnew - told;
told = tnew;
return (ris / (float) CLOCKS_PER_SEC);
}
static void
calcposobs(void)
{
dir[0] = sin(alpha * M_PI / 180.0);
dir[1] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
dir[2] = cos(beta * M_PI / 180.0);
obs[0] += v * dir[0];
obs[1] += v * dir[1];
obs[2] += v * dir[2];
}
static void
special(int k, int x, int y)
{
switch (k) {
case GLUT_KEY_LEFT:
alpha -= 2.0;
break;
case GLUT_KEY_RIGHT:
alpha += 2.0;
break;
case GLUT_KEY_DOWN:
beta -= 2.0;
break;
case GLUT_KEY_UP:
beta += 2.0;
break;
}
}
static void
key(unsigned char k, int x, int y)
{
switch (k) {
case 27:
exit(0);
break;
case 'a':
v += 0.01;
break;
case 'z':
v -= 0.01;
break;
#ifdef XMESA
case ' ':
fullscreen = (!fullscreen);
XMesaSetFXmode(fullscreen ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW);
break;
#endif
case '+':
LODbias--;
break;
case '-':
LODbias++;
break;
case 'j':
joyactive = (!joyactive);
break;
case 'h':
help = (!help);
break;
case 'f':
fog = (!fog);
break;
case 't':
usetex = (!usetex);
break;
case 'n':
normext = (!normext);
break;
case 'b':
if (bfcull) {
glDisable(GL_CULL_FACE);
bfcull = 0;
}
else {
glEnable(GL_CULL_FACE);
bfcull = 1;
}
break;
case 'p':
if (poutline) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
poutline = 0;
usetex = 1;
}
else {
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
poutline = 1;
usetex = 0;
}
break;
}
}
static void
reshape(int w, int h)
{
WIDTH = w;
HEIGHT = h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.0, w / (float) h, 0.8, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, w, h);
}
static void
printstring(void *font, char *string)
{
int len, i;
len = (int) strlen(string);
for (i = 0; i < len; i++)
glutBitmapCharacter(font, string[i]);
}
static void
printhelp(void)
{
glEnable(GL_BLEND);
glColor4f(0.5, 0.5, 0.5, 0.5);
glRecti(40, 40, 600, 440);
glDisable(GL_BLEND);
glColor3f(1.0, 0.0, 0.0);
glRasterPos2i(300, 420);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "Help");
glRasterPos2i(60, 390);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "h - Toggle Help");
glRasterPos2i(60, 360);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "t - Toggle Textures");
glRasterPos2i(60, 330);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "f - Toggle Fog");
glRasterPos2i(60, 300);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "b - Toggle Back face culling");
glRasterPos2i(60, 270);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "Arrow Keys - Rotate");
glRasterPos2i(60, 240);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "a - Increase velocity");
glRasterPos2i(60, 210);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "z - Decrease velocity");
glRasterPos2i(60, 180);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "p - Toggle Wire frame");
glRasterPos2i(60, 150);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,
"b - Toggle GL_EXT_rescale_normal extension");
glRasterPos2i(60, 120);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,
"+/- - Increase/decrease the Object maximum LOD");
glRasterPos2i(60, 90);
if (joyavailable)
printstring(GLUT_BITMAP_TIMES_ROMAN_24,
"j - Toggle jostick control (Joystick control available)");
else
printstring(GLUT_BITMAP_TIMES_ROMAN_24,
"(No Joystick control available)");
}
static void
dojoy(void)
{
#ifdef _WIN32
static UINT max[2] = { 0, 0 };
static UINT min[2] = { 0xffffffff, 0xffffffff }, center[2];
MMRESULT res;
JOYINFO joy;
res = joyGetPos(JOYSTICKID1, &joy);
if (res == JOYERR_NOERROR) {
joyavailable = 1;
if (max[0] < joy.wXpos)
max[0] = joy.wXpos;
if (min[0] > joy.wXpos)
min[0] = joy.wXpos;
center[0] = (max[0] + min[0]) / 2;
if (max[1] < joy.wYpos)
max[1] = joy.wYpos;
if (min[1] > joy.wYpos)
min[1] = joy.wYpos;
center[1] = (max[1] + min[1]) / 2;
if (joyactive) {
if (fabs(center[0] - (float) joy.wXpos) > 0.1 * (max[0] - min[0]))
alpha -=
2.0 * (center[0] - (float) joy.wXpos) / (max[0] - min[0]);
if (fabs(center[1] - (float) joy.wYpos) > 0.1 * (max[1] - min[1]))
beta += 2.0 * (center[1] - (float) joy.wYpos) / (max[1] - min[1]);
if (joy.wButtons & JOY_BUTTON1)
v += 0.01;
if (joy.wButtons & JOY_BUTTON2)
v -= 0.01;
}
}
else
joyavailable = 0;
#endif
}
static void
drawipers(int depth, int from)
{
int lod;
if (depth == maxdepth)
return;
lod = depth + LODbias;
if (lod < 0)
lod = 0;
if (lod >= MAX_LOD)
return;
switch (from) {
case FROM_NONE:
glCallList(LODdlist[lod]);
depth++;
drawipers(depth, FROM_DOWN);
drawipers(depth, FROM_UP);
drawipers(depth, FROM_FRONT);
drawipers(depth, FROM_BACK);
drawipers(depth, FROM_LEFT);
drawipers(depth, FROM_RIGHT);
break;
case FROM_FRONT:
glPushMatrix();
glTranslatef(0.0f, -1.5f, 0.0f);
glScalef(0.5f, 0.5f, 0.5f);
glCallList(LODdlist[lod]);
depth++;
drawipers(depth, FROM_DOWN);
drawipers(depth, FROM_UP);
drawipers(depth, FROM_FRONT);
drawipers(depth, FROM_LEFT);
drawipers(depth, FROM_RIGHT);
glPopMatrix();
break;
case FROM_BACK:
glPushMatrix();
glTranslatef(0.0f, 1.5f, 0.0f);
glScalef(0.5f, 0.5f, 0.5f);
glCallList(LODdlist[lod]);
depth++;
drawipers(depth, FROM_DOWN);
drawipers(depth, FROM_UP);
drawipers(depth, FROM_BACK);
drawipers(depth, FROM_LEFT);
drawipers(depth, FROM_RIGHT);
glPopMatrix();
break;
case FROM_LEFT:
glPushMatrix();
glTranslatef(-1.5f, 0.0f, 0.0f);
glScalef(0.5f, 0.5f, 0.5f);
glCallList(LODdlist[lod]);
depth++;
drawipers(depth, FROM_DOWN);
drawipers(depth, FROM_UP);
drawipers(depth, FROM_FRONT);
drawipers(depth, FROM_BACK);
drawipers(depth, FROM_LEFT);
glPopMatrix();
break;
case FROM_RIGHT:
glPushMatrix();
glTranslatef(1.5f, 0.0f, 0.0f);
glScalef(0.5f, 0.5f, 0.5f);
glCallList(LODdlist[lod]);
depth++;
drawipers(depth, FROM_DOWN);
drawipers(depth, FROM_UP);
drawipers(depth, FROM_FRONT);
drawipers(depth, FROM_BACK);
drawipers(depth, FROM_RIGHT);
glPopMatrix();
break;
case FROM_DOWN:
glPushMatrix();
glTranslatef(0.0f, 0.0f, 1.5f);
glScalef(0.5f, 0.5f, 0.5f);
glCallList(LODdlist[lod]);
depth++;
drawipers(depth, FROM_DOWN);
drawipers(depth, FROM_FRONT);
drawipers(depth, FROM_BACK);
drawipers(depth, FROM_LEFT);
drawipers(depth, FROM_RIGHT);
glPopMatrix();
break;
case FROM_UP:
glPushMatrix();
glTranslatef(0.0f, 0.0f, -1.5f);
glScalef(0.5f, 0.5f, 0.5f);
glCallList(LODdlist[lod]);
depth++;
drawipers(depth, FROM_UP);
drawipers(depth, FROM_FRONT);
drawipers(depth, FROM_BACK);
drawipers(depth, FROM_LEFT);
drawipers(depth, FROM_RIGHT);
glPopMatrix();
break;
}
totpoly += LODnumpoly[lod];
}
static void
draw(void)
{
static int count = 0;
static char frbuf[80];
static GLfloat alpha = 0.0f;
static GLfloat beta = 0.0f;
float fr;
dojoy();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (usetex)
glEnable(GL_TEXTURE_2D);
else
glDisable(GL_TEXTURE_2D);
if (fog)
glEnable(GL_FOG);
else
glDisable(GL_FOG);
glPushMatrix();
calcposobs();
gluLookAt(obs[0], obs[1], obs[2],
obs[0] + dir[0], obs[1] + dir[1], obs[2] + dir[2],
0.0, 0.0, 1.0);
/* Scene */
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glBindTexture(GL_TEXTURE_2D, t1id);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor3f(1.0f, 1.0f, 1.0f);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
if (normext)
glEnable(GL_RESCALE_NORMAL_EXT);
else
glEnable(GL_NORMALIZE);
glPushMatrix();
glRotatef(alpha, 0.0f, 0.0f, 1.0f);
glRotatef(beta, 1.0f, 0.0f, 0.0f);
totpoly = 0;
drawipers(0, FROM_NONE);
glPopMatrix();
alpha += 0.5f;
beta += 0.3f;
glDisable(GL_LIGHTING);
glDisable(GL_LIGHT0);
glShadeModel(GL_FLAT);
if (normext)
glDisable(GL_RESCALE_NORMAL_EXT);
else
glDisable(GL_NORMALIZE);
glCallList(skydlist);
glPopMatrix();
/* Help Screen */
fr = gettime();
sprintf(frbuf,
"Frame rate: %0.2f LOD: %d Tot. poly.: %d Poly/sec: %.1f",
1.0 / fr, LODbias, totpoly, totpoly / fr);
glDisable(GL_TEXTURE_2D);
glDisable(GL_FOG);
glShadeModel(GL_FLAT);
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-0.5, 639.5, -0.5, 479.5, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(1.0, 0.0, 0.0);
glRasterPos2i(10, 10);
printstring(GLUT_BITMAP_HELVETICA_18, frbuf);
glRasterPos2i(350, 470);
printstring(GLUT_BITMAP_HELVETICA_10,
"IperS V1.0 Written by David Bucciarelli (tech.hmw@plus.it)");
if (help)
printhelp();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glutSwapBuffers();
count++;
}
int
main(int ac, char **av)
{
float fogcolor[4] = { 0.7, 0.7, 0.7, 1.0 };
fprintf(stderr,
"IperS V1.0\nWritten by David Bucciarelli (tech.hmw@plus.it)\n");
glutInitWindowPosition(0, 0);
glutInitWindowSize(WIDTH, HEIGHT);
glutInit(&ac, av);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
if (!(win = glutCreateWindow("IperS"))) {
fprintf(stderr, "Error, couldn't open window\n");
exit(-1);
}
reshape(WIDTH, HEIGHT);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_FOG);
glFogi(GL_FOG_MODE, GL_EXP2);
glFogfv(GL_FOG_COLOR, fogcolor);
glFogf(GL_FOG_DENSITY, 0.006);
glHint(GL_FOG_HINT, GL_NICEST);
inittextures();
initdlists();
initlight();
glClearColor(fogcolor[0], fogcolor[1], fogcolor[2], fogcolor[3]);
glClear(GL_COLOR_BUFFER_BIT);
calcposobs();
glutReshapeFunc(reshape);
glutDisplayFunc(draw);
glutKeyboardFunc(key);
glutSpecialFunc(special);
glutIdleFunc(draw);
glutMainLoop();
return 0;
}

View File

@@ -1,4 +1,4 @@
/* $Id: isosurf.c,v 1.6 2000/06/27 17:04:43 brianp Exp $ */
/* $Id: isosurf.c,v 1.4 1999/10/21 16:39:06 brianp Exp $ */
/*
* Display an isosurface of 3-D wind speed volume.
@@ -25,12 +25,38 @@
* Other options are available via the popup menu.
*/
/*
* $Log: isosurf.c,v $
* Revision 1.4 1999/10/21 16:39:06 brianp
* added -info command line option
*
* Revision 1.3 1999/09/08 22:14:31 brianp
* minor changes. always call compactify_arrays()
*
* Revision 1.2 1999/09/03 14:56:40 keithw
* Fog, displaylist and zoom operations
*
* Revision 3.4 1999/04/24 01:10:47 keithw
* clip planes, materials
*
* Revision 3.3 1999/03/31 19:42:14 keithw
* support for cva
*
* Revision 3.1 1998/11/01 20:30:20 brianp
* added benchmark feature (b key)
*
* Revision 3.0 1998/02/14 18:42:29 brianp
* initial rev
*
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define GL_GLEXT_LEGACY
#include "GL/glut.h"
#include "../util/readtex.c" /* I know, this is a hack. KW: me too. */
@@ -61,9 +87,6 @@
#define NO_FOG 0x400000
#define QUIT 0x800000
#define DISPLAYLIST 0x1000000
#define GLINFO 0x2000000
#define STIPPLE 0x4000000
#define NO_STIPPLE 0x8000000
#define LIGHT_MASK (LIT|UNLIT)
#define TEXTURE_MASK (TEXTURE|NO_TEXTURE)
@@ -76,7 +99,6 @@
#define CLIP_MASK (USER_CLIP|NO_USER_CLIP)
#define SHADE_MASK (SHADE_SMOOTH|SHADE_FLAT)
#define FOG_MASK (FOG|NO_FOG)
#define STIPPLE_MASK (STIPPLE|NO_STIPPLE)
#define MAXVERTS 10000
static float data[MAXVERTS][6];
@@ -96,20 +118,6 @@ static GLuint surf1;
static GLboolean PrintInfo = GL_FALSE;
static GLubyte halftone[] = {
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA,
0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA,
0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA,
0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA,
0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA,
0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55};
/* forward decl */
int BuildList( int mode );
@@ -527,8 +535,6 @@ static void InitMaterials(void)
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_mat_shininess);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_mat_specular);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, front_mat_diffuse);
glPolygonStipple (halftone);
}
@@ -546,13 +552,6 @@ static void ModeMenu(int m)
if (m==QUIT)
exit(0);
if (m==GLINFO) {
printf("GL_VERSION: %s\n", (char *) glGetString(GL_VERSION));
printf("GL_EXTENSIONS: %s\n", (char *) glGetString(GL_EXTENSIONS));
printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER));
return;
}
if (CHANGED(state, m, FILTER_MASK)) {
if (m & LINEAR_FILTER) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -616,19 +615,6 @@ static void ModeMenu(int m)
}
}
if (CHANGED(state, m, STIPPLE_MASK)) {
if (m & STIPPLE)
{
glEnable(GL_POLYGON_STIPPLE);
printf("STIPPLE enable\n");
}
else
{
glDisable(GL_POLYGON_STIPPLE);
printf("STIPPLE disable\n");
}
}
#ifdef GL_EXT_vertex_array
if (CHANGED(state, m, (COMPILED_MASK|RENDER_STYLE_MASK|PRIMITIVE_MASK)))
{
@@ -645,12 +631,10 @@ static void ModeMenu(int m)
&compressed_data[0][3]);
}
#ifdef GL_EXT_compiled_vertex_array
if (allowed & COMPILED) {
if (m & COMPILED) {
glLockArraysEXT( 0, numuniq );
} else {
glUnlockArraysEXT();
}
if (m & COMPILED) {
glLockArraysEXT( 0, numuniq );
} else {
glUnlockArraysEXT();
}
#endif
}
@@ -673,7 +657,7 @@ static void Init(int argc, char *argv[])
{
GLfloat fogColor[4] = {0.5,1.0,0.5,1.0};
glClearColor(0.0, 0.0, 1.0, 0.0);
glClearColor(0.0, 0.0, 0.0, 0.0);
glEnable( GL_DEPTH_TEST );
glEnable( GL_VERTEX_ARRAY_EXT );
glEnable( GL_NORMAL_ARRAY_EXT );
@@ -690,7 +674,7 @@ static void Init(int argc, char *argv[])
set_matrix();
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
@@ -722,7 +706,6 @@ static void Init(int argc, char *argv[])
NO_USER_CLIP|
NO_MATERIALS|
NO_FOG|
NO_STIPPLE|
GLVERTEX);
if (PrintInfo) {
@@ -755,9 +738,6 @@ static void Key( unsigned char key, int x, int y )
case 's':
ModeMenu((state ^ SHADE_MASK) & SHADE_MASK);
break;
case 't':
ModeMenu((state ^ STIPPLE_MASK) & STIPPLE_MASK);
break;
case 'l':
ModeMenu((state ^ LIGHT_MASK) & LIGHT_MASK);
break;
@@ -767,13 +747,6 @@ static void Key( unsigned char key, int x, int y )
case 'c':
ModeMenu((state ^ CLIP_MASK) & CLIP_MASK);
break;
case 'v':
if (allowed&COMPILED)
ModeMenu(COMPILED|DRAW_ARRAYS|TRIANGLES);
break;
case 'V':
ModeMenu(IMMEDIATE|GLVERTEX|STRIPS);
break;
case 'b':
Benchmark(5.0, 0);
break;
@@ -905,8 +878,6 @@ int main(int argc, char **argv)
ModeMenu(arg_mode);
glutCreateMenu(ModeMenu);
glutAddMenuEntry("GL info", GLINFO);
glutAddMenuEntry("", 0);
glutAddMenuEntry("Lit", LIT|NO_TEXTURE|NO_REFLECT);
glutAddMenuEntry("Unlit", UNLIT|NO_TEXTURE|NO_REFLECT);
/* glutAddMenuEntry("Textured", TEXTURE); */
@@ -918,9 +889,6 @@ int main(int argc, char **argv)
glutAddMenuEntry("Fog", FOG);
glutAddMenuEntry("No Fog", NO_FOG);
glutAddMenuEntry("", 0);
glutAddMenuEntry("Stipple", STIPPLE);
glutAddMenuEntry("No Stipple", NO_STIPPLE);
glutAddMenuEntry("", 0);
glutAddMenuEntry("Point Filtered", POINT_FILTER);
glutAddMenuEntry("Linear Filtered", LINEAR_FILTER);
glutAddMenuEntry("", 0);
@@ -960,7 +928,6 @@ int main(int argc, char **argv)
glutKeyboardFunc(Key);
glutSpecialFunc(SpecialKey);
glutDisplayFunc(Display);
glutMainLoop();
return 0;
}

View File

@@ -1,229 +0,0 @@
/*
* GL_EXT_texture_lod_bias demo
*
* Thanks to Michael Vance for implementing this extension in Mesa.
*
* Brian Paul
* 20 March 2000
*
* Copyright (C) 2000 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/glext.h>
#include "../util/readtex.c" /* I know, this is a hack. */
#define TEXTURE_FILE "../images/girl.rgb"
static GLfloat Xrot = 0, Yrot = -30, Zrot = 0;
static GLboolean Anim = GL_TRUE;
static GLint Bias = 0, BiasStepSign = +1; /* ints avoid fp precision problem */
static GLint BiasMin = -200, BiasMax = 500;
static void
PrintString(const char *s)
{
while (*s) {
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
s++;
}
}
static void Idle( void )
{
static int lastTime = 0;
int time = glutGet(GLUT_ELAPSED_TIME);
int step;
if (lastTime == 0)
lastTime = time;
else if (time - lastTime < 10)
return;
step = (time - lastTime) / 10 * BiasStepSign;
lastTime = time;
Bias += step;
if (Bias < BiasMin) {
Bias = BiasMin;
BiasStepSign = +1;
}
else if (Bias > BiasMax) {
Bias = BiasMax;
BiasStepSign = -1;
}
glutPostRedisplay();
}
static void Display( void )
{
char str[100];
glClear( GL_COLOR_BUFFER_BIT );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho(-1, 1, -1, 1, -1, 1);
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glDisable(GL_TEXTURE_2D);
glColor3f(1,1,1);
glRasterPos3f(-0.9, -0.9, 0.0);
sprintf(str, "Texture LOD Bias = %4.1f", Bias * 0.01);
PrintString(str);
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.0, 0.0, -8.0 );
glPushMatrix();
glRotatef(Xrot, 1, 0, 0);
glRotatef(Yrot, 0, 1, 0);
glRotatef(Zrot, 0, 0, 1);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0.01 * Bias);
glBegin(GL_POLYGON);
glTexCoord2f(0, 0); glVertex2f(-1, -1);
glTexCoord2f(2, 0); glVertex2f( 1, -1);
glTexCoord2f(2, 2); glVertex2f( 1, 1);
glTexCoord2f(0, 2); glVertex2f(-1, 1);
glEnd();
glPopMatrix();
glutSwapBuffers();
}
static void Reshape( int width, int height )
{
glViewport( 0, 0, width, height );
}
static void Key( unsigned char key, int x, int y )
{
const GLfloat step = 3.0;
(void) x;
(void) y;
switch (key) {
case 'a':
Anim = !Anim;
if (Anim)
glutIdleFunc(Idle);
else
glutIdleFunc(NULL);
break;
case 'z':
Zrot -= step;
break;
case 'Z':
Zrot += step;
break;
case 'b':
Bias -= 10;
break;
case 'B':
Bias += 10;
break;
case 27:
exit(0);
break;
}
glutPostRedisplay();
}
static void SpecialKey( int key, int x, int y )
{
const GLfloat step = 3.0;
(void) x;
(void) y;
switch (key) {
case GLUT_KEY_UP:
Xrot -= step;
break;
case GLUT_KEY_DOWN:
Xrot += step;
break;
case GLUT_KEY_LEFT:
Yrot -= step;
break;
case GLUT_KEY_RIGHT:
Yrot += step;
break;
}
glutPostRedisplay();
}
static void Init( void )
{
const char *exten = (const char *) glGetString(GL_EXTENSIONS);
if (!strstr(exten, "GL_EXT_texture_lod_bias")) {
printf("Sorry, GL_EXT_texture_lod_bias not supported by this renderer.\n");
exit(1);
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) {
printf("Error: could not load texture image %s\n", TEXTURE_FILE);
exit(1);
}
/* mipmapping required for this extension */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
int main( int argc, char *argv[] )
{
glutInit( &argc, argv );
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( 350, 350 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
glutCreateWindow(argv[0]);
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );
glutSpecialFunc( SpecialKey );
glutDisplayFunc( Display );
if (Anim)
glutIdleFunc(Idle);
Init();
glutMainLoop();
return 0;
}

View File

@@ -1,13 +1,7 @@
/* $Id: morph3d.c,v 1.4 2000/06/27 17:04:43 brianp Exp $ */
/* $Id: morph3d.c,v 1.2 1999/09/17 12:27:01 brianp Exp $ */
/*
* $Log: morph3d.c,v $
* Revision 1.4 2000/06/27 17:04:43 brianp
* fixed compiler warnings
*
* Revision 1.3 1999/12/15 13:00:45 brianp
* moved #define to column 0
*
* Revision 1.2 1999/09/17 12:27:01 brianp
* silenced some warnings
*
@@ -504,7 +498,7 @@ static void draw_dodeca( void )
{
GLuint list;
#define TAU ((SQRT5+1)/2)
#define TAU ((SQRT5+1)/2)
list = glGenLists( 1 );
glNewList( list, GL_COMPILE );
@@ -833,7 +827,7 @@ static void pinit(void)
}
static void INIT(void)
void INIT(void)
{
printf("Morph 3D - Shows morphing platonic polyhedra\n");
printf("Author: Marcelo Fernandes Vianna (vianna@cat.cbpf.br)\n\n");

View File

@@ -1,4 +1,4 @@
/* $Id: multiarb.c,v 1.6 2000/05/23 23:21:00 brianp Exp $ */
/* $Id: multiarb.c,v 1.3 1999/10/21 16:40:32 brianp Exp $ */
/*
* GL_ARB_multitexture demo
@@ -12,15 +12,6 @@
/*
* $Log: multiarb.c,v $
* Revision 1.6 2000/05/23 23:21:00 brianp
* set default window pos
*
* Revision 1.5 2000/02/02 17:31:45 brianp
* changed > to >=
*
* Revision 1.4 2000/02/02 01:07:21 brianp
* limit Drift to [0, 1]
*
* Revision 1.3 1999/10/21 16:40:32 brianp
* added -info command line option
*
@@ -70,8 +61,6 @@ static void Idle( void )
{
if (Animate) {
Drift += 0.05;
if (Drift >= 1.0)
Drift = 0.0;
#ifdef GL_ARB_multitexture
glActiveTextureARB(GL_TEXTURE0_ARB);
@@ -322,7 +311,6 @@ int main( int argc, char *argv[] )
{
glutInit( &argc, argv );
glutInitWindowSize( 300, 300 );
glutInitWindowPosition( 0, 0 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
glutCreateWindow(argv[0] );

View File

@@ -1,226 +0,0 @@
/*
* GL_HP_occlustion_test demo
*
* Brian Paul
* 31 March 2000
*
* Copyright (C) 2000 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/glext.h>
static GLfloat Xpos = 0;
static void
PrintString(const char *s)
{
while (*s) {
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
s++;
}
}
static void Idle(void)
{
static int lastTime = 0;
static int sign = +1;
int time = glutGet(GLUT_ELAPSED_TIME);
float step;
if (lastTime == 0)
lastTime = time;
else if (time - lastTime < 20) /* 50Hz update */
return;
step = (time - lastTime) / 1000.0 * sign;
lastTime = time;
Xpos += step;
if (Xpos > 2.5) {
Xpos = 2.5;
sign = -1;
}
else if (Xpos < -2.5) {
Xpos = -2.5;
sign = +1;
}
glutPostRedisplay();
}
static void Display( void )
{
GLboolean result;
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.0, 0.0, -15.0 );
/* draw the occluding polygons */
glColor3f(0, 0.6, 0.8);
glBegin(GL_QUADS);
glVertex2f(-1.6, -1.5);
glVertex2f(-0.4, -1.5);
glVertex2f(-0.4, 1.5);
glVertex2f(-1.6, 1.5);
glVertex2f( 0.4, -1.5);
glVertex2f( 1.6, -1.5);
glVertex2f( 1.6, 1.5);
glVertex2f( 0.4, 1.5);
glEnd();
/* draw the test polygon with occlusion testing */
glPushMatrix();
glTranslatef(Xpos, 0, -0.5);
glScalef(0.3, 0.3, 1.0);
glRotatef(-90.0 * Xpos, 0, 0, 1);
glEnable(GL_OCCLUSION_TEST_HP); /* NOTE: enabling the occlusion test */
/* doesn't clear the result flag! */
glColorMask(0, 0, 0, 0);
glDepthMask(GL_FALSE);
/* this call clear's the result flag. Not really needed for this demo. */
glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP, &result);
glBegin(GL_POLYGON);
glVertex3f(-1, -1, 0);
glVertex3f( 1, -1, 0);
glVertex3f( 1, 1, 0);
glVertex3f(-1, 1, 0);
glEnd();
glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP, &result);
/* turn off occlusion testing */
glDisable(GL_OCCLUSION_TEST_HP);
glColorMask(1, 1, 1, 1);
glDepthMask(GL_TRUE);
/* draw the green rect, so we can see what's going on */
glColor3f(0.8, 0.5, 0);
glBegin(GL_POLYGON);
glVertex3f(-1, -1, 0);
glVertex3f( 1, -1, 0);
glVertex3f( 1, 1, 0);
glVertex3f(-1, 1, 0);
glEnd();
glPopMatrix();
/* Print result message */
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glColor3f(1, 1, 1);
glRasterPos3f(-0.25, -0.7, 0);
if (result)
PrintString(" Visible");
else
PrintString("Fully Occluded");
glutSwapBuffers();
}
static void Reshape( int width, int height )
{
glViewport( 0, 0, width, height );
}
static void Key( unsigned char key, int x, int y )
{
(void) x;
(void) y;
switch (key) {
case 27:
exit(0);
break;
}
glutPostRedisplay();
}
static void SpecialKey( int key, int x, int y )
{
const GLfloat step = 0.1;
(void) x;
(void) y;
switch (key) {
case GLUT_KEY_LEFT:
Xpos -= step;
break;
case GLUT_KEY_RIGHT:
Xpos += step;
break;
}
glutPostRedisplay();
}
static void Init( void )
{
const char *ext = (const char *) glGetString(GL_EXTENSIONS);
if (!strstr(ext, "GL_HP_occlusion_test")) {
printf("Sorry, this demo requires the GL_HP_occlusion_test extension\n");
exit(-1);
}
glEnable(GL_DEPTH_TEST);
}
int main( int argc, char *argv[] )
{
glutInit( &argc, argv );
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( 400, 400 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
glutCreateWindow(argv[0]);
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );
glutSpecialFunc( SpecialKey );
glutIdleFunc( Idle );
glutDisplayFunc( Display );
Init();
glutMainLoop();
return 0;
}

View File

@@ -1,4 +1,4 @@
/* $Id: osdemo.c,v 1.4 2000/03/28 16:59:39 rjfrank Exp $ */
/* $Id: osdemo.c,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
/*
* Demo of off-screen Mesa rendering
@@ -17,14 +17,24 @@
*/
/*
* $Log: osdemo.c,v $
* Revision 1.1 1999/08/19 00:55:40 jtg
* Initial revision
*
* Revision 3.0 1998/02/14 18:42:29 brianp
* initial rev
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "GL/osmesa.h"
#include "GL/glut.h"
#define SAVE_TARGA
#define WIDTH 400
#define HEIGHT 400
@@ -75,159 +85,27 @@ static void render_image( void )
glutSolidCone(1.0, 2.0, 16, 1);
glPopMatrix();
#ifdef GL_HP_occlusion_test
{
GLboolean bRet;
glDepthMask(GL_FALSE);
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
glEnable(GL_OCCLUSION_TEST_HP);
glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP,&bRet);
glPushMatrix();
glTranslatef(0.75, 0.0, -1.0);
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue_mat );
glutSolidSphere(1.0, 20, 20);
glPopMatrix();
glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP,&bRet);
printf("Occlusion test 1 (result should be 1): %d\n",bRet);
glDepthMask(GL_TRUE);
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
glDisable(GL_OCCLUSION_TEST_HP);
}
#endif
glPushMatrix();
glTranslatef(0.75, 0.0, -1.0);
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue_mat );
glutSolidSphere(1.0, 20, 20);
glPopMatrix();
#ifdef GL_HP_occlusion_test
{
GLboolean bRet;
glDepthMask(GL_FALSE);
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
glEnable(GL_OCCLUSION_TEST_HP);
glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP,&bRet);
/* draw a sphere inside the previous sphere */
glPushMatrix();
glTranslatef(0.75, 0.0, -1.0);
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue_mat );
glutSolidSphere(0.5, 20, 20);
glPopMatrix();
glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP,&bRet);
printf("Occlusion test 2 (result should be 0): %d\n",bRet);
glDepthMask(GL_TRUE);
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
glDisable(GL_OCCLUSION_TEST_HP);
}
#endif
glPopMatrix();
}
static void
write_targa(const char *filename, const GLubyte *buffer, int width, int height)
{
FILE *f = fopen( filename, "w" );
if (f) {
int i, x, y;
const GLubyte *ptr = buffer;
printf ("osdemo, writing tga file \n");
fputc (0x00, f); /* ID Length, 0 => No ID */
fputc (0x00, f); /* Color Map Type, 0 => No color map included */
fputc (0x02, f); /* Image Type, 2 => Uncompressed, True-color Image */
fputc (0x00, f); /* Next five bytes are about the color map entries */
fputc (0x00, f); /* 2 bytes Index, 2 bytes length, 1 byte size */
fputc (0x00, f);
fputc (0x00, f);
fputc (0x00, f);
fputc (0x00, f); /* X-origin of Image */
fputc (0x00, f);
fputc (0x00, f); /* Y-origin of Image */
fputc (0x00, f);
fputc (WIDTH & 0xff, f); /* Image Width */
fputc ((WIDTH>>8) & 0xff, f);
fputc (HEIGHT & 0xff, f); /* Image Height */
fputc ((HEIGHT>>8) & 0xff, f);
fputc (0x18, f); /* Pixel Depth, 0x18 => 24 Bits */
fputc (0x20, f); /* Image Descriptor */
fclose(f);
f = fopen( filename, "ab" ); /* reopen in binary append mode */
for (y=height-1; y>=0; y--) {
for (x=0; x<width; x++) {
i = (y*width + x) * 4;
fputc(ptr[i+2], f); /* write blue */
fputc(ptr[i+1], f); /* write green */
fputc(ptr[i], f); /* write red */
}
}
}
}
static void
write_ppm(const char *filename, const GLubyte *buffer, int width, int height)
{
const int binary = 0;
FILE *f = fopen( filename, "w" );
if (f) {
int i, x, y;
const GLubyte *ptr = buffer;
if (binary) {
fprintf(f,"P6\n");
fprintf(f,"# ppm-file created by osdemo.c\n");
fprintf(f,"%i %i\n", width,height);
fprintf(f,"255\n");
fclose(f);
f = fopen( filename, "ab" ); /* reopen in binary append mode */
for (y=height-1; y>=0; y--) {
for (x=0; x<width; x++) {
i = (y*width + x) * 4;
fputc(ptr[i], f); /* write red */
fputc(ptr[i+1], f); /* write green */
fputc(ptr[i+2], f); /* write blue */
}
}
}
else {
/*ASCII*/
int counter = 0;
fprintf(f,"P3\n");
fprintf(f,"# ascii ppm file created by osdemo.c\n");
fprintf(f,"%i %i\n", width, height);
fprintf(f,"255\n");
for (y=height-1; y>=0; y--) {
for (x=0; x<width; x++) {
i = (y*width + x) * 4;
fprintf(f, " %3d %3d %3d", ptr[i], ptr[i+1], ptr[i+2]);
counter++;
if (counter % 5 == 0)
fprintf(f, "\n");
}
}
}
fclose(f);
}
}
int main( int argc, char *argv[] )
{
OSMesaContext ctx;
void *buffer;
/* Create an RGBA-mode context */
OSMesaContext ctx = OSMesaCreateContext( GL_RGBA, NULL );
ctx = OSMesaCreateContext( GL_RGBA, NULL );
/* Allocate the image buffer */
void *buffer = malloc( WIDTH * HEIGHT * 4 );
buffer = malloc( WIDTH * HEIGHT * 4 );
/* Bind the buffer to the context and make it current */
OSMesaMakeCurrent( ctx, buffer, GL_UNSIGNED_BYTE, WIDTH, HEIGHT );
@@ -235,14 +113,48 @@ int main( int argc, char *argv[] )
render_image();
if (argc>1) {
#ifdef SAVE_TARGA
write_targa(argv[1], buffer, WIDTH, HEIGHT);
#else
write_ppm(argv[1], buffer, WIDTH, HEIGHT);
/* write PPM file */
FILE *f = fopen( argv[1], "w" );
if (f) {
int i, x, y;
GLubyte *ptr = (GLubyte *) buffer;
#define BINARY 0
#if BINARY
fprintf(f,"P6\n");
fprintf(f,"# ppm-file created by %s\n", argv[0]);
fprintf(f,"%i %i\n", WIDTH,HEIGHT);
fprintf(f,"255\n");
fclose(f);
f = fopen( argv[1], "ab" ); /* reopen in binary append mode */
for (y=HEIGHT-1; y>=0; y--) {
for (x=0; x<WIDTH; x++) {
i = (y*WIDTH + x) * 4;
fputc(ptr[i], f); /* write red */
fputc(ptr[i+1], f); /* write green */
fputc(ptr[i+2], f); /* write blue */
}
}
#else /*ASCII*/
int counter = 0;
fprintf(f,"P3\n");
fprintf(f,"# ascii ppm file created by %s\n", argv[0]);
fprintf(f,"%i %i\n", WIDTH, HEIGHT);
fprintf(f,"255\n");
for (y=HEIGHT-1; y>=0; y--) {
for (x=0; x<WIDTH; x++) {
i = (y*WIDTH + x) * 4;
fprintf(f, " %3d %3d %3d", ptr[i], ptr[i+1], ptr[i+2]);
counter++;
if (counter % 5 == 0)
fprintf(f, "\n");
}
}
#endif
fclose(f);
}
}
else {
printf("Specify a filename if you want to make an image file\n");
printf("Specify a filename if you want to make a ppm file\n");
}
printf("all done\n");

View File

@@ -1,14 +1,30 @@
/* $Id: paltex.c,v 1.4 2000/06/27 17:12:10 brianp Exp $ */
/* $Id: paltex.c,v 1.2 1999/11/02 15:09:04 brianp Exp $ */
/*
* Paletted texture demo. Written by Brian Paul.
* This program is in the public domain.
*/
/*
* $Log: paltex.c,v $
* Revision 1.2 1999/11/02 15:09:04 brianp
* new texture image, cleaned-up code
*
* Revision 1.1.1.1 1999/08/19 00:55:40 jtg
* Imported sources
*
* Revision 3.1 1999/03/28 18:20:49 brianp
* minor clean-up
*
* Revision 3.0 1998/02/14 18:42:29 brianp
* initial rev
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GL_GLEXT_LEGACY
#include <GL/glut.h>
@@ -82,6 +98,7 @@ static void Init( void )
" "
};
GLubyte table[256][4];
int i;
if (!glutExtensionSupported("GL_EXT_paletted_texture")) {
printf("Sorry, GL_EXT_paletted_texture not supported\n");

View File

@@ -1,219 +0,0 @@
/*
* This program is under the GNU GPL.
* Use at your own risk.
*
* written by David Bucciarelli (humanware@plus.it)
* Humanware s.r.l.
*/
#include <stdlib.h>
#include "particles.h"
#define vinit(a,i,j,k) {\
(a)[0]=i;\
(a)[1]=j;\
(a)[2]=k;\
}
#define vadds(a,dt,b) {\
(a)[0]+=(dt)*(b)[0];\
(a)[1]+=(dt)*(b)[1];\
(a)[2]+=(dt)*(b)[2];\
}
#define vequ(a,b) {\
(a)[0]=(b)[0];\
(a)[1]=(b)[1];\
(a)[2]=(b)[2];\
}
#define vinter(a,dt,b,c) {\
(a)[0]=(dt)*(b)[0]+(1.0-dt)*(c)[0];\
(a)[1]=(dt)*(b)[1]+(1.0-dt)*(c)[1];\
(a)[2]=(dt)*(b)[2]+(1.0-dt)*(c)[2];\
}
#define clamp(a) ((a) < 0.0 ? 0.0 : ((a) < 1.0 ? (a) : 1.0))
#define vclamp(v) {\
(v)[0]=clamp((v)[0]);\
(v)[1]=clamp((v)[1]);\
(v)[2]=clamp((v)[2]);\
}
float rainParticle::min[3];
float rainParticle::max[3];
float rainParticle::partLength=0.2f;
static float vrnd(void)
{
return(((float)rand())/RAND_MAX);
}
particle::particle()
{
age=0.0f;
vinit(acc,0.0f,0.0f,0.0f);
vinit(vel,0.0f,0.0f,0.0f);
vinit(pos,0.0f,0.0f,0.0f);
}
void particle::elapsedTime(float dt)
{
age+=dt;
vadds(vel,dt,acc);
vadds(pos,dt,vel);
}
/////////////////////////////////////////
// Particle System
/////////////////////////////////////////
particleSystem::particleSystem()
{
t=0.0f;
part=NULL;
particleNum=0;
}
particleSystem::~particleSystem()
{
if(part)
free(part);
}
void particleSystem::addParticle(particle *p)
{
if(!part) {
part=(particle **)calloc(1,sizeof(particle *));
part[0]=p;
particleNum=1;
} else {
particleNum++;
part=(particle **)realloc(part,sizeof(particle *)*particleNum);
part[particleNum-1]=p;
}
}
void particleSystem::reset(void)
{
if(part)
free(part);
t=0.0f;
part=NULL;
particleNum=0;
}
void particleSystem::draw(void)
{
if(!part)
return;
part[0]->beginDraw();
for(unsigned int i=0;i<particleNum;i++)
part[i]->draw();
part[0]->endDraw();
}
void particleSystem::addTime(float dt)
{
if(!part)
return;
for(unsigned int i=0;i<particleNum;i++) {
part[i]->elapsedTime(dt);
part[i]->checkAge();
}
}
/////////////////////////////////////////
// Rain
/////////////////////////////////////////
void rainParticle::init(void)
{
age=0.0f;
acc[0]=0.0f;
acc[1]=-0.98f;
acc[2]=0.0f;
vel[0]=0.0f;
vel[1]=0.0f;
vel[2]=0.0f;
oldpos[0]=pos[0]=min[0]+(max[0]-min[0])*vrnd();
oldpos[1]=pos[1]=max[1]+0.2f*max[1]*vrnd();
oldpos[2]=pos[2]=min[2]+(max[2]-min[2])*vrnd();
vadds(oldpos,-partLength,vel);
}
rainParticle::rainParticle()
{
init();
}
void rainParticle::setRainingArea(float minx, float miny, float minz,
float maxx, float maxy, float maxz)
{
vinit(min,minx,miny,minz);
vinit(max,maxx,maxy,maxz);
}
void rainParticle::setLength(float l)
{
partLength=l;
}
void rainParticle::draw(void)
{
glColor4f(0.7f,0.95f,1.0f,0.0f);
glVertex3fv(oldpos);
glColor4f(0.3f,0.7f,1.0f,1.0f);
glVertex3fv(pos);
}
void rainParticle::checkAge(void)
{
if(pos[1]<min[1])
init();
}
void rainParticle::elapsedTime(float dt)
{
particle::elapsedTime(dt);
if(pos[0]<min[0])
pos[0]=max[0]-(min[0]-pos[0]);
if(pos[2]<min[2])
pos[2]=max[2]-(min[2]-pos[2]);
if(pos[0]>max[0])
pos[0]=min[0]+(pos[0]-max[0]);
if(pos[2]>max[2])
pos[2]=min[2]+(pos[2]-max[2]);
vequ(oldpos,pos);
vadds(oldpos,-partLength,vel);
}
void rainParticle::randomHeight(void)
{
pos[1]=(max[1]-min[1])*vrnd()+min[1];
oldpos[1]=pos[1]-partLength*vel[1];
}

View File

@@ -1,81 +0,0 @@
/*
* This program is under the GNU GPL.
* Use at your own risk.
*
* written by David Bucciarelli (humanware@plus.it)
* Humanware s.r.l.
*/
#ifndef PARTICLES_H
#define PARTICLES_H
#include <GL/gl.h>
class particle {
protected:
float age; // in seconds
float acc[3];
float vel[3];
float pos[3];
public:
particle();
virtual ~particle() {};
virtual void beginDraw(void) {};
virtual void draw(void)=0;
virtual void endDraw(void) {};
virtual void elapsedTime(float);
virtual void checkAge(void) {};
};
class particleSystem {
protected:
particle **part;
float t;
unsigned long particleNum;
public:
particleSystem();
~particleSystem();
void addParticle(particle *);
void reset(void);
void draw(void);
void addTime(float);
};
class rainParticle : public particle {
protected:
static float min[3];
static float max[3];
static float partLength;
float oldpos[3];
void init(void);
public:
rainParticle();
static void setRainingArea(float, float, float,
float, float, float);
static void setLength(float);
static float getLength(void) { return partLength; };
void beginDraw(void) { glBegin(GL_LINES); };
void draw(void);
void endDraw(void) { glEnd(); };
void elapsedTime(float);
void checkAge(void);
void randomHeight(void);
};
#endif

View File

@@ -1,210 +0,0 @@
/*
* GL_SGIS_pixel_texture demo
*
* Brian Paul
* 6 Apr 2000
*
* Copyright (C) 2000 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* How this works:
* 1. We load the image into a 2D texture.
* 2. We generate a sequence of RGB images in which the R component
* is really the S texture coordinate and the G component is really
* the T texture coordinate.
* By warping the mapping from R to S and G to T we can get non-linear
* distortions.
* 3. Draw the warped image (a 2-D warping function) with pixel texgen
* enabled.
* 4. Loop over the warped images to animate.
*
* The pixel texgen extension can also be used to do color-space
* conversions. For example, we could convert YCR to RGB with a
* 3D texture map which takes YCR as the S,T,R texture coordinate and
* returns RGB texel values.
*
* You can use this extension in (at least) two ways:
* 1. glDrawPixels w/ color space conversion/warping
* 2. glDrawPixels to spatially warp another image in texture memory
*
* We're basically using glDrawPixels to draw a texture coordinate image.
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <GL/glut.h>
#include <GL/glext.h>
#include "../util/readtex.c" /* I know, this is a hack. */
#define TEXTURE_FILE "../images/girl.rgb"
static int ImgWidth = 300, ImgHeight = 300;
#define FRAMES 20
static GLubyte *ImgData[FRAMES];
static GLint Frame = 0;
static GLboolean TextureFlag = GL_TRUE;
static void Display( void )
{
glClear( GL_COLOR_BUFFER_BIT );
if (TextureFlag) {
glEnable(GL_PIXEL_TEXTURE_SGIS);
glEnable(GL_TEXTURE_2D);
}
else {
glDisable(GL_PIXEL_TEXTURE_SGIS);
glDisable(GL_TEXTURE_2D);
}
glColor3f(1, 1, 1);
glRasterPos2f(10, 10);
glDrawPixels(ImgWidth, ImgHeight, GL_RGB, GL_UNSIGNED_BYTE, ImgData[Frame]);
glutSwapBuffers();
}
static void Reshape( int width, int height )
{
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho(0, width, 0, height, -1, 1);
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}
static void Key( unsigned char key, int x, int y )
{
(void) x;
(void) y;
switch (key) {
case ' ':
TextureFlag = !TextureFlag;
break;
case 27:
exit(0);
break;
}
glutPostRedisplay();
}
static void Idle(void)
{
Frame++;
if (Frame >= FRAMES)
Frame = 0;
glutPostRedisplay();
}
static GLubyte warp(GLfloat s, int frame)
{
static const GLfloat PI = 3.14159265;
static int halfFrame = FRAMES / 2;
GLfloat y, weight, v;
if (frame >= halfFrame)
frame = halfFrame - (frame - halfFrame);
y = sin(s * PI);
weight = (float) frame / (FRAMES-1);
v = y * (0.8 * weight + 0.2);
return (GLint) (v * 255.0F);
}
static void InitImage(void)
{
int i, j, frame;
for (frame = 0; frame < FRAMES; frame++) {
ImgData[frame] = (GLubyte *) malloc(ImgWidth * ImgHeight * 3);
for (i = 0; i < ImgHeight; i++) {
for (j = 0; j < ImgWidth; j++) {
GLubyte *pixel = ImgData[frame] + (i * ImgWidth + j) * 3;
pixel[0] = warp((float) j / (ImgWidth - 0), frame);
pixel[1] = warp((float) i / (ImgHeight - 0), frame);
pixel[2] = 0.0;
}
}
}
}
static void Init( int argc, char *argv[] )
{
const char *exten = (const char *) glGetString(GL_EXTENSIONS);
if (!strstr(exten, "GL_SGIS_pixel_texture")) {
printf("Sorry, GL_SGIS_pixel_texture not supported by this renderer.\n");
exit(1);
}
/* linear filtering looks nicer, but it's slower, since it's in software */
#if 1
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
#else
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
#endif
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) {
printf("Error: couldn't load texture image\n");
exit(1);
}
glClearColor(0.3, 0.3, 0.4, 1.0);
InitImage();
printf("Hit SPACE to toggle pixel texgen\n");
}
int main( int argc, char *argv[] )
{
glutInit( &argc, argv );
glutInitWindowSize( 330, 330 );
glutInitWindowPosition( 0, 0 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
glutCreateWindow(argv[0] );
Init( argc, argv );
glutKeyboardFunc( Key );
glutReshapeFunc( Reshape );
glutDisplayFunc( Display );
glutIdleFunc( Idle );
glutMainLoop();
return 0;
}

View File

@@ -13,11 +13,8 @@
/*
* $Log: pointblast.c,v $
* Revision 1.2 2000/06/27 17:04:43 brianp
* fixed compiler warnings
*
* Revision 1.1.1.1 1999/08/19 00:55:40 jtg
* Imported sources
* Revision 1.1 1999/08/19 00:55:40 jtg
* Initial revision
*
* Revision 3.3 1998/07/26 01:24:27 brianp
* removed include of gl.h
@@ -38,7 +35,6 @@
#include <stdlib.h>
#include <string.h>
#include <math.h> /* for cos(), sin(), and sqrt() */
#define GL_GLEXT_LEGACY
#include <GL/glut.h>
/* Some <math.h> files do not define M_PI... */
@@ -104,7 +100,7 @@ static float float_rand(void) { return rand() / (float) RAND_MAX; }
/* Modeling units of ground extent in each X and Z direction. */
#define EDGE 12
static void
void
makePointList(void)
{
float angle, velocity, direction;
@@ -128,7 +124,7 @@ makePointList(void)
theTime = 0.0;
}
static void
void
updatePointList(void)
{
float distance;
@@ -171,7 +167,7 @@ updatePointList(void)
}
}
static void
void
idle(void)
{
updatePointList();
@@ -182,7 +178,7 @@ idle(void)
glutPostRedisplay();
}
static void
void
visible(int vis)
{
if (vis == GLUT_VISIBLE) {
@@ -194,7 +190,7 @@ visible(int vis)
}
}
static void
void
recalcModelView(void)
{
glPopMatrix();
@@ -203,7 +199,7 @@ recalcModelView(void)
newModel = 0;
}
static void
void
redraw(void)
{
int i;
@@ -251,7 +247,7 @@ redraw(void)
}
/* ARGSUSED2 */
static void
void
mouse(int button, int state, int x, int y)
{
/* Scene can be spun around Y axis using left
@@ -266,7 +262,7 @@ mouse(int button, int state, int x, int y)
}
/* ARGSUSED1 */
static void
void
mouseMotion(int x, int y)
{
if (moving) {
@@ -277,7 +273,7 @@ mouseMotion(int x, int y)
}
}
static void
void
menu(int option)
{
switch (option) {
@@ -351,7 +347,7 @@ menu(int option)
}
/* ARGSUSED1 */
static void
void
key(unsigned char c, int x, int y)
{
switch (c) {

View File

@@ -1,388 +0,0 @@
/*
* This program is under the GNU GPL.
* Use at your own risk.
*
* written by David Bucciarelli (humanware@plus.it)
* Humanware s.r.l.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <GL/glut.h>
#include "particles.h"
extern "C" {
#include "image.h"
}
#ifdef WIN32
#include <windows.h>
#include <mmsystem.h>
#endif
#ifdef XMESA
#include "GL/xmesa.h"
static int fullscreen=1;
#endif
static int WIDTH=640;
static int HEIGHT=480;
static int NUMPART=7500;
#define FRAME 50
static float fogcolor[4]={1.0,1.0,1.0,1.0};
#define DIMP 40.0
#define DIMTP 32.0
static float q[4][3]={
{-DIMP,0.0,-DIMP},
{DIMP,0.0,-DIMP},
{DIMP,0.0,DIMP},
{-DIMP,0.0,DIMP}
};
static float qt[4][2]={
{-DIMTP,-DIMTP},
{DIMTP,-DIMTP},
{DIMTP,DIMTP},
{-DIMTP,DIMTP}
};
static int win=0;
static int fog=1;
static int help=1;
static GLuint groundid;
static float obs[3]={2.0,1.0,0.0};
static float dir[3];
static float v=0.0;
static float alpha=-90.0;
static float beta=90.0;
static particleSystem *ps;
static float gettime()
{
static clock_t told=0;
clock_t tnew,ris;
tnew=clock();
ris=tnew-told;
told=tnew;
return(ris/(float)CLOCKS_PER_SEC);
}
static float gettimerain()
{
static clock_t told=0;
clock_t tnew,ris;
tnew=clock();
ris=tnew-told;
told=tnew;
return(ris/(float)CLOCKS_PER_SEC);
}
static void calcposobs(void)
{
dir[0]=sin(alpha*M_PI/180.0);
dir[2]=cos(alpha*M_PI/180.0)*sin(beta*M_PI/180.0);
dir[1]=cos(beta*M_PI/180.0);
obs[0]+=v*dir[0];
obs[1]+=v*dir[1];
obs[2]+=v*dir[2];
rainParticle::setRainingArea(obs[0]-7.0f,-0.2f,obs[2]-7.0f,obs[0]+7.0f,8.0f,obs[2]+7.0f);
}
static void printstring(void *font, char *string)
{
int len,i;
len=(int)strlen(string);
for(i=0;i<len;i++)
glutBitmapCharacter(font,string[i]);
}
static void reshape(int width, int height)
{
WIDTH=width;
HEIGHT=height;
glViewport(0,0,(GLint)width,(GLint)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(70.0,width/(float)height,0.1,30.0);
glMatrixMode(GL_MODELVIEW);
}
static void printhelp(void)
{
glEnable(GL_BLEND);
glColor4f(0.0,0.0,0.0,0.5);
glRecti(40,40,600,440);
glDisable(GL_BLEND);
glColor3f(1.0,0.0,0.0);
glRasterPos2i(300,420);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"Help");
glRasterPos2i(60,390);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"h - Togle Help");
glRasterPos2i(60,360);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"f - Togle Fog");
glRasterPos2i(60,330);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"Arrow Keys - Rotate");
glRasterPos2i(60,300);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"a - Increase velocity");
glRasterPos2i(60,270);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"z - Decrease velocity");
glRasterPos2i(60,240);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"l - Increase rain length");
glRasterPos2i(60,210);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"k - Increase rain length");
}
static void drawrain(void)
{
static int count=0;
static char frbuf[80];
float fr;
glEnable(GL_DEPTH_TEST);
if(fog)
glEnable(GL_FOG);
else
glDisable(GL_FOG);
glDepthMask(GL_TRUE);
glClearColor(1.0,1.0,1.0,1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
calcposobs();
gluLookAt(obs[0],obs[1],obs[2],
obs[0]+dir[0],obs[1]+dir[1],obs[2]+dir[2],
0.0,1.0,0.0);
glColor4f(1.0,1.0,1.0,1.0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,groundid);
glBegin(GL_QUADS);
glTexCoord2fv(qt[0]);
glVertex3fv(q[0]);
glTexCoord2fv(qt[1]);
glVertex3fv(q[1]);
glTexCoord2fv(qt[2]);
glVertex3fv(q[2]);
glTexCoord2fv(qt[3]);
glVertex3fv(q[3]);
glEnd();
// Particle System
glDisable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND);
ps->draw();
ps->addTime(gettimerain());
glShadeModel(GL_FLAT);
if((count % FRAME)==0) {
fr=gettime();
sprintf(frbuf,"Frame rate: %f",FRAME/fr);
}
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glDisable(GL_FOG);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-0.5,639.5,-0.5,479.5,-1.0,1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(1.0,0.0,0.0);
glRasterPos2i(10,10);
printstring(GLUT_BITMAP_HELVETICA_18,frbuf);
glRasterPos2i(350,470);
printstring(GLUT_BITMAP_HELVETICA_10,"Rain V1.0 Written by David Bucciarelli (humanware@plus.it)");
if(help)
printhelp();
reshape(WIDTH,HEIGHT);
glPopMatrix();
glutSwapBuffers();
count++;
}
static void special(int key, int x, int y)
{
switch (key) {
case GLUT_KEY_LEFT:
alpha+=2.0;
break;
case GLUT_KEY_RIGHT:
alpha-=2.0;
break;
case GLUT_KEY_DOWN:
beta-=2.0;
break;
case GLUT_KEY_UP:
beta+=2.0;
break;
}
}
static void key(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(0);
break;
case 'a':
v+=0.01;
break;
case 'z':
v-=0.01;
break;
case 'l':
rainParticle::setLength(rainParticle::getLength()+0.025f);
break;
case 'k':
rainParticle::setLength(rainParticle::getLength()-0.025f);
break;
case 'h':
help=(!help);
break;
case 'f':
fog=(!fog);
break;
#ifdef XMESA
case ' ':
XMesaSetFXmode(fullscreen ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW);
fullscreen=(!fullscreen);
break;
#endif
}
}
static void inittextures(void)
{
IMAGE *img;
GLenum gluerr;
glGenTextures(1,&groundid);
glBindTexture(GL_TEXTURE_2D,groundid);
if(!(img=ImageLoad("s128.rgb"))) {
fprintf(stderr,"Error reading a texture.\n");
exit(-1);
}
glPixelStorei(GL_UNPACK_ALIGNMENT,4);
if((gluerr=(GLenum)gluBuild2DMipmaps(GL_TEXTURE_2D, 3, img->sizeX, img->sizeY, GL_RGB,
GL_UNSIGNED_BYTE, (GLvoid *)(img->data)))) {
fprintf(stderr,"GLULib%s\n",gluErrorString(gluerr));
exit(-1);
}
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);
}
static void initparticle(void)
{
ps=new particleSystem;
rainParticle::setRainingArea(-7.0f,-0.2f,-7.0f,7.0f,8.0f,7.0f);
for(int i=0;i<NUMPART;i++) {
rainParticle *p=new rainParticle;
p->randomHeight();
ps->addParticle((particle *)p);
}
}
int main(int ac,char **av)
{
fprintf(stderr,"Rain V1.0\nWritten by David Bucciarelli (humanware@plus.it)\n");
/* Default settings */
WIDTH=640;
HEIGHT=480;
glutInitWindowPosition(0,0);
glutInitWindowSize(WIDTH,HEIGHT);
glutInit(&ac,av);
glutInitDisplayMode(GLUT_RGB|GLUT_DEPTH|GLUT_DOUBLE);
if(!(win=glutCreateWindow("Rain"))) {
fprintf(stderr,"Error opening a window.\n");
exit(-1);
}
reshape(WIDTH,HEIGHT);
inittextures();
glShadeModel(GL_FLAT);
glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_FOG);
glFogi(GL_FOG_MODE,GL_EXP);
glFogfv(GL_FOG_COLOR,fogcolor);
glFogf(GL_FOG_DENSITY,0.1);
#ifdef FX
glHint(GL_FOG_HINT,GL_NICEST);
#endif
initparticle();
glutKeyboardFunc(key);
glutSpecialFunc(special);
glutDisplayFunc(drawrain);
glutIdleFunc(drawrain);
glutReshapeFunc(reshape);
glutMainLoop();
return(0);
}

View File

@@ -1,908 +0,0 @@
/*
* This program is under the GNU GPL.
* Use at your own risk.
*
* written by David Bucciarelli (tech.hmw@plus.it)
* Humanware s.r.l.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#ifdef WIN32
#include <windows.h>
#endif
#include <GL/glut.h>
#ifdef XMESA
#include "GL/xmesa.h"
static int fullscreen = 1;
#endif
static int WIDTH = 640;
static int HEIGHT = 480;
#define FRAME 50
#define BASESIZE 7.5f
#define SPHERE_RADIUS 0.75f
#define TEX_CHECK_WIDTH 256
#define TEX_CHECK_HEIGHT 256
#define TEX_CHECK_SLOT_SIZE (TEX_CHECK_HEIGHT/16)
#define TEX_CHECK_NUMSLOT (TEX_CHECK_HEIGHT/TEX_CHECK_SLOT_SIZE)
#define TEX_REFLECT_WIDTH 256
#define TEX_REFLECT_HEIGHT 256
#define TEX_REFLECT_SLOT_SIZE (TEX_REFLECT_HEIGHT/16)
#define TEX_REFLECT_NUMSLOT (TEX_REFLECT_HEIGHT/TEX_REFLECT_SLOT_SIZE)
#ifndef M_PI
#define M_PI 3.1415926535
#endif
#define EPSILON 0.0001
#define clamp255(a) ( (a)<(0.0f) ? (0.0f) : ((a)>(255.0f) ? (255.0f) : (a)) )
#define fabs(x) ((x)<0.0f?-(x):(x))
#define vequ(a,b) { (a)[0]=(b)[0]; (a)[1]=(b)[1]; (a)[2]=(b)[2]; }
#define vsub(a,b,c) { (a)[0]=(b)[0]-(c)[0]; (a)[1]=(b)[1]-(c)[1]; (a)[2]=(b)[2]-(c)[2]; }
#define dprod(a,b) ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])
#define vnormalize(a,b) { \
register float m_norm; \
m_norm=sqrt((double)dprod((a),(a))); \
(a)[0] /=m_norm; \
(a)[1] /=m_norm; \
(a)[2] /=m_norm; }
static GLubyte checkmap[TEX_CHECK_HEIGHT][TEX_CHECK_WIDTH][3];
static GLuint checkid;
static int checkmap_currentslot = 0;
static GLubyte reflectmap[TEX_REFLECT_HEIGHT][TEX_REFLECT_WIDTH][3];
static GLuint reflectid;
static int reflectmap_currentslot = 0;
static GLuint lightdlist;
static GLuint objdlist;
static float lightpos[3] = { 2.1, 2.1, 2.8 };
static float objpos[3] = { 0.0, 0.0, 1.0 };
static float sphere_pos[TEX_CHECK_HEIGHT][TEX_REFLECT_WIDTH][3];
static int win = 0;
static float fogcolor[4] = { 0.05, 0.05, 0.05, 1.0 };
static float obs[3] = { 7.0, 0.0, 2.0 };
static float dir[3];
static float v = 0.0;
static float alpha = -90.0;
static float beta = 90.0;
static int fog = 1;
static int bfcull = 1;
static int poutline = 0;
static int help = 1;
static int showcheckmap = 1;
static int showreflectmap = 1;
static int joyavailable = 0;
static int joyactive = 0;
static float
gettime(void)
{
static float told = 0.0f;
float tnew, ris;
tnew = glutGet(GLUT_ELAPSED_TIME);
ris = tnew - told;
told = tnew;
return ris / 1000.0;
}
static void
calcposobs(void)
{
dir[0] = sin(alpha * M_PI / 180.0);
dir[1] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
dir[2] = cos(beta * M_PI / 180.0);
obs[0] += v * dir[0];
obs[1] += v * dir[1];
obs[2] += v * dir[2];
}
static void
special(int k, int x, int y)
{
switch (k) {
case GLUT_KEY_LEFT:
alpha -= 2.0;
break;
case GLUT_KEY_RIGHT:
alpha += 2.0;
break;
case GLUT_KEY_DOWN:
beta -= 2.0;
break;
case GLUT_KEY_UP:
beta += 2.0;
break;
}
}
static void
key(unsigned char k, int x, int y)
{
switch (k) {
case 27:
exit(0);
break;
case 's':
lightpos[1] -= 0.1;
break;
case 'd':
lightpos[1] += 0.1;
break;
case 'e':
lightpos[0] -= 0.1;
break;
case 'x':
lightpos[0] += 0.1;
break;
case 'w':
lightpos[2] -= 0.1;
break;
case 'r':
lightpos[2] += 0.1;
break;
case 'j':
objpos[1] -= 0.1;
break;
case 'k':
objpos[1] += 0.1;
break;
case 'i':
objpos[0] -= 0.1;
break;
case 'm':
objpos[0] += 0.1;
break;
case 'u':
objpos[2] -= 0.1;
break;
case 'o':
objpos[2] += 0.1;
break;
case 'a':
v += 0.005;
break;
case 'z':
v -= 0.005;
break;
case 'g':
joyactive = (!joyactive);
break;
case 'h':
help = (!help);
break;
case 'f':
fog = (!fog);
break;
case '1':
showcheckmap = (!showcheckmap);
break;
case '2':
showreflectmap = (!showreflectmap);
break;
case 'b':
if (bfcull) {
glDisable(GL_CULL_FACE);
bfcull = 0;
}
else {
glEnable(GL_CULL_FACE);
bfcull = 1;
}
break;
case 'p':
if (poutline) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
poutline = 0;
}
else {
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
poutline = 1;
}
break;
#ifdef XMESA
case ' ':
XMesaSetFXmode(fullscreen ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW);
fullscreen = (!fullscreen);
break;
#endif
}
}
static void
reshape(int w, int h)
{
WIDTH = w;
HEIGHT = h;
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, w / (float) h, 0.8, 40.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
static void
printstring(void *font, char *string)
{
int len, i;
len = (int) strlen(string);
for (i = 0; i < len; i++)
glutBitmapCharacter(font, string[i]);
}
static void
printhelp(void)
{
glEnable(GL_BLEND);
glColor4f(0.5, 0.5, 0.5, 0.5);
glRecti(40, 40, 600, 440);
glDisable(GL_BLEND);
glColor3f(0.0, 0.0, 1.0);
glRasterPos2i(300, 420);
printstring(GLUT_BITMAP_HELVETICA_18, "Help");
glRasterPos2i(60, 390);
printstring(GLUT_BITMAP_HELVETICA_12, "h - Togle Help");
glRasterPos2i(60, 370);
printstring(GLUT_BITMAP_HELVETICA_12, "f - Togle Fog");
glRasterPos2i(60, 350);
printstring(GLUT_BITMAP_HELVETICA_12, "b - Togle Back face culling");
glRasterPos2i(60, 330);
printstring(GLUT_BITMAP_HELVETICA_12, "p - Togle Wire frame");
glRasterPos2i(60, 310);
printstring(GLUT_BITMAP_HELVETICA_12, "Arrow Keys - Rotate");
glRasterPos2i(60, 290);
printstring(GLUT_BITMAP_HELVETICA_12, "a - Increase velocity");
glRasterPos2i(60, 270);
printstring(GLUT_BITMAP_HELVETICA_12, "z - Decrease velocity");
glRasterPos2i(60, 250);
if (joyavailable)
printstring(GLUT_BITMAP_HELVETICA_12,
"j - Togle jostick control (Joystick control available)");
else
printstring(GLUT_BITMAP_HELVETICA_12,
"(No Joystick control available)");
glRasterPos2i(60, 230);
printstring(GLUT_BITMAP_HELVETICA_12,
"To move the light source: s - left, d - right, e - far, x - near, w - down r - up");
glRasterPos2i(60, 210);
printstring(GLUT_BITMAP_HELVETICA_12,
"To move the mirror sphere: j - left, k - right, i - far, m - near, u - down o - up");
glRasterPos2i(60, 190);
printstring(GLUT_BITMAP_HELVETICA_12,
"1 - Togle the plane texture map window");
glRasterPos2i(60, 170);
printstring(GLUT_BITMAP_HELVETICA_12,
"2 - Togle the sphere texture map window");
}
static GLboolean
seelight(float p[3], float dir[3])
{
float c[3], b, a, d, t, dist[3];
vsub(c, p, objpos);
b = -dprod(c, dir);
a = dprod(c, c) - SPHERE_RADIUS * SPHERE_RADIUS;
if ((d = b * b - a) < 0.0 || (b < 0.0 && a > 0.0))
return GL_FALSE;
d = sqrt(d);
t = b - d;
if (t < EPSILON) {
t = b + d;
if (t < EPSILON)
return GL_FALSE;
}
vsub(dist, lightpos, p);
if (dprod(dist, dist) < t * t)
return GL_FALSE;
return GL_TRUE;
}
static int
colorcheckmap(float ppos[3], float c[3])
{
static float norm[3] = { 0.0f, 0.0f, 1.0f };
float ldir[3], vdir[3], h[3], dfact, kfact, r, g, b;
int x, y;
x = (int) ((ppos[0] + BASESIZE / 2) * (10.0f / BASESIZE));
if ((x < 0) || (x > 10))
return GL_FALSE;
y = (int) ((ppos[1] + BASESIZE / 2) * (10.0f / BASESIZE));
if ((y < 0) || (y > 10))
return GL_FALSE;
r = 255.0f;
if (y & 1) {
if (x & 1)
g = 255.0f;
else
g = 0.0f;
}
else {
if (x & 1)
g = 0.0f;
else
g = 255.0f;
}
b = 0.0f;
vsub(ldir, lightpos, ppos);
vnormalize(ldir, ldir);
if (seelight(ppos, ldir)) {
c[0] = r * 0.05f;
c[1] = g * 0.05f;
c[2] = b * 0.05f;
return GL_TRUE;
}
dfact = dprod(ldir, norm);
if (dfact < 0.0f)
dfact = 0.0f;
vsub(vdir, obs, ppos);
vnormalize(vdir, vdir);
h[0] = 0.5f * (vdir[0] + ldir[0]);
h[1] = 0.5f * (vdir[1] + ldir[1]);
h[2] = 0.5f * (vdir[2] + ldir[2]);
kfact = dprod(h, norm);
kfact =
kfact * kfact * kfact * kfact * kfact * kfact * kfact * 7.0f * 255.0f;
r = r * dfact + kfact;
g = g * dfact + kfact;
b = b * dfact + kfact;
c[0] = clamp255(r);
c[1] = clamp255(g);
c[2] = clamp255(b);
return GL_TRUE;
}
static void
updatecheckmap(int slot)
{
float c[3], ppos[3];
int x, y;
glBindTexture(GL_TEXTURE_2D, checkid);
ppos[2] = 0.0f;
for (y = slot * TEX_CHECK_SLOT_SIZE; y < (slot + 1) * TEX_CHECK_SLOT_SIZE;
y++) {
ppos[1] = (y / (float) TEX_CHECK_HEIGHT) * BASESIZE - BASESIZE / 2;
for (x = 0; x < TEX_CHECK_WIDTH; x++) {
ppos[0] = (x / (float) TEX_CHECK_WIDTH) * BASESIZE - BASESIZE / 2;
colorcheckmap(ppos, c);
checkmap[y][x][0] = (GLubyte) c[0];
checkmap[y][x][1] = (GLubyte) c[1];
checkmap[y][x][2] = (GLubyte) c[2];
}
}
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, slot * TEX_CHECK_SLOT_SIZE,
TEX_CHECK_WIDTH, TEX_CHECK_SLOT_SIZE, GL_RGB,
GL_UNSIGNED_BYTE,
&checkmap[slot * TEX_CHECK_SLOT_SIZE][0][0]);
}
static void
updatereflectmap(int slot)
{
float rf, r, g, b, t, dfact, kfact, rdir[3];
float rcol[3], ppos[3], norm[3], ldir[3], h[3], vdir[3], planepos[3];
int x, y;
glBindTexture(GL_TEXTURE_2D, reflectid);
for (y = slot * TEX_REFLECT_SLOT_SIZE;
y < (slot + 1) * TEX_REFLECT_SLOT_SIZE; y++)
for (x = 0; x < TEX_REFLECT_WIDTH; x++) {
ppos[0] = sphere_pos[y][x][0] + objpos[0];
ppos[1] = sphere_pos[y][x][1] + objpos[1];
ppos[2] = sphere_pos[y][x][2] + objpos[2];
vsub(norm, ppos, objpos);
vnormalize(norm, norm);
vsub(ldir, lightpos, ppos);
vnormalize(ldir, ldir);
vsub(vdir, obs, ppos);
vnormalize(vdir, vdir);
rf = 2.0f * dprod(norm, vdir);
if (rf > EPSILON) {
rdir[0] = rf * norm[0] - vdir[0];
rdir[1] = rf * norm[1] - vdir[1];
rdir[2] = rf * norm[2] - vdir[2];
t = -objpos[2] / rdir[2];
if (t > EPSILON) {
planepos[0] = objpos[0] + t * rdir[0];
planepos[1] = objpos[1] + t * rdir[1];
planepos[2] = 0.0f;
if (!colorcheckmap(planepos, rcol))
rcol[0] = rcol[1] = rcol[2] = 0.0f;
}
else
rcol[0] = rcol[1] = rcol[2] = 0.0f;
}
else
rcol[0] = rcol[1] = rcol[2] = 0.0f;
dfact = 0.1f * dprod(ldir, norm);
if (dfact < 0.0f) {
dfact = 0.0f;
kfact = 0.0f;
}
else {
h[0] = 0.5f * (vdir[0] + ldir[0]);
h[1] = 0.5f * (vdir[1] + ldir[1]);
h[2] = 0.5f * (vdir[2] + ldir[2]);
kfact = dprod(h, norm);
kfact *= kfact;
kfact *= kfact;
kfact *= kfact;
kfact *= kfact;
kfact *= 10.0f;
}
r = dfact + kfact;
g = dfact + kfact;
b = dfact + kfact;
r *= 255.0f;
g *= 255.0f;
b *= 255.0f;
r += rcol[0];
g += rcol[1];
b += rcol[2];
r = clamp255(r);
g = clamp255(g);
b = clamp255(b);
reflectmap[y][x][0] = (GLubyte) r;
reflectmap[y][x][1] = (GLubyte) g;
reflectmap[y][x][2] = (GLubyte) b;
}
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, slot * TEX_REFLECT_SLOT_SIZE,
TEX_REFLECT_WIDTH, TEX_REFLECT_SLOT_SIZE, GL_RGB,
GL_UNSIGNED_BYTE,
&reflectmap[slot * TEX_REFLECT_SLOT_SIZE][0][0]);
}
static void
drawbase(void)
{
glColor3f(0.0, 0.0, 0.0);
glBindTexture(GL_TEXTURE_2D, checkid);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-BASESIZE / 2.0f, -BASESIZE / 2.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(BASESIZE / 2.0f, -BASESIZE / 2.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(BASESIZE / 2.0f, BASESIZE / 2.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-BASESIZE / 2.0f, BASESIZE / 2.0f, 0.0f);
glEnd();
}
static void
drawobj(void)
{
glColor3f(0.0, 0.0, 0.0);
glBindTexture(GL_TEXTURE_2D, reflectid);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glPushMatrix();
glTranslatef(objpos[0], objpos[1], objpos[2]);
glCallList(objdlist);
glPopMatrix();
}
static void
dojoy(void)
{
#ifdef WIN32
static UINT max[2] = { 0, 0 };
static UINT min[2] = { 0xffffffff, 0xffffffff }, center[2];
MMRESULT res;
JOYINFO joy;
res = joyGetPos(JOYSTICKID1, &joy);
if (res == JOYERR_NOERROR) {
joyavailable = 1;
if (max[0] < joy.wXpos)
max[0] = joy.wXpos;
if (min[0] > joy.wXpos)
min[0] = joy.wXpos;
center[0] = (max[0] + min[0]) / 2;
if (max[1] < joy.wYpos)
max[1] = joy.wYpos;
if (min[1] > joy.wYpos)
min[1] = joy.wYpos;
center[1] = (max[1] + min[1]) / 2;
if (joyactive) {
if (fabs(center[0] - (float) joy.wXpos) > 0.1 * (max[0] - min[0]))
alpha -=
2.5 * (center[0] - (float) joy.wXpos) / (max[0] - min[0]);
if (fabs(center[1] - (float) joy.wYpos) > 0.1 * (max[1] - min[1]))
beta += 2.5 * (center[1] - (float) joy.wYpos) / (max[1] - min[1]);
if (joy.wButtons & JOY_BUTTON1)
v += 0.005;
if (joy.wButtons & JOY_BUTTON2)
v -= 0.005;
}
}
else
joyavailable = 0;
#endif
}
static void
updatemaps(void)
{
updatecheckmap(checkmap_currentslot);
checkmap_currentslot = (checkmap_currentslot + 1) % TEX_CHECK_NUMSLOT;
updatereflectmap(reflectmap_currentslot);
reflectmap_currentslot =
(reflectmap_currentslot + 1) % TEX_REFLECT_NUMSLOT;
}
static void
draw(void)
{
static int count = 0;
static char frbuf[80];
float fr;
dojoy();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
if (fog)
glEnable(GL_FOG);
else
glDisable(GL_FOG);
glPushMatrix();
calcposobs();
gluLookAt(obs[0], obs[1], obs[2],
obs[0] + dir[0], obs[1] + dir[1], obs[2] + dir[2],
0.0, 0.0, 1.0);
drawbase();
drawobj();
glColor3f(1.0, 1.0, 1.0);
glDisable(GL_TEXTURE_2D);
glPushMatrix();
glTranslatef(lightpos[0], lightpos[1], lightpos[2]);
glCallList(lightdlist);
glPopMatrix();
glPopMatrix();
if ((count % FRAME) == 0) {
fr = gettime();
sprintf(frbuf, "Frame rate: %f", FRAME / fr);
}
glDisable(GL_DEPTH_TEST);
glDisable(GL_FOG);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-0.5, 639.5, -0.5, 479.5, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glColor3f(0.0f, 0.3f, 1.0f);
if (showcheckmap) {
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, checkid);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 0.0f);
glVertex2i(10, 30);
glTexCoord2f(1.0f, 1.0f);
glVertex2i(10 + 90, 30);
glTexCoord2f(0.0f, 1.0f);
glVertex2i(10 + 90, 30 + 90);
glTexCoord2f(0.0f, 0.0f);
glVertex2i(10, 30 + 90);
glEnd();
glDisable(GL_TEXTURE_2D);
glBegin(GL_LINE_LOOP);
glVertex2i(10, 30);
glVertex2i(10 + 90, 30);
glVertex2i(10 + 90, 30 + 90);
glVertex2i(10, 30 + 90);
glEnd();
glRasterPos2i(105, 65);
printstring(GLUT_BITMAP_HELVETICA_18, "Plane Texture Map");
}
if (showreflectmap) {
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, reflectid);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 0.0f);
glVertex2i(540, 30);
glTexCoord2f(1.0f, 1.0f);
glVertex2i(540 + 90, 30);
glTexCoord2f(0.0f, 1.0f);
glVertex2i(540 + 90, 30 + 90);
glTexCoord2f(0.0f, 0.0f);
glVertex2i(540, 30 + 90);
glEnd();
glDisable(GL_TEXTURE_2D);
glBegin(GL_LINE_LOOP);
glVertex2i(540, 30);
glVertex2i(540 + 90, 30);
glVertex2i(540 + 90, 30 + 90);
glVertex2i(540, 30 + 90);
glEnd();
glRasterPos2i(360, 65);
printstring(GLUT_BITMAP_HELVETICA_18, "Sphere Texture Map");
}
glDisable(GL_TEXTURE_2D);
glRasterPos2i(10, 10);
printstring(GLUT_BITMAP_HELVETICA_18, frbuf);
glRasterPos2i(360, 470);
printstring(GLUT_BITMAP_HELVETICA_10,
"Ray V1.0 Written by David Bucciarelli (tech.hmw@plus.it)");
if (help)
printhelp();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
updatemaps();
glutSwapBuffers();
count++;
}
static void
inittextures(void)
{
int y;
glGenTextures(1, &checkid);
glBindTexture(GL_TEXTURE_2D, checkid);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TEX_CHECK_WIDTH, TEX_CHECK_HEIGHT,
0, GL_RGB, GL_UNSIGNED_BYTE, checkmap);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
for (y = 0; y < TEX_CHECK_NUMSLOT; y++)
updatecheckmap(y);
glGenTextures(1, &reflectid);
glBindTexture(GL_TEXTURE_2D, reflectid);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TEX_REFLECT_WIDTH, TEX_REFLECT_HEIGHT,
0, GL_RGB, GL_UNSIGNED_BYTE, reflectmap);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
for (y = 0; y < TEX_REFLECT_NUMSLOT; y++)
updatereflectmap(y);
}
static void
initspherepos(void)
{
float alpha, beta, sa, ca, sb, cb;
int x, y;
for (y = 0; y < TEX_REFLECT_HEIGHT; y++) {
beta = M_PI - y * (M_PI / TEX_REFLECT_HEIGHT);
for (x = 0; x < TEX_REFLECT_WIDTH; x++) {
alpha = -x * (2.0f * M_PI / TEX_REFLECT_WIDTH);
sa = sin(alpha);
ca = cos(alpha);
sb = sin(beta);
cb = cos(beta);
sphere_pos[y][x][0] = SPHERE_RADIUS * sa * sb;
sphere_pos[y][x][1] = SPHERE_RADIUS * ca * sb;
sphere_pos[y][x][2] = SPHERE_RADIUS * cb;
}
}
}
static void
initdlists(void)
{
GLUquadricObj *obj;
obj = gluNewQuadric();
lightdlist = glGenLists(1);
glNewList(lightdlist, GL_COMPILE);
gluQuadricDrawStyle(obj, GLU_FILL);
gluQuadricNormals(obj, GLU_NONE);
gluQuadricTexture(obj, GL_TRUE);
gluSphere(obj, 0.25f, 6, 6);
glEndList();
objdlist = glGenLists(1);
glNewList(objdlist, GL_COMPILE);
gluQuadricDrawStyle(obj, GLU_FILL);
gluQuadricNormals(obj, GLU_NONE);
gluQuadricTexture(obj, GL_TRUE);
gluSphere(obj, SPHERE_RADIUS, 16, 16);
glEndList();
}
int
main(int ac, char **av)
{
fprintf(stderr,
"Ray V1.0\nWritten by David Bucciarelli (tech.hmw@plus.it)\n");
/*
if(!SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS)) {
fprintf(stderr,"Error setting the process class.\n");
return 0;
}
if(!SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL)) {
fprintf(stderr,"Error setting the process priority.\n");
return 0;
}
*/
glutInitWindowPosition(0, 0);
glutInitWindowSize(WIDTH, HEIGHT);
glutInit(&ac, av);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
if (!(win = glutCreateWindow("Ray"))) {
fprintf(stderr, "Error, couldn't open window\n");
return -1;
}
reshape(WIDTH, HEIGHT);
glShadeModel(GL_FLAT);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_FOG);
glFogi(GL_FOG_MODE, GL_EXP2);
glFogfv(GL_FOG_COLOR, fogcolor);
glFogf(GL_FOG_DENSITY, 0.01);
#ifdef FX
glHint(GL_FOG_HINT, GL_NICEST);
#endif
calcposobs();
initspherepos();
inittextures();
initdlists();
glClearColor(fogcolor[0], fogcolor[1], fogcolor[2], fogcolor[3]);
glutReshapeFunc(reshape);
glutDisplayFunc(draw);
glutKeyboardFunc(key);
glutSpecialFunc(special);
glutIdleFunc(draw);
glutMainLoop();
return 0;
}

View File

@@ -1,270 +0,0 @@
/* $Id: readpix.c,v 1.3 2000/03/31 01:01:31 brianp Exp $ */
/*
* glReadPixels and glCopyPixels test
*
* Brian Paul March 1, 2000 This file is in the public domain.
*/
/*
* $Log: readpix.c,v $
* Revision 1.3 2000/03/31 01:01:31 brianp
* tweaks to allow different read formats/types
*
* Revision 1.2 2000/03/23 19:47:25 brianp
* added benchmarking
*
* Revision 1.1 2000/03/01 16:23:14 brianp
* test glDraw/Read/CopyPixels()
*
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include "../util/readtex.c" /* a hack, I know */
#define IMAGE_FILE "../images/girl.rgb"
static int ImgWidth, ImgHeight;
static GLenum ImgFormat;
static GLubyte *Image = NULL;
static int APosX, APosY; /* simple drawpixels */
static int BPosX, BPosY; /* read/draw pixels */
static int CPosX, CPosY; /* copypixels */
static GLboolean DrawFront = GL_FALSE;
static GLboolean ScaleAndBias = GL_FALSE;
static GLboolean Benchmark = GL_FALSE;
static GLubyte *TempImage = NULL;
#if 1
#define ReadFormat ImgFormat
#define ReadType GL_UNSIGNED_BYTE
#endif
#if 0
static GLenum ReadFormat = GL_RGBA;
static GLenum ReadType = GL_UNSIGNED_BYTE;
#endif
#if 0
static GLenum ReadFormat = GL_RGB;
static GLenum ReadType = GL_UNSIGNED_SHORT_5_6_5;
#endif
static void
Reset( void )
{
APosX = 5; APosY = 20;
BPosX = APosX + ImgWidth + 5; BPosY = 20;
CPosX = BPosX + ImgWidth + 5; CPosY = 20;
}
static void
PrintString(const char *s)
{
while (*s) {
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
s++;
}
}
static void
SetupPixelTransfer(GLboolean invert)
{
if (invert) {
glPixelTransferf(GL_RED_SCALE, -1.0);
glPixelTransferf(GL_RED_BIAS, 1.0);
glPixelTransferf(GL_GREEN_SCALE, -1.0);
glPixelTransferf(GL_GREEN_BIAS, 1.0);
glPixelTransferf(GL_BLUE_SCALE, -1.0);
glPixelTransferf(GL_BLUE_BIAS, 1.0);
}
else {
glPixelTransferf(GL_RED_SCALE, 1.0);
glPixelTransferf(GL_RED_BIAS, 0.0);
glPixelTransferf(GL_GREEN_SCALE, 1.0);
glPixelTransferf(GL_GREEN_BIAS, 0.0);
glPixelTransferf(GL_BLUE_SCALE, 1.0);
glPixelTransferf(GL_BLUE_BIAS, 0.0);
}
}
static void
Display( void )
{
glClear( GL_COLOR_BUFFER_BIT );
glRasterPos2i(5, ImgHeight+25);
PrintString("f = toggle front/back s = toggle scale/bias b = benchmark");
/* draw original image */
glRasterPos2i(APosX, 5);
PrintString("Original");
glRasterPos2i(APosX, APosY);
glEnable(GL_DITHER);
SetupPixelTransfer(GL_FALSE);
glDrawPixels(ImgWidth, ImgHeight, ImgFormat, GL_UNSIGNED_BYTE, Image);
/* do readpixels, drawpixels */
glRasterPos2i(BPosX, 5);
PrintString("Read/DrawPixels");
SetupPixelTransfer(ScaleAndBias);
if (Benchmark) {
GLint reads = 0;
GLint endTime;
GLint startTime = glutGet(GLUT_ELAPSED_TIME);
GLdouble seconds, pixelsPerSecond;
printf("Benchmarking...\n");
do {
glReadPixels(APosX, APosY, ImgWidth, ImgHeight,
ReadFormat, ReadType, TempImage);
reads++;
endTime = glutGet(GLUT_ELAPSED_TIME);
} while (endTime - startTime < 4000); /* 4 seconds */
seconds = (double) (endTime - startTime) / 1000.0;
pixelsPerSecond = reads * ImgWidth * ImgHeight / seconds;
printf("Result: %d reads in %f seconds = %f pixels/sec\n",
reads, seconds, pixelsPerSecond);
Benchmark = GL_FALSE;
}
else {
glReadPixels(APosX, APosY, ImgWidth, ImgHeight,
ReadFormat, ReadType, TempImage);
}
glRasterPos2i(BPosX, BPosY);
glDisable(GL_DITHER);
SetupPixelTransfer(GL_FALSE);
glDrawPixels(ImgWidth, ImgHeight, ReadFormat, ReadType, TempImage);
/* do copypixels */
glRasterPos2i(CPosX, 5);
PrintString("CopyPixels");
glRasterPos2i(CPosX, CPosY);
glDisable(GL_DITHER);
SetupPixelTransfer(ScaleAndBias);
glCopyPixels(APosX, APosY, ImgWidth, ImgHeight, GL_COLOR);
if (!DrawFront)
glutSwapBuffers();
}
static void
Reshape( int width, int height )
{
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( 0.0, width, 0.0, height, -1.0, 1.0 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}
static void
Key( unsigned char key, int x, int y )
{
(void) x;
(void) y;
switch (key) {
case 'b':
Benchmark = GL_TRUE;
break;
case 's':
ScaleAndBias = !ScaleAndBias;
break;
case 'f':
DrawFront = !DrawFront;
if (DrawFront) {
glDrawBuffer(GL_FRONT);
glReadBuffer(GL_FRONT);
}
else {
glDrawBuffer(GL_BACK);
glReadBuffer(GL_BACK);
}
printf("glDrawBuffer(%s)\n", DrawFront ? "GL_FRONT" : "GL_BACK");
break;
case 27:
exit(0);
break;
}
glutPostRedisplay();
}
static void
Init( GLboolean ciMode )
{
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
Image = LoadRGBImage( IMAGE_FILE, &ImgWidth, &ImgHeight, &ImgFormat );
if (!Image) {
printf("Couldn't read %s\n", IMAGE_FILE);
exit(0);
}
if (ciMode) {
/* Convert RGB image to grayscale */
GLubyte *indexImage = malloc( ImgWidth * ImgHeight );
GLint i;
for (i=0; i<ImgWidth*ImgHeight; i++) {
int gray = Image[i*3] + Image[i*3+1] + Image[i*3+2];
indexImage[i] = gray / 3;
}
free(Image);
Image = indexImage;
ImgFormat = GL_COLOR_INDEX;
for (i=0;i<255;i++) {
float g = i / 255.0;
glutSetColor(i, g, g, g);
}
}
printf("Loaded %d by %d image\n", ImgWidth, ImgHeight );
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ROW_LENGTH, ImgWidth);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ROW_LENGTH, ImgWidth);
Reset();
TempImage = (GLubyte *) malloc(ImgWidth * ImgHeight * 4 * sizeof(GLubyte));
assert(TempImage);
}
int
main( int argc, char *argv[] )
{
GLboolean ciMode = GL_FALSE;
if (argc > 1 && strcmp(argv[1], "-ci")==0) {
ciMode = GL_TRUE;
}
glutInit( &argc, argv );
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( 750, 250 );
if (ciMode)
glutInitDisplayMode( GLUT_INDEX | GLUT_DOUBLE );
else
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
glutCreateWindow(argv[0]);
Init(ciMode);
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );
glutDisplayFunc( Display );
glutMainLoop();
return 0;
}

View File

@@ -1,4 +1,4 @@
/* $Id: reflect.c,v 1.3 2000/06/15 14:25:48 brianp Exp $ */
/* $Id: reflect.c,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
/*
* Demo of a reflective, texture-mapped surface with OpenGL.
@@ -20,40 +20,70 @@
*/
/*
* Authors:
* Brian Paul
* Dirk Reiners (reiners@igd.fhg.de) made some modifications to this code.
* Mark Kilgard (April 1997)
* Brian Paul (April 2000 - added keyboard d/s options)
* Dirk Reiners (reiners@igd.fhg.de) made some modifications to this code.
*
* August 1996 - A few optimizations by Brian
*/
/*
* April, 1997 - Added Mark Kilgard's changes.
*/
/*
* $Log: reflect.c,v $
* Revision 1.1 1999/08/19 00:55:40 jtg
* Initial revision
*
* Revision 3.4 1999/03/28 18:22:05 brianp
* minor clean-up
*
* Revision 3.3 1998/11/22 02:54:29 brianp
* only draw one stack for gluCylinders
*
* Revision 3.2 1998/11/19 02:53:48 brianp
* changed texture image and background color
*
* Revision 3.1 1998/11/05 04:34:04 brianp
* moved image files to ../images/ directory
*
* Revision 3.0 1998/02/14 18:42:29 brianp
* initial rev
*
*/
#define USE_ZBUFFER
/* OK, without hardware support this is overkill. */
#define USE_TEXTURE
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "GL/glut.h"
#include "../util/showbuffer.c"
#include "../util/readtex.c"
#include "../util/readtex.c" /* a hack, I know */
#define DEG2RAD (3.14159/180.0)
#define TABLE_TEXTURE "../images/tile.rgb"
static GLint ImgWidth, ImgHeight;
static int ImgWidth, ImgHeight;
static GLenum ImgFormat;
static GLubyte *Image = NULL;
#define MAX_OBJECTS 2
static GLint table_list;
static GLint objects_list[MAX_OBJECTS];
static GLfloat xrot, yrot;
static GLfloat spin;
static GLint Width = 400, Height = 300;
static GLenum ShowBuffer = GL_NONE;
static void make_table( void )
@@ -116,11 +146,16 @@ static void make_objects( void )
}
static GLfloat light_pos[] = { 0.0, 20.0, 0.0, 1.0 };
static void init( void )
{
make_table();
make_objects();
/* Setup texture */
#ifdef USE_TEXTURE
Image = LoadRGBImage( TABLE_TEXTURE, &ImgWidth, &ImgHeight, &ImgFormat );
if (!Image) {
printf("Couldn't read %s\n", TABLE_TEXTURE);
@@ -134,11 +169,17 @@ static void init( void )
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
#endif
xrot = 30.0;
yrot = 50.0;
spin = 0.0;
#ifndef USE_ZBUFFER
glEnable( GL_CULL_FACE );
#endif
glShadeModel( GL_FLAT );
glEnable( GL_LIGHT0 );
@@ -153,14 +194,12 @@ static void init( void )
static void reshape(int w, int h)
{
GLfloat yAspect = 2.5;
GLfloat xAspect = yAspect * (float) w / (float) h;
Width = w;
Height = h;
GLfloat aspect = (float) w / (float) h;
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum( -xAspect, xAspect, -yAspect, yAspect, 10.0, 30.0 );
glFrustum( -aspect, aspect, -1.0, 1.0, 4.0, 300.0 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
@@ -173,7 +212,8 @@ static void draw_objects( GLfloat eyex, GLfloat eyey, GLfloat eyez )
(void) eyey;
(void) eyez;
#ifndef USE_ZBUFFER
if (eyex<0.5) {
if (eyex<0.5)
{
#endif
glPushMatrix();
glTranslatef( 1.0, 1.5, 0.0 );
@@ -190,8 +230,9 @@ static void draw_objects( GLfloat eyex, GLfloat eyey, GLfloat eyez )
glCallList( objects_list[1] );
glPopMatrix();
#ifndef USE_ZBUFFER
}
else {
}
else
{
glPushMatrix();
glTranslatef( -1.0, 0.85+3.0*fabs( cos(0.01*spin) ), 0.0 );
glRotatef( 0.5*spin, 0.0, 0.5, 1.0 );
@@ -206,7 +247,7 @@ static void draw_objects( GLfloat eyex, GLfloat eyey, GLfloat eyez )
glRotatef( 0.5*spin, 0.0, 0.5, 1.0 );
glCallList( objects_list[0] );
glPopMatrix();
}
}
#endif
}
@@ -221,7 +262,6 @@ static void draw_table( void )
static void draw_scene( void )
{
static GLfloat light_pos[] = { 0.0, 20.0, 0.0, 1.0 };
GLfloat dist = 20.0;
GLfloat eyex, eyey, eyez;
@@ -239,15 +279,20 @@ static void draw_scene( void )
glLightfv( GL_LIGHT0, GL_POSITION, light_pos );
/* draw table into stencil planes */
glDisable( GL_DEPTH_TEST );
glEnable( GL_STENCIL_TEST );
#ifdef USE_ZBUFFER
glDisable( GL_DEPTH_TEST );
#endif
glStencilFunc( GL_ALWAYS, 1, 0xffffffff );
glStencilOp( GL_REPLACE, GL_REPLACE, GL_REPLACE );
glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
draw_table();
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
#ifdef USE_ZBUFFER
glEnable( GL_DEPTH_TEST );
#endif
/* render view from below (reflected viewport) */
/* only draw where stencil==1 */
@@ -273,7 +318,9 @@ static void draw_scene( void )
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
#ifdef USE_TEXTURE
glEnable( GL_TEXTURE_2D );
#endif
draw_table();
glDisable( GL_TEXTURE_2D );
glDisable( GL_BLEND );
@@ -287,34 +334,43 @@ static void draw_scene( void )
glPopMatrix();
if (ShowBuffer == GL_DEPTH) {
ShowDepthBuffer(Width, Height, 1.0, 0.0);
}
else if (ShowBuffer == GL_STENCIL) {
ShowStencilBuffer(Width, Height, 255.0, 0.0);
}
glutSwapBuffers();
}
#if 0
void draw_scene(void)
{
GLfloat dist = 20.0;
GLfloat eyex, eyey, eyez;
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
eyex = dist * cos(yrot*DEG2RAD) * cos(xrot*DEG2RAD);
eyez = dist * sin(yrot*DEG2RAD) * cos(xrot*DEG2RAD);
eyey = dist * sin(xrot*DEG2RAD);
/* view from top */
glPushMatrix();
gluLookAt( eyex, eyey, eyez, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 );
draw_table();
glPopMatrix();
glutSwapBuffers();
}
#endif
static void Key( unsigned char key, int x, int y )
{
(void) x;
(void) y;
if (key == 'd') {
ShowBuffer = GL_DEPTH;
}
else if (key == 's') {
ShowBuffer = GL_STENCIL;
}
else if (key==27) {
if (key==27)
exit(0);
}
else {
ShowBuffer = GL_NONE;
}
glutPostRedisplay();
}
@@ -325,13 +381,15 @@ static void SpecialKey( int key, int x, int y )
switch (key) {
case GLUT_KEY_UP:
xrot += 3.0;
if ( xrot > 85 )
xrot = 85;
#ifndef USE_ZBUFFER
if ( xrot > 180 ) xrot = 180;
#endif
break;
case GLUT_KEY_DOWN:
xrot -= 3.0;
if ( xrot < 5 )
xrot = 5;
#ifndef USE_ZBUFFER
if ( xrot < 0 ) xrot = 0;
#endif
break;
case GLUT_KEY_LEFT:
yrot += 3.0;
@@ -356,17 +414,22 @@ static void idle( void )
int main( int argc, char *argv[] )
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB
#ifdef USE_ZBUFFER
| GLUT_DEPTH
#endif
| GLUT_STENCIL);
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( Width, Height );
glutInitWindowSize(400, 300 );
glutCreateWindow(argv[0]);
glutReshapeFunc(reshape);
glutDisplayFunc(draw_scene);
glutKeyboardFunc(Key);
glutSpecialFunc(SpecialKey);
glutIdleFunc(idle);
init();
glutMainLoop();
return 0;
}

View File

@@ -1,119 +0,0 @@
/**
(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.
*/
/* Taken from the projshadow.c - by Tom McReynolds, SGI */
/* Modified by David Bucciarelli */
/* Rendering shadows using projective shadows. */
#include <GL/glut.h>
#include "shadow.h"
enum {
X, Y, Z, W
};
enum {
A, B, C, D
};
/* create a matrix that will project the desired shadow */
void
shadowmatrix(GLfloat shadowMat[4][4],
GLfloat groundplane[4],
GLfloat lightpos[4])
{
GLfloat dot;
/* find dot product between light position vector and ground plane normal */
dot = groundplane[X] * lightpos[X] +
groundplane[Y] * lightpos[Y] +
groundplane[Z] * lightpos[Z] +
groundplane[W] * lightpos[W];
shadowMat[0][0] = dot - lightpos[X] * groundplane[X];
shadowMat[1][0] = 0.f - lightpos[X] * groundplane[Y];
shadowMat[2][0] = 0.f - lightpos[X] * groundplane[Z];
shadowMat[3][0] = 0.f - lightpos[X] * groundplane[W];
shadowMat[X][1] = 0.f - lightpos[Y] * groundplane[X];
shadowMat[1][1] = dot - lightpos[Y] * groundplane[Y];
shadowMat[2][1] = 0.f - lightpos[Y] * groundplane[Z];
shadowMat[3][1] = 0.f - lightpos[Y] * groundplane[W];
shadowMat[X][2] = 0.f - lightpos[Z] * groundplane[X];
shadowMat[1][2] = 0.f - lightpos[Z] * groundplane[Y];
shadowMat[2][2] = dot - lightpos[Z] * groundplane[Z];
shadowMat[3][2] = 0.f - lightpos[Z] * groundplane[W];
shadowMat[X][3] = 0.f - lightpos[W] * groundplane[X];
shadowMat[1][3] = 0.f - lightpos[W] * groundplane[Y];
shadowMat[2][3] = 0.f - lightpos[W] * groundplane[Z];
shadowMat[3][3] = dot - lightpos[W] * groundplane[W];
}
/* find the plane equation given 3 points */
void
findplane(GLfloat plane[4],
GLfloat v0[3], GLfloat v1[3], GLfloat v2[3])
{
GLfloat vec0[3], vec1[3];
/* need 2 vectors to find cross product */
vec0[X] = v1[X] - v0[X];
vec0[Y] = v1[Y] - v0[Y];
vec0[Z] = v1[Z] - v0[Z];
vec1[X] = v2[X] - v0[X];
vec1[Y] = v2[Y] - v0[Y];
vec1[Z] = v2[Z] - v0[Z];
/* find cross product to get A, B, and C of plane equation */
plane[A] = vec0[Y] * vec1[Z] - vec0[Z] * vec1[Y];
plane[B] = -(vec0[X] * vec1[Z] - vec0[Z] * vec1[X]);
plane[C] = vec0[X] * vec1[Y] - vec0[Y] * vec1[X];
plane[D] = -(plane[A] * v0[X] + plane[B] * v0[Y] + plane[C] * v0[Z]);
}

View File

@@ -1,18 +0,0 @@
#ifndef SHADOW_H
#define SHADOW_H
extern void
shadowmatrix(GLfloat shadowMat[4][4],
GLfloat groundplane[4],
GLfloat lightpos[4]);
extern void
findplane(GLfloat plane[4],
GLfloat v0[3], GLfloat v1[3], GLfloat v2[3]);
#endif

View File

@@ -1,4 +1,4 @@
/* $Id: stex3d.c,v 1.5 2000/06/27 17:04:43 brianp Exp $ */
/* $Id: stex3d.c,v 1.2 1999/09/17 12:27:01 brianp Exp $ */
/*-----------------------------
* stex3d.c GL example of the mesa 3d-texture extention to simulate procedural
@@ -17,15 +17,6 @@
/*
* $Log: stex3d.c,v $
* Revision 1.5 2000/06/27 17:04:43 brianp
* fixed compiler warnings
*
* Revision 1.4 2000/03/22 19:48:57 brianp
* converted from GL_EXT_texture3D to GL 1.2
*
* Revision 1.3 1999/12/16 08:54:22 brianp
* added a cast to malloc call
*
* Revision 1.2 1999/09/17 12:27:01 brianp
* silenced some warnings
*
@@ -62,6 +53,7 @@ void init(void),
initNoise(void);
float turbulence(float point[3], float lofreq, float hifreq);
int isExtSupported(char *ext);
void KeyHandler( unsigned char key, int x, int y );
GLenum parseCmdLine(int argc, char **argv);
float noise3(float vec[3]);
@@ -129,20 +121,17 @@ void init()
/* start the noise function variables */
initNoise();
/* see if we have OpenGL 1.2 or later, for 3D texturing */
{
const char *version = (const char *) glGetString(GL_VERSION);
if (strncmp(version, "1.0", 3) == 0 ||
strncmp(version, "1.1", 3) == 0) {
printf("Sorry, OpenGL 1.2 or later is required\n");
exit(1);
}
/* see if the texture 3d extention is supported */
if (!isExtSupported("GL_EXT_texture3D")) {
printf("Sorry this GL implementation (%s) does not support 3d texture extentions\n",
(char *)(glGetString(GL_RENDERER)));
/* tkQuit();*/
}
/* if texture is supported then generate the texture */
create3Dtexture();
glEnable(GL_TEXTURE_3D);
glEnable(GL_TEXTURE_3D_EXT);
/*
glBlendFunc(GL_SRC_COLOR, GL_SRC_ALPHA);
glEnable(GL_BLEND);
@@ -241,7 +230,7 @@ void create3Dtexture()
int tmp;
printf("creating 3d textures...\n");
voxels = (unsigned char *) malloc((size_t)(4*tex_width*tex_height*tex_depth));
voxels = (unsigned char *) malloc((4*tex_width*tex_height*tex_depth));
vp=voxels;
for (i=0;i<tex_width;i++){
vec[0]=i;
@@ -260,20 +249,39 @@ void create3Dtexture()
printf("setting up 3d texture...\n");
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_WRAP_R_EXT, GL_REPEAT);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA,
tex_width, tex_height, tex_depth,
0, GL_RGBA, GL_UNSIGNED_BYTE, voxels);
glTexImage3DEXT(GL_TEXTURE_3D_EXT, 0, GL_RGBA,
tex_width, tex_height, tex_depth,
0, GL_RGBA, GL_UNSIGNED_BYTE, voxels);
printf("finished setting up 3d texture image...\n");
}
int isExtSupported(char *ext)
{
/* routine to find whether a specified OpenGL extension is supported */
char *c;
int len;
char *allext = (char *)(glGetString(GL_EXTENSIONS));
len = strlen(ext);
if (len <= 0) return 0;
c = allext;
while (c) {
if (!strncmp(c,ext,len)) return 1;
c = strchr(c+1,'G');
}
return 0;
}
void printHelp()
{
printf("\nUsage: stex3d <cmd line options>\n");
@@ -388,7 +396,7 @@ void resize(int w, int h)
glTranslatef(0,0,-5);
}
static void cleanEverything(void)
void cleanEverything(void)
{
/* free(voxels); */
}
@@ -424,10 +432,10 @@ void KeyHandler( unsigned char key, int x, int y )
angz-=10;
break;
case 't':
glEnable(GL_TEXTURE_3D);
glEnable(GL_TEXTURE_3D_EXT);
break;
case 'T':
glDisable(GL_TEXTURE_3D);
glDisable(GL_TEXTURE_3D_EXT);
break;
case 's':
glShadeModel(GL_SMOOTH);

View File

@@ -1,573 +0,0 @@
/*
* This program is under the GNU GPL.
* Use at your own risk.
*
* written by David Bucciarelli (tech.hmw@plus.it)
* Humanware s.r.l.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#ifdef WIN32
#include <windows.h>
#endif
#include <GL/glut.h>
#include "../util/readtex.c"
#include "shadow.c"
#ifdef XMESA
#include "GL/xmesa.h"
static int fullscreen=1;
#endif
static int WIDTH=640;
static int HEIGHT=480;
#define FRAME 50
#define BASESIZE 10.0
#define BASERES 12
#define TEAPOTRES 3
#ifndef M_PI
#define M_PI 3.1415926535
#endif
extern void shadowmatrix(GLfloat [4][4], GLfloat [4], GLfloat [4]);
extern void findplane(GLfloat [4], GLfloat [3], GLfloat [3], GLfloat [3]);
static int win=0;
static float obs[3]={5.0,0.0,1.0};
static float dir[3];
static float v=0.0;
static float alpha=-90.0;
static float beta=90.0;
static GLfloat baseshadow[4][4];
static GLfloat lightpos[4]={2.3,0.0,3.0,1.0};
static GLfloat lightdir[3]={-2.3,0.0,-3.0};
static GLfloat lightalpha=0.0;
static int fog=1;
static int bfcull=1;
static int usetex=1;
static int help=1;
static int joyavailable=0;
static int joyactive=0;
static GLuint t1id,t2id;
static GLuint teapotdlist,basedlist,lightdlist;
static float gettime(void)
{
static clock_t told=0;
clock_t tnew,ris;
tnew=clock();
ris=tnew-told;
told=tnew;
return(ris/(float)CLOCKS_PER_SEC);
}
static void calcposobs(void)
{
dir[0]=sin(alpha*M_PI/180.0);
dir[1]=cos(alpha*M_PI/180.0)*sin(beta*M_PI/180.0);
dir[2]=cos(beta*M_PI/180.0);
obs[0]+=v*dir[0];
obs[1]+=v*dir[1];
obs[2]+=v*dir[2];
}
static void special(int k, int x, int y)
{
switch(k) {
case GLUT_KEY_LEFT:
alpha-=2.0;
break;
case GLUT_KEY_RIGHT:
alpha+=2.0;
break;
case GLUT_KEY_DOWN:
beta-=2.0;
break;
case GLUT_KEY_UP:
beta+=2.0;
break;
}
}
static void key(unsigned char k, int x, int y)
{
switch(k) {
case 27:
exit(0);
break;
case 'a':
v+=0.005;
break;
case 'z':
v-=0.005;
break;
case 'j':
joyactive=(!joyactive);
break;
case 'h':
help=(!help);
break;
case 'f':
fog=(!fog);
break;
case 't':
usetex=(!usetex);
break;
case 'b':
if(bfcull) {
glDisable(GL_CULL_FACE);
bfcull=0;
} else {
glEnable(GL_CULL_FACE);
bfcull=1;
}
break;
#ifdef XMESA
case ' ':
XMesaSetFXmode(fullscreen ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW);
fullscreen=(!fullscreen);
break;
#endif
}
}
static void reshape(int w, int h)
{
WIDTH=w;
HEIGHT=h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0,w/(float)h,0.2,40.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0,0,w,h);
}
static void printstring(void *font, char *string)
{
int len,i;
len=(int)strlen(string);
for(i=0;i<len;i++)
glutBitmapCharacter(font,string[i]);
}
static void printhelp(void)
{
glEnable(GL_BLEND);
glColor4f(0.5,0.5,0.5,0.5);
glRecti(40,40,600,440);
glDisable(GL_BLEND);
glColor3f(1.0,0.0,0.0);
glRasterPos2i(300,420);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"Help");
glRasterPos2i(60,390);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"h - Togle Help");
glRasterPos2i(60,360);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"t - Togle Textures");
glRasterPos2i(60,330);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"f - Togle Fog");
glRasterPos2i(60,300);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"b - Togle Back face culling");
glRasterPos2i(60,270);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"Arrow Keys - Rotate");
glRasterPos2i(60,240);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"a - Increase velocity");
glRasterPos2i(60,210);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"z - Decrease velocity");
glRasterPos2i(60,180);
if(joyavailable)
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"j - Togle jostick control (Joystick control available)");
else
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"(No Joystick control available)");
}
static void drawbase(void)
{
int i,j;
float x,y,dx,dy;
glBindTexture(GL_TEXTURE_2D,t1id);
dx=BASESIZE/BASERES;
dy=-BASESIZE/BASERES;
for(y=BASESIZE/2.0,j=0;j<BASERES;y+=dy,j++) {
glBegin(GL_QUAD_STRIP);
glColor3f(1.0,1.0,1.0);
glNormal3f(0.0,0.0,1.0);
for(x=-BASESIZE/2.0,i=0;i<BASERES;x+=dx,i++) {
glTexCoord2f(x,y);
glVertex3f(x,y,0.0);
glTexCoord2f(x,y+dy);
glVertex3f(x,y+dy,0.0);
}
glEnd();
}
}
static void drawteapot(void)
{
static float xrot=0.0;
static float zrot=0.0;
glPushMatrix();
glRotatef(lightalpha,0.0,0.0,1.0);
glMultMatrixf((GLfloat *)baseshadow);
glRotatef(-lightalpha,0.0,0.0,1.0);
glTranslatef(0.0,0.0,1.0);
glRotatef(xrot,1.0,0.0,0.0);
glRotatef(zrot,0.0,0.0,1.0);
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glColor3f(0.0,0.0,0.0);
glCallList(teapotdlist);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
if(usetex)
glEnable(GL_TEXTURE_2D);
glPopMatrix();
glPushMatrix();
glTranslatef(0.0,0.0,1.0);
glRotatef(xrot,1.0,0.0,0.0);
glRotatef(zrot,0.0,0.0,1.0);
glCallList(teapotdlist);
glPopMatrix();
xrot+=2.0;
zrot+=1.0;
}
static void drawlight1(void)
{
glPushMatrix();
glRotatef(lightalpha,0.0,0.0,1.0);
glLightfv(GL_LIGHT0,GL_POSITION,lightpos);
glLightfv(GL_LIGHT0,GL_SPOT_DIRECTION,lightdir);
glPopMatrix();
}
static void drawlight2(void)
{
glPushMatrix();
glRotatef(lightalpha,0.0,0.0,1.0);
glTranslatef(lightpos[0],lightpos[1],lightpos[2]);
glDisable(GL_TEXTURE_2D);
glCallList(lightdlist);
if(usetex)
glEnable(GL_TEXTURE_2D);
glPopMatrix();
lightalpha+=1.0;
}
static void dojoy(void)
{
#ifdef WIN32
static UINT max[2]={0,0};
static UINT min[2]={0xffffffff,0xffffffff},center[2];
MMRESULT res;
JOYINFO joy;
res=joyGetPos(JOYSTICKID1,&joy);
if(res==JOYERR_NOERROR) {
joyavailable=1;
if(max[0]<joy.wXpos)
max[0]=joy.wXpos;
if(min[0]>joy.wXpos)
min[0]=joy.wXpos;
center[0]=(max[0]+min[0])/2;
if(max[1]<joy.wYpos)
max[1]=joy.wYpos;
if(min[1]>joy.wYpos)
min[1]=joy.wYpos;
center[1]=(max[1]+min[1])/2;
if(joyactive) {
if(fabs(center[0]-(float)joy.wXpos)>0.1*(max[0]-min[0]))
alpha-=2.5*(center[0]-(float)joy.wXpos)/(max[0]-min[0]);
if(fabs(center[1]-(float)joy.wYpos)>0.1*(max[1]-min[1]))
beta+=2.5*(center[1]-(float)joy.wYpos)/(max[1]-min[1]);
if(joy.wButtons & JOY_BUTTON1)
v+=0.005;
if(joy.wButtons & JOY_BUTTON2)
v-=0.005;
}
} else
joyavailable=0;
#endif
}
static void draw(void)
{
static int count=0;
static char frbuf[80];
float fr;
dojoy();
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
if(usetex)
glEnable(GL_TEXTURE_2D);
else
glDisable(GL_TEXTURE_2D);
if(fog)
glEnable(GL_FOG);
else
glDisable(GL_FOG);
glEnable(GL_LIGHTING);
glShadeModel(GL_SMOOTH);
glPushMatrix();
calcposobs();
gluLookAt(obs[0],obs[1],obs[2],
obs[0]+dir[0],obs[1]+dir[1],obs[2]+dir[2],
0.0,0.0,1.0);
drawlight1();
glCallList(basedlist);
drawteapot();
drawlight2();
glPopMatrix();
if((count % FRAME)==0) {
fr=gettime();
sprintf(frbuf,"Frame rate: %f",FRAME/fr);
}
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glDisable(GL_FOG);
glShadeModel(GL_FLAT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-0.5,639.5,-0.5,479.5,-1.0,1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(1.0,0.0,0.0);
glRasterPos2i(10,10);
printstring(GLUT_BITMAP_HELVETICA_18,frbuf);
glRasterPos2i(350,470);
printstring(GLUT_BITMAP_HELVETICA_10,"Teapot V1.2 Written by David Bucciarelli (tech.hmw@plus.it)");
if(help)
printhelp();
reshape(WIDTH,HEIGHT);
glutSwapBuffers();
count++;
}
static void inittextures(void)
{
glGenTextures(1,&t1id);
glBindTexture(GL_TEXTURE_2D,t1id);
glPixelStorei(GL_UNPACK_ALIGNMENT,4);
if (!LoadRGBMipmaps("../images/tile.rgb", GL_RGB)) {
fprintf(stderr,"Error reading a texture.\n");
exit(-1);
}
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
glGenTextures(1,&t2id);
glBindTexture(GL_TEXTURE_2D,t2id);
if (!LoadRGBMipmaps("../images/bw.rgb", GL_RGB)) {
fprintf(stderr,"Error reading a texture.\n");
exit(-1);
}
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
}
static void initlight(void)
{
float lamb[4]={0.2,0.2,0.2,1.0};
float lspec[4]={1.0,1.0,1.0,1.0};
glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,70.0);
glLightf(GL_LIGHT0,GL_SPOT_EXPONENT,20.0);
glLightfv(GL_LIGHT0,GL_AMBIENT,lamb);
glLightfv(GL_LIGHT0,GL_SPECULAR,lspec);
glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,20.0);
glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,lspec);
glEnable(GL_LIGHT0);
}
static void initdlists(void)
{
GLUquadricObj *lcone,*lbase;
GLfloat plane[4];
GLfloat v0[3]={0.0,0.0,0.0};
GLfloat v1[3]={1.0,0.0,0.0};
GLfloat v2[3]={0.0,1.0,0.0};
findplane(plane,v0,v1,v2);
shadowmatrix(baseshadow,plane,lightpos);
teapotdlist=glGenLists(1);
glNewList(teapotdlist,GL_COMPILE);
glRotatef(90.0,1.0,0.0,0.0);
glCullFace(GL_FRONT);
glBindTexture(GL_TEXTURE_2D,t2id);
glutSolidTeapot(0.75);
glCullFace(GL_BACK);
glEndList();
basedlist=glGenLists(1);
glNewList(basedlist,GL_COMPILE);
drawbase();
glEndList();
lightdlist=glGenLists(1);
glNewList(lightdlist,GL_COMPILE);
glDisable(GL_LIGHTING);
lcone=gluNewQuadric();
lbase=gluNewQuadric();
glRotatef(45.0,0.0,1.0,0.0);
glColor3f(1.0,1.0,1.0);
glCullFace(GL_FRONT);
gluDisk(lbase,0.0,0.2,12.0,1.0);
glCullFace(GL_BACK);
glColor3f(0.5,0.0,0.0);
gluCylinder(lcone,0.2,0.0,0.5,12,1);
gluDeleteQuadric(lcone);
gluDeleteQuadric(lbase);
glEnable(GL_LIGHTING);
glEndList();
}
int main(int ac, char **av)
{
float fogcolor[4]={0.025,0.025,0.025,1.0};
fprintf(stderr,"Teapot V1.2\nWritten by David Bucciarelli (tech.hmw@plus.it)\n");
/*
if(!SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS)) {
fprintf(stderr,"Error setting the process class.\n");
return 0;
}
if(!SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL)) {
fprintf(stderr,"Error setting the process priority.\n");
return 0;
}
*/
glutInitWindowPosition(0,0);
glutInitWindowSize(WIDTH,HEIGHT);
glutInit(&ac,av);
glutInitDisplayMode(GLUT_RGB|GLUT_DEPTH|GLUT_DOUBLE);
if(!(win=glutCreateWindow("Teapot"))) {
fprintf(stderr,"Error, couldn't open window\n");
return -1;
}
reshape(WIDTH,HEIGHT);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glEnable(GL_FOG);
glFogi(GL_FOG_MODE,GL_EXP2);
glFogfv(GL_FOG_COLOR,fogcolor);
glFogf(GL_FOG_DENSITY,0.04);
glHint(GL_FOG_HINT,GL_NICEST);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
calcposobs();
inittextures();
initlight();
initdlists();
glClearColor(fogcolor[0],fogcolor[1],fogcolor[2],fogcolor[3]);
glutReshapeFunc(reshape);
glutDisplayFunc(draw);
glutKeyboardFunc(key);
glutSpecialFunc(special);
glutIdleFunc(draw);
glutMainLoop();
return 0;
}

View File

@@ -1,653 +0,0 @@
/*
* This program is under the GNU GPL.
* Use at your own risk.
*
* written by David Bucciarelli (tech.hmw@plus.it)
* Humanware s.r.l.
*
* based on a Mikael SkiZoWalker's (MoDEL) / France (Skizo@Hol.Fr) demo
*/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#ifdef WIN32
#include <windows.h>
#endif
#include <GL/glut.h>
#ifdef XMESA
#include "GL/xmesa.h"
static int fullscreen = 1;
#endif
#ifndef M_PI
#define M_PI 3.14159265
#endif
#define heightMnt 450
#define lenghtXmnt 62
#define lenghtYmnt 62
#define stepXmnt 96.0
#define stepYmnt 96.0
#define WIDTH 640
#define HEIGHT 480
#define TSCALE 4
#define FRAME 50
#define FOV 85
static GLfloat terrain[256 * 256];
static GLfloat terraincolor[256 * 256][3];
static int win = 0;
static int fog = 1;
static int bfcull = 1;
static int usetex = 1;
static int poutline = 0;
static int help = 1;
static int joyavailable = 0;
static int joyactive = 0;
static float ModZMnt;
static long GlobalMnt = 0;
static int scrwidth = WIDTH;
static int scrheight = HEIGHT;
#define OBSSTARTX 992.0
#define OBSSTARTY 103.0
static float obs[3] = { OBSSTARTX, heightMnt * 1.3, OBSSTARTY };
static float dir[3], v1[2], v2[2];
static float v = 15.0;
static float alpha = 75.0;
static float beta = 90.0;
static float
gettime(void)
{
static clock_t told = 0;
clock_t tnew, ris;
tnew = clock();
ris = tnew - told;
told = tnew;
return (ris / (float) CLOCKS_PER_SEC);
}
static void
calcposobs(void)
{
float alpha1, alpha2;
dir[0] = sin(alpha * M_PI / 180.0);
dir[2] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
dir[1] = cos(beta * M_PI / 180.0);
alpha1 = alpha + FOV / 2.0;
v1[0] = sin(alpha1 * M_PI / 180.0);
v1[1] = cos(alpha1 * M_PI / 180.0);
alpha2 = alpha - FOV / 2.0;
v2[0] = sin(alpha2 * M_PI / 180.0);
v2[1] = cos(alpha2 * M_PI / 180.0);
obs[0] += v * dir[0];
obs[1] += v * dir[1];
obs[2] += v * dir[2];
if (obs[1] < 0.0)
obs[1] = 0.0;
}
static void
reshape(int width, int height)
{
scrwidth = width;
scrheight = height;
glViewport(0, 0, (GLint) width, (GLint) height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(50.0, ((GLfloat) width / (GLfloat) height),
lenghtXmnt * stepYmnt * 0.01, lenghtXmnt * stepYmnt * 0.7);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
static int
clipstrip(float y, float *start, float *end)
{
float x1, x2, t1, t2, tmp;
if (v1[1] == 0.0) {
t1 = 0.0;
x1 = -HUGE_VAL;
}
else {
t1 = y / v1[1];
x1 = t1 * v1[0];
}
if (v2[1] == 0.0) {
t2 = 0.0;
x2 = HUGE_VAL;
}
else {
t2 = y / v2[1];
x2 = t2 * v2[0];
}
if (((x1 < -(lenghtXmnt * stepXmnt) / 2) && (t2 <= 0.0)) ||
((t1 <= 0.0) && (x2 > (lenghtXmnt * stepXmnt) / 2)) ||
((t1 < 0.0) && (t2 < 0.0)))
return 0;
if ((t1 == 0.0) && (t2 == 0.0)) {
if ((v1[0] < 0.0) && (v1[1] > 0.0) && (v2[0] < 0.0) && (v2[1] < 0.0)) {
*start = -(lenghtXmnt * stepXmnt) / 2;
*end = stepXmnt;
return 1;
}
else {
if ((v1[0] > 0.0) && (v1[1] < 0.0) && (v2[0] > 0.0) && (v2[1] > 0.0)) {
*start = -stepXmnt;
*end = (lenghtXmnt * stepXmnt) / 2;
return 1;
}
else
return 0;
}
}
else {
if (t2 < 0.0) {
if (x1 < 0.0)
x2 = -(lenghtXmnt * stepXmnt) / 2;
else
x2 = (lenghtXmnt * stepXmnt) / 2;
}
if (t1 < 0.0) {
if (x2 < 0.0)
x1 = -(lenghtXmnt * stepXmnt) / 2;
else
x1 = (lenghtXmnt * stepXmnt) / 2;
}
}
if (x1 > x2) {
tmp = x1;
x1 = x2;
x2 = tmp;
}
x1 -= stepXmnt;
if (x1 < -(lenghtXmnt * stepXmnt) / 2)
x1 = -(lenghtXmnt * stepXmnt) / 2;
x2 += stepXmnt;
if (x2 > (lenghtXmnt * stepXmnt) / 2)
x2 = (lenghtXmnt * stepXmnt) / 2;
*start = ((int) (x1 / stepXmnt)) * stepXmnt;
*end = ((int) (x2 / stepXmnt)) * stepXmnt;
return 1;
}
static void
printstring(void *font, char *string)
{
int len, i;
len = (int) strlen(string);
for (i = 0; i < len; i++)
glutBitmapCharacter(font, string[i]);
}
static void
printhelp(void)
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0.0, 0.0, 0.0, 0.5);
glRecti(40, 40, 600, 440);
glDisable(GL_BLEND);
glColor3f(1.0, 0.0, 0.0);
glRasterPos2i(300, 420);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "Help");
glRasterPos2i(60, 390);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "h - Togle Help");
glRasterPos2i(60, 360);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "t - Togle Textures");
glRasterPos2i(60, 330);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "f - Togle Fog");
glRasterPos2i(60, 300);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "p - Wire frame");
glRasterPos2i(60, 270);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "b - Togle Back face culling");
glRasterPos2i(60, 240);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "Arrow Keys - Rotate");
glRasterPos2i(60, 210);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "a - Increase velocity");
glRasterPos2i(60, 180);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "z - Decrease velocity");
glRasterPos2i(60, 150);
if (joyavailable)
printstring(GLUT_BITMAP_TIMES_ROMAN_24,
"j - Togle jostick control (Joystick control available)");
else
printstring(GLUT_BITMAP_TIMES_ROMAN_24,
"(No Joystick control available)");
}
static void
drawterrain(void)
{
int h, i, idx, ox, oy;
float j, k, start, end;
ox = (int) (obs[0] / stepXmnt);
oy = (int) (obs[2] / stepYmnt);
GlobalMnt = ((ox * TSCALE) & 255) + ((oy * TSCALE) & 255) * 256;
glPushMatrix();
glTranslatef((float) ox * stepXmnt, 0, (float) oy * stepYmnt);
for (h = 0, k = -(lenghtYmnt * stepYmnt) / 2; h < lenghtYmnt;
k += stepYmnt, h++) {
if (!clipstrip(k, &start, &end))
continue;
glBegin(GL_TRIANGLE_STRIP); /* I hope that the optimizer will be able to improve this code */
for (i = (int) (lenghtXmnt / 2 + start / stepXmnt), j = start; j <= end;
j += stepXmnt, i++) {
idx = (i * TSCALE + h * 256 * TSCALE + GlobalMnt) & 65535;
glColor3fv(terraincolor[idx]);
glTexCoord2f((ox + i) / 8.0, (oy + h) / 8.0);
glVertex3f(j, terrain[idx], k);
idx =
(i * TSCALE + h * 256 * TSCALE + 256 * TSCALE +
GlobalMnt) & 65535;
glColor3fv(terraincolor[idx]);
glTexCoord2f((ox + i) / 8.0, (oy + h + 1) / 8.0);
glVertex3f(j, terrain[idx], k + stepYmnt);
}
glEnd();
}
glDisable(GL_CULL_FACE);
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBegin(GL_QUADS);
glColor4f(0.1, 0.7, 1.0, 0.4);
glVertex3f(-(lenghtXmnt * stepXmnt) / 2.0, heightMnt * 0.6,
-(lenghtYmnt * stepYmnt) / 2.0);
glVertex3f(-(lenghtXmnt * stepXmnt) / 2.0, heightMnt * 0.6,
(lenghtYmnt * stepYmnt) / 2.0);
glVertex3f((lenghtXmnt * stepXmnt) / 2.0, heightMnt * 0.6,
(lenghtYmnt * stepYmnt) / 2.0);
glVertex3f((lenghtXmnt * stepXmnt) / 2.0, heightMnt * 0.6,
-(lenghtYmnt * stepYmnt) / 2.0);
glEnd();
glDisable(GL_BLEND);
if (bfcull)
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glPopMatrix();
}
static void
dojoy(void)
{
#ifdef WIN32
static UINT max[2] = { 0, 0 };
static UINT min[2] = { 0xffffffff, 0xffffffff }, center[2];
MMRESULT res;
JOYINFO joy;
res = joyGetPos(JOYSTICKID1, &joy);
if (res == JOYERR_NOERROR) {
joyavailable = 1;
if (max[0] < joy.wXpos)
max[0] = joy.wXpos;
if (min[0] > joy.wXpos)
min[0] = joy.wXpos;
center[0] = (max[0] + min[0]) / 2;
if (max[1] < joy.wYpos)
max[1] = joy.wYpos;
if (min[1] > joy.wYpos)
min[1] = joy.wYpos;
center[1] = (max[1] + min[1]) / 2;
if (joyactive) {
if (fabs(center[0] - (float) joy.wXpos) > 0.1 * (max[0] - min[0]))
alpha +=
2.5 * (center[0] - (float) joy.wXpos) / (max[0] - min[0]);
if (fabs(center[1] - (float) joy.wYpos) > 0.1 * (max[1] - min[1]))
beta += 2.5 * (center[1] - (float) joy.wYpos) / (max[1] - min[1]);
if (joy.wButtons & JOY_BUTTON1)
v += 0.5;
if (joy.wButtons & JOY_BUTTON2)
v -= 0.5;
}
}
else
joyavailable = 0;
#endif
}
static void
drawscene(void)
{
static int count = 0;
static char frbuf[80];
float fr;
dojoy();
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
if (usetex)
glEnable(GL_TEXTURE_2D);
else
glDisable(GL_TEXTURE_2D);
if (fog)
glEnable(GL_FOG);
else
glDisable(GL_FOG);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
calcposobs();
gluLookAt(obs[0], obs[1], obs[2],
obs[0] + dir[0], obs[1] + dir[1], obs[2] + dir[2],
0.0, 1.0, 0.0);
drawterrain();
glPopMatrix();
if ((count % FRAME) == 0) {
fr = gettime();
sprintf(frbuf, "Frame rate: %.3f", FRAME / fr);
}
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glDisable(GL_FOG);
glShadeModel(GL_FLAT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-0.5, 639.5, -0.5, 479.5, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(1.0, 0.0, 0.0);
glRasterPos2i(10, 10);
printstring(GLUT_BITMAP_HELVETICA_18, frbuf);
glRasterPos2i(350, 470);
printstring(GLUT_BITMAP_HELVETICA_10,
"Terrain V1.2 Written by David Bucciarelli (tech.hmw@plus.it)");
glRasterPos2i(434, 457);
printstring(GLUT_BITMAP_HELVETICA_10,
"Based on a Mickael's demo (Skizo@Hol.Fr)");
if (help)
printhelp();
reshape(scrwidth, scrheight);
glutSwapBuffers();
count++;
}
static void
key(unsigned char k, int x, int y)
{
switch (k) {
case 27:
exit(0);
break;
case 'a':
v += 0.5;
break;
case 'z':
v -= 0.5;
break;
case 'p':
if (poutline) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
poutline = 0;
}
else {
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
poutline = 1;
}
break;
case 'j':
joyactive = (!joyactive);
break;
case 'h':
help = (!help);
break;
case 'f':
fog = (!fog);
break;
case 't':
usetex = (!usetex);
break;
case 'b':
if (bfcull) {
glDisable(GL_CULL_FACE);
bfcull = 0;
}
else {
glEnable(GL_CULL_FACE);
bfcull = 1;
}
break;
#ifdef XMESA
case ' ':
XMesaSetFXmode(fullscreen ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW);
fullscreen = (!fullscreen);
break;
#endif
}
}
static void
special(int k, int x, int y)
{
switch (k) {
case GLUT_KEY_LEFT:
alpha += 2.0;
break;
case GLUT_KEY_RIGHT:
alpha -= 2.0;
break;
case GLUT_KEY_DOWN:
beta -= 2.0;
break;
case GLUT_KEY_UP:
beta += 2.0;
break;
}
}
static void
calccolor(GLfloat height, GLfloat c[3])
{
GLfloat color[4][3] = {
{1.0, 1.0, 1.0},
{0.0, 0.8, 0.0},
{1.0, 1.0, 0.3},
{0.0, 0.0, 0.8}
};
GLfloat fact;
height = height * (1.0 / 255.0);
if (height >= 0.9) {
c[0] = color[0][0];
c[1] = color[0][1];
c[2] = color[0][2];
return;
}
if ((height < 0.9) && (height >= 0.7)) {
fact = (height - 0.7) * 5.0;
c[0] = fact * color[0][0] + (1.0 - fact) * color[1][0];
c[1] = fact * color[0][1] + (1.0 - fact) * color[1][1];
c[2] = fact * color[0][2] + (1.0 - fact) * color[1][2];
return;
}
if ((height < 0.7) && (height >= 0.6)) {
fact = (height - 0.6) * 10.0;
c[0] = fact * color[1][0] + (1.0 - fact) * color[2][0];
c[1] = fact * color[1][1] + (1.0 - fact) * color[2][1];
c[2] = fact * color[1][2] + (1.0 - fact) * color[2][2];
return;
}
if ((height < 0.6) && (height >= 0.5)) {
fact = (height - 0.5) * 10.0;
c[0] = fact * color[2][0] + (1.0 - fact) * color[3][0];
c[1] = fact * color[2][1] + (1.0 - fact) * color[3][1];
c[2] = fact * color[2][2] + (1.0 - fact) * color[3][2];
return;
}
c[0] = color[3][0];
c[1] = color[3][1];
c[2] = color[3][2];
}
static void
loadpic(void)
{
GLubyte bufferter[256 * 256], terrainpic[256 * 256];
FILE *FilePic;
int i, tmp;
GLenum gluerr;
if ((FilePic = fopen("terrain.dat", "r")) == NULL) {
fprintf(stderr, "Error loading Mnt.bin\n");
exit(-1);
}
fread(bufferter, 256 * 256, 1, FilePic);
fclose(FilePic);
for (i = 0; i < (256 * 256); i++) {
terrain[i] = (bufferter[i] * (heightMnt / 255.0f));
calccolor((GLfloat) bufferter[i], terraincolor[i]);
tmp = (((int) bufferter[i]) + 96);
terrainpic[i] = (tmp > 255) ? 255 : tmp;
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if ((gluerr = gluBuild2DMipmaps(GL_TEXTURE_2D, 1, 256, 256, GL_LUMINANCE,
GL_UNSIGNED_BYTE,
(GLvoid *) (&terrainpic[0])))) {
fprintf(stderr, "GLULib%s\n", gluErrorString(gluerr));
exit(-1);
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_2D);
}
static void
init(void)
{
float fogcolor[4] = { 0.6, 0.7, 0.7, 1.0 };
glClearColor(fogcolor[0], fogcolor[1], fogcolor[2], fogcolor[3]);
glClearDepth(1.0);
glDepthFunc(GL_LEQUAL);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glDisable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_FOG);
glFogi(GL_FOG_MODE, GL_EXP2);
glFogfv(GL_FOG_COLOR, fogcolor);
glFogf(GL_FOG_DENSITY, 0.0007);
#ifdef FX
glHint(GL_FOG_HINT, GL_NICEST);
#endif
reshape(scrwidth, scrheight);
}
int
main(int ac, char **av)
{
glutInitWindowPosition(0, 0);
glutInitWindowSize(WIDTH, HEIGHT);
glutInit(&ac, av);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
if (!(win = glutCreateWindow("Terrain"))) {
fprintf(stderr, "Error, couldn't open window\n");
return -1;
}
ModZMnt = 0.0f;
loadpic();
init();
#ifndef FX
glDisable(GL_TEXTURE_2D);
usetex = 0;
#endif
glutReshapeFunc(reshape);
glutDisplayFunc(drawscene);
glutKeyboardFunc(key);
glutSpecialFunc(special);
glutIdleFunc(drawscene);
glutMainLoop();
return 0;
}

View File

@@ -1,7 +1,51 @@
/* $Id: tessdemo.c,v 1.8 2000/07/11 14:11:58 brianp Exp $ */
/* $Id: tessdemo.c,v 1.3.2.1 1999/11/16 11:09:09 gareth Exp $ */
/*
* A demo of the GLU polygon tesselation functions written by Bogdan Sikorski.
* This demo isn't built by the Makefile because it needs GLUT. After you've
* installed GLUT you can try this demo.
* Here's the command for IRIX, for example:
cc -g -ansi -prototypes -fullwarn -float -I../include -DSHM tess_demo.c -L../lib -lglut -lMesaGLU -lMesaGL -lm -lX11 -lXext -lXmu -lfpe -lXext -o tess_demo
*/
/*
* Updated for GLU 1.3 tessellation by Gareth Hughes <garethh@bell-labs.com>
*/
/*
* $Log: tessdemo.c,v $
* Revision 1.3.2.1 1999/11/16 11:09:09 gareth
* Added combine callback. Converted vertices from ints to floats.
*
* Revision 1.3 1999/11/04 04:00:42 gareth
* Updated demo for new GLU 1.3 tessellation. Added optimized rendering
* by saving the output of the tessellation into display lists.
*
* Revision 1.2 1999/09/19 20:09:00 tanner
*
* lots of autoconf updates
*
* Revision 1.1.1.1 1999/08/19 00:55:40 jtg
* Imported sources
*
* Revision 3.5 1999/03/28 18:24:37 brianp
* minor clean-up
*
* Revision 3.4 1999/02/14 03:37:07 brianp
* fixed callback problem
*
* Revision 3.3 1998/07/26 01:25:26 brianp
* removed include of gl.h and glu.h
*
* Revision 3.2 1998/06/29 02:37:30 brianp
* minor changes for Windows (Ted Jump)
*
* Revision 3.1 1998/06/09 01:53:49 brianp
* main() should return an int
*
* Revision 3.0 1998/02/14 18:42:29 brianp
* initial rev
*
*/
@@ -10,322 +54,422 @@
#include <stdlib.h>
#include <string.h>
#define MAX_POINTS 200
#define MAX_CONTOURS 50
#define MAX_POINTS 256
#define MAX_CONTOURS 32
#define MAX_TRIANGLES 256
static int menu;
typedef enum
{ QUIT, TESSELATE, CLEAR }
menu_entries;
#ifndef GLCALLBACK
#ifdef CALLBACK
#define GLCALLBACK CALLBACK
#else
#define GLCALLBACK
#endif
#endif
typedef enum
{ DEFINE, TESSELATED }
mode_type;
typedef enum{ QUIT, TESSELATE, CLEAR } menu_entries;
typedef enum{ DEFINE, TESSELATED } mode_type;
struct
static GLsizei width, height;
static GLuint contour_cnt;
static GLuint triangle_cnt;
static mode_type mode;
static int menu;
static GLuint list_start;
static GLfloat edge_color[3];
static struct
{
GLint p[MAX_POINTS][2];
GLuint point_cnt;
}
contours[MAX_CONTOURS];
GLfloat p[MAX_POINTS][2];
GLuint point_cnt;
} contours[MAX_CONTOURS];
static GLuint contour_cnt;
static GLsizei width, height;
static mode_type mode;
struct
static struct
{
GLsizei no;
GLfloat color[3];
GLint p[3][2];
GLclampf p_color[3][3];
}
triangle;
GLsizei no;
GLfloat p[3][2];
GLclampf color[3][3];
} triangles[MAX_TRIANGLES];
static void GLCALLBACK
my_error(GLenum err)
void GLCALLBACK error_callback( GLenum err )
{
int len, i;
char const *str;
int len, i;
char const *str;
glColor3f(0.9, 0.9, 0.9);
glRasterPos2i(5, 5);
str = (const char *) gluErrorString(err);
len = strlen(str);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, str[i]);
}
glColor3f( 0.9, 0.9, 0.9 );
glRasterPos2i( 5, 5 );
str = (const char *) gluErrorString( err );
len = strlen( str );
static void GLCALLBACK
begin_callback(GLenum mode)
{
triangle.no = 0;
}
static void GLCALLBACK
edge_callback(GLenum flag)
{
if (flag == GL_TRUE) {
triangle.color[0] = 1.0;
triangle.color[1] = 1.0;
triangle.color[2] = 0.5;
}
else {
triangle.color[0] = 1.0;
triangle.color[1] = 0.0;
triangle.color[2] = 0.0;
for ( i = 0 ; i < len ; i++ ) {
glutBitmapCharacter( GLUT_BITMAP_9_BY_15, str[i] );
}
}
static void GLCALLBACK
end_callback()
void GLCALLBACK begin_callback( GLenum mode )
{
glBegin(GL_LINES);
glColor3f(triangle.p_color[0][0], triangle.p_color[0][1],
triangle.p_color[0][2]);
glVertex2i(triangle.p[0][0], triangle.p[0][1]);
glVertex2i(triangle.p[1][0], triangle.p[1][1]);
glColor3f(triangle.p_color[1][0], triangle.p_color[1][1],
triangle.p_color[1][2]);
glVertex2i(triangle.p[1][0], triangle.p[1][1]);
glVertex2i(triangle.p[2][0], triangle.p[2][1]);
glColor3f(triangle.p_color[2][0], triangle.p_color[2][1],
triangle.p_color[2][2]);
glVertex2i(triangle.p[2][0], triangle.p[2][1]);
glVertex2i(triangle.p[0][0], triangle.p[0][1]);
/* Allow multiple triangles to be output inside the begin/end pair. */
triangle_cnt = 0;
triangles[triangle_cnt].no = 0;
}
void GLCALLBACK edge_callback( GLenum flag )
{
/* Persist the edge flag across triangles. */
if ( flag == GL_TRUE )
{
edge_color[0] = 1.0;
edge_color[1] = 1.0;
edge_color[2] = 0.5;
}
else
{
edge_color[0] = 1.0;
edge_color[1] = 0.0;
edge_color[2] = 0.0;
}
}
void GLCALLBACK end_callback()
{
GLint i;
glBegin( GL_LINES );
/* Output the three edges of each triangle as lines colored
according to their edge flag. */
for ( i = 0 ; i < triangle_cnt ; i++ )
{
glColor3f( triangles[i].color[0][0],
triangles[i].color[0][1],
triangles[i].color[0][2] );
glVertex2f( triangles[i].p[0][0], triangles[i].p[0][1] );
glVertex2f( triangles[i].p[1][0], triangles[i].p[1][1] );
glColor3f( triangles[i].color[1][0],
triangles[i].color[1][1],
triangles[i].color[1][2] );
glVertex2f( triangles[i].p[1][0], triangles[i].p[1][1] );
glVertex2f( triangles[i].p[2][0], triangles[i].p[2][1] );
glColor3f( triangles[i].color[2][0],
triangles[i].color[2][1],
triangles[i].color[2][2] );
glVertex2f( triangles[i].p[2][0], triangles[i].p[2][1] );
glVertex2f( triangles[i].p[0][0], triangles[i].p[0][1] );
}
glEnd();
}
static void GLCALLBACK
vertex_callback(void *data)
void GLCALLBACK vertex_callback( void *data )
{
GLsizei no;
GLint *p;
GLsizei no;
GLfloat *p;
p = (GLint *) data;
no = triangle.no;
triangle.p[no][0] = p[0];
triangle.p[no][1] = p[1];
triangle.p_color[no][0] = triangle.color[0];
triangle.p_color[no][1] = triangle.color[1];
triangle.p_color[no][2] = triangle.color[2];
++(triangle.no);
p = (GLfloat *) data;
no = triangles[triangle_cnt].no;
triangles[triangle_cnt].p[no][0] = p[0];
triangles[triangle_cnt].p[no][1] = p[1];
triangles[triangle_cnt].color[no][0] = edge_color[0];
triangles[triangle_cnt].color[no][1] = edge_color[1];
triangles[triangle_cnt].color[no][2] = edge_color[2];
/* After every three vertices, initialize the next triangle. */
if ( ++(triangles[triangle_cnt].no) == 3 )
{
triangle_cnt++;
triangles[triangle_cnt].no = 0;
}
}
void GLCALLBACK combine_callback( GLdouble coords[3],
GLdouble *vertex_data[4],
GLfloat weight[4], void **data )
{
GLfloat *vertex;
int i;
vertex = (GLfloat *) malloc( 2 * sizeof(GLfloat) );
vertex[0] = (GLfloat) coords[0];
vertex[1] = (GLfloat) coords[1];
*data = vertex;
}
static void
set_screen_wh(GLsizei w, GLsizei h)
void set_screen_wh( GLsizei w, GLsizei h )
{
width = w;
height = h;
}
static void
tesse(void)
void tesse( void )
{
GLUtriangulatorObj *tobj;
GLdouble data[3];
GLuint i, j, point_cnt;
GLUtesselator *tobj;
GLdouble data[3];
GLuint i, j, point_cnt;
list_start = glGenLists( 2 );
tobj = gluNewTess();
if (tobj != NULL) {
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.7, 0.7, 0.0);
gluTessCallback(tobj, GLU_BEGIN, glBegin);
gluTessCallback(tobj, GLU_END, glEnd);
gluTessCallback(tobj, GLU_ERROR, my_error);
gluTessCallback(tobj, GLU_VERTEX, glVertex2iv);
gluBeginPolygon(tobj);
for (j = 0; j <= contour_cnt; j++) {
if ( tobj != NULL )
{
gluTessCallback( tobj, GLU_TESS_BEGIN, glBegin );
gluTessCallback( tobj, GLU_TESS_VERTEX, glVertex2fv );
gluTessCallback( tobj, GLU_TESS_END, glEnd );
gluTessCallback( tobj, GLU_TESS_ERROR, error_callback );
gluTessCallback( tobj, GLU_TESS_COMBINE, combine_callback );
glNewList( list_start, GL_COMPILE );
gluBeginPolygon( tobj );
for ( j = 0 ; j <= contour_cnt ; j++ )
{
point_cnt = contours[j].point_cnt;
gluNextContour(tobj, GLU_UNKNOWN);
for (i = 0; i < point_cnt; i++) {
data[0] = (GLdouble) (contours[j].p[i][0]);
data[1] = (GLdouble) (contours[j].p[i][1]);
gluNextContour( tobj, GLU_UNKNOWN );
for ( i = 0 ; i < point_cnt ; i++ )
{
data[0] = (GLdouble)( contours[j].p[i][0] );
data[1] = (GLdouble)( contours[j].p[i][1] );
data[2] = 0.0;
gluTessVertex(tobj, data, contours[j].p[i]);
gluTessVertex( tobj, data, contours[j].p[i] );
}
}
gluEndPolygon(tobj);
glLineWidth(2.0);
gluTessCallback(tobj, GLU_BEGIN, begin_callback);
gluTessCallback(tobj, GLU_END, end_callback);
gluTessCallback(tobj, GLU_VERTEX, vertex_callback);
gluTessCallback(tobj, GLU_EDGE_FLAG, edge_callback);
gluBeginPolygon(tobj);
for (j = 0; j <= contour_cnt; j++) {
gluEndPolygon( tobj );
glEndList();
gluTessCallback( tobj, GLU_TESS_BEGIN, begin_callback );
gluTessCallback( tobj, GLU_TESS_VERTEX, vertex_callback );
gluTessCallback( tobj, GLU_TESS_END, end_callback );
gluTessCallback( tobj, GLU_TESS_EDGE_FLAG, edge_callback );
glNewList( list_start + 1, GL_COMPILE );
gluBeginPolygon( tobj );
for ( j = 0 ; j <= contour_cnt ; j++ )
{
point_cnt = contours[j].point_cnt;
gluNextContour(tobj, GLU_UNKNOWN);
for (i = 0; i < point_cnt; i++) {
data[0] = (GLdouble) (contours[j].p[i][0]);
data[1] = (GLdouble) (contours[j].p[i][1]);
gluNextContour( tobj, GLU_UNKNOWN );
for ( i = 0 ; i < point_cnt ; i++ )
{
data[0] = (GLdouble)( contours[j].p[i][0] );
data[1] = (GLdouble)( contours[j].p[i][1] );
data[2] = 0.0;
gluTessVertex(tobj, data, contours[j].p[i]);
gluTessVertex( tobj, data, contours[j].p[i] );
}
}
gluEndPolygon(tobj);
gluDeleteTess(tobj);
glutMouseFunc(NULL);
glColor3f(1.0, 1.0, 0.0);
glLineWidth(1.0);
gluEndPolygon( tobj );
glEndList();
gluDeleteTess( tobj );
glutMouseFunc( NULL );
mode = TESSELATED;
}
}
static void
left_down(int x1, int y1)
void left_down( int x1, int y1 )
{
GLint P[2];
GLuint point_cnt;
GLfloat P[2];
GLuint point_cnt;
/* translate GLUT into GL coordinates */
P[0] = x1;
P[1] = height - y1;
point_cnt = contours[contour_cnt].point_cnt;
contours[contour_cnt].p[point_cnt][0] = P[0];
contours[contour_cnt].p[point_cnt][1] = P[1];
glBegin(GL_LINES);
if (point_cnt) {
glVertex2iv(contours[contour_cnt].p[point_cnt - 1]);
glVertex2iv(P);
glBegin( GL_LINES );
if ( point_cnt )
{
glVertex2fv( contours[contour_cnt].p[point_cnt-1] );
glVertex2fv( P );
}
else {
glVertex2iv(P);
glVertex2iv(P);
else
{
glVertex2fv( P );
glVertex2fv( P );
}
glEnd();
glFinish();
++(contours[contour_cnt].point_cnt);
contours[contour_cnt].point_cnt++;
}
static void
middle_down(int x1, int y1)
void middle_down( int x1, int y1 )
{
GLuint point_cnt;
GLuint point_cnt;
(void) x1;
(void) y1;
point_cnt = contours[contour_cnt].point_cnt;
if (point_cnt > 2) {
glBegin(GL_LINES);
glVertex2iv(contours[contour_cnt].p[0]);
glVertex2iv(contours[contour_cnt].p[point_cnt - 1]);
if ( point_cnt > 2 )
{
glBegin( GL_LINES );
glVertex2fv( contours[contour_cnt].p[0] );
glVertex2fv( contours[contour_cnt].p[point_cnt-1] );
contours[contour_cnt].p[point_cnt][0] = -1;
glEnd();
glFinish();
contour_cnt++;
contours[contour_cnt].point_cnt = 0;
}
}
static void
mouse_clicked(int button, int state, int x, int y)
void mouse_clicked( int button, int state, int x, int y )
{
x -= x % 10;
y -= y % 10;
switch (button) {
x -= x%10;
y -= y%10;
switch ( button )
{
case GLUT_LEFT_BUTTON:
if (state == GLUT_DOWN)
left_down(x, y);
if ( state == GLUT_DOWN ) {
left_down( x, y );
}
break;
case GLUT_MIDDLE_BUTTON:
if (state == GLUT_DOWN)
middle_down(x, y);
if ( state == GLUT_DOWN ) {
middle_down( x, y );
}
break;
}
}
static void
display(void)
void display( void )
{
GLuint i, j;
GLuint i,j;
GLuint point_cnt;
glClear(GL_COLOR_BUFFER_BIT);
switch (mode) {
glClear( GL_COLOR_BUFFER_BIT );
switch ( mode )
{
case DEFINE:
/* draw grid */
glColor3f(0.6, 0.5, 0.5);
glBegin(GL_LINES);
for (i = 0; i < width; i += 10)
for (j = 0; j < height; j += 10) {
glVertex2i(0, j);
glVertex2i(width, j);
glVertex2i(i, height);
glVertex2i(i, 0);
glColor3f( 0.6, 0.5, 0.5 );
glBegin( GL_LINES );
for ( i = 0 ; i < width ; i += 10 )
{
for ( j = 0 ; j < height ; j += 10 )
{
glVertex2i( 0, j );
glVertex2i( width, j );
glVertex2i( i, height );
glVertex2i( i, 0 );
}
glEnd();
glColor3f(1.0, 1.0, 0.0);
for (i = 0; i <= contour_cnt; i++) {
}
glColor3f( 1.0, 1.0, 0.0 );
for ( i = 0 ; i <= contour_cnt ; i++ )
{
point_cnt = contours[i].point_cnt;
glBegin(GL_LINES);
switch (point_cnt) {
glBegin( GL_LINES );
switch ( point_cnt )
{
case 0:
break;
case 1:
glVertex2iv(contours[i].p[0]);
glVertex2iv(contours[i].p[0]);
glVertex2fv( contours[i].p[0] );
glVertex2fv( contours[i].p[0] );
break;
case 2:
glVertex2iv(contours[i].p[0]);
glVertex2iv(contours[i].p[1]);
glVertex2fv( contours[i].p[0] );
glVertex2fv( contours[i].p[1] );
break;
default:
--point_cnt;
for (j = 0; j < point_cnt; j++) {
glVertex2iv(contours[i].p[j]);
glVertex2iv(contours[i].p[j + 1]);
for ( j = 0 ; j < point_cnt ; j++ )
{
glVertex2fv( contours[i].p[j] );
glVertex2fv( contours[i].p[j+1] );
}
if (contours[i].p[j + 1][0] == -1) {
glVertex2iv(contours[i].p[0]);
glVertex2iv(contours[i].p[j]);
if ( contours[i].p[j+1][0] == -1 )
{
glVertex2fv( contours[i].p[0] );
glVertex2fv( contours[i].p[j] );
}
break;
}
glEnd();
}
glFinish();
break;
case TESSELATED:
/* draw lines */
tesse();
/* draw triangles */
glColor3f( 0.7, 0.7, 0.0 );
glCallList( list_start );
glLineWidth( 2.0 );
glCallList( list_start + 1 );
glLineWidth( 1.0 );
glFlush();
break;
}
glColor3f(1.0, 1.0, 0.0);
glColor3f( 1.0, 1.0, 0.0 );
}
static void
clear(void)
void clear( void )
{
contour_cnt = 0;
contours[0].point_cnt = 0;
glutMouseFunc(mouse_clicked);
triangle_cnt = 0;
glutMouseFunc( mouse_clicked );
mode = DEFINE;
display();
glDeleteLists( list_start, 2 );
list_start = 0;
}
static void
quit(void)
void quit( void )
{
exit(0);
exit( 0 );
}
static void
menu_selected(int entry)
void menu_selected( int entry )
{
switch (entry) {
switch ( entry )
{
case CLEAR:
clear();
break;
@@ -336,87 +480,99 @@ menu_selected(int entry)
quit();
break;
}
glutPostRedisplay();
}
static void
key_pressed(unsigned char key, int x, int y)
void key_pressed( unsigned char key, int x, int y )
{
switch (key) {
(void) x;
(void) y;
switch ( key )
{
case 'c':
case 'C':
clear();
break;
case 't':
case 'T':
tesse();
glFinish();
break;
case 'q':
case 'Q':
quit();
break;
case 'c':
case 'C':
clear();
break;
}
glutPostRedisplay();
}
static void
myinit(void)
void myinit( void )
{
/* clear background to gray */
glClearColor(0.4, 0.4, 0.4, 0.0);
glShadeModel(GL_FLAT);
/* clear background to gray */
glClearColor( 0.4, 0.4, 0.4, 0.0 );
glShadeModel( GL_FLAT );
glPolygonMode( GL_FRONT, GL_FILL );
menu = glutCreateMenu( menu_selected );
glutAddMenuEntry( "clear", CLEAR );
glutAddMenuEntry( "tesselate", TESSELATE );
glutAddMenuEntry( "quit", QUIT );
glutAttachMenu( GLUT_RIGHT_BUTTON );
glutMouseFunc( mouse_clicked );
glutKeyboardFunc( key_pressed );
menu = glutCreateMenu(menu_selected);
glutAddMenuEntry("clear", CLEAR);
glutAddMenuEntry("tesselate", TESSELATE);
glutAddMenuEntry("quit", QUIT);
glutAttachMenu(GLUT_RIGHT_BUTTON);
glutMouseFunc(mouse_clicked);
glutKeyboardFunc(key_pressed);
contour_cnt = 0;
glPolygonMode(GL_FRONT, GL_FILL);
mode = DEFINE;
}
static void
reshape(GLsizei w, GLsizei h)
static void reshape( GLsizei w, GLsizei h )
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glViewport( 0, 0, w, h );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho(0.0, (GLdouble) w, 0.0, (GLdouble) h, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glOrtho( 0.0, (GLdouble)w, 0.0, (GLdouble)h, -1.0, 1.0 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
set_screen_wh(w, h);
set_screen_wh( w, h );
}
static void
usage(void)
static void usage( void )
{
printf("Use left mouse button to place vertices.\n");
printf("Press middle mouse button when done.\n");
printf("Select tesselate from the pop-up menu.\n");
printf( "Use left mouse button to place vertices.\n" );
printf( "Press middle mouse button when done.\n" );
printf( "Select tesselate from the pop-up menu.\n" );
}
/* Main Loop
* Open window with initial window size, title bar,
* RGBA display mode, and handle input events.
/*
* Main Loop
* Open window with initial window size, title bar,
* RGBA display mode, and handle input events.
*/
int
main(int argc, char **argv)
int main( int argc, char **argv )
{
usage();
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(400, 400);
glutCreateWindow(argv[0]);
myinit();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
usage();
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB );
glutInitWindowSize( 400, 400 );
glutCreateWindow( argv[0] );
myinit();
glutDisplayFunc( display );
glutReshapeFunc( reshape );
glutMainLoop();
return 0;
}

View File

@@ -1,387 +0,0 @@
/* $Id: texdown.c,v 1.3 2000/03/29 18:02:52 brianp Exp $ */
/*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* texdown
*
* Measure texture download speed.
* Use keyboard to change texture size, format, datatype, scale/bias,
* subimageload, etc.
*
* Brian Paul 28 January 2000
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
static GLsizei MaxSize = 1024;
static GLsizei TexWidth = 256, TexHeight = 256, TexBorder = 0;
static GLboolean ScaleAndBias = GL_FALSE;
static GLboolean SubImage = GL_FALSE;
static GLdouble DownloadRate = 0.0; /* texels/sec */
static GLuint Mode = 0;
#define NUM_FORMATS 4
struct FormatRec {
GLenum Format;
GLenum Type;
GLenum IntFormat;
GLint TexelSize;
};
static const struct FormatRec FormatTable[NUM_FORMATS] = {
/* Format Type IntFormat TexelSize */
{ GL_RGB, GL_UNSIGNED_BYTE, GL_RGB, 3 },
{ GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA, 4 },
{ GL_RGBA, GL_UNSIGNED_BYTE, GL_RGB, 4 },
{ GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_RGB, 2 },
};
static GLint Format;
static int
BytesPerTexel(GLint format)
{
return FormatTable[format].TexelSize;
}
static const char *
FormatStr(GLenum format)
{
switch (format) {
case GL_RGB:
return "GL_RGB";
case GL_RGBA:
return "GL_RGBA";
default:
return "";
}
}
static const char *
TypeStr(GLenum type)
{
switch (type) {
case GL_UNSIGNED_BYTE:
return "GL_UNSIGNED_BYTE";
case GL_UNSIGNED_SHORT:
return "GL_UNSIGNED_SHORT";
case GL_UNSIGNED_SHORT_5_6_5:
return "GL_UNSIGNED_SHORT_5_6_5";
case GL_UNSIGNED_SHORT_5_6_5_REV:
return "GL_UNSIGNED_SHORT_5_6_5_REV";
default:
return "";
}
}
static void
MeasureDownloadRate(void)
{
const int w = TexWidth + 2 * TexBorder;
const int h = TexHeight + 2 * TexBorder;
const int bytes = w * h * BytesPerTexel(Format);
GLubyte *texImage, *getImage;
GLdouble t0, t1, time;
int count;
int i;
texImage = (GLubyte *) malloc(bytes);
getImage = (GLubyte *) malloc(bytes);
if (!texImage || !getImage) {
DownloadRate = 0.0;
return;
}
for (i = 0; i < bytes; i++) {
texImage[i] = i & 0xff;
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
if (ScaleAndBias) {
glPixelTransferf(GL_RED_SCALE, 0.5);
glPixelTransferf(GL_GREEN_SCALE, 0.5);
glPixelTransferf(GL_BLUE_SCALE, 0.5);
glPixelTransferf(GL_RED_BIAS, 0.5);
glPixelTransferf(GL_GREEN_BIAS, 0.5);
glPixelTransferf(GL_BLUE_BIAS, 0.5);
}
else {
glPixelTransferf(GL_RED_SCALE, 1.0);
glPixelTransferf(GL_GREEN_SCALE, 1.0);
glPixelTransferf(GL_BLUE_SCALE, 1.0);
glPixelTransferf(GL_RED_BIAS, 0.0);
glPixelTransferf(GL_GREEN_BIAS, 0.0);
glPixelTransferf(GL_BLUE_BIAS, 0.0);
}
count = 0;
t0 = glutGet(GLUT_ELAPSED_TIME) * 0.001;
do {
if (SubImage && count > 0) {
glTexSubImage2D(GL_TEXTURE_2D, 0, -TexBorder, -TexBorder, w, h,
FormatTable[Format].Format,
FormatTable[Format].Type, texImage);
}
else {
glTexImage2D(GL_TEXTURE_2D, 0,
FormatTable[Format].IntFormat, w, h, TexBorder,
FormatTable[Format].Format,
FormatTable[Format].Type, texImage);
}
if (count == 0) {
/* draw a tiny polygon to force texture into texram */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glEnable(GL_TEXTURE_2D);
glBegin(GL_TRIANGLES);
glTexCoord2f(0, 0); glVertex2f(1, 1);
glTexCoord2f(1, 0); glVertex2f(3, 1);
glTexCoord2f(0.5, 1); glVertex2f(2, 3);
glEnd();
glDisable(GL_TEXTURE_2D);
}
t1 = glutGet(GLUT_ELAPSED_TIME) * 0.001;
time = t1 - t0;
count++;
} while (time < 3.0);
printf("w*h=%d count=%d time=%f\n", w*h, count, time);
DownloadRate = w * h * count / time;
#if 0
if (!ScaleAndBias) {
/* verify texture readback */
glGetTexImage(GL_TEXTURE_2D, 0,
FormatTable[Format].Format,
FormatTable[Format].Type, getImage);
for (i = 0; i < w * h; i++) {
if (texImage[i] != getImage[i]) {
printf("[%d] %d != %d\n", i, texImage[i], getImage[i]);
}
}
}
#endif
free(texImage);
free(getImage);
{
GLint err = glGetError();
if (err)
printf("GL error %d\n", err);
}
}
static void
PrintString(const char *s)
{
while (*s) {
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
s++;
}
}
static void
Display(void)
{
const int w = TexWidth + 2 * TexBorder;
const int h = TexHeight + 2 * TexBorder;
char s[1000];
glClear(GL_COLOR_BUFFER_BIT);
glRasterPos2i(10, 80);
sprintf(s, "Texture size[cursor]: %d x %d Border[b]: %d", w, h, TexBorder);
PrintString(s);
glRasterPos2i(10, 65);
sprintf(s, "Format[f]: %s Type: %s IntFormat: %s",
FormatStr(FormatTable[Format].Format),
TypeStr( FormatTable[Format].Type),
FormatStr(FormatTable[Format].IntFormat));
PrintString(s);
glRasterPos2i(10, 50);
sprintf(s, "Pixel Scale&Bias[p]: %s TexSubImage[s]: %s",
ScaleAndBias ? "Yes" : "No",
SubImage ? "Yes" : "No");
PrintString(s);
if (Mode == 0) {
glRasterPos2i(200, 10);
sprintf(s, "...Measuring...");
PrintString(s);
glutSwapBuffers();
glutPostRedisplay();
Mode++;
}
else if (Mode == 1) {
MeasureDownloadRate();
glutPostRedisplay();
Mode++;
}
else {
/* show results */
glRasterPos2i(10, 10);
sprintf(s, "Download rate: %g Mtexels/second %g MB/second",
DownloadRate / 1000000.0,
DownloadRate * BytesPerTexel(Format) / 1000000.0);
PrintString(s);
{
GLint r, g, b, a, l, i;
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &r);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &g);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &b);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &a);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE, &l);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTENSITY_SIZE, &i);
sprintf(s, "TexelBits: R=%d G=%d B=%d A=%d L=%d I=%d", r, g, b, a, l, i);
glRasterPos2i(10, 25);
PrintString(s);
}
glutSwapBuffers();
}
}
static void
Reshape(int width, int height)
{
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho(0, width, 0, height, -1, 1);
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}
static void
Key(unsigned char key, int x, int y)
{
(void) x;
(void) y;
switch (key) {
case ' ':
Mode = 0;
break;
case 'b':
/* toggle border */
TexBorder = 1 - TexBorder;
Mode = 0;
break;
case 'f':
/* change format */
Format = (Format + 1) % NUM_FORMATS;
Mode = 0;
break;
case 'p':
/* toggle border */
ScaleAndBias = !ScaleAndBias;
Mode = 0;
break;
case 's':
SubImage = !SubImage;
Mode = 0;
break;
case 27:
exit(0);
break;
}
glutPostRedisplay();
}
static void
SpecialKey(int key, int x, int y)
{
(void) x;
(void) y;
switch (key) {
case GLUT_KEY_UP:
if (TexHeight < MaxSize)
TexHeight *= 2;
break;
case GLUT_KEY_DOWN:
if (TexHeight > 1)
TexHeight /= 2;
break;
case GLUT_KEY_LEFT:
if (TexWidth > 1)
TexWidth /= 2;
break;
case GLUT_KEY_RIGHT:
if (TexWidth < MaxSize)
TexWidth *= 2;
break;
}
Mode = 0;
glutPostRedisplay();
}
static void
Init(void)
{
printf("GL_VENDOR = %s\n", (const char *) glGetString(GL_VENDOR));
printf("GL_VERSION = %s\n", (const char *) glGetString(GL_VERSION));
printf("GL_RENDERER = %s\n", (const char *) glGetString(GL_RENDERER));
}
int
main(int argc, char *argv[])
{
glutInit( &argc, argv );
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( 600, 100 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
glutCreateWindow(argv[0]);
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );
glutSpecialFunc( SpecialKey );
glutDisplayFunc( Display );
Init();
glutMainLoop();
return 0;
}

View File

@@ -1,759 +0,0 @@
/* 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.
*/
/*
* Demonstrates texture environment modes and internal image formats.
*/
/*
* Hacked on, updated by Gareth Hughes <gareth@valinux.com>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <GL/glut.h>
#undef max
#undef min
#define max( a, b ) ((a) >= (b) ? (a) : (b))
#define min( a, b ) ((a) <= (b) ? (a) : (b))
GLfloat lightCheck[4] = { 0.7, 0.7, 0.7, 1.0 };
GLfloat darkCheck[4] = { 0.3, 0.3, 0.3, 1.0 };
GLfloat labelColor0[4] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat labelColor1[4] = { 1.0, 1.0, 0.4, 1.0 };
GLfloat *labelInfoColor = labelColor0;
GLfloat labelLevelColor0[4] = { 0.8, 0.8, 0.1, 1.0 };
GLfloat labelLevelColor1[4] = { 0.0, 0.0, 0.0, 1.0 };
GLboolean doubleBuffered = GL_FALSE;
GLboolean drawBackground = GL_FALSE;
GLboolean drawBlended = GL_TRUE;
GLboolean drawSmooth = GL_FALSE;
GLboolean drawTextured = GL_TRUE;
GLboolean displayLevelInfo = GL_FALSE;
int textureWidth = 64;
int textureHeight = 64;
int winWidth = 580, winHeight = 720;
struct formatInfo {
GLenum baseFormat;
GLenum internalFormat;
char *name;
};
#define NUM_LUMINANCE_FORMATS (sizeof(luminanceFormats) / sizeof(luminanceFormats[0]))
struct formatInfo luminanceFormats[] =
{
{ GL_LUMINANCE, GL_LUMINANCE, "LUMINANCE" },
{ GL_LUMINANCE, GL_LUMINANCE4, "LUMINANCE4" },
{ GL_LUMINANCE, GL_LUMINANCE8, "LUMINANCE8" },
{ GL_LUMINANCE, GL_LUMINANCE12, "LUMINANCE12" },
{ GL_LUMINANCE, GL_LUMINANCE16, "LUMINANCE16" },
};
#define NUM_ALPHA_FORMATS (sizeof(alphaFormats) / sizeof(alphaFormats[0]))
struct formatInfo alphaFormats[] =
{
{ GL_ALPHA, GL_ALPHA, "ALPHA" },
{ GL_ALPHA, GL_ALPHA4, "ALPHA4" },
{ GL_ALPHA, GL_ALPHA8, "ALPHA8" },
{ GL_ALPHA, GL_ALPHA12, "ALPHA12" },
{ GL_ALPHA, GL_ALPHA16, "ALPHA16" },
};
#define NUM_INTENSITY_FORMATS (sizeof(intensityFormats) / sizeof(intensityFormats[0]))
struct formatInfo intensityFormats[] =
{
{ GL_INTENSITY, GL_INTENSITY, "INTENSITY" },
{ GL_INTENSITY, GL_INTENSITY4, "INTENSITY4" },
{ GL_INTENSITY, GL_INTENSITY8, "INTENSITY8" },
{ GL_INTENSITY, GL_INTENSITY12, "INTENSITY12" },
{ GL_INTENSITY, GL_INTENSITY16, "INTENSITY16" },
};
#define NUM_LUMINANCE_ALPHA_FORMATS (sizeof(luminanceAlphaFormats) / sizeof(luminanceAlphaFormats[0]))
struct formatInfo luminanceAlphaFormats[] =
{
{ GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, "LUMINANCE_ALPHA" },
{ GL_LUMINANCE_ALPHA, GL_LUMINANCE4_ALPHA4, "LUMINANCE4_ALPHA4" },
{ GL_LUMINANCE_ALPHA, GL_LUMINANCE6_ALPHA2, "LUMINANCE6_ALPHA2" },
{ GL_LUMINANCE_ALPHA, GL_LUMINANCE8_ALPHA8, "LUMINANCE8_ALPHA8" },
{ GL_LUMINANCE_ALPHA, GL_LUMINANCE12_ALPHA4, "LUMINANCE12_ALPHA4" },
{ GL_LUMINANCE_ALPHA, GL_LUMINANCE12_ALPHA12, "LUMINANCE12_ALPHA12" },
{ GL_LUMINANCE_ALPHA, GL_LUMINANCE16_ALPHA16, "LUMINANCE16_ALPHA16" },
};
#define NUM_RGB_FORMATS (sizeof(rgbFormats) / sizeof(rgbFormats[0]))
struct formatInfo rgbFormats[] =
{
{ GL_RGB, GL_RGB, "RGB" },
{ GL_RGB, GL_R3_G3_B2, "R3_G3_B2" },
{ GL_RGB, GL_RGB4, "RGB4" },
{ GL_RGB, GL_RGB5, "RGB5" },
{ GL_RGB, GL_RGB8, "RGB8" },
{ GL_RGB, GL_RGB10, "RGB10" },
{ GL_RGB, GL_RGB12, "RGB12" },
{ GL_RGB, GL_RGB16, "RGB16" },
};
#define NUM_RGBA_FORMATS (sizeof(rgbaFormats) / sizeof(rgbaFormats[0]))
struct formatInfo rgbaFormats[] =
{
{ GL_RGBA, 4, "RGBA" },
{ GL_RGBA, GL_RGBA2, "RGBA2" },
{ GL_RGBA, GL_RGBA4, "RGBA4" },
{ GL_RGBA, GL_RGB5_A1, "RGB5_A1" },
{ GL_RGBA, GL_RGBA8, "RGBA8" },
{ GL_RGBA, GL_RGB10_A2, "RGB10_A2" },
{ GL_RGBA, GL_RGBA12, "RGBA12" },
{ GL_RGBA, GL_RGBA16, "RGBA16" },
};
struct baseFormatInfo {
struct formatInfo *format;
int current, number;
};
#define NUM_BASE_FORMATS (sizeof(baseFormats) / sizeof(baseFormats[0]))
int baseFormat;
struct baseFormatInfo baseFormats[] =
{
{ luminanceFormats, 0, NUM_LUMINANCE_FORMATS },
{ alphaFormats, 0, NUM_ALPHA_FORMATS },
{ intensityFormats, 0, NUM_INTENSITY_FORMATS },
{ luminanceAlphaFormats, 0, NUM_LUMINANCE_ALPHA_FORMATS },
{ rgbFormats, 0, NUM_RGB_FORMATS },
{ rgbaFormats, 0, NUM_RGBA_FORMATS },
};
#define NUM_ENV_COLORS (sizeof(envColors) / sizeof(envColors[0]))
int envColor;
GLfloat envColors[][4] =
{
{ 0.0, 0.0, 0.0, 1.0 },
{ 1.0, 0.0, 0.0, 1.0 },
{ 0.0, 1.0, 0.0, 1.0 },
{ 0.0, 0.0, 1.0, 1.0 },
{ 1.0, 1.0, 1.0, 1.0 },
};
struct envModeInfo {
GLenum mode;
char *name;
};
/* allow for run-time check for GL_EXT_texture_env_add */
int NUM_ENV_MODES = 5;
struct envModeInfo envModes[] =
{
{ GL_REPLACE, "REPLACE" },
{ GL_MODULATE, "MODULATE" },
{ GL_BLEND, "BLEND" },
{ GL_DECAL, "DECAL" },
#if GL_EXT_texture_env_add
{ GL_ADD, "ADD" },
#endif
};
static void checkErrors( void )
{
GLenum error;
return;
while ( (error = glGetError()) != GL_NO_ERROR ) {
fprintf( stderr, "Error: %s\n", (char *) gluErrorString( error ) );
}
}
static void drawString( char *string, GLfloat x, GLfloat y, GLfloat color[4] )
{
glColor4fv( color );
glRasterPos2f( x, y );
while ( *string ) {
glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_10, *string );
string++;
}
}
static void drawStringOutline( char *string, GLfloat x, GLfloat y,
GLfloat color[4], GLfloat outline[4] )
{
drawString( string, x - 1, y, outline );
drawString( string, x + 1, y, outline );
drawString( string, x, y - 1, outline );
drawString( string, x, y + 1, outline );
drawString( string, x, y, color );
}
static void begin2D( int width, int height )
{
glMatrixMode( GL_PROJECTION );
glPushMatrix();
glLoadIdentity();
glOrtho( 0, width, 0, height, -1, 1 );
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glLoadIdentity();
}
static void end2D( void )
{
glMatrixMode( GL_PROJECTION );
glPopMatrix();
glMatrixMode( GL_MODELVIEW );
glPopMatrix();
}
static void initialize( void )
{
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( -1.5, 1.5, -1.5, 1.5, -1.5, 1.5 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glShadeModel( GL_FLAT );
}
/* ARGSUSED1 */
static void keyboard( unsigned char c, int x, int y )
{
switch ( c ) {
case 'c':
envColor = ++envColor % (int) NUM_ENV_COLORS;
break;
case 'g':
drawBackground = !drawBackground;
break;
case 'b':
drawBlended = !drawBlended;
break;
case 's':
drawSmooth = !drawSmooth;
break;
case 't':
drawTextured = !drawTextured;
break;
case 'i':
displayLevelInfo = !displayLevelInfo;
break;
case 27: /* Escape key should force exit. */
exit(0);
break;
default:
break;
}
glutPostRedisplay();
}
/* ARGSUSED1 */
static void special( int key, int x, int y )
{
switch ( key ) {
case GLUT_KEY_DOWN:
if ( ++baseFormat > NUM_BASE_FORMATS - 1 ) {
baseFormat = 0;
}
break;
case GLUT_KEY_UP:
if ( --baseFormat < 0 ) {
baseFormat = NUM_BASE_FORMATS - 1;
}
break;
case GLUT_KEY_LEFT:
--baseFormats[baseFormat].current;
if ( baseFormats[baseFormat].current < 0 ) {
baseFormats[baseFormat].current = baseFormats[baseFormat].number - 1;
}
break;
case GLUT_KEY_RIGHT:
++baseFormats[baseFormat].current;
if ( baseFormats[baseFormat].current > baseFormats[baseFormat].number - 1 ) {
baseFormats[baseFormat].current = 0;
}
break;
default:
break;
}
glutPostRedisplay();
}
static void
reshape( int w, int h )
{
winWidth = w;
winHeight = h;
/* No need to call glViewPort here since "draw" calls it! */
}
static void loadTexture( int width, int height, struct formatInfo *format )
{
int luminanceSize = 0;
int alphaSize = 0;
int rgbSize = 0;
GLenum textureFormat;
GLubyte *texImage, *p;
int elementsPerGroup, elementSize, groupSize, rowSize;
int i, j;
switch ( format->baseFormat ) {
case GL_LUMINANCE:
luminanceSize = 1;
textureFormat = GL_LUMINANCE;
break;
case GL_INTENSITY:
luminanceSize = 1;
textureFormat = GL_INTENSITY;
break;
case GL_ALPHA:
alphaSize = 1;
textureFormat = GL_ALPHA;
break;
case GL_LUMINANCE_ALPHA:
luminanceSize = 1;
alphaSize = 1;
textureFormat = GL_LUMINANCE_ALPHA;
break;
case GL_RGB:
rgbSize = 3;
textureFormat = GL_RGB;
break;
case GL_RGBA:
rgbSize = 3;
alphaSize = 1;
textureFormat = GL_RGBA;
break;
default:
fprintf(stderr, "bad internal format info\n");
return;
}
elementsPerGroup = luminanceSize + alphaSize + rgbSize;
elementSize = sizeof(GLubyte);
groupSize = elementsPerGroup * elementSize;
rowSize = width * groupSize;
if ( (texImage = (GLubyte *) malloc( height * rowSize ) ) == NULL ) {
fprintf( stderr, "texture malloc failed\n" );
return;
}
for ( i = 0 ; i < height ; i++ )
{
p = texImage + i * rowSize;
for ( j = 0 ; j < width ; j++ )
{
if ( luminanceSize > 0 )
{
/**
** +-----+-----+
** | | |
** | W | LG |
** | | |
** +-----+-----+
** | | |
** | DG | B |
** | | |
** +-----+-----+
**/
if ( i > height / 2 ) {
if ( j < width / 2 ) {
p[0] = 0xff;
} else {
p[0] = 0xaa;
}
} else {
if ( j < width / 2 ) {
p[0] = 0x55;
} else {
p[0] = 0x00;
}
}
p += elementSize;
}
if ( rgbSize > 0 )
{
/**
** +-----+-----+
** | | |
** | R | G |
** | | |
** +-----+-----+
** | | |
** | Y | B |
** | | |
** +-----+-----+
**/
if ( i > height / 2 ) {
if ( j < width / 2 ) {
p[0] = 0xff;
p[1] = 0x00;
p[2] = 0x00;
} else {
p[0] = 0x00;
p[1] = 0xff;
p[2] = 0x00;
}
} else {
if ( j < width / 2 ) {
p[0] = 0xff;
p[1] = 0xff;
p[2] = 0x00;
} else {
p[0] = 0x00;
p[1] = 0x00;
p[2] = 0xff;
}
}
p += 3 * elementSize;
}
if ( alphaSize > 0 )
{
/**
** +-----------+
** | W |
** | +-----+ |
** | | | |
** | | B | |
** | | | |
** | +-----+ |
** | |
** +-----------+
**/
int i2 = i - height / 2;
int j2 = j - width / 2;
int h8 = height / 8;
int w8 = width / 8;
if ( -h8 <= i2 && i2 <= h8 && -w8 <= j2 && j2 <= w8 ) {
p[0] = 0x00;
} else if ( -2 * h8 <= i2 && i2 <= 2 * h8 && -2 * w8 <= j2 && j2 <= 2 * w8 ) {
p[0] = 0x55;
} else if ( -3 * h8 <= i2 && i2 <= 3 * h8 && -3 * w8 <= j2 && j2 <= 3 * w8 ) {
p[0] = 0xaa;
} else {
p[0] = 0xff;
}
p += elementSize;
}
}
}
glTexImage2D( GL_TEXTURE_2D, 0,
format->internalFormat, width, height, 0,
textureFormat, GL_UNSIGNED_BYTE, texImage );
free( texImage );
}
static void drawCheck( int w, int h, GLfloat lightCheck[4], GLfloat darkCheck[4] )
{
float dw = 2.0 / w;
float dh = 2.0 / h;
int i, j;
for ( i = 0 ; i < w ; i++ ) {
GLfloat x0 = -1.0 + i * dw;
GLfloat x1 = x0 + dw;
glBegin( GL_QUAD_STRIP );
for ( j = 0 ; j <= h ; j++ ) {
GLfloat y = -1.0 + j * dh;
if ( (i ^ j) & 1 ) {
glColor4fv( lightCheck );
} else {
glColor4fv( darkCheck );
}
glVertex2f( x0, y );
glVertex2f( x1, y );
}
glEnd();
}
}
static void drawSample( int x, int y, int w, int h,
struct formatInfo *format, struct envModeInfo *envMode )
{
glViewport( x, y, w, h );
glScissor( x, y, w, h );
glClearColor( 0.1, 0.1, 0.1, 1.0 );
glClear( GL_COLOR_BUFFER_BIT );
begin2D( w, h );
drawString( format->name, 10, h - 15, labelInfoColor );
drawString( envMode->name, 10, 5, labelInfoColor );
end2D();
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, envMode->mode );
glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, envColors[envColor] );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
loadTexture( textureWidth, textureHeight, format );
if ( drawBackground ) {
drawCheck( 15, 15, lightCheck, darkCheck );
}
if ( drawBlended ) {
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glEnable( GL_BLEND );
}
if ( drawSmooth ) {
glShadeModel( GL_SMOOTH );
}
if ( drawTextured ) {
glEnable( GL_TEXTURE_2D );
}
glBegin( GL_QUADS );
glColor4f( 1.0, 0.0, 0.0, 1.0 );
glTexCoord2f( 0.0, 0.0 );
glVertex2f( -0.8, -0.8 );
glColor4f( 0.0, 1.0, 0.0, 1.0 );
glTexCoord2f( 1.0, 0.0 );
glVertex2f( 0.8, -0.8 );
glColor4f( 0.0, 0.0, 1.0, 1.0 );
glTexCoord2f( 1.0, 1.0 );
glVertex2f( 0.8, 0.8 );
glColor4f( 1.0, 1.0, 1.0, 1.0 );
glTexCoord2f( 0.0, 1.0 );
glVertex2f( -0.8, 0.8 );
glEnd();
glDisable( GL_BLEND );
glShadeModel( GL_FLAT );
glDisable( GL_TEXTURE_2D );
if ( displayLevelInfo ) {
GLint width, height, border, components;
GLint redSize, greenSize, blueSize, alphaSize;
GLint luminanceSize, intensitySize;
char buf[255];
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_BORDER, &border );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_COMPONENTS, &components );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &redSize );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &greenSize );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &blueSize );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &alphaSize );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE, &luminanceSize );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_INTENSITY_SIZE, &intensitySize );
begin2D( w, h );
sprintf( buf, "dimensions: %d x %d", width, height );
drawStringOutline( buf, 15, h / 2 + 20, labelLevelColor0, labelLevelColor1 );
sprintf( buf, "border: %d", border );
drawStringOutline( buf, 15, h / 2 + 10, labelLevelColor0, labelLevelColor1 );
sprintf( buf, "components: 0x%04X", components );
drawStringOutline( buf, 15, h / 2, labelLevelColor0, labelLevelColor1 );
sprintf( buf, "sizes:" );
drawStringOutline( buf, 15, h / 2 - 10, labelLevelColor0, labelLevelColor1 );
sprintf( buf, " %d / %d / %d / %d / %d / %d",
redSize, greenSize, blueSize, alphaSize,
luminanceSize, intensitySize );
drawStringOutline( buf, 15, h / 2 - 20, labelLevelColor0, labelLevelColor1 );
end2D();
}
}
static void display( void )
{
int numX = NUM_ENV_MODES, numY = NUM_BASE_FORMATS;
float xBase = (float) winWidth * 0.01;
float xOffset = (winWidth - xBase) / numX;
float xSize = max( xOffset - xBase, 1 );
float yBase = (float) winHeight * 0.01;
float yOffset = (winHeight - yBase) / numY;
float ySize = max( yOffset - yBase, 1 );
float x, y;
int i, j;
glViewport( 0, 0, winWidth, winHeight );
glDisable( GL_SCISSOR_TEST );
glClearColor( 0.0, 0.0, 0.0, 0.0 );
glClear( GL_COLOR_BUFFER_BIT );
glEnable( GL_SCISSOR_TEST );
x = xBase;
y = (winHeight - 1) - yOffset;
for ( i = 0 ; i < NUM_BASE_FORMATS ; i++ )
{
struct formatInfo *format;
if ( i == baseFormat ) {
labelInfoColor = labelColor1;
} else {
labelInfoColor = labelColor0;
}
format = &baseFormats[i].format[baseFormats[i].current];
for ( j = 0 ; j < NUM_ENV_MODES ; j++ ) {
struct envModeInfo *envMode;
envMode = &envModes[j];
drawSample( x, y, xSize, ySize, format, envMode );
x += xOffset;
}
x = xBase;
y -= yOffset;
}
if ( doubleBuffered ) {
glutSwapBuffers();
} else {
glFlush();
}
checkErrors();
}
static void usage( char *name )
{
fprintf( stderr, "usage: %s [ options ]\n", name );
fprintf( stderr, "\n" );
fprintf( stderr, "options:\n" );
fprintf( stderr, " -sb single buffered\n" );
fprintf( stderr, " -db double buffered\n" );
fprintf( stderr, " -info print OpenGL driver info\n" );
}
static void instructions( void )
{
fprintf( stderr, "texenv - texture environment and internal format test\n" );
fprintf( stderr, "\n" );
fprintf( stderr, " [c] - cycle through background colors\n" );
fprintf( stderr, " [g] - toggle background\n" );
fprintf( stderr, " [b] - toggle blend\n" );
fprintf( stderr, " [s] - toggle smooth shading\n" );
fprintf( stderr, " [t] - toggle texturing\n" );
fprintf( stderr, " [i] - toggle information display\n" );
}
int main( int argc, char *argv[] )
{
GLboolean info = GL_FALSE;
int i;
glutInit( &argc, argv );
for ( i = 1 ; i < argc ; i++ ) {
if ( !strcmp( "-sb", argv[i] ) ) {
doubleBuffered = GL_FALSE;
} else if ( !strcmp( "-db", argv[i] ) ) {
doubleBuffered = GL_TRUE;
} else if ( !strcmp( "-info", argv[i] ) ) {
info = GL_TRUE;
} else {
usage( argv[0] );
exit( 1 );
}
}
if ( doubleBuffered ) {
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
} else {
glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE );
}
glutInitWindowSize( winWidth, winHeight );
glutCreateWindow( "Texture Environment Test" );
initialize();
instructions();
if ( info ) {
printf( "\n" );
printf( "GL_RENDERER = %s\n", (char *) glGetString( GL_RENDERER ) );
printf( "GL_VERSION = %s\n", (char *) glGetString( GL_VERSION ) );
printf( "GL_VENDOR = %s\n", (char *) glGetString( GL_VENDOR ) ) ;
printf( "GL_EXTENSIONS = %s\n", (char *) glGetString( GL_EXTENSIONS ) );
}
#if GL_EXT_texture_env_add
if ( !glutExtensionSupported( "GL_EXT_texture_env_add" ) ) {
fprintf( stderr, "missing extension: GL_EXT_texture_env_add\n" );
NUM_ENV_MODES--;
}
#endif
glutDisplayFunc( display );
glutReshapeFunc( reshape );
glutKeyboardFunc( keyboard );
glutSpecialFunc( special );
glutMainLoop();
return 0;
}

View File

@@ -1,4 +1,4 @@
/* $Id: texobj.c,v 1.5 2000/07/19 23:57:24 brianp Exp $ */
/* $Id: texobj.c,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
/*
* Example of using the 1.1 texture object functions.
@@ -7,6 +7,21 @@
* Brian Paul June 1996 This file is in the public domain.
*/
/*
* $Log: texobj.c,v $
* Revision 1.1 1999/08/19 00:55:40 jtg
* Initial revision
*
* Revision 3.1 1999/03/28 18:24:37 brianp
* minor clean-up
*
* Revision 3.0 1998/02/14 18:42:29 brianp
* initial rev
*
*/
#include <math.h>
#include <stdlib.h>
#include <string.h>
@@ -16,10 +31,10 @@ static GLuint Window = 0;
static GLuint TexObj[2];
static GLfloat Angle = 0.0f;
static GLboolean UseObj = GL_FALSE;
static GLboolean HaveTexObj = GL_FALSE;
#if defined(GL_VERSION_1_1) || defined(GL_VERSION_1_2)
#if defined(GL_VERSION_1_1)
# define TEXTURE_OBJECT 1
#elif defined(GL_EXT_texture_object)
# define TEXTURE_OBJECT 1
@@ -43,7 +58,7 @@ static void draw( void )
glPushMatrix();
glTranslatef( -1.0, 0.0, 0.0 );
glRotatef( Angle, 0.0, 0.0, 1.0 );
if (UseObj) {
if (HaveTexObj) {
#ifdef TEXTURE_OBJECT
glBindTexture( GL_TEXTURE_2D, TexObj[0] );
#endif
@@ -63,13 +78,13 @@ static void draw( void )
glPushMatrix();
glTranslatef( 1.0, 0.0, 0.0 );
glRotatef( Angle-90.0, 0.0, 1.0, 0.0 );
if (UseObj) {
if (HaveTexObj) {
#ifdef TEXTURE_OBJECT
glBindTexture( GL_TEXTURE_2D, TexObj[1] );
#endif
}
else {
glCallList( TexObj[1] );
glCallList( TexObj[0] );
}
glBegin( GL_POLYGON );
glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 );
@@ -159,7 +174,7 @@ static void init( void )
/* generate texture object IDs */
if (UseObj) {
if (HaveTexObj) {
#ifdef TEXTURE_OBJECT
glGenTextures( 2, TexObj );
#endif
@@ -170,7 +185,7 @@ static void init( void )
}
/* setup first texture object */
if (UseObj) {
if (HaveTexObj) {
#ifdef TEXTURE_OBJECT
glBindTexture( GL_TEXTURE_2D, TexObj[0] );
#endif
@@ -197,13 +212,13 @@ static void init( void )
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
if (!UseObj) {
if (!HaveTexObj) {
glEndList();
}
/* end of texture object */
/* setup second texture object */
if (UseObj) {
if (HaveTexObj) {
#ifdef TEXTURE_OBJECT
glBindTexture( GL_TEXTURE_2D, TexObj[1] );
#endif
@@ -229,7 +244,7 @@ static void init( void )
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
if (!UseObj) {
if (!HaveTexObj) {
glEndList();
}
/* end texture object */
@@ -240,7 +255,6 @@ static void init( void )
int main( int argc, char *argv[] )
{
glutInit(&argc, argv);
glutInitWindowPosition(0, 0);
glutInitWindowSize(300, 300);
glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
@@ -258,9 +272,8 @@ int main( int argc, char *argv[] )
char *exten = (char *) glGetString( GL_EXTENSIONS );
char *version = (char *) glGetString( GL_VERSION );
if ( strstr( exten, "GL_EXT_texture_object" )
|| strncmp( version, "1.1", 3 )==0
|| strncmp( version, "1.2", 3 )==0 ) {
UseObj = GL_TRUE;
|| strncmp( version, "1.1", 3 )==0 ) {
HaveTexObj = GL_TRUE;
}
}
#endif

View File

@@ -1,512 +0,0 @@
/*
* This program is under the GNU GPL.
* Use at your own risk.
*
* written by David Bucciarelli (tech.hmw@plus.it)
* Humanware s.r.l.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#ifdef WIN32
#include <windows.h>
#endif
#include <GL/glut.h>
#include "../util/readtex.c"
#include "tunneldat.c"
#ifdef XMESA
#include "GL/xmesa.h"
static int fullscreen = 1;
#endif
static int WIDTH = 640;
static int HEIGHT = 480;
#define FRAME 50
#define NUMBLOC 5
#ifndef M_PI
#define M_PI 3.1415926535
#endif
extern int striplength_skin_13[];
extern float stripdata_skin_13[];
extern int striplength_skin_12[];
extern float stripdata_skin_12[];
extern int striplength_skin_11[];
extern float stripdata_skin_11[];
extern int striplength_skin_9[];
extern float stripdata_skin_9[];
static int win = 0;
static float obs[3] = { 1000.0, 0.0, 2.0 };
static float dir[3];
static float v = 0.5;
static float alpha = 90.0;
static float beta = 90.0;
static int fog = 0;
static int bfcull = 1;
static int usetex = 1;
static int cstrip = 0;
static int help = 1;
static int joyavailable = 0;
static int joyactive = 0;
static GLuint t1id, t2id;
static void
inittextures(void)
{
glGenTextures(1, &t1id);
glBindTexture(GL_TEXTURE_2D, t1id);
if (!LoadRGBMipmaps("../images/tile.rgb", GL_RGB)) {
fprintf(stderr, "Error reading a texture.\n");
exit(-1);
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glGenTextures(1, &t2id);
glBindTexture(GL_TEXTURE_2D, t2id);
if (!LoadRGBMipmaps("../images/bw.rgb", GL_RGB)) {
fprintf(stderr, "Error reading a texture.\n");
exit(-1);
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
static void
drawobjs(int *l, float *f)
{
int mend, j;
if (cstrip) {
float r = 0.33, g = 0.33, b = 0.33;
for (; (*l) != 0;) {
mend = *l++;
r += 0.33;
if (r > 1.0) {
r = 0.33;
g += 0.33;
if (g > 1.0) {
g = 0.33;
b += 0.33;
if (b > 1.0)
b = 0.33;
}
}
glColor3f(r, g, b);
glBegin(GL_TRIANGLE_STRIP);
for (j = 0; j < mend; j++) {
f += 4;
glTexCoord2fv(f);
f += 2;
glVertex3fv(f);
f += 3;
}
glEnd();
}
}
else
for (; (*l) != 0;) {
mend = *l++;
glBegin(GL_TRIANGLE_STRIP);
for (j = 0; j < mend; j++) {
glColor4fv(f);
f += 4;
glTexCoord2fv(f);
f += 2;
glVertex3fv(f);
f += 3;
}
glEnd();
}
}
static float
gettime(void)
{
static clock_t told = 0;
clock_t tnew, ris;
tnew = clock();
ris = tnew - told;
told = tnew;
return (ris / (float) CLOCKS_PER_SEC);
}
static void
calcposobs(void)
{
dir[0] = sin(alpha * M_PI / 180.0);
dir[1] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
dir[2] = cos(beta * M_PI / 180.0);
obs[0] += v * dir[0];
obs[1] += v * dir[1];
obs[2] += v * dir[2];
}
static void
special(int k, int x, int y)
{
switch (k) {
case GLUT_KEY_LEFT:
alpha -= 2.0;
break;
case GLUT_KEY_RIGHT:
alpha += 2.0;
break;
case GLUT_KEY_DOWN:
beta -= 2.0;
break;
case GLUT_KEY_UP:
beta += 2.0;
break;
}
}
static void
key(unsigned char k, int x, int y)
{
switch (k) {
case 27:
exit(0);
break;
case 'a':
v += 0.01;
break;
case 'z':
v -= 0.01;
break;
#ifdef XMESA
case ' ':
fullscreen = (!fullscreen);
XMesaSetFXmode(fullscreen ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW);
break;
#endif
case 'j':
joyactive = (!joyactive);
break;
case 'h':
help = (!help);
break;
case 'f':
fog = (!fog);
break;
case 't':
usetex = (!usetex);
break;
case 'b':
if (bfcull) {
glDisable(GL_CULL_FACE);
bfcull = 0;
}
else {
glEnable(GL_CULL_FACE);
bfcull = 1;
}
break;
case 'm':
cstrip = (!cstrip);
break;
case 'd':
fprintf(stderr, "Deleting textures...\n");
glDeleteTextures(1, &t1id);
glDeleteTextures(1, &t2id);
fprintf(stderr, "Loading textures...\n");
inittextures();
fprintf(stderr, "Done.\n");
break;
}
}
static void
reshape(int w, int h)
{
WIDTH = w;
HEIGHT = h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(80.0, w / (float) h, 1.0, 50.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, w, h);
}
static void
printstring(void *font, char *string)
{
int len, i;
len = (int) strlen(string);
for (i = 0; i < len; i++)
glutBitmapCharacter(font, string[i]);
}
static void
printhelp(void)
{
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0.0, 0.0, 0.0, 0.5);
glRecti(40, 40, 600, 440);
glColor3f(1.0, 0.0, 0.0);
glRasterPos2i(300, 420);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "Help");
glRasterPos2i(60, 390);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "h - Togle Help");
glRasterPos2i(60, 360);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "t - Togle Textures");
glRasterPos2i(60, 330);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "f - Togle Fog");
glRasterPos2i(60, 300);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "m - Togle strips");
glRasterPos2i(60, 270);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "b - Togle Back face culling");
glRasterPos2i(60, 240);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "Arrow Keys - Rotate");
glRasterPos2i(60, 210);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "a - Increase velocity");
glRasterPos2i(60, 180);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "z - Decrease velocity");
glRasterPos2i(60, 150);
if (joyavailable)
printstring(GLUT_BITMAP_TIMES_ROMAN_24,
"j - Togle jostick control (Joystick control available)");
else
printstring(GLUT_BITMAP_TIMES_ROMAN_24,
"(No Joystick control available)");
}
static void
dojoy(void)
{
#ifdef WIN32
static UINT max[2] = { 0, 0 };
static UINT min[2] = { 0xffffffff, 0xffffffff }, center[2];
MMRESULT res;
JOYINFO joy;
res = joyGetPos(JOYSTICKID1, &joy);
if (res == JOYERR_NOERROR) {
joyavailable = 1;
if (max[0] < joy.wXpos)
max[0] = joy.wXpos;
if (min[0] > joy.wXpos)
min[0] = joy.wXpos;
center[0] = (max[0] + min[0]) / 2;
if (max[1] < joy.wYpos)
max[1] = joy.wYpos;
if (min[1] > joy.wYpos)
min[1] = joy.wYpos;
center[1] = (max[1] + min[1]) / 2;
if (joyactive) {
if (fabs(center[0] - (float) joy.wXpos) > 0.1 * (max[0] - min[0]))
alpha -=
2.0 * (center[0] - (float) joy.wXpos) / (max[0] - min[0]);
if (fabs(center[1] - (float) joy.wYpos) > 0.1 * (max[1] - min[1]))
beta += 2.0 * (center[1] - (float) joy.wYpos) / (max[1] - min[1]);
if (joy.wButtons & JOY_BUTTON1)
v += 0.01;
if (joy.wButtons & JOY_BUTTON2)
v -= 0.01;
}
}
else
joyavailable = 0;
#endif
}
static void
draw(void)
{
static int count = 0;
static char frbuf[80];
int i;
float fr, base, offset;
dojoy();
glClear(GL_COLOR_BUFFER_BIT);
if (usetex)
glEnable(GL_TEXTURE_2D);
else
glDisable(GL_TEXTURE_2D);
if (fog)
glEnable(GL_FOG);
else
glDisable(GL_FOG);
glShadeModel(GL_SMOOTH);
glPushMatrix();
calcposobs();
gluLookAt(obs[0], obs[1], obs[2],
obs[0] + dir[0], obs[1] + dir[1], obs[2] + dir[2],
0.0, 0.0, 1.0);
if (dir[0] > 0) {
offset = 8.0;
base = obs[0] - fmod(obs[0], 8.0);
}
else {
offset = -8.0;
base = obs[0] + (8.0 - fmod(obs[0], 8.0));
}
glPushMatrix();
glTranslatef(base - offset / 2.0, 0.0, 0.0);
for (i = 0; i < NUMBLOC; i++) {
glTranslatef(offset, 0.0, 0.0);
glBindTexture(GL_TEXTURE_2D, t1id);
drawobjs(striplength_skin_11, stripdata_skin_11);
glBindTexture(GL_TEXTURE_2D, t2id);
drawobjs(striplength_skin_12, stripdata_skin_12);
drawobjs(striplength_skin_9, stripdata_skin_9);
drawobjs(striplength_skin_13, stripdata_skin_13);
}
glPopMatrix();
glPopMatrix();
if ((count % FRAME) == 0) {
fr = gettime();
sprintf(frbuf, "Frame rate: %f", FRAME / fr);
}
glDisable(GL_TEXTURE_2D);
glDisable(GL_FOG);
glShadeModel(GL_FLAT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-0.5, 639.5, -0.5, 479.5, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(1.0, 0.0, 0.0);
glRasterPos2i(10, 10);
printstring(GLUT_BITMAP_HELVETICA_18, frbuf);
glRasterPos2i(350, 470);
printstring(GLUT_BITMAP_HELVETICA_10,
"Tunnel V1.5 Written by David Bucciarelli (tech.hmw@plus.it)");
if (help)
printhelp();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glutSwapBuffers();
count++;
}
int
main(int ac, char **av)
{
float fogcolor[4] = { 0.7, 0.7, 0.7, 1.0 };
fprintf(stderr,
"Tunnel V1.5\nWritten by David Bucciarelli (tech.hmw@plus.it)\n");
glutInitWindowPosition(0, 0);
glutInitWindowSize(WIDTH, HEIGHT);
glutInit(&ac, av);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
if (!(win = glutCreateWindow("Tunnel"))) {
fprintf(stderr, "Error, couldn't open window\n");
return -1;
}
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(80.0, WIDTH / (float) HEIGHT, 1.0, 50.0);
glMatrixMode(GL_MODELVIEW);
glShadeModel(GL_SMOOTH);
glDisable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glEnable(GL_FOG);
glFogi(GL_FOG_MODE, GL_EXP2);
glFogfv(GL_FOG_COLOR, fogcolor);
glFogf(GL_FOG_DENSITY, 0.06);
glHint(GL_FOG_HINT, GL_NICEST);
inittextures();
glClearColor(fogcolor[0], fogcolor[1], fogcolor[2], fogcolor[3]);
glClear(GL_COLOR_BUFFER_BIT);
calcposobs();
glutReshapeFunc(reshape);
glutDisplayFunc(draw);
glutKeyboardFunc(key);
glutSpecialFunc(special);
glutIdleFunc(draw);
glEnable(GL_BLEND);
/*glBlendFunc(GL_SRC_ALPHA_SATURATE,GL_ONE); */
/*glEnable(GL_POLYGON_SMOOTH); */
glutMainLoop();
return 0;
}

View File

@@ -1,616 +0,0 @@
/*
* This program is under the GNU GPL.
* Use at your own risk.
*
* You need TWO Voodoo Graphics boards in order to run
* this demo !
*
* written by David Bucciarelli (tech.hmw@plus.it)
* Humanware s.r.l.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#ifdef WIN32
#include <windows.h>
#endif
#include <GL/glut.h>
#include "../util/readtex.c"
#include "tunneldat.c"
#ifdef FX
#endif
#ifdef XMESA
#include "GL/xmesa.h"
static int fullscreen = 1;
#endif
#ifdef FX
GLboolean fxMesaSelectCurrentBoard(int);
#endif
static int WIDTHC0 = 640;
static int HEIGHTC0 = 480;
static int WIDTHC1 = 640;
static int HEIGHTC1 = 480;
#define FRAME 50
#define NUMBLOC 5
#ifndef M_PI
#define M_PI 3.1415926535
#endif
extern int striplength_skin_13[];
extern float stripdata_skin_13[];
extern int striplength_skin_12[];
extern float stripdata_skin_12[];
extern int striplength_skin_11[];
extern float stripdata_skin_11[];
extern int striplength_skin_9[];
extern float stripdata_skin_9[];
static float obs[3] = { 1000.0, 0.0, 2.0 };
static float dir[3];
static float v = 0.5;
static float alpha = 90.0;
static float beta = 90.0;
static int fog = 0;
static int bfcull = 1;
static int usetex = 1;
static int cstrip = 0;
static int help = 1;
static int joyavailable = 0;
static int joyactive = 0;
static int channel[2];
static GLuint t1id, t2id;
static void
inittextures(void)
{
glGenTextures(1, &t1id);
glBindTexture(GL_TEXTURE_2D, t1id);
if (!LoadRGBMipmaps("../images/tile.rgb", GL_RGB)) {
fprintf(stderr, "Error reading a texture.\n");
exit(-1);
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glGenTextures(1, &t2id);
glBindTexture(GL_TEXTURE_2D, t2id);
if (!LoadRGBMipmaps("../images/bw.rgb", GL_RGB)) {
fprintf(stderr, "Error reading a texture.\n");
exit(-1);
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
static void
drawobjs(int *l, float *f)
{
int mend, j;
if (cstrip) {
float r = 0.33, g = 0.33, b = 0.33;
for (; (*l) != 0;) {
mend = *l++;
r += 0.33;
if (r > 1.0) {
r = 0.33;
g += 0.33;
if (g > 1.0) {
g = 0.33;
b += 0.33;
if (b > 1.0)
b = 0.33;
}
}
glColor3f(r, g, b);
glBegin(GL_TRIANGLE_STRIP);
for (j = 0; j < mend; j++) {
f += 4;
glTexCoord2fv(f);
f += 2;
glVertex3fv(f);
f += 3;
}
glEnd();
}
}
else
for (; (*l) != 0;) {
mend = *l++;
glBegin(GL_TRIANGLE_STRIP);
for (j = 0; j < mend; j++) {
glColor4fv(f);
f += 4;
glTexCoord2fv(f);
f += 2;
glVertex3fv(f);
f += 3;
}
glEnd();
}
}
static float
gettime(void)
{
static clock_t told = 0;
clock_t tnew, ris;
tnew = clock();
ris = tnew - told;
told = tnew;
return (ris / (float) CLOCKS_PER_SEC);
}
static void
calcposobs(void)
{
dir[0] = sin(alpha * M_PI / 180.0);
dir[1] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
dir[2] = cos(beta * M_PI / 180.0);
obs[0] += v * dir[0];
obs[1] += v * dir[1];
obs[2] += v * dir[2];
}
static void
special(int k, int x, int y)
{
switch (k) {
case GLUT_KEY_LEFT:
alpha -= 2.0;
break;
case GLUT_KEY_RIGHT:
alpha += 2.0;
break;
case GLUT_KEY_DOWN:
beta -= 2.0;
break;
case GLUT_KEY_UP:
beta += 2.0;
break;
}
}
static void
key(unsigned char k, int x, int y)
{
switch (k) {
case 27:
exit(0);
break;
case 'a':
v += 0.01;
break;
case 'z':
v -= 0.01;
break;
#ifdef XMESA
case ' ':
fullscreen = (!fullscreen);
glutSetWindow(channel[0]);
XMesaSetFXmode(fullscreen ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW);
glutSetWindow(channel[1]);
XMesaSetFXmode(fullscreen ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW);
break;
#endif
case 'j':
joyactive = (!joyactive);
break;
case 'h':
help = (!help);
break;
case 'f':
fog = (!fog);
break;
case 't':
usetex = (!usetex);
break;
case 'b':
if (bfcull) {
glDisable(GL_CULL_FACE);
bfcull = 0;
}
else {
glEnable(GL_CULL_FACE);
bfcull = 1;
}
break;
case 'm':
cstrip = (!cstrip);
break;
case 'd':
fprintf(stderr, "Deleting textures...\n");
glDeleteTextures(1, &t1id);
glDeleteTextures(1, &t2id);
fprintf(stderr, "Loading textures...\n");
inittextures();
fprintf(stderr, "Done.\n");
break;
}
}
static void
reshapechannel0(int w, int h)
{
float ratio;
WIDTHC0 = w;
HEIGHTC0 = h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
ratio = 0.5f * w / (float) h;
glFrustum(-2.0, 0.0, -1.0 * ratio, 1.0 * ratio, 1.0, 60.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, w, h);
}
static void
reshapechannel1(int w, int h)
{
float ratio;
WIDTHC1 = w;
HEIGHTC1 = h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
ratio = 0.5f * w / (float) h;
glFrustum(0.0, 2.0, -1.0 * ratio, 1.0 * ratio, 1.0, 60.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, w, h);
}
static void
printstring(void *font, char *string)
{
int len, i;
len = (int) strlen(string);
for (i = 0; i < len; i++)
glutBitmapCharacter(font, string[i]);
}
static void
printhelp(void)
{
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0.0, 0.0, 0.0, 0.5);
glRecti(40, 40, 600, 440);
glColor3f(1.0, 0.0, 0.0);
glRasterPos2i(300, 420);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "Help");
glRasterPos2i(60, 390);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "h - Togle Help");
glRasterPos2i(60, 360);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "t - Togle Textures");
glRasterPos2i(60, 330);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "f - Togle Fog");
glRasterPos2i(60, 300);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "m - Togle strips");
glRasterPos2i(60, 270);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "b - Togle Back face culling");
glRasterPos2i(60, 240);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "Arrow Keys - Rotate");
glRasterPos2i(60, 210);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "a - Increase velocity");
glRasterPos2i(60, 180);
printstring(GLUT_BITMAP_TIMES_ROMAN_24, "z - Decrease velocity");
glRasterPos2i(60, 150);
if (joyavailable)
printstring(GLUT_BITMAP_TIMES_ROMAN_24,
"j - Togle jostick control (Joystick control available)");
else
printstring(GLUT_BITMAP_TIMES_ROMAN_24,
"(No Joystick control available)");
}
static void
dojoy(void)
{
#ifdef WIN32
static UINT max[2] = { 0, 0 };
static UINT min[2] = { 0xffffffff, 0xffffffff }, center[2];
MMRESULT res;
JOYINFO joy;
res = joyGetPos(JOYSTICKID1, &joy);
if (res == JOYERR_NOERROR) {
joyavailable = 1;
if (max[0] < joy.wXpos)
max[0] = joy.wXpos;
if (min[0] > joy.wXpos)
min[0] = joy.wXpos;
center[0] = (max[0] + min[0]) / 2;
if (max[1] < joy.wYpos)
max[1] = joy.wYpos;
if (min[1] > joy.wYpos)
min[1] = joy.wYpos;
center[1] = (max[1] + min[1]) / 2;
if (joyactive) {
if (fabs(center[0] - (float) joy.wXpos) > 0.1 * (max[0] - min[0]))
alpha -=
2.0 * (center[0] - (float) joy.wXpos) / (max[0] - min[0]);
if (fabs(center[1] - (float) joy.wYpos) > 0.1 * (max[1] - min[1]))
beta += 2.0 * (center[1] - (float) joy.wYpos) / (max[1] - min[1]);
if (joy.wButtons & JOY_BUTTON1)
v += 0.01;
if (joy.wButtons & JOY_BUTTON2)
v -= 0.01;
}
}
else
joyavailable = 0;
#endif
}
static void
draw(void)
{
static int count = 0;
static char frbuf[80];
int i;
float fr, base, offset;
dojoy();
glClear(GL_COLOR_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT);
if (usetex)
glEnable(GL_TEXTURE_2D);
else
glDisable(GL_TEXTURE_2D);
if (fog)
glEnable(GL_FOG);
else
glDisable(GL_FOG);
glShadeModel(GL_SMOOTH);
glPushMatrix();
calcposobs();
gluLookAt(obs[0], obs[1], obs[2],
obs[0] + dir[0], obs[1] + dir[1], obs[2] + dir[2],
0.0, 0.0, 1.0);
if (dir[0] > 0) {
offset = 8.0;
base = obs[0] - fmod(obs[0], 8.0);
}
else {
offset = -8.0;
base = obs[0] + (8.0 - fmod(obs[0], 8.0));
}
glPushMatrix();
glTranslatef(base - offset / 2.0, 0.0, 0.0);
for (i = 0; i < NUMBLOC; i++) {
glTranslatef(offset, 0.0, 0.0);
glBindTexture(GL_TEXTURE_2D, t1id);
drawobjs(striplength_skin_11, stripdata_skin_11);
glBindTexture(GL_TEXTURE_2D, t2id);
drawobjs(striplength_skin_12, stripdata_skin_12);
drawobjs(striplength_skin_9, stripdata_skin_9);
drawobjs(striplength_skin_13, stripdata_skin_13);
}
glPopMatrix();
glPopMatrix();
if ((count % FRAME) == 0) {
fr = gettime();
sprintf(frbuf, "Frame rate: %f", FRAME / fr);
}
glDisable(GL_TEXTURE_2D);
glDisable(GL_FOG);
glShadeModel(GL_FLAT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-0.5, 639.5, -0.5, 479.5, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(1.0, 0.0, 0.0);
glRasterPos2i(10, 10);
printstring(GLUT_BITMAP_HELVETICA_18, frbuf);
glRasterPos2i(350, 470);
printstring(GLUT_BITMAP_HELVETICA_10,
"Tunnel2 V1.0 Written by David Bucciarelli (tech.hmw@plus.it)");
if (help)
printhelp();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
count++;
}
static void
drawchannel0(void)
{
glutSetWindow(channel[0]);
draw();
glutSwapBuffers();
}
static void
drawchannel1(void)
{
glutSetWindow(channel[1]);
draw();
glutSwapBuffers();
}
static void
drawall(void)
{
glutSetWindow(channel[0]);
draw();
glutSetWindow(channel[1]);
draw();
glutSetWindow(channel[0]);
glutSwapBuffers();
glutSetWindow(channel[1]);
glutSwapBuffers();
}
static void
init(void)
{
float fogcolor[4] = { 0.7, 0.7, 0.7, 1.0 };
glShadeModel(GL_SMOOTH);
glDisable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glEnable(GL_FOG);
glFogi(GL_FOG_MODE, GL_EXP2);
glFogfv(GL_FOG_COLOR, fogcolor);
glFogf(GL_FOG_DENSITY, 0.06);
glHint(GL_FOG_HINT, GL_NICEST);
glEnable(GL_BLEND);
/*
glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE);
glEnable(GL_POLYGON_SMOOTH);
*/
glClearColor(fogcolor[0], fogcolor[1], fogcolor[2], fogcolor[3]);
glClear(GL_COLOR_BUFFER_BIT);
}
int
main(int ac, char **av)
{
fprintf(stderr,
"Tunnel2 V1.0\nWritten by David Bucciarelli (tech.hmw@plus.it)\n");
fprintf(stderr,
"You need TWO Voodoo Graphics boards in order to run this demo !\n");
glutInitWindowPosition(0, 0);
glutInitWindowSize(WIDTHC0, HEIGHTC0);
glutInit(&ac, av);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA);
#ifdef FX
if (!fxMesaSelectCurrentBoard(0)) {
fprintf(stderr, "The first Voodoo Graphics board is missing !?!?\n");
return -1;
}
#endif
if (!(channel[0] = glutCreateWindow("Channel 0"))) {
fprintf(stderr, "Error, couldn't open window\n");
return -1;
}
reshapechannel0(WIDTHC0, HEIGHTC0);
init();
inittextures();
glutDisplayFunc(drawchannel0);
glutReshapeFunc(reshapechannel0);
glutKeyboardFunc(key);
glutSpecialFunc(special);
#ifdef FX
if (!fxMesaSelectCurrentBoard(1)) {
fprintf(stderr, "The second Voodoo Graphics board is missing !\n");
exit(-1);
}
#endif
glutInitWindowPosition(WIDTHC0, 0);
glutInitWindowSize(WIDTHC1, HEIGHTC1);
if (!(channel[1] = glutCreateWindow("Channel 1"))) {
fprintf(stderr, "Error, couldn't open window\n");
exit(-1);
}
reshapechannel1(WIDTHC1, HEIGHTC1);
init();
inittextures();
glutDisplayFunc(drawchannel1);
glutReshapeFunc(reshapechannel1);
glutKeyboardFunc(key);
glutSpecialFunc(special);
glutIdleFunc(drawall);
calcposobs();
glutMainLoop();
return 0;
}

View File

@@ -1,83 +0,0 @@
/* Object: skin_13 */
#if defined(_MSC_VER) && defined(_WIN32)
#pragma warning( disable : 4305 ) /* 'initializing' : truncation from 'const double' to 'float' */
#endif
int striplength_skin_13[]={
10,7,3,5,5,4,4,4,4,5,3,4,5,4,4,4,4,4,4,6,
6,3,6,3,3,3,3,0};
float stripdata_skin_13[]={
0.415686,0.415686,0.415686,1.000000,0.000000,1.500000,2.000000,4.000000,0.000000,0.341176,0.341176,0.341176,1.000000,-0.500000,1.500000,4.000000,4.000000,0.000000,0.545098,0.545098,0.545098,1.000000,0.000000,1.000000,2.000000,4.000000,2.000000,0.435294,0.435294,0.435294,1.000000,-0.500000,1.000000,4.000000,4.000000,2.000000,0.517647,0.517647,0.517647,1.000000,0.000000,0.500000,2.000000,4.000000,4.000000,0.450980,0.450980,0.450980,1.000000,-0.500000,0.500000,4.000000,4.000000,4.000000,0.427451,0.427451,0.427451,1.000000,0.000000,0.000000,2.000000,4.000000,6.000000,0.388235,0.388235,0.388235,1.000000,-0.500000,0.000000,4.000000,4.000000,6.000000,0.356863,0.356863,0.356863,1.000000,0.000000,-0.500000,2.000000,4.000000,8.000000,0.333333,0.333333,0.333333,1.000000,-0.500000,-0.500000,4.000000,4.000000,8.000000,
0.435294,0.435294,0.435294,1.000000,1.500000,1.000000,-4.000000,4.000000,2.000000,0.415686,0.415686,0.415686,1.000000,1.000000,1.500000,-2.000000,4.000000,0.000000,0.545098,0.545098,0.545098,1.000000,1.000000,1.000000,-2.000000,4.000000,2.000000,0.450980,0.450980,0.450980,1.000000,0.500000,1.500000,0.000000,4.000000,0.000000,0.600000,0.600000,0.600000,1.000000,0.500000,1.000000,0.000000,4.000000,2.000000,0.415686,0.415686,0.415686,1.000000,0.000000,1.500000,2.000000,4.000000,0.000000,0.545098,0.545098,0.545098,1.000000,0.000000,1.000000,2.000000,4.000000,2.000000,
0.435294,0.435294,0.435294,1.000000,1.500000,1.000000,-4.000000,4.000000,2.000000,0.341176,0.341176,0.341176,1.000000,1.500000,1.500000,-4.000000,4.000000,0.000000,0.415686,0.415686,0.415686,1.000000,1.000000,1.500000,-2.000000,4.000000,0.000000,
0.356863,0.356863,0.356863,1.000000,0.000000,-0.500000,2.000000,4.000000,8.000000,0.364706,0.364706,0.364706,1.000000,0.500000,-0.500000,0.000000,4.000000,8.000000,0.427451,0.427451,0.427451,1.000000,0.000000,0.000000,2.000000,4.000000,6.000000,0.415686,0.415686,0.415686,1.000000,0.395020,-0.133318,0.420032,4.000000,6.533272,0.423529,0.423529,0.423529,1.000000,0.388550,-0.103582,0.445932,4.000000,6.414327,
0.423529,0.423529,0.423529,1.000000,0.388550,-0.103582,0.445932,4.000000,6.414327,0.427451,0.427451,0.427451,1.000000,0.383423,-0.069344,0.466541,4.000000,6.277375,0.427451,0.427451,0.427451,1.000000,0.000000,0.000000,2.000000,4.000000,6.000000,0.435294,0.435294,0.435294,1.000000,0.380371,-0.034595,0.478689,4.000000,6.138380,0.439216,0.439216,0.439216,1.000000,0.379272,0.000000,0.482673,4.000000,6.000000,
0.407843,0.407843,0.407843,1.000000,0.414673,-0.191394,0.341301,4.000000,6.765576,0.411765,0.411765,0.411765,1.000000,0.403687,-0.162957,0.385368,4.000000,6.651829,0.364706,0.364706,0.364706,1.000000,0.500000,-0.500000,0.000000,4.000000,8.000000,0.415686,0.415686,0.415686,1.000000,0.395020,-0.133318,0.420032,4.000000,6.533272,
0.400000,0.400000,0.400000,1.000000,0.438232,-0.232438,0.247284,4.000000,6.929754,0.403922,0.403922,0.403922,1.000000,0.425171,-0.212276,0.299425,4.000000,6.849104,0.364706,0.364706,0.364706,1.000000,0.500000,-0.500000,0.000000,4.000000,8.000000,0.407843,0.407843,0.407843,1.000000,0.414673,-0.191394,0.341301,4.000000,6.765576,
0.396078,0.396078,0.396078,1.000000,0.467285,-0.260554,0.130636,4.000000,7.042214,0.400000,0.400000,0.400000,1.000000,0.453857,-0.250068,0.184711,4.000000,7.000273,0.364706,0.364706,0.364706,1.000000,0.500000,-0.500000,0.000000,4.000000,8.000000,0.400000,0.400000,0.400000,1.000000,0.438232,-0.232438,0.247284,4.000000,6.929754,
0.396078,0.396078,0.396078,1.000000,0.500000,-0.270672,0.000000,4.000000,7.082688,0.396078,0.396078,0.396078,1.000000,0.482788,-0.267902,0.068730,4.000000,7.071609,0.364706,0.364706,0.364706,1.000000,0.500000,-0.500000,0.000000,4.000000,8.000000,0.396078,0.396078,0.396078,1.000000,0.467285,-0.260554,0.130636,4.000000,7.042214,
0.439216,0.439216,0.439216,1.000000,0.379272,0.000000,0.482673,4.000000,6.000000,0.474510,0.474510,0.474510,1.000000,0.379272,0.180448,0.482673,4.000000,5.278208,0.517647,0.517647,0.517647,1.000000,0.000000,0.500000,2.000000,4.000000,4.000000,0.513726,0.513726,0.513726,1.000000,0.379272,0.360896,0.482673,4.000000,4.556417,0.545098,0.545098,0.545098,1.000000,0.379272,0.500000,0.482673,4.000000,4.000000,
0.545098,0.545098,0.545098,1.000000,0.379272,0.500000,0.482673,4.000000,4.000000,0.545098,0.545098,0.545098,1.000000,0.000000,1.000000,2.000000,4.000000,2.000000,0.517647,0.517647,0.517647,1.000000,0.000000,0.500000,2.000000,4.000000,4.000000,
0.600000,0.600000,0.600000,1.000000,0.500000,1.000000,0.000000,4.000000,2.000000,0.545098,0.545098,0.545098,1.000000,0.000000,1.000000,2.000000,4.000000,2.000000,0.552941,0.552941,0.552941,1.000000,0.379272,0.541344,0.482673,4.000000,3.834625,0.545098,0.545098,0.545098,1.000000,0.379272,0.500000,0.482673,4.000000,4.000000,
0.552941,0.552941,0.552941,1.000000,0.379272,0.541344,0.482673,4.000000,3.834625,0.556863,0.556863,0.556863,1.000000,0.459717,0.541344,0.160891,4.000000,3.834625,0.600000,0.600000,0.600000,1.000000,0.500000,1.000000,0.000000,4.000000,2.000000,0.556863,0.556863,0.556863,1.000000,0.500000,0.541344,0.000000,4.000000,3.834625,0.556863,0.556863,0.556863,1.000000,0.540283,0.541344,-0.160891,4.000000,3.834625,
0.396078,0.396078,0.396078,1.000000,0.517212,-0.267902,-0.068730,4.000000,7.071609,0.396078,0.396078,0.396078,1.000000,0.500000,-0.270672,0.000000,4.000000,7.082688,0.356863,0.356863,0.356863,1.000000,1.000000,-0.500000,-2.000000,4.000000,8.000000,0.364706,0.364706,0.364706,1.000000,0.500000,-0.500000,0.000000,4.000000,8.000000,
0.400000,0.400000,0.400000,1.000000,0.546143,-0.250068,-0.184711,4.000000,7.000273,0.396078,0.396078,0.396078,1.000000,0.532715,-0.260554,-0.130636,4.000000,7.042214,0.356863,0.356863,0.356863,1.000000,1.000000,-0.500000,-2.000000,4.000000,8.000000,0.396078,0.396078,0.396078,1.000000,0.517212,-0.267902,-0.068730,4.000000,7.071609,
0.403922,0.403922,0.403922,1.000000,0.574829,-0.212276,-0.299425,4.000000,6.849104,0.400000,0.400000,0.400000,1.000000,0.561768,-0.232438,-0.247284,4.000000,6.929754,0.356863,0.356863,0.356863,1.000000,1.000000,-0.500000,-2.000000,4.000000,8.000000,0.400000,0.400000,0.400000,1.000000,0.546143,-0.250068,-0.184711,4.000000,7.000273,
0.411765,0.411765,0.411765,1.000000,0.596313,-0.162957,-0.385368,4.000000,6.651829,0.407843,0.407843,0.407843,1.000000,0.585327,-0.191394,-0.341301,4.000000,6.765576,0.356863,0.356863,0.356863,1.000000,1.000000,-0.500000,-2.000000,4.000000,8.000000,0.403922,0.403922,0.403922,1.000000,0.574829,-0.212276,-0.299425,4.000000,6.849104,
0.423529,0.423529,0.423529,1.000000,0.611450,-0.103582,-0.445931,4.000000,6.414327,0.415686,0.415686,0.415686,1.000000,0.604980,-0.133318,-0.420033,4.000000,6.533272,0.356863,0.356863,0.356863,1.000000,1.000000,-0.500000,-2.000000,4.000000,8.000000,0.411765,0.411765,0.411765,1.000000,0.596313,-0.162957,-0.385368,4.000000,6.651829,
0.435294,0.435294,0.435294,1.000000,0.619629,-0.034595,-0.478689,4.000000,6.138380,0.427451,0.427451,0.427451,1.000000,0.616577,-0.069344,-0.466541,4.000000,6.277375,0.356863,0.356863,0.356863,1.000000,1.000000,-0.500000,-2.000000,4.000000,8.000000,0.423529,0.423529,0.423529,1.000000,0.611450,-0.103582,-0.445931,4.000000,6.414327,
0.513726,0.513726,0.513726,1.000000,0.620728,0.360896,-0.482673,4.000000,4.556417,0.474510,0.474510,0.474510,1.000000,0.620728,0.180448,-0.482673,4.000000,5.278208,0.427451,0.427451,0.427451,1.000000,1.000000,0.000000,-2.000000,4.000000,6.000000,0.439216,0.439216,0.439216,1.000000,0.620728,0.000000,-0.482673,4.000000,6.000000,0.356863,0.356863,0.356863,1.000000,1.000000,-0.500000,-2.000000,4.000000,8.000000,0.435294,0.435294,0.435294,1.000000,0.619629,-0.034595,-0.478689,4.000000,6.138380,
0.333333,0.333333,0.333333,1.000000,1.500000,-0.500000,-4.000000,4.000000,8.000000,0.388235,0.388235,0.388235,1.000000,1.500000,0.000000,-4.000000,4.000000,6.000000,0.427451,0.427451,0.427451,1.000000,1.000000,0.000000,-2.000000,4.000000,6.000000,0.517647,0.517647,0.517647,1.000000,1.000000,0.500000,-2.000000,4.000000,4.000000,0.513726,0.513726,0.513726,1.000000,0.620728,0.360896,-0.482673,4.000000,4.556417,0.545098,0.545098,0.545098,1.000000,0.620728,0.500000,-0.482673,4.000000,4.000000,
0.333333,0.333333,0.333333,1.000000,1.500000,-0.500000,-4.000000,4.000000,8.000000,0.427451,0.427451,0.427451,1.000000,1.000000,0.000000,-2.000000,4.000000,6.000000,0.356863,0.356863,0.356863,1.000000,1.000000,-0.500000,-2.000000,4.000000,8.000000,
0.556863,0.556863,0.556863,1.000000,0.540283,0.541344,-0.160891,4.000000,3.834625,0.552941,0.552941,0.552941,1.000000,0.620728,0.541344,-0.482673,4.000000,3.834625,0.545098,0.545098,0.545098,1.000000,1.000000,1.000000,-2.000000,4.000000,2.000000,0.517647,0.517647,0.517647,1.000000,1.000000,0.500000,-2.000000,4.000000,4.000000,0.450980,0.450980,0.450980,1.000000,1.500000,0.500000,-4.000000,4.000000,4.000000,0.388235,0.388235,0.388235,1.000000,1.500000,0.000000,-4.000000,4.000000,6.000000,
0.517647,0.517647,0.517647,1.000000,1.000000,0.500000,-2.000000,4.000000,4.000000,0.552941,0.552941,0.552941,1.000000,0.620728,0.541344,-0.482673,4.000000,3.834625,0.545098,0.545098,0.545098,1.000000,0.620728,0.500000,-0.482673,4.000000,4.000000,
0.450980,0.450980,0.450980,1.000000,1.500000,0.500000,-4.000000,4.000000,4.000000,0.435294,0.435294,0.435294,1.000000,1.500000,1.000000,-4.000000,4.000000,2.000000,0.545098,0.545098,0.545098,1.000000,1.000000,1.000000,-2.000000,4.000000,2.000000,
0.439216,0.439216,0.439216,1.000000,0.379272,0.000000,0.482673,4.000000,6.000000,0.517647,0.517647,0.517647,1.000000,0.000000,0.500000,2.000000,4.000000,4.000000,0.427451,0.427451,0.427451,1.000000,0.000000,0.000000,2.000000,4.000000,6.000000,
0.556863,0.556863,0.556863,1.000000,0.540283,0.541344,-0.160891,4.000000,3.834625,0.545098,0.545098,0.545098,1.000000,1.000000,1.000000,-2.000000,4.000000,2.000000,0.600000,0.600000,0.600000,1.000000,0.500000,1.000000,0.000000,4.000000,2.000000
};
/* Object: skin_12 */
int striplength_skin_12[]={
12,12,12,12,12,0};
float stripdata_skin_12[]={
0.498039,0.498039,0.498039,1.000000,-0.099976,1.500000,-2.400000,-4.000000,-0.000002,0.337255,0.337255,0.337255,1.000000,-0.500000,1.500000,-4.000000,-4.000000,-0.000002,0.568627,0.568627,0.568627,1.000000,-0.099976,1.100000,-2.400000,-4.000000,1.599999,0.341176,0.341176,0.341176,1.000000,-0.500000,1.100000,-4.000000,-4.000000,1.599999,0.498039,0.498039,0.498039,1.000000,-0.099976,0.700000,-2.400000,-4.000000,3.200000,0.325490,0.325490,0.325490,1.000000,-0.500000,0.700000,-4.000000,-4.000000,3.199999,0.352941,0.352941,0.352941,1.000000,-0.099976,0.300000,-2.400000,-4.000000,4.800000,0.282353,0.282353,0.282353,1.000000,-0.500000,0.300000,-4.000000,-4.000000,4.800000,0.282353,0.282353,0.282353,1.000000,-0.099976,-0.100000,-2.400000,-4.000000,6.400001,0.254902,0.254902,0.254902,1.000000,-0.500000,-0.100000,-4.000000,-4.000000,6.400000,0.239216,0.239216,0.239216,1.000000,-0.099976,-0.500000,-2.400000,-4.000000,8.000000,0.227451,0.227451,0.227451,1.000000,-0.500000,-0.500000,-4.000000,-4.000000,8.000000,
0.239216,0.239216,0.239216,1.000000,1.099976,-0.500000,2.400001,-4.000000,8.000000,0.227451,0.227451,0.227451,1.000000,1.500000,-0.500000,4.000002,-4.000000,8.000000,0.282353,0.282353,0.282353,1.000000,1.099976,-0.100000,2.400001,-4.000000,6.400001,0.254902,0.254902,0.254902,1.000000,1.500000,-0.100000,4.000002,-4.000000,6.400001,0.352941,0.352941,0.352941,1.000000,1.099976,0.300000,2.400002,-4.000000,4.800001,0.282353,0.282353,0.282353,1.000000,1.500000,0.300000,4.000002,-4.000000,4.800001,0.498039,0.498039,0.498039,1.000000,1.099976,0.700000,2.400002,-4.000000,3.200000,0.321569,0.321569,0.321569,1.000000,1.500000,0.700000,4.000003,-4.000000,3.200000,0.568627,0.568627,0.568627,1.000000,1.099976,1.100000,2.400002,-4.000000,1.599999,0.341176,0.341176,0.341176,1.000000,1.500000,1.100000,4.000003,-4.000000,1.599999,0.494118,0.494118,0.494118,1.000000,1.099976,1.500000,2.400003,-4.000000,-0.000002,0.337255,0.337255,0.337255,1.000000,1.500000,1.500000,4.000004,-4.000000,-0.000002,
0.639216,0.639216,0.639216,1.000000,0.300049,1.500000,-0.799999,-4.000000,-0.000002,0.498039,0.498039,0.498039,1.000000,-0.099976,1.500000,-2.400000,-4.000000,-0.000002,0.858824,0.858824,0.858824,1.000000,0.300049,1.100000,-0.799999,-4.000000,1.599999,0.568627,0.568627,0.568627,1.000000,-0.099976,1.100000,-2.400000,-4.000000,1.599999,0.686275,0.686275,0.686275,1.000000,0.300049,0.700000,-0.799999,-4.000000,3.200000,0.498039,0.498039,0.498039,1.000000,-0.099976,0.700000,-2.400000,-4.000000,3.200000,0.419608,0.419608,0.419608,1.000000,0.300049,0.300000,-0.800000,-4.000000,4.800000,0.352941,0.352941,0.352941,1.000000,-0.099976,0.300000,-2.400000,-4.000000,4.800000,0.298039,0.298039,0.298039,1.000000,0.300049,-0.100000,-0.800000,-4.000000,6.400001,0.282353,0.282353,0.282353,1.000000,-0.099976,-0.100000,-2.400000,-4.000000,6.400001,0.247059,0.247059,0.247059,1.000000,0.300049,-0.500000,-0.800000,-4.000000,8.000000,0.239216,0.239216,0.239216,1.000000,-0.099976,-0.500000,-2.400000,-4.000000,8.000000,
0.639216,0.639216,0.639216,1.000000,0.699951,1.500000,0.800002,-4.000000,-0.000002,0.639216,0.639216,0.639216,1.000000,0.300049,1.500000,-0.799999,-4.000000,-0.000002,0.858824,0.858824,0.858824,1.000000,0.699951,1.100000,0.800001,-4.000000,1.599999,0.858824,0.858824,0.858824,1.000000,0.300049,1.100000,-0.799999,-4.000000,1.599999,0.686275,0.686275,0.686275,1.000000,0.699951,0.700000,0.800001,-4.000000,3.200000,0.686275,0.686275,0.686275,1.000000,0.300049,0.700000,-0.799999,-4.000000,3.200000,0.419608,0.419608,0.419608,1.000000,0.699951,0.300000,0.800001,-4.000000,4.800001,0.419608,0.419608,0.419608,1.000000,0.300049,0.300000,-0.800000,-4.000000,4.800000,0.298039,0.298039,0.298039,1.000000,0.699951,-0.100000,0.800001,-4.000000,6.400001,0.298039,0.298039,0.298039,1.000000,0.300049,-0.100000,-0.800000,-4.000000,6.400001,0.247059,0.247059,0.247059,1.000000,0.699951,-0.500000,0.800000,-4.000000,8.000000,0.247059,0.247059,0.247059,1.000000,0.300049,-0.500000,-0.800000,-4.000000,8.000000,
0.494118,0.494118,0.494118,1.000000,1.099976,1.500000,2.400003,-4.000000,-0.000002,0.639216,0.639216,0.639216,1.000000,0.699951,1.500000,0.800002,-4.000000,-0.000002,0.568627,0.568627,0.568627,1.000000,1.099976,1.100000,2.400002,-4.000000,1.599999,0.858824,0.858824,0.858824,1.000000,0.699951,1.100000,0.800001,-4.000000,1.599999,0.498039,0.498039,0.498039,1.000000,1.099976,0.700000,2.400002,-4.000000,3.200000,0.686275,0.686275,0.686275,1.000000,0.699951,0.700000,0.800001,-4.000000,3.200000,0.352941,0.352941,0.352941,1.000000,1.099976,0.300000,2.400002,-4.000000,4.800001,0.419608,0.419608,0.419608,1.000000,0.699951,0.300000,0.800001,-4.000000,4.800001,0.282353,0.282353,0.282353,1.000000,1.099976,-0.100000,2.400001,-4.000000,6.400001,0.298039,0.298039,0.298039,1.000000,0.699951,-0.100000,0.800001,-4.000000,6.400001,0.239216,0.239216,0.239216,1.000000,1.099976,-0.500000,2.400001,-4.000000,8.000000,0.247059,0.247059,0.247059,1.000000,0.699951,-0.500000,0.800000,-4.000000,8.000000
};
/* Object: skin_11 */
int striplength_skin_11[]={
12,12,12,12,12,0};
float stripdata_skin_11[]={
0.145098,0.145098,0.145098,1.000000,-0.099976,1.500000,-2.400000,4.000002,0.000000,0.141176,0.141176,0.141176,1.000000,-0.500000,1.500000,-4.000000,4.000002,0.000000,0.176471,0.176471,0.176471,1.000000,-0.099976,1.100000,-2.400000,2.400001,0.000000,0.145098,0.145098,0.145098,1.000000,-0.500000,1.100000,-4.000000,2.400001,0.000000,0.341176,0.341176,0.341176,1.000000,-0.099976,0.700000,-2.400000,0.800000,0.000000,0.188235,0.188235,0.188235,1.000000,-0.500000,0.700000,-4.000000,0.800000,0.000000,0.450980,0.450980,0.450980,1.000000,-0.099976,0.300000,-2.400000,-0.800000,0.000000,0.247059,0.247059,0.247059,1.000000,-0.500000,0.300000,-4.000000,-0.800000,0.000000,0.439216,0.439216,0.439216,1.000000,-0.099976,-0.100000,-2.400000,-2.400000,0.000000,0.270588,0.270588,0.270588,1.000000,-0.500000,-0.100000,-4.000000,-2.400000,0.000000,0.364706,0.364706,0.364706,1.000000,-0.099976,-0.500000,-2.400000,-4.000000,0.000000,0.258824,0.258824,0.258824,1.000000,-0.500000,-0.500000,-4.000000,-4.000000,0.000000,
0.364706,0.364706,0.364706,1.000000,1.099976,-0.500000,2.400001,-4.000000,0.000000,0.258824,0.258824,0.258824,1.000000,1.500000,-0.500000,4.000002,-4.000000,0.000000,0.439216,0.439216,0.439216,1.000000,1.099976,-0.100000,2.400001,-2.400001,0.000000,0.270588,0.270588,0.270588,1.000000,1.500000,-0.100000,4.000002,-2.400001,0.000000,0.454902,0.454902,0.454902,1.000000,1.099976,0.300000,2.400002,-0.800000,0.000000,0.247059,0.247059,0.247059,1.000000,1.500000,0.300000,4.000002,-0.800000,0.000000,0.341176,0.341176,0.341176,1.000000,1.099976,0.700000,2.400002,0.800000,0.000000,0.184314,0.184314,0.184314,1.000000,1.500000,0.700000,4.000003,0.800000,0.000000,0.176471,0.176471,0.176471,1.000000,1.099976,1.100000,2.400002,2.400001,0.000000,0.145098,0.145098,0.145098,1.000000,1.500000,1.100000,4.000003,2.400001,0.000000,0.145098,0.145098,0.145098,1.000000,1.099976,1.500000,2.400003,4.000003,0.000000,0.141176,0.141176,0.141176,1.000000,1.500000,1.500000,4.000004,4.000002,0.000000,
0.145098,0.145098,0.145098,1.000000,0.300049,1.500000,-0.799999,4.000002,0.000000,0.145098,0.145098,0.145098,1.000000,-0.099976,1.500000,-2.400000,4.000002,0.000000,0.262745,0.262745,0.262745,1.000000,0.300049,1.100000,-0.799999,2.400001,0.000000,0.176471,0.176471,0.176471,1.000000,-0.099976,1.100000,-2.400000,2.400001,0.000000,0.580392,0.580392,0.580392,1.000000,0.300049,0.700000,-0.799999,0.800000,0.000000,0.341176,0.341176,0.341176,1.000000,-0.099976,0.700000,-2.400000,0.800000,0.000000,0.709804,0.709804,0.709804,1.000000,0.300049,0.300000,-0.800000,-0.800000,0.000000,0.450980,0.450980,0.450980,1.000000,-0.099976,0.300000,-2.400000,-0.800000,0.000000,0.627451,0.627451,0.627451,1.000000,0.300049,-0.100000,-0.800000,-2.400001,0.000000,0.439216,0.439216,0.439216,1.000000,-0.099976,-0.100000,-2.400000,-2.400000,0.000000,0.458824,0.458824,0.458824,1.000000,0.300049,-0.500000,-0.800000,-4.000000,0.000000,0.364706,0.364706,0.364706,1.000000,-0.099976,-0.500000,-2.400000,-4.000000,0.000000,
0.145098,0.145098,0.145098,1.000000,0.699951,1.500000,0.800002,4.000002,0.000000,0.145098,0.145098,0.145098,1.000000,0.300049,1.500000,-0.799999,4.000002,0.000000,0.262745,0.262745,0.262745,1.000000,0.699951,1.100000,0.800001,2.400001,0.000000,0.262745,0.262745,0.262745,1.000000,0.300049,1.100000,-0.799999,2.400001,0.000000,0.580392,0.580392,0.580392,1.000000,0.699951,0.700000,0.800001,0.800000,0.000000,0.580392,0.580392,0.580392,1.000000,0.300049,0.700000,-0.799999,0.800000,0.000000,0.713726,0.713726,0.713726,1.000000,0.699951,0.300000,0.800001,-0.800000,0.000000,0.709804,0.709804,0.709804,1.000000,0.300049,0.300000,-0.800000,-0.800000,0.000000,0.631373,0.631373,0.631373,1.000000,0.699951,-0.100000,0.800001,-2.400001,0.000000,0.627451,0.627451,0.627451,1.000000,0.300049,-0.100000,-0.800000,-2.400001,0.000000,0.458824,0.458824,0.458824,1.000000,0.699951,-0.500000,0.800000,-4.000000,0.000000,0.458824,0.458824,0.458824,1.000000,0.300049,-0.500000,-0.800000,-4.000000,0.000000,
0.145098,0.145098,0.145098,1.000000,1.099976,1.500000,2.400003,4.000003,0.000000,0.145098,0.145098,0.145098,1.000000,0.699951,1.500000,0.800002,4.000002,0.000000,0.176471,0.176471,0.176471,1.000000,1.099976,1.100000,2.400002,2.400001,0.000000,0.262745,0.262745,0.262745,1.000000,0.699951,1.100000,0.800001,2.400001,0.000000,0.341176,0.341176,0.341176,1.000000,1.099976,0.700000,2.400002,0.800000,0.000000,0.580392,0.580392,0.580392,1.000000,0.699951,0.700000,0.800001,0.800000,0.000000,0.454902,0.454902,0.454902,1.000000,1.099976,0.300000,2.400002,-0.800000,0.000000,0.713726,0.713726,0.713726,1.000000,0.699951,0.300000,0.800001,-0.800000,0.000000,0.439216,0.439216,0.439216,1.000000,1.099976,-0.100000,2.400001,-2.400001,0.000000,0.631373,0.631373,0.631373,1.000000,0.699951,-0.100000,0.800001,-2.400001,0.000000,0.364706,0.364706,0.364706,1.000000,1.099976,-0.500000,2.400001,-4.000000,0.000000,0.458824,0.458824,0.458824,1.000000,0.699951,-0.500000,0.800000,-4.000000,0.000000
};
/* Object: skin_9 */
int striplength_skin_9[]={
18,0};
float stripdata_skin_9[]={
0.384314,0.384314,0.384314,1.000000,-0.500000,1.500000,-4.000000,4.000000,8.000000,0.384314,0.384314,0.384314,1.000000,1.500000,1.500000,4.000000,4.000000,8.000000,0.376471,0.376471,0.376471,1.000000,-0.500000,1.250000,-4.000000,3.695518,9.530733,0.403922,0.403922,0.403922,1.000000,1.500000,1.250000,4.000000,3.695518,9.530733,0.415686,0.415686,0.415686,1.000000,-0.500000,1.000000,-4.000000,2.828427,10.828427,0.431373,0.431373,0.431373,1.000000,1.500000,1.000000,4.000000,2.828427,10.828427,0.435294,0.435294,0.435294,1.000000,-0.500000,0.750000,-4.000000,1.530734,11.695518,0.443137,0.443137,0.443137,1.000000,1.500000,0.750000,4.000000,1.530734,11.695518,0.439216,0.439216,0.439216,1.000000,-0.500000,0.500000,-4.000000,0.000000,12.000000,0.435294,0.435294,0.435294,1.000000,1.500000,0.500000,4.000000,0.000000,12.000000,0.427451,0.427451,0.427451,1.000000,-0.500000,0.250000,-4.000000,-1.530734,11.695518,0.411765,0.411765,0.411765,1.000000,1.500000,0.250000,4.000000,-1.530734,11.695518,0.396078,0.396078,0.396078,1.000000,-0.500000,0.000000,-4.000000,-2.828427,10.828427,0.368627,0.368627,0.368627,1.000000,1.500000,0.000000,4.000000,-2.828427,10.828427,0.341176,0.341176,0.341176,1.000000,-0.500000,-0.250000,-4.000000,-3.695518,9.530733,0.301961,0.301961,0.301961,1.000000,1.500000,-0.250000,4.000000,-3.695518,9.530733,0.294118,0.294118,0.294118,1.000000,-0.500000,-0.500000,-4.000000,-4.000000,8.000000,0.294118,0.294118,0.294118,1.000000,1.500000,-0.500000,4.000000,-4.000000,8.000000
};

View File

@@ -1,4 +1,4 @@
/* $Id: winpos.c,v 1.2 2000/06/27 17:04:43 brianp Exp $ */
/* $Id: winpos.c,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
/*
* Example of how to use the GL_MESA_window_pos extension.
@@ -8,11 +8,8 @@
/*
* $Log: winpos.c,v $
* Revision 1.2 2000/06/27 17:04:43 brianp
* fixed compiler warnings
*
* Revision 1.1.1.1 1999/08/19 00:55:40 jtg
* Imported sources
* Revision 1.1 1999/08/19 00:55:40 jtg
* Initial revision
*
* Revision 3.3 1999/03/28 18:24:37 brianp
* minor clean-up
@@ -33,7 +30,6 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#define GL_GLEXT_LEGACY
#include "GL/glut.h"
#include "../util/readtex.c" /* a hack, I know */

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -219,3 +219,4 @@ NormalProgramTarget(xfont,xfont.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter
DependTarget()


View File

@@ -1,4 +1,4 @@
# $Id: Makefile.X11,v 1.3 2000/02/16 01:09:06 brianp Exp $
# $Id: Makefile.X11,v 1.2 1999/10/27 10:09:53 brianp Exp $
# Mesa 3-D graphics library
# Version: 3.1
@@ -12,7 +12,7 @@
INCDIR = ../include
LIBDIR = ../lib
GL_LIBS = -L$(LIBDIR) -lglut -lGLU -lGL $(APP_LIB_DEPS)
GL_LIBS = -L$(LIBDIR) -lglut -lGLU -lGL $(XLIBS)
LIB_DEP = $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(GLU_LIB) $(LIBDIR)/$(GLUT_LIB)

View File

@@ -47,14 +47,11 @@
#ifdef GL_VERSION_1_1
GLuint list;
GLint fill = 1;
GLfloat spinx = 0;
GLfloat spiny = 0;
GLint spinx = 0;
GLint spiny = 0;
GLfloat tdist = 0.0;
GLfloat polyfactor = 1.0;
GLfloat polyunits = 1.0;
GLboolean doubleBuffer;
/* display() draws two spheres, one with a gray, diffuse material,
* the other sphere with a magenta material with a specular highlight.
@@ -73,34 +70,22 @@ void display (void)
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, gray);
glMaterialfv(GL_FRONT, GL_SPECULAR, black);
glMaterialf(GL_FRONT, GL_SHININESS, 0.0);
if (fill) {
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(polyfactor, polyunits);
glCallList (list);
glDisable(GL_POLYGON_OFFSET_FILL);
}
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(polyfactor, polyunits);
glCallList (list);
glDisable(GL_POLYGON_OFFSET_FILL);
glDisable(GL_LIGHTING);
glDisable(GL_LIGHT0);
glColor3f (1.0, 1.0, 1.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glPolygonOffset(-polyfactor, -polyunits);
if (!fill) glEnable(GL_POLYGON_OFFSET_LINE);
glCallList (list);
glDisable(GL_POLYGON_OFFSET_LINE);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
if (!fill) {
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glCallList (list);
}
glPopMatrix ();
glFlush ();
if (doubleBuffer) glutSwapBuffers();
}
/* specify initial properties
@@ -145,32 +130,6 @@ void reshape(int width, int height)
gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}
static void Benchmark( float xdiff, float ydiff )
{
int startTime, endTime;
int draws;
double seconds, fps, triPerSecond;
printf("Benchmarking...\n");
draws = 0;
startTime = glutGet(GLUT_ELAPSED_TIME);
spinx = spiny = 0.0;
do {
spinx += xdiff;
spiny += ydiff;
display();
draws++;
endTime = glutGet(GLUT_ELAPSED_TIME);
} while (endTime - startTime < 5000); /* 5 seconds */
/* Results */
seconds = (double) (endTime - startTime) / 1000.0;
fps = draws / seconds;
printf("Result: fps: %g\n", fps);
}
/* call when mouse button is pressed */
/* ARGSUSED2 */
void mouse(int button, int state, int x, int y) {
@@ -178,7 +137,7 @@ void mouse(int button, int state, int x, int y) {
case GLUT_LEFT_BUTTON:
switch (state) {
case GLUT_DOWN:
spinx += 5;
spinx = (spinx + 5) % 360;
glutPostRedisplay();
break;
default:
@@ -188,7 +147,7 @@ void mouse(int button, int state, int x, int y) {
case GLUT_MIDDLE_BUTTON:
switch (state) {
case GLUT_DOWN:
spiny += 5;
spiny = (spiny + 5) % 360;
glutPostRedisplay();
break;
default:
@@ -245,20 +204,6 @@ void keyboard (unsigned char key, int x, int y)
printf ("polyunits is %f\n", polyunits);
glutPostRedisplay();
break;
case 'b':
Benchmark(5.0, 0);
break;
case 'B':
Benchmark(0, 5.0);
break;
case ' ':
fill = !fill;
printf ("fill/line: %d\n", fill);
glutPostRedisplay();
break;
case 27: /* Escape */
exit(0);
break;
default:
break;
}
@@ -277,47 +222,21 @@ key(unsigned char k, int x, int y)
glutPostRedisplay();
}
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 {
printf("%s (Bad option).\n", argv[i]);
return GL_FALSE;
}
}
return GL_TRUE;
}
/* Main Loop
* Open window with initial window size, title bar,
* RGBA display mode, and handle input events.
*/
int main(int argc, char** argv)
{
GLuint type;
glutInit(&argc, argv);
Args(argc, argv);
type = GLUT_DEPTH | GLUT_RGB;
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
glutInitDisplayMode(type);
glutCreateWindow("polyoff");
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow(argv[0]);
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutKeyboardFunc(keyboard);
gfxinit();
glutKeyboardFunc(key);
glutMainLoop();
return 0;
}

View File

@@ -64,30 +64,30 @@ GLuint list;
void makeNewLists (void) {
int i;
static GLdouble rects[12][3] =
{{ 50.0, 50.0, 0.0}, {300.0, 50.0, 0.0},
{300.0, 300.0, 0.0}, { 50.0, 300.0, 0.0},
{100.0, 100.0, 0.0}, {250.0, 100.0, 0.0},
{250.0, 250.0, 0.0}, {100.0, 250.0, 0.0},
{150.0, 150.0, 0.0}, {200.0, 150.0, 0.0},
{200.0, 200.0, 0.0}, {150.0, 200.0, 0.0}};
{50.0, 50.0, 0.0, 300.0, 50.0, 0.0,
300.0, 300.0, 0.0, 50.0, 300.0, 0.0,
100.0, 100.0, 0.0, 250.0, 100.0, 0.0,
250.0, 250.0, 0.0, 100.0, 250.0, 0.0,
150.0, 150.0, 0.0, 200.0, 150.0, 0.0,
200.0, 200.0, 0.0, 150.0, 200.0, 0.0};
static GLdouble spiral[16][3] =
{{400.0, 250.0, 0.0}, {400.0, 50.0, 0.0},
{ 50.0, 50.0, 0.0}, { 50.0, 400.0, 0.0},
{350.0, 400.0, 0.0}, {350.0, 100.0, 0.0},
{100.0, 100.0, 0.0}, {100.0, 350.0, 0.0},
{300.0, 350.0, 0.0}, {300.0, 150.0, 0.0},
{150.0, 150.0, 0.0}, {150.0, 300.0, 0.0},
{250.0, 300.0, 0.0}, {250.0, 200.0, 0.0},
{200.0, 200.0, 0.0}, {200.0, 250.0, 0.0}};
{400.0, 250.0, 0.0, 400.0, 50.0, 0.0,
50.0, 50.0, 0.0, 50.0, 400.0, 0.0,
350.0, 400.0, 0.0, 350.0, 100.0, 0.0,
100.0, 100.0, 0.0, 100.0, 350.0, 0.0,
300.0, 350.0, 0.0, 300.0, 150.0, 0.0,
150.0, 150.0, 0.0, 150.0, 300.0, 0.0,
250.0, 300.0, 0.0, 250.0, 200.0, 0.0,
200.0, 200.0, 0.0, 200.0, 250.0, 0.0};
static GLdouble quad1[4][3] =
{{ 50.0, 150.0, 0.0}, {350.0, 150.0, 0.0},
{350.0, 200.0, 0.0}, { 50.0, 200.0, 0.0}};
{50.0, 150.0, 0.0, 350.0, 150.0, 0.0,
350.0, 200.0, 0.0, 50.0, 200.0, 0.0};
static GLdouble quad2[4][3] =
{{100.0, 100.0, 0.0}, {300.0, 100.0, 0.0},
{300.0, 350.0, 0.0}, {100.0, 350.0, 0.0}};
{100.0, 100.0, 0.0, 300.0, 100.0, 0.0,
300.0, 350.0, 0.0, 100.0, 350.0, 0.0};
static GLdouble tri[3][3] =
{{200.0, 50.0, 0.0}, {250.0, 300.0, 0.0},
{150.0, 300.0, 0.0}};
{200.0, 50.0, 0.0, 250.0, 300.0, 0.0,
150.0, 300.0, 0.0};
gluTessProperty(tobj, GLU_TESS_WINDING_RULE,
currentWinding);

View File

@@ -99,3 +99,4 @@ NormalProgramTarget(wave,wave.o,NullParameter,$(LOCAL_LIBRARIES),NullParameter)
DependTarget()


View File

@@ -1,18 +1,20 @@
# $Id: Makefile.X11,v 1.3 2000/02/16 01:09:06 brianp Exp $
# $Id: Makefile.X11,v 1.2 1999/10/27 10:09:53 brianp Exp $
# Mesa 3-D graphics library
# Version: 3.3
# Version: 3.1
# Copyright (C) 1995-1999 Brian Paul
# Makefile for assorted SGI OpenGL demos
##### MACROS #####
INCDIR = ../include
LIBDIR = ../lib
GL_LIBS = -L$(LIBDIR) -lglut -lGLU -lGL $(APP_LIB_DEPS)
GL_LIBS = -L$(LIBDIR) -lglut -lGLU -lGL $(XLIBS)
LIB_DEP = $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(GLU_LIB) $(LIBDIR)/$(GLUT_LIB)
@@ -21,6 +23,7 @@ PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
shape sphere star stencil stretch texture tri wave
##### RULES #####
.SUFFIXES:

View File

@@ -1,4 +1,4 @@
/* $Id: logo.c,v 1.2 1999/12/15 13:02:09 brianp Exp $ */
/* $Id: logo.c,v 1.1 1999/08/19 00:55:41 jtg Exp $ */
/*
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
@@ -108,16 +108,16 @@ GLubyte *image = checkImage;
GLint imageHeight = CHECKIMAGEHEIGHT;
GLint imageWidth = CHECKIMAGEWIDTH;
static float decal[] = {
float decal[] = {
GL_DECAL,
};
static float modulate[] = {
float modulate[] = {
GL_MODULATE,
};
static float repeat[] = {
float repeat[] = {
GL_REPEAT,
};
static float nearest[] = {
float nearest[] = {
GL_NEAREST,
};

View File

@@ -12,7 +12,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "readtex.h"
#ifndef SEEK_SET
@@ -266,15 +265,6 @@ static void FreeImage( TK_RGBImageRec *image )
* Return: GL_TRUE if success, GL_FALSE if error.
*/
GLboolean LoadRGBMipmaps( const char *imageFile, GLint intFormat )
{
GLint w, h;
return LoadRGBMipmaps2( imageFile, GL_TEXTURE_2D, intFormat, &w, &h );
}
GLboolean LoadRGBMipmaps2( const char *imageFile, GLenum target,
GLint intFormat, GLint *width, GLint *height )
{
GLint error;
GLenum format;
@@ -299,18 +289,14 @@ GLboolean LoadRGBMipmaps2( const char *imageFile, GLenum target,
return GL_FALSE;
}
error = gluBuild2DMipmaps( target,
error = gluBuild2DMipmaps( GL_TEXTURE_2D,
intFormat,
image->sizeX, image->sizeY,
format,
GL_UNSIGNED_BYTE,
image->data );
*width = image->sizeX;
*height = image->sizeY;
FreeImage(image);
return error ? GL_FALSE : GL_TRUE;
}

View File

@@ -1,24 +0,0 @@
/* readtex.h */
#ifndef READTEX_H
#define READTEX_H
#include <GL/gl.h>
extern GLboolean
LoadRGBMipmaps( const char *imageFile, GLint intFormat );
extern GLboolean
LoadRGBMipmaps2( const char *imageFile, GLenum target,
GLint intFormat, GLint *width, GLint *height );
extern GLubyte *
LoadRGBImage( const char *imageFile,
GLint *width, GLint *height, GLenum *format );
#endif

View File

@@ -1,8 +1,8 @@
# $Id: Makefile.X11,v 1.10 2000/07/20 20:12:17 brianp Exp $
# $Id: Makefile.X11,v 1.4.2.1 1999/11/12 15:43:25 brianp Exp $
# Mesa 3-D graphics library
# Version: 3.3
# Copyright (C) 1995-2000 Brian Paul
# Version: 3.1
# Copyright (C) 1995-1999 Brian Paul
# Makefile for non-GLUT (X11, SVGA, etc) demo programs
@@ -12,20 +12,11 @@
INCDIR = ../include
LIBDIR = ../lib
GL_LIBS = -L$(LIBDIR) -lglut -lGLU -lGL $(APP_LIB_DEPS)
GL_LIBS = -L$(LIBDIR) -lglut -lGLU -lGL $(XLIBS)
LIB_DEP = $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(GLU_LIB) $(LIBDIR)/$(GLUT_LIB)
PROGS = glthreads \
glxdemo \
glxheads \
glxinfo \
glxpixmap \
manywin \
offset \
wincopy \
xdemo \
xfont
PROGS = glxdemo glxpixmap offset xdemo glxinfo xfont glxdpyinfo

View File

@@ -1,420 +0,0 @@
/* $Id: glthreads.c,v 1.1 2000/07/20 20:12:17 brianp Exp $ */
/*
* Copyright (C) 2000 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* This program tests GLX thread safety.
* Command line options:
* -n <num threads> Number of threads to create (default is 2)
* -display <display name> Specify X display (default is :0.0)
*
* Brian Paul 20 July 2000
*/
#if defined(PTHREADS) /* defined by Mesa on Linux and other platforms */
#include <GL/gl.h>
#include <GL/glx.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
/*
* Each window/thread/context:
*/
struct winthread {
Display *Dpy;
int Index;
pthread_t Thread;
Window Win;
GLXContext Context;
float Angle;
int WinWidth, WinHeight;
GLboolean NewSize;
};
#define MAX_WINTHREADS 100
static struct winthread WinThreads[MAX_WINTHREADS];
static int NumWinThreads = 0;
static GLboolean ExitFlag = GL_FALSE;
static void
Error(const char *msg)
{
fprintf(stderr, "Error: %s\n", msg);
exit(1);
}
/* draw a colored cube */
static void
draw_object(void)
{
glPushMatrix();
glScalef(0.75, 0.75, 0.75);
glColor3f(1, 0, 0);
glBegin(GL_POLYGON);
glVertex3f(1, -1, -1);
glVertex3f(1, 1, -1);
glVertex3f(1, 1, 1);
glVertex3f(1, -1, 1);
glEnd();
glColor3f(0, 1, 1);
glBegin(GL_POLYGON);
glVertex3f(-1, -1, -1);
glVertex3f(-1, 1, -1);
glVertex3f(-1, 1, 1);
glVertex3f(-1, -1, 1);
glEnd();
glColor3f(0, 1, 0);
glBegin(GL_POLYGON);
glVertex3f(-1, 1, -1);
glVertex3f( 1, 1, -1);
glVertex3f( 1, 1, 1);
glVertex3f(-1, 1, 1);
glEnd();
glColor3f(1, 0, 1);
glBegin(GL_POLYGON);
glVertex3f(-1, -1, -1);
glVertex3f( 1, -1, -1);
glVertex3f( 1, -1, 1);
glVertex3f(-1, -1, 1);
glEnd();
glColor3f(0, 0, 1);
glBegin(GL_POLYGON);
glVertex3f(-1, -1, 1);
glVertex3f( 1, -1, 1);
glVertex3f( 1, 1, 1);
glVertex3f(-1, 1, 1);
glEnd();
glColor3f(1, 1, 0);
glBegin(GL_POLYGON);
glVertex3f(-1, -1, -1);
glVertex3f( 1, -1, -1);
glVertex3f( 1, 1, -1);
glVertex3f(-1, 1, -1);
glEnd();
glPopMatrix();
}
/* signal resize of given window */
static void
resize(struct winthread *wt, int w, int h)
{
wt->NewSize = GL_TRUE;
wt->WinWidth = w;
wt->WinHeight = h;
}
/*
* We have an instance of this for each thread.
*/
static void
draw_loop(struct winthread *wt)
{
while (!ExitFlag) {
glXMakeCurrent(wt->Dpy, wt->Win, wt->Context);
glEnable(GL_DEPTH_TEST);
if (wt->NewSize) {
GLfloat w = (float) wt->WinWidth / (float) wt->WinHeight;
glViewport(0, 0, wt->WinWidth, wt->WinHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-w, w, -1.0, 1.0, 1.5, 10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2.5);
wt->NewSize = GL_FALSE;
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(wt->Angle, 0, 0, 1);
glRotatef(wt->Angle, 1, 0, 0);
glScalef(0.7, 0.7, 0.7);
draw_object();
glPopMatrix();
glXSwapBuffers(wt->Dpy, wt->Win);
wt->Angle += 1.0;
}
}
/*
* The main process thread runs this loop.
*/
static void
event_loop(Display *dpy)
{
while (!ExitFlag) {
static long mask = StructureNotifyMask | ExposureMask | KeyPressMask;
XEvent event;
int i;
for (i = 0; i < NumWinThreads; i++) {
struct winthread *wt = &WinThreads[i];
while (XCheckWindowEvent(dpy, wt->Win, mask, &event)) {
if (event.xany.window == wt->Win) {
switch (event.type) {
case ConfigureNotify:
resize(wt, event.xconfigure.width,
event.xconfigure.height);
break;
case KeyPress:
/* tell all threads to exit */
ExitFlag = GL_TRUE;
/*printf("exit draw_loop %d\n", wt->Index);*/
return;
default:
/*no-op*/ ;
}
}
else {
printf("window mismatch\n");
}
}
}
}
}
/*
* we'll call this once for each thread, before the threads are created.
*/
static void
create_window(struct winthread *wt)
{
Window win;
GLXContext ctx;
int attrib[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DEPTH_SIZE, 1,
GLX_DOUBLEBUFFER,
None };
int scrnum;
XSetWindowAttributes attr;
unsigned long mask;
Window root;
XVisualInfo *visinfo;
int width = 80, height = 80;
int xpos = (wt->Index % 10) * 90;
int ypos = (wt->Index / 10) * 100;
scrnum = DefaultScreen(wt->Dpy);
root = RootWindow(wt->Dpy, scrnum);
visinfo = glXChooseVisual(wt->Dpy, scrnum, attrib);
if (!visinfo) {
Error("Unable to find RGB, Z, double-buffered visual");
}
/* window attributes */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap(wt->Dpy, root, visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow(wt->Dpy, root, xpos, ypos, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr);
if (!win) {
Error("Couldn't create window");
}
{
XSizeHints sizehints;
sizehints.x = xpos;
sizehints.y = ypos;
sizehints.width = width;
sizehints.height = height;
sizehints.flags = USSize | USPosition;
XSetNormalHints(wt->Dpy, win, &sizehints);
XSetStandardProperties(wt->Dpy, win, "glthreads", "glthreads",
None, (char **)NULL, 0, &sizehints);
}
ctx = glXCreateContext(wt->Dpy, visinfo, NULL, True);
if (!ctx) {
Error("Couldn't create GLX context");
}
XMapWindow(wt->Dpy, win);
XSync(wt->Dpy, 0);
/* save the info for this window/context */
wt->Win = win;
wt->Context = ctx;
wt->Angle = 0.0;
wt->WinWidth = width;
wt->WinHeight = height;
wt->NewSize = GL_TRUE;
}
/*
* Called by pthread_create()
*/
static void *
thread_function(void *p)
{
struct winthread *wt = (struct winthread *) p;
draw_loop(wt);
return NULL;
}
/*
* called before exit to wait for all threads to finish
*/
static void
clean_up(void)
{
int i;
/* wait for threads to finish */
for (i = 0; i < NumWinThreads; i++) {
pthread_join(WinThreads[i].Thread, NULL);
}
for (i = 0; i < NumWinThreads; i++) {
glXDestroyContext(WinThreads[i].Dpy, WinThreads[i].Context);
XDestroyWindow(WinThreads[i].Dpy, WinThreads[i].Win);
}
}
int
main(int argc, char *argv[])
{
char *displayName = ":0.0";
int numThreads = 2;
Display *dpy;
int i;
Status threadStat;
if (argc == 1) {
printf("threadgl: test of GL thread safety (any key = exit)\n");
printf("Usage:\n");
printf(" threadgl [-display dpyName] [-n numthreads]\n");
}
else {
int i;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-display") == 0 && i + 1 < argc) {
displayName = argv[i + 1];
i++;
}
else if (strcmp(argv[i], "-n") == 0 && i + 1 < argc) {
numThreads = atoi(argv[i + 1]);
if (numThreads < 1)
numThreads = 1;
else if (numThreads > MAX_WINTHREADS)
numThreads = MAX_WINTHREADS;
i++;
}
}
}
/*
* VERY IMPORTANT: call XInitThreads() before any other Xlib functions.
*/
threadStat = XInitThreads();
if (threadStat) {
printf("XInitThreads() returned %d (success)\n", (int) threadStat);
}
else {
printf("XInitThreads() returned 0 (failure- this program may fail)\n");
}
dpy = XOpenDisplay(displayName);
if (!dpy) {
fprintf(stderr, "Unable to open display %s\n", displayName);
return -1;
}
NumWinThreads = numThreads;
/* Create the GLX windows and contexts */
for (i = 0; i < numThreads; i++) {
WinThreads[i].Dpy = dpy;
WinThreads[i].Index = i;
create_window(&WinThreads[i]);
}
/* Create the threads */
for (i = 0; i < numThreads; i++) {
pthread_create(&WinThreads[i].Thread, NULL, thread_function,
(void*) &WinThreads[i]);
printf("Created Thread %p\n", WinThreads[i].Thread);
}
event_loop(dpy);
clean_up();
XCloseDisplay(dpy);
return 0;
}
#else /* PTHREADS */
#include <stdio.h>
int
main(int argc, char *argv[])
{
printf("Sorry, this program wasn't compiled with PTHREADS defined.\n");
return 0;
}
#endif /* PTHREADS */

1073
progs/xdemos/glxdpyinfo.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,286 +0,0 @@
/* $Id: glxheads.c,v 1.1 2000/06/13 19:41:30 brianp Exp $ */
/*
* Exercise multiple GLX connections on multiple X displays.
* Direct GLX contexts are attempted first, then indirect.
* Each window will display a spinning green triangle.
*
* Copyright (C) 2000 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <GL/gl.h>
#include <GL/glx.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/*
* Each display/window/context:
*/
struct head {
char DisplayName[1000];
Display *Dpy;
Window Win;
GLXContext Context;
float Angle;
char Renderer[1000];
char Vendor[1000];
char Version[1000];
};
#define MAX_HEADS 20
static struct head Heads[MAX_HEADS];
static int NumHeads = 0;
static void
Error(const char *display, const char *msg)
{
fprintf(stderr, "Error on display %s - %s\n", display, msg);
exit(1);
}
static struct head *
AddHead(const char *displayName)
{
Display *dpy;
Window win;
GLXContext ctx;
int attrib[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
None };
int scrnum;
XSetWindowAttributes attr;
unsigned long mask;
Window root;
XVisualInfo *visinfo;
int width = 300, height = 300;
int xpos = 10, ypos = 10;
if (NumHeads >= MAX_HEADS)
return NULL;
dpy = XOpenDisplay(displayName);
if (!dpy) {
Error(displayName, "Unable to open display");
return NULL;
}
scrnum = DefaultScreen(dpy);
root = RootWindow(dpy, scrnum);
visinfo = glXChooseVisual(dpy, scrnum, attrib);
if (!visinfo) {
Error(displayName, "Unable to find RGB, double-buffered visual");
return NULL;
}
/* window attributes */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow(dpy, root, 0, 0, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr);
if (!win) {
Error(displayName, "Couldn't create window");
return NULL;
}
{
XSizeHints sizehints;
sizehints.x = xpos;
sizehints.y = ypos;
sizehints.width = width;
sizehints.height = height;
sizehints.flags = USSize | USPosition;
XSetNormalHints(dpy, win, &sizehints);
XSetStandardProperties(dpy, win, displayName, displayName,
None, (char **)NULL, 0, &sizehints);
}
ctx = glXCreateContext(dpy, visinfo, NULL, True);
if (!ctx) {
Error(displayName, "Couldn't create GLX context");
return NULL;
}
XMapWindow(dpy, win);
if (!glXMakeCurrent(dpy, win, ctx)) {
Error(displayName, "glXMakeCurrent failed");
printf("glXMakeCurrent failed in Redraw()\n");
return;
}
/* save the info for this head */
{
struct head *h = &Heads[NumHeads];
strcpy(h->DisplayName, displayName);
h->Dpy = dpy;
h->Win = win;
h->Context = ctx;
h->Angle = 0.0;
strcpy(h->Version, (char *) glGetString(GL_VERSION));
strcpy(h->Vendor, (char *) glGetString(GL_VENDOR));
strcpy(h->Renderer, (char *) glGetString(GL_RENDERER));
NumHeads++;
return &Heads[NumHeads-1];
}
}
static void
Redraw(struct head *h)
{
if (!glXMakeCurrent(h->Dpy, h->Win, h->Context)) {
Error(h->DisplayName, "glXMakeCurrent failed");
printf("glXMakeCurrent failed in Redraw()\n");
return;
}
h->Angle += 1.0;
glShadeModel(GL_FLAT);
glClearColor(0.5, 0.5, 0.5, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
/* draw green triangle */
glColor3f(0.0, 1.0, 0.0);
glPushMatrix();
glRotatef(h->Angle, 0, 0, 1);
glBegin(GL_TRIANGLES);
glVertex2f(0, 0.8);
glVertex2f(-0.8, -0.7);
glVertex2f(0.8, -0.7);
glEnd();
glPopMatrix();
glXSwapBuffers(h->Dpy, h->Win);
}
static void
Resize(const struct head *h, unsigned int width, unsigned int height)
{
if (!glXMakeCurrent(h->Dpy, h->Win, h->Context)) {
Error(h->DisplayName, "glXMakeCurrent failed in Resize()");
return;
}
glFlush();
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
}
static void
EventLoop(void)
{
while (1) {
int i;
for (i = 0; i < NumHeads; i++) {
struct head *h = &Heads[i];
while (XPending(h->Dpy) > 0) {
XEvent event;
XNextEvent(h->Dpy, &event);
if (event.xany.window == h->Win) {
switch (event.type) {
case Expose:
Redraw(h);
break;
case ConfigureNotify:
Resize(h, event.xconfigure.width, event.xconfigure.height);
break;
case KeyPress:
return;
default:
/*no-op*/ ;
}
}
else {
printf("window mismatch\n");
}
}
Redraw(h);
}
usleep(1);
}
}
static void
PrintInfo(const struct head *h)
{
printf("Name: %s\n", h->DisplayName);
printf(" Display: 0x%x\n", h->Dpy);
printf(" Window: 0x%x\n", h->Win);
printf(" Context: 0x%x\n", h->Context);
printf(" GL_VERSION: %s\n", h->Version);
printf(" GL_VENDOR: %s\n", h->Vendor);
printf(" GL_RENDERER: %s\n", h->Renderer);
}
int
main(int argc, char *argv[])
{
int i;
if (argc == 1) {
struct head *h;
printf("glxheads: exercise multiple GLX connections (any key = exit)\n");
printf("Usage:\n");
printf(" glxheads xdisplayname ...\n");
printf("Example:\n");
printf(" glxheads :0 mars:0 venus:1\n");
h = AddHead(":0");
if (h)
PrintInfo(h);
}
else {
for (i = 1; i < argc; i++) {
const char *name = argv[i];
struct head *h = AddHead(name);
if (h) {
PrintInfo(h);
}
}
}
EventLoop();
return 0;
}

View File

@@ -1,153 +1,57 @@
/* $Id: glxinfo.c,v 1.10 2000/05/08 14:53:57 brianp Exp $ */
/*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* $Id: glxinfo.c,v 1.1 1999/09/16 16:40:46 brianp Exp $ */
/*
* This program is a work-alike of the IRIX glxinfo program.
* Command line options:
* -t print wide table
* -v print verbose information
* -display DisplayName specify the X display to interogate
*
* Brian Paul 26 January 2000
* Query GLX extensions, version, vendor, etc.
* This program is in the public domain.
* brian_paul@mesa3d.org
*/
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>
#include <GL/glu.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef enum
{
Normal,
Wide,
Verbose
} InfoMode;
struct visual_attribs
{
/* X visual attribs */
int id;
int klass;
int depth;
int redMask, greenMask, blueMask;
int colormapSize;
int bitsPerRGB;
/* GL visual attribs */
int supportsGL;
int transparent;
int bufferSize;
int level;
int rgba;
int doubleBuffer;
int stereo;
int auxBuffers;
int redSize, greenSize, blueSize, alphaSize;
int depthSize;
int stencilSize;
int accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize;
int numSamples, numMultisample;
int visualCaveat;
};
/*
* Print a list of extensions, with word-wrapping.
*/
static void
print_extension_list(const char *ext)
query_glx( Display *dpy, int scr )
{
const char *indentString = " ";
const int indent = 4;
const int max = 79;
int width, i, j;
printf("GL_VERSION: %s\n", (char *) glGetString(GL_VERSION));
printf("GL_EXTENSIONS: %s\n", (char *) glGetString(GL_EXTENSIONS));
printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VENDOR: %s\n", (char *) glGetString(GL_VENDOR));
printf("GLU_VERSION: %s\n", (char *) gluGetString(GLU_VERSION));
printf("GLU_EXTENSIONS: %s\n", (char *) gluGetString(GLU_EXTENSIONS));
if (!ext || !ext[0])
return;
printf("server GLX_VENDOR: %s\n", (char *) glXQueryServerString( dpy, scr, GLX_VENDOR));
printf("server GLX_VERSION: %s\n", (char *) glXQueryServerString( dpy, scr, GLX_VERSION));
printf("server GLX_EXTENSIONS: %s\n", (char *) glXQueryServerString( dpy, scr, GLX_EXTENSIONS));
width = indent;
printf(indentString);
i = j = 0;
while (1) {
if (ext[j] == ' ' || ext[j] == 0) {
/* found end of an extension name */
const int len = j - i;
if (width + len > max) {
/* start a new line */
printf("\n");
width = indent;
printf(indentString);
}
/* print the extension name between ext[i] and ext[j] */
while (i < j) {
printf("%c", ext[i]);
i++;
}
/* either we're all done, or we'll continue with next extension */
width += len + 1;
if (ext[j] == 0) {
break;
}
else {
i++;
j++;
if (ext[j] == 0)
break;
printf(", ");
width += 2;
}
}
j++;
}
printf("\n");
printf("client GLX_VENDOR: %s\n", (char *) glXGetClientString( dpy, GLX_VENDOR));
printf("client GLX_VERSION: %s\n", (char *) glXGetClientString( dpy, GLX_VERSION));
printf("client GLX_EXTENSIONS: %s\n", (char *) glXGetClientString( dpy, GLX_EXTENSIONS));
printf("GLX extensions: %s\n", (char *) glXQueryExtensionsString(dpy, scr));
}
static void
print_screen_info(Display *dpy, int scrnum)
{
Window win;
int attribSingle[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
None };
int attribDouble[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
None };
int
main( int argc, char *argv[] )
{
Display *dpy;
Window win;
int attrib[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
None };
int scrnum;
XSetWindowAttributes attr;
unsigned long mask;
Window root;
@@ -155,377 +59,40 @@ print_screen_info(Display *dpy, int scrnum)
XVisualInfo *visinfo;
int width = 100, height = 100;
root = RootWindow(dpy, scrnum);
visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
if (!visinfo) {
visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
if (!visinfo) {
fprintf(stderr, "Error: couldn't find RGB GLX visual\n");
return;
}
dpy = XOpenDisplay(NULL);
if (!dpy) {
fprintf(stderr, "Unable to open default display!\n");
return 1;
}
scrnum = DefaultScreen( dpy );
root = RootWindow( dpy, scrnum );
visinfo = glXChooseVisual( dpy, scrnum, attrib );
if (!visinfo) {
fprintf(stderr, "Error: couldn't find RGB GLX visual!\n");
return 1;
}
/* window attributes */
attr.background_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;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow(dpy, root, 0, 0, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr);
win = XCreateWindow( dpy, root, 0, 0, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr );
ctx = glXCreateContext( dpy, visinfo, NULL, True );
if (!ctx) {
fprintf(stderr, "Error: glXCreateContext failed\n");
XDestroyWindow(dpy, win);
return;
}
if (glXMakeCurrent(dpy, win, ctx)) {
const char *serverVendor = glXQueryServerString(dpy, scrnum, GLX_VENDOR);
const char *serverVersion = glXQueryServerString(dpy, scrnum, GLX_VERSION);
const char *serverExtensions = glXQueryServerString(dpy, scrnum, GLX_EXTENSIONS);
const char *clientVendor = glXGetClientString(dpy, GLX_VENDOR);
const char *clientVersion = glXGetClientString(dpy, GLX_VERSION);
const char *clientExtensions = glXGetClientString(dpy, GLX_EXTENSIONS);
const char *glxExtensions = glXQueryExtensionsString(dpy, scrnum);
const char *glVendor = (const char *) glGetString(GL_VENDOR);
const char *glRenderer = (const char *) glGetString(GL_RENDERER);
const char *glVersion = (const char *) glGetString(GL_VERSION);
const char *glExtensions = (const char *) glGetString(GL_EXTENSIONS);
const char *gluVersion = (const char *) gluGetString(GLU_VERSION);
const char *gluExtensions = (const char *) gluGetString(GLU_EXTENSIONS);
printf("display: %s screen:%d\n", DisplayString(dpy), scrnum);
printf("direct rendering: %s\n", glXIsDirect(dpy, ctx) ? "Yes" : "No");
printf("server glx vendor string: %s\n", serverVendor);
printf("server glx version string: %s\n", serverVersion);
printf("server glx extensions:\n");
print_extension_list(serverExtensions);
printf("client glx vendor string: %s\n", clientVendor);
printf("client glx version string: %s\n", clientVersion);
printf("client glx extensions:\n");
print_extension_list(clientExtensions);
printf("GLX extensions:\n");
print_extension_list(glxExtensions);
printf("OpenGL vendor string: %s\n", glVendor);
printf("OpenGL renderer string: %s\n", glRenderer);
printf("OpenGL version string: %s\n", glVersion);
printf("OpenGL extensions:\n");
print_extension_list(glExtensions);
printf("glu version: %s\n", gluVersion);
printf("glu extensions:\n");
print_extension_list(gluExtensions);
}
else {
fprintf(stderr, "Error: glXMakeCurrent failed\n");
}
glXMakeCurrent( dpy, win, ctx );
query_glx(dpy, scrnum);
glXDestroyContext(dpy, ctx);
XDestroyWindow(dpy, win);
}
static const char *
visual_class_name(int cls)
{
switch (cls) {
case StaticColor:
return "StaticColor";
case PseudoColor:
return "PseudoColor";
case StaticGray:
return "StaticGray";
case GrayScale:
return "GrayScale";
case TrueColor:
return "TrueColor";
case DirectColor:
return "DirectColor";
default:
return "";
}
}
static const char *
visual_class_abbrev(int cls)
{
switch (cls) {
case StaticColor:
return "sc";
case PseudoColor:
return "pc";
case StaticGray:
return "sg";
case GrayScale:
return "gs";
case TrueColor:
return "tc";
case DirectColor:
return "dc";
default:
return "";
}
}
static void
get_visual_attribs(Display *dpy, XVisualInfo *vInfo,
struct visual_attribs *attribs)
{
const char *ext = glXQueryExtensionsString(dpy, vInfo->screen);
memset(attribs, 0, sizeof(struct visual_attribs));
attribs->id = vInfo->visualid;
#if defined(__cplusplus) || defined(c_plusplus)
attribs->klass = vInfo->c_class;
#else
attribs->klass = vInfo->class;
#endif
attribs->depth = vInfo->depth;
attribs->redMask = vInfo->red_mask;
attribs->greenMask = vInfo->green_mask;
attribs->blueMask = vInfo->blue_mask;
attribs->colormapSize = vInfo->colormap_size;
attribs->bitsPerRGB = vInfo->bits_per_rgb;
if (glXGetConfig(dpy, vInfo, GLX_USE_GL, &attribs->supportsGL) != 0)
return;
glXGetConfig(dpy, vInfo, GLX_BUFFER_SIZE, &attribs->bufferSize);
glXGetConfig(dpy, vInfo, GLX_LEVEL, &attribs->level);
glXGetConfig(dpy, vInfo, GLX_RGBA, &attribs->rgba);
glXGetConfig(dpy, vInfo, GLX_DOUBLEBUFFER, &attribs->doubleBuffer);
glXGetConfig(dpy, vInfo, GLX_STEREO, &attribs->stereo);
glXGetConfig(dpy, vInfo, GLX_AUX_BUFFERS, &attribs->auxBuffers);
glXGetConfig(dpy, vInfo, GLX_RED_SIZE, &attribs->redSize);
glXGetConfig(dpy, vInfo, GLX_GREEN_SIZE, &attribs->greenSize);
glXGetConfig(dpy, vInfo, GLX_BLUE_SIZE, &attribs->blueSize);
glXGetConfig(dpy, vInfo, GLX_ALPHA_SIZE, &attribs->alphaSize);
glXGetConfig(dpy, vInfo, GLX_DEPTH_SIZE, &attribs->depthSize);
glXGetConfig(dpy, vInfo, GLX_STENCIL_SIZE, &attribs->stencilSize);
glXGetConfig(dpy, vInfo, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize);
glXGetConfig(dpy, vInfo, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize);
glXGetConfig(dpy, vInfo, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize);
glXGetConfig(dpy, vInfo, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize);
/* transparent pixel value not implemented yet */
attribs->transparent = 0;
/* multisample tests not implemented yet */
attribs->numSamples = 0;
attribs->numMultisample = 0;
#if defined(GLX_EXT_visual_rating)
if (ext && strstr(ext, "GLX_EXT_visual_rating")) {
glXGetConfig(dpy, vInfo, GLX_VISUAL_CAVEAT_EXT, &attribs->visualCaveat);
}
else {
attribs->visualCaveat = GLX_NONE_EXT;
}
#else
attribs->visualCaveat = 0;
#endif
}
static void
print_visual_attribs_verbose(const struct visual_attribs *attribs)
{
printf("Visual ID: %x depth=%d class=%s\n",
attribs->id, attribs->depth, visual_class_name(attribs->klass));
printf(" bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n",
attribs->bufferSize, attribs->level, attribs->rgba ? "rgba" : "ci",
attribs->doubleBuffer, attribs->stereo);
printf(" rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n",
attribs->redSize, attribs->greenSize,
attribs->blueSize, attribs->alphaSize);
printf(" auxBuffers=%d depthSize=%d stencilSize=%d\n",
attribs->auxBuffers, attribs->depthSize, attribs->stencilSize);
printf(" accum: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n",
attribs->accumRedSize, attribs->accumGreenSize,
attribs->accumBlueSize, attribs->accumAlphaSize);
printf(" multiSample=%d multiSampleBuffers=%d\n",
attribs->numSamples, attribs->numMultisample);
#ifdef GLX_EXT_visual_rating
if (attribs->visualCaveat == GLX_NONE_EXT || attribs->visualCaveat == 0)
printf(" visualCaveat=None\n");
else if (attribs->visualCaveat == GLX_SLOW_VISUAL_EXT)
printf(" visualCaveat=Slow\n");
else if (attribs->visualCaveat == GLX_NON_CONFORMANT_VISUAL_EXT)
printf(" visualCaveat=Nonconformant\n");
#endif
printf(" %s\n", attribs->transparent ? "Transparent." : "Opaque.");
}
static void
print_visual_attribs_short_header(void)
{
printf(" visual x bf lv rg d st colorbuffer ax dp st accumbuffer ms cav\n");
printf(" id dep cl sp sz l ci b ro r g b a bf th cl r g b a ns b eat\n");
printf("----------------------------------------------------------------------\n");
}
static void
print_visual_attribs_short(const struct visual_attribs *attribs)
{
char *caveat;
#ifdef GLX_EXT_visual_rating
if (attribs->visualCaveat == GLX_NONE_EXT || attribs->visualCaveat == 0)
caveat = "None";
else if (attribs->visualCaveat == GLX_SLOW_VISUAL_EXT)
caveat = "Slow";
else if (attribs->visualCaveat == GLX_NON_CONFORMANT_VISUAL_EXT)
caveat = "Ncon";
#else
caveat = "None";
#endif
printf("0x%2x %2d %2s %2d %2d %2d %1s %2s %2s %2d %2d %2d %2d %2d %2d %2d",
attribs->id,
attribs->depth,
visual_class_abbrev(attribs->klass),
attribs->transparent,
attribs->bufferSize,
attribs->level,
attribs->rgba ? "r" : "c",
attribs->doubleBuffer ? "y" : ".",
attribs->stereo ? "y" : ".",
attribs->redSize, attribs->greenSize,
attribs->blueSize, attribs->alphaSize,
attribs->auxBuffers,
attribs->depthSize,
attribs->stencilSize
);
printf(" %2d %2d %2d %2d %2d %1d %s\n",
attribs->accumRedSize, attribs->accumGreenSize,
attribs->accumBlueSize, attribs->accumAlphaSize,
attribs->numSamples, attribs->numMultisample,
caveat
);
}
static void
print_visual_attribs_long_header(void)
{
printf("Vis Vis Visual Trans buff lev render DB ste r g b a aux dep ste accum buffers MS MS\n");
printf(" ID Depth Type parent size el type reo sz sz sz sz buf th ncl r g b a num bufs\n");
printf("----------------------------------------------------------------------------------------------------\n");
}
static void
print_visual_attribs_long(const struct visual_attribs *attribs)
{
printf("0x%2x %2d %-11s %2d %2d %2d %4s %3d %3d %3d %3d %3d %3d",
attribs->id,
attribs->depth,
visual_class_name(attribs->klass),
attribs->transparent,
attribs->bufferSize,
attribs->level,
attribs->rgba ? "rgba" : "ci ",
attribs->doubleBuffer,
attribs->stereo,
attribs->redSize, attribs->greenSize,
attribs->blueSize, attribs->alphaSize
);
printf(" %3d %4d %2d %3d %3d %3d %3d %2d %2d\n",
attribs->auxBuffers,
attribs->depthSize,
attribs->stencilSize,
attribs->accumRedSize, attribs->accumGreenSize,
attribs->accumBlueSize, attribs->accumAlphaSize,
attribs->numSamples, attribs->numMultisample
);
}
static void
print_visual_info(Display *dpy, int scrnum, InfoMode mode)
{
XVisualInfo template;
XVisualInfo *visuals;
int numVisuals;
long mask;
int i;
/* get list of all visuals on this screen */
template.screen = scrnum;
mask = VisualScreenMask;
visuals = XGetVisualInfo(dpy, mask, &template, &numVisuals);
if (mode == Verbose) {
for (i = 0; i < numVisuals; i++) {
struct visual_attribs attribs;
get_visual_attribs(dpy, &visuals[i], &attribs);
print_visual_attribs_verbose(&attribs);
}
}
else if (mode == Normal) {
print_visual_attribs_short_header();
for (i = 0; i < numVisuals; i++) {
struct visual_attribs attribs;
get_visual_attribs(dpy, &visuals[i], &attribs);
print_visual_attribs_short(&attribs);
}
}
else if (mode == Wide) {
print_visual_attribs_long_header();
for (i = 0; i < numVisuals; i++) {
struct visual_attribs attribs;
get_visual_attribs(dpy, &visuals[i], &attribs);
print_visual_attribs_long(&attribs);
}
}
XFree(visuals);
}
int
main(int argc, char *argv[])
{
char *displayName = ":0";
Display *dpy;
int numScreens, scrnum;
InfoMode mode = Normal;
int i;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-display") == 0 && i + 1 < argc) {
displayName = argv[i + 1];
i++;
}
else if (strcmp(argv[i], "-t") == 0) {
mode = Wide;
}
else if (strcmp(argv[i], "-v") == 0) {
mode = Verbose;
}
}
dpy = XOpenDisplay(displayName);
if (!dpy) {
fprintf(stderr, "Error: unable to open display %s\n", displayName);
return -1;
}
numScreens = ScreenCount(dpy);
for (scrnum = 0; scrnum < numScreens; scrnum++) {
print_screen_info(dpy, scrnum);
printf("\n");
print_visual_info(dpy, scrnum, mode);
if (scrnum + 1 < numScreens)
printf("\n\n");
}
XCloseDisplay(dpy);
return 0;

View File

@@ -1,4 +1,4 @@
/* $Id: glxpixmap.c,v 1.2 2000/07/11 16:05:29 brianp Exp $ */
/* $Id: glxpixmap.c,v 1.1 1999/08/19 00:55:43 jtg Exp $ */
/*
@@ -9,11 +9,16 @@
*/
/*
* $Id: glxpixmap.c,v 1.1 1999/08/19 00:55:43 jtg Exp $
*/
#include <GL/gl.h>
#include <GL/glx.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static GLXContext ctx;
@@ -25,17 +30,11 @@ static GC gc;
static Window make_rgb_window( Display *dpy,
unsigned int width, unsigned int height )
{
const int sbAttrib[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
None };
const int dbAttrib[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
None };
int attrib[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
None };
int scrnum;
XSetWindowAttributes attr;
unsigned long mask;
@@ -45,13 +44,10 @@ static Window make_rgb_window( Display *dpy,
scrnum = DefaultScreen( dpy );
root = RootWindow( dpy, scrnum );
visinfo = glXChooseVisual( dpy, scrnum, (int *) sbAttrib );
visinfo = glXChooseVisual( dpy, scrnum, attrib );
if (!visinfo) {
visinfo = glXChooseVisual( dpy, scrnum, (int *) dbAttrib );
if (!visinfo) {
printf("Error: couldn't get an RGB visual\n");
exit(1);
}
printf("Error: couldn't get an RGB, Double-buffered visual\n");
exit(1);
}
/* window attributes */
@@ -69,33 +65,20 @@ static Window make_rgb_window( Display *dpy,
/* make an X GC so we can do XCopyArea later */
gc = XCreateGC( dpy, win, 0, NULL );
/* need indirect context */
ctx = glXCreateContext( dpy, visinfo, NULL, False );
if (!ctx) {
printf("Error: glXCreateContext failed\n");
exit(-1);
}
printf("Direct rendering: %s\n", glXIsDirect(dpy, ctx) ? "Yes" : "No");
ctx = glXCreateContext( dpy, visinfo, NULL, True );
return win;
}
static GLXPixmap make_pixmap( Display *dpy, Window win,
unsigned int width, unsigned int height,
Pixmap *pixmap)
unsigned int width, unsigned int height )
{
Pixmap pm;
GLXPixmap glxpm;
XWindowAttributes attr;
pm = XCreatePixmap( dpy, win, width, height, visinfo->depth );
if (!pm) {
printf("Error: XCreatePixmap failed\n");
exit(-1);
}
XGetWindowAttributes( dpy, win, &attr );
/*
@@ -106,25 +89,12 @@ static GLXPixmap make_pixmap( Display *dpy, Window win,
* into any kind of visual, not just TrueColor or DirectColor.
*/
#ifdef GLX_MESA_pixmap_colormap
if (strstr(glXQueryExtensionsString(dpy, 0), "GLX_MESA_pixmap_colormap")) {
/* stand-alone Mesa, specify the colormap */
glxpm = glXCreateGLXPixmapMESA( dpy, visinfo, pm, attr.colormap );
}
else {
glxpm = glXCreateGLXPixmap( dpy, visinfo, pm );
}
glxpm = glXCreateGLXPixmapMESA( dpy, visinfo, pm, attr.colormap );
#else
/* This will work with Mesa too if the visual is TrueColor or DirectColor */
glxpm = glXCreateGLXPixmap( dpy, visinfo, pm );
#endif
if (!glxpm) {
printf("Error: GLXCreateGLXPixmap failed\n");
exit(-1);
}
*pixmap = pm;
return glxpm;
}
@@ -158,16 +128,18 @@ int main( int argc, char *argv[] )
{
Display *dpy;
Window win;
Pixmap pm;
GLXPixmap glxpm;
GLXPixmap pm;
dpy = XOpenDisplay(NULL);
win = make_rgb_window( dpy, 300, 300 );
glxpm = make_pixmap( dpy, win, 300, 300, &pm );
pm = make_pixmap( dpy, win, 300, 300 );
glXMakeCurrent( dpy, glxpm, ctx );
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
#ifdef JUNK
glXMakeCurrent( dpy, win, ctx ); /*to make sure ctx is properly initialized*/
#endif
glXMakeCurrent( dpy, pm, ctx );
/* Render an image into the pixmap */
glShadeModel( GL_FLAT );
@@ -179,6 +151,8 @@ int main( int argc, char *argv[] )
glRectf( -0.75, -0.75, 0.75, 0.75 );
glFlush();
/* when a redraw is needed we'll just copy the pixmap image to the window */
XMapWindow( dpy, win );
event_loop( dpy, pm );

View File

@@ -1,289 +0,0 @@
/* $Id: manywin.c,v 1.1 2000/06/13 19:41:30 brianp Exp $ */
/*
* Create N GLX windows/contexts and render to them in round-robin
* order.
*
* Copyright (C) 2000 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <GL/gl.h>
#include <GL/glx.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/*
* Each display/window/context:
*/
struct head {
char DisplayName[1000];
Display *Dpy;
Window Win;
GLXContext Context;
float Angle;
char Renderer[1000];
char Vendor[1000];
char Version[1000];
};
#define MAX_HEADS 200
static struct head Heads[MAX_HEADS];
static int NumHeads = 0;
static void
Error(const char *display, const char *msg)
{
fprintf(stderr, "Error on display %s - %s\n", display, msg);
exit(1);
}
static struct head *
AddHead(const char *displayName, const char *name)
{
Display *dpy;
Window win;
GLXContext ctx;
int attrib[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
None };
int scrnum;
XSetWindowAttributes attr;
unsigned long mask;
Window root;
XVisualInfo *visinfo;
int width = 90, height = 90;
int xpos = 0, ypos = 0;
if (NumHeads >= MAX_HEADS)
return NULL;
dpy = XOpenDisplay(displayName);
if (!dpy) {
Error(displayName, "Unable to open display");
return NULL;
}
scrnum = DefaultScreen(dpy);
root = RootWindow(dpy, scrnum);
visinfo = glXChooseVisual(dpy, scrnum, attrib);
if (!visinfo) {
Error(displayName, "Unable to find RGB, double-buffered visual");
return NULL;
}
/* window attributes */
xpos = (NumHeads % 10) * 100;
ypos = (NumHeads / 10) * 100;
printf("%d, %d\n", xpos, ypos);
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow(dpy, root, xpos, ypos, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr);
if (!win) {
Error(displayName, "Couldn't create window");
return NULL;
}
{
XSizeHints sizehints;
sizehints.x = xpos;
sizehints.y = ypos;
sizehints.width = width;
sizehints.height = height;
sizehints.flags = USSize | USPosition;
XSetNormalHints(dpy, win, &sizehints);
XSetStandardProperties(dpy, win, name, name,
None, (char **)NULL, 0, &sizehints);
}
ctx = glXCreateContext(dpy, visinfo, NULL, True);
if (!ctx) {
Error(displayName, "Couldn't create GLX context");
return NULL;
}
XMapWindow(dpy, win);
if (!glXMakeCurrent(dpy, win, ctx)) {
Error(displayName, "glXMakeCurrent failed");
printf("glXMakeCurrent failed in Redraw()\n");
return;
}
/* save the info for this head */
{
struct head *h = &Heads[NumHeads];
strcpy(h->DisplayName, name);
h->Dpy = dpy;
h->Win = win;
h->Context = ctx;
h->Angle = 0.0;
strcpy(h->Version, (char *) glGetString(GL_VERSION));
strcpy(h->Vendor, (char *) glGetString(GL_VENDOR));
strcpy(h->Renderer, (char *) glGetString(GL_RENDERER));
NumHeads++;
return &Heads[NumHeads-1];
}
}
static void
Redraw(struct head *h)
{
if (!glXMakeCurrent(h->Dpy, h->Win, h->Context)) {
Error(h->DisplayName, "glXMakeCurrent failed");
printf("glXMakeCurrent failed in Redraw()\n");
return;
}
h->Angle += 1.0;
glShadeModel(GL_FLAT);
glClearColor(0.5, 0.5, 0.5, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
/* draw green triangle */
glColor3f(0.0, 1.0, 0.0);
glPushMatrix();
glRotatef(h->Angle, 0, 0, 1);
glBegin(GL_TRIANGLES);
glVertex2f(0, 0.8);
glVertex2f(-0.8, -0.7);
glVertex2f(0.8, -0.7);
glEnd();
glPopMatrix();
glXSwapBuffers(h->Dpy, h->Win);
}
static void
Resize(const struct head *h, unsigned int width, unsigned int height)
{
if (!glXMakeCurrent(h->Dpy, h->Win, h->Context)) {
Error(h->DisplayName, "glXMakeCurrent failed in Resize()");
return;
}
glFlush();
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
}
static void
EventLoop(void)
{
while (1) {
int i;
for (i = 0; i < NumHeads; i++) {
struct head *h = &Heads[i];
while (XPending(h->Dpy) > 0) {
XEvent event;
XNextEvent(h->Dpy, &event);
if (event.xany.window == h->Win) {
switch (event.type) {
case Expose:
Redraw(h);
break;
case ConfigureNotify:
Resize(h, event.xconfigure.width, event.xconfigure.height);
break;
case KeyPress:
return;
default:
/*no-op*/ ;
}
}
else {
printf("window mismatch\n");
}
}
Redraw(h);
}
usleep(1);
}
}
static void
PrintInfo(const struct head *h)
{
printf("Name: %s\n", h->DisplayName);
printf(" Display: 0x%x\n", h->Dpy);
printf(" Window: 0x%x\n", h->Win);
printf(" Context: 0x%x\n", h->Context);
printf(" GL_VERSION: %s\n", h->Version);
printf(" GL_VENDOR: %s\n", h->Vendor);
printf(" GL_RENDERER: %s\n", h->Renderer);
}
int
main(int argc, char *argv[])
{
int i;
if (argc == 1) {
struct head *h;
printf("manywin: open N simultaneous glx windows\n");
printf("Usage:\n");
printf(" manywin numWindows\n");
printf("Example:\n");
printf(" manywin 10\n");
return 0;
}
else {
int n = atoi(argv[1]);
printf("%d windows\n", n);
for (i = 0; i < n; i++) {
char name[100];
struct head *h;
sprintf(name, "%d", i);
h = AddHead(":0", name);
if (h) {
PrintInfo(h);
}
}
}
EventLoop();
return 0;
}

View File

@@ -1,4 +1,4 @@
/* $Id: shape.c,v 1.3 2000/06/27 15:34:35 brianp Exp $ */
/* $Id: shape.c,v 1.1 1999/08/19 00:55:43 jtg Exp $ */
/*
* Example of using the X "shape" extension with OpenGL: render a spinning
@@ -45,7 +45,7 @@ static void display(Display *dpy, Window win)
{
float scale = 1.7;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
@@ -53,9 +53,6 @@ static void display(Display *dpy, Window win)
glRotatef(Xangle, 1.0, 0.0, 0.0);
glRotatef(Yangle, 0.0, 1.0, 0.0);
/*
* wireframe box
*/
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINE_LOOP);
glVertex3f(-1.0, -1.0, -1.0);
@@ -78,62 +75,6 @@ static void display(Display *dpy, Window win)
glVertex3f(-1.0, 1.0, -1.0); glVertex3f(-1.0, 1.0, 1.0);
glEnd();
/*
* Solid box
*/
glPushMatrix();
glScalef(0.75, 0.75, 0.75);
glColor3f(1, 0, 0);
glBegin(GL_POLYGON);
glVertex3f(1, -1, -1);
glVertex3f(1, 1, -1);
glVertex3f(1, 1, 1);
glVertex3f(1, -1, 1);
glEnd();
glColor3f(0, 1, 1);
glBegin(GL_POLYGON);
glVertex3f(-1, -1, -1);
glVertex3f(-1, 1, -1);
glVertex3f(-1, 1, 1);
glVertex3f(-1, -1, 1);
glEnd();
glColor3f(0, 1, 0);
glBegin(GL_POLYGON);
glVertex3f(-1, 1, -1);
glVertex3f( 1, 1, -1);
glVertex3f( 1, 1, 1);
glVertex3f(-1, 1, 1);
glEnd();
glColor3f(1, 0, 1);
glBegin(GL_POLYGON);
glVertex3f(-1, -1, -1);
glVertex3f( 1, -1, -1);
glVertex3f( 1, -1, 1);
glVertex3f(-1, -1, 1);
glEnd();
glColor3f(0, 0, 1);
glBegin(GL_POLYGON);
glVertex3f(-1, -1, 1);
glVertex3f( 1, -1, 1);
glVertex3f( 1, 1, 1);
glVertex3f(-1, 1, 1);
glEnd();
glColor3f(1, 1, 0);
glBegin(GL_POLYGON);
glVertex3f(-1, -1, -1);
glVertex3f( 1, -1, -1);
glVertex3f( 1, 1, -1);
glVertex3f(-1, 1, -1);
glEnd();
glPopMatrix();
glPopMatrix();
glXSwapBuffers(dpy, win);
@@ -211,8 +152,6 @@ static void reshape(int width, int height)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -10.0);
glEnable(GL_DEPTH_TEST);
}
@@ -310,7 +249,6 @@ int main(int argc, char *argv[])
unsigned long winAttribsMask;
GLXContext glCtx;
int ignore;
const char *name = "OpenGL in a Shaped Window";
dpy = XOpenDisplay(NULL);
if (!dpy) {
@@ -354,27 +292,10 @@ int main(int argc, char *argv[])
visInfo->depth, InputOutput,
visInfo->visual,
winAttribsMask, &winAttribs);
{
XSizeHints sizehints;
/*
sizehints.x = xpos;
sizehints.y = ypos;
sizehints.width = width;
sizehints.height = height;
*/
sizehints.flags = 0;
XSetNormalHints(dpy, win, &sizehints);
XSetStandardProperties(dpy, win, name, name,
None, (char **)NULL, 0, &sizehints);
}
XMapWindow(dpy, win);
glXMakeCurrent(dpy, win, glCtx);
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("Press ESC to exit.\n");
printf("Press up/down to change window shape.\n");

View File

@@ -1,270 +0,0 @@
/* $Id: wincopy.c,v 1.1 1999/11/25 17:41:51 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.3
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* This program opens two GLX windows, renders into one and uses
* glCopyPixels to copy the image from the first window into the
* second by means of the GLX 1.3 function glxMakeContextCurrent().
* This function works just like the glXMakeCurrentReadSGI() function
* in the GLX_SGI_make_current_read extension.
*/
#include <GL/gl.h>
#include <GL/glx.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef GLX_VERSION_1_3
static Display *Dpy;
static int ScrNum;
static GLXContext Context;
static Window Win[2]; /* Win[0] = source, Win[1] = dest */
static GLint Width[2], Height[2];
static GLfloat Angle = 0.0;
static Window
CreateWindow(Display *dpy, int scrnum, XVisualInfo *visinfo,
int xpos, int ypos, int width, int height,
const char *name)
{
Window win;
XSetWindowAttributes attr;
unsigned long mask;
Window root;
root = RootWindow(dpy, scrnum);
/* window attributes */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow(dpy, root, xpos, ypos, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr);
if (win) {
XSizeHints sizehints;
sizehints.x = xpos;
sizehints.y = ypos;
sizehints.width = width;
sizehints.height = height;
sizehints.flags = USSize | USPosition;
XSetNormalHints(dpy, win, &sizehints);
XSetStandardProperties(dpy, win, name, name,
None, (char **)NULL, 0, &sizehints);
XMapWindow(dpy, win);
}
return win;
}
static void
Redraw(void)
{
/* make the first window the current one */
if (!glXMakeContextCurrent(Dpy, Win[0], Win[0], Context)) {
printf("glXMakeContextCurrent failed in Redraw()\n");
return;
}
Angle += 1.0;
glViewport(0, 0, Width[0], Height[0]);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glShadeModel(GL_FLAT);
glClearColor(0.5, 0.5, 0.5, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
/* draw blue quad */
glColor3f(0.3, 0.3, 1.0);
glPushMatrix();
glRotatef(Angle, 0, 0, 1);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.25);
glVertex2f( 0.5, -0.25);
glVertex2f( 0.5, 0.25);
glVertex2f(-0.5, 0.25);
glEnd();
glPopMatrix();
glXSwapBuffers(Dpy, Win[0]);
/* copy image from window 0 to window 1 */
if (!glXMakeContextCurrent(Dpy, Win[1], Win[0], Context)) {
printf("glXMakeContextCurrent failed in Redraw()\n");
return;
}
/* raster pos setup */
glViewport(0, 0, Width[1], Height[1]);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-1, 1, -1, 1, -1, 1);
glRasterPos2f(-1, -1);
/* copy the image between windows */
glDrawBuffer(GL_FRONT);
glCopyPixels(0, 0, Width[0], Height[0], GL_COLOR);
glDrawBuffer(GL_BACK);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
static void
Resize(Window win, unsigned int width, unsigned int height)
{
int i;
if (win == Win[0]) {
i = 0;
}
else {
i = 1;
}
Width[i] = width;
Height[i] = height;
if (!glXMakeCurrent(Dpy, Win[i], Context)) {
printf("glXMakeCurrent failed in Resize()\n");
return;
}
}
static void
EventLoop(void)
{
XEvent event;
while (1) {
if (XPending(Dpy) > 0) {
XNextEvent( Dpy, &event );
switch (event.type) {
case Expose:
Redraw();
break;
case ConfigureNotify:
Resize(event.xany.window, event.xconfigure.width, event.xconfigure.height);
break;
case KeyPress:
return;
default:
/*no-op*/ ;
}
}
else {
/* animate */
Redraw();
}
}
}
static void
Init(void)
{
XVisualInfo *visinfo;
int attrib[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
None };
Dpy = XOpenDisplay(NULL);
if (!Dpy) {
printf("Couldn't open default display!\n");
exit(1);
}
ScrNum = DefaultScreen(Dpy);
visinfo = glXChooseVisual(Dpy, ScrNum, attrib);
if (!visinfo) {
printf("Unable to find RGB, double-buffered visual\n");
exit(1);
}
Context = glXCreateContext(Dpy, visinfo, NULL, True);
if (!Context) {
printf("Couldn't create GLX context\n");
exit(1);
}
Win[0] = CreateWindow(Dpy, ScrNum, visinfo,
0, 0, 300, 300, "source window");
Win[1] = CreateWindow(Dpy, ScrNum, visinfo,
350, 0, 300, 300, "dest window");
}
int
main(int argc, char *argv[])
{
Init();
EventLoop();
return 0;
}
#else
int
main(int argc, char *argv[])
{
printf("This program requires GLX 1.3!\n");
return 0;
}
#endif /* GLX_VERSION_1_3 */

Some files were not shown because too many files have changed in this diff Show More